@ckeditor/ckeditor5-ui 29.2.0 → 32.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 (146) 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 +2 -2
  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 +1 -1
  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 -21
  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 +2 -2
  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 -169
  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 +2 -2
  99. package/src/panel/balloon/balloonpanelview.js +343 -217
  100. package/src/panel/balloon/contextualballoon.js +32 -5
  101. package/src/panel/sticky/stickypanelview.js +6 -2
  102. package/src/template.js +1 -1
  103. package/src/toolbar/balloon/balloontoolbar.js +49 -36
  104. package/src/toolbar/block/blockbuttonview.js +1 -1
  105. package/src/toolbar/block/blocktoolbar.js +4 -3
  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 +7 -4
  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
  146. package/CHANGELOG.md +0 -542
@@ -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
 
@@ -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
 
@@ -184,7 +184,7 @@ export default class ButtonView extends View {
184
184
  this.children.add( this.tooltipView );
185
185
  this.children.add( this.labelView );
186
186
 
187
- if ( this.withKeystroke ) {
187
+ if ( this.withKeystroke && this.keystroke ) {
188
188
  this.children.add( this.keystrokeView );
189
189
  }
190
190
  }
@@ -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
 
@@ -176,6 +176,16 @@ export default class ColorGridView extends View {
176
176
  this.keystrokes.listenTo( this.element );
177
177
  }
178
178
 
179
+ /**
180
+ * @inheritDoc
181
+ */
182
+ destroy() {
183
+ super.destroy();
184
+
185
+ this.focusTracker.destroy();
186
+ this.keystrokes.destroy();
187
+ }
188
+
179
189
  /**
180
190
  * Fired when the `ColorTileView` for the picked item is executed.
181
191
  *
@@ -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
 
@@ -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
 
@@ -155,6 +155,16 @@ export default class SplitButtonView extends View {
155
155
  } );
156
156
  }
157
157
 
158
+ /**
159
+ * @inheritDoc
160
+ */
161
+ destroy() {
162
+ super.destroy();
163
+
164
+ this.focusTracker.destroy();
165
+ this.keystrokes.destroy();
166
+ }
167
+
158
168
  /**
159
169
  * Focuses the {@link #actionView#element} of the action part of split button.
160
170
  */
@@ -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
 
@@ -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
 
@@ -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
 
@@ -7,7 +7,7 @@
7
7
  * @module ui/focuscycler
8
8
  */
9
9
 
10
- import global from '@ckeditor/ckeditor5-utils/src/dom/global';
10
+ import isVisible from '@ckeditor/ckeditor5-utils/src/dom/isvisible';
11
11
 
12
12
  /**
13
13
  * A utility class that helps cycling over focusable {@link module:ui/view~View views} in a
@@ -131,6 +131,8 @@ export default class FocusCycler {
131
131
  * Returns the first focusable view in {@link #focusables}.
132
132
  * Returns `null` if there is none.
133
133
  *
134
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
135
+ *
134
136
  * @readonly
135
137
  * @member {module:ui/view~View|null} #first
136
138
  */
@@ -142,6 +144,8 @@ export default class FocusCycler {
142
144
  * Returns the last focusable view in {@link #focusables}.
143
145
  * Returns `null` if there is none.
144
146
  *
147
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
148
+ *
145
149
  * @readonly
146
150
  * @member {module:ui/view~View|null} #last
147
151
  */
@@ -153,6 +157,8 @@ export default class FocusCycler {
153
157
  * Returns the next focusable view in {@link #focusables} based on {@link #current}.
154
158
  * Returns `null` if there is none.
155
159
  *
160
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
161
+ *
156
162
  * @readonly
157
163
  * @member {module:ui/view~View|null} #next
158
164
  */
@@ -164,6 +170,8 @@ export default class FocusCycler {
164
170
  * Returns the previous focusable view in {@link #focusables} based on {@link #current}.
165
171
  * Returns `null` if there is none.
166
172
  *
173
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
174
+ *
167
175
  * @readonly
168
176
  * @member {module:ui/view~View|null} #previous
169
177
  */
@@ -201,6 +209,8 @@ export default class FocusCycler {
201
209
 
202
210
  /**
203
211
  * Focuses the {@link #first} item in {@link #focusables}.
212
+ *
213
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
204
214
  */
205
215
  focusFirst() {
206
216
  this._focus( this.first );
@@ -208,6 +218,8 @@ export default class FocusCycler {
208
218
 
209
219
  /**
210
220
  * Focuses the {@link #last} item in {@link #focusables}.
221
+ *
222
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
211
223
  */
212
224
  focusLast() {
213
225
  this._focus( this.last );
@@ -215,6 +227,8 @@ export default class FocusCycler {
215
227
 
216
228
  /**
217
229
  * Focuses the {@link #next} item in {@link #focusables}.
230
+ *
231
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
218
232
  */
219
233
  focusNext() {
220
234
  this._focus( this.next );
@@ -222,6 +236,8 @@ export default class FocusCycler {
222
236
 
223
237
  /**
224
238
  * Focuses the {@link #previous} item in {@link #focusables}.
239
+ *
240
+ * **Note**: Hidden views (e.g. with `display: none`) are ignored.
225
241
  */
226
242
  focusPrevious() {
227
243
  this._focus( this.previous );
@@ -269,7 +285,6 @@ export default class FocusCycler {
269
285
  do {
270
286
  const view = this.focusables.get( index );
271
287
 
272
- // TODO: Check if view is visible.
273
288
  if ( isFocusable( view ) ) {
274
289
  return view;
275
290
  }
@@ -288,5 +303,5 @@ export default class FocusCycler {
288
303
  // @param {module:ui/view~View} view A view to be checked.
289
304
  // @returns {Boolean}
290
305
  function isFocusable( view ) {
291
- return !!( view.focus && global.window.getComputedStyle( view.element ).display != 'none' );
306
+ return !!( view.focus && isVisible( view.element ) );
292
307
  }
@@ -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
 
package/src/index.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
 
@@ -32,7 +32,9 @@ export { default as FormHeaderView } from './formheader/formheaderview';
32
32
  export { default as FocusCycler } from './focuscycler';
33
33
 
34
34
  export { default as IconView } from './icon/iconview';
35
+ export { default as InputView } from './input/inputview';
35
36
  export { default as InputTextView } from './inputtext/inputtextview';
37
+ export { default as InputNumberView } from './inputnumber/inputnumberview';
36
38
 
37
39
  export { default as IframeView } from './iframe/iframeview';
38
40
 
@@ -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] 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
+ }