UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

218 lines (217 loc) 7.09 kB
import React from 'react'; import { StandardProps } from '../../util/component-types'; import { propsSearch } from '../../util/text-manipulation'; import * as reducers from './SearchableSelect.reducers'; import { IDropMenuOptionProps, IDropMenuOptionGroupProps, IDropMenuProps, IDropMenuState, IOptionsData } from '../DropMenu/DropMenu'; import { SearchFieldDumb as SearchField } from '../SearchField/SearchField'; interface ISearchableSelectPlaceholderProps extends StandardProps { description?: string; } /** Option Child Component */ export interface ISearchableSelectOptionProps extends IDropMenuOptionProps { description?: string; name?: string; Selected?: React.ReactNode; } declare type ISearchableSelectDropMenuProps = Partial<IDropMenuProps>; export interface ISearchableSelectProps extends StandardProps { hasReset: boolean; isDisabled: boolean; isInvisible: boolean; isLoading: boolean; isSelectionHighlighted: boolean; maxMenuHeight?: string | number; selectedIndex: number | null; searchText: string; DropMenu: ISearchableSelectDropMenuProps; Placeholder?: React.ReactNode; Option?: React.ReactNode; OptionGroup?: IDropMenuOptionGroupProps; Error: React.ReactNode; /** Called when an option is clicked, or when an option has focus and the Enter key is pressed. */ onSelect: (optionIndex: number | null, { props, event, }: { props: IDropMenuOptionProps | undefined; event: React.KeyboardEvent | React.MouseEvent; }) => void; onSearch: (searchText: string, firstVisibleIndex: number | undefined) => void; optionFilter: (searchValue: string, props: any) => boolean; } export interface ISearchableSelectState { DropMenu: IDropMenuState; selectedIndex: number | null; searchText: string | null; optionGroups: IDropMenuOptionGroupProps[]; flattenedOptionsData: IOptionsData[]; ungroupedOptionData: IOptionsData[]; optionGroupDataLookup: { [key: number]: IOptionsData[]; }; } declare class SearchableSelect extends React.Component<ISearchableSelectProps, ISearchableSelectState> { static displayName: string; static peek: { description: string; categories: string[]; madeFrom: string[]; }; static defaultProps: { hasReset: boolean; isSelectionHighlighted: boolean; isDisabled: boolean; isInvisible: boolean; isLoading: boolean; optionFilter: typeof propsSearch; searchText: string; selectedIndex: null; DropMenu: { isDisabled: boolean; isExpanded: boolean; direction: "down"; alignment: "start"; selectedIndices: never[]; focusedIndex: null; flyOutStyle: { maxHeight: string; }; onExpand: (...args: any[]) => void; onCollapse: (...args: any[]) => void; onSelect: (...args: any[]) => void; onFocusNext: (...args: any[]) => void; onFocusPrev: (...args: any[]) => void; onFocusOption: (...args: any[]) => void; portalId: string; optionContainerStyle: {}; ContextMenu: { direction: string; directonOffset: number; minWidthOffset: number; alignment: string; getAlignmentOffset: () => number; isExpanded: boolean; onClickOut: null; portalId: null; }; }; Error: null; onSearch: (...args: any[]) => void; onSelect: (...args: any[]) => void; }; static reducers: typeof reducers; static Placeholder: { (_props: ISearchableSelectPlaceholderProps): null; displayName: string; peek: { description: string; }; propName: string; propTypes: {}; }; static Option: { (_props: ISearchableSelectOptionProps): null; displayName: string; peek: { description: string; }; Selected: { (_props: { children?: React.ReactNode; }): null; displayName: string; peek: { description: string; }; propName: string; propTypes: {}; }; propName: string; propTypes: { isDisabled: any; isHidden: any; isWrapped: any; Selected: any; value: any; filterText: any; }; defaultProps: { isDisabled: boolean; isHidden: boolean; isWrapped: boolean; }; }; static OptionGroup: { (_props: IDropMenuOptionGroupProps): null; displayName: string; peek: { description: string; }; propName: string; propTypes: { isHidden: any; }; defaultProps: { isHidden: boolean; }; }; static SearchField: typeof SearchField; static NullOption: { (_props: import("../DropMenu/DropMenu").IDropMenuNullOptionProps): null; displayName: string; peek: { description: string; }; propName: string; propTypes: {}; }; static FixedOption: { (_props: import("../DropMenu/DropMenu").IDropMenuFixedOptionProps): null; displayName: string; peek: { description: string; }; propName: string; propTypes: { isDisabled: any; isHidden: any; isWrapped: any; }; defaultProps: { isDisabled: boolean; isHidden: boolean; isWrapped: boolean; }; }; static propTypes: { children: any; className: any; style: any; hasReset: any; isDisabled: any; isInvisible: any; isLoading: any; isSelectionHighlighted: any; maxMenuHeight: any; onSearch: any; onSelect: any; optionFilter: any; searchText: any; selectedIndex: any; DropMenu: any; Placeholder: any; Option: any; FixedOption: any; NullOption: any; OptionGroup: any; Error: any; }; UNSAFE_componentWillMount(): void; UNSAFE_componentWillReceiveProps: (nextProps: ISearchableSelectProps) => void; handleSearch: (searchText: string) => void; renderUnderlinedChildren: (childText: string, searchText: string) => ("" | JSX.Element)[]; renderOption: (optionProps: IDropMenuOptionProps, optionIndex: number) => JSX.Element; renderOptions(): JSX.Element | JSX.Element[]; render(): JSX.Element; } declare const _default: typeof SearchableSelect & import("../../util/state-management").IHybridComponent<ISearchableSelectProps, ISearchableSelectState>; export default _default; export { SearchableSelect as SearchableSelectDumb };