@vtex/admin-ui
Version:
> VTEX admin component library
38 lines (37 loc) • 1.94 kB
TypeScript
import type { Dispatch, SetStateAction, ReactNode } from 'react';
import type { ComboboxStateProps as AriakitComboboxStateProps, ComboboxState as AriakitComboboxState } from 'ariakit/combobox';
export declare function useComboboxState<T>(props?: ComboboxStateProps<T>): ComboboxState<T>;
declare type Status = 'loading' | 'error' | 'empty-search' | 'no-result' | 'ready';
export declare type ComboboxStateProps<T> = Pick<AriakitComboboxStateProps, 'virtualFocus'> & {
/** Initial list of values that will be filtered on search, should be set unless the input will be controlled */
list?: T[];
/** Function for transforming item shape into a string value, no need to use it on string[] lists */
getOptionValue?: (item: T) => string;
/** Function for transforming item shape into renderable node, no need to use it on string[] lists */
renderOption?: (item: T) => ReactNode;
/** Debounce interval */
timeoutMs?: number;
};
export declare type ComboboxState<T> = Omit<AriakitComboboxState, 'matches'> & {
/** Debounced value. */
deferredValue: string;
/** Sets component state to error */
setError: Dispatch<SetStateAction<boolean>>;
/** Sets component state to loading */
setLoading: Dispatch<SetStateAction<boolean>>;
/** Component status */
status: Status;
/** Function that gets text value from the items in matches or list */
getOptionValue: (item: T) => string;
/** Function that render items from matches or list */
renderOption: (item: T) => ReactNode;
/** Array of options that matched with the input value */
matches: T[];
/** Setter for array of options that matched with the input value */
setMatches: (arg: T[]) => void;
/** Full value of current selected item */
selectedItem: T | undefined;
/** Setter for current selected item */
setSelectedItem: (arg?: T) => void;
};
export {};