UNPKG

@tabula/ui-multi-selector

Version:

A MultiSelector allows users to select one or more items from a list of choices, or suggest own item.

30 lines (29 loc) 1.09 kB
import { ComponentType, ReactNode } from 'react'; export type Option = string | { icon?: IconComponent; label?: string; value: string; }; export type Selected = Set<string>; export type CompleteKey = 'Enter' | 'Tab'; export type AddChangeType = 'add' | 'add-all' | 'add-found' | 'add-custom'; export type RemoveChangeType = 'remove' | 'remove-all'; export type ChangeType = AddChangeType | RemoveChangeType; export type ChangeHandler = (selected: Selected, type: ChangeType, difference: Selected) => void; export type UpdateHandler = (type: ChangeType, values: string[]) => void; export type SearchHandler = (search: string) => void; export type TagRenderer = (className: string, option: Option) => ReactNode; export type DropdownController = { goToNext: () => void; goToPrevious: () => void; selectCurrent: () => void; }; export type IconComponent = ComponentType<{ className?: string; }>; export type BatchAction = string | { icon?: IconComponent; label: string; }; export type Size = 'small' | 'medium'; export type Variant = 'accent' | 'contrast';