ol-form-control.tsx 875 B

123456789101112131415161718192021222324252627282930
  1. import { forwardRef } from 'react'
  2. import FormControl, {
  3. type OLBS5FormControlProps,
  4. } from '@/features/ui/components/bootstrap-5/form/form-control'
  5. import OLSpinner from '@/features/ui/components/ol/ol-spinner'
  6. import type { BsPrefixRefForwardingComponent } from 'react-bootstrap-5/helpers'
  7. type OLFormControlProps = OLBS5FormControlProps & {
  8. 'data-ol-dirty'?: unknown
  9. 'main-field'?: any // For the CM6's benefit in the editor search panel
  10. loading?: boolean
  11. }
  12. const OLFormControl: BsPrefixRefForwardingComponent<
  13. 'input',
  14. OLFormControlProps
  15. > = forwardRef<HTMLInputElement, OLFormControlProps>((props, ref) => {
  16. const { append, ...rest } = props
  17. return (
  18. <FormControl
  19. ref={ref}
  20. {...rest}
  21. append={rest.loading ? <OLSpinner size="sm" /> : append}
  22. />
  23. )
  24. })
  25. OLFormControl.displayName = 'OLFormControl'
  26. export default OLFormControl