import type { JSX } from 'solid-js'; export interface SelectStateProperties { isSelected: (value: T) => boolean; select: (value: T) => void; hasSelected: () => boolean; isActive: (value: T) => boolean; hasActive: () => boolean; focus: (value: T) => void; blur: () => void; disabled: () => boolean; } export interface SingleSelectStateControlledOptions { multiple?: false; toggleable?: boolean; /** `undefined` means nothing is selected, which is also what `toggleable` produces. */ value: T | undefined; onChange?: (value?: T) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export interface SingleSelectStateUncontrolledOptions { multiple?: false; toggleable?: boolean; /** `undefined` starts with nothing selected. */ defaultValue: T | undefined; onChange?: (value?: T) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export type SingleSelectStateOptions = SingleSelectStateControlledOptions | SingleSelectStateUncontrolledOptions; /** * Creates a selection state that holds at most one value, and tracks which * value is active. Backs `Accordion`, `Select`, `Listbox`, `RadioGroup` and * `TabGroup`. * * Pass `by` when the values are objects, since the default comparison is by * reference. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#select-state} */ export declare function createSingleSelectState(options: SingleSelectStateOptions): SelectStateProperties; export interface MultipleSelectStateControlledOptions { multiple: true; toggleable?: boolean; value: T[]; onChange?: (value: T[]) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export interface MultipleSelectStateUncontrolledOptions { multiple: true; toggleable?: boolean; defaultValue: T[]; onChange?: (value: T[]) => void; disabled?: boolean; by?: (a: T, b: T) => boolean; } export type MultipleSelectStateOptions = MultipleSelectStateControlledOptions | MultipleSelectStateUncontrolledOptions; /** * Creates a selection state that holds an array of values, and tracks which * value is active. Requires `multiple: true`. * * Pass `by` when the values are objects, since the default comparison is by * reference. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#select-state} */ export declare function createMultipleSelectState(options: MultipleSelectStateOptions): SelectStateProperties; export interface SelectStateRenderProps { children?: JSX.Element | ((state: SelectStateProperties) => JSX.Element); } export interface SelectStateProviderProps extends SelectStateRenderProps { state: SelectStateProperties; } export declare function SelectStateProvider(props: SelectStateProviderProps): JSX.Element; /** * Reads the nearest select state from context. Throws when there is none. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#select-state} */ export declare function useSelectState(): SelectStateProperties; /** * Passes the nearest select state to a render prop. A function child is * treated as a render prop only when it declares exactly one parameter. * * @see {@link https://github.com/lxsmnsyc/terracotta/blob/main/docs/states.md#select-state} */ export declare function SelectStateChild(props: SelectStateRenderProps): JSX.Element; //# sourceMappingURL=create-select-state.d.ts.map