-
Notifications
You must be signed in to change notification settings - Fork 30k
/
MenuSelectWidget.d.ts
193 lines (168 loc) · 7.67 KB
/
MenuSelectWidget.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
declare namespace OO.ui {
/**
* MenuSelectWidget is a {@link OO.ui.SelectWidget select widget} that contains options and
* is used together with OO.ui.MenuOptionWidget. It is designed be used as part of another widget.
* See {@link OO.ui.DropdownWidget DropdownWidget},
* {@link OO.ui.ComboBoxInputWidget ComboBoxInputWidget}, and
* {@link OO.ui.mixin.LookupElement LookupElement} for examples of widgets that contain menus.
* MenuSelectWidgets themselves are not instantiated directly, rather subclassed
* and customized to be opened, closed, and displayed as needed.
*
* By default, menus are clipped to the visible viewport and are not visible when a user presses the
* mouse outside the menu.
*
* Menus also have support for keyboard interaction:
*
* - Enter/Return key: choose and select a menu option
* - Up-arrow key: highlight the previous menu option
* - Down-arrow key: highlight the next menu option
* - Escape key: hide the menu
*
* Unlike most widgets, MenuSelectWidget is initially hidden and must be shown by calling
* {@link toggle}.
*
* Please see the [OOUI documentation on MediaWiki](https://www.mediawiki.org/wiki/OOUI/Widgets/Selects_and_Options)
* for more information.
*
* ResourceLoader module: `oojs-ui-core`
*
* @see https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.MenuSelectWidget
*/
interface MenuSelectWidget extends MenuSelectWidget.Props, MenuSelectWidget.Prototype {}
namespace MenuSelectWidget {
interface EventMap extends SelectWidget.EventMap {
ready: [];
}
interface ConfigOptions
extends
SelectWidget.ConfigOptions,
mixin.ClippableElement.ConfigOptions,
mixin.FloatableElement.ConfigOptions
{
/**
* Text input used to implement option highlighting for menu
* items that match the text the user types. This config is used by
* {@link OO.ui.ComboBoxInputWidget ComboBoxInputWidget} and
* {@link OO.ui.mixin.LookupElement LookupElement}
*/
input?: TextInputWidget;
/**
* Text input used to implement option highlighting for menu items that match
* the text the user types. This config is used by
* {@link OO.ui.TagMultiselectWidget TagMultiselectWidget}
*/
$input?: JQuery;
/**
* Widget associated with the menu's active state. If the user clicks
* the mouse anywhere on the page outside of this widget, the menu is hidden. For
* example, if there is a button that toggles the menu's visibility on click, the menu
* will be hidden then re-shown when the user clicks that button, unless the button (or
* its parent widget) is passed in here.
*/
widget?: Widget;
/** Hide the menu when the mouse is pressed outside the menu. */
autoHide?: boolean;
/** If these elements are clicked, don't auto-hide the menu. */
$autoCloseIgnore?: JQuery;
/** Hide the menu when the user chooses an option. */
hideOnChoose?: boolean;
/** Filter the displayed options from the input */
filterFromInput?: boolean;
/** Highlight the first result when filtering */
highlightOnFilter?: boolean;
/**
* The mode by which the menu filters the results.
* Options are 'exact', 'prefix' or 'substring'. See `OO.ui.SelectWidget.getItemMatcher`
*/
filterMode?: "substring" | "prefix" | "exact";
/**
* Width of the menu as a number of pixels or CSS string with unit
* suffix, used by {@link OO.ui.mixin.ClippableElement ClippableElement}
*/
width?: number | string;
}
interface Static extends SelectWidget.Static {
/**
* Positions to flip to if there isn't room in the container for the
* menu in a specific direction.
*/
flippedPositions: Record<string, string>;
}
interface Props extends SelectWidget.Props, mixin.ClippableElement.Props, mixin.FloatableElement.Props {
$input: JQuery | null;
$widget: JQuery | null;
$autoCloseIgnore: JQuery;
}
interface Prototype
extends SelectWidget.Prototype, mixin.ClippableElement.Prototype, mixin.FloatableElement.Prototype
{
/**
* Return the visible items in the menu.
*
* @return Visible items
*/
getVisibleItems(): MenuOptionWidget[];
/**
* Toggle visibility of the menu for screen readers.
*
* @param screenReaderMode
*/
toggleScreenReaderMode(screenReaderMode: boolean): void;
/**
* Scroll to the top of the menu
*/
scrollToTop(): void;
// #region EventEmitter overloads
on<K extends keyof EventMap, A extends ArgTuple = [], C = null>(
event: K,
method: EventHandler<C, (this: C, ...args: [...A, ...EventMap[K]]) => void>,
args?: A,
context?: C,
): this;
on<K extends string, C = null>(
event: K extends keyof EventMap ? never : K,
method: EventHandler<C>,
args?: any[],
context?: C,
): this;
once<K extends keyof EventMap>(event: K, listener: (this: null, ...args: EventMap[K]) => void): this;
once<K extends string>(
event: K extends keyof EventMap ? never : K,
listener: (this: null, ...args: any[]) => void,
): this;
off<K extends keyof EventMap, C = null>(
event: K,
method?: EventHandler<C, (this: C, ...args: EventMap[K]) => void>,
context?: C,
): this;
off<K extends string, C = null>(
event: K extends keyof EventMap ? never : K,
method?: EventHandler<C>,
context?: C,
): this;
emit<K extends keyof EventMap>(event: K, ...args: EventMap[K]): boolean;
emit<K extends string>(event: K extends keyof EventMap ? never : K, ...args: any[]): boolean;
emitThrow<K extends keyof EventMap>(event: K, ...args: EventMap[K]): boolean;
emitThrow<K extends string>(event: K extends keyof EventMap ? never : K, ...args: any[]): boolean;
connect<T extends Partial<Record<keyof EventMap, any>>, C>( // eslint-disable-line @definitelytyped/no-unnecessary-generics
context: C,
methods: EventConnectionMap<T, C, EventMap>,
): this;
disconnect<T extends Partial<Record<keyof EventMap, any>>, C>( // eslint-disable-line @definitelytyped/no-unnecessary-generics
context: C,
methods?: EventConnectionMap<T, C, EventMap>,
): this;
// #endregion
}
interface Constructor {
/** @param config Configuration options */
new(config?: ConfigOptions): MenuSelectWidget;
prototype: Prototype;
static: Static;
super: SelectWidget.Constructor;
/** @deprecated Use `super` instead */
parent: SelectWidget.Constructor;
}
}
const MenuSelectWidget: MenuSelectWidget.Constructor;
}