@ckeditor/ckeditor5-ui 48.2.0 → 48.3.0-alpha.1

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 (117) hide show
  1. package/dist/arialiveannouncer.d.ts +90 -90
  2. package/dist/augmentation.d.ts +86 -86
  3. package/dist/autocomplete/autocompleteview.d.ts +70 -70
  4. package/dist/badge/badge.d.ts +119 -121
  5. package/dist/bindings/addkeyboardhandlingforgrid.d.ts +22 -22
  6. package/dist/bindings/clickoutsidehandler.d.ts +25 -25
  7. package/dist/bindings/csstransitiondisablermixin.d.ts +47 -36
  8. package/dist/bindings/draggableviewmixin.d.ts +45 -37
  9. package/dist/bindings/preventdefault.d.ts +30 -30
  10. package/dist/bindings/submithandler.d.ts +49 -49
  11. package/dist/button/button.d.ts +167 -167
  12. package/dist/button/buttonlabel.d.ts +28 -28
  13. package/dist/button/buttonlabelview.d.ts +26 -26
  14. package/dist/button/buttonview.d.ts +192 -192
  15. package/dist/button/filedialogbuttonview.d.ts +107 -99
  16. package/dist/button/listitembuttonview.d.ts +73 -73
  17. package/dist/button/switchbuttonview.d.ts +40 -40
  18. package/dist/collapsible/collapsibleview.d.ts +63 -63
  19. package/dist/colorgrid/colorgridview.d.ts +117 -117
  20. package/dist/colorgrid/colortileview.d.ts +21 -21
  21. package/dist/colorgrid/utils.d.ts +35 -35
  22. package/dist/colorpicker/colorpickerview.d.ts +155 -157
  23. package/dist/colorpicker/utils.d.ts +37 -37
  24. package/dist/colorselector/colorgridsfragmentview.d.ts +191 -191
  25. package/dist/colorselector/colorpickerfragmentview.d.ts +129 -129
  26. package/dist/colorselector/colorselectorview.d.ts +227 -229
  27. package/dist/colorselector/documentcolorcollection.d.ts +52 -59
  28. package/dist/componentfactory.d.ts +76 -76
  29. package/dist/dialog/dialog.d.ts +311 -288
  30. package/dist/dialog/dialogactionsview.d.ts +62 -62
  31. package/dist/dialog/dialogcontentview.d.ts +22 -22
  32. package/dist/dialog/dialogview.d.ts +255 -251
  33. package/dist/dropdown/button/dropdownbutton.d.ts +17 -17
  34. package/dist/dropdown/button/dropdownbuttonview.d.ts +41 -41
  35. package/dist/dropdown/button/splitbuttonview.d.ts +155 -155
  36. package/dist/dropdown/dropdownpanelfocusable.d.ts +16 -16
  37. package/dist/dropdown/dropdownpanelview.d.ts +56 -56
  38. package/dist/dropdown/dropdownview.d.ts +326 -326
  39. package/dist/dropdown/menu/dropdownmenubehaviors.d.ts +43 -43
  40. package/dist/dropdown/menu/dropdownmenubuttonview.d.ts +29 -29
  41. package/dist/dropdown/menu/dropdownmenulistitembuttonview.d.ts +12 -12
  42. package/dist/dropdown/menu/dropdownmenulistitemview.d.ts +17 -17
  43. package/dist/dropdown/menu/dropdownmenulistview.d.ts +19 -19
  44. package/dist/dropdown/menu/dropdownmenunestedmenupanelview.d.ts +28 -28
  45. package/dist/dropdown/menu/dropdownmenunestedmenuview.d.ts +126 -126
  46. package/dist/dropdown/menu/dropdownmenurootlistview.d.ts +132 -132
  47. package/dist/dropdown/menu/utils.d.ts +112 -112
  48. package/dist/dropdown/utils.d.ts +272 -272
  49. package/dist/editableui/editableuiview.d.ts +78 -78
  50. package/dist/editableui/inline/inlineeditableuiview.d.ts +38 -38
  51. package/dist/editorui/accessibilityhelp/accessibilityhelp.d.ts +50 -50
  52. package/dist/editorui/accessibilityhelp/accessibilityhelpcontentview.d.ts +30 -30
  53. package/dist/editorui/bodycollection.d.ts +86 -86
  54. package/dist/editorui/boxed/boxededitoruiview.d.ts +35 -35
  55. package/dist/editorui/editorui.d.ts +348 -351
  56. package/dist/editorui/editoruiview.d.ts +53 -53
  57. package/dist/editorui/evaluationbadge.d.ts +28 -28
  58. package/dist/editorui/poweredby.d.ts +25 -25
  59. package/dist/focuscycler.d.ts +265 -270
  60. package/dist/formheader/formheaderview.d.ts +53 -53
  61. package/dist/formrow/formrowview.d.ts +52 -52
  62. package/dist/highlightedtext/buttonlabelwithhighlightview.d.ts +25 -25
  63. package/dist/highlightedtext/highlightedtextview.d.ts +33 -33
  64. package/dist/highlightedtext/labelwithhighlightview.d.ts +21 -21
  65. package/dist/icon/iconview.d.ts +83 -83
  66. package/dist/iframe/iframeview.d.ts +42 -42
  67. package/dist/index.css.map +1 -1
  68. package/dist/index.d.ts +136 -136
  69. package/dist/index.js +16467 -17751
  70. package/dist/index.js.map +1 -1
  71. package/dist/input/inputbase.d.ts +114 -114
  72. package/dist/input/inputview.d.ts +28 -28
  73. package/dist/inputnumber/inputnumberview.d.ts +44 -44
  74. package/dist/inputtext/inputtextview.d.ts +13 -13
  75. package/dist/label/labelview.d.ts +31 -31
  76. package/dist/labeledfield/labeledfieldview.d.ts +180 -180
  77. package/dist/labeledfield/utils.d.ts +112 -112
  78. package/dist/labeledinput/labeledinputview.d.ts +120 -120
  79. package/dist/legacyerrors.d.ts +0 -4
  80. package/dist/list/listitemgroupview.d.ts +54 -54
  81. package/dist/list/listitemview.d.ts +31 -31
  82. package/dist/list/listseparatorview.d.ts +13 -13
  83. package/dist/list/listview.d.ts +119 -119
  84. package/dist/menubar/menubarmenubuttonview.d.ts +28 -28
  85. package/dist/menubar/menubarmenulistitembuttonview.d.ts +16 -16
  86. package/dist/menubar/menubarmenulistitemfiledialogbuttonview.d.ts +18 -18
  87. package/dist/menubar/menubarmenulistitemview.d.ts +20 -20
  88. package/dist/menubar/menubarmenulistview.d.ts +24 -24
  89. package/dist/menubar/menubarmenupanelview.d.ts +47 -47
  90. package/dist/menubar/menubarmenuview.d.ts +113 -113
  91. package/dist/menubar/menubarview.d.ts +145 -145
  92. package/dist/menubar/utils.d.ts +455 -455
  93. package/dist/model.d.ts +19 -18
  94. package/dist/notification/notification.d.ts +200 -200
  95. package/dist/panel/balloon/balloonpanelview.d.ts +692 -692
  96. package/dist/panel/balloon/contextualballoon.d.ts +298 -298
  97. package/dist/panel/sticky/stickypanelview.d.ts +151 -151
  98. package/dist/search/filteredview.d.ts +23 -23
  99. package/dist/search/filtergroupanditemnames.d.ts +11 -11
  100. package/dist/search/searchinfoview.d.ts +39 -39
  101. package/dist/search/searchresultsview.d.ts +49 -49
  102. package/dist/search/text/searchtextqueryview.d.ts +63 -63
  103. package/dist/search/text/searchtextview.d.ts +203 -203
  104. package/dist/spinner/spinnerview.d.ts +20 -20
  105. package/dist/template.d.ts +897 -902
  106. package/dist/textarea/textareaview.d.ts +96 -96
  107. package/dist/toolbar/balloon/balloontoolbar.d.ts +122 -122
  108. package/dist/toolbar/block/blockbuttonview.d.ts +30 -30
  109. package/dist/toolbar/block/blocktoolbar.d.ts +166 -166
  110. package/dist/toolbar/normalizetoolbarconfig.d.ts +35 -35
  111. package/dist/toolbar/toolbarlinebreakview.d.ts +13 -13
  112. package/dist/toolbar/toolbarseparatorview.d.ts +13 -13
  113. package/dist/toolbar/toolbarview.d.ts +271 -271
  114. package/dist/tooltipmanager.d.ts +190 -193
  115. package/dist/view.d.ts +385 -388
  116. package/dist/viewcollection.d.ts +134 -134
  117. package/package.json +6 -6
package/dist/view.d.ts CHANGED
@@ -1,394 +1,391 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module ui/view
7
- */
8
- import { ViewCollection } from './viewcollection.js';
9
- import { Template, type BindChain, type TemplateDefinition } from './template.js';
10
- import { Collection, type DecoratedMethodEvent, type Locale, type LocaleTranslate } from '@ckeditor/ckeditor5-utils';
11
- import '../theme/index.css';
12
- declare const View_base: import("@ckeditor/ckeditor5-utils").Mixed<{
13
- new (): import("@ckeditor/ckeditor5-utils").Observable;
14
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
15
- }, import("@ckeditor/ckeditor5-utils").DomEmitter>;
6
+ * @module ui/view
7
+ */
8
+ import { ViewCollection } from "./viewcollection.js";
9
+ import { Template, type BindChain, type TemplateDefinition } from "./template.js";
10
+ import { Collection, type DecoratedMethodEvent, type Locale, type LocaleTranslate, type ObservableMixinConstructor, type DomEmitterMixinConstructor } from "@ckeditor/ckeditor5-utils";
11
+ import "../theme/index.css";
12
+ declare const ViewBase: DomEmitterMixinConstructor<ObservableMixinConstructor>;
16
13
  /**
17
- * The basic view class, which represents an HTML element created out of a
18
- * {@link module:ui/view~View#template}. Views are building blocks of the user interface and handle
19
- * interaction
20
- *
21
- * Views {@link module:ui/view~View#registerChild aggregate} children in
22
- * {@link module:ui/view~View#createCollection collections} and manage the life cycle of DOM
23
- * listeners e.g. by handling rendering and destruction.
24
- *
25
- * See the {@link module:ui/template~TemplateDefinition} syntax to learn more about shaping view
26
- * elements, attributes and listeners.
27
- *
28
- * ```ts
29
- * class SampleView extends View {
30
- * constructor( locale ) {
31
- * super( locale );
32
- *
33
- * const bind = this.bindTemplate;
34
- *
35
- * // Views define their interface (state) using observable attributes.
36
- * this.set( 'elementClass', 'bar' );
37
- *
38
- * this.setTemplate( {
39
- * tag: 'p',
40
- *
41
- * // The element of the view can be defined with its children.
42
- * children: [
43
- * 'Hello',
44
- * {
45
- * tag: 'b',
46
- * children: [ 'world!' ]
47
- * }
48
- * ],
49
- * attributes: {
50
- * class: [
51
- * 'foo',
52
- *
53
- * // Observable attributes control the state of the view in DOM.
54
- * bind.to( 'elementClass' )
55
- * ]
56
- * },
57
- * on: {
58
- * // Views listen to DOM events and propagate them.
59
- * click: bind.to( 'clicked' )
60
- * }
61
- * } );
62
- * }
63
- * }
64
- *
65
- * const view = new SampleView( locale );
66
- *
67
- * view.render();
68
- *
69
- * // Append <p class="foo bar">Hello<b>world</b></p> to the <body>
70
- * document.body.appendChild( view.element );
71
- *
72
- * // Change the class attribute to <p class="foo baz">Hello<b>world</b></p>
73
- * view.elementClass = 'baz';
74
- *
75
- * // Respond to the "click" event in DOM by executing a custom action.
76
- * view.on( 'clicked', () => {
77
- * console.log( 'The view has been clicked!' );
78
- * } );
79
- * ```
80
- *
81
- * @property {TElement | null} element An HTML element of the view. `null` until {@link module:ui/view~View#render rendered}
82
- * from the {@link module:ui/view~View#template template}. The class-level example above illustrates typical usage. The
83
- * full description, fenced examples, and assignment note are in the block comment immediately above the `element` field
84
- * in the source.
85
- */
86
- export declare class View<TElement extends HTMLElement = HTMLElement> extends /* #__PURE__ */ View_base {
87
- element: TElement | null;
88
- /**
89
- * Set `true` when the view has already been {@link module:ui/view~View#render rendered}.
90
- *
91
- * @readonly
92
- */
93
- isRendered: boolean;
94
- /**
95
- * A set of tools to localize the user interface.
96
- *
97
- * Also see {@link module:core/editor/editor~Editor#locale}.
98
- *
99
- * @readonly
100
- */
101
- locale: Locale | undefined;
102
- /**
103
- * Shorthand for {@link module:utils/locale~Locale#t}.
104
- *
105
- * Note: If {@link #locale} instance hasn't been passed to the view this method may not
106
- * be available.
107
- *
108
- * @see module:utils/locale~Locale#t
109
- */
110
- t: LocaleTranslate | undefined;
111
- /**
112
- * Template of this view. It provides the {@link #element} representing
113
- * the view in DOM, which is {@link #render rendered}.
114
- */
115
- template?: Template;
116
- viewUid?: string;
117
- /**
118
- * Collections registered with {@link #createCollection}.
119
- */
120
- protected _viewCollections: Collection<ViewCollection>;
121
- /**
122
- * A collection of view instances, which have been added directly
123
- * into the {@link module:ui/template~Template#children}.
124
- */
125
- protected _unboundChildren: ViewCollection;
126
- /**
127
- * Cached {@link module:ui/template~BindChain bind chain} object created by the
128
- * {@link #template}. See {@link #bindTemplate}.
129
- */
130
- private _bindTemplate?;
131
- /**
132
- * Creates an instance of the {@link module:ui/view~View} class.
133
- *
134
- * Also see {@link #render}.
135
- *
136
- * @param locale The localization services instance.
137
- */
138
- constructor(locale?: Locale);
139
- /**
140
- * Shorthand for {@link module:ui/template~Template.bind}, a binding
141
- * {@link module:ui/template~BindChain interface} pre–configured for the view instance.
142
- *
143
- * It provides {@link module:ui/template~BindChain#to `to()`} and
144
- * {@link module:ui/template~BindChain#if `if()`} methods that initialize bindings with
145
- * observable attributes and attach DOM listeners.
146
- *
147
- * ```ts
148
- * class SampleView extends View {
149
- * constructor( locale ) {
150
- * super( locale );
151
- *
152
- * const bind = this.bindTemplate;
153
- *
154
- * // These {@link module:utils/observablemixin~Observable observable} attributes will control
155
- * // the state of the view in DOM.
156
- * this.set( {
157
- * elementClass: 'foo',
158
- * isEnabled: true
159
- * } );
160
- *
161
- * this.setTemplate( {
162
- * tag: 'p',
163
- *
164
- * attributes: {
165
- * // The class HTML attribute will follow elementClass
166
- * // and isEnabled view attributes.
167
- * class: [
168
- * bind.to( 'elementClass' )
169
- * bind.if( 'isEnabled', 'present-when-enabled' )
170
- * ]
171
- * },
172
- *
173
- * on: {
174
- * // The view will fire the "clicked" event upon clicking <p> in DOM.
175
- * click: bind.to( 'clicked' )
176
- * }
177
- * } );
178
- * }
179
- * }
180
- * ```
181
- */
182
- get bindTemplate(): BindChain<this>;
183
- /**
184
- * Creates a new collection of views, which can be used as
185
- * {@link module:ui/template~Template#children} of this view.
186
- *
187
- * ```ts
188
- * class SampleView extends View {
189
- * constructor( locale ) {
190
- * super( locale );
191
- *
192
- * const child = new ChildView( locale );
193
- * this.items = this.createCollection( [ child ] );
194
- *
195
- * this.setTemplate( {
196
- * tag: 'p',
197
- *
198
- * // `items` collection will render here.
199
- * children: this.items
200
- * } );
201
- * }
202
- * }
203
- *
204
- * const view = new SampleView( locale );
205
- * view.render();
206
- *
207
- * // It will append <p><child#element></p> to the <body>.
208
- * document.body.appendChild( view.element );
209
- * ```
210
- *
211
- * @param views Initial views of the collection.
212
- * @returns A new collection of view instances.
213
- */
214
- createCollection<T extends View = View>(views?: Iterable<T>): ViewCollection<T>;
215
- /**
216
- * Registers a new child view under the view instance. Once registered, a child
217
- * view is managed by its parent, including {@link #render rendering}
218
- * and {@link #destroy destruction}.
219
- *
220
- * To revert this, use {@link #deregisterChild}.
221
- *
222
- * ```ts
223
- * class SampleView extends View {
224
- * constructor( locale ) {
225
- * super( locale );
226
- *
227
- * this.childA = new SomeChildView( locale );
228
- * this.childB = new SomeChildView( locale );
229
- *
230
- * this.setTemplate( { tag: 'p' } );
231
- *
232
- * // Register the children.
233
- * this.registerChild( [ this.childA, this.childB ] );
234
- * }
235
- *
236
- * render() {
237
- * super.render();
238
- *
239
- * this.element.appendChild( this.childA.element );
240
- * this.element.appendChild( this.childB.element );
241
- * }
242
- * }
243
- *
244
- * const view = new SampleView( locale );
245
- *
246
- * view.render();
247
- *
248
- * // Will append <p><childA#element><b></b><childB#element></p>.
249
- * document.body.appendChild( view.element );
250
- * ```
251
- *
252
- * **Note**: There's no need to add child views if they're already referenced in the
253
- * {@link #template}:
254
- *
255
- * ```ts
256
- * class SampleView extends View {
257
- * constructor( locale ) {
258
- * super( locale );
259
- *
260
- * this.childA = new SomeChildView( locale );
261
- * this.childB = new SomeChildView( locale );
262
- *
263
- * this.setTemplate( {
264
- * tag: 'p',
265
- *
266
- * // These children will be added automatically. There's no
267
- * // need to call {@link #registerChild} for any of them.
268
- * children: [ this.childA, this.childB ]
269
- * } );
270
- * }
271
- *
272
- * // ...
273
- * }
274
- * ```
275
- *
276
- * @param children Children views to be registered.
277
- */
278
- registerChild(children: View | Iterable<View>): void;
279
- /**
280
- * The opposite of {@link #registerChild}. Removes a child view from this view instance.
281
- * Once removed, the child is no longer managed by its parent, e.g. it can safely
282
- * become a child of another parent view.
283
- *
284
- * @see #registerChild
285
- * @param children Child views to be removed.
286
- */
287
- deregisterChild(children: View | Iterable<View>): void;
288
- /**
289
- * Sets the {@link #template} of the view with with given definition.
290
- *
291
- * A shorthand for:
292
- *
293
- * ```ts
294
- * view.setTemplate( definition );
295
- * ```
296
- *
297
- * @param definition Definition of view's template.
298
- */
299
- setTemplate(definition: TemplateDefinition): void;
300
- /**
301
- * {@link module:ui/template~Template.extend Extends} the {@link #template} of the view with
302
- * with given definition.
303
- *
304
- * A shorthand for:
305
- *
306
- * ```ts
307
- * Template.extend( view.template, definition );
308
- * ```
309
- *
310
- * **Note**: Is requires the {@link #template} to be already set. See {@link #setTemplate}.
311
- *
312
- * @param definition Definition which extends the {@link #template}.
313
- */
314
- extendTemplate(definition: Partial<TemplateDefinition>): void;
315
- /**
316
- * Recursively renders the view.
317
- *
318
- * Once the view is rendered:
319
- * * the {@link #element} becomes an HTML element out of {@link #template},
320
- * * the {@link #isRendered} flag is set `true`.
321
- *
322
- * **Note**: The children of the view:
323
- * * defined directly in the {@link #template}
324
- * * residing in collections created by the {@link #createCollection} method,
325
- * * and added by {@link #registerChild}
326
- * are also rendered in the process.
327
- *
328
- * In general, `render()` method is the right place to keep the code which refers to the
329
- * {@link #element} and should be executed at the very beginning of the view's life cycle.
330
- *
331
- * It is possible to {@link module:ui/template~Template.extend} the {@link #template} before
332
- * the view is rendered. To allow an early customization of the view (e.g. by its parent),
333
- * such references should be done in `render()`.
334
- *
335
- * ```ts
336
- * class SampleView extends View {
337
- * constructor() {
338
- * this.setTemplate( {
339
- * // ...
340
- * } );
341
- * },
342
- *
343
- * render() {
344
- * // View#element becomes available.
345
- * super.render();
346
- *
347
- * // The "scroll" listener depends on #element.
348
- * this.listenTo( window, 'scroll', () => {
349
- * // A reference to #element would render the #template and make it non-extendable.
350
- * if ( window.scrollY > 0 ) {
351
- * this.element.scrollLeft = 100;
352
- * } else {
353
- * this.element.scrollLeft = 0;
354
- * }
355
- * } );
356
- * }
357
- * }
358
- *
359
- * const view = new SampleView();
360
- *
361
- * // Let's customize the view before it gets rendered.
362
- * view.extendTemplate( {
363
- * attributes: {
364
- * class: [
365
- * 'additional-class'
366
- * ]
367
- * }
368
- * } );
369
- *
370
- * // Late rendering allows customization of the view.
371
- * view.render();
372
- * ```
373
- */
374
- render(): void;
375
- /**
376
- * Recursively destroys the view instance and child views added by {@link #registerChild} and
377
- * residing in collections created by the {@link #createCollection}.
378
- *
379
- * Destruction disables all event listeners:
380
- * * created on the view, e.g. `view.on( 'event', () => {} )`,
381
- * * defined in the {@link #template} for DOM events.
382
- */
383
- destroy(): void;
14
+ * The basic view class, which represents an HTML element created out of a
15
+ * {@link module:ui/view~View#template}. Views are building blocks of the user interface and handle
16
+ * interaction
17
+ *
18
+ * Views {@link module:ui/view~View#registerChild aggregate} children in
19
+ * {@link module:ui/view~View#createCollection collections} and manage the life cycle of DOM
20
+ * listeners e.g. by handling rendering and destruction.
21
+ *
22
+ * See the {@link module:ui/template~TemplateDefinition} syntax to learn more about shaping view
23
+ * elements, attributes and listeners.
24
+ *
25
+ * ```ts
26
+ * class SampleView extends View {
27
+ * constructor( locale ) {
28
+ * super( locale );
29
+ *
30
+ * const bind = this.bindTemplate;
31
+ *
32
+ * // Views define their interface (state) using observable attributes.
33
+ * this.set( 'elementClass', 'bar' );
34
+ *
35
+ * this.setTemplate( {
36
+ * tag: 'p',
37
+ *
38
+ * // The element of the view can be defined with its children.
39
+ * children: [
40
+ * 'Hello',
41
+ * {
42
+ * tag: 'b',
43
+ * children: [ 'world!' ]
44
+ * }
45
+ * ],
46
+ * attributes: {
47
+ * class: [
48
+ * 'foo',
49
+ *
50
+ * // Observable attributes control the state of the view in DOM.
51
+ * bind.to( 'elementClass' )
52
+ * ]
53
+ * },
54
+ * on: {
55
+ * // Views listen to DOM events and propagate them.
56
+ * click: bind.to( 'clicked' )
57
+ * }
58
+ * } );
59
+ * }
60
+ * }
61
+ *
62
+ * const view = new SampleView( locale );
63
+ *
64
+ * view.render();
65
+ *
66
+ * // Append <p class="foo bar">Hello<b>world</b></p> to the <body>
67
+ * document.body.appendChild( view.element );
68
+ *
69
+ * // Change the class attribute to <p class="foo baz">Hello<b>world</b></p>
70
+ * view.elementClass = 'baz';
71
+ *
72
+ * // Respond to the "click" event in DOM by executing a custom action.
73
+ * view.on( 'clicked', () => {
74
+ * console.log( 'The view has been clicked!' );
75
+ * } );
76
+ * ```
77
+ *
78
+ * @property {TElement | null} element An HTML element of the view. `null` until {@link module:ui/view~View#render rendered}
79
+ * from the {@link module:ui/view~View#template template}. The class-level example above illustrates typical usage. The
80
+ * full description, fenced examples, and assignment note are in the block comment immediately above the `element` field
81
+ * in the source.
82
+ */
83
+ export declare class View<TElement extends HTMLElement = HTMLElement> extends ViewBase {
84
+ element: TElement | null;
85
+ /**
86
+ * Set `true` when the view has already been {@link module:ui/view~View#render rendered}.
87
+ *
88
+ * @readonly
89
+ */
90
+ isRendered: boolean;
91
+ /**
92
+ * A set of tools to localize the user interface.
93
+ *
94
+ * Also see {@link module:core/editor/editor~Editor#locale}.
95
+ *
96
+ * @readonly
97
+ */
98
+ locale: Locale | undefined;
99
+ /**
100
+ * Shorthand for {@link module:utils/locale~Locale#t}.
101
+ *
102
+ * Note: If {@link #locale} instance hasn't been passed to the view this method may not
103
+ * be available.
104
+ *
105
+ * @see module:utils/locale~Locale#t
106
+ */
107
+ t: LocaleTranslate | undefined;
108
+ /**
109
+ * Template of this view. It provides the {@link #element} representing
110
+ * the view in DOM, which is {@link #render rendered}.
111
+ */
112
+ template?: Template;
113
+ viewUid?: string;
114
+ /**
115
+ * Collections registered with {@link #createCollection}.
116
+ */
117
+ protected _viewCollections: Collection<ViewCollection>;
118
+ /**
119
+ * A collection of view instances, which have been added directly
120
+ * into the {@link module:ui/template~Template#children}.
121
+ */
122
+ protected _unboundChildren: ViewCollection;
123
+ /**
124
+ * Cached {@link module:ui/template~BindChain bind chain} object created by the
125
+ * {@link #template}. See {@link #bindTemplate}.
126
+ */
127
+ private _bindTemplate?;
128
+ /**
129
+ * Creates an instance of the {@link module:ui/view~View} class.
130
+ *
131
+ * Also see {@link #render}.
132
+ *
133
+ * @param locale The localization services instance.
134
+ */
135
+ constructor(locale?: Locale);
136
+ /**
137
+ * Shorthand for {@link module:ui/template~Template.bind}, a binding
138
+ * {@link module:ui/template~BindChain interface} pre–configured for the view instance.
139
+ *
140
+ * It provides {@link module:ui/template~BindChain#to `to()`} and
141
+ * {@link module:ui/template~BindChain#if `if()`} methods that initialize bindings with
142
+ * observable attributes and attach DOM listeners.
143
+ *
144
+ * ```ts
145
+ * class SampleView extends View {
146
+ * constructor( locale ) {
147
+ * super( locale );
148
+ *
149
+ * const bind = this.bindTemplate;
150
+ *
151
+ * // These {@link module:utils/observablemixin~Observable observable} attributes will control
152
+ * // the state of the view in DOM.
153
+ * this.set( {
154
+ * elementClass: 'foo',
155
+ * isEnabled: true
156
+ * } );
157
+ *
158
+ * this.setTemplate( {
159
+ * tag: 'p',
160
+ *
161
+ * attributes: {
162
+ * // The class HTML attribute will follow elementClass
163
+ * // and isEnabled view attributes.
164
+ * class: [
165
+ * bind.to( 'elementClass' )
166
+ * bind.if( 'isEnabled', 'present-when-enabled' )
167
+ * ]
168
+ * },
169
+ *
170
+ * on: {
171
+ * // The view will fire the "clicked" event upon clicking <p> in DOM.
172
+ * click: bind.to( 'clicked' )
173
+ * }
174
+ * } );
175
+ * }
176
+ * }
177
+ * ```
178
+ */
179
+ get bindTemplate(): BindChain<this>;
180
+ /**
181
+ * Creates a new collection of views, which can be used as
182
+ * {@link module:ui/template~Template#children} of this view.
183
+ *
184
+ * ```ts
185
+ * class SampleView extends View {
186
+ * constructor( locale ) {
187
+ * super( locale );
188
+ *
189
+ * const child = new ChildView( locale );
190
+ * this.items = this.createCollection( [ child ] );
191
+ *
192
+ * this.setTemplate( {
193
+ * tag: 'p',
194
+ *
195
+ * // `items` collection will render here.
196
+ * children: this.items
197
+ * } );
198
+ * }
199
+ * }
200
+ *
201
+ * const view = new SampleView( locale );
202
+ * view.render();
203
+ *
204
+ * // It will append <p><child#element></p> to the <body>.
205
+ * document.body.appendChild( view.element );
206
+ * ```
207
+ *
208
+ * @param views Initial views of the collection.
209
+ * @returns A new collection of view instances.
210
+ */
211
+ createCollection<T extends View = View>(views?: Iterable<T>): ViewCollection<T>;
212
+ /**
213
+ * Registers a new child view under the view instance. Once registered, a child
214
+ * view is managed by its parent, including {@link #render rendering}
215
+ * and {@link #destroy destruction}.
216
+ *
217
+ * To revert this, use {@link #deregisterChild}.
218
+ *
219
+ * ```ts
220
+ * class SampleView extends View {
221
+ * constructor( locale ) {
222
+ * super( locale );
223
+ *
224
+ * this.childA = new SomeChildView( locale );
225
+ * this.childB = new SomeChildView( locale );
226
+ *
227
+ * this.setTemplate( { tag: 'p' } );
228
+ *
229
+ * // Register the children.
230
+ * this.registerChild( [ this.childA, this.childB ] );
231
+ * }
232
+ *
233
+ * render() {
234
+ * super.render();
235
+ *
236
+ * this.element.appendChild( this.childA.element );
237
+ * this.element.appendChild( this.childB.element );
238
+ * }
239
+ * }
240
+ *
241
+ * const view = new SampleView( locale );
242
+ *
243
+ * view.render();
244
+ *
245
+ * // Will append <p><childA#element><b></b><childB#element></p>.
246
+ * document.body.appendChild( view.element );
247
+ * ```
248
+ *
249
+ * **Note**: There's no need to add child views if they're already referenced in the
250
+ * {@link #template}:
251
+ *
252
+ * ```ts
253
+ * class SampleView extends View {
254
+ * constructor( locale ) {
255
+ * super( locale );
256
+ *
257
+ * this.childA = new SomeChildView( locale );
258
+ * this.childB = new SomeChildView( locale );
259
+ *
260
+ * this.setTemplate( {
261
+ * tag: 'p',
262
+ *
263
+ * // These children will be added automatically. There's no
264
+ * // need to call {@link #registerChild} for any of them.
265
+ * children: [ this.childA, this.childB ]
266
+ * } );
267
+ * }
268
+ *
269
+ * // ...
270
+ * }
271
+ * ```
272
+ *
273
+ * @param children Children views to be registered.
274
+ */
275
+ registerChild(children: View | Iterable<View>): void;
276
+ /**
277
+ * The opposite of {@link #registerChild}. Removes a child view from this view instance.
278
+ * Once removed, the child is no longer managed by its parent, e.g. it can safely
279
+ * become a child of another parent view.
280
+ *
281
+ * @see #registerChild
282
+ * @param children Child views to be removed.
283
+ */
284
+ deregisterChild(children: View | Iterable<View>): void;
285
+ /**
286
+ * Sets the {@link #template} of the view with with given definition.
287
+ *
288
+ * A shorthand for:
289
+ *
290
+ * ```ts
291
+ * view.setTemplate( definition );
292
+ * ```
293
+ *
294
+ * @param definition Definition of view's template.
295
+ */
296
+ setTemplate(definition: TemplateDefinition): void;
297
+ /**
298
+ * {@link module:ui/template~Template.extend Extends} the {@link #template} of the view with
299
+ * with given definition.
300
+ *
301
+ * A shorthand for:
302
+ *
303
+ * ```ts
304
+ * Template.extend( view.template, definition );
305
+ * ```
306
+ *
307
+ * **Note**: Is requires the {@link #template} to be already set. See {@link #setTemplate}.
308
+ *
309
+ * @param definition Definition which extends the {@link #template}.
310
+ */
311
+ extendTemplate(definition: Partial<TemplateDefinition>): void;
312
+ /**
313
+ * Recursively renders the view.
314
+ *
315
+ * Once the view is rendered:
316
+ * * the {@link #element} becomes an HTML element out of {@link #template},
317
+ * * the {@link #isRendered} flag is set `true`.
318
+ *
319
+ * **Note**: The children of the view:
320
+ * * defined directly in the {@link #template}
321
+ * * residing in collections created by the {@link #createCollection} method,
322
+ * * and added by {@link #registerChild}
323
+ * are also rendered in the process.
324
+ *
325
+ * In general, `render()` method is the right place to keep the code which refers to the
326
+ * {@link #element} and should be executed at the very beginning of the view's life cycle.
327
+ *
328
+ * It is possible to {@link module:ui/template~Template.extend} the {@link #template} before
329
+ * the view is rendered. To allow an early customization of the view (e.g. by its parent),
330
+ * such references should be done in `render()`.
331
+ *
332
+ * ```ts
333
+ * class SampleView extends View {
334
+ * constructor() {
335
+ * this.setTemplate( {
336
+ * // ...
337
+ * } );
338
+ * },
339
+ *
340
+ * render() {
341
+ * // View#element becomes available.
342
+ * super.render();
343
+ *
344
+ * // The "scroll" listener depends on #element.
345
+ * this.listenTo( window, 'scroll', () => {
346
+ * // A reference to #element would render the #template and make it non-extendable.
347
+ * if ( window.scrollY > 0 ) {
348
+ * this.element.scrollLeft = 100;
349
+ * } else {
350
+ * this.element.scrollLeft = 0;
351
+ * }
352
+ * } );
353
+ * }
354
+ * }
355
+ *
356
+ * const view = new SampleView();
357
+ *
358
+ * // Let's customize the view before it gets rendered.
359
+ * view.extendTemplate( {
360
+ * attributes: {
361
+ * class: [
362
+ * 'additional-class'
363
+ * ]
364
+ * }
365
+ * } );
366
+ *
367
+ * // Late rendering allows customization of the view.
368
+ * view.render();
369
+ * ```
370
+ */
371
+ render(): void;
372
+ /**
373
+ * Recursively destroys the view instance and child views added by {@link #registerChild} and
374
+ * residing in collections created by the {@link #createCollection}.
375
+ *
376
+ * Destruction disables all event listeners:
377
+ * * created on the view, e.g. `view.on( 'event', () => {} )`,
378
+ * * defined in the {@link #template} for DOM events.
379
+ */
380
+ destroy(): void;
384
381
  }
385
382
  /**
386
- * Event fired by the {@link module:ui/view~View#render} method. Actual rendering is executed as a listener to
387
- * this event with the default priority.
388
- *
389
- * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
390
- *
391
- * @eventName ~View#render
392
- */
393
- export type UIViewRenderEvent = DecoratedMethodEvent<View, 'render'>;
383
+ * Event fired by the {@link module:ui/view~View#render} method. Actual rendering is executed as a listener to
384
+ * this event with the default priority.
385
+ *
386
+ * See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
387
+ *
388
+ * @eventName ~View#render
389
+ */
390
+ export type UIViewRenderEvent = DecoratedMethodEvent<View, "render">;
394
391
  export {};