1 | import * as React from 'react';
|
2 | import { KeyCodes } from '../../Utilities';
|
3 | import { Selection } from '../../utilities/selection/index';
|
4 | import { Suggestions } from './Suggestions/Suggestions';
|
5 | import { SuggestionsController } from './Suggestions/SuggestionsController';
|
6 | import { Autofill } from '../Autofill/index';
|
7 | import type { ISuggestions, ISuggestionsProps } from './Suggestions/Suggestions.types';
|
8 | import type { IBasePicker, IBasePickerProps } from './BasePicker.types';
|
9 | import type { IAutofill } from '../Autofill/index';
|
10 | export interface IBasePickerState<T> {
|
11 | items?: any;
|
12 | suggestedDisplayValue?: string;
|
13 | moreSuggestionsAvailable?: boolean;
|
14 | isFocused?: boolean;
|
15 | isSearching?: boolean;
|
16 | isMostRecentlyUsedVisible?: boolean;
|
17 | suggestionsVisible?: boolean;
|
18 | suggestionsLoading?: boolean;
|
19 | isResultsFooterVisible?: boolean;
|
20 | selectedIndices?: number[];
|
21 | selectionRemoved?: T;
|
22 | }
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare type IPickerAriaIds = {
|
28 | |
29 |
|
30 |
|
31 | selectedSuggestionAlert: string;
|
32 | |
33 |
|
34 |
|
35 | selectedItems: string;
|
36 | |
37 |
|
38 |
|
39 | suggestionList: string;
|
40 | |
41 |
|
42 |
|
43 | combobox: string;
|
44 | };
|
45 |
|
46 |
|
47 |
|
48 | export declare class BasePicker<T, P extends IBasePickerProps<T>> extends React.Component<P, IBasePickerState<T>> implements IBasePicker<T> {
|
49 | protected root: React.RefObject<HTMLDivElement>;
|
50 | protected input: React.RefObject<IAutofill>;
|
51 | protected suggestionElement: React.RefObject<ISuggestions<T>>;
|
52 | protected selection: Selection;
|
53 | protected suggestionStore: SuggestionsController<T>;
|
54 | |
55 |
|
56 |
|
57 | protected SuggestionOfProperType: new (props: ISuggestionsProps<T>) => Suggestions<T>;
|
58 | protected currentPromise: PromiseLike<any> | undefined;
|
59 | protected _ariaMap: IPickerAriaIds;
|
60 | private _styledSuggestions;
|
61 | private _id;
|
62 | private _async;
|
63 | static getDerivedStateFromProps(newProps: IBasePickerProps<any>): {
|
64 | items: any[];
|
65 | } | null;
|
66 | constructor(basePickerProps: P);
|
67 | get items(): T[];
|
68 | componentDidMount(): void;
|
69 | componentDidUpdate(oldProps: P, oldState: IBasePickerState<T>): void;
|
70 | componentWillUnmount(): void;
|
71 | focus(): void;
|
72 | focusInput(): void;
|
73 | dismissSuggestions: (ev?: any) => void;
|
74 | completeSuggestion(forceComplete?: boolean): void;
|
75 | refocusSuggestions: (keyCode: KeyCodes) => void;
|
76 | render(): JSX.Element;
|
77 | protected canAddItems(): boolean;
|
78 | protected renderSuggestions(): JSX.Element | null;
|
79 | protected renderItems(): JSX.Element[];
|
80 | protected resetFocus(index?: number): void;
|
81 | protected onSuggestionSelect(): void;
|
82 | protected onSelectionChange(): void;
|
83 | protected updateSuggestions(suggestions: any[]): void;
|
84 | /**
|
85 | * Only to be called when there is nothing in the input. Checks to see if the consumer has
|
86 | * provided a function to resolve suggestions
|
87 | */
|
88 | protected onEmptyInputFocus(): void;
|
89 | protected updateValue(updatedValue: string): void;
|
90 | protected updateSuggestionsList(suggestions: T[] | PromiseLike<T[]>, updatedValue?: string): void;
|
91 | protected resolveNewValue(updatedValue: string, suggestions: T[]): void;
|
92 | protected onChange(items?: T[]): void;
|
93 | protected onInputChange: (value: string) => void;
|
94 | protected onSuggestionClick: (ev: React.MouseEvent<HTMLElement>, item: any, index: number) => void;
|
95 | protected onSuggestionRemove: (ev: React.MouseEvent<HTMLElement>, item: T, index: number) => void;
|
96 | protected onInputFocus: (ev: React.FocusEvent<HTMLInputElement | Autofill>) => void;
|
97 | protected onInputBlur: (ev: React.FocusEvent<HTMLInputElement | Autofill>) => void;
|
98 | protected onBlur: (ev: React.FocusEvent<HTMLElement | Autofill>) => void;
|
99 | /**
|
100 | * Resets focus to last element in wrapper div if clicking back into Picker that has hit item limit
|
101 | */
|
102 | protected onWrapperClick: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
103 | /**
|
104 | * Reveals suggestions any time the user clicks on the input element
|
105 | * without shifting focus.
|
106 | */
|
107 | protected onClick: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
108 | protected onFocus: () => void;
|
109 | protected onKeyDown: (ev: React.KeyboardEvent<HTMLElement>) => void;
|
110 | protected onItemChange: (changedItem: T, index: number) => void;
|
111 | protected onGetMoreResults: () => void;
|
112 | protected completeSelection: (item: T) => void;
|
113 | protected addItemByIndex: (index: number) => void;
|
114 | protected addItem: (item: T) => void;
|
115 | protected removeItem: (item: T) => void;
|
116 | protected removeItems: (itemsToRemove: any[]) => void;
|
117 | protected onBackspace(ev: React.KeyboardEvent<HTMLElement>): void;
|
118 | /**
|
119 | * @deprecated this is no longer necessary as focuszone has been removed
|
120 | */
|
121 | protected _shouldFocusZoneEnterInnerZone: (ev: React.KeyboardEvent<HTMLElement>) => boolean;
|
122 | protected getActiveDescendant(): string | undefined;
|
123 | /** @deprecated use renderCustomAlert instead */
|
124 | protected getSuggestionsAlert(suggestionAlertClassName?: string): JSX.Element | undefined;
|
125 | protected renderCustomAlert(alertClassName?: string): JSX.Element;
|
126 | /**
|
127 | * Takes in the current updated value and either resolves it with the new suggestions
|
128 | * or if updated value is undefined then it clears out currently suggested items
|
129 | */
|
130 | private _updateAndResolveValue;
|
131 | /**
|
132 | * Controls what happens whenever there is an action that impacts the selected items.
|
133 | * If `selectedItems` is provided, this will act as a controlled component and it will not update its own state.
|
134 | */
|
135 | private _updateSelectedItems;
|
136 | private _onSelectedItemsUpdated;
|
137 | /**
|
138 | * Suggestions are normally shown after the user updates text and the text
|
139 | * is non-empty, but also when the user clicks on the input element.
|
140 | * @returns True if suggestions should be shown.
|
141 | */
|
142 | private _getShowSuggestions;
|
143 | private _onResolveSuggestions;
|
144 | private _completeGenericSuggestion;
|
145 | private _getTextFromItem;
|
146 | /**
|
147 | * This should be called when the user does something other than use text entry to trigger suggestions.
|
148 | *
|
149 | */
|
150 | private _userTriggeredSuggestions;
|
151 | }
|
152 | export declare class BasePickerListBelow<T, P extends IBasePickerProps<T>> extends BasePicker<T, P> {
|
153 | render(): JSX.Element;
|
154 | protected onBackspace(ev: React.KeyboardEvent<HTMLElement>): void;
|
155 | }
|