import { ReactNode } from "react"; import { ILoadable, ILocalizable } from "./Base"; import { IInputField } from "./Input"; interface IBaseSelect extends ILocalizable, ILoadable, IInputField { /** * Enables autocomplete feature */ autoComplete?: boolean; /** * Automatically sorts options in alphabetical order (localeCompare) */ autoSort?: boolean; /** * Method to allow custom rendering of each option */ customOptionRendering?: (option: T, selected: boolean) => ReactNode; /** * Method to determine group label from group name */ getGroupLabel?: (groupName: string) => string; /** * Method to extract option label from option */ getOptionLabel?: (option: T) => string; /** * Method to determine currently selected option */ getOptionSelected?: (option: T, value: T) => boolean; /** * Method to group options using one option property */ groupBy?: (option: T) => string; /** * Callback for close event */ onClose?: () => void; /** * Callback for change event on input field */ onInputChange?: (input: string) => void; /** * Callback for scrollEnd event on options list */ onScrollEnd?: () => void; /** * List of available options */ options: T[]; /** * Width of options list popup */ popperWidth?: number; } type SingleSelectDataType = T | null; interface ISelectSingle extends IBaseSelect { /** * Enables multiple mode */ multiple: false; onChange: (value: SingleSelectDataType) => void; value?: SingleSelectDataType; } type MultipleSelectDataType = T[] | null; interface ISelectMultiple extends IBaseSelect { /** * Enables multiple mode */ multiple: true; onChange: (value: MultipleSelectDataType) => void; value?: MultipleSelectDataType; } export type ISelect = ISelectSingle | ISelectMultiple; export {};