Skip to content

Commit

Permalink
refactor: define FormFieldCheckbox properties in a way where optional…
Browse files Browse the repository at this point in the history
… fields are more resiliently defined
  • Loading branch information
Robbert committed Nov 24, 2024
1 parent a01401a commit 2ceb531
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions packages/components-react/form-field-checkbox-react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,26 @@ import type { ForwardedRef, PropsWithChildren, ReactNode, Ref } from 'react';
import { forwardRef, useId } from 'react';

export interface FormFieldCheckboxProps
extends Omit<FormFieldProps, 'onBlur' | 'onChange' | 'onFocus' | 'onInput' | 'type'>,
Pick<
CheckboxProps,
| 'checked'
| 'defaultChecked'
| 'defaultValue'
| 'disabled'
| 'indeterminate'
| 'inputRequired'
| 'invalid'
| 'name'
| 'onBlur'
| 'onChange'
| 'onFocus'
| 'onInput'
| 'required'
| 'value'
> {
extends Omit<FormFieldProps, 'onBlur' | 'onChange' | 'onFocus' | 'onInput' | 'type'> {
checked?: CheckboxProps['checked'];
defaultChecked?: CheckboxProps['defaultChecked'];
defaultValue?: CheckboxProps['defaultValue'];
description?: ReactNode;
disabled?: CheckboxProps['disabled'];
errorMessage?: ReactNode;
indeterminate?: CheckboxProps['indeterminate'];
inputRef?: Ref<HTMLInputElement>;
inputRequired?: CheckboxProps['inputRequired'];
invalid?: CheckboxProps['invalid'];
label: ReactNode;
name?: CheckboxProps['name'];
onBlur?: CheckboxProps['onBlur'];
onChange?: CheckboxProps['onChange'];
onFocus?: CheckboxProps['onFocus'];
onInput?: CheckboxProps['onInput'];
required?: CheckboxProps['required'];
status?: ReactNode;
value?: CheckboxProps['value'];
}

export const FormFieldCheckbox = forwardRef(
Expand Down

0 comments on commit 2ceb531

Please sign in to comment.