@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
37 lines (36 loc) • 1.62 kB
TypeScript
import * as React from "react";
interface GenericGroupContext {
value: string | string[];
onChange: (newState: boolean, itemValue: string) => void;
items?: [string, React.RefObject<HTMLButtonElement>][];
}
interface CheckBaseProps {
strategy?: "check-control" | "radio-control";
enterKeyFunctionality?: "request-form-submit" | "check";
keyboardActivationBehavior?: "manual" | "automatic";
value?: string;
groupCtx?: GenericGroupContext;
checked?: boolean;
toggle?: boolean;
defaultChecked?: boolean;
disabled?: boolean;
autoFocus?: boolean;
onChange?: (checkedState: boolean) => void;
onBlur?: React.FocusEventHandler<HTMLButtonElement>;
onFocus?: React.FocusEventHandler<HTMLButtonElement>;
onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;
onKeyUp?: React.KeyboardEventHandler<HTMLButtonElement>;
}
declare const useCheckBase: (props: CheckBaseProps) => {
checked: boolean;
isFocusedVisible: boolean;
controllerRef: React.MutableRefObject<HTMLButtonElement | undefined>;
emitChange: (newChecked: boolean) => void;
handleBlur: (event: React.FocusEvent<HTMLButtonElement, Element>) => void;
handleClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
handleFocus: (event: React.FocusEvent<HTMLButtonElement, Element>) => void;
handleKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
handleKeyUp: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
handleControllerRef: (instance: HTMLButtonElement | null | undefined) => void;
};
export default useCheckBase;