-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
MultiselectWidget.d.ts
129 lines (111 loc) · 4.94 KB
/
MultiselectWidget.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
declare namespace OO.ui {
/**
* MultiselectWidget allows selecting multiple options from a list.
*
* For more information about menus and options, please see the [OOUI documentation
* on MediaWiki](https://www.mediawiki.org/wiki/OOUI/Widgets/Selects_and_Options#Menu_selects_and_options).
*
* ResourceLoader module: `oojs-ui-core`
*
* @see https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.MultiselectWidget
*/
interface MultiselectWidget extends MultiselectWidget.Props, MultiselectWidget.Prototype {}
namespace MultiselectWidget {
interface EventMap extends Widget.EventMap, mixin.GroupElement.EventMap {
select: [];
}
interface ConfigOptions
extends Widget.ConfigOptions, mixin.GroupElement.ConfigOptions, mixin.TitledElement.ConfigOptions
{
/** An array of options to add to the multiselect. */
items?: MultioptionWidget[];
}
interface Static extends Widget.Static, mixin.TitledElement.Static {}
interface Props extends Widget.Props, mixin.GroupElement.Props, mixin.TitledElement.Props {}
interface Prototype extends Widget.Prototype, mixin.GroupElement.Prototype, mixin.TitledElement.Prototype {
/**
* Find options that are selected.
*
* @return Selected options
*/
findSelectedItems(): MultioptionWidget[];
/**
* Find the data of options that are selected.
*
* @return Values of selected options
*/
findSelectedItemsData(): unknown[];
/**
* Select options by reference. Options not mentioned in the `items` array will be deselected.
*
* @param items Items to select
* @return The widget, for chaining
*/
selectItems(items: MultioptionWidget[]): this;
/**
* Select items by their data. Options not mentioned in the `datas` array will be deselected.
*
* @param datas Values of items to select
* @return The widget, for chaining
*/
selectItemsByData(datas: any[]): this;
/**
* Deselect all items.
*
* @return The widget, for chaining
*/
clearSelection(): this;
// #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): MultiselectWidget;
prototype: Prototype;
static: Static;
super: Widget.Constructor;
/** @deprecated Use `super` instead */
parent: Widget.Constructor;
}
}
const MultiselectWidget: MultiselectWidget.Constructor;
}