-
Notifications
You must be signed in to change notification settings - Fork 29.9k
/
CheckboxInputWidget.d.ts
150 lines (133 loc) · 6.06 KB
/
CheckboxInputWidget.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
declare namespace OO.ui {
/**
* CheckboxInputWidgets, like HTML checkboxes, can be selected and/or configured with a value.
* Note that these {@link OO.ui.InputWidget input widgets} are best laid out
* in {@link OO.ui.FieldLayout field layouts} that use the {@link OO.ui.FieldLayout.ConfigOptions.align inline}
* alignment.For more information, please see the[OOUI documentation on MediaWiki](https://www.mediawiki.org/wiki/OOUI/Widgets/Inputs).
*
* This widget can be used inside an HTML form, such as a OO.ui.FormLayout.
*
* // An example of selected, unselected, and disabled checkbox inputs.
* var checkbox1 = new OO.ui.CheckboxInputWidget( {
* value: 'a',
* selected: true
* } ),
* checkbox2 = new OO.ui.CheckboxInputWidget( {
* value: 'b'
* } ),
* checkbox3 = new OO.ui.CheckboxInputWidget( {
* value:'c',
* disabled: true
* } ),
* // Create a fieldset layout with fields for each checkbox.
* fieldset = new OO.ui.FieldsetLayout( {
* label: 'Checkboxes'
* } );
* fieldset.addItems( [
* new OO.ui.FieldLayout( checkbox1, { label: 'Selected checkbox', align: 'inline' } ),
* new OO.ui.FieldLayout( checkbox2, { label: 'Unselected checkbox', align: 'inline' } ),
* new OO.ui.FieldLayout( checkbox3, { label: 'Disabled checkbox', align: 'inline' } ),
* ] );
* $( document.body ).append( fieldset.$element );
*
* ResourceLoader module: `oojs-ui-core`
*
* @see https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.CheckboxInputWidget
*/
interface CheckboxInputWidget extends CheckboxInputWidget.Props, CheckboxInputWidget.Prototype {}
namespace CheckboxInputWidget {
// HACK: See SelectWidget.d.ts
interface EventMap {
change: [selected: boolean | string, indeterminate?: boolean];
disable: [disabled: boolean];
toggle: [visible: boolean];
}
interface ConfigOptions extends InputWidget.ConfigOptions, mixin.RequiredElement.ConfigOptions {
/** Select the checkbox initially. By default, the checkbox is not selected. */
selected?: boolean;
/** Whether the checkbox is in the indeterminate state. */
indeterminate?: boolean;
}
type Static = InputWidget.Static;
interface Props extends InputWidget.Props, mixin.RequiredElement.Props {}
interface Prototype extends InputWidget.Prototype, mixin.RequiredElement.Prototype {
/**
* Set selection state of this checkbox.
*
* @param state Selected state
* @return The widget, for chaining
*/
setSelected(state: boolean): this;
/**
* Check if this checkbox is selected.
*
* @return Checkbox is selected
*/
isSelected(): boolean;
/**
* Set indeterminate state of this checkbox.
*
* @param state Indeterminate state
* @return The widget, for chaining
*/
setIndeterminate(state: boolean): this;
/**
* Check if this checkbox is selected.
*
* @return Checkbox is selected
*/
isIndeterminate(): 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): CheckboxInputWidget;
prototype: Prototype;
static: Static;
super: InputWidget.Constructor;
/** @deprecated Use `super` instead */
parent: InputWidget.Constructor;
}
}
const CheckboxInputWidget: CheckboxInputWidget.Constructor;
}