@progress/kendo-dateinputs-common 0.2.0-dev.202301101148 → 0.2.0-dev.202301130811
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-dateinputs-common.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/dateobject.js +176 -142
- package/dist/es/dateinput/dateinput.js +39 -22
- package/dist/es2015/common/dateobject.js +172 -132
- package/dist/es2015/dateinput/dateinput.js +39 -22
- package/dist/npm/common/dateobject.d.ts +4 -0
- package/dist/npm/common/dateobject.js +176 -142
- package/dist/npm/dateinput/dateinput.js +39 -22
- package/dist/systemjs/kendo-dateinputs-common.js +1 -1
- package/global-setup.js +3 -3
- package/package.json +1 -1
|
@@ -158,16 +158,18 @@ var DateObject = /** @class */ (function () {
|
|
|
158
158
|
partiallyInvalidText += text[i];
|
|
159
159
|
}
|
|
160
160
|
else if (this.getInvalidDatePartValue(symbol)) {
|
|
161
|
+
var partsForSegment = this.getPartsForSegment(mask, i);
|
|
161
162
|
if (symbol === "M") {
|
|
162
|
-
|
|
163
|
+
var datePartText = (parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
|
|
164
|
+
if (partsForSegment.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
163
165
|
partiallyInvalidText += formattedDates[symbol][i];
|
|
164
166
|
}
|
|
165
167
|
else {
|
|
166
168
|
if (this.getInvalidDatePartValue(symbol)) {
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
i +=
|
|
169
|
+
var formattedDatePart = padZero(partsForSegment.length - datePartText.length) + datePartText;
|
|
170
|
+
partiallyInvalidText += formattedDatePart;
|
|
171
|
+
// add -1 as the first character in the segment is at index i
|
|
172
|
+
i += partsForSegment.length - 1;
|
|
171
173
|
}
|
|
172
174
|
else {
|
|
173
175
|
partiallyInvalidText += formattedDates[symbol][i];
|
|
@@ -176,8 +178,11 @@ var DateObject = /** @class */ (function () {
|
|
|
176
178
|
}
|
|
177
179
|
else {
|
|
178
180
|
if (this.getInvalidDatePartValue(symbol)) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
var datePartText = this.getInvalidDatePartValue(symbol).toString();
|
|
182
|
+
var formattedDatePart = padZero(partsForSegment.length - datePartText.length) + datePartText;
|
|
183
|
+
partiallyInvalidText += formattedDatePart;
|
|
184
|
+
// add -1 as the first character in the segment is at index i
|
|
185
|
+
i += partsForSegment.length - 1;
|
|
181
186
|
}
|
|
182
187
|
else {
|
|
183
188
|
partiallyInvalidText += formattedDates[symbol][i];
|
|
@@ -288,16 +293,18 @@ var DateObject = /** @class */ (function () {
|
|
|
288
293
|
}
|
|
289
294
|
};
|
|
290
295
|
DateObject.prototype.modifyPart = function (symbol, offset) {
|
|
296
|
+
if (!isPresent(symbol) || !isPresent(offset) || offset === 0) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
291
299
|
var newValue = cloneDate(this.value);
|
|
292
|
-
var originalValue = cloneDate(this.value);
|
|
293
300
|
var timeModified = false;
|
|
294
301
|
var invalidDateFound;
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
302
|
+
var isMonth = symbol === "M";
|
|
303
|
+
var isDay = symbol === "d" || symbol === "E";
|
|
304
|
+
var symbolExists = this.getExisting(symbol);
|
|
305
|
+
if (!this.autoCorrectParts && (isDay || isMonth)) {
|
|
299
306
|
var invalidDateParts = this._partiallyInvalidDate.invalidDateParts || {};
|
|
300
|
-
var
|
|
307
|
+
var invalidDatePartValue = this.getInvalidDatePartValue(symbol);
|
|
301
308
|
var year = invalidDateParts.y.value || newValue.getFullYear();
|
|
302
309
|
var month = invalidDateParts.M.value || newValue.getMonth();
|
|
303
310
|
var day = invalidDateParts.d.value || invalidDateParts.E.value || newValue.getDate();
|
|
@@ -316,33 +323,61 @@ var DateObject = /** @class */ (function () {
|
|
|
316
323
|
case 'E':
|
|
317
324
|
day += offset;
|
|
318
325
|
break;
|
|
319
|
-
case 'h':
|
|
320
|
-
case 'H':
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
case '
|
|
324
|
-
minutes += offset;
|
|
325
|
-
break;
|
|
326
|
-
case 's':
|
|
327
|
-
seconds += offset;
|
|
328
|
-
break;
|
|
329
|
-
case 'S':
|
|
330
|
-
milliseconds += offset;
|
|
331
|
-
break;
|
|
332
|
-
// case 'a': newValue.setHours(newValue.getHours() + (12 * offset)); timeModified = true; break;
|
|
326
|
+
// case 'h':
|
|
327
|
+
// case 'H': hour += offset; break;
|
|
328
|
+
// case 'm': minutes += offset; break;
|
|
329
|
+
// case 's': seconds += offset; break;
|
|
330
|
+
// case 'S': milliseconds += offset; break;
|
|
333
331
|
default: break;
|
|
334
332
|
}
|
|
335
333
|
if (symbol === "M") {
|
|
336
|
-
if ((month < 0 || month > 11)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
334
|
+
if ((month < 0 || month > 11)) {
|
|
335
|
+
if (symbolExists) {
|
|
336
|
+
this.setExisting(symbol, false);
|
|
337
|
+
this.resetInvalidDateSymbol(symbol);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (!symbolExists) {
|
|
342
|
+
if (month < 0) {
|
|
343
|
+
month = clamp(11 + ((month % 11) + 1), 0, 11);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
var monthValue = isPresent(invalidDatePartValue) ?
|
|
347
|
+
month :
|
|
348
|
+
((offset - JS_MONTH_OFFSET) % 12);
|
|
349
|
+
month = clamp(monthValue, 0, 11);
|
|
350
|
+
}
|
|
351
|
+
month = clamp(month, 0, 11);
|
|
352
|
+
}
|
|
353
|
+
month = clamp(month, 0, 11);
|
|
354
|
+
}
|
|
355
|
+
else if (symbol === "d") {
|
|
356
|
+
if (symbolExists) {
|
|
357
|
+
if (day <= 0 || day > 31) {
|
|
358
|
+
this.setExisting(symbol, false);
|
|
359
|
+
this.resetInvalidDateSymbol(symbol);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
else if (!symbolExists) {
|
|
364
|
+
if (isPresent(invalidDatePartValue)) {
|
|
365
|
+
if (day <= 0 || day > 31) {
|
|
366
|
+
this.setExisting(symbol, false);
|
|
367
|
+
this.resetInvalidDateSymbol(symbol);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (offset < 0) {
|
|
372
|
+
var dayValue = isPresent(invalidDatePartValue) ? day : 1 + (31 - Math.abs(offset % 31));
|
|
373
|
+
day = clamp(dayValue, 1, 31);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
var dayValue = isPresent(invalidDatePartValue) ? day : offset % 31;
|
|
377
|
+
day = clamp(dayValue, 1, 31);
|
|
378
|
+
}
|
|
379
|
+
day = clamp(day, 1, 31);
|
|
340
380
|
}
|
|
341
|
-
// const mask = this.dateFormatString(this.value, this.format);
|
|
342
|
-
// const monthPart = mask.partMap.filter(x => x.type === "month");
|
|
343
|
-
// if (monthPart && monthPart[0] && monthPart[0].pattern.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
344
|
-
month = (12 + month) % 12;
|
|
345
|
-
// }
|
|
346
381
|
}
|
|
347
382
|
var dateCandidate = createDate(year, month, day, hour, minutes, seconds, milliseconds);
|
|
348
383
|
var newValueCandidate = isMonth || isDay ?
|
|
@@ -439,92 +474,6 @@ var DateObject = /** @class */ (function () {
|
|
|
439
474
|
this.setExisting(symbol, false);
|
|
440
475
|
}
|
|
441
476
|
}
|
|
442
|
-
else {
|
|
443
|
-
// this.modifyDateSymbol()
|
|
444
|
-
switch (symbol) {
|
|
445
|
-
case 'y':
|
|
446
|
-
newValue.setFullYear(newValue.getFullYear() + offset);
|
|
447
|
-
break;
|
|
448
|
-
case 'M':
|
|
449
|
-
newValue = addMonths(this.value, offset);
|
|
450
|
-
break;
|
|
451
|
-
case 'd':
|
|
452
|
-
case 'E':
|
|
453
|
-
newValue.setDate(newValue.getDate() + offset);
|
|
454
|
-
break;
|
|
455
|
-
case 'h':
|
|
456
|
-
case 'H':
|
|
457
|
-
newValue.setHours(newValue.getHours() + offset);
|
|
458
|
-
timeModified = true;
|
|
459
|
-
break;
|
|
460
|
-
case 'm':
|
|
461
|
-
newValue.setMinutes(newValue.getMinutes() + offset);
|
|
462
|
-
timeModified = true;
|
|
463
|
-
break;
|
|
464
|
-
case 's':
|
|
465
|
-
newValue.setSeconds(newValue.getSeconds() + offset);
|
|
466
|
-
timeModified = true;
|
|
467
|
-
break;
|
|
468
|
-
case "S":
|
|
469
|
-
newValue.setMilliseconds(newValue.getMilliseconds() + offset);
|
|
470
|
-
break;
|
|
471
|
-
case 'a':
|
|
472
|
-
newValue.setHours(newValue.getHours() + (12 * offset));
|
|
473
|
-
timeModified = true;
|
|
474
|
-
break;
|
|
475
|
-
default: break;
|
|
476
|
-
}
|
|
477
|
-
invalidDateFound = true;
|
|
478
|
-
if (invalidDatePart && invalidDatePart.value) {
|
|
479
|
-
currentInvalidDatePartValue = parseToInt(invalidDatePart.value);
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
if (!isPresent(invalidDatePart.value)) {
|
|
483
|
-
newValue = cloneDate(originalValue);
|
|
484
|
-
// this.modifyDateSymbol()
|
|
485
|
-
switch (symbol) {
|
|
486
|
-
case 'y':
|
|
487
|
-
currentInvalidDatePartValue = originalValue.getFullYear();
|
|
488
|
-
break;
|
|
489
|
-
case 'M':
|
|
490
|
-
currentInvalidDatePartValue = originalValue.getMonth();
|
|
491
|
-
break;
|
|
492
|
-
case 'd':
|
|
493
|
-
case 'E':
|
|
494
|
-
currentInvalidDatePartValue = originalValue.getDate();
|
|
495
|
-
break;
|
|
496
|
-
case 'h':
|
|
497
|
-
case 'H':
|
|
498
|
-
currentInvalidDatePartValue = originalValue.getHours();
|
|
499
|
-
break;
|
|
500
|
-
case 'm':
|
|
501
|
-
currentInvalidDatePartValue = originalValue.getMinutes();
|
|
502
|
-
break;
|
|
503
|
-
case 's':
|
|
504
|
-
currentInvalidDatePartValue = originalValue.getSeconds();
|
|
505
|
-
break;
|
|
506
|
-
case 'S':
|
|
507
|
-
currentInvalidDatePartValue = originalValue.getMilliseconds();
|
|
508
|
-
break;
|
|
509
|
-
// case 'a': newValue.setHours(newValue.getHours() + (12 * offset)); timeModified = true; break;
|
|
510
|
-
default: break;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
var invalidDatePartValue = Math.max(0, currentInvalidDatePartValue + offset);
|
|
517
|
-
if (symbol !== "y") {
|
|
518
|
-
invalidDatePartValue = clamp(currentInvalidDatePartValue + offset, 0, 99);
|
|
519
|
-
}
|
|
520
|
-
this.setInvalidDatePart(symbol, {
|
|
521
|
-
value: invalidDatePartValue,
|
|
522
|
-
date: cloneDate(newValue),
|
|
523
|
-
startDateOffset: (this.getInvalidDatePart(symbol).startDateOffset || 0) + offset,
|
|
524
|
-
startDate: cloneDate(this.value)
|
|
525
|
-
});
|
|
526
|
-
this.setExisting(symbol, false);
|
|
527
|
-
}
|
|
528
477
|
}
|
|
529
478
|
else {
|
|
530
479
|
switch (symbol) {
|
|
@@ -789,6 +738,7 @@ var DateObject = /** @class */ (function () {
|
|
|
789
738
|
// to "Thursday, February 1, 2022 3:04:05 AM"
|
|
790
739
|
// as "EEEE, February..." is not parsable
|
|
791
740
|
parsedDate = this.intl.parseDate(basePrefix + middle + baseSuffix, this.format, this.localeId);
|
|
741
|
+
datePartText = middle;
|
|
792
742
|
}
|
|
793
743
|
var isCurrentCharParsable = !isNaN(parseInt(currentChar, 10)) || (isInCaretMode && isDeleting && currentChar === "");
|
|
794
744
|
if (!parsedDate && !isNaN(middleNumber) && isCurrentCharParsable) {
|
|
@@ -826,6 +776,26 @@ var DateObject = /** @class */ (function () {
|
|
|
826
776
|
}
|
|
827
777
|
this._value = parsedDate;
|
|
828
778
|
this.setExisting(symbol, true);
|
|
779
|
+
if (isInCaretMode && switchToNext) {
|
|
780
|
+
if (symbol === "M") {
|
|
781
|
+
if (segmentLength <= MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
782
|
+
var datePartValue = parseToInt(datePartText);
|
|
783
|
+
if (datePartValue >= 2) {
|
|
784
|
+
switchToNext = true;
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
switchToNext = false;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
switchToNext = switchToNext ?
|
|
793
|
+
hasFixedFormat ?
|
|
794
|
+
datePartText.length === segmentLength :
|
|
795
|
+
datePartText.length > segmentLength :
|
|
796
|
+
switchToNext;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
829
799
|
return extend(parseResult, { value: this.value, switchToNext: switchToNext });
|
|
830
800
|
}
|
|
831
801
|
}
|
|
@@ -1037,42 +1007,80 @@ var DateObject = /** @class */ (function () {
|
|
|
1037
1007
|
var resultText = '';
|
|
1038
1008
|
var resultFormat = '';
|
|
1039
1009
|
var format = mask.symbols;
|
|
1040
|
-
var
|
|
1041
|
-
|
|
1042
|
-
|
|
1010
|
+
var processTextSymbolsEnded = false;
|
|
1011
|
+
var ignoreFormatSymbolsCount = 0;
|
|
1012
|
+
var formattedDates = this.getFormattedInvalidDates(format);
|
|
1013
|
+
for (var formatSymbolIndex = format.length - 1; formatSymbolIndex >= 0; formatSymbolIndex--) {
|
|
1014
|
+
var partsForSegment = this.getPartsForSegment(mask, formatSymbolIndex);
|
|
1015
|
+
if (this.knownParts.indexOf(format[formatSymbolIndex]) === -1 || this.getExisting(format[formatSymbolIndex])) {
|
|
1016
|
+
if (this.autoCorrectParts) {
|
|
1017
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
if (text.length !== format.length) {
|
|
1021
|
+
if (processTextSymbolsEnded) {
|
|
1022
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1023
|
+
}
|
|
1024
|
+
else if (ignoreFormatSymbolsCount > 0) {
|
|
1025
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1026
|
+
ignoreFormatSymbolsCount--;
|
|
1027
|
+
if (ignoreFormatSymbolsCount <= 0) {
|
|
1028
|
+
processTextSymbolsEnded = true;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
resultText = (text[formatSymbolIndex + text.length - format.length] || "") + resultText;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
else {
|
|
1036
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1043
1039
|
resultFormat = format[formatSymbolIndex] + resultFormat;
|
|
1044
1040
|
}
|
|
1045
1041
|
else {
|
|
1046
1042
|
var symbol = format[formatSymbolIndex];
|
|
1047
|
-
|
|
1048
|
-
|
|
1043
|
+
var formatSymbolIndexModifier = 0;
|
|
1044
|
+
if (this.autoCorrectParts || (!this.autoCorrectParts && !this.getInvalidDatePartValue(symbol))) {
|
|
1045
|
+
while (formatSymbolIndex >= 0 && symbol === format[formatSymbolIndex]) {
|
|
1046
|
+
formatSymbolIndex--;
|
|
1047
|
+
}
|
|
1048
|
+
formatSymbolIndex++;
|
|
1049
1049
|
}
|
|
1050
|
-
|
|
1051
|
-
if (this_1.leadingZero && this_1.leadingZero[symbol]) {
|
|
1050
|
+
if (this.leadingZero && this.leadingZero[symbol]) {
|
|
1052
1051
|
resultText = '0' + resultText;
|
|
1053
1052
|
}
|
|
1054
1053
|
else {
|
|
1055
|
-
if (!
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1054
|
+
if (!this.autoCorrectParts && this.getInvalidDatePartValue(symbol)) {
|
|
1055
|
+
var datePartText = this.getInvalidDatePartValue(symbol).toString();
|
|
1056
|
+
if (symbol === "M") {
|
|
1057
|
+
datePartText = (parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
|
|
1058
|
+
if (partsForSegment.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
1059
|
+
resultText = formattedDates[symbol][formatSymbolIndex] + resultText;
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
datePartText = (parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
|
|
1063
|
+
resultText = datePartText + resultText;
|
|
1064
|
+
ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
resultText = datePartText + resultText;
|
|
1069
|
+
formatSymbolIndexModifier = datePartText.length - 1;
|
|
1070
|
+
ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
|
|
1071
|
+
}
|
|
1061
1072
|
}
|
|
1062
1073
|
else {
|
|
1063
|
-
resultText =
|
|
1074
|
+
resultText = this.dateFieldName(mask.partMap[formatSymbolIndex]) + resultText;
|
|
1064
1075
|
}
|
|
1065
1076
|
}
|
|
1066
1077
|
while (resultFormat.length < resultText.length) {
|
|
1067
1078
|
resultFormat = format[formatSymbolIndex] + resultFormat;
|
|
1068
1079
|
}
|
|
1080
|
+
if (formatSymbolIndexModifier !== 0) {
|
|
1081
|
+
formatSymbolIndex = (formatSymbolIndex - formatSymbolIndexModifier) + (text.length - format.length);
|
|
1082
|
+
}
|
|
1069
1083
|
}
|
|
1070
|
-
out_formatSymbolIndex_1 = formatSymbolIndex;
|
|
1071
|
-
};
|
|
1072
|
-
var this_1 = this, out_formatSymbolIndex_1;
|
|
1073
|
-
for (var formatSymbolIndex = format.length - 1; formatSymbolIndex >= 0; formatSymbolIndex--) {
|
|
1074
|
-
_loop_1(formatSymbolIndex);
|
|
1075
|
-
formatSymbolIndex = out_formatSymbolIndex_1;
|
|
1076
1084
|
}
|
|
1077
1085
|
return { text: resultText, format: resultFormat };
|
|
1078
1086
|
};
|
|
@@ -1239,6 +1247,32 @@ var DateObject = /** @class */ (function () {
|
|
|
1239
1247
|
DateObject.prototype.markDatePartsAsExisting = function () {
|
|
1240
1248
|
this.modifyExisting(true);
|
|
1241
1249
|
};
|
|
1250
|
+
/**
|
|
1251
|
+
* @hidden
|
|
1252
|
+
*/
|
|
1253
|
+
DateObject.prototype.getPartsForSegment = function (mask, partIndex) {
|
|
1254
|
+
var segmentPart = mask.partMap[partIndex];
|
|
1255
|
+
var partsForSegment = [];
|
|
1256
|
+
for (var maskPartIndex = partIndex; maskPartIndex < mask.partMap.length; maskPartIndex++) {
|
|
1257
|
+
var part = mask.partMap[maskPartIndex];
|
|
1258
|
+
if (segmentPart.type === part.type && segmentPart.pattern === part.pattern) {
|
|
1259
|
+
partsForSegment.push(part);
|
|
1260
|
+
}
|
|
1261
|
+
else {
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
for (var maskPartIndex = partIndex - 1; maskPartIndex >= 0; maskPartIndex--) {
|
|
1266
|
+
var part = mask.partMap[maskPartIndex];
|
|
1267
|
+
if (segmentPart.type === part.type && segmentPart.pattern === part.pattern) {
|
|
1268
|
+
partsForSegment.unshift(part);
|
|
1269
|
+
}
|
|
1270
|
+
else {
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return partsForSegment;
|
|
1275
|
+
};
|
|
1242
1276
|
return DateObject;
|
|
1243
1277
|
}());
|
|
1244
1278
|
export { DateObject };
|
|
@@ -91,7 +91,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
91
91
|
dateValue = null;
|
|
92
92
|
}
|
|
93
93
|
this.element = element;
|
|
94
|
-
this.element._kendoWidget = this;
|
|
94
|
+
// this.element._kendoWidget = this;
|
|
95
95
|
this.options = extend({}, defaultDateInputOptions, options);
|
|
96
96
|
this.intl = this.options.intlService;
|
|
97
97
|
this.formatPlaceholder = this.options.formatPlaceholder ? this.options.formatPlaceholder : 'formatPattern';
|
|
@@ -100,6 +100,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
100
100
|
this.setTextAndFormat();
|
|
101
101
|
this.bindEvents();
|
|
102
102
|
this.resetSegmentValue = true;
|
|
103
|
+
this.interactionMode = DateInputInteractionMode.None;
|
|
103
104
|
this.forceUpdate();
|
|
104
105
|
};
|
|
105
106
|
DateInput.prototype.destroy = function () {
|
|
@@ -155,8 +156,8 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
155
156
|
if (refresh === void 0) { refresh = false; }
|
|
156
157
|
this.options = extend(this.options, options);
|
|
157
158
|
if (refresh) {
|
|
158
|
-
this.
|
|
159
|
-
this.init(this.element, options);
|
|
159
|
+
this.unbindEvents();
|
|
160
|
+
this.init(this.element, this.options);
|
|
160
161
|
}
|
|
161
162
|
};
|
|
162
163
|
/**
|
|
@@ -369,14 +370,10 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
369
370
|
}
|
|
370
371
|
else if (hasCaret) {
|
|
371
372
|
if (this.options.format.length !== this.currentFormat.length) {
|
|
372
|
-
if (hasDateValueChanged && isPresent(this.dateObject.
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
this.setSelection({
|
|
377
|
-
start: currentSelection.start + selectionOffset,
|
|
378
|
-
end: currentSelection.start + selectionOffset
|
|
379
|
-
});
|
|
373
|
+
if (hasDateValueChanged && isPresent(this.dateObject.getValue())) {
|
|
374
|
+
if (switchPart) {
|
|
375
|
+
this.switchDateSegment(1);
|
|
376
|
+
}
|
|
380
377
|
}
|
|
381
378
|
}
|
|
382
379
|
else {
|
|
@@ -681,6 +678,14 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
681
678
|
if (start < 0) {
|
|
682
679
|
start = 0;
|
|
683
680
|
}
|
|
681
|
+
if (!this.options.autoCorrectParts && this.currentFormat.length !== this.currentText.length) {
|
|
682
|
+
if (this.currentFormat.length < this.currentText.length) {
|
|
683
|
+
end += this.currentText.length - this.currentFormat.length;
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
686
|
+
end = Math.max(0, end - (this.currentFormat.length - this.currentText.length));
|
|
687
|
+
}
|
|
688
|
+
}
|
|
684
689
|
return { start: start, end: end };
|
|
685
690
|
};
|
|
686
691
|
/**
|
|
@@ -704,24 +709,36 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
704
709
|
var selection = this.selection;
|
|
705
710
|
if (this.isInCaretMode()) {
|
|
706
711
|
var start = selection.start;
|
|
707
|
-
var
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
712
|
+
var currentSymbol = this.currentFormat[start - (this.elementValue.length - this.currentFormat.length)];
|
|
713
|
+
var symbol = "";
|
|
714
|
+
var symbolCandidate = "";
|
|
715
|
+
if (offset < 0) {
|
|
716
|
+
for (var i = 0; i < start + offset; i++) {
|
|
717
|
+
symbolCandidate = this.currentFormat[i];
|
|
718
|
+
if (symbolCandidate !== Constants.formatSeparator &&
|
|
719
|
+
symbolCandidate !== currentSymbol) {
|
|
720
|
+
start = i;
|
|
721
|
+
symbol = symbolCandidate;
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
713
724
|
}
|
|
714
725
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
726
|
+
else {
|
|
727
|
+
for (var i = start + offset; i < this.currentFormat.length; i++) {
|
|
728
|
+
symbolCandidate = this.currentFormat[i];
|
|
729
|
+
if (symbolCandidate !== Constants.formatSeparator &&
|
|
730
|
+
symbolCandidate !== currentSymbol) {
|
|
731
|
+
start = i;
|
|
732
|
+
symbol = symbolCandidate;
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
720
735
|
}
|
|
721
736
|
}
|
|
722
737
|
if (symbol) {
|
|
723
738
|
this.forceUpdate();
|
|
724
739
|
this.setSelection(this.selectionBySymbol(symbol));
|
|
740
|
+
this.interactionMode = DateInputInteractionMode.Selection;
|
|
741
|
+
return;
|
|
725
742
|
}
|
|
726
743
|
}
|
|
727
744
|
var _a = this.selection, selectionStart = _a.start, selectionEnd = _a.end;
|