diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/components/atoms/forms/form.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (diff) | |
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should
use default exports. Everything else should use named exports to
reduce the number of import statements.
Diffstat (limited to 'src/components/atoms/forms/form.tsx')
| -rw-r--r-- | src/components/atoms/forms/form.tsx | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/components/atoms/forms/form.tsx b/src/components/atoms/forms/form.tsx index 3307153..85ff8fd 100644 --- a/src/components/atoms/forms/form.tsx +++ b/src/components/atoms/forms/form.tsx @@ -1,24 +1,22 @@ -import { Children, FC, FormEvent, Fragment, ReactNode } from 'react'; +import { + Children, + FC, + FormEvent, + FormHTMLAttributes, + Fragment, + ReactNode, +} from 'react'; import styles from './forms.module.scss'; -export type FormProps = { - /** - * An accessible name. - */ - 'aria-label'?: string; - /** - * One or more ids that refers to the form name. - */ - 'aria-labelledby'?: string; +export type FormProps = Omit< + FormHTMLAttributes<HTMLFormElement>, + 'onSubmit' +> & { /** * The form body. */ children: ReactNode; /** - * Set additional classnames to the form wrapper. - */ - className?: string; - /** * Wrap each items with a div. Default: true. */ grouped?: boolean; @@ -37,7 +35,7 @@ export type FormProps = { * * Render children wrapped in a form element. */ -const Form: FC<FormProps> = ({ +export const Form: FC<FormProps> = ({ children, grouped = true, itemsClassName = '', @@ -75,10 +73,8 @@ const Form: FC<FormProps> = ({ }; return ( - <form onSubmit={handleSubmit} {...props}> + <form {...props} onSubmit={handleSubmit}> {getFormItems()} </form> ); }; - -export default Form; |
