-
Notifications
You must be signed in to change notification settings - Fork 30k
/
DropdownInputWidget.d.ts
80 lines (73 loc) · 3.51 KB
/
DropdownInputWidget.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
declare namespace OO.ui {
/**
* DropdownInputWidget is a {@link OO.ui.DropdownWidget DropdownWidget} intended to be used
* within an HTML form, such as a OO.ui.FormLayout. The selected value is synchronized with the
* value of a hidden HTML `input` tag. Please see the [OOUI documentation on MediaWiki](https://www.mediawiki.org/wiki/OOUI/Widgets/Inputs)
* for more information about input widgets.
*
* A DropdownInputWidget always has a value (one of the options is always selected), unless there
* are no options. If no `value` configuration option is provided, the first option is selected.
* If you need a state representing no value (no option being selected), use a DropdownWidget.
*
* This and OO.ui.RadioSelectInputWidget support similar configuration options.
*
* // A DropdownInputWidget with three options.
* var dropdownInput = new OO.ui.DropdownInputWidget( {
* options: [
* { data: 'a', label: 'First' },
* { data: 'b', label: 'Second', disabled: true },
* { optgroup: 'Group label' },
* { data: 'c', label: 'First sub-item)' }
* ]
* } );
* $( document.body ).append( dropdownInput.$element );
*
* ResourceLoader module: `oojs-ui-core`
*
* @see https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.DropdownInputWidget
*/
interface DropdownInputWidget extends DropdownInputWidget.Props, DropdownInputWidget.Prototype {}
namespace DropdownInputWidget {
interface Option {
data?: any;
label?: string;
optgroup?: string;
disabled?: boolean;
}
interface ConfigOptions extends InputWidget.ConfigOptions, mixin.RequiredElement.ConfigOptions {
/** Array of menu options in the format described above. */
options?: Option[];
/** Configuration options for {@link OO.ui.DropdownWidget DropdownWidget} */
dropdown?: DropdownWidget.ConfigOptions;
/**
* Render the menu into a separate layer. This configuration is
* useful in cases where the expanded menu is larger than its containing `<div>`. The
* specified overlay layer is usually on top of the containing `<div>` and has a larger
* area. By default, the menu uses relative positioning. Pass 'true' to use the default
* overlay. See <https://www.mediawiki.org/wiki/OOUI/Concepts#Overlays>.
*/
$overlay?: JQuery | boolean;
}
type Static = InputWidget.Static;
interface Props extends InputWidget.Props, mixin.RequiredElement.Props {}
interface Prototype extends InputWidget.Prototype, mixin.RequiredElement.Prototype {
/**
* Set the options available for this input.
*
* @param options Array of menu options in the format `{ data: …, label: … }`
* @return The widget, for chaining
*/
setOptions(options: Option[]): this;
}
interface Constructor {
/** @param config Configuration options */
new(config?: ConfigOptions): DropdownInputWidget;
prototype: Prototype;
static: Static;
super: InputWidget.Constructor;
/** @deprecated Use `super` instead */
parent: InputWidget.Constructor;
}
}
const DropdownInputWidget: DropdownInputWidget.Constructor;
}