@progress/kendo-dateinputs-common 0.2.0-dev.202301101148 → 0.2.0-dev.202301131210
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 +198 -148
- package/dist/es/dateinput/dateinput.js +40 -29
- package/dist/es2015/common/dateobject.js +194 -138
- package/dist/es2015/dateinput/dateinput.js +40 -29
- package/dist/npm/common/dateobject.d.ts +4 -0
- package/dist/npm/common/dateobject.js +198 -148
- package/dist/npm/dateinput/dateinput.js +40 -29
- package/dist/systemjs/kendo-dateinputs-common.js +1 -1
- package/global-setup.js +3 -3
- package/package.json +1 -1
|
@@ -160,16 +160,18 @@ var DateObject = /** @class */ (function () {
|
|
|
160
160
|
partiallyInvalidText += text[i];
|
|
161
161
|
}
|
|
162
162
|
else if (this.getInvalidDatePartValue(symbol)) {
|
|
163
|
+
var partsForSegment = this.getPartsForSegment(mask, i);
|
|
163
164
|
if (symbol === "M") {
|
|
164
|
-
|
|
165
|
+
var datePartText = (utils_2.parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
|
|
166
|
+
if (partsForSegment.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
165
167
|
partiallyInvalidText += formattedDates[symbol][i];
|
|
166
168
|
}
|
|
167
169
|
else {
|
|
168
170
|
if (this.getInvalidDatePartValue(symbol)) {
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
i +=
|
|
171
|
+
var formattedDatePart = utils_1.padZero(partsForSegment.length - datePartText.length) + datePartText;
|
|
172
|
+
partiallyInvalidText += formattedDatePart;
|
|
173
|
+
// add -1 as the first character in the segment is at index i
|
|
174
|
+
i += partsForSegment.length - 1;
|
|
173
175
|
}
|
|
174
176
|
else {
|
|
175
177
|
partiallyInvalidText += formattedDates[symbol][i];
|
|
@@ -178,8 +180,11 @@ var DateObject = /** @class */ (function () {
|
|
|
178
180
|
}
|
|
179
181
|
else {
|
|
180
182
|
if (this.getInvalidDatePartValue(symbol)) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
var datePartText = this.getInvalidDatePartValue(symbol).toString();
|
|
184
|
+
var formattedDatePart = utils_1.padZero(partsForSegment.length - datePartText.length) + datePartText;
|
|
185
|
+
partiallyInvalidText += formattedDatePart;
|
|
186
|
+
// add -1 as the first character in the segment is at index i
|
|
187
|
+
i += partsForSegment.length - 1;
|
|
183
188
|
}
|
|
184
189
|
else {
|
|
185
190
|
partiallyInvalidText += formattedDates[symbol][i];
|
|
@@ -290,16 +295,18 @@ var DateObject = /** @class */ (function () {
|
|
|
290
295
|
}
|
|
291
296
|
};
|
|
292
297
|
DateObject.prototype.modifyPart = function (symbol, offset) {
|
|
298
|
+
if (!utils_2.isPresent(symbol) || !utils_2.isPresent(offset) || offset === 0) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
293
301
|
var newValue = kendo_date_math_1.cloneDate(this.value);
|
|
294
|
-
var originalValue = kendo_date_math_1.cloneDate(this.value);
|
|
295
302
|
var timeModified = false;
|
|
296
303
|
var invalidDateFound;
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
var isMonth = symbol === "M";
|
|
305
|
+
var isDay = symbol === "d" || symbol === "E";
|
|
306
|
+
var symbolExists = this.getExisting(symbol);
|
|
307
|
+
if (!this.autoCorrectParts && (isDay || isMonth)) {
|
|
301
308
|
var invalidDateParts = this._partiallyInvalidDate.invalidDateParts || {};
|
|
302
|
-
var
|
|
309
|
+
var invalidDatePartValue = this.getInvalidDatePartValue(symbol);
|
|
303
310
|
var year = invalidDateParts.y.value || newValue.getFullYear();
|
|
304
311
|
var month = invalidDateParts.M.value || newValue.getMonth();
|
|
305
312
|
var day = invalidDateParts.d.value || invalidDateParts.E.value || newValue.getDate();
|
|
@@ -318,33 +325,61 @@ var DateObject = /** @class */ (function () {
|
|
|
318
325
|
case 'E':
|
|
319
326
|
day += offset;
|
|
320
327
|
break;
|
|
321
|
-
case 'h':
|
|
322
|
-
case 'H':
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
case '
|
|
326
|
-
minutes += offset;
|
|
327
|
-
break;
|
|
328
|
-
case 's':
|
|
329
|
-
seconds += offset;
|
|
330
|
-
break;
|
|
331
|
-
case 'S':
|
|
332
|
-
milliseconds += offset;
|
|
333
|
-
break;
|
|
334
|
-
// case 'a': newValue.setHours(newValue.getHours() + (12 * offset)); timeModified = true; break;
|
|
328
|
+
// case 'h':
|
|
329
|
+
// case 'H': hour += offset; break;
|
|
330
|
+
// case 'm': minutes += offset; break;
|
|
331
|
+
// case 's': seconds += offset; break;
|
|
332
|
+
// case 'S': milliseconds += offset; break;
|
|
335
333
|
default: break;
|
|
336
334
|
}
|
|
337
335
|
if (symbol === "M") {
|
|
338
|
-
if ((month < 0 || month > 11)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
336
|
+
if ((month < 0 || month > 11)) {
|
|
337
|
+
if (symbolExists) {
|
|
338
|
+
this.setExisting(symbol, false);
|
|
339
|
+
this.resetInvalidDateSymbol(symbol);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (!symbolExists) {
|
|
344
|
+
if (month < 0) {
|
|
345
|
+
month = utils_2.clamp(11 + ((month % 11) + 1), 0, 11);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
var monthValue = utils_2.isPresent(invalidDatePartValue) ?
|
|
349
|
+
month :
|
|
350
|
+
((offset - JS_MONTH_OFFSET) % 12);
|
|
351
|
+
month = utils_2.clamp(monthValue, 0, 11);
|
|
352
|
+
}
|
|
353
|
+
month = utils_2.clamp(month, 0, 11);
|
|
354
|
+
}
|
|
355
|
+
month = utils_2.clamp(month, 0, 11);
|
|
356
|
+
}
|
|
357
|
+
else if (symbol === "d") {
|
|
358
|
+
if (symbolExists) {
|
|
359
|
+
if (day <= 0 || day > 31) {
|
|
360
|
+
this.setExisting(symbol, false);
|
|
361
|
+
this.resetInvalidDateSymbol(symbol);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
else if (!symbolExists) {
|
|
366
|
+
if (utils_2.isPresent(invalidDatePartValue)) {
|
|
367
|
+
if (day <= 0 || day > 31) {
|
|
368
|
+
this.setExisting(symbol, false);
|
|
369
|
+
this.resetInvalidDateSymbol(symbol);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (offset < 0) {
|
|
374
|
+
var dayValue = utils_2.isPresent(invalidDatePartValue) ? day : 1 + (31 - Math.abs(offset % 31));
|
|
375
|
+
day = utils_2.clamp(dayValue, 1, 31);
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
var dayValue = utils_2.isPresent(invalidDatePartValue) ? day : offset % 31;
|
|
379
|
+
day = utils_2.clamp(dayValue, 1, 31);
|
|
380
|
+
}
|
|
381
|
+
day = utils_2.clamp(day, 1, 31);
|
|
342
382
|
}
|
|
343
|
-
// const mask = this.dateFormatString(this.value, this.format);
|
|
344
|
-
// const monthPart = mask.partMap.filter(x => x.type === "month");
|
|
345
|
-
// if (monthPart && monthPart[0] && monthPart[0].pattern.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
346
|
-
month = (12 + month) % 12;
|
|
347
|
-
// }
|
|
348
383
|
}
|
|
349
384
|
var dateCandidate = kendo_date_math_1.createDate(year, month, day, hour, minutes, seconds, milliseconds);
|
|
350
385
|
var newValueCandidate = isMonth || isDay ?
|
|
@@ -441,92 +476,6 @@ var DateObject = /** @class */ (function () {
|
|
|
441
476
|
this.setExisting(symbol, false);
|
|
442
477
|
}
|
|
443
478
|
}
|
|
444
|
-
else {
|
|
445
|
-
// this.modifyDateSymbol()
|
|
446
|
-
switch (symbol) {
|
|
447
|
-
case 'y':
|
|
448
|
-
newValue.setFullYear(newValue.getFullYear() + offset);
|
|
449
|
-
break;
|
|
450
|
-
case 'M':
|
|
451
|
-
newValue = kendo_date_math_1.addMonths(this.value, offset);
|
|
452
|
-
break;
|
|
453
|
-
case 'd':
|
|
454
|
-
case 'E':
|
|
455
|
-
newValue.setDate(newValue.getDate() + offset);
|
|
456
|
-
break;
|
|
457
|
-
case 'h':
|
|
458
|
-
case 'H':
|
|
459
|
-
newValue.setHours(newValue.getHours() + offset);
|
|
460
|
-
timeModified = true;
|
|
461
|
-
break;
|
|
462
|
-
case 'm':
|
|
463
|
-
newValue.setMinutes(newValue.getMinutes() + offset);
|
|
464
|
-
timeModified = true;
|
|
465
|
-
break;
|
|
466
|
-
case 's':
|
|
467
|
-
newValue.setSeconds(newValue.getSeconds() + offset);
|
|
468
|
-
timeModified = true;
|
|
469
|
-
break;
|
|
470
|
-
case "S":
|
|
471
|
-
newValue.setMilliseconds(newValue.getMilliseconds() + offset);
|
|
472
|
-
break;
|
|
473
|
-
case 'a':
|
|
474
|
-
newValue.setHours(newValue.getHours() + (12 * offset));
|
|
475
|
-
timeModified = true;
|
|
476
|
-
break;
|
|
477
|
-
default: break;
|
|
478
|
-
}
|
|
479
|
-
invalidDateFound = true;
|
|
480
|
-
if (invalidDatePart && invalidDatePart.value) {
|
|
481
|
-
currentInvalidDatePartValue = utils_2.parseToInt(invalidDatePart.value);
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
if (!utils_2.isPresent(invalidDatePart.value)) {
|
|
485
|
-
newValue = kendo_date_math_1.cloneDate(originalValue);
|
|
486
|
-
// this.modifyDateSymbol()
|
|
487
|
-
switch (symbol) {
|
|
488
|
-
case 'y':
|
|
489
|
-
currentInvalidDatePartValue = originalValue.getFullYear();
|
|
490
|
-
break;
|
|
491
|
-
case 'M':
|
|
492
|
-
currentInvalidDatePartValue = originalValue.getMonth();
|
|
493
|
-
break;
|
|
494
|
-
case 'd':
|
|
495
|
-
case 'E':
|
|
496
|
-
currentInvalidDatePartValue = originalValue.getDate();
|
|
497
|
-
break;
|
|
498
|
-
case 'h':
|
|
499
|
-
case 'H':
|
|
500
|
-
currentInvalidDatePartValue = originalValue.getHours();
|
|
501
|
-
break;
|
|
502
|
-
case 'm':
|
|
503
|
-
currentInvalidDatePartValue = originalValue.getMinutes();
|
|
504
|
-
break;
|
|
505
|
-
case 's':
|
|
506
|
-
currentInvalidDatePartValue = originalValue.getSeconds();
|
|
507
|
-
break;
|
|
508
|
-
case 'S':
|
|
509
|
-
currentInvalidDatePartValue = originalValue.getMilliseconds();
|
|
510
|
-
break;
|
|
511
|
-
// case 'a': newValue.setHours(newValue.getHours() + (12 * offset)); timeModified = true; break;
|
|
512
|
-
default: break;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
var invalidDatePartValue = Math.max(0, currentInvalidDatePartValue + offset);
|
|
519
|
-
if (symbol !== "y") {
|
|
520
|
-
invalidDatePartValue = utils_2.clamp(currentInvalidDatePartValue + offset, 0, 99);
|
|
521
|
-
}
|
|
522
|
-
this.setInvalidDatePart(symbol, {
|
|
523
|
-
value: invalidDatePartValue,
|
|
524
|
-
date: kendo_date_math_1.cloneDate(newValue),
|
|
525
|
-
startDateOffset: (this.getInvalidDatePart(symbol).startDateOffset || 0) + offset,
|
|
526
|
-
startDate: kendo_date_math_1.cloneDate(this.value)
|
|
527
|
-
});
|
|
528
|
-
this.setExisting(symbol, false);
|
|
529
|
-
}
|
|
530
479
|
}
|
|
531
480
|
else {
|
|
532
481
|
switch (symbol) {
|
|
@@ -684,6 +633,13 @@ var DateObject = /** @class */ (function () {
|
|
|
684
633
|
if (originalFormat.length < rawInputValue.length) {
|
|
685
634
|
datePartText += currentChar;
|
|
686
635
|
}
|
|
636
|
+
else if (!isDeleting && originalFormat.length > rawInputValue.length) {
|
|
637
|
+
var lengthDiff = originalFormat.length - rawInputValue.length;
|
|
638
|
+
var trimmedDatePartText = datePartText.substring(0, datePartText.length - lengthDiff);
|
|
639
|
+
if (trimmedDatePartText && trimmedDatePartText.length > 0) {
|
|
640
|
+
datePartText = trimmedDatePartText;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
687
643
|
if (datePartText.length > segmentLength) {
|
|
688
644
|
return utils_2.extend(parseResult, { value: null, switchToNext: false });
|
|
689
645
|
}
|
|
@@ -721,6 +677,13 @@ var DateObject = /** @class */ (function () {
|
|
|
721
677
|
if (originalFormat.length < rawInputValue.length) {
|
|
722
678
|
datePartText += currentChar;
|
|
723
679
|
}
|
|
680
|
+
else if (!isDeleting && originalFormat.length > rawInputValue.length) {
|
|
681
|
+
var lengthDiff = originalFormat.length - rawInputValue.length;
|
|
682
|
+
var trimmedDatePartText = datePartText.substring(0, datePartText.length - lengthDiff);
|
|
683
|
+
if (trimmedDatePartText && trimmedDatePartText.length > 0) {
|
|
684
|
+
datePartText = trimmedDatePartText;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
724
687
|
}
|
|
725
688
|
}
|
|
726
689
|
else {
|
|
@@ -766,14 +729,19 @@ var DateObject = /** @class */ (function () {
|
|
|
766
729
|
if (!tryParse) {
|
|
767
730
|
break;
|
|
768
731
|
}
|
|
769
|
-
if (!this.autoCorrectParts) {
|
|
770
|
-
tryParse = false;
|
|
771
|
-
}
|
|
772
732
|
var middle = resetSegmentValue ?
|
|
773
733
|
currentChar :
|
|
774
734
|
isInCaretMode ?
|
|
775
735
|
datePartText :
|
|
776
736
|
(current.substring(i) + currentChar);
|
|
737
|
+
if (!this.autoCorrectParts) {
|
|
738
|
+
tryParse = false;
|
|
739
|
+
if (!isInCaretMode) {
|
|
740
|
+
// try to make an exact match as there will be only 1 attempt
|
|
741
|
+
middle = utils_1.unpadZero(middle);
|
|
742
|
+
middle = utils_1.padZero(segmentLength - middle.length) + middle;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
777
745
|
if (isInCaretMode) {
|
|
778
746
|
// try to make an exact match as there will be only 1 attempt
|
|
779
747
|
tryParse = false;
|
|
@@ -791,6 +759,7 @@ var DateObject = /** @class */ (function () {
|
|
|
791
759
|
// to "Thursday, February 1, 2022 3:04:05 AM"
|
|
792
760
|
// as "EEEE, February..." is not parsable
|
|
793
761
|
parsedDate = this.intl.parseDate(basePrefix + middle + baseSuffix, this.format, this.localeId);
|
|
762
|
+
datePartText = middle;
|
|
794
763
|
}
|
|
795
764
|
var isCurrentCharParsable = !isNaN(parseInt(currentChar, 10)) || (isInCaretMode && isDeleting && currentChar === "");
|
|
796
765
|
if (!parsedDate && !isNaN(middleNumber) && isCurrentCharParsable) {
|
|
@@ -828,6 +797,26 @@ var DateObject = /** @class */ (function () {
|
|
|
828
797
|
}
|
|
829
798
|
this._value = parsedDate;
|
|
830
799
|
this.setExisting(symbol, true);
|
|
800
|
+
if (isInCaretMode && switchToNext) {
|
|
801
|
+
if (symbol === "M") {
|
|
802
|
+
if (segmentLength <= MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
803
|
+
var datePartValue = utils_2.parseToInt(datePartText);
|
|
804
|
+
if (datePartValue >= 2) {
|
|
805
|
+
switchToNext = true;
|
|
806
|
+
}
|
|
807
|
+
else {
|
|
808
|
+
switchToNext = false;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
switchToNext = switchToNext ?
|
|
814
|
+
hasFixedFormat ?
|
|
815
|
+
datePartText.length === segmentLength :
|
|
816
|
+
datePartText.length > segmentLength :
|
|
817
|
+
switchToNext;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
831
820
|
return utils_2.extend(parseResult, { value: this.value, switchToNext: switchToNext });
|
|
832
821
|
}
|
|
833
822
|
}
|
|
@@ -855,9 +844,6 @@ var DateObject = /** @class */ (function () {
|
|
|
855
844
|
}
|
|
856
845
|
if (!this.autoCorrectParts) {
|
|
857
846
|
this.setExisting(symbol, false);
|
|
858
|
-
// todo check if string is better
|
|
859
|
-
// const padPrefix = padZero(Math.abs(current.length - datePartText.length));
|
|
860
|
-
// const paddedDatePartText = padPrefix + datePartText;
|
|
861
847
|
var datePartValue = void 0;
|
|
862
848
|
var textToParse = isInCaretMode ? datePartText : current;
|
|
863
849
|
var parsedValue = utils_2.parseToInt(textToParse);
|
|
@@ -1039,42 +1025,80 @@ var DateObject = /** @class */ (function () {
|
|
|
1039
1025
|
var resultText = '';
|
|
1040
1026
|
var resultFormat = '';
|
|
1041
1027
|
var format = mask.symbols;
|
|
1042
|
-
var
|
|
1043
|
-
|
|
1044
|
-
|
|
1028
|
+
var processTextSymbolsEnded = false;
|
|
1029
|
+
var ignoreFormatSymbolsCount = 0;
|
|
1030
|
+
var formattedDates = this.getFormattedInvalidDates(format);
|
|
1031
|
+
for (var formatSymbolIndex = format.length - 1; formatSymbolIndex >= 0; formatSymbolIndex--) {
|
|
1032
|
+
var partsForSegment = this.getPartsForSegment(mask, formatSymbolIndex);
|
|
1033
|
+
if (this.knownParts.indexOf(format[formatSymbolIndex]) === -1 || this.getExisting(format[formatSymbolIndex])) {
|
|
1034
|
+
if (this.autoCorrectParts) {
|
|
1035
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
if (text.length !== format.length) {
|
|
1039
|
+
if (processTextSymbolsEnded) {
|
|
1040
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1041
|
+
}
|
|
1042
|
+
else if (ignoreFormatSymbolsCount > 0) {
|
|
1043
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1044
|
+
ignoreFormatSymbolsCount--;
|
|
1045
|
+
if (ignoreFormatSymbolsCount <= 0) {
|
|
1046
|
+
processTextSymbolsEnded = true;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
resultText = (text[formatSymbolIndex + text.length - format.length] || "") + resultText;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
resultText = text[formatSymbolIndex] + resultText;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1045
1057
|
resultFormat = format[formatSymbolIndex] + resultFormat;
|
|
1046
1058
|
}
|
|
1047
1059
|
else {
|
|
1048
1060
|
var symbol = format[formatSymbolIndex];
|
|
1049
|
-
|
|
1050
|
-
|
|
1061
|
+
var formatSymbolIndexModifier = 0;
|
|
1062
|
+
if (this.autoCorrectParts || (!this.autoCorrectParts && !this.getInvalidDatePartValue(symbol))) {
|
|
1063
|
+
while (formatSymbolIndex >= 0 && symbol === format[formatSymbolIndex]) {
|
|
1064
|
+
formatSymbolIndex--;
|
|
1065
|
+
}
|
|
1066
|
+
formatSymbolIndex++;
|
|
1051
1067
|
}
|
|
1052
|
-
|
|
1053
|
-
if (this_1.leadingZero && this_1.leadingZero[symbol]) {
|
|
1068
|
+
if (this.leadingZero && this.leadingZero[symbol]) {
|
|
1054
1069
|
resultText = '0' + resultText;
|
|
1055
1070
|
}
|
|
1056
1071
|
else {
|
|
1057
|
-
if (!
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1072
|
+
if (!this.autoCorrectParts && this.getInvalidDatePartValue(symbol)) {
|
|
1073
|
+
var datePartText = this.getInvalidDatePartValue(symbol).toString();
|
|
1074
|
+
if (symbol === "M") {
|
|
1075
|
+
datePartText = (utils_2.parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
|
|
1076
|
+
if (partsForSegment.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
|
|
1077
|
+
resultText = formattedDates[symbol][formatSymbolIndex] + resultText;
|
|
1078
|
+
}
|
|
1079
|
+
else {
|
|
1080
|
+
datePartText = (utils_2.parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
|
|
1081
|
+
resultText = datePartText + resultText;
|
|
1082
|
+
ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
resultText = datePartText + resultText;
|
|
1087
|
+
formatSymbolIndexModifier = datePartText.length - 1;
|
|
1088
|
+
ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
|
|
1089
|
+
}
|
|
1063
1090
|
}
|
|
1064
1091
|
else {
|
|
1065
|
-
resultText =
|
|
1092
|
+
resultText = this.dateFieldName(mask.partMap[formatSymbolIndex]) + resultText;
|
|
1066
1093
|
}
|
|
1067
1094
|
}
|
|
1068
1095
|
while (resultFormat.length < resultText.length) {
|
|
1069
1096
|
resultFormat = format[formatSymbolIndex] + resultFormat;
|
|
1070
1097
|
}
|
|
1098
|
+
if (formatSymbolIndexModifier !== 0) {
|
|
1099
|
+
formatSymbolIndex = (formatSymbolIndex - formatSymbolIndexModifier) + (text.length - format.length);
|
|
1100
|
+
}
|
|
1071
1101
|
}
|
|
1072
|
-
out_formatSymbolIndex_1 = formatSymbolIndex;
|
|
1073
|
-
};
|
|
1074
|
-
var this_1 = this, out_formatSymbolIndex_1;
|
|
1075
|
-
for (var formatSymbolIndex = format.length - 1; formatSymbolIndex >= 0; formatSymbolIndex--) {
|
|
1076
|
-
_loop_1(formatSymbolIndex);
|
|
1077
|
-
formatSymbolIndex = out_formatSymbolIndex_1;
|
|
1078
1102
|
}
|
|
1079
1103
|
return { text: resultText, format: resultFormat };
|
|
1080
1104
|
};
|
|
@@ -1241,6 +1265,32 @@ var DateObject = /** @class */ (function () {
|
|
|
1241
1265
|
DateObject.prototype.markDatePartsAsExisting = function () {
|
|
1242
1266
|
this.modifyExisting(true);
|
|
1243
1267
|
};
|
|
1268
|
+
/**
|
|
1269
|
+
* @hidden
|
|
1270
|
+
*/
|
|
1271
|
+
DateObject.prototype.getPartsForSegment = function (mask, partIndex) {
|
|
1272
|
+
var segmentPart = mask.partMap[partIndex];
|
|
1273
|
+
var partsForSegment = [];
|
|
1274
|
+
for (var maskPartIndex = partIndex; maskPartIndex < mask.partMap.length; maskPartIndex++) {
|
|
1275
|
+
var part = mask.partMap[maskPartIndex];
|
|
1276
|
+
if (segmentPart.type === part.type && segmentPart.pattern === part.pattern) {
|
|
1277
|
+
partsForSegment.push(part);
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
break;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
for (var maskPartIndex = partIndex - 1; maskPartIndex >= 0; maskPartIndex--) {
|
|
1284
|
+
var part = mask.partMap[maskPartIndex];
|
|
1285
|
+
if (segmentPart.type === part.type && segmentPart.pattern === part.pattern) {
|
|
1286
|
+
partsForSegment.unshift(part);
|
|
1287
|
+
}
|
|
1288
|
+
else {
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return partsForSegment;
|
|
1293
|
+
};
|
|
1244
1294
|
return DateObject;
|
|
1245
1295
|
}());
|
|
1246
1296
|
exports.DateObject = DateObject;
|
|
@@ -93,7 +93,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
93
93
|
dateValue = null;
|
|
94
94
|
}
|
|
95
95
|
this.element = element;
|
|
96
|
-
this.element._kendoWidget = this;
|
|
96
|
+
// this.element._kendoWidget = this;
|
|
97
97
|
this.options = utils_2.extend({}, defaultDateInputOptions, options);
|
|
98
98
|
this.intl = this.options.intlService;
|
|
99
99
|
this.formatPlaceholder = this.options.formatPlaceholder ? this.options.formatPlaceholder : 'formatPattern';
|
|
@@ -102,6 +102,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
102
102
|
this.setTextAndFormat();
|
|
103
103
|
this.bindEvents();
|
|
104
104
|
this.resetSegmentValue = true;
|
|
105
|
+
this.interactionMode = interaction_mode_1.DateInputInteractionMode.None;
|
|
105
106
|
this.forceUpdate();
|
|
106
107
|
};
|
|
107
108
|
DateInput.prototype.destroy = function () {
|
|
@@ -157,8 +158,8 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
157
158
|
if (refresh === void 0) { refresh = false; }
|
|
158
159
|
this.options = utils_2.extend(this.options, options);
|
|
159
160
|
if (refresh) {
|
|
160
|
-
this.
|
|
161
|
-
this.init(this.element, options);
|
|
161
|
+
this.unbindEvents();
|
|
162
|
+
this.init(this.element, this.options);
|
|
162
163
|
}
|
|
163
164
|
};
|
|
164
165
|
/**
|
|
@@ -370,24 +371,13 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
370
371
|
}
|
|
371
372
|
}
|
|
372
373
|
else if (hasCaret) {
|
|
373
|
-
if (
|
|
374
|
-
if (
|
|
375
|
-
|
|
376
|
-
this.forceUpdate();
|
|
377
|
-
var selectionOffset = this.elementValue.length - elementValueLength;
|
|
378
|
-
this.setSelection({
|
|
379
|
-
start: currentSelection.start + selectionOffset,
|
|
380
|
-
end: currentSelection.start + selectionOffset
|
|
381
|
-
});
|
|
374
|
+
if (hasDateValueChanged && utils_2.isPresent(this.dateObject.getValue())) {
|
|
375
|
+
if (switchPart) {
|
|
376
|
+
this.switchDateSegment(1);
|
|
382
377
|
}
|
|
383
378
|
}
|
|
384
379
|
else {
|
|
385
|
-
if (
|
|
386
|
-
if (lastParseResultHasNoValue) {
|
|
387
|
-
this.restorePreviousInputEventState();
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
380
|
+
if (lastParseResultHasNoValue) {
|
|
391
381
|
this.restorePreviousInputEventState();
|
|
392
382
|
}
|
|
393
383
|
}
|
|
@@ -683,6 +673,14 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
683
673
|
if (start < 0) {
|
|
684
674
|
start = 0;
|
|
685
675
|
}
|
|
676
|
+
if (!this.options.autoCorrectParts && this.currentFormat.length !== this.currentText.length) {
|
|
677
|
+
if (this.currentFormat.length < this.currentText.length) {
|
|
678
|
+
end += this.currentText.length - this.currentFormat.length;
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
end = Math.max(0, end - (this.currentFormat.length - this.currentText.length));
|
|
682
|
+
}
|
|
683
|
+
}
|
|
686
684
|
return { start: start, end: end };
|
|
687
685
|
};
|
|
688
686
|
/**
|
|
@@ -706,24 +704,37 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
706
704
|
var selection = this.selection;
|
|
707
705
|
if (this.isInCaretMode()) {
|
|
708
706
|
var start = selection.start;
|
|
709
|
-
var
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
707
|
+
var currentSymbol = this.currentFormat[start - (this.elementValue.length - this.currentFormat.length)] ||
|
|
708
|
+
this.currentFormat[start];
|
|
709
|
+
var symbol = "";
|
|
710
|
+
var symbolCandidate = "";
|
|
711
|
+
if (offset < 0) {
|
|
712
|
+
for (var i = start + offset; i >= 0; i--) {
|
|
713
|
+
symbolCandidate = this.currentFormat[i];
|
|
714
|
+
if (symbolCandidate !== constants_1.Constants.formatSeparator &&
|
|
715
|
+
symbolCandidate !== currentSymbol) {
|
|
716
|
+
start = i;
|
|
717
|
+
symbol = symbolCandidate;
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
715
720
|
}
|
|
716
721
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
+
else {
|
|
723
|
+
for (var i = start + offset; i < this.currentFormat.length; i++) {
|
|
724
|
+
symbolCandidate = this.currentFormat[i];
|
|
725
|
+
if (symbolCandidate !== constants_1.Constants.formatSeparator &&
|
|
726
|
+
symbolCandidate !== currentSymbol) {
|
|
727
|
+
start = i;
|
|
728
|
+
symbol = symbolCandidate;
|
|
729
|
+
break;
|
|
730
|
+
}
|
|
722
731
|
}
|
|
723
732
|
}
|
|
724
733
|
if (symbol) {
|
|
725
734
|
this.forceUpdate();
|
|
726
735
|
this.setSelection(this.selectionBySymbol(symbol));
|
|
736
|
+
this.interactionMode = interaction_mode_1.DateInputInteractionMode.Selection;
|
|
737
|
+
return;
|
|
727
738
|
}
|
|
728
739
|
}
|
|
729
740
|
var _a = this.selection, selectionStart = _a.start, selectionEnd = _a.end;
|