@vtex/admin-ui
Version:
> VTEX admin component library
41 lines (40 loc) • 1.39 kB
TypeScript
import React from 'react';
import type { ListState } from '@react-stately/list';
import type { PickerStateReturn } from '../picker';
export declare function useBaseFilterState(props: UseBaseFilterStateProps): UseFilterMultipleReturn;
export declare type Key = string | number;
export interface FilterItem {
id: Key;
label: string;
[x: string]: unknown;
}
export interface GenericFilterStateReturn {
popover: PickerStateReturn;
onClear: () => void;
onChange: () => void;
ref: React.MutableRefObject<any>;
listBoxProps: React.HTMLAttributes<HTMLElement>;
labelProps: React.HTMLAttributes<HTMLElement>;
listState: ListState<FilterItem>;
label: string;
}
export interface UseFilterMultipleReturn extends GenericFilterStateReturn {
appliedItems: FilterItem[];
appliedKeys: Key[];
selectedKeys: Key[];
}
export interface UseFilterMultipleStateProps {
/** Function called when a change is applied. */
onChange?: ({ selected }: {
selected: Key[];
}) => void;
/** The initial selected keys. */
initialApplied?: Key[];
/** Filter button label. */
label: string;
items: FilterItem[];
}
export interface UseBaseFilterStateProps extends UseFilterMultipleStateProps {
/** set to multiple if filter is multiselect. */
selectionMode: 'multiple' | 'single';
}