@ckeditor/ckeditor5-ui 36.0.1 → 37.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/package.json +23 -22
  2. package/src/bindings/addkeyboardhandlingforgrid.d.ts +27 -0
  3. package/src/bindings/addkeyboardhandlingforgrid.js +42 -34
  4. package/src/bindings/clickoutsidehandler.d.ts +28 -0
  5. package/src/bindings/clickoutsidehandler.js +5 -6
  6. package/src/bindings/csstransitiondisablermixin.d.ts +40 -0
  7. package/src/bindings/csstransitiondisablermixin.js +55 -0
  8. package/src/bindings/injectcsstransitiondisabler.d.ts +59 -0
  9. package/src/bindings/injectcsstransitiondisabler.js +23 -20
  10. package/src/bindings/preventdefault.d.ts +33 -0
  11. package/src/bindings/preventdefault.js +13 -15
  12. package/src/bindings/submithandler.d.ts +57 -0
  13. package/src/bindings/submithandler.js +22 -23
  14. package/src/button/button.d.ts +154 -0
  15. package/src/button/buttonview.d.ts +155 -0
  16. package/src/button/buttonview.js +16 -60
  17. package/src/button/switchbuttonview.d.ts +45 -0
  18. package/src/button/switchbuttonview.js +9 -18
  19. package/src/colorgrid/colorgridview.d.ts +132 -0
  20. package/src/colorgrid/colorgridview.js +8 -40
  21. package/src/colorgrid/colortileview.d.ts +28 -0
  22. package/src/colorgrid/colortileview.js +0 -13
  23. package/src/colorgrid/utils.d.ts +47 -0
  24. package/src/colorgrid/utils.js +7 -13
  25. package/src/componentfactory.d.ts +81 -0
  26. package/src/componentfactory.js +21 -35
  27. package/src/dropdown/button/dropdownbutton.d.ts +25 -0
  28. package/src/dropdown/button/dropdownbuttonview.d.ts +48 -0
  29. package/src/dropdown/button/dropdownbuttonview.js +11 -21
  30. package/src/dropdown/button/splitbuttonview.d.ts +145 -0
  31. package/src/dropdown/button/splitbuttonview.js +10 -51
  32. package/src/dropdown/dropdownpanelfocusable.d.ts +21 -0
  33. package/src/dropdown/dropdownpanelview.d.ts +62 -0
  34. package/src/dropdown/dropdownpanelview.js +2 -30
  35. package/src/dropdown/dropdownview.d.ts +315 -0
  36. package/src/dropdown/dropdownview.js +121 -222
  37. package/src/dropdown/utils.d.ts +219 -0
  38. package/src/dropdown/utils.js +112 -106
  39. package/src/editableui/editableuiview.d.ts +71 -0
  40. package/src/editableui/editableuiview.js +14 -43
  41. package/src/editableui/inline/inlineeditableuiview.d.ts +40 -0
  42. package/src/editableui/inline/inlineeditableuiview.js +5 -15
  43. package/src/editorui/bodycollection.d.ts +51 -0
  44. package/src/editorui/bodycollection.js +2 -16
  45. package/src/editorui/boxed/boxededitoruiview.d.ts +40 -0
  46. package/src/editorui/boxed/boxededitoruiview.js +1 -27
  47. package/src/editorui/editorui.d.ts +264 -0
  48. package/src/editorui/editorui.js +21 -128
  49. package/src/editorui/editoruiview.d.ts +39 -0
  50. package/src/editorui/editoruiview.js +1 -10
  51. package/src/focuscycler.d.ts +183 -0
  52. package/src/focuscycler.js +34 -90
  53. package/src/formheader/formheaderview.d.ts +53 -0
  54. package/src/formheader/formheaderview.js +3 -24
  55. package/src/icon/iconview.d.ts +78 -0
  56. package/src/icon/iconview.js +0 -50
  57. package/src/iframe/iframeview.d.ts +50 -0
  58. package/src/iframe/iframeview.js +2 -2
  59. package/src/index.d.ts +54 -0
  60. package/src/index.js +1 -0
  61. package/src/input/inputview.d.ts +121 -0
  62. package/src/input/inputview.js +0 -82
  63. package/src/inputnumber/inputnumberview.d.ts +49 -0
  64. package/src/inputnumber/inputnumberview.js +5 -28
  65. package/src/inputtext/inputtextview.d.ts +18 -0
  66. package/src/inputtext/inputtextview.js +0 -2
  67. package/src/label/labelview.d.ts +36 -0
  68. package/src/label/labelview.js +0 -20
  69. package/src/labeledfield/labeledfieldview.d.ts +182 -0
  70. package/src/labeledfield/labeledfieldview.js +20 -126
  71. package/src/labeledfield/utils.d.ts +93 -0
  72. package/src/labeledfield/utils.js +24 -18
  73. package/src/labeledinput/labeledinputview.d.ts +125 -0
  74. package/src/labeledinput/labeledinputview.js +7 -90
  75. package/src/list/listitemview.d.ts +35 -0
  76. package/src/list/listitemview.js +0 -16
  77. package/src/list/listseparatorview.d.ts +18 -0
  78. package/src/list/listseparatorview.js +0 -2
  79. package/src/list/listview.d.ts +59 -0
  80. package/src/list/listview.js +0 -33
  81. package/src/model.d.ts +22 -0
  82. package/src/model.js +2 -4
  83. package/src/notification/notification.d.ts +216 -0
  84. package/src/notification/notification.js +64 -51
  85. package/src/panel/balloon/balloonpanelview.d.ts +685 -0
  86. package/src/panel/balloon/balloonpanelview.js +146 -168
  87. package/src/panel/balloon/contextualballoon.d.ts +240 -0
  88. package/src/panel/balloon/contextualballoon.js +41 -171
  89. package/src/panel/sticky/stickypanelview.d.ts +132 -0
  90. package/src/panel/sticky/stickypanelview.js +0 -115
  91. package/src/template.d.ts +940 -0
  92. package/src/template.js +396 -460
  93. package/src/toolbar/balloon/balloontoolbar.d.ts +124 -0
  94. package/src/toolbar/balloon/balloontoolbar.js +15 -81
  95. package/src/toolbar/block/blockbuttonview.d.ts +35 -0
  96. package/src/toolbar/block/blockbuttonview.js +1 -13
  97. package/src/toolbar/block/blocktoolbar.d.ts +159 -0
  98. package/src/toolbar/block/blocktoolbar.js +32 -69
  99. package/src/toolbar/normalizetoolbarconfig.d.ts +39 -0
  100. package/src/toolbar/normalizetoolbarconfig.js +12 -8
  101. package/src/toolbar/toolbarlinebreakview.d.ts +18 -0
  102. package/src/toolbar/toolbarlinebreakview.js +0 -2
  103. package/src/toolbar/toolbarseparatorview.d.ts +18 -0
  104. package/src/toolbar/toolbarseparatorview.js +0 -2
  105. package/src/toolbar/toolbarview.d.ts +241 -0
  106. package/src/toolbar/toolbarview.js +54 -305
  107. package/src/tooltipmanager.d.ts +180 -0
  108. package/src/tooltipmanager.js +47 -94
  109. package/src/uiconfig.d.ts +82 -0
  110. package/src/uiconfig.js +5 -0
  111. package/src/view.d.ts +422 -0
  112. package/src/view.js +182 -251
  113. package/src/viewcollection.d.ts +139 -0
  114. package/src/viewcollection.js +62 -56
@@ -14,20 +14,22 @@ import '../../theme/components/dropdown/dropdown.css';
14
14
  * In most cases, the easiest way to create a dropdown is by using the {@link module:ui/dropdown/utils~createDropdown}
15
15
  * util:
16
16
  *
17
- * const dropdown = createDropdown( locale );
17
+ * ```ts
18
+ * const dropdown = createDropdown( locale );
18
19
  *
19
- * // Configure dropdown's button properties:
20
- * dropdown.buttonView.set( {
21
- * label: 'A dropdown',
22
- * withText: true
23
- * } );
20
+ * // Configure dropdown's button properties:
21
+ * dropdown.buttonView.set( {
22
+ * label: 'A dropdown',
23
+ * withText: true
24
+ * } );
24
25
  *
25
- * dropdown.render();
26
+ * dropdown.render();
26
27
  *
27
- * dropdown.panelView.element.textContent = 'Content of the panel';
28
+ * dropdown.panelView.element.textContent = 'Content of the panel';
28
29
  *
29
- * // Will render a dropdown with a panel containing a "Content of the panel" text.
30
- * document.body.appendChild( dropdown.element );
30
+ * // Will render a dropdown with a panel containing a "Content of the panel" text.
31
+ * document.body.appendChild( dropdown.element );
32
+ * ```
31
33
  *
32
34
  * If you want to add a richer content to the dropdown panel, you can use the {@link module:ui/dropdown/utils~addListToDropdown}
33
35
  * and {@link module:ui/dropdown/utils~addToolbarToDropdown} helpers. See more examples in
@@ -35,28 +37,28 @@ import '../../theme/components/dropdown/dropdown.css';
35
37
  *
36
38
  * If you want to create a completely custom dropdown, then you can compose it manually:
37
39
  *
38
- * const button = new DropdownButtonView( locale );
39
- * const panel = new DropdownPanelView( locale );
40
- * const dropdown = new DropdownView( locale, button, panel );
40
+ * ```ts
41
+ * const button = new DropdownButtonView( locale );
42
+ * const panel = new DropdownPanelView( locale );
43
+ * const dropdown = new DropdownView( locale, button, panel );
41
44
  *
42
- * button.set( {
43
- * label: 'A dropdown',
44
- * withText: true
45
- * } );
45
+ * button.set( {
46
+ * label: 'A dropdown',
47
+ * withText: true
48
+ * } );
46
49
  *
47
- * dropdown.render();
50
+ * dropdown.render();
48
51
  *
49
- * panel.element.textContent = 'Content of the panel';
52
+ * panel.element.textContent = 'Content of the panel';
50
53
  *
51
- * // Will render a dropdown with a panel containing a "Content of the panel" text.
52
- * document.body.appendChild( dropdown.element );
54
+ * // Will render a dropdown with a panel containing a "Content of the panel" text.
55
+ * document.body.appendChild( dropdown.element );
56
+ * ```
53
57
  *
54
58
  * However, dropdown created this way will contain little behavior. You will need to implement handlers for actions
55
59
  * such as {@link module:ui/bindings/clickoutsidehandler~clickOutsideHandler clicking outside an open dropdown}
56
60
  * (which should close it) and support for arrow keys inside the panel. Therefore, unless you really know what
57
61
  * you do and you really need to do it, it is recommended to use the {@link module:ui/dropdown/utils~createDropdown} helper.
58
- *
59
- * @extends module:ui/view~View
60
62
  */
61
63
  export default class DropdownView extends View {
62
64
  /**
@@ -64,102 +66,19 @@ export default class DropdownView extends View {
64
66
  *
65
67
  * Also see {@link #render}.
66
68
  *
67
- * @param {module:utils/locale~Locale} [locale] The localization services instance.
68
- * @param {module:ui/dropdown/button/dropdownbutton~DropdownButton} buttonView
69
- * @param {module:ui/dropdown/dropdownpanelview~DropdownPanelView} panelView
69
+ * @param locale The localization services instance.
70
70
  */
71
71
  constructor(locale, buttonView, panelView) {
72
72
  super(locale);
73
73
  const bind = this.bindTemplate;
74
- /**
75
- * Button of the dropdown view. Clicking the button opens the {@link #panelView}.
76
- *
77
- * @readonly
78
- * @member {module:ui/button/buttonview~ButtonView} #buttonView
79
- */
80
74
  this.buttonView = buttonView;
81
- /**
82
- * Panel of the dropdown. It opens when the {@link #buttonView} is
83
- * {@link module:ui/button/buttonview~ButtonView#event:execute executed} (i.e. clicked).
84
- *
85
- * Child views can be added to the panel's `children` collection:
86
- *
87
- * dropdown.panelView.children.add( childView );
88
- *
89
- * See {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView#children} and
90
- * {@link module:ui/viewcollection~ViewCollection#add}.
91
- *
92
- * @readonly
93
- * @member {module:ui/dropdown/dropdownpanelview~DropdownPanelView} #panelView
94
- */
95
75
  this.panelView = panelView;
96
- /**
97
- * Controls whether the dropdown view is open, i.e. shows or hides the {@link #panelView panel}.
98
- *
99
- * **Note**: When the dropdown gets open, it will attempt to call `focus()` on the first child of its {@link #panelView}.
100
- * See {@link module:ui/dropdown/utils~addToolbarToDropdown}, {@link module:ui/dropdown/utils~addListToDropdown}, and
101
- * {@link module:ui/dropdown/utils~focusChildOnDropdownOpen} to learn more about focus management in dropdowns.
102
- *
103
- * @observable
104
- * @member {Boolean} #isOpen
105
- */
106
76
  this.set('isOpen', false);
107
- /**
108
- * Controls whether the dropdown is enabled, i.e. it can be clicked and execute an action.
109
- *
110
- * See {@link module:ui/button/buttonview~ButtonView#isEnabled}.
111
- *
112
- * @observable
113
- * @member {Boolean} #isEnabled
114
- */
115
77
  this.set('isEnabled', true);
116
- /**
117
- * (Optional) The additional CSS class set on the dropdown {@link #element}.
118
- *
119
- * @observable
120
- * @member {String} #class
121
- */
122
78
  this.set('class', undefined);
123
- /**
124
- * (Optional) The `id` attribute of the dropdown (i.e. to pair with a `<label>` element).
125
- *
126
- * @observable
127
- * @member {String} #id
128
- */
129
79
  this.set('id', undefined);
130
- /**
131
- * The position of the panel, relative to the dropdown.
132
- *
133
- * **Note**: When `'auto'`, the panel will use one of the remaining positions to stay
134
- * in the viewport, visible to the user. The positions correspond directly to
135
- * {@link module:ui/dropdown/dropdownview~DropdownView.defaultPanelPositions default panel positions}.
136
- *
137
- * **Note**: This value has an impact on the
138
- * {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView#position} property
139
- * each time the panel becomes {@link #isOpen open}.
140
- *
141
- * @observable
142
- * @default 'auto'
143
- * @member {'auto'|'s'|'se'|'sw'|'sme'|'smw'|'n'|'ne'|'nw'|'nme'|'nmw'} #panelPosition
144
- */
145
80
  this.set('panelPosition', 'auto');
146
- /**
147
- * Instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}. It manages
148
- * keystrokes of the dropdown:
149
- *
150
- * * <kbd>▼</kbd> opens the dropdown,
151
- * * <kbd>◀</kbd> and <kbd>Esc</kbd> closes the dropdown.
152
- *
153
- * @readonly
154
- * @member {module:utils/keystrokehandler~KeystrokeHandler}
155
- */
156
81
  this.keystrokes = new KeystrokeHandler();
157
- /**
158
- * Tracks information about the DOM focus in the dropdown.
159
- *
160
- * @readonly
161
- * @member {module:utils/focustracker~FocusTracker}
162
- */
163
82
  this.focusTracker = new FocusTracker();
164
83
  this.setTemplate({
165
84
  tag: 'div',
@@ -186,38 +105,6 @@ export default class DropdownView extends View {
186
105
  'data-cke-tooltip-disabled': bind.to('isOpen')
187
106
  }
188
107
  });
189
- /**
190
- * A child {@link module:ui/list/listview~ListView list view} of the dropdown located
191
- * in its {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
192
- *
193
- * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addListToDropdown}.
194
- *
195
- * @readonly
196
- * @member {module:ui/list/listview~ListView} #listView
197
- */
198
- /**
199
- * A child toolbar of the dropdown located in the
200
- * {@link module:ui/dropdown/dropdownview~DropdownView#panelView panel}.
201
- *
202
- * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addToolbarToDropdown}.
203
- *
204
- * @readonly
205
- * @member {module:ui/toolbar/toolbarview~ToolbarView} #toolbarView
206
- */
207
- /**
208
- * Fired when the toolbar button or list item is executed.
209
- *
210
- * For {@link #listView} It fires when a child of some {@link module:ui/list/listitemview~ListItemView}
211
- * fired `execute`.
212
- *
213
- * For {@link #toolbarView} It fires when one of the buttons has been
214
- * {@link module:ui/button/buttonview~ButtonView#event:execute executed}.
215
- *
216
- * **Note**: Only supported when dropdown has list view added using {@link module:ui/dropdown/utils~addListToDropdown}
217
- * or {@link module:ui/dropdown/utils~addToolbarToDropdown}.
218
- *
219
- * @event execute
220
- */
221
108
  }
222
109
  /**
223
110
  * @inheritDoc
@@ -288,9 +175,6 @@ export default class DropdownView extends View {
288
175
  * Returns {@link #panelView panel} positions to be used by the
289
176
  * {@link module:utils/dom/position~getOptimalPosition `getOptimalPosition()`}
290
177
  * utility considering the direction of the language the UI of the editor is displayed in.
291
- *
292
- * @type {module:utils/dom/position~Options#positions}
293
- * @private
294
178
  */
295
179
  get _panelPositions() {
296
180
  const { south, north, southEast, southWest, northEast, northWest, southMiddleEast, southMiddleWest, northMiddleEast, northMiddleWest } = DropdownView.defaultPanelPositions;
@@ -320,84 +204,102 @@ export default class DropdownView extends View {
320
204
  *
321
205
  * * `south`
322
206
  *
207
+ * ```
323
208
  * [ Button ]
324
- * +-----------------+
325
- * | Panel |
326
- * +-----------------+
327
- *
328
- * * `southEast`
329
- *
330
- * [ Button ]
331
- * +-----------------+
332
- * | Panel |
333
- * +-----------------+
334
- *
335
- * * `southWest`
336
- *
337
- * [ Button ]
338
- * +-----------------+
339
- * | Panel |
340
- * +-----------------+
341
- *
342
- * * `southMiddleEast`
343
- *
344
- * [ Button ]
345
- * +-----------------+
346
- * | Panel |
347
- * +-----------------+
348
- *
349
- * * `southMiddleWest`
350
- *
351
- * [ Button ]
352
- * +-----------------+
353
- * | Panel |
354
- * +-----------------+
355
- *
356
- * **North**
357
- *
358
- * * `north`
359
- *
360
- * +-----------------+
361
- * | Panel |
362
- * +-----------------+
363
- * [ Button ]
364
- *
365
- * * `northEast`
366
- *
367
- * +-----------------+
368
- * | Panel |
369
- * +-----------------+
370
- * [ Button ]
371
- *
372
- * * `northWest`
373
- *
374
- * +-----------------+
375
- * | Panel |
376
- * +-----------------+
377
- * [ Button ]
378
- *
379
- * * `northMiddleEast`
380
- *
381
- * +-----------------+
382
- * | Panel |
383
- * +-----------------+
384
- * [ Button ]
385
- *
386
- * * `northMiddleWest`
387
- *
388
- * +-----------------+
389
- * | Panel |
390
- * +-----------------+
391
- * [ Button ]
392
- *
393
- * Positioning functions are compatible with {@link module:utils/dom/position~Position}.
394
- *
395
- * The name that position function returns will be reflected in dropdown panel's class that
396
- * controls its placement. See {@link module:ui/dropdown/dropdownview~DropdownView#panelPosition}
397
- * to learn more.
398
- *
399
- * @member {Object} module:ui/dropdown/dropdownview~DropdownView.defaultPanelPositions
400
- */
209
+ * +-----------------+
210
+ * | Panel |
211
+ * +-----------------+
212
+ * ```
213
+ *
214
+ * * `southEast`
215
+ *
216
+ * ```
217
+ * [ Button ]
218
+ * +-----------------+
219
+ * | Panel |
220
+ * +-----------------+
221
+ * ```
222
+ *
223
+ * * `southWest`
224
+ *
225
+ * ```
226
+ * [ Button ]
227
+ * +-----------------+
228
+ * | Panel |
229
+ * +-----------------+
230
+ * ```
231
+ *
232
+ * * `southMiddleEast`
233
+ *
234
+ * ```
235
+ * [ Button ]
236
+ * +-----------------+
237
+ * | Panel |
238
+ * +-----------------+
239
+ * ```
240
+ *
241
+ * * `southMiddleWest`
242
+ *
243
+ * ```
244
+ * [ Button ]
245
+ * +-----------------+
246
+ * | Panel |
247
+ * +-----------------+
248
+ * ```
249
+ *
250
+ * **North**
251
+ *
252
+ * * `north`
253
+ *
254
+ * ```
255
+ * +-----------------+
256
+ * | Panel |
257
+ * +-----------------+
258
+ * [ Button ]
259
+ * ```
260
+ *
261
+ * * `northEast`
262
+ *
263
+ * ```
264
+ * +-----------------+
265
+ * | Panel |
266
+ * +-----------------+
267
+ * [ Button ]
268
+ * ```
269
+ *
270
+ * * `northWest`
271
+ *
272
+ * ```
273
+ * +-----------------+
274
+ * | Panel |
275
+ * +-----------------+
276
+ * [ Button ]
277
+ * ```
278
+ *
279
+ * * `northMiddleEast`
280
+ *
281
+ * ```
282
+ * +-----------------+
283
+ * | Panel |
284
+ * +-----------------+
285
+ * [ Button ]
286
+ * ```
287
+ *
288
+ * * `northMiddleWest`
289
+ *
290
+ * ```
291
+ * +-----------------+
292
+ * | Panel |
293
+ * +-----------------+
294
+ * [ Button ]
295
+ * ```
296
+ *
297
+ * Positioning functions are compatible with {@link module:utils/dom/position~Position}.
298
+ *
299
+ * The name that position function returns will be reflected in dropdown panel's class that
300
+ * controls its placement. See {@link module:ui/dropdown/dropdownview~DropdownView#panelPosition}
301
+ * to learn more.
302
+ */
401
303
  DropdownView.defaultPanelPositions = {
402
304
  south: (buttonRect, panelRect) => {
403
305
  return {
@@ -472,8 +374,5 @@ DropdownView.defaultPanelPositions = {
472
374
  };
473
375
  /**
474
376
  * A function used to calculate the optimal position for the dropdown panel.
475
- *
476
- * @protected
477
- * @member {Function} module:ui/dropdown/dropdownview~DropdownView._getOptimalPosition
478
377
  */
479
378
  DropdownView._getOptimalPosition = getOptimalPosition;
@@ -0,0 +1,219 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import DropdownView from './dropdownview';
6
+ import ViewCollection from '../viewcollection';
7
+ import type { default as View } from '../view';
8
+ import type Model from '../model';
9
+ import type DropdownButton from './button/dropdownbutton';
10
+ import type { FocusableView } from '../focuscycler';
11
+ import type { FalsyValue } from '../template';
12
+ import { type Collection, type Locale } from '@ckeditor/ckeditor5-utils';
13
+ import '../../theme/components/dropdown/toolbardropdown.css';
14
+ import '../../theme/components/dropdown/listdropdown.css';
15
+ /**
16
+ * A helper for creating dropdowns. It creates an instance of a {@link module:ui/dropdown/dropdownview~DropdownView dropdown},
17
+ * with a {@link module:ui/dropdown/button/dropdownbutton~DropdownButton button},
18
+ * {@link module:ui/dropdown/dropdownpanelview~DropdownPanelView panel} and all standard dropdown's behaviors.
19
+ *
20
+ * # Creating dropdowns
21
+ *
22
+ * By default, the default {@link module:ui/dropdown/button/dropdownbuttonview~DropdownButtonView} class is used as
23
+ * definition of the button:
24
+ *
25
+ * ```ts
26
+ * const dropdown = createDropdown( model );
27
+ *
28
+ * // Configure dropdown's button properties:
29
+ * dropdown.buttonView.set( {
30
+ * label: 'A dropdown',
31
+ * withText: true
32
+ * } );
33
+ *
34
+ * dropdown.render();
35
+ *
36
+ * // Will render a dropdown labeled "A dropdown" with an empty panel.
37
+ * document.body.appendChild( dropdown.element );
38
+ * ```
39
+ *
40
+ * You can also provide other button views (they need to implement the
41
+ * {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface). For instance, you can use
42
+ * {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} to create a dropdown with a split button.
43
+ *
44
+ * ```ts
45
+ * const dropdown = createDropdown( locale, SplitButtonView );
46
+ *
47
+ * // Configure dropdown's button properties:
48
+ * dropdown.buttonView.set( {
49
+ * label: 'A dropdown',
50
+ * withText: true
51
+ * } );
52
+ *
53
+ * dropdown.buttonView.on( 'execute', () => {
54
+ * // Add the behavior of the "action part" of the split button.
55
+ * // Split button consists of the "action part" and "arrow part".
56
+ * // The arrow opens the dropdown while the action part can have some other behavior.
57
+ * } );
58
+ *
59
+ * dropdown.render();
60
+ *
61
+ * // Will render a dropdown labeled "A dropdown" with an empty panel.
62
+ * document.body.appendChild( dropdown.element );
63
+ * ```
64
+ *
65
+ * # Adding content to the dropdown's panel
66
+ *
67
+ * The content of the panel can be inserted directly into the `dropdown.panelView.element`:
68
+ *
69
+ * ```ts
70
+ * dropdown.panelView.element.textContent = 'Content of the panel';
71
+ * ```
72
+ *
73
+ * However, most of the time you will want to add there either a {@link module:ui/list/listview~ListView list of options}
74
+ * or a list of buttons (i.e. a {@link module:ui/toolbar/toolbarview~ToolbarView toolbar}).
75
+ * To simplify the task, you can use, respectively, {@link module:ui/dropdown/utils~addListToDropdown} or
76
+ * {@link module:ui/dropdown/utils~addToolbarToDropdown} utils.
77
+ *
78
+ * @param locale The locale instance.
79
+ * @param ButtonClass The dropdown button view class. Needs to implement the
80
+ * {@link module:ui/dropdown/button/dropdownbutton~DropdownButton} interface.
81
+ * @returns The dropdown view instance.
82
+ */
83
+ export declare function createDropdown(locale: Locale | undefined, ButtonClass?: new (locale?: Locale) => DropdownButton & FocusableView): DropdownView;
84
+ /**
85
+ * Adds an instance of {@link module:ui/toolbar/toolbarview~ToolbarView} to a dropdown.
86
+ *
87
+ * ```ts
88
+ * const buttonsCreator = () => {
89
+ * const buttons = [];
90
+ *
91
+ * // Either create a new ButtonView instance or create existing.
92
+ * buttons.push( new ButtonView() );
93
+ * buttons.push( editor.ui.componentFactory.create( 'someButton' ) );
94
+ * };
95
+ *
96
+ * const dropdown = createDropdown( locale );
97
+ *
98
+ * addToolbarToDropdown( dropdown, buttonsCreator, { isVertical: true } );
99
+ *
100
+ * // Will render a vertical button dropdown labeled "A button dropdown"
101
+ * // with a button group in the panel containing two buttons.
102
+ * // Buttons inside the dropdown will be created on first dropdown panel open.
103
+ * dropdown.render()
104
+ * document.body.appendChild( dropdown.element );
105
+ * ```
106
+ *
107
+ * **Note:** To improve the accessibility, you can tell the dropdown to focus the first active button of the toolbar when the dropdown
108
+ * {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}. See the documentation of `options` to learn more.
109
+ *
110
+ * **Note:** Toolbar view will be created on first open of the dropdown.
111
+ *
112
+ * See {@link module:ui/dropdown/utils~createDropdown} and {@link module:ui/toolbar/toolbarview~ToolbarView}.
113
+ *
114
+ * @param dropdownView A dropdown instance to which `ToolbarView` will be added.
115
+ * @param options.enableActiveItemFocusOnDropdownOpen When set `true`, the focus will automatically move to the first
116
+ * active {@link module:ui/toolbar/toolbarview~ToolbarView#items item} of the toolbar upon
117
+ * {@link module:ui/dropdown/dropdownview~DropdownView#isOpen opening} the dropdown. Active items are those with the `isOn` property set
118
+ * `true` (for instance {@link module:ui/button/buttonview~ButtonView buttons}). If no active items is found, the toolbar will be focused
119
+ * as a whole resulting in the focus moving to its first focusable item (default behavior of
120
+ * {@link module:ui/dropdown/dropdownview~DropdownView}).
121
+ * @param options.ariaLabel Label used by assistive technologies to describe toolbar element.
122
+ * @param options.maxWidth The maximum width of the toolbar element.
123
+ * Details: {@link module:ui/toolbar/toolbarview~ToolbarView#maxWidth}.
124
+ * @param options.class An additional CSS class added to the toolbar element.
125
+ * @param options.isCompact When set true, makes the toolbar look compact with toolbar element.
126
+ * @param options.isVertical Controls the orientation of toolbar items.
127
+ */
128
+ export declare function addToolbarToDropdown(dropdownView: DropdownView, buttonsOrCallback: Array<View> | ViewCollection | (() => Array<View> | ViewCollection), options?: {
129
+ enableActiveItemFocusOnDropdownOpen?: boolean;
130
+ ariaLabel?: string;
131
+ maxWidth?: string;
132
+ class?: string;
133
+ isCompact?: boolean;
134
+ isVertical?: boolean;
135
+ }): void;
136
+ /**
137
+ * Adds an instance of {@link module:ui/list/listview~ListView} to a dropdown.
138
+ *
139
+ * ```ts
140
+ * const items = new Collection();
141
+ *
142
+ * items.add( {
143
+ * type: 'button',
144
+ * model: new Model( {
145
+ * withText: true,
146
+ * label: 'First item',
147
+ * labelStyle: 'color: red'
148
+ * } )
149
+ * } );
150
+ *
151
+ * items.add( {
152
+ * type: 'button',
153
+ * model: new Model( {
154
+ * withText: true,
155
+ * label: 'Second item',
156
+ * labelStyle: 'color: green',
157
+ * class: 'foo'
158
+ * } )
159
+ * } );
160
+ *
161
+ * const dropdown = createDropdown( locale );
162
+ *
163
+ * addListToDropdown( dropdown, items );
164
+ *
165
+ * // Will render a dropdown with a list in the panel containing two items.
166
+ * dropdown.render()
167
+ * document.body.appendChild( dropdown.element );
168
+ * ```
169
+ *
170
+ * The `items` collection passed to this methods controls the presence and attributes of respective
171
+ * {@link module:ui/list/listitemview~ListItemView list items}.
172
+ *
173
+ * **Note:** To improve the accessibility, when a list is added to the dropdown using this helper the dropdown will automatically attempt
174
+ * to focus the first active item (a host to a {@link module:ui/button/buttonview~ButtonView} with
175
+ * {@link module:ui/button/buttonview~ButtonView#isOn} set `true`) or the very first item when none are active.
176
+ *
177
+ * **Note:** List view will be created on first open of the dropdown.
178
+ *
179
+ * See {@link module:ui/dropdown/utils~createDropdown} and {@link module:list/list~List}.
180
+ *
181
+ * @param dropdownView A dropdown instance to which `ListVIew` will be added.
182
+ * @param itemsOrCallback A collection of the list item definitions or a callback returning a list item definitions to populate the list.
183
+ * @param options.ariaLabel Label used by assistive technologies to describe list element.
184
+ */
185
+ export declare function addListToDropdown(dropdownView: DropdownView, itemsOrCallback: Collection<ListDropdownItemDefinition> | (() => Collection<ListDropdownItemDefinition>), options?: {
186
+ ariaLabel?: string;
187
+ }): void;
188
+ /**
189
+ * A helper to be used on an existing {@link module:ui/dropdown/dropdownview~DropdownView} that focuses
190
+ * a specific child in DOM when the dropdown {@link module:ui/dropdown/dropdownview~DropdownView#isOpen gets open}.
191
+ *
192
+ * @param dropdownView A dropdown instance to which the focus behavior will be added.
193
+ * @param childSelectorCallback A callback executed when the dropdown gets open. It should return a {@link module:ui/view~View}
194
+ * instance (child of {@link module:ui/dropdown/dropdownview~DropdownView#panelView}) that will get focused or a falsy value.
195
+ * If falsy value is returned, a default behavior of the dropdown will engage focusing the first focusable child in
196
+ * the {@link module:ui/dropdown/dropdownview~DropdownView#panelView}.
197
+ */
198
+ export declare function focusChildOnDropdownOpen(dropdownView: DropdownView, childSelectorCallback: () => View | FalsyValue): void;
199
+ /**
200
+ * A definition of the list item used by the {@link module:ui/dropdown/utils~addListToDropdown}
201
+ * utility.
202
+ */
203
+ export type ListDropdownItemDefinition = ListDropdownSeparatorDefinition | ListDropdownButtonDefinition;
204
+ /**
205
+ * A definition of the 'separator' list item.
206
+ */
207
+ export type ListDropdownSeparatorDefinition = {
208
+ type: 'separator';
209
+ };
210
+ /**
211
+ * A definition of the 'button' or 'switchbutton' list item.
212
+ */
213
+ export type ListDropdownButtonDefinition = {
214
+ type: 'button' | 'switchbutton';
215
+ /**
216
+ * Model of the item. Its properties fuel the newly created list item (or its children, depending on the `type`).
217
+ */
218
+ model: Model;
219
+ };