import { type Accessor, createContext, useContext } from "solid-js"; export interface CheckboxDataSet { "data-checked": string | undefined; "data-indeterminate": string | undefined; } export interface CheckboxContextValue { value: Accessor; dataset: Accessor; checked: Accessor; indeterminate: Accessor; inputRef: Accessor; generateId: (part: string) => string; toggle: () => void; setIsChecked: (isChecked: boolean) => void; setIsFocused: (isFocused: boolean) => void; setInputRef: (el: HTMLInputElement) => void; } export const CheckboxContext = createContext(); export function useCheckboxContext() { const context = useContext(CheckboxContext); if (context === undefined) { throw new Error( "[kobalte]: `useCheckboxContext` must be used within a `Checkbox` component", ); } return context; }