import { Key, Keyed, Optional } from '@synnaxlabs/x';

/**
 * Extra information passed as an additional argument to the `onChange` callback.
 * of the {@link useSelect} hook.
 */
export interface UseSelectOnChangeExtra<K extends Key = Key, E extends Keyed<K> = Keyed<K>> {
    clickedIndex: number | null;
    /** The key of the entry that was last clicked. */
    clicked: K | null;
    /** The entries that are currently selected. */
    entries: E[];
}
export interface UseSelectSingleAllowNoneProps<K extends Key, E extends Keyed<K>> {
    data: E[];
    replaceOnSingle?: boolean;
    allowMultiple: false;
    allowNone?: true | undefined;
    value: K | null;
    onChange: (next: K | null, extra: UseSelectOnChangeExtra<K, E>) => void;
}
export interface UseSelectSingleDisallowNoneProps<K extends Key, E extends Keyed<K>> {
    data: E[];
    replaceOnSingle?: boolean;
    allowMultiple: false;
    allowNone: false;
    value: K;
    onChange: (next: K, extra: UseSelectOnChangeExtra<K, any>) => void;
}
type UseSelectSingleInternalProps<K extends Key, E extends Keyed<K>> = UseSelectSingleAllowNoneProps<K, E> | UseSelectSingleDisallowNoneProps<K, E>;
export type UseSelectSingleProps<K extends Key, E extends Keyed<K>> = Optional<UseSelectSingleInternalProps<K, E>, "allowNone">;
export interface UseSelectMultipleProps<K extends Key, E extends Keyed<K>> {
    data: E[] | (() => E[]);
    allowMultiple?: true;
    replaceOnSingle?: boolean;
    allowNone?: boolean;
    value: K | K[];
    onChange: (next: K[], extra: UseSelectOnChangeExtra<K, E>) => void;
}
/** Props for the {@link useSelect} hook. */
export type UseSelectProps<K extends Key = Key, E extends Keyed<K> = Keyed<K>> = UseSelectSingleInternalProps<K, E> | UseSelectMultipleProps<K, E>;
/** Return value for the {@link useSelect} hook. */
export interface UseSelectMultipleReturn<K extends Key = Key> {
    onSelect: (key: K) => void;
    clear: () => void;
}
export declare const selectValueIsZero: <K extends Key>(value: K | K[] | null) => value is K[] | null;
/**
 * Implements generic selection over a collection of keyed records. The hook
 * does not maintain internal selection state, but instead relies on the `value` and
 * `onChange` props to manage the selection state. This allows the hook to be used
 * with any selection state implementation, such as a React state hook or a Redux
 * store.
 *
 * The hook also supports shift-selection of a range. This means that the data passed in
 * must be in the same order/cardinality as the data that is displayed.
 *
 * It's important to note that the hook implements the InputControl interface, which
 *  means that it can be used as a controlled input in a form.
 *
 * @param props - The props for the hook.
 * @param props.data - The data to select from.
 * @param props.value - The current selection state.
 * @param props.onChange - The callback to invoke when the selection state changes.
 * @param props.allowMultiple - Whether to allow multiple selections.
 *
 * @returns transform - A transform that can be used to add a `selected` property to
 * each record in the data.
 * @returns onSelect - A callback that can be used to select a record. This should
 * probably be passed to the `onClick` corresponding to each record.
 * @returns clear - A callback that can be used to clear the selection.
 */
export declare const useSelect: <K extends Key, E extends Keyed<K>>({ data: propsData, value: propsValue, allowMultiple, allowNone, replaceOnSingle, onChange, }: UseSelectProps<K, E>) => UseSelectMultipleReturn<K>;
export {};
//# sourceMappingURL=useSelect.d.ts.map