import type { ForwardedRef } from 'react'; import React from 'react'; import { forwardRef } from 'react'; import type { Complete, Exact } from '../../../types'; import { destruct } from '../../../utils/destruct'; import { omit } from '../../../utils/omit'; import { pick } from '../../../utils/pick'; import type { FormRowProps } from '../../FormRow/FormRow'; import { FormRow } from '../../FormRow/FormRow'; import type { FormRowHelperTextOwnProps } from '../../FormRow/FormRowHelperText'; import type { CheckboxProps } from '../../Inputs/Checkbox/Checkbox'; import { Checkbox } from '../../Inputs/Checkbox/Checkbox'; import type { LabelAfterProps } from '../../LabelAfter/LabelAfter'; import { LabelAfter } from '../../LabelAfter/LabelAfter'; export interface CheckboxFieldContainerProps extends Omit< FormRowProps, 'children' | 'htmlFor' | 'isFullWidth' | 'label' > {} export interface CheckboxFieldHelperTextProps extends Partial {} export interface CheckboxFieldInputProps extends Omit< CheckboxProps, 'type' | 'loading' | 'width' | 'error' | 'warning' > {} export interface CheckboxFieldProps extends CheckboxFieldContainerProps, CheckboxFieldHelperTextProps, CheckboxFieldInputProps { /** * The label to display after the checkbox. */ labelAfter?: LabelAfterProps['label']; } export const CheckboxField = forwardRef(function CheckboxField( props: CheckboxFieldProps, forwardedRef: ForwardedRef ) { const [formRowProps, helperTextProps, inputProps] = destruct( props, ['as', 'justify', 'labelHidden', 'required', 'tooltip'], ['error', 'hint', 'warning'] ); formRowProps satisfies Exact, typeof formRowProps>; helperTextProps satisfies Exact, typeof helperTextProps>; inputProps satisfies Exact< Complete & Pick>, typeof inputProps >; return (
{inputProps.labelAfter && }
); });