import { ReactElement, ReactNode, CSSProperties, FocusEvent } from 'react'; import { CommonProps } from '../../common'; import { IconName } from '../../Icon'; import { BaseOption, GroupedOption } from '../types'; export interface SelectProps extends CommonProps { /** * Specify the [automated assistance](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) in filling out form field values by the browser. */ autoComplete?: string; /** * Allow to clear value after selecting an item. */ clearable?: boolean; /** * Whether the select is disabled. */ disabled?: boolean; /** * Whether the input is invalid. */ invalid?: boolean; /** * Loading state of Select, which will render a spinner at bottom of the option list. */ loading?: boolean; /** * Name of element, is used to refer to the form data for submission. */ name?: string; /** * Content to render when filtering items returns zero results. */ noResults?: ReactNode; /** * Blur event handler. */ onBlur?: (e: FocusEvent) => void; /** * onChange event handler. */ onChange: (value?: string | number) => void; /** * Callback to allow to create new option when option not found based on query (only when the callback is defined). */ onCreateNewOption?: (optionText: string) => void; /** * Focus event handler. */ onFocus?: (e: FocusEvent) => void; /** * Callback invoked when the query string changes. */ onQueryChange?: (query?: string) => void; /** * Handle scroll event when scrolling to the bottom of the option list. */ onScrollListToBottom?: () => void; /** * Additonal inline style for option menu dropdown. */ optionMenuStyle?: CSSProperties; /** * Customise option renderer. */ optionRenderer?: ({ option, index, }: { index: number; option: T; }) => ReactElement; /** * An array of (grouped) options to be selected. * * The generic parameter T should extend BaseOption: * * type BaseOption = { * disabled?: boolean; * helpText?: string; * text: string; * value: string | number; * }; * * type GroupedOption = { * category: string; * options: T[]; * }; */ options: Array> | Array; /** * Placeholder text in the absence of any value. */ placeholder?: string; /** * Name of Icon or an Icon element to render on the left side of the input. */ prefix?: IconName | ReactElement; /** * Query string to filter options. This value is controlled: its state if defined must be managed externally. */ query?: string; /** * Customise selected option renderer. */ selectedOptionRenderer?: ({ option }: { option: T; }) => string | ReactElement; /** * The size of the input box. */ size?: 'small' | 'medium' | 'large'; /** * Current selected value. */ value?: string | number; } declare const Select: ({ options, value, onBlur, onChange, onFocus, query, onQueryChange, optionRenderer, selectedOptionRenderer, noResults, disabled, size, invalid, placeholder, prefix, onScrollListToBottom, loading, name, onCreateNewOption, id, className, style, sx, autoComplete, optionMenuStyle, clearable, "data-test-id": dataTestId, }: SelectProps) => ReactElement; export default Select;