@progress/kendo-vue-inputs 3.6.4 → 3.6.5-dev.202210181442
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/dist/cdn/js/kendo-vue-inputs.js +1 -1
- package/dist/es/checkbox/Checkbox.js +17 -35
- package/dist/es/colors/ColorContrastLabels.js +0 -2
- package/dist/es/colors/ColorContrastSvg.js +6 -20
- package/dist/es/colors/ColorGradient.js +2 -28
- package/dist/es/colors/ColorInput.js +12 -20
- package/dist/es/colors/ColorPalette.js +0 -19
- package/dist/es/colors/ColorPicker.js +28 -52
- package/dist/es/colors/FlatColorPicker.js +14 -24
- package/dist/es/colors/HexInput.js +0 -4
- package/dist/es/colors/Picker.js +6 -9
- package/dist/es/input/Input.js +15 -29
- package/dist/es/input-separator/InputSeparator.js +0 -2
- package/dist/es/maskedtextbox/MaskedTextBox.js +13 -32
- package/dist/es/numerictextbox/NumericTextBox.js +15 -48
- package/dist/es/numerictextbox/utils/main.js +33 -132
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/radiobutton/RadioButton.js +11 -16
- package/dist/es/radiobutton/RadioGroup.js +9 -12
- package/dist/es/range-slider/RangeSlider.js +9 -32
- package/dist/es/range-slider/range-raducer.js +0 -26
- package/dist/es/slider/Slider.js +8 -20
- package/dist/es/slider/SliderLabel.js +2 -12
- package/dist/es/switch/Switch.js +6 -18
- package/dist/es/textarea/TextArea.js +27 -40
- package/dist/esm/checkbox/Checkbox.js +17 -35
- package/dist/esm/colors/ColorContrastLabels.js +0 -2
- package/dist/esm/colors/ColorContrastSvg.js +6 -20
- package/dist/esm/colors/ColorGradient.js +2 -28
- package/dist/esm/colors/ColorInput.js +12 -20
- package/dist/esm/colors/ColorPalette.js +0 -19
- package/dist/esm/colors/ColorPicker.js +28 -52
- package/dist/esm/colors/FlatColorPicker.js +14 -24
- package/dist/esm/colors/HexInput.js +0 -4
- package/dist/esm/colors/Picker.js +6 -9
- package/dist/esm/input/Input.js +15 -29
- package/dist/esm/input-separator/InputSeparator.js +0 -2
- package/dist/esm/maskedtextbox/MaskedTextBox.js +13 -32
- package/dist/esm/numerictextbox/NumericTextBox.js +15 -48
- package/dist/esm/numerictextbox/utils/main.js +33 -132
- package/dist/esm/package-metadata.js +1 -1
- package/dist/esm/radiobutton/RadioButton.js +11 -16
- package/dist/esm/radiobutton/RadioGroup.js +9 -12
- package/dist/esm/range-slider/RangeSlider.js +9 -32
- package/dist/esm/range-slider/range-raducer.js +0 -26
- package/dist/esm/slider/Slider.js +8 -20
- package/dist/esm/slider/SliderLabel.js +2 -12
- package/dist/esm/switch/Switch.js +6 -18
- package/dist/esm/textarea/TextArea.js +27 -40
- package/dist/npm/checkbox/Checkbox.js +19 -43
- package/dist/npm/colors/ColorContrastLabels.js +2 -9
- package/dist/npm/colors/ColorContrastSvg.js +8 -26
- package/dist/npm/colors/ColorGradient.js +4 -44
- package/dist/npm/colors/ColorInput.js +12 -29
- package/dist/npm/colors/ColorPalette.js +2 -29
- package/dist/npm/colors/ColorPicker.js +26 -59
- package/dist/npm/colors/FlatColorPicker.js +14 -35
- package/dist/npm/colors/HexInput.js +2 -11
- package/dist/npm/colors/Picker.js +8 -15
- package/dist/npm/input/Input.js +15 -34
- package/dist/npm/input-separator/InputSeparator.js +2 -8
- package/dist/npm/maskedtextbox/MaskedTextBox.js +15 -40
- package/dist/npm/numerictextbox/NumericTextBox.js +17 -59
- package/dist/npm/numerictextbox/utils/main.js +33 -160
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/radiobutton/RadioButton.js +13 -23
- package/dist/npm/radiobutton/RadioGroup.js +11 -19
- package/dist/npm/range-slider/RangeSlider.js +7 -38
- package/dist/npm/range-slider/range-raducer.js +0 -27
- package/dist/npm/slider/Slider.js +10 -30
- package/dist/npm/slider/SliderLabel.js +2 -15
- package/dist/npm/switch/Switch.js +8 -26
- package/dist/npm/textarea/TextArea.js +25 -43
- package/package.json +11 -11
|
@@ -2,18 +2,14 @@ var __assign = this && this.__assign || function () {
|
|
|
2
2
|
__assign = Object.assign || function (t) {
|
|
3
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
4
|
s = arguments[i];
|
|
5
|
-
|
|
6
5
|
for (var p in s) {
|
|
7
6
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return t;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
return __assign.apply(this, arguments);
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
var DEFAULT_NUMBER = 1111111.1111111;
|
|
18
14
|
var MAX_DECIMAL = 0.31111111111111117;
|
|
19
15
|
var MIN_DECIMAL = 1;
|
|
@@ -24,7 +20,6 @@ var MAX_PRECISION = 15;
|
|
|
24
20
|
/**
|
|
25
21
|
* @hidden
|
|
26
22
|
*/
|
|
27
|
-
|
|
28
23
|
export var getInitialState = function getInitialState() {
|
|
29
24
|
return {
|
|
30
25
|
eventValue: null,
|
|
@@ -41,51 +36,42 @@ export var getInitialState = function getInitialState() {
|
|
|
41
36
|
/**
|
|
42
37
|
* @hidden
|
|
43
38
|
*/
|
|
44
|
-
|
|
45
39
|
export var getStateOrPropsValue = function getStateOrPropsValue(value, stateValue) {
|
|
46
40
|
return value !== undefined ? value : stateValue;
|
|
47
41
|
};
|
|
48
42
|
/**
|
|
49
43
|
* @hidden
|
|
50
44
|
*/
|
|
51
|
-
|
|
52
45
|
export var formatValue = function formatValue(value, format, intlService) {
|
|
53
46
|
if (value === null && value === undefined) {
|
|
54
47
|
return '';
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
if (typeof value === 'string') {
|
|
58
50
|
return value;
|
|
59
51
|
}
|
|
60
|
-
|
|
61
52
|
return intlService.formatNumber(value, format);
|
|
62
53
|
};
|
|
63
54
|
/**
|
|
64
55
|
* @hidden
|
|
65
56
|
*/
|
|
66
|
-
|
|
67
57
|
export var fractionLength = function fractionLength(value) {
|
|
68
58
|
return (String(value).split('.')[1] || '').length;
|
|
69
59
|
};
|
|
70
60
|
/**
|
|
71
61
|
* @hidden
|
|
72
62
|
*/
|
|
73
|
-
|
|
74
63
|
var maxFractionLength = function maxFractionLength(value1, value2) {
|
|
75
64
|
return Math.max(fractionLength(value1), fractionLength(value2));
|
|
76
65
|
};
|
|
77
66
|
/**
|
|
78
67
|
* @hidden
|
|
79
68
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
69
|
export var limitPrecision = function limitPrecision(precision) {
|
|
83
70
|
return Math.min(precision, MAX_PRECISION);
|
|
84
71
|
};
|
|
85
72
|
/**
|
|
86
73
|
* @hidden
|
|
87
74
|
*/
|
|
88
|
-
|
|
89
75
|
export var toFixedPrecision = function toFixedPrecision(value, precision) {
|
|
90
76
|
var maxPrecision = limitPrecision(precision);
|
|
91
77
|
return parseFloat(value.toFixed(maxPrecision));
|
|
@@ -93,7 +79,6 @@ export var toFixedPrecision = function toFixedPrecision(value, precision) {
|
|
|
93
79
|
/**
|
|
94
80
|
* @hidden
|
|
95
81
|
*/
|
|
96
|
-
|
|
97
82
|
export var increaseValue = function increaseValue(value, newState, step, min, max, format, intlService) {
|
|
98
83
|
var maxPrecision = maxFractionLength(value || 0, step || 0);
|
|
99
84
|
var increasedValue = rangeValue(toFixedPrecision((value || 0) + (step || 0), maxPrecision), min, max);
|
|
@@ -104,7 +89,6 @@ export var increaseValue = function increaseValue(value, newState, step, min, ma
|
|
|
104
89
|
/**
|
|
105
90
|
* @hidden
|
|
106
91
|
*/
|
|
107
|
-
|
|
108
92
|
export var decreaseValue = function decreaseValue(value, newState, step, min, max, format, intlService) {
|
|
109
93
|
var maxPrecision = maxFractionLength(value || 0, step || 0);
|
|
110
94
|
var decreasedValue = rangeValue(toFixedPrecision((value || 0) - (step || 0), maxPrecision), min, max);
|
|
@@ -115,89 +99,71 @@ export var decreaseValue = function decreaseValue(value, newState, step, min, ma
|
|
|
115
99
|
/**
|
|
116
100
|
* @hidden
|
|
117
101
|
*/
|
|
118
|
-
|
|
119
102
|
export var rangeValue = function rangeValue(value, min, max) {
|
|
120
103
|
if (value == null) {
|
|
121
104
|
return value;
|
|
122
105
|
}
|
|
123
|
-
|
|
124
106
|
if (!(value > 1 || value < 1 || value === 1)) {
|
|
125
107
|
// null, undefined or NaN
|
|
126
108
|
return null;
|
|
127
109
|
}
|
|
128
|
-
|
|
129
110
|
if (max !== undefined && min !== undefined && max < min) {
|
|
130
111
|
return null;
|
|
131
112
|
}
|
|
132
|
-
|
|
133
113
|
if (max !== undefined && value > max) {
|
|
134
114
|
value = max;
|
|
135
115
|
}
|
|
136
|
-
|
|
137
116
|
if (min !== undefined && value < min) {
|
|
138
117
|
value = min;
|
|
139
118
|
}
|
|
140
|
-
|
|
141
119
|
return value;
|
|
142
120
|
};
|
|
143
121
|
/**
|
|
144
122
|
* @hidden
|
|
145
123
|
*/
|
|
146
|
-
|
|
147
124
|
export var getMaxCursorPosition = function getMaxCursorPosition(nextValue, formatInfo) {
|
|
148
125
|
var formatSuffixIndex = formatInfo.findIndex(function (_a) {
|
|
149
126
|
var _ = _a[0],
|
|
150
|
-
|
|
127
|
+
currSuffix = _a[1];
|
|
151
128
|
return Boolean(currSuffix) && nextValue.indexOf(currSuffix) === nextValue.length - currSuffix.length;
|
|
152
129
|
});
|
|
153
|
-
|
|
154
130
|
if (formatSuffixIndex === -1) {
|
|
155
131
|
return -1;
|
|
156
132
|
}
|
|
157
|
-
|
|
158
133
|
var suffix = formatInfo[formatSuffixIndex][1];
|
|
159
134
|
return nextValue.length - suffix.length;
|
|
160
135
|
};
|
|
161
136
|
/**
|
|
162
137
|
* @hidden
|
|
163
138
|
*/
|
|
164
|
-
|
|
165
139
|
export var getMinCursorPosition = function getMinCursorPosition(nextValue, formatInfo) {
|
|
166
140
|
var formatPrefixIndex = formatInfo.findIndex(function (_a) {
|
|
167
141
|
var currPrefix = _a[0],
|
|
168
|
-
|
|
142
|
+
_ = _a[1];
|
|
169
143
|
return Boolean(currPrefix) && nextValue.indexOf(currPrefix) === 0;
|
|
170
144
|
});
|
|
171
|
-
|
|
172
145
|
if (formatPrefixIndex === -1) {
|
|
173
146
|
return -1;
|
|
174
147
|
}
|
|
175
|
-
|
|
176
148
|
var prefix = formatInfo[formatPrefixIndex][0];
|
|
177
149
|
return prefix.length;
|
|
178
150
|
};
|
|
179
151
|
/**
|
|
180
152
|
* @hidden
|
|
181
153
|
*/
|
|
182
|
-
|
|
183
154
|
export var rangeSelection = function rangeSelection(nextLooseValue, formatInfo, newState) {
|
|
184
155
|
var maxPosition = getMaxCursorPosition(nextLooseValue, formatInfo);
|
|
185
|
-
|
|
186
156
|
if (maxPosition !== -1 && newState.selectionStart > maxPosition) {
|
|
187
157
|
newState.selectionStart = newState.selectionEnd = maxPosition;
|
|
188
158
|
return;
|
|
189
159
|
}
|
|
190
|
-
|
|
191
160
|
if (newState.selectionStart > nextLooseValue.length) {
|
|
192
161
|
newState.selectionStart = newState.selectionEnd = nextLooseValue.length;
|
|
193
162
|
}
|
|
194
|
-
|
|
195
163
|
var minPosition = getMinCursorPosition(nextLooseValue, formatInfo);
|
|
196
|
-
|
|
197
164
|
if (minPosition !== -1 && newState.selectionStart < minPosition) {
|
|
198
165
|
newState.selectionStart = newState.selectionEnd = minPosition;
|
|
199
166
|
}
|
|
200
|
-
|
|
201
167
|
if (newState.selectionStart === -1) {
|
|
202
168
|
newState.selectionStart = newState.selectionEnd = 0;
|
|
203
169
|
}
|
|
@@ -205,7 +171,6 @@ export var rangeSelection = function rangeSelection(nextLooseValue, formatInfo,
|
|
|
205
171
|
/**
|
|
206
172
|
* @hidden
|
|
207
173
|
*/
|
|
208
|
-
|
|
209
174
|
export var setSelection = function setSelection(newState, newIndex, nextLooseValue, formatInfo) {
|
|
210
175
|
newState.selectionStart = newState.selectionEnd = newIndex;
|
|
211
176
|
rangeSelection(nextLooseValue, formatInfo, newState);
|
|
@@ -213,7 +178,6 @@ export var setSelection = function setSelection(newState, newIndex, nextLooseVal
|
|
|
213
178
|
/**
|
|
214
179
|
* @hidden
|
|
215
180
|
*/
|
|
216
|
-
|
|
217
181
|
export var setInvalid = function setInvalid(newState, format, formatInfo, intlService) {
|
|
218
182
|
newState.eventValue = intlService.parseNumber(newState.prevLooseValue, format);
|
|
219
183
|
newState.currentLooseValue = newState.prevLooseValue;
|
|
@@ -223,7 +187,6 @@ export var setInvalid = function setInvalid(newState, format, formatInfo, intlSe
|
|
|
223
187
|
/**
|
|
224
188
|
* @hidden
|
|
225
189
|
*/
|
|
226
|
-
|
|
227
190
|
export var isMinusSymbolAdded = function isMinusSymbolAdded(newState, symbols) {
|
|
228
191
|
var newText = String(newState.currentLooseValue);
|
|
229
192
|
var oldText = String(newState.prevLooseValue);
|
|
@@ -232,7 +195,6 @@ export var isMinusSymbolAdded = function isMinusSymbolAdded(newState, symbols) {
|
|
|
232
195
|
/**
|
|
233
196
|
* @hidden
|
|
234
197
|
*/
|
|
235
|
-
|
|
236
198
|
export var isMinusSymbolRemoved = function isMinusSymbolRemoved(newState, symbols) {
|
|
237
199
|
var newText = String(newState.currentLooseValue);
|
|
238
200
|
var oldText = String(newState.prevLooseValue);
|
|
@@ -241,7 +203,6 @@ export var isMinusSymbolRemoved = function isMinusSymbolRemoved(newState, symbol
|
|
|
241
203
|
/**
|
|
242
204
|
* @hidden
|
|
243
205
|
*/
|
|
244
|
-
|
|
245
206
|
export var isDecimalDuplicated = function isDecimalDuplicated(newState, symbols) {
|
|
246
207
|
var newText = String(newState.currentLooseValue);
|
|
247
208
|
return newText.split(symbols.decimal).length > 2;
|
|
@@ -249,7 +210,6 @@ export var isDecimalDuplicated = function isDecimalDuplicated(newState, symbols)
|
|
|
249
210
|
/**
|
|
250
211
|
* @hidden
|
|
251
212
|
*/
|
|
252
|
-
|
|
253
213
|
export var getFormatPrefixSufix = function getFormatPrefixSufix(format, intlService) {
|
|
254
214
|
var positiveResult = intlService.formatNumber(DEFAULT_NUMBER, format);
|
|
255
215
|
var negativeResult = intlService.formatNumber(-DEFAULT_NUMBER, format);
|
|
@@ -273,7 +233,6 @@ export var getFormatPrefixSufix = function getFormatPrefixSufix(format, intlServ
|
|
|
273
233
|
/**
|
|
274
234
|
* @hidden
|
|
275
235
|
*/
|
|
276
|
-
|
|
277
236
|
export var getFormatSymbols = function getFormatSymbols(format, intlService) {
|
|
278
237
|
var positiveResult = intlService.formatNumber(DEFAULT_NUMBER, format);
|
|
279
238
|
var negativeResult = intlService.formatNumber(-DEFAULT_NUMBER, format);
|
|
@@ -291,41 +250,34 @@ export var getFormatSymbols = function getFormatSymbols(format, intlService) {
|
|
|
291
250
|
/**
|
|
292
251
|
* @hidden
|
|
293
252
|
*/
|
|
294
|
-
|
|
295
253
|
export var getInitialPosition = function getInitialPosition(nextLooseValue, symbols) {
|
|
296
254
|
var decimalIdex = nextLooseValue.indexOf(symbols.decimal);
|
|
297
|
-
|
|
298
255
|
if (decimalIdex > -1) {
|
|
299
256
|
return decimalIdex;
|
|
300
257
|
}
|
|
301
|
-
|
|
302
258
|
return getLastNumberIndex(nextLooseValue, DIGITS_REGEX);
|
|
303
259
|
};
|
|
304
260
|
/**
|
|
305
261
|
* @hidden
|
|
306
262
|
*/
|
|
307
|
-
|
|
308
263
|
export var reverseString = function reverseString(str) {
|
|
309
264
|
return str.split('').reverse().join('');
|
|
310
265
|
};
|
|
311
266
|
/**
|
|
312
267
|
* @hidden
|
|
313
268
|
*/
|
|
314
|
-
|
|
315
269
|
export var getLastNumberIndex = function getLastNumberIndex(currentLooseValue, inputRegex) {
|
|
316
270
|
return currentLooseValue.length - reverseString(currentLooseValue).search(inputRegex);
|
|
317
271
|
};
|
|
318
272
|
/**
|
|
319
273
|
* @hidden
|
|
320
274
|
*/
|
|
321
|
-
|
|
322
275
|
export var getPrefix = function getPrefix(str) {
|
|
323
276
|
return str.split(str[str.search(DIGITS_REGEX)])[0];
|
|
324
277
|
};
|
|
325
278
|
/**
|
|
326
279
|
* @hidden
|
|
327
280
|
*/
|
|
328
|
-
|
|
329
281
|
export var getSuffix = function getSuffix(str) {
|
|
330
282
|
var reversedString = reverseString(str);
|
|
331
283
|
return reverseString(reversedString.split(reversedString[reversedString.search(DIGITS_REGEX)])[0]);
|
|
@@ -333,14 +285,12 @@ export var getSuffix = function getSuffix(str) {
|
|
|
333
285
|
/**
|
|
334
286
|
* @hidden
|
|
335
287
|
*/
|
|
336
|
-
|
|
337
288
|
export var getFirstNumberIndex = function getFirstNumberIndex(prevLooseValue, inputRegex) {
|
|
338
289
|
return prevLooseValue.search(inputRegex);
|
|
339
290
|
};
|
|
340
291
|
/**
|
|
341
292
|
* @hidden
|
|
342
293
|
*/
|
|
343
|
-
|
|
344
294
|
export var getDecimalCount = function getDecimalCount(value, decimal) {
|
|
345
295
|
var currentDecimalPlace = value.indexOf(decimal);
|
|
346
296
|
return currentDecimalPlace > -1 ? value.length - currentDecimalPlace - 1 : 0;
|
|
@@ -348,46 +298,35 @@ export var getDecimalCount = function getDecimalCount(value, decimal) {
|
|
|
348
298
|
/**
|
|
349
299
|
* @hidden
|
|
350
300
|
*/
|
|
351
|
-
|
|
352
301
|
export var changeBasedSelection = function changeBasedSelection(currentValue, nextValue, selectionPosition, isDelete, sanitizeRegex) {
|
|
353
302
|
var isCurrentLeadingZero = currentValue.replace(sanitizeRegex, '')[0] === '0';
|
|
354
303
|
var isNextLeadingZero = nextValue.replace(sanitizeRegex, '')[0] === '0';
|
|
355
|
-
|
|
356
304
|
if (isCurrentLeadingZero && !isNextLeadingZero) {
|
|
357
305
|
return selectionPosition - 1;
|
|
358
306
|
}
|
|
359
|
-
|
|
360
307
|
if (isNextLeadingZero && isDelete) {
|
|
361
308
|
return selectionPosition + 1;
|
|
362
309
|
}
|
|
363
|
-
|
|
364
310
|
var numberCounter = 0;
|
|
365
|
-
|
|
366
311
|
for (var idx = 0; idx < selectionPosition; idx++) {
|
|
367
312
|
if (DIGITS_REGEX.test(currentValue.charAt(idx))) {
|
|
368
313
|
numberCounter++;
|
|
369
314
|
}
|
|
370
315
|
}
|
|
371
|
-
|
|
372
316
|
var newSelection = 0;
|
|
373
|
-
|
|
374
317
|
while (numberCounter > 0 && nextValue.length > newSelection) {
|
|
375
318
|
if (DIGITS_REGEX.test(nextValue.charAt(newSelection))) {
|
|
376
319
|
numberCounter--;
|
|
377
320
|
}
|
|
378
|
-
|
|
379
321
|
newSelection++;
|
|
380
322
|
}
|
|
381
|
-
|
|
382
323
|
return newSelection;
|
|
383
324
|
};
|
|
384
325
|
/**
|
|
385
326
|
* @hidden
|
|
386
327
|
*/
|
|
387
|
-
|
|
388
328
|
export var sanitizeNumber = function sanitizeNumber(state, format, intlService) {
|
|
389
329
|
var newState = __assign({}, state);
|
|
390
|
-
|
|
391
330
|
var prevLooseValue = newState.prevLooseValue;
|
|
392
331
|
var symbols = intlService.numberSymbols();
|
|
393
332
|
var restrictedSymbols = getFormatSymbols(format, intlService);
|
|
@@ -409,13 +348,11 @@ export var sanitizeNumber = function sanitizeNumber(state, format, intlService)
|
|
|
409
348
|
var formattedMin = intlService.formatNumber(MIN_DECIMAL, format).replace(sanitizeRegex, '');
|
|
410
349
|
var minDecimalIndex = formattedMin.indexOf(symbols.decimal);
|
|
411
350
|
var minDecimalCount = minDecimalIndex > -1 ? formattedMin.length - minDecimalIndex - 1 : 0;
|
|
412
|
-
|
|
413
351
|
var _a = getFormatPrefixSufix(format, intlService),
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
352
|
+
positiveInfo = _a.positiveInfo,
|
|
353
|
+
negativeInfo = _a.negativeInfo,
|
|
354
|
+
zeroInfo = _a.zeroInfo,
|
|
355
|
+
oneInfo = _a.oneInfo;
|
|
419
356
|
var formatInfo = [positiveInfo, negativeInfo, zeroInfo, oneInfo];
|
|
420
357
|
var isFormatContainPrefixSuffix = formatInfo.findIndex(function (info) {
|
|
421
358
|
return info.findIndex(function (nestedInfo) {
|
|
@@ -424,24 +361,21 @@ export var sanitizeNumber = function sanitizeNumber(state, format, intlService)
|
|
|
424
361
|
}) !== 1;
|
|
425
362
|
var isDelete = currentLooseValueAsString.length > 0 && currentLooseValueAsString.length < prevLooseValueAsString.length;
|
|
426
363
|
var isPercentFormat = format && format[0] === 'p' && currentLooseValueAsString && currentLooseValueAsString.indexOf(symbols.percentSign) === -1;
|
|
427
|
-
|
|
428
364
|
if (!newState.isPaste) {
|
|
429
365
|
// 1. Empty input
|
|
430
366
|
if (currentLooseValueAsString === '') {
|
|
431
367
|
newState.eventValue = null;
|
|
432
368
|
newState.currentLooseValue = '';
|
|
433
369
|
return newState;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
|
|
370
|
+
}
|
|
371
|
+
// 2. Check is minus sign
|
|
437
372
|
if (newState.currentLooseValue === symbols.minusSign && intlService.formatNumber(-0, format) !== prevLooseValueAsString) {
|
|
438
373
|
newState.eventValue = -0;
|
|
439
374
|
newState.currentLooseValue = formatValue(newState.eventValue, format, intlService);
|
|
440
375
|
setSelection(newState, getInitialPosition(newState.currentLooseValue, symbols), newState.currentLooseValue, formatInfo);
|
|
441
376
|
return newState;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
377
|
+
}
|
|
378
|
+
// 3. Minus sign toggle
|
|
445
379
|
if (isMinusSymbolAdded(newState, symbols)) {
|
|
446
380
|
var nextValue = intlService.parseNumber(prevLooseValue, format);
|
|
447
381
|
newState.eventValue = -(nextValue !== null ? nextValue : 0);
|
|
@@ -451,103 +385,84 @@ export var sanitizeNumber = function sanitizeNumber(state, format, intlService)
|
|
|
451
385
|
setSelection(newState, newState.selectionEnd - 1 + (currentNumberStart - oldNumberStart), newState.currentLooseValue, formatInfo);
|
|
452
386
|
return newState;
|
|
453
387
|
}
|
|
454
|
-
|
|
455
388
|
if (isMinusSymbolRemoved(newState, symbols)) {
|
|
456
389
|
newState.eventValue = intlService.parseNumber(newState.currentLooseValue, format);
|
|
457
390
|
setSelection(newState, newState.selectionStart, newState.currentLooseValue, formatInfo);
|
|
458
391
|
return newState;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
392
|
+
}
|
|
393
|
+
// 4. Check is decimal symbol
|
|
462
394
|
if (newState.currentLooseValue === symbols.decimal) {
|
|
463
395
|
newState.eventValue = 0;
|
|
464
396
|
var valueCandidate = formatValue(newState.eventValue, format, intlService);
|
|
465
|
-
|
|
466
397
|
if (minDecimalCount === 0 && maxDecimalCount > 0) {
|
|
467
398
|
var currentLastNumberIndex = getLastNumberIndex(valueCandidate, DIGITS_REGEX);
|
|
468
399
|
newState.currentLooseValue = valueCandidate.substring(0, currentLastNumberIndex) + symbols.decimal + valueCandidate.substring(currentLastNumberIndex);
|
|
469
400
|
} else {
|
|
470
401
|
newState.currentLooseValue = valueCandidate;
|
|
471
402
|
}
|
|
472
|
-
|
|
473
403
|
setSelection(newState, getInitialPosition(newState.currentLooseValue, symbols) + 1, newState.currentLooseValue, formatInfo);
|
|
474
404
|
return newState;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
|
|
405
|
+
}
|
|
406
|
+
// 5. Duplicate decimal - it's possible only as trailing
|
|
478
407
|
if (isDecimalDuplicated(newState, symbols)) {
|
|
479
408
|
setInvalid(newState, format, formatInfo, intlService);
|
|
480
409
|
return newState;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
410
|
+
}
|
|
411
|
+
// 6. Percent format
|
|
484
412
|
if (isPercentFormat) {
|
|
485
413
|
newState.eventValue = intlService.parseNumber(currentLooseValueAsString, format) / 100;
|
|
486
414
|
newState.currentLooseValue = formatValue(newState.eventValue, format, intlService);
|
|
487
415
|
return newState;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
|
|
416
|
+
}
|
|
417
|
+
// 7. More than 15 numeric symbols
|
|
491
418
|
var numericSymbols = String(newState.currentLooseValue).replace(/[^\d]/g, '');
|
|
492
|
-
|
|
493
419
|
if (numericSymbols.length > MAX_PRECISION) {
|
|
494
420
|
setInvalid(newState, format, formatInfo, intlService);
|
|
495
421
|
return newState;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
422
|
+
}
|
|
423
|
+
// 8. Check prefix / suffix for modifications
|
|
499
424
|
if (sanitizedString !== currentLooseValueAsString && currentLooseValueAsString && isFormatContainPrefixSuffix) {
|
|
500
425
|
var formatInfoIndex = formatInfo.findIndex(function (_a) {
|
|
501
426
|
var prefix = _a[0],
|
|
502
|
-
|
|
427
|
+
suffix = _a[1];
|
|
503
428
|
var prefixIndex = currentLooseValueAsString.indexOf(prefix);
|
|
504
429
|
var suffixIndex = currentLooseValueAsString.indexOf(suffix);
|
|
505
430
|
var prefixFound = prefixIndex === 0;
|
|
506
431
|
var suffixFound = suffixIndex === currentLooseValueAsString.length - suffix.length;
|
|
507
432
|
var prefixGap = prefixIndex + prefix.length !== numberStart && numberStart !== -1 && currentLooseValueAsString[prefixIndex + prefix.length] !== symbols.decimal;
|
|
508
433
|
var suffixGap = suffixIndex !== numberEnd && numberEnd !== -1 && currentLooseValueAsString[suffixIndex - 1] !== symbols.decimal;
|
|
509
|
-
|
|
510
434
|
if (prefix && suffix) {
|
|
511
435
|
if (prefixGap || suffixGap) {
|
|
512
436
|
return false;
|
|
513
437
|
}
|
|
514
|
-
|
|
515
438
|
return prefixFound && suffixFound;
|
|
516
439
|
}
|
|
517
|
-
|
|
518
440
|
if (prefix) {
|
|
519
441
|
if (prefixGap) {
|
|
520
442
|
return false;
|
|
521
443
|
}
|
|
522
|
-
|
|
523
444
|
return prefixFound;
|
|
524
445
|
}
|
|
525
|
-
|
|
526
446
|
if (suffix) {
|
|
527
447
|
if (suffixGap) {
|
|
528
448
|
return false;
|
|
529
449
|
}
|
|
530
|
-
|
|
531
450
|
return suffixFound;
|
|
532
451
|
}
|
|
533
|
-
|
|
534
452
|
return false;
|
|
535
453
|
});
|
|
536
|
-
|
|
537
454
|
if (formatInfoIndex === -1) {
|
|
538
455
|
setInvalid(newState, format, formatInfo, intlService);
|
|
539
456
|
return newState;
|
|
540
457
|
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
|
|
458
|
+
}
|
|
459
|
+
// 9. Value ending on decimal separator (here as decimal might be typed inside format)
|
|
544
460
|
if (sanitizedString[sanitizedString.length - 1] === symbols.decimal && maxDecimalCount > 0) {
|
|
545
461
|
newState.eventValue = intlService.parseNumber(currentLooseValueAsString, format);
|
|
546
462
|
newState.currentLooseValue = sanitizedFormattedString;
|
|
547
463
|
return newState;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
464
|
+
}
|
|
465
|
+
// 10. prevent deleting decimal and group symbols
|
|
551
466
|
if (newState.currentLooseValue && prevLooseValue) {
|
|
552
467
|
var isSpecialSymbolDeleted = (restrictedSymbols + symbols.decimal + symbols.group).split('').findIndex(function (s) {
|
|
553
468
|
if (currentLooseValueAsString.split('').filter(function (x) {
|
|
@@ -558,33 +473,27 @@ export var sanitizeNumber = function sanitizeNumber(state, format, intlService)
|
|
|
558
473
|
if (s === symbols.decimal && getDecimalCount(prevLooseValueAsString.replace(sanitizeRegex, ''), symbols.decimal) === 0) {
|
|
559
474
|
return false;
|
|
560
475
|
}
|
|
561
|
-
|
|
562
476
|
return true;
|
|
563
477
|
}
|
|
564
|
-
|
|
565
478
|
return false;
|
|
566
479
|
}) > -1;
|
|
567
|
-
|
|
568
480
|
if (isSpecialSymbolDeleted) {
|
|
569
481
|
newState.eventValue = intlService.parseNumber(state.prevLooseValue, format);
|
|
570
482
|
newState.currentLooseValue = state.prevLooseValue;
|
|
571
483
|
return newState;
|
|
572
484
|
}
|
|
573
485
|
}
|
|
574
|
-
|
|
575
486
|
var currentDecimalCount = getDecimalCount(sanitizedString, symbols.decimal);
|
|
576
|
-
var endsOnDecimal = sanitizedString[sanitizedString.length - 1] === '0';
|
|
577
|
-
|
|
487
|
+
var endsOnDecimal = sanitizedString[sanitizedString.length - 1] === '0';
|
|
488
|
+
// 11. Deleting more decimals than allowed
|
|
578
489
|
if (isDelete && endsOnDecimal && currentDecimalCount < minDecimalCount) {
|
|
579
490
|
newState.eventValue = intlService.parseNumber(newState.currentLooseValue, format);
|
|
580
491
|
newState.currentLooseValue = formatValue(newState.eventValue, format, intlService);
|
|
581
492
|
return newState;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
493
|
+
}
|
|
494
|
+
// 12. Ending on zero OR more decimals than allowed
|
|
585
495
|
if (currentDecimalCount > 0) {
|
|
586
496
|
var valueUntillDecimal = currentLooseValueAsString.substring(0, decimalIndex);
|
|
587
|
-
|
|
588
497
|
if (endsOnDecimal && (!valueUntillDecimal || prevLooseValueAsString.indexOf(valueUntillDecimal) !== 0)) {
|
|
589
498
|
// ending on zero but typing before decimal separator
|
|
590
499
|
newState.eventValue = intlService.parseNumber(newState.currentLooseValue, format);
|
|
@@ -593,7 +502,6 @@ export var sanitizeNumber = function sanitizeNumber(state, format, intlService)
|
|
|
593
502
|
newState.currentLooseValue = nextLooseValue;
|
|
594
503
|
return newState;
|
|
595
504
|
}
|
|
596
|
-
|
|
597
505
|
if (currentDecimalCount > maxDecimalCount) {
|
|
598
506
|
// typing more symbols than format allows
|
|
599
507
|
var looseDecimalPlace = currentLooseValueAsString.indexOf(symbols.decimal);
|
|
@@ -603,14 +511,12 @@ export var sanitizeNumber = function sanitizeNumber(state, format, intlService)
|
|
|
603
511
|
setSelection(newState, newState.selectionStart, result, formatInfo);
|
|
604
512
|
return newState;
|
|
605
513
|
}
|
|
606
|
-
|
|
607
514
|
if (minDecimalCount !== maxDecimalCount && currentDecimalCount <= maxDecimalCount && endsOnDecimal) {
|
|
608
515
|
// adding trailing zeroes
|
|
609
516
|
newState.eventValue = intlService.parseNumber(newState.currentLooseValue, format);
|
|
610
517
|
newState.currentLooseValue = sanitizedFormattedString;
|
|
611
518
|
return newState;
|
|
612
519
|
}
|
|
613
|
-
|
|
614
520
|
if (currentDecimalCount < minDecimalCount) {
|
|
615
521
|
// deleting more decimals than allowed
|
|
616
522
|
newState.eventValue = intlService.parseNumber(newState.currentLooseValue, format);
|
|
@@ -618,29 +524,24 @@ export var sanitizeNumber = function sanitizeNumber(state, format, intlService)
|
|
|
618
524
|
return newState;
|
|
619
525
|
}
|
|
620
526
|
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
|
|
527
|
+
}
|
|
528
|
+
// X. All other values should be parsed
|
|
624
529
|
newState.eventValue = intlService.parseNumber(newState.currentLooseValue, format);
|
|
625
|
-
|
|
626
530
|
if (isPercentFormat) {
|
|
627
531
|
newState.eventValue = newState.eventValue / 100;
|
|
628
532
|
}
|
|
629
|
-
|
|
630
533
|
if (typeof newState.eventValue === 'number') {
|
|
631
|
-
var nextLooseValue = formatValue(newState.eventValue, format, intlService);
|
|
632
|
-
|
|
534
|
+
var nextLooseValue = formatValue(newState.eventValue, format, intlService);
|
|
535
|
+
// First digit add
|
|
633
536
|
if (currentLooseValueAsString.length === 1) {
|
|
634
537
|
setSelection(newState, getInitialPosition(nextLooseValue, symbols), nextLooseValue, formatInfo);
|
|
635
538
|
} else {
|
|
636
539
|
setSelection(newState, changeBasedSelection(currentLooseValueAsString, nextLooseValue, newState.selectionEnd, isDelete, sanitizeRegex), nextLooseValue, formatInfo);
|
|
637
540
|
}
|
|
638
|
-
|
|
639
541
|
newState.currentLooseValue = nextLooseValue;
|
|
640
542
|
} else {
|
|
641
543
|
// Case when deleting last number
|
|
642
544
|
newState.currentLooseValue = formatValue(intlService.parseNumber(sanitizedString), format, intlService);
|
|
643
545
|
}
|
|
644
|
-
|
|
645
546
|
return newState;
|
|
646
547
|
};
|
|
@@ -5,7 +5,7 @@ export var packageMetadata = {
|
|
|
5
5
|
name: '@progress/kendo-vue-inputs',
|
|
6
6
|
productName: 'Kendo UI for Vue',
|
|
7
7
|
productCodes: ['KENDOUIVUE', 'KENDOUICOMPLETE'],
|
|
8
|
-
publishDate:
|
|
8
|
+
publishDate: 1666103447,
|
|
9
9
|
version: '',
|
|
10
10
|
licensingDocsUrl: 'https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning'
|
|
11
11
|
};
|
|
@@ -11,7 +11,6 @@ import { packageMetadata } from '../package-metadata';
|
|
|
11
11
|
/**
|
|
12
12
|
* @hidden
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
var RadioButtonVue2 = {
|
|
16
15
|
name: 'KendoRadioButton',
|
|
17
16
|
props: {
|
|
@@ -60,7 +59,6 @@ var RadioButtonVue2 = {
|
|
|
60
59
|
computed: {
|
|
61
60
|
inputClassName: function inputClassName() {
|
|
62
61
|
var _a;
|
|
63
|
-
|
|
64
62
|
return _a = {
|
|
65
63
|
'k-radio': true
|
|
66
64
|
}, _a["k-radio-".concat(kendoThemeMaps.sizeMap[this.$props.size])] = this.$props.size, _a['k-invalid'] = this.$props.valid === false, _a[this.$props.className] = this.$props.className, _a;
|
|
@@ -102,19 +100,18 @@ var RadioButtonVue2 = {
|
|
|
102
100
|
var h = gh || createElement;
|
|
103
101
|
var defaultSlot = getDefaultSlots(this);
|
|
104
102
|
var _a = this.$props,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
103
|
+
ariaDescribedBy = _a.ariaDescribedBy,
|
|
104
|
+
checked = _a.checked,
|
|
105
|
+
disabled = _a.disabled,
|
|
106
|
+
id = _a.id,
|
|
107
|
+
label = _a.label,
|
|
108
|
+
labelRender = _a.labelRender,
|
|
109
|
+
labelPlacement = _a.labelPlacement,
|
|
110
|
+
name = _a.name,
|
|
111
|
+
tabIndex = _a.tabIndex,
|
|
112
|
+
value = _a.value,
|
|
113
|
+
tag = _a.tag;
|
|
116
114
|
var renderedLabel = label;
|
|
117
|
-
|
|
118
115
|
if (labelRender) {
|
|
119
116
|
var renderTemplate = labelRender ? templateRendering.call(this, labelRender, getListeners.call(this)) : null;
|
|
120
117
|
renderedLabel = getTemplate.call(this, {
|
|
@@ -122,7 +119,6 @@ var RadioButtonVue2 = {
|
|
|
122
119
|
template: renderTemplate
|
|
123
120
|
});
|
|
124
121
|
}
|
|
125
|
-
|
|
126
122
|
var content = getTemplate.call(this, {
|
|
127
123
|
h: h,
|
|
128
124
|
template: this.$props.content
|
|
@@ -190,6 +186,5 @@ var RadioButtonVue2 = {
|
|
|
190
186
|
/**
|
|
191
187
|
* @hidden
|
|
192
188
|
*/
|
|
193
|
-
|
|
194
189
|
var RadioButton = RadioButtonVue2;
|
|
195
190
|
export { RadioButton, RadioButtonVue2 };
|