-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
OptionWidget.d.ts
214 lines (189 loc) · 8.35 KB
/
OptionWidget.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
declare namespace OO.ui {
/**
* OptionWidgets are special elements that can be selected and configured with data. The
* data is often unique for each option, but it does not have to be. OptionWidgets are used
* with OO.ui.SelectWidget to create a selection of mutually exclusive options. For more information
* and examples, please see the [OOUI documentation on MediaWiki](https://www.mediawiki.org/wiki/OOUI/Widgets/Selects_and_Options).
*
* ResourceLoader module: `oojs-ui-core`
*
* @see https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.OptionWidget
*/
interface OptionWidget extends OptionWidget.Props, OptionWidget.Prototype {}
namespace OptionWidget {
interface EventMap extends Widget.EventMap, mixin.LabelElement.EventMap, mixin.FlaggedElement.EventMap {}
interface ConfigOptions
extends
Widget.ConfigOptions,
mixin.LabelElement.ConfigOptions,
mixin.FlaggedElement.ConfigOptions,
mixin.AccessKeyedElement.ConfigOptions,
mixin.TitledElement.ConfigOptions
{}
interface Static
extends
Widget.Static,
mixin.LabelElement.Static,
mixin.FlaggedElement.Static,
mixin.AccessKeyedElement.Static,
mixin.TitledElement.Static
{
/** Whether this option can be selected. See {@link Prototype.setSelected setSelected}. */
selectable: boolean;
/** Whether this option can be highlighted. See {@link Prototype.setHighlighted setHighlighted}. */
highlightable: boolean;
/** Whether this option can be pressed. See {@link Prototype.setPressed setPressed}. */
pressable: boolean;
/** Whether this option will be scrolled into view when it is selected. */
scrollIntoViewOnSelect: boolean;
}
interface Props
extends
Widget.Props,
mixin.LabelElement.Props,
mixin.FlaggedElement.Props,
mixin.AccessKeyedElement.Props,
mixin.TitledElement.Props
{}
interface Prototype
extends
Widget.Prototype,
mixin.LabelElement.Prototype,
mixin.FlaggedElement.Prototype,
mixin.AccessKeyedElement.Prototype,
mixin.TitledElement.Prototype
{
/**
* Check if the option can be selected.
*
* @return Item is selectable
*/
isSelectable(): boolean;
/**
* Check if the option can be highlighted. A highlight indicates that the option
* may be selected when a user presses Enter key or clicks. Disabled items cannot
* be highlighted.
*
* @return Item is highlightable
*/
isHighlightable(): boolean;
/**
* Check if the option can be pressed. The pressed state occurs when a user mouses
* down on an item, but has not yet let go of the mouse.
*
* @return Item is pressable
*/
isPressable(): boolean;
/**
* Check if the option is selected.
*
* @return Item is selected
*/
isSelected(): boolean;
/**
* Check if the option is highlighted. A highlight indicates that the
* item may be selected when a user presses Enter key or clicks.
*
* @return Item is highlighted
*/
isHighlighted(): boolean;
/**
* Check if the option is pressed. The pressed state occurs when a user mouses
* down on an item, but has not yet let go of the mouse. The item may appear
* selected, but it will not be selected until the user releases the mouse.
*
* @return Item is pressed
*/
isPressed(): boolean;
/**
* Set the option’s selected state. In general, all modifications to the selection
* should be handled by the SelectWidget’s
* {@link OO.ui.SelectWidget.selectItem selectItem( [item] )} method instead of this method.
*
* @param state Select option
* @return The widget, for chaining
*/
setSelected(state?: boolean): this;
/**
* Set the option’s highlighted state. In general, all programmatic
* modifications to the highlight should be handled by the
* SelectWidget’s {@link OO.ui.SelectWidget.highlightItem highlightItem( [item] )}
* method instead of this method.
*
* @param state Highlight option
* @return The widget, for chaining
*/
setHighlighted(state?: boolean): this;
/**
* Set the option’s pressed state. In general, all
* programmatic modifications to the pressed state should be handled by the
* SelectWidget’s {@link OO.ui.SelectWidget.pressItem pressItem( [item] )}
* method instead of this method.
*
* @param state Press option
* @return The widget, for chaining
*/
setPressed(state?: boolean): this;
/**
* Get text to match search strings against.
*
* The default implementation returns the label text, but subclasses
* can override this to provide more complex behavior.
*
* @return String to match search string against
*/
getMatchText(): string | boolean;
// #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): OptionWidget;
prototype: Prototype;
static: Static;
super: Widget.Constructor;
/** @deprecated Use `super` instead */
parent: Widget.Constructor;
}
}
const OptionWidget: OptionWidget.Constructor;
}