import type { CheckboxGroupState } from '@react-stately/checkbox'; import type { MutableRefObject } from 'react'; import type { TouchableOpacityProps } from 'react-native'; import type { IFormControlContext } from '../../composites/FormControl'; import type { InterfaceBoxProps } from '../Box'; import type { IIconProps } from '../Icon'; import type { IStackProps } from '../../primitives/Stack'; import type { CustomProps, ResponsiveValue, ThemeComponentSizeType, } from '../../../components/types'; import type { ColorSchemeType } from '../../../components/types'; export type ICheckboxValue = string; export interface InterfaceCheckbox extends InterfaceBoxProps { /** * assign id to checkbox */ id?: string; /** * The name of the input field in a checkbox. */ name?: string; /** * The value to be used in the checkbox input. This is the value that will be returned on form submission. */ value: ICheckboxValue; /** * The color of the radio when it's checked. This should be one of the color keys in the theme (e.g."green", "red"). */ colorScheme?: ColorSchemeType & ResponsiveValue<'default'>; /** * If true, the checkbox will be initially checked. (use defaultValue prop if using it inside Checkbox.Group) */ defaultIsChecked?: boolean; /** * If true, the checkbox will be checked. You'll need to pass onChange to update it's value (since it's now controlled). */ isChecked?: boolean; /** * If true, the checkbox will be indeterminate. This only affects the icon shown inside checkbox. */ isIndeterminate?: boolean; // isFullWidth?: boolean; /** * If true, the checkbox will be disabled. */ isDisabled?: boolean; /** * If true, the checkbox is marked as invalid. */ isInvalid?: boolean; /** * If true, the checkbox is marked as readonly. */ isReadOnly?: boolean; /** * If true, the checkbox will be hovered. */ isHovered?: boolean; /** * If true, the checkbox will be pressed. */ isPressed?: boolean; /** * If true, the checkbox will be focused. */ isFocused?: boolean; /** * If true, the checkbox focus ring will be visible. */ isFocusVisible?: boolean; /** * The size (width and height) of the checkbox. * @default 'md' */ size?: ThemeComponentSizeType<'Checkbox'>; /** * If given, will use this icon instead of the default. */ icon?: JSX.Element; /** * Passed props wilICheckboxGroupPropsl be applied on disabled state. */ _disabled?: Omit, '_disabled'>; /** * Passed props will be applied on checked state. */ _checked?: Omit, '_checked'>; /** * Passed props will be applied on unchecked state. */ _unchecked?: Omit, '_unchecked'>; /** * Passed props will be applied on focus state. */ _focus?: Omit, '_focus'>; /** * Passed props will be applied on hover state. */ _hover?: Omit, '_hover'>; /** * Passed props will be applied on invalid state. */ _invalid?: Omit, '_invalid'>; /** * Passed props will be applied on pressed state on native. */ _pressed?: Omit, '_pressed'>; /** * Passed props will be applied on readonly state. */ _readOnly?: Omit, '_readOnly'>; /** * Icon related props can be passed in _icon. */ _icon?: Partial; /** * You can style interaction box around the checkbox using this. */ _interactionBox?: Omit, '_interactionBox'>; /** * Props to be passed to the Stack used inside. */ _stack?: Partial; /** * Function called when the state of the checkbox changes. */ onChange?: (isSelected: boolean) => void; // onBlur?: (event: any) => void; // onFocus?: (event: any) => void; // ariaLabelledby?: string; /** * Ref to be passed to Icon's wrapper Box */ wrapperRef?: any; ref?: MutableRefObject; } export interface ICheckboxGroupProps extends InterfaceBoxProps { /** * assign id to checkbox group */ id?: string; /** * The value of the checkbox group. */ value?: Array; /** * The initial value of the checkbox group. */ defaultValue?: Array; /** * The color of the radio when it's checked. This should be one of the color keys in the theme (e.g."green", "red"). */ colorScheme?: ColorSchemeType; /** * The size (width and height) of the checkbox. */ size?: ResponsiveValue<'sm' | 'md' | 'lg'>; /** * The callback fired when any children Checkbox is checked or unchecked. */ onChange?: (values: any) => any; /** * Pass props will be passed to each checkbox. */ _checkbox?: Partial; } export interface ICheckboxContext extends IFormControlContext { colorScheme?: ColorSchemeType; size?: ResponsiveValue<'sm' | 'md' | 'lg'>; state: CheckboxGroupState; } export interface IUseCheckboxReturnType { inputProps: { checked: boolean; } & Partial; } export interface IUseCheckboxGroupReturnType { checkboxGroupProps: { onChange: (checkboxValue: ICheckboxValue, isChecked: boolean) => any; values: Array; }; } export type ICheckboxComponentType = (( props: ICheckboxProps ) => JSX.Element) & { Group: React.MemoExoticComponent< (props: ICheckboxGroupProps, ref?: MutableRefObject) => JSX.Element >; }; export type ICheckboxProps = InterfaceCheckbox & CustomProps<'Checkbox'>;