platina-core
Version:
UI Kit of SberMarketing
38 lines (37 loc) • 1.05 kB
TypeScript
export type EventHandler<T> = (type: keyof ComboboxDispatcher<T>, detail: ComboboxDispatcher<T>[keyof ComboboxDispatcher<T>]) => void;
export interface Props<T> {
selected: T[] | T;
multiple: boolean;
disabled: boolean;
config?: Config;
groupBy?: (option: T, index?: number) => string | number;
searchBy?: SearchBy<T>;
keyBy?: KeyBy<T>;
loadOptions?: AsyncOptions<T>;
}
export interface Config {
ctxKey: string;
}
export type KeyBy<T> = (option: T) => string;
export type SearchBy<T> = (option: T) => string;
export type State = Record<string, boolean>;
export type LoadOptionsParams = {
search: string;
skip: number;
take: number;
signal: AbortSignal;
};
export type LoadOptions<T> = (params: LoadOptionsParams) => Promise<T[]> | T[];
export type AsyncOptions<T> = {
callback: LoadOptions<T>;
pageSize?: number;
searchDebounce?: number;
};
export type ComboboxDispatcher<T> = {
blur: unknown;
select: T[] | T;
toggle: {
option: T;
state: unknown;
};
};