( props: CheckboxProps | CheckboxFieldProps, userProvidedInputRef: RefObject<HTMLInputElement | null> | null )
| 428 | }); |
| 429 | |
| 430 | function useCheckboxAria( |
| 431 | props: CheckboxProps | CheckboxFieldProps, |
| 432 | userProvidedInputRef: RefObject<HTMLInputElement | null> | null |
| 433 | ): [CheckboxAria, RefObject<HTMLInputElement | null>] { |
| 434 | let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {}; |
| 435 | let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native'; |
| 436 | let groupState = useContext(CheckboxGroupStateContext); |
| 437 | let inputRef = useObjectRef( |
| 438 | useMemo( |
| 439 | () => mergeRefs(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null), |
| 440 | [userProvidedInputRef, props.inputRef] |
| 441 | ) |
| 442 | ); |
| 443 | let checkboxProps = { |
| 444 | ...removeDataAttributes(props), |
| 445 | children: typeof props.children === 'function' ? true : props.children, |
| 446 | value: props.value!, |
| 447 | validationBehavior |
| 448 | }; |
| 449 | |
| 450 | let aria = groupState |
| 451 | ? // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks |
| 452 | useCheckboxGroupItem(checkboxProps, groupState, inputRef) |
| 453 | : // oxlint-disable-next-line react/react-compiler, react-hooks/rules-of-hooks |
| 454 | useCheckbox(checkboxProps, useToggleState(props), inputRef); |
| 455 | return [aria, inputRef]; |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * A checkbox allows a user to select multiple items from a list of individual items, or |
no test coverage detected