aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/forms/form/form.tsx
blob: 86481d23a286a2e36c739fb71062611e989007cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {
  type FormHTMLAttributes,
  forwardRef,
  type ForwardRefRenderFunction,
} from 'react';

export type FormRole = 'form' | 'search' | 'none' | 'presentation';

export type FormProps = FormHTMLAttributes<HTMLFormElement> & {
  /**
   * An accessible role.
   */
  role?: FormRole;
};

const FormWithRef: ForwardRefRenderFunction<HTMLFormElement, FormProps> = (
  { children, ...props },
  ref
) => (
  <form {...props} ref={ref}>
    {children}
  </form>
);

/**
 * Form component.
 */
export const Form = forwardRef(FormWithRef);