UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

248 lines (247 loc) 8.48 kB
import React from 'react'; import { propsSearch } from '../../util/text-manipulation'; import { StandardProps, Overwrite } from '../../util/component-types'; import { ISearchFieldProps } from '../SearchField/SearchField'; import { IDropMenuProps, IDropMenuState, IDropMenuOptionProps, IOptionsData, IDropMenuOptionGroupProps, DropMenuDumb as DropMenu } from '../DropMenu/DropMenu'; import * as reducers from './SearchableSingleSelect.reducers'; /** Option Child Component w/ Selection property */ export interface ISearchableSingleSelectOptionProps extends IDropMenuOptionProps { description?: string; name?: string; Selected?: React.ReactNode; } export interface ISearchableSingleSelectPropsRaw extends StandardProps { hasReset?: boolean; hasSelections?: boolean; isDisabled: boolean; isLoading: boolean; maxMenuHeight?: string; selectedIndex: number | null; searchText: string; SearchField: React.ReactNode; DropMenu: IDropMenuProps; 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 | null, { props, event, }: { props: IDropMenuOptionProps; event: React.KeyboardEvent | React.MouseEvent; }) => void; optionFilter: (searchValue: string, props: any) => boolean; } export declare type ISearchableSingleSelectProps = Overwrite<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ISearchableSingleSelectPropsRaw>; export interface ISearchableSingleSelectState { DropMenu: IDropMenuState; selectedIndex: number | null; searchText: string | null; optionGroups: IDropMenuOptionGroupProps[]; flattenedOptionsData: IOptionsData[]; ungroupedOptionData: IOptionsData[]; optionGroupDataLookup: { [key: number]: IOptionsData[]; }; } declare class SearchableSingleSelect extends React.Component<ISearchableSingleSelectProps, ISearchableSingleSelectState> { static displayName: string; static peek: { description: string; categories: string[]; madeFrom: string[]; }; static defaultProps: { isDisabled: 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; SearchField: { isDisabled: boolean; onChange: (...args: any[]) => void; onChangeDebounced: (...args: any[]) => void; debounceLevel: number; onSubmit: (...args: any[]) => void; value: string; }; }; static reducers: typeof reducers; static Option: { (_props: ISearchableSingleSelectOptionProps): 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: { (_props: ISearchFieldProps): null; displayName: string; peek: { description: string; }; propName: string; propTypes: { onChange: any; onChangeDebounced: any; debounceLevel: any; onSubmit: any; value: any; isValid: any; isDisabled: any; placeholder: any; className: any; Icon: any; TextField: any; }; defaultProps: { isDisabled: boolean; onChange: (...args: any[]) => void; onChangeDebounced: (...args: any[]) => void; debounceLevel: number; onSubmit: (...args: any[]) => void; value: string; }; }; 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 DropMenu: typeof DropMenu; static propTypes: { children: any; className: any; isDisabled: any; isLoading: any; maxMenuHeight: any; onSearch: any; onSelect: any; optionFilter: any; searchText: any; selectedIndex: any; DropMenu: any; Option: any; Error: any; FixedOption: any; NullOption: any; OptionGroup: any; SearchField: any; }; UNSAFE_componentWillMount(): void; UNSAFE_componentWillReceiveProps(nextProps: ISearchableSingleSelectProps): void; handleSearch: (searchText: string, { event, }: { event: React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent>; }) => void; renderUnderlinedChildren: (childText: string, searchText: string) => any[]; renderOptionContent: (optionProps: ISearchableSingleSelectOptionProps, searchText: string) => any; renderOption: ({ optionProps, optionIndex, }: { optionProps: ISearchableSingleSelectOptionProps; optionIndex: number | null; }) => any; renderOptions: () => any; removeSelection: ({ event, props, }: { event: React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent>; props: ISearchableSingleSelectOptionProps; }) => void; render: () => JSX.Element; } declare const _default: typeof SearchableSingleSelect & import("../../util/state-management").IHybridComponent<Overwrite<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ISearchableSingleSelectPropsRaw>, ISearchableSingleSelectState>; export default _default; export { SearchableSingleSelect as SearchableSingleSelectDumb };