import { ListChildComponentProps } from "react-window"; import { PureComponent, SyntheticEvent, KeyboardEvent } from 'react'; import { SelectOption } from './types'; export declare class Dropdown extends PureComponent { private dropdownRef; private picklistRef; private debouncedSetPicklistState; private resizePicklist; static defaultProps: { optional: boolean; options: never[]; initialOptions: never[]; placeholder: string; filterable: boolean; multiselect: boolean; typeaheadValue: string; onChange: (...args: any[]) => void; onSelect: (...args: any[]) => void; onDeselect: (...args: any[]) => void; onShowPicker: (...args: any[]) => void; onHidePicker: (...args: any[]) => void; onTypeaheadChange: (...args: any[]) => void; onPicklistChange: (...args: any[]) => void; }; constructor(props: Props); componentDidMount(): void; componentDidUpdate(): void; componentWillUnmount(): void; render(): JSX.Element; /** * * @returns {JSX.Element} */ renderHeader(): JSX.Element; renderPicklist(): JSX.Element | null; /** * Render an extra option in the picklist, displaying the placeholder value, * so users can "deselect" their current selection - ie. this dropdown is optional */ renderDeselectOption(): JSX.Element | null; /** * Reset the users selected choice to null */ clearSelection: () => void; /** * TODO: This should be handled by a separate component, so we don't need to * rerender the button on every change (which inadvertently dismisses open pickers) */ renderPicklistItems(): JSX.Element | JSX.Element[] | null; renderItem({ index, style }: Pick): JSX.Element; renderSearch(): JSX.Element | null; setSearchValue: (event: SyntheticEvent) => void; setPicklistState: () => void; onKeyDown: (event: KeyboardEvent) => void; renderClearIcon(): JSX.Element | null; renderArrowIcon(): JSX.Element; getSelectedValue(): string; showPicker: () => void; hidePicker: () => void; handleOutsideClick: (event: SyntheticEvent | Event) => void; togglePicker: () => void; onChange: (key: SelectOption['key']) => void; isDisabled: () => boolean; static getDerivedStateFromProps(props: Props, state: State): State; getClasses: (k: string) => any; } export interface HeaderRenderer { /** * Display value of the current selection. * If multiple selections, this will be the phrase "N selected" */ selectedValue: SelectOption['value']; /** * A Set containing the values of the selected items */ selected: State['selected']; /** * Function to show the picker */ show: (event: SyntheticEvent) => void; /** * Function to hide the picker */ hide: (event: SyntheticEvent | Event) => void; } export interface PicklistRenderer { /** * onClick handler for when users select a picklist option */ onClick: (key: SelectOption['key']) => void; /** * Options for picklist */ options: SelectOption[]; /** * Picklist items that are already selected and need to be disabled */ selectedOptions?: string[]; /** * Function to hide the picker */ hide: () => void; } export interface State { /** * Whether the picklist is visible */ open: boolean; /** * Currently selected value(s) */ selected: Set; /** * Current search filter */ search: string; /** * Currently visible options */ options: SelectOption[]; /** * The intial set of options we received as props, used to compare with * incoming props to determine when we need to reset the list */ initialOptions: SelectOption[]; /** * Value displayed for typeahead auto-fill */ autofill: string; /** * Last known value of the typeahead search input */ initialTypeaheadValue: string; } export interface Props { /** * Custom header to use instead of the default placeholder select box */ header?: (data: HeaderRenderer) => JSX.Element; /** * Custom picklist to use instead of the default picklist */ picklist?: (data: PicklistRenderer) => JSX.Element; /** * Selected value (for use as a controlled component) */ value?: SelectOption['key'] | null; /** * Placeholder text to display when no value is selected */ placeholder: string; /** * Include search functionality in the picklist */ filterable: boolean; /** * Make search the default behavior */ typeahead: boolean; /** * Allow multiple values to be selected */ multiselect: boolean; /** * Options to display */ options: SelectOption[]; /** * Options to display */ initialOptions: SelectOption[]; /** * Classes for the wrapper div */ className?: string; /** * Whether or not the dropdown is disabled */ disabled?: boolean; /** * Selected values (requires multiselect: true, for use as a controlled component) */ selected?: State['selected'] | Array | SelectOption['key'] | null; /** * Picklist items that are already selected and need to be disabled */ selectedOptions?: string[]; /** * Allow users to deselect the value, returning to the original placeholder */ optional: boolean; /** * Value to be displayed (in typeaheads) */ typeaheadValue: string; /** * Event fired for single selection dropdowns (multiselect: false) */ onChange: (selected: SelectOption['key'] | null) => void; /** * Event fired for multiselect dropdowns (multiselect: true) */ onSelect: (selected: SelectOption['key'] | null) => void; /** * Event fired when deselecting a multiselect value (multiselect: true) */ onDeselect: (selected: SelectOption['key'] | null) => void; /** * Event fired when showing the picker */ onShowPicker: () => void; /** * Event fired when hiding the picker */ onHidePicker: () => void; /** * Event fired when hiding the picker */ onTypeaheadChange: (value: string) => void; /** * Event fired after the picklist has been filtered by a search value * This is helpful for custom picklists. This way, consumers don't have to * redundantly apply filtering to the picklist, externally */ onPicklistChange: (options: SelectOption[]) => void; /** * zIndex for picklist */ zIndex?: number; }