UNPKG

lucid-ui

Version:

A UI component library from Xandr.

346 lines 14.2 kB
import React from 'react'; import PropTypes from 'prop-types'; 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'; /** Placeholder Child Component */ export interface ISearchableSelectPlaceholderProps extends StandardProps { description?: string; } export interface ISearchableSelectOptionProps extends IDropMenuOptionProps { description?: string; name?: string; Selected?: React.ReactNode; } /** Searchable Select */ 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[]; }; isFocusOnSearchFieldRequired: boolean; } /** SearchableSelect Component */ 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: PropTypes.Requireable<boolean>; isHidden: PropTypes.Requireable<boolean>; isWrapped: PropTypes.Requireable<boolean>; /** Customizes the rendering of the Option when it is selected and is displayed instead of the Placeholder. */ Selected: PropTypes.Requireable<any>; value: PropTypes.Requireable<string>; filterText: PropTypes.Requireable<string>; }; defaultProps: { isDisabled: boolean; isHidden: boolean; isWrapped: boolean; }; }; static OptionGroup: { (_props: IDropMenuOptionGroupProps): null; displayName: string; peek: { description: string; }; propName: string; propTypes: { isHidden: PropTypes.Requireable<boolean>; }; 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: PropTypes.Requireable<boolean>; isHidden: PropTypes.Requireable<boolean>; isWrapped: PropTypes.Requireable<boolean>; }; defaultProps: { isDisabled: boolean; isHidden: boolean; isWrapped: boolean; }; }; static propTypes: { /** Should be instances of {\`SearchableSelect.Placeholder\`, \`SearchableSelect.Option\`, \`SearchableSelect.OptionGroup\`}. Other direct child elements will not render. */ children: PropTypes.Requireable<PropTypes.ReactNodeLike>; className: PropTypes.Requireable<string>; /** Appended to the component-specific class names set on the root elements. Applies to *both* the control and the flyout menu. */ /** Styles that are passed through to root element. */ style: PropTypes.Requireable<object>; /** Allows user to reset the \`optionIndex\` to \`null\` if they select the placeholder at the top of the options list. If \`false\`, it will not render the placeholder in the menu. */ hasReset: PropTypes.Requireable<boolean>; /** Disables the SearchableSelect from being clicked or focused. */ isDisabled: PropTypes.Requireable<boolean>; /** The SearchableSelect will be invisible. */ isInvisible: PropTypes.Requireable<boolean>; /** Displays a centered LoadingIcon to allow for asynchronous loading of options. */ isLoading: PropTypes.Requireable<boolean>; /** Applies primary color styling to the control when an item is selected. */ isSelectionHighlighted: PropTypes.Requireable<boolean>; /** The max height of the fly-out menu. */ maxMenuHeight: PropTypes.Requireable<string | number>; onSearch: PropTypes.Requireable<(...args: any[]) => any>; /** Called when the user enters a value to search for; the set of visible Options will be filtered using the value. Has the signature \`(searchText, firstVisibleIndex, {props, event}) => {}\` where \`searchText\` is the value from the \`SearchField\` and \`firstVisibleIndex\` is the index of the first option that will be visible after filtering. */ /** Called when an option is selected. Has the signature \`(optionIndex, {props, event}) => {}\` where \`optionIndex\` is the new \`selectedIndex\` or \`null\`. */ onSelect: PropTypes.Requireable<(...args: any[]) => any>; /** The function that will be run against each Option's props to determine whether it should be visible or not. The default behavior of the function is to match, ignoring case, against any text node descendant of the \`Option\`. Has the signature \`(searchText, optionProps)\` If \`true\`, option will be visible. If \`false\`, the option will not be visible. */ optionFilter: PropTypes.Requireable<(...args: any[]) => any>; /** The current search text to filter the list of options by. */ searchText: PropTypes.Requireable<string>; /** The currently selected \`SearchableSelect.Option\` index or \`null\` if nothing is selected. */ selectedIndex: PropTypes.Requireable<number>; /** Object of DropMenu props which are passed thru to the underlying DropMenu component. */ DropMenu: PropTypes.Requireable<PropTypes.InferProps<{ children: PropTypes.Requireable<PropTypes.ReactNodeLike>; className: PropTypes.Requireable<string>; style: PropTypes.Requireable<object>; isDisabled: PropTypes.Requireable<boolean>; isExpanded: PropTypes.Requireable<boolean>; direction: PropTypes.Requireable<string>; alignment: PropTypes.Requireable<string>; selectedIndices: PropTypes.Requireable<(number | null | undefined)[]>; focusedIndex: PropTypes.Requireable<number>; portalId: PropTypes.Requireable<string>; flyOutStyle: PropTypes.Requireable<object>; optionContainerStyle: PropTypes.Requireable<object>; onExpand: PropTypes.Requireable<(...args: any[]) => any>; onCollapse: PropTypes.Requireable<(...args: any[]) => any>; onSelect: PropTypes.Requireable<(...args: any[]) => any>; onFocusNext: PropTypes.Requireable<(...args: any[]) => any>; onFocusPrev: PropTypes.Requireable<(...args: any[]) => any>; onFocusOption: PropTypes.Requireable<(...args: any[]) => any>; Control: PropTypes.Requireable<any>; Option: PropTypes.Requireable<any>; OptionGroup: PropTypes.Requireable<any>; NullOption: PropTypes.Requireable<any>; Header: PropTypes.Requireable<any>; ContextMenu: PropTypes.Requireable<any>; FixedOption: PropTypes.Requireable<any>; }>>; Placeholder: PropTypes.Requireable<any>; /** *Child Element* - The content rendered in the control when there is no option is selected. Also rendered in the option list to remove current selection. */ Option: PropTypes.Requireable<any>; /** *Child Element* - These are menu options. The \`optionIndex\` is in-order of rendering regardless of group nesting, starting with index \`0\`. Each \`Option\` may be passed a prop called \`isDisabled\` to disable selection of that \`Option\`. Any other props pass to Option will be available from the \`onSelect\` handler. */ FixedOption: PropTypes.Requireable<any>; /** *Child Element* - A special kind of \`Option\` that is always rendered at the top of the menu. */ NullOption: PropTypes.Requireable<any>; /** *Child Element* - A special kind of \`Option\` that is always rendered at the top of the menu and has an \`optionIndex\` of \`null\`. Useful for unselect. */ OptionGroup: PropTypes.Requireable<any>; /** *Child Element* - Used to group \`Option\`s within the menu. Any non-\`Option\`s passed in will be rendered as a label for the group. */ /** In most cases this will be a string, but it also accepts any valid React element. If this is a falsey value, then no error message will be displayed. If this is the literal \`true\`, it will add the \`-is-error\` class to the wrapper div, but not render the \`-error-content\` \`div\`. */ Error: PropTypes.Requireable<any>; }; UNSAFE_componentWillMount(): void; UNSAFE_componentWillReceiveProps: (nextProps: ISearchableSelectProps) => void; handleSearch: (searchText: string) => void; handleExpand: ({ props, event, }: { props: IDropMenuProps; event: React.KeyboardEvent | React.MouseEvent; }) => void; setSearchField: (e: SearchField) => 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 }; //# sourceMappingURL=SearchableSelect.d.ts.map