@ckeditor/ckeditor5-ui 31.0.0 → 33.0.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 (145) hide show
  1. package/LICENSE.md +2 -2
  2. package/lang/translations/ar.po +2 -2
  3. package/lang/translations/ast.po +1 -1
  4. package/lang/translations/az.po +1 -1
  5. package/lang/translations/cs.po +1 -1
  6. package/lang/translations/da.po +1 -1
  7. package/lang/translations/de-ch.po +1 -1
  8. package/lang/translations/de.po +1 -1
  9. package/lang/translations/el.po +23 -23
  10. package/lang/translations/en-au.po +1 -1
  11. package/lang/translations/en-gb.po +1 -1
  12. package/lang/translations/en.po +1 -1
  13. package/lang/translations/eo.po +1 -1
  14. package/lang/translations/es.po +1 -1
  15. package/lang/translations/et.po +1 -1
  16. package/lang/translations/eu.po +1 -1
  17. package/lang/translations/fa.po +1 -1
  18. package/lang/translations/fi.po +4 -4
  19. package/lang/translations/fr.po +1 -1
  20. package/lang/translations/gl.po +1 -1
  21. package/lang/translations/he.po +1 -1
  22. package/lang/translations/hi.po +1 -1
  23. package/lang/translations/hr.po +1 -1
  24. package/lang/translations/hu.po +1 -1
  25. package/lang/translations/id.po +1 -1
  26. package/lang/translations/it.po +1 -1
  27. package/lang/translations/ja.po +1 -1
  28. package/lang/translations/km.po +1 -1
  29. package/lang/translations/kn.po +1 -1
  30. package/lang/translations/ko.po +1 -1
  31. package/lang/translations/ku.po +1 -1
  32. package/lang/translations/lt.po +1 -1
  33. package/lang/translations/lv.po +1 -1
  34. package/lang/translations/nb.po +1 -1
  35. package/lang/translations/ne.po +1 -1
  36. package/lang/translations/nl.po +2 -2
  37. package/lang/translations/no.po +1 -1
  38. package/lang/translations/pl.po +1 -1
  39. package/lang/translations/pt-br.po +1 -1
  40. package/lang/translations/pt.po +1 -1
  41. package/lang/translations/ro.po +1 -1
  42. package/lang/translations/ru.po +1 -1
  43. package/lang/translations/sk.po +1 -1
  44. package/lang/translations/sl.po +1 -1
  45. package/lang/translations/sq.po +1 -1
  46. package/lang/translations/sr-latn.po +1 -1
  47. package/lang/translations/sr.po +1 -1
  48. package/lang/translations/sv.po +1 -1
  49. package/lang/translations/th.po +1 -1
  50. package/lang/translations/tk.po +1 -1
  51. package/lang/translations/tr.po +1 -1
  52. package/lang/translations/ug.po +2 -2
  53. package/lang/translations/uk.po +1 -1
  54. package/lang/translations/uz.po +105 -0
  55. package/lang/translations/vi.po +1 -1
  56. package/lang/translations/zh-cn.po +1 -1
  57. package/lang/translations/zh.po +1 -1
  58. package/package.json +20 -20
  59. package/src/bindings/clickoutsidehandler.js +1 -1
  60. package/src/bindings/injectcsstransitiondisabler.js +1 -1
  61. package/src/bindings/preventdefault.js +1 -1
  62. package/src/bindings/submithandler.js +1 -1
  63. package/src/button/button.jsdoc +1 -1
  64. package/src/button/buttonview.js +1 -1
  65. package/src/button/switchbuttonview.js +1 -1
  66. package/src/colorgrid/colorgridview.js +11 -1
  67. package/src/colorgrid/colortileview.js +1 -1
  68. package/src/colorgrid/utils.js +1 -1
  69. package/src/componentfactory.js +1 -1
  70. package/src/dropdown/button/dropdownbutton.jsdoc +1 -1
  71. package/src/dropdown/button/dropdownbuttonview.js +1 -1
  72. package/src/dropdown/button/splitbuttonview.js +11 -1
  73. package/src/dropdown/dropdownpanelfocusable.jsdoc +1 -1
  74. package/src/dropdown/dropdownpanelview.js +1 -1
  75. package/src/dropdown/dropdownview.js +1 -1
  76. package/src/dropdown/utils.js +1 -1
  77. package/src/editableui/editableuiview.js +1 -1
  78. package/src/editableui/inline/inlineeditableuiview.js +1 -1
  79. package/src/editorui/bodycollection.js +1 -1
  80. package/src/editorui/boxed/boxededitoruiview.js +1 -1
  81. package/src/editorui/editoruiview.js +1 -1
  82. package/src/focuscycler.js +19 -4
  83. package/src/formheader/formheaderview.js +1 -1
  84. package/src/icon/iconview.js +1 -1
  85. package/src/iframe/iframeview.js +1 -1
  86. package/src/index.js +3 -1
  87. package/src/input/inputview.js +216 -0
  88. package/src/inputnumber/inputnumberview.js +71 -0
  89. package/src/inputtext/inputtextview.js +7 -172
  90. package/src/label/labelview.js +1 -1
  91. package/src/labeledfield/labeledfieldview.js +1 -1
  92. package/src/labeledfield/utils.js +54 -5
  93. package/src/labeledinput/labeledinputview.js +1 -1
  94. package/src/list/listitemview.js +1 -1
  95. package/src/list/listseparatorview.js +1 -1
  96. package/src/list/listview.js +11 -1
  97. package/src/model.js +1 -1
  98. package/src/notification/notification.js +1 -1
  99. package/src/panel/balloon/balloonpanelview.js +289 -225
  100. package/src/panel/balloon/contextualballoon.js +21 -1
  101. package/src/panel/sticky/stickypanelview.js +1 -1
  102. package/src/template.js +1 -1
  103. package/src/toolbar/balloon/balloontoolbar.js +48 -35
  104. package/src/toolbar/block/blockbuttonview.js +1 -1
  105. package/src/toolbar/block/blocktoolbar.js +1 -1
  106. package/src/toolbar/enabletoolbarkeyboardfocus.js +1 -1
  107. package/src/toolbar/normalizetoolbarconfig.js +1 -1
  108. package/src/toolbar/toolbarlinebreakview.js +1 -1
  109. package/src/toolbar/toolbarseparatorview.js +1 -1
  110. package/src/toolbar/toolbarview.js +5 -2
  111. package/src/tooltip/tooltipview.js +1 -1
  112. package/src/view.js +1 -1
  113. package/src/viewcollection.js +1 -1
  114. package/theme/components/button/button.css +1 -1
  115. package/theme/components/button/switchbutton.css +1 -1
  116. package/theme/components/colorgrid/colorgrid.css +1 -1
  117. package/theme/components/dropdown/dropdown.css +1 -1
  118. package/theme/components/dropdown/listdropdown.css +1 -1
  119. package/theme/components/dropdown/splitbutton.css +1 -1
  120. package/theme/components/dropdown/toolbardropdown.css +1 -1
  121. package/theme/components/editorui/editorui.css +1 -1
  122. package/theme/components/formheader/formheader.css +1 -1
  123. package/theme/components/icon/icon.css +1 -1
  124. package/theme/components/{inputtext/inputtext.css → input/input.css} +1 -1
  125. package/theme/components/label/label.css +1 -1
  126. package/theme/components/labeledfield/labeledfieldview.css +1 -1
  127. package/theme/components/labeledinput/labeledinput.css +1 -1
  128. package/theme/components/list/list.css +1 -1
  129. package/theme/components/panel/balloonpanel.css +1 -1
  130. package/theme/components/panel/balloonrotator.css +1 -1
  131. package/theme/components/panel/fakepanel.css +1 -1
  132. package/theme/components/panel/stickypanel.css +1 -1
  133. package/theme/components/responsive-form/responsiveform.css +1 -1
  134. package/theme/components/toolbar/blocktoolbar.css +1 -1
  135. package/theme/components/toolbar/toolbar.css +1 -1
  136. package/theme/components/tooltip/mixins/_tooltip.css +1 -1
  137. package/theme/components/tooltip/tooltip.css +1 -1
  138. package/theme/globals/_hidden.css +1 -1
  139. package/theme/globals/_reset.css +1 -1
  140. package/theme/globals/_transition.css +1 -1
  141. package/theme/globals/_zindex.css +1 -1
  142. package/theme/globals/globals.css +1 -1
  143. package/theme/mixins/_dir.css +1 -1
  144. package/theme/mixins/_rwd.css +1 -1
  145. package/theme/mixins/_unselectable.css +1 -1
@@ -0,0 +1,216 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+
6
+ /**
7
+ * @module ui/input/inputview
8
+ */
9
+
10
+ import View from '../view';
11
+ import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
12
+
13
+ import '../../theme/components/input/input.css';
14
+
15
+ /**
16
+ * The base input view class.
17
+ *
18
+ * @extends module:ui/view~View
19
+ */
20
+ export default class InputView extends View {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ constructor( locale ) {
25
+ super( locale );
26
+
27
+ /**
28
+ * The value of the input.
29
+ *
30
+ * @observable
31
+ * @member {String} #value
32
+ */
33
+ this.set( 'value' );
34
+
35
+ /**
36
+ * The `id` attribute of the input (i.e. to pair with a `<label>` element).
37
+ *
38
+ * @observable
39
+ * @member {String} #id
40
+ */
41
+ this.set( 'id' );
42
+
43
+ /**
44
+ * The `placeholder` attribute of the input.
45
+ *
46
+ * @observable
47
+ * @member {String} #placeholder
48
+ */
49
+ this.set( 'placeholder' );
50
+
51
+ /**
52
+ * Controls whether the input view is in read-only mode.
53
+ *
54
+ * @observable
55
+ * @member {Boolean} #isReadOnly
56
+ */
57
+ this.set( 'isReadOnly', false );
58
+
59
+ /**
60
+ * Set to `true` when the field has some error. Usually controlled via
61
+ * {@link module:ui/labeledinput/labeledinputview~LabeledInputView#errorText}.
62
+ *
63
+ * @observable
64
+ * @member {Boolean} #hasError
65
+ */
66
+ this.set( 'hasError', false );
67
+
68
+ /**
69
+ * The `id` of the element describing this field, e.g. when it has
70
+ * some error; it helps screen readers read the error text.
71
+ *
72
+ * @observable
73
+ * @member {Boolean} #ariaDescribedById
74
+ */
75
+ this.set( 'ariaDescribedById' );
76
+
77
+ /**
78
+ * Stores information about the editor UI focus and propagates it so various plugins and components
79
+ * are unified as a focus group.
80
+ *
81
+ * @readonly
82
+ * @member {module:utils/focustracker~FocusTracker} #focusTracker
83
+ */
84
+ this.focusTracker = new FocusTracker();
85
+
86
+ /**
87
+ * An observable flag set to `true` when the input is currently focused by the user.
88
+ * Set to `false` otherwise.
89
+ *
90
+ * @readonly
91
+ * @observable
92
+ * @member {Boolean} #isFocused
93
+ * @default false
94
+ */
95
+ this.bind( 'isFocused' ).to( this.focusTracker );
96
+
97
+ /**
98
+ * An observable flag set to `true` when the input contains no text, i.e.
99
+ * when {@link #value} is `''`, `null`, or `false`.
100
+ *
101
+ * @readonly
102
+ * @observable
103
+ * @member {Boolean} #isEmpty
104
+ * @default true
105
+ */
106
+ this.set( 'isEmpty', true );
107
+
108
+ /**
109
+ * Corresponds to the `inputmode` DOM attribute. Can be `text`, `numeric`, `decimal`, etc.
110
+ *
111
+ * @observable
112
+ * @member {Boolean} #inputMode
113
+ * @default 'text'
114
+ */
115
+ this.set( 'inputMode', 'text' );
116
+
117
+ const bind = this.bindTemplate;
118
+
119
+ this.setTemplate( {
120
+ tag: 'input',
121
+ attributes: {
122
+ class: [
123
+ 'ck',
124
+ 'ck-input',
125
+ bind.if( 'isFocused', 'ck-input_focused' ),
126
+ bind.if( 'isEmpty', 'ck-input-text_empty' ),
127
+ bind.if( 'hasError', 'ck-error' )
128
+ ],
129
+ id: bind.to( 'id' ),
130
+ placeholder: bind.to( 'placeholder' ),
131
+ readonly: bind.to( 'isReadOnly' ),
132
+ inputmode: bind.to( 'inputMode' ),
133
+ 'aria-invalid': bind.if( 'hasError', true ),
134
+ 'aria-describedby': bind.to( 'ariaDescribedById' )
135
+ },
136
+ on: {
137
+ input: bind.to( ( ...args ) => {
138
+ this.fire( 'input', ...args );
139
+ this._updateIsEmpty();
140
+ } ),
141
+ change: bind.to( this._updateIsEmpty.bind( this ) )
142
+ }
143
+ } );
144
+
145
+ /**
146
+ * Fired when the user types in the input. Corresponds to the native
147
+ * DOM `input` event.
148
+ *
149
+ * @event input
150
+ */
151
+ }
152
+
153
+ /**
154
+ * @inheritDoc
155
+ */
156
+ render() {
157
+ super.render();
158
+
159
+ this.focusTracker.add( this.element );
160
+
161
+ this._setDomElementValue( this.value );
162
+ this._updateIsEmpty();
163
+
164
+ // Bind `this.value` to the DOM element's value.
165
+ // We cannot use `value` DOM attribute because removing it on Edge does not clear the DOM element's value property.
166
+ this.on( 'change:value', ( evt, name, value ) => {
167
+ this._setDomElementValue( value );
168
+ this._updateIsEmpty();
169
+ } );
170
+ }
171
+
172
+ /**
173
+ * @inheritDoc
174
+ */
175
+ destroy() {
176
+ super.destroy();
177
+
178
+ this.focusTracker.destroy();
179
+ }
180
+
181
+ /**
182
+ * Moves the focus to the input and selects the value.
183
+ */
184
+ select() {
185
+ this.element.select();
186
+ }
187
+
188
+ /**
189
+ * Focuses the input.
190
+ */
191
+ focus() {
192
+ this.element.focus();
193
+ }
194
+
195
+ /**
196
+ * Updates the {@link #isEmpty} property value on demand.
197
+ *
198
+ * @private
199
+ */
200
+ _updateIsEmpty() {
201
+ this.isEmpty = isInputElementEmpty( this.element );
202
+ }
203
+
204
+ /**
205
+ * Sets the `value` property of the {@link #element DOM element} on demand.
206
+ *
207
+ * @private
208
+ */
209
+ _setDomElementValue( value ) {
210
+ this.element.value = ( !value && value !== 0 ) ? '' : value;
211
+ }
212
+ }
213
+
214
+ function isInputElementEmpty( domElement ) {
215
+ return !domElement.value;
216
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+
6
+ /**
7
+ * @module ui/inputnumber/inputnumberview
8
+ */
9
+
10
+ import InputView from '../input/inputview';
11
+
12
+ /**
13
+ * The number input view class.
14
+ *
15
+ * @extends module:ui/input/inputview~InputView
16
+ */
17
+ export default class InputNumberView extends InputView {
18
+ /**
19
+ * Creates an instance of the input number view.
20
+ *
21
+ * @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor#locale} instance.
22
+ * @param {Object} [options] The options of the input.
23
+ * @param {Number} [options.min] The value of the `min` DOM attribute (the lowest accepted value).
24
+ * @param {Number} [options.max] The value of the `max` DOM attribute (the highest accepted value).
25
+ * @param {Number} [options.step] The value of the `step` DOM attribute.
26
+ */
27
+ constructor( locale, { min, max, step } = {} ) {
28
+ super( locale );
29
+
30
+ const bind = this.bindTemplate;
31
+
32
+ /**
33
+ * The value of the `min` DOM attribute (the lowest accepted value) set on the {@link #element}.
34
+ *
35
+ * @observable
36
+ * @default undefined
37
+ * @member {Number} #min
38
+ */
39
+ this.set( 'min', min );
40
+
41
+ /**
42
+ * The value of the `max` DOM attribute (the highest accepted value) set on the {@link #element}.
43
+ *
44
+ * @observable
45
+ * @default undefined
46
+ * @member {Number} #max
47
+ */
48
+ this.set( 'max', max );
49
+
50
+ /**
51
+ * The value of the `step` DOM attribute set on the {@link #element}.
52
+ *
53
+ * @observable
54
+ * @default undefined
55
+ * @member {Number} #step
56
+ */
57
+ this.set( 'step', step );
58
+
59
+ this.extendTemplate( {
60
+ attributes: {
61
+ type: 'number',
62
+ class: [
63
+ 'ck-input-number'
64
+ ],
65
+ min: bind.to( 'min' ),
66
+ max: bind.to( 'max' ),
67
+ step: bind.to( 'step' )
68
+ }
69
+ } );
70
+ }
71
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -7,192 +7,27 @@
7
7
  * @module ui/inputtext/inputtextview
8
8
  */
9
9
 
10
- import View from '../view';
11
- import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
12
- import '../../theme/components/inputtext/inputtext.css';
10
+ import InputView from '../input/inputview';
13
11
 
14
12
  /**
15
13
  * The text input view class.
16
14
  *
17
- * @extends module:ui/view~View
15
+ * @extends module:ui/input/inputview~InputView
18
16
  */
19
- export default class InputTextView extends View {
17
+ export default class InputTextView extends InputView {
20
18
  /**
21
19
  * @inheritDoc
22
20
  */
23
21
  constructor( locale ) {
24
22
  super( locale );
25
23
 
26
- /**
27
- * The value of the input.
28
- *
29
- * @observable
30
- * @member {String} #value
31
- */
32
- this.set( 'value' );
33
-
34
- /**
35
- * The `id` attribute of the input (i.e. to pair with a `<label>` element).
36
- *
37
- * @observable
38
- * @member {String} #id
39
- */
40
- this.set( 'id' );
41
-
42
- /**
43
- * The `placeholder` attribute of the input.
44
- *
45
- * @observable
46
- * @member {String} #placeholder
47
- */
48
- this.set( 'placeholder' );
49
-
50
- /**
51
- * Controls whether the input view is in read-only mode.
52
- *
53
- * @observable
54
- * @member {Boolean} #isReadOnly
55
- */
56
- this.set( 'isReadOnly', false );
57
-
58
- /**
59
- * Set to `true` when the field has some error. Usually controlled via
60
- * {@link module:ui/labeledinput/labeledinputview~LabeledInputView#errorText}.
61
- *
62
- * @observable
63
- * @member {Boolean} #hasError
64
- */
65
- this.set( 'hasError', false );
66
-
67
- /**
68
- * The `id` of the element describing this field, e.g. when it has
69
- * some error, it helps screen readers read the error text.
70
- *
71
- * @observable
72
- * @member {Boolean} #ariaDescribedById
73
- */
74
- this.set( 'ariaDescribedById' );
75
-
76
- /**
77
- * Stores information about the editor UI focus and propagates it so various plugins and components
78
- * are unified as a focus group.
79
- *
80
- * @readonly
81
- * @member {module:utils/focustracker~FocusTracker} #focusTracker
82
- */
83
- this.focusTracker = new FocusTracker();
84
-
85
- /**
86
- * An observable flag set to `true` when the input is currently focused by the user.
87
- * Set to `false` otherwise.
88
- *
89
- * @readonly
90
- * @observable
91
- * @member {Boolean} #isFocused
92
- * @default false
93
- */
94
- this.bind( 'isFocused' ).to( this.focusTracker );
95
-
96
- /**
97
- * An observable flag set to `true` when the input contains no text, i.e.
98
- * when {@link #value} is `''`, `null`, or `false`.
99
- *
100
- * @readonly
101
- * @observable
102
- * @member {Boolean} #isEmpty
103
- * @default true
104
- */
105
- this.set( 'isEmpty', true );
106
-
107
- const bind = this.bindTemplate;
108
-
109
- this.setTemplate( {
110
- tag: 'input',
24
+ this.extendTemplate( {
111
25
  attributes: {
112
26
  type: 'text',
113
27
  class: [
114
- 'ck',
115
- 'ck-input',
116
- 'ck-input-text',
117
- bind.if( 'isFocused', 'ck-input_focused' ),
118
- bind.if( 'isEmpty', 'ck-input-text_empty' ),
119
- bind.if( 'hasError', 'ck-error' )
120
- ],
121
- id: bind.to( 'id' ),
122
- placeholder: bind.to( 'placeholder' ),
123
- readonly: bind.to( 'isReadOnly' ),
124
- 'aria-invalid': bind.if( 'hasError', true ),
125
- 'aria-describedby': bind.to( 'ariaDescribedById' )
126
- },
127
- on: {
128
- input: bind.to( ( ...args ) => {
129
- this.fire( 'input', ...args );
130
- this._updateIsEmpty();
131
- } ),
132
- change: bind.to( this._updateIsEmpty.bind( this ) )
28
+ 'ck-input-text'
29
+ ]
133
30
  }
134
31
  } );
135
-
136
- /**
137
- * Fired when the user types in the input. Corresponds to the native
138
- * DOM `input` event.
139
- *
140
- * @event input
141
- */
142
- }
143
-
144
- /**
145
- * @inheritDoc
146
- */
147
- render() {
148
- super.render();
149
-
150
- this.focusTracker.add( this.element );
151
-
152
- this._setDomElementValue( this.value );
153
- this._updateIsEmpty();
154
-
155
- // Bind `this.value` to the DOM element's value.
156
- // We cannot use `value` DOM attribute because removing it on Edge does not clear the DOM element's value property.
157
- this.on( 'change:value', ( evt, name, value ) => {
158
- this._setDomElementValue( value );
159
- this._updateIsEmpty();
160
- } );
161
- }
162
-
163
- /**
164
- * Moves the focus to the input and selects the value.
165
- */
166
- select() {
167
- this.element.select();
168
32
  }
169
-
170
- /**
171
- * Focuses the input.
172
- */
173
- focus() {
174
- this.element.focus();
175
- }
176
-
177
- /**
178
- * Updates the {@link #isEmpty} property value on demand.
179
- *
180
- * @private
181
- */
182
- _updateIsEmpty() {
183
- this.isEmpty = isInputElementEmpty( this.element );
184
- }
185
-
186
- /**
187
- * Sets the `value` property of the {@link #element DOM element} on demand.
188
- *
189
- * @private
190
- */
191
- _setDomElementValue( value ) {
192
- this.element.value = ( !value && value !== 0 ) ? '' : value;
193
- }
194
- }
195
-
196
- function isInputElementEmpty( domElement ) {
197
- return !domElement.value;
198
33
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import InputTextView from '../inputtext/inputtextview';
11
+ import InputNumberView from '../inputnumber/inputnumberview';
11
12
  import { createDropdown } from '../dropdown/utils';
12
13
 
13
14
  /**
@@ -21,12 +22,12 @@ import { createDropdown } from '../dropdown/utils';
21
22
  * * It sets input's `id` and `ariaDescribedById` attributes.
22
23
  * * It binds input's `isReadOnly` to the labeled view.
23
24
  * * It binds input's `hasError` to the labeled view.
24
- * * It enables a logic that cleans up the error when user starts typing in the input..
25
+ * * It enables a logic that cleans up the error when user starts typing in the input.
25
26
  *
26
27
  * Usage:
27
28
  *
28
- * const labeledInputView = new LabeledFieldView( locale, createLabeledDropdown );
29
- * console.log( labeledInputView.view ); // An input instance.
29
+ * const labeledInputView = new LabeledFieldView( locale, createLabeledInputText );
30
+ * console.log( labeledInputView.fieldView ); // A text input instance.
30
31
  *
31
32
  * @param {module:ui/labeledfield/labeledfieldview~LabeledFieldView} labeledFieldView The instance of the labeled field view.
32
33
  * @param {String} viewUid An UID string that allows DOM logical connection between the
@@ -57,6 +58,54 @@ export function createLabeledInputText( labeledFieldView, viewUid, statusUid ) {
57
58
  return inputView;
58
59
  }
59
60
 
61
+ /**
62
+ * A helper for creating labeled number inputs.
63
+ *
64
+ * It creates an instance of a {@link module:ui/inputnumber/inputnumberview~InputNumberView input number} that is
65
+ * logically related to a {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView labeled view} in DOM.
66
+ *
67
+ * The helper does the following:
68
+ *
69
+ * * It sets input's `id` and `ariaDescribedById` attributes.
70
+ * * It binds input's `isReadOnly` to the labeled view.
71
+ * * It binds input's `hasError` to the labeled view.
72
+ * * It enables a logic that cleans up the error when user starts typing in the input.
73
+ *
74
+ * Usage:
75
+ *
76
+ * const labeledInputView = new LabeledFieldView( locale, createLabeledInputNumber );
77
+ * console.log( labeledInputView.fieldView ); // A number input instance.
78
+ *
79
+ * @param {module:ui/labeledfield/labeledfieldview~LabeledFieldView} labeledFieldView The instance of the labeled field view.
80
+ * @param {String} viewUid An UID string that allows DOM logical connection between the
81
+ * {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#labelView labeled view's label} and the input.
82
+ * @param {String} statusUid An UID string that allows DOM logical connection between the
83
+ * {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#statusView labeled view's status} and the input.
84
+ * @returns {module:ui/inputnumber/inputnumberview~InputNumberView} The input number view instance.
85
+ */
86
+ export function createLabeledInputNumber( labeledFieldView, viewUid, statusUid ) {
87
+ const inputView = new InputNumberView( labeledFieldView.locale );
88
+
89
+ inputView.set( {
90
+ id: viewUid,
91
+ ariaDescribedById: statusUid,
92
+ inputMode: 'numeric'
93
+ } );
94
+
95
+ inputView.bind( 'isReadOnly' ).to( labeledFieldView, 'isEnabled', value => !value );
96
+ inputView.bind( 'hasError' ).to( labeledFieldView, 'errorText', value => !!value );
97
+
98
+ inputView.on( 'input', () => {
99
+ // UX: Make the error text disappear and disable the error indicator as the user
100
+ // starts fixing the errors.
101
+ labeledFieldView.errorText = null;
102
+ } );
103
+
104
+ labeledFieldView.bind( 'isEmpty', 'isFocused', 'placeholder' ).to( inputView );
105
+
106
+ return inputView;
107
+ }
108
+
60
109
  /**
61
110
  * A helper for creating labeled dropdowns.
62
111
  *
@@ -71,7 +120,7 @@ export function createLabeledInputText( labeledFieldView, viewUid, statusUid ) {
71
120
  * Usage:
72
121
  *
73
122
  * const labeledInputView = new LabeledFieldView( locale, createLabeledDropdown );
74
- * console.log( labeledInputView.view ); // A dropdown instance.
123
+ * console.log( labeledInputView.fieldView ); // A dropdown instance.
75
124
  *
76
125
  * @param {module:ui/labeledfield/labeledfieldview~LabeledFieldView} labeledFieldView The instance of the labeled field view.
77
126
  * @param {String} viewUid An UID string that allows DOM logical connection between the
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -109,6 +109,16 @@ export default class ListView extends View {
109
109
  this.keystrokes.listenTo( this.element );
110
110
  }
111
111
 
112
+ /**
113
+ * @inheritDoc
114
+ */
115
+ destroy() {
116
+ super.destroy();
117
+
118
+ this.focusTracker.destroy();
119
+ this.keystrokes.destroy();
120
+ }
121
+
112
122
  /**
113
123
  * Focuses the first focusable in {@link #items}.
114
124
  */
package/src/model.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
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
5