ol-form-text.tsx 942 B

123456789101112131415161718192021222324252627282930
  1. import FormText, {
  2. FormTextProps,
  3. getFormTextClass,
  4. } from '@/features/ui/components/bootstrap-5/form/form-text'
  5. import PolymorphicComponent from '@/shared/components/polymorphic-component'
  6. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  7. import classnames from 'classnames'
  8. type OLFormTextProps = FormTextProps & {
  9. bs3Props?: Record<string, unknown>
  10. }
  11. function OLFormText({ as = 'div', ...props }: OLFormTextProps) {
  12. const { bs3Props, ...rest } = props
  13. const bs3HelpBlockProps = {
  14. children: rest.children,
  15. className: classnames('small', rest.className, getFormTextClass(rest.type)),
  16. ...bs3Props,
  17. } as const satisfies React.ComponentProps<typeof PolymorphicComponent>
  18. return (
  19. <BootstrapVersionSwitcher
  20. bs3={<PolymorphicComponent {...bs3HelpBlockProps} as={as} />}
  21. bs5={<FormText {...rest} as={as} />}
  22. />
  23. )
  24. }
  25. export default OLFormText