@ckeditor/ckeditor5-ui 35.2.1 → 35.3.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 (59) hide show
  1. package/package.json +31 -23
  2. package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
  3. package/src/bindings/clickoutsidehandler.js +15 -21
  4. package/src/bindings/injectcsstransitiondisabler.js +16 -20
  5. package/src/bindings/preventdefault.js +6 -8
  6. package/src/bindings/submithandler.js +5 -7
  7. package/src/button/button.js +5 -0
  8. package/src/button/buttonview.js +220 -259
  9. package/src/button/switchbuttonview.js +56 -71
  10. package/src/colorgrid/colorgridview.js +135 -197
  11. package/src/colorgrid/colortileview.js +37 -47
  12. package/src/colorgrid/utils.js +57 -66
  13. package/src/componentfactory.js +79 -93
  14. package/src/dropdown/button/dropdownbutton.js +5 -0
  15. package/src/dropdown/button/dropdownbuttonview.js +44 -57
  16. package/src/dropdown/button/splitbuttonview.js +159 -207
  17. package/src/dropdown/dropdownpanelfocusable.js +5 -0
  18. package/src/dropdown/dropdownpanelview.js +101 -112
  19. package/src/dropdown/dropdownview.js +396 -438
  20. package/src/dropdown/utils.js +164 -213
  21. package/src/editableui/editableuiview.js +125 -141
  22. package/src/editableui/inline/inlineeditableuiview.js +44 -54
  23. package/src/editorui/bodycollection.js +61 -75
  24. package/src/editorui/boxed/boxededitoruiview.js +91 -104
  25. package/src/editorui/editoruiview.js +30 -39
  26. package/src/focuscycler.js +214 -245
  27. package/src/formheader/formheaderview.js +58 -70
  28. package/src/icon/iconview.js +145 -111
  29. package/src/iframe/iframeview.js +37 -49
  30. package/src/index.js +0 -17
  31. package/src/input/inputview.js +170 -198
  32. package/src/inputnumber/inputnumberview.js +48 -56
  33. package/src/inputtext/inputtextview.js +14 -18
  34. package/src/label/labelview.js +44 -53
  35. package/src/labeledfield/labeledfieldview.js +212 -235
  36. package/src/labeledfield/utils.js +39 -57
  37. package/src/labeledinput/labeledinputview.js +190 -221
  38. package/src/list/listitemview.js +40 -50
  39. package/src/list/listseparatorview.js +15 -19
  40. package/src/list/listview.js +94 -115
  41. package/src/model.js +19 -25
  42. package/src/notification/notification.js +151 -202
  43. package/src/panel/balloon/balloonpanelview.js +535 -628
  44. package/src/panel/balloon/contextualballoon.js +611 -732
  45. package/src/panel/sticky/stickypanelview.js +238 -270
  46. package/src/template.js +1049 -1479
  47. package/src/toolbar/balloon/balloontoolbar.js +337 -424
  48. package/src/toolbar/block/blockbuttonview.js +32 -42
  49. package/src/toolbar/block/blocktoolbar.js +375 -477
  50. package/src/toolbar/normalizetoolbarconfig.js +17 -21
  51. package/src/toolbar/toolbarlinebreakview.js +15 -19
  52. package/src/toolbar/toolbarseparatorview.js +15 -19
  53. package/src/toolbar/toolbarview.js +866 -1053
  54. package/src/tooltipmanager.js +324 -353
  55. package/src/view.js +389 -430
  56. package/src/viewcollection.js +147 -178
  57. package/src/button/button.jsdoc +0 -165
  58. package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
  59. package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
@@ -2,238 +2,207 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module ui/labeledinput/labeledinputview
8
7
  */
9
-
10
8
  import View from '../view';
11
9
  import uid from '@ckeditor/ckeditor5-utils/src/uid';
12
10
  import LabelView from '../label/labelview';
13
11
  import '../../theme/components/labeledinput/labeledinput.css';
14
-
15
12
  /**
16
13
  * The labeled input view class.
17
14
  *
18
15
  * @extends module:ui/view~View
19
16
  */
20
17
  export default class LabeledInputView extends View {
21
- /**
22
- * Creates an instance of the labeled input view class.
23
- *
24
- * @param {module:utils/locale~Locale} locale The locale instance.
25
- * @param {Function} InputView Constructor of the input view.
26
- */
27
- constructor( locale, InputView ) {
28
- super( locale );
29
-
30
- const inputUid = `ck-input-${ uid() }`;
31
- const statusUid = `ck-status-${ uid() }`;
32
-
33
- /**
34
- * The text of the label.
35
- *
36
- * @observable
37
- * @member {String} #label
38
- */
39
- this.set( 'label' );
40
-
41
- /**
42
- * The value of the input.
43
- *
44
- * @observable
45
- * @member {String} #value
46
- */
47
- this.set( 'value' );
48
-
49
- /**
50
- * Controls whether the component is in read-only mode.
51
- *
52
- * @observable
53
- * @member {Boolean} #isReadOnly
54
- */
55
- this.set( 'isReadOnly', false );
56
-
57
- /**
58
- * The validation error text. When set, it will be displayed
59
- * next to the {@link #inputView} as a typical validation error message.
60
- * Set it to `null` to hide the message.
61
- *
62
- * **Note:** Setting this property to anything but `null` will automatically
63
- * make the {@link module:ui/inputtext/inputtextview~InputTextView#hasError `hasError`}
64
- * of the {@link #inputView} `true`.
65
- *
66
- * **Note:** Typing in the {@link #inputView} which fires the
67
- * {@link module:ui/inputtext/inputtextview~InputTextView#event:input `input` event}
68
- * resets this property back to `null`, indicating that the input field can be re–validated.
69
- *
70
- * @observable
71
- * @member {String|null} #errorText
72
- */
73
- this.set( 'errorText', null );
74
-
75
- /**
76
- * The additional information text displayed next to the {@link #inputView} which can
77
- * be used to inform the user about the purpose of the input, provide help or hints.
78
- *
79
- * Set it to `null` to hide the message.
80
- *
81
- * **Note:** This text will be displayed in the same place as {@link #errorText} but the
82
- * latter always takes precedence: if the {@link #errorText} is set, it replaces
83
- * {@link #errorText} for as long as the value of the input is invalid.
84
- *
85
- * @observable
86
- * @member {String|null} #infoText
87
- */
88
- this.set( 'infoText', null );
89
-
90
- /**
91
- * The label view.
92
- *
93
- * @member {module:ui/label/labelview~LabelView} #labelView
94
- */
95
- this.labelView = this._createLabelView( inputUid );
96
-
97
- /**
98
- * The input view.
99
- *
100
- * @member {module:ui/inputtext/inputtextview~InputTextView} #inputView
101
- */
102
- this.inputView = this._createInputView( InputView, inputUid, statusUid );
103
-
104
- /**
105
- * The status view for the {@link #inputView}. It displays {@link #errorText} and
106
- * {@link #infoText}.
107
- *
108
- * @member {module:ui/view~View} #statusView
109
- */
110
- this.statusView = this._createStatusView( statusUid );
111
-
112
- /**
113
- * The combined status text made of {@link #errorText} and {@link #infoText}.
114
- * Note that when present, {@link #errorText} always takes precedence in the
115
- * status.
116
- *
117
- * @see #errorText
118
- * @see #infoText
119
- * @see #statusView
120
- * @private
121
- * @observable
122
- * @member {String|null} #_statusText
123
- */
124
- this.bind( '_statusText' ).to(
125
- this, 'errorText',
126
- this, 'infoText',
127
- ( errorText, infoText ) => errorText || infoText
128
- );
129
-
130
- const bind = this.bindTemplate;
131
-
132
- this.setTemplate( {
133
- tag: 'div',
134
- attributes: {
135
- class: [
136
- 'ck',
137
- 'ck-labeled-input',
138
- bind.if( 'isReadOnly', 'ck-disabled' )
139
- ]
140
- },
141
- children: [
142
- this.labelView,
143
- this.inputView,
144
- this.statusView
145
- ]
146
- } );
147
- }
148
-
149
- /**
150
- * Creates label view class instance and bind with view.
151
- *
152
- * @private
153
- * @param {String} id Unique id to set as labelView#for attribute.
154
- * @returns {module:ui/label/labelview~LabelView}
155
- */
156
- _createLabelView( id ) {
157
- const labelView = new LabelView( this.locale );
158
-
159
- labelView.for = id;
160
- labelView.bind( 'text' ).to( this, 'label' );
161
-
162
- return labelView;
163
- }
164
-
165
- /**
166
- * Creates input view class instance and bind with view.
167
- *
168
- * @private
169
- * @param {Function} InputView Input view constructor.
170
- * @param {String} inputUid Unique id to set as inputView#id attribute.
171
- * @param {String} statusUid Unique id of the status for the input's `aria-describedby` attribute.
172
- * @returns {module:ui/inputtext/inputtextview~InputTextView}
173
- */
174
- _createInputView( InputView, inputUid, statusUid ) {
175
- const inputView = new InputView( this.locale, statusUid );
176
-
177
- inputView.id = inputUid;
178
- inputView.ariaDescribedById = statusUid;
179
- inputView.bind( 'value' ).to( this );
180
- inputView.bind( 'isReadOnly' ).to( this );
181
- inputView.bind( 'hasError' ).to( this, 'errorText', value => !!value );
182
-
183
- inputView.on( 'input', () => {
184
- // UX: Make the error text disappear and disable the error indicator as the user
185
- // starts fixing the errors.
186
- this.errorText = null;
187
- } );
188
-
189
- return inputView;
190
- }
191
-
192
- /**
193
- * Creates the status view instance. It displays {@link #errorText} and {@link #infoText}
194
- * next to the {@link #inputView}. See {@link #_statusText}.
195
- *
196
- * @private
197
- * @param {String} statusUid Unique id of the status, shared with the input's `aria-describedby` attribute.
198
- * @returns {module:ui/view~View}
199
- */
200
- _createStatusView( statusUid ) {
201
- const statusView = new View( this.locale );
202
- const bind = this.bindTemplate;
203
-
204
- statusView.setTemplate( {
205
- tag: 'div',
206
- attributes: {
207
- class: [
208
- 'ck',
209
- 'ck-labeled-input__status',
210
- bind.if( 'errorText', 'ck-labeled-input__status_error' ),
211
- bind.if( '_statusText', 'ck-hidden', value => !value )
212
- ],
213
- id: statusUid,
214
- role: bind.if( 'errorText', 'alert' )
215
- },
216
- children: [
217
- {
218
- text: bind.to( '_statusText' )
219
- }
220
- ]
221
- } );
222
-
223
- return statusView;
224
- }
225
-
226
- /**
227
- * Moves the focus to the input and selects the value.
228
- */
229
- select() {
230
- this.inputView.select();
231
- }
232
-
233
- /**
234
- * Focuses the input.
235
- */
236
- focus() {
237
- this.inputView.focus();
238
- }
18
+ /**
19
+ * Creates an instance of the labeled input view class.
20
+ *
21
+ * @param {module:utils/locale~Locale} locale The locale instance.
22
+ * @param {Function} InputView Constructor of the input view.
23
+ */
24
+ constructor(locale, InputView) {
25
+ super(locale);
26
+ const inputUid = `ck-input-${uid()}`;
27
+ const statusUid = `ck-status-${uid()}`;
28
+ /**
29
+ * The text of the label.
30
+ *
31
+ * @observable
32
+ * @member {String} #label
33
+ */
34
+ this.set('label', undefined);
35
+ /**
36
+ * The value of the input.
37
+ *
38
+ * @observable
39
+ * @member {String} #value
40
+ */
41
+ this.set('value', undefined);
42
+ /**
43
+ * Controls whether the component is in read-only mode.
44
+ *
45
+ * @observable
46
+ * @member {Boolean} #isReadOnly
47
+ */
48
+ this.set('isReadOnly', false);
49
+ /**
50
+ * The validation error text. When set, it will be displayed
51
+ * next to the {@link #inputView} as a typical validation error message.
52
+ * Set it to `null` to hide the message.
53
+ *
54
+ * **Note:** Setting this property to anything but `null` will automatically
55
+ * make the {@link module:ui/inputtext/inputtextview~InputTextView#hasError `hasError`}
56
+ * of the {@link #inputView} `true`.
57
+ *
58
+ * **Note:** Typing in the {@link #inputView} which fires the
59
+ * {@link module:ui/inputtext/inputtextview~InputTextView#event:input `input` event}
60
+ * resets this property back to `null`, indicating that the input field can be re–validated.
61
+ *
62
+ * @observable
63
+ * @member {String|null} #errorText
64
+ */
65
+ this.set('errorText', null);
66
+ /**
67
+ * The additional information text displayed next to the {@link #inputView} which can
68
+ * be used to inform the user about the purpose of the input, provide help or hints.
69
+ *
70
+ * Set it to `null` to hide the message.
71
+ *
72
+ * **Note:** This text will be displayed in the same place as {@link #errorText} but the
73
+ * latter always takes precedence: if the {@link #errorText} is set, it replaces
74
+ * {@link #errorText} for as long as the value of the input is invalid.
75
+ *
76
+ * @observable
77
+ * @member {String|null} #infoText
78
+ */
79
+ this.set('infoText', null);
80
+ /**
81
+ * The label view.
82
+ *
83
+ * @member {module:ui/label/labelview~LabelView} #labelView
84
+ */
85
+ this.labelView = this._createLabelView(inputUid);
86
+ /**
87
+ * The input view.
88
+ *
89
+ * @member {module:ui/inputtext/inputtextview~InputTextView} #inputView
90
+ */
91
+ this.inputView = this._createInputView(InputView, inputUid, statusUid);
92
+ /**
93
+ * The status view for the {@link #inputView}. It displays {@link #errorText} and
94
+ * {@link #infoText}.
95
+ *
96
+ * @member {module:ui/view~View} #statusView
97
+ */
98
+ this.statusView = this._createStatusView(statusUid);
99
+ /**
100
+ * The combined status text made of {@link #errorText} and {@link #infoText}.
101
+ * Note that when present, {@link #errorText} always takes precedence in the
102
+ * status.
103
+ *
104
+ * @see #errorText
105
+ * @see #infoText
106
+ * @see #statusView
107
+ * @private
108
+ * @observable
109
+ * @member {String|null} #_statusText
110
+ */
111
+ this.bind('_statusText').to(this, 'errorText', this, 'infoText', (errorText, infoText) => errorText || infoText);
112
+ const bind = this.bindTemplate;
113
+ this.setTemplate({
114
+ tag: 'div',
115
+ attributes: {
116
+ class: [
117
+ 'ck',
118
+ 'ck-labeled-input',
119
+ bind.if('isReadOnly', 'ck-disabled')
120
+ ]
121
+ },
122
+ children: [
123
+ this.labelView,
124
+ this.inputView,
125
+ this.statusView
126
+ ]
127
+ });
128
+ }
129
+ /**
130
+ * Creates label view class instance and bind with view.
131
+ *
132
+ * @private
133
+ * @param {String} id Unique id to set as labelView#for attribute.
134
+ * @returns {module:ui/label/labelview~LabelView}
135
+ */
136
+ _createLabelView(id) {
137
+ const labelView = new LabelView(this.locale);
138
+ labelView.for = id;
139
+ labelView.bind('text').to(this, 'label');
140
+ return labelView;
141
+ }
142
+ /**
143
+ * Creates input view class instance and bind with view.
144
+ *
145
+ * @private
146
+ * @param {Function} InputView Input view constructor.
147
+ * @param {String} inputUid Unique id to set as inputView#id attribute.
148
+ * @param {String} statusUid Unique id of the status for the input's `aria-describedby` attribute.
149
+ * @returns {module:ui/inputtext/inputtextview~InputTextView}
150
+ */
151
+ _createInputView(InputView, inputUid, statusUid) {
152
+ const inputView = new InputView(this.locale, statusUid);
153
+ inputView.id = inputUid;
154
+ inputView.ariaDescribedById = statusUid;
155
+ inputView.bind('value').to(this);
156
+ inputView.bind('isReadOnly').to(this);
157
+ inputView.bind('hasError').to(this, 'errorText', value => !!value);
158
+ inputView.on('input', () => {
159
+ // UX: Make the error text disappear and disable the error indicator as the user
160
+ // starts fixing the errors.
161
+ this.errorText = null;
162
+ });
163
+ return inputView;
164
+ }
165
+ /**
166
+ * Creates the status view instance. It displays {@link #errorText} and {@link #infoText}
167
+ * next to the {@link #inputView}. See {@link #_statusText}.
168
+ *
169
+ * @private
170
+ * @param {String} statusUid Unique id of the status, shared with the input's `aria-describedby` attribute.
171
+ * @returns {module:ui/view~View}
172
+ */
173
+ _createStatusView(statusUid) {
174
+ const statusView = new View(this.locale);
175
+ const bind = this.bindTemplate;
176
+ statusView.setTemplate({
177
+ tag: 'div',
178
+ attributes: {
179
+ class: [
180
+ 'ck',
181
+ 'ck-labeled-input__status',
182
+ bind.if('errorText', 'ck-labeled-input__status_error'),
183
+ bind.if('_statusText', 'ck-hidden', value => !value)
184
+ ],
185
+ id: statusUid,
186
+ role: bind.if('errorText', 'alert')
187
+ },
188
+ children: [
189
+ {
190
+ text: bind.to('_statusText')
191
+ }
192
+ ]
193
+ });
194
+ return statusView;
195
+ }
196
+ /**
197
+ * Moves the focus to the input and selects the value.
198
+ */
199
+ select() {
200
+ this.inputView.select();
201
+ }
202
+ /**
203
+ * Focuses the input.
204
+ */
205
+ focus() {
206
+ this.inputView.focus();
207
+ }
239
208
  }
@@ -2,64 +2,54 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module ui/list/listitemview
8
7
  */
9
-
10
8
  import View from '../view';
11
-
12
9
  /**
13
10
  * The list item view class.
14
11
  *
15
12
  * @extends module:ui/view~View
16
13
  */
17
14
  export default class ListItemView extends View {
18
- /**
19
- * @inheritDoc
20
- */
21
- constructor( locale ) {
22
- super( locale );
23
-
24
- const bind = this.bindTemplate;
25
-
26
- /**
27
- * Controls whether the item view is visible. Visible by default, list items are hidden
28
- * using a CSS class.
29
- *
30
- * @observable
31
- * @default true
32
- * @member {Boolean} #isVisible
33
- */
34
- this.set( 'isVisible', true );
35
-
36
- /**
37
- * Collection of the child views inside of the list item {@link #element}.
38
- *
39
- * @readonly
40
- * @member {module:ui/viewcollection~ViewCollection}
41
- */
42
- this.children = this.createCollection();
43
-
44
- this.setTemplate( {
45
- tag: 'li',
46
-
47
- attributes: {
48
- class: [
49
- 'ck',
50
- 'ck-list__item',
51
- bind.if( 'isVisible', 'ck-hidden', value => !value )
52
- ]
53
- },
54
-
55
- children: this.children
56
- } );
57
- }
58
-
59
- /**
60
- * Focuses the list item.
61
- */
62
- focus() {
63
- this.children.first.focus();
64
- }
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ constructor(locale) {
19
+ super(locale);
20
+ const bind = this.bindTemplate;
21
+ /**
22
+ * Controls whether the item view is visible. Visible by default, list items are hidden
23
+ * using a CSS class.
24
+ *
25
+ * @observable
26
+ * @default true
27
+ * @member {Boolean} #isVisible
28
+ */
29
+ this.set('isVisible', true);
30
+ /**
31
+ * Collection of the child views inside of the list item {@link #element}.
32
+ *
33
+ * @readonly
34
+ * @member {module:ui/viewcollection~ViewCollection}
35
+ */
36
+ this.children = this.createCollection();
37
+ this.setTemplate({
38
+ tag: 'li',
39
+ attributes: {
40
+ class: [
41
+ 'ck',
42
+ 'ck-list__item',
43
+ bind.if('isVisible', 'ck-hidden', value => !value)
44
+ ]
45
+ },
46
+ children: this.children
47
+ });
48
+ }
49
+ /**
50
+ * Focuses the list item.
51
+ */
52
+ focus() {
53
+ this.children.first.focus();
54
+ }
65
55
  }
@@ -2,33 +2,29 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module ui/list/listseparatorview
8
7
  */
9
-
10
8
  import View from '../view';
11
-
12
9
  /**
13
10
  * The list separator view class.
14
11
  *
15
12
  * @extends module:ui/view~View
16
13
  */
17
14
  export default class ListSeparatorView extends View {
18
- /**
19
- * @inheritDoc
20
- */
21
- constructor( locale ) {
22
- super( locale );
23
-
24
- this.setTemplate( {
25
- tag: 'li',
26
- attributes: {
27
- class: [
28
- 'ck',
29
- 'ck-list__separator'
30
- ]
31
- }
32
- } );
33
- }
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ constructor(locale) {
19
+ super(locale);
20
+ this.setTemplate({
21
+ tag: 'li',
22
+ attributes: {
23
+ class: [
24
+ 'ck',
25
+ 'ck-list__separator'
26
+ ]
27
+ }
28
+ });
29
+ }
34
30
  }