@ckeditor/ckeditor5-ui 35.2.1 → 35.3.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.
- package/package.json +31 -23
- package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
- package/src/bindings/clickoutsidehandler.js +15 -21
- package/src/bindings/injectcsstransitiondisabler.js +16 -20
- package/src/bindings/preventdefault.js +6 -8
- package/src/bindings/submithandler.js +5 -7
- package/src/button/button.js +5 -0
- package/src/button/buttonview.js +220 -259
- package/src/button/switchbuttonview.js +56 -71
- package/src/colorgrid/colorgridview.js +135 -197
- package/src/colorgrid/colortileview.js +37 -47
- package/src/colorgrid/utils.js +57 -66
- package/src/componentfactory.js +79 -93
- package/src/dropdown/button/dropdownbutton.js +5 -0
- package/src/dropdown/button/dropdownbuttonview.js +44 -57
- package/src/dropdown/button/splitbuttonview.js +159 -207
- package/src/dropdown/dropdownpanelfocusable.js +5 -0
- package/src/dropdown/dropdownpanelview.js +101 -112
- package/src/dropdown/dropdownview.js +396 -438
- package/src/dropdown/utils.js +164 -213
- package/src/editableui/editableuiview.js +125 -141
- package/src/editableui/inline/inlineeditableuiview.js +44 -54
- package/src/editorui/bodycollection.js +61 -75
- package/src/editorui/boxed/boxededitoruiview.js +91 -104
- package/src/editorui/editoruiview.js +30 -39
- package/src/focuscycler.js +214 -245
- package/src/formheader/formheaderview.js +58 -70
- package/src/icon/iconview.js +145 -111
- package/src/iframe/iframeview.js +37 -49
- package/src/index.js +0 -17
- package/src/input/inputview.js +170 -198
- package/src/inputnumber/inputnumberview.js +48 -56
- package/src/inputtext/inputtextview.js +14 -18
- package/src/label/labelview.js +44 -53
- package/src/labeledfield/labeledfieldview.js +212 -235
- package/src/labeledfield/utils.js +39 -57
- package/src/labeledinput/labeledinputview.js +190 -221
- package/src/list/listitemview.js +40 -50
- package/src/list/listseparatorview.js +15 -19
- package/src/list/listview.js +94 -115
- package/src/model.js +19 -25
- package/src/notification/notification.js +151 -202
- package/src/panel/balloon/balloonpanelview.js +535 -628
- package/src/panel/balloon/contextualballoon.js +611 -732
- package/src/panel/sticky/stickypanelview.js +238 -270
- package/src/template.js +1049 -1479
- package/src/toolbar/balloon/balloontoolbar.js +337 -424
- package/src/toolbar/block/blockbuttonview.js +32 -42
- package/src/toolbar/block/blocktoolbar.js +375 -477
- package/src/toolbar/normalizetoolbarconfig.js +17 -21
- package/src/toolbar/toolbarlinebreakview.js +15 -19
- package/src/toolbar/toolbarseparatorview.js +15 -19
- package/src/toolbar/toolbarview.js +866 -1053
- package/src/tooltipmanager.js +324 -353
- package/src/view.js +389 -430
- package/src/viewcollection.js +147 -178
- package/src/button/button.jsdoc +0 -165
- package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
- package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
|
@@ -2,16 +2,13 @@
|
|
|
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/labeledfield/labeledfieldview
|
|
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/labeledfield/labeledfieldview.css';
|
|
14
|
-
|
|
15
12
|
/**
|
|
16
13
|
* The labeled field view class. It can be used to enhance any view with the following features:
|
|
17
14
|
*
|
|
@@ -51,236 +48,216 @@ import '../../theme/components/labeledfield/labeledfieldview.css';
|
|
|
51
48
|
* @extends module:ui/view~View
|
|
52
49
|
*/
|
|
53
50
|
export default class LabeledFieldView extends View {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
],
|
|
267
|
-
id: statusUid,
|
|
268
|
-
role: bind.if( 'errorText', 'alert' )
|
|
269
|
-
},
|
|
270
|
-
children: [
|
|
271
|
-
{
|
|
272
|
-
text: bind.to( '_statusText' )
|
|
273
|
-
}
|
|
274
|
-
]
|
|
275
|
-
} );
|
|
276
|
-
|
|
277
|
-
return statusView;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Focuses the {@link #fieldView}.
|
|
282
|
-
*/
|
|
283
|
-
focus() {
|
|
284
|
-
this.fieldView.focus();
|
|
285
|
-
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates an instance of the labeled field view class using a provided creator function
|
|
53
|
+
* that provides the view to be labeled.
|
|
54
|
+
*
|
|
55
|
+
* @param {module:utils/locale~Locale} locale The locale instance.
|
|
56
|
+
* @param {Function} viewCreator A function that returns a {@link module:ui/view~View}
|
|
57
|
+
* that will be labeled. The following arguments are passed to the creator function:
|
|
58
|
+
*
|
|
59
|
+
* * an instance of the `LabeledFieldView` to allow binding observable properties,
|
|
60
|
+
* * an UID string that connects the {@link #labelView label} and the labeled field view in DOM,
|
|
61
|
+
* * an UID string that connects the {@link #statusView status} and the labeled field view in DOM.
|
|
62
|
+
*/
|
|
63
|
+
constructor(locale, viewCreator) {
|
|
64
|
+
super(locale);
|
|
65
|
+
const viewUid = `ck-labeled-field-view-${uid()}`;
|
|
66
|
+
const statusUid = `ck-labeled-field-view-status-${uid()}`;
|
|
67
|
+
/**
|
|
68
|
+
* The field view that gets labeled.
|
|
69
|
+
*
|
|
70
|
+
* @member {module:ui/view~View} #fieldView
|
|
71
|
+
*/
|
|
72
|
+
this.fieldView = viewCreator(this, viewUid, statusUid);
|
|
73
|
+
/**
|
|
74
|
+
* The text of the label.
|
|
75
|
+
*
|
|
76
|
+
* @observable
|
|
77
|
+
* @member {String} #label
|
|
78
|
+
*/
|
|
79
|
+
this.set('label', undefined);
|
|
80
|
+
/**
|
|
81
|
+
* Controls whether the component is in read-only mode.
|
|
82
|
+
*
|
|
83
|
+
* @observable
|
|
84
|
+
* @member {Boolean} #isEnabled
|
|
85
|
+
*/
|
|
86
|
+
this.set('isEnabled', true);
|
|
87
|
+
/**
|
|
88
|
+
* An observable flag set to `true` when {@link #fieldView} is empty (`false` otherwise).
|
|
89
|
+
*
|
|
90
|
+
* @readonly
|
|
91
|
+
* @observable
|
|
92
|
+
* @member {Boolean} #isEmpty
|
|
93
|
+
* @default true
|
|
94
|
+
*/
|
|
95
|
+
this.set('isEmpty', true);
|
|
96
|
+
/**
|
|
97
|
+
* An observable flag set to `true` when {@link #fieldView} is currently focused by
|
|
98
|
+
* the user (`false` otherwise).
|
|
99
|
+
*
|
|
100
|
+
* @readonly
|
|
101
|
+
* @observable
|
|
102
|
+
* @member {Boolean} #isFocused
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
this.set('isFocused', false);
|
|
106
|
+
/**
|
|
107
|
+
* The validation error text. When set, it will be displayed
|
|
108
|
+
* next to the {@link #fieldView} as a typical validation error message.
|
|
109
|
+
* Set it to `null` to hide the message.
|
|
110
|
+
*
|
|
111
|
+
* **Note:** Setting this property to anything but `null` will automatically
|
|
112
|
+
* make the `hasError` of the {@link #fieldView} `true`.
|
|
113
|
+
*
|
|
114
|
+
* @observable
|
|
115
|
+
* @member {String|null} #errorText
|
|
116
|
+
*/
|
|
117
|
+
this.set('errorText', null);
|
|
118
|
+
/**
|
|
119
|
+
* The additional information text displayed next to the {@link #fieldView} which can
|
|
120
|
+
* be used to inform the user about its purpose, provide help or hints.
|
|
121
|
+
*
|
|
122
|
+
* Set it to `null` to hide the message.
|
|
123
|
+
*
|
|
124
|
+
* **Note:** This text will be displayed in the same place as {@link #errorText} but the
|
|
125
|
+
* latter always takes precedence: if the {@link #errorText} is set, it replaces
|
|
126
|
+
* {@link #infoText}.
|
|
127
|
+
*
|
|
128
|
+
* @observable
|
|
129
|
+
* @member {String|null} #infoText
|
|
130
|
+
* @default null
|
|
131
|
+
*/
|
|
132
|
+
this.set('infoText', null);
|
|
133
|
+
/**
|
|
134
|
+
* (Optional) The additional CSS class set on the dropdown {@link #element}.
|
|
135
|
+
*
|
|
136
|
+
* @observable
|
|
137
|
+
* @member {String} #class
|
|
138
|
+
*/
|
|
139
|
+
this.set('class', undefined);
|
|
140
|
+
/**
|
|
141
|
+
* The content of the `placeholder` attribute of the {@link #fieldView}.
|
|
142
|
+
*
|
|
143
|
+
* @observable
|
|
144
|
+
* @member {String} #placeholder
|
|
145
|
+
*/
|
|
146
|
+
this.set('placeholder', undefined);
|
|
147
|
+
/**
|
|
148
|
+
* The label view instance that describes the entire view.
|
|
149
|
+
*
|
|
150
|
+
* @member {module:ui/label/labelview~LabelView} #labelView
|
|
151
|
+
*/
|
|
152
|
+
this.labelView = this._createLabelView(viewUid);
|
|
153
|
+
/**
|
|
154
|
+
* The status view for the {@link #fieldView}. It displays {@link #errorText} and
|
|
155
|
+
* {@link #infoText}.
|
|
156
|
+
*
|
|
157
|
+
* @member {module:ui/view~View} #statusView
|
|
158
|
+
*/
|
|
159
|
+
this.statusView = this._createStatusView(statusUid);
|
|
160
|
+
/**
|
|
161
|
+
* A collection of children of the internal wrapper element. Allows inserting additional DOM elements (views) next to
|
|
162
|
+
* the {@link #fieldView} for easy styling (e.g. positioning).
|
|
163
|
+
*
|
|
164
|
+
* By default, the collection contains {@link #fieldView} and {@link #labelView}.
|
|
165
|
+
*
|
|
166
|
+
* @member {module:ui/viewcollection~ViewCollection} #fieldWrapperChildren
|
|
167
|
+
*/
|
|
168
|
+
this.fieldWrapperChildren = this.createCollection([this.fieldView, this.labelView]);
|
|
169
|
+
/**
|
|
170
|
+
* The combined status text made of {@link #errorText} and {@link #infoText}.
|
|
171
|
+
* Note that when present, {@link #errorText} always takes precedence in the
|
|
172
|
+
* status.
|
|
173
|
+
*
|
|
174
|
+
* @see #errorText
|
|
175
|
+
* @see #infoText
|
|
176
|
+
* @see #statusView
|
|
177
|
+
* @private
|
|
178
|
+
* @observable
|
|
179
|
+
* @member {String|null} #_statusText
|
|
180
|
+
*/
|
|
181
|
+
this.bind('_statusText').to(this, 'errorText', this, 'infoText', (errorText, infoText) => errorText || infoText);
|
|
182
|
+
const bind = this.bindTemplate;
|
|
183
|
+
this.setTemplate({
|
|
184
|
+
tag: 'div',
|
|
185
|
+
attributes: {
|
|
186
|
+
class: [
|
|
187
|
+
'ck',
|
|
188
|
+
'ck-labeled-field-view',
|
|
189
|
+
bind.to('class'),
|
|
190
|
+
bind.if('isEnabled', 'ck-disabled', value => !value),
|
|
191
|
+
bind.if('isEmpty', 'ck-labeled-field-view_empty'),
|
|
192
|
+
bind.if('isFocused', 'ck-labeled-field-view_focused'),
|
|
193
|
+
bind.if('placeholder', 'ck-labeled-field-view_placeholder'),
|
|
194
|
+
bind.if('errorText', 'ck-error')
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
children: [
|
|
198
|
+
{
|
|
199
|
+
tag: 'div',
|
|
200
|
+
attributes: {
|
|
201
|
+
class: [
|
|
202
|
+
'ck',
|
|
203
|
+
'ck-labeled-field-view__input-wrapper'
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
children: this.fieldWrapperChildren
|
|
207
|
+
},
|
|
208
|
+
this.statusView
|
|
209
|
+
]
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Creates label view class instance and bind with view.
|
|
214
|
+
*
|
|
215
|
+
* @private
|
|
216
|
+
* @param {String} id Unique id to set as labelView#for attribute.
|
|
217
|
+
* @returns {module:ui/label/labelview~LabelView}
|
|
218
|
+
*/
|
|
219
|
+
_createLabelView(id) {
|
|
220
|
+
const labelView = new LabelView(this.locale);
|
|
221
|
+
labelView.for = id;
|
|
222
|
+
labelView.bind('text').to(this, 'label');
|
|
223
|
+
return labelView;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Creates the status view instance. It displays {@link #errorText} and {@link #infoText}
|
|
227
|
+
* next to the {@link #fieldView}. See {@link #_statusText}.
|
|
228
|
+
*
|
|
229
|
+
* @private
|
|
230
|
+
* @param {String} statusUid Unique id of the status, shared with the {@link #fieldView view's}
|
|
231
|
+
* `aria-describedby` attribute.
|
|
232
|
+
* @returns {module:ui/view~View}
|
|
233
|
+
*/
|
|
234
|
+
_createStatusView(statusUid) {
|
|
235
|
+
const statusView = new View(this.locale);
|
|
236
|
+
const bind = this.bindTemplate;
|
|
237
|
+
statusView.setTemplate({
|
|
238
|
+
tag: 'div',
|
|
239
|
+
attributes: {
|
|
240
|
+
class: [
|
|
241
|
+
'ck',
|
|
242
|
+
'ck-labeled-field-view__status',
|
|
243
|
+
bind.if('errorText', 'ck-labeled-field-view__status_error'),
|
|
244
|
+
bind.if('_statusText', 'ck-hidden', value => !value)
|
|
245
|
+
],
|
|
246
|
+
id: statusUid,
|
|
247
|
+
role: bind.if('errorText', 'alert')
|
|
248
|
+
},
|
|
249
|
+
children: [
|
|
250
|
+
{
|
|
251
|
+
text: bind.to('_statusText')
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
});
|
|
255
|
+
return statusView;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Focuses the {@link #fieldView}.
|
|
259
|
+
*/
|
|
260
|
+
focus() {
|
|
261
|
+
this.fieldView.focus();
|
|
262
|
+
}
|
|
286
263
|
}
|
|
@@ -2,15 +2,12 @@
|
|
|
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/labeledfield/utils
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import InputTextView from '../inputtext/inputtextview';
|
|
11
9
|
import InputNumberView from '../inputnumber/inputnumberview';
|
|
12
10
|
import { createDropdown } from '../dropdown/utils';
|
|
13
|
-
|
|
14
11
|
/**
|
|
15
12
|
* A helper for creating labeled inputs.
|
|
16
13
|
*
|
|
@@ -36,28 +33,22 @@ import { createDropdown } from '../dropdown/utils';
|
|
|
36
33
|
* {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#statusView labeled view's status} and the input.
|
|
37
34
|
* @returns {module:ui/inputtext/inputtextview~InputTextView} The input text view instance.
|
|
38
35
|
*/
|
|
39
|
-
export function createLabeledInputText(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} );
|
|
55
|
-
|
|
56
|
-
labeledFieldView.bind( 'isEmpty', 'isFocused', 'placeholder' ).to( inputView );
|
|
57
|
-
|
|
58
|
-
return inputView;
|
|
36
|
+
export function createLabeledInputText(labeledFieldView, viewUid, statusUid) {
|
|
37
|
+
const inputView = new InputTextView(labeledFieldView.locale);
|
|
38
|
+
inputView.set({
|
|
39
|
+
id: viewUid,
|
|
40
|
+
ariaDescribedById: statusUid
|
|
41
|
+
});
|
|
42
|
+
inputView.bind('isReadOnly').to(labeledFieldView, 'isEnabled', value => !value);
|
|
43
|
+
inputView.bind('hasError').to(labeledFieldView, 'errorText', value => !!value);
|
|
44
|
+
inputView.on('input', () => {
|
|
45
|
+
// UX: Make the error text disappear and disable the error indicator as the user
|
|
46
|
+
// starts fixing the errors.
|
|
47
|
+
labeledFieldView.errorText = null;
|
|
48
|
+
});
|
|
49
|
+
labeledFieldView.bind('isEmpty', 'isFocused', 'placeholder').to(inputView);
|
|
50
|
+
return inputView;
|
|
59
51
|
}
|
|
60
|
-
|
|
61
52
|
/**
|
|
62
53
|
* A helper for creating labeled number inputs.
|
|
63
54
|
*
|
|
@@ -83,29 +74,23 @@ export function createLabeledInputText( labeledFieldView, viewUid, statusUid ) {
|
|
|
83
74
|
* {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#statusView labeled view's status} and the input.
|
|
84
75
|
* @returns {module:ui/inputnumber/inputnumberview~InputNumberView} The input number view instance.
|
|
85
76
|
*/
|
|
86
|
-
export function createLabeledInputNumber(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
} );
|
|
103
|
-
|
|
104
|
-
labeledFieldView.bind( 'isEmpty', 'isFocused', 'placeholder' ).to( inputView );
|
|
105
|
-
|
|
106
|
-
return inputView;
|
|
77
|
+
export function createLabeledInputNumber(labeledFieldView, viewUid, statusUid) {
|
|
78
|
+
const inputView = new InputNumberView(labeledFieldView.locale);
|
|
79
|
+
inputView.set({
|
|
80
|
+
id: viewUid,
|
|
81
|
+
ariaDescribedById: statusUid,
|
|
82
|
+
inputMode: 'numeric'
|
|
83
|
+
});
|
|
84
|
+
inputView.bind('isReadOnly').to(labeledFieldView, 'isEnabled', value => !value);
|
|
85
|
+
inputView.bind('hasError').to(labeledFieldView, 'errorText', value => !!value);
|
|
86
|
+
inputView.on('input', () => {
|
|
87
|
+
// UX: Make the error text disappear and disable the error indicator as the user
|
|
88
|
+
// starts fixing the errors.
|
|
89
|
+
labeledFieldView.errorText = null;
|
|
90
|
+
});
|
|
91
|
+
labeledFieldView.bind('isEmpty', 'isFocused', 'placeholder').to(inputView);
|
|
92
|
+
return inputView;
|
|
107
93
|
}
|
|
108
|
-
|
|
109
94
|
/**
|
|
110
95
|
* A helper for creating labeled dropdowns.
|
|
111
96
|
*
|
|
@@ -129,15 +114,12 @@ export function createLabeledInputNumber( labeledFieldView, viewUid, statusUid )
|
|
|
129
114
|
* {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView#statusView labeled view status} and the dropdown.
|
|
130
115
|
* @returns {module:ui/dropdown/dropdownview~DropdownView} The dropdown view instance.
|
|
131
116
|
*/
|
|
132
|
-
export function createLabeledDropdown(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
dropdownView.bind( 'isEnabled' ).to( labeledFieldView );
|
|
141
|
-
|
|
142
|
-
return dropdownView;
|
|
117
|
+
export function createLabeledDropdown(labeledFieldView, viewUid, statusUid) {
|
|
118
|
+
const dropdownView = createDropdown(labeledFieldView.locale);
|
|
119
|
+
dropdownView.set({
|
|
120
|
+
id: viewUid,
|
|
121
|
+
ariaDescribedById: statusUid
|
|
122
|
+
});
|
|
123
|
+
dropdownView.bind('isEnabled').to(labeledFieldView);
|
|
124
|
+
return dropdownView;
|
|
143
125
|
}
|