@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
63 lines (62 loc) • 1.95 kB
TypeScript
import { HTMLProps, HTMLRefAttributes, PropGetter } from "../../core/components/index.types.js";
import "../../core/index.js";
import { FieldProps } from "../field/field.js";
import { ChangeEvent, ChangeEventHandler, FocusEventHandler } from "react";
//#region src/components/checkbox/use-checkbox.d.ts
interface UseCheckboxProps<Y extends string = string> extends Omit<HTMLProps<"label">, "onBlur" | "onChange" | "onFocus" | "ref">, HTMLRefAttributes<"input">, FieldProps {
/**
* id assigned to input.
*/
id?: string;
/**
* The name of the input field in a checkbox.
*/
name?: string;
/**
* If `true`, the checkbox will be checked.
*/
checked?: boolean;
/**
* If `true`, the checkbox will be initially checked.
*
* @default false
*/
defaultChecked?: boolean;
/**
* If `true`, the checkbox will be indeterminate.
*
* @default false
*/
indeterminate?: boolean;
/**
* The value of the checkbox.
*/
value?: Y;
/**
* The callback invoked when the checkbox is blurred.
*/
onBlur?: FocusEventHandler<HTMLInputElement>;
/**
* The callback invoked when the checked state changes.
*/
onChange?: ChangeEventHandler<HTMLInputElement>;
/**
* The callback invoked when the checkbox is focused.
*/
onFocus?: FocusEventHandler<HTMLInputElement>;
}
declare const useCheckbox: <Y extends string = string>({
"aria-describedby": ariaDescribedbyProp,
...props
}?: UseCheckboxProps<Y>) => {
checked: boolean;
indeterminate: boolean;
getIndicatorProps: PropGetter<"div", undefined, undefined>;
getInputProps: PropGetter<"input", undefined, undefined>;
getRootProps: PropGetter<"label", undefined, undefined>;
onChange: (ev: ChangeEvent<HTMLInputElement>) => true | undefined;
};
type UseCheckboxReturn = ReturnType<typeof useCheckbox>;
//#endregion
export { UseCheckboxProps, UseCheckboxReturn, useCheckbox };
//# sourceMappingURL=use-checkbox.d.ts.map