@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.
@@ -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
- if (mask.partMap[i].pattern.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
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 month = parseToInt(this.getInvalidDatePartValue(symbol) + JS_MONTH_OFFSET).toString();
168
- var formattedMonth = padZero(Math.abs(mask.partMap[i].pattern.length - month.length)) + month;
169
- partiallyInvalidText += formattedMonth;
170
- i += Math.max(0, formattedMonth.length - 1);
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
- partiallyInvalidText += this.getInvalidDatePartValue(symbol);
180
- i += Math.max(0, this.getInvalidDatePartValue(symbol).toString().length - 1);
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 currentInvalidDatePartValue = 0;
296
- if (!this.autoCorrectParts) {
297
- var isMonth = symbol === "M";
298
- var isDay = symbol === "d" || symbol === "E";
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 invalidDatePart = invalidDateParts[symbol];
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
- hour += offset;
322
- break;
323
- case 'm':
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) && this.getExisting(symbol)) {
337
- // do not cycle months
338
- this.setExisting(symbol, false);
339
- return;
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) {
@@ -682,6 +631,13 @@ var DateObject = /** @class */ (function () {
682
631
  if (originalFormat.length < rawInputValue.length) {
683
632
  datePartText += currentChar;
684
633
  }
634
+ else if (!isDeleting && originalFormat.length > rawInputValue.length) {
635
+ var lengthDiff = originalFormat.length - rawInputValue.length;
636
+ var trimmedDatePartText = datePartText.substring(0, datePartText.length - lengthDiff);
637
+ if (trimmedDatePartText && trimmedDatePartText.length > 0) {
638
+ datePartText = trimmedDatePartText;
639
+ }
640
+ }
685
641
  if (datePartText.length > segmentLength) {
686
642
  return extend(parseResult, { value: null, switchToNext: false });
687
643
  }
@@ -719,6 +675,13 @@ var DateObject = /** @class */ (function () {
719
675
  if (originalFormat.length < rawInputValue.length) {
720
676
  datePartText += currentChar;
721
677
  }
678
+ else if (!isDeleting && originalFormat.length > rawInputValue.length) {
679
+ var lengthDiff = originalFormat.length - rawInputValue.length;
680
+ var trimmedDatePartText = datePartText.substring(0, datePartText.length - lengthDiff);
681
+ if (trimmedDatePartText && trimmedDatePartText.length > 0) {
682
+ datePartText = trimmedDatePartText;
683
+ }
684
+ }
722
685
  }
723
686
  }
724
687
  else {
@@ -764,14 +727,19 @@ var DateObject = /** @class */ (function () {
764
727
  if (!tryParse) {
765
728
  break;
766
729
  }
767
- if (!this.autoCorrectParts) {
768
- tryParse = false;
769
- }
770
730
  var middle = resetSegmentValue ?
771
731
  currentChar :
772
732
  isInCaretMode ?
773
733
  datePartText :
774
734
  (current.substring(i) + currentChar);
735
+ if (!this.autoCorrectParts) {
736
+ tryParse = false;
737
+ if (!isInCaretMode) {
738
+ // try to make an exact match as there will be only 1 attempt
739
+ middle = unpadZero(middle);
740
+ middle = padZero(segmentLength - middle.length) + middle;
741
+ }
742
+ }
775
743
  if (isInCaretMode) {
776
744
  // try to make an exact match as there will be only 1 attempt
777
745
  tryParse = false;
@@ -789,6 +757,7 @@ var DateObject = /** @class */ (function () {
789
757
  // to "Thursday, February 1, 2022 3:04:05 AM"
790
758
  // as "EEEE, February..." is not parsable
791
759
  parsedDate = this.intl.parseDate(basePrefix + middle + baseSuffix, this.format, this.localeId);
760
+ datePartText = middle;
792
761
  }
793
762
  var isCurrentCharParsable = !isNaN(parseInt(currentChar, 10)) || (isInCaretMode && isDeleting && currentChar === "");
794
763
  if (!parsedDate && !isNaN(middleNumber) && isCurrentCharParsable) {
@@ -826,6 +795,26 @@ var DateObject = /** @class */ (function () {
826
795
  }
827
796
  this._value = parsedDate;
828
797
  this.setExisting(symbol, true);
798
+ if (isInCaretMode && switchToNext) {
799
+ if (symbol === "M") {
800
+ if (segmentLength <= MONTH_PART_WITH_WORDS_THRESHOLD) {
801
+ var datePartValue = parseToInt(datePartText);
802
+ if (datePartValue >= 2) {
803
+ switchToNext = true;
804
+ }
805
+ else {
806
+ switchToNext = false;
807
+ }
808
+ }
809
+ }
810
+ else {
811
+ switchToNext = switchToNext ?
812
+ hasFixedFormat ?
813
+ datePartText.length === segmentLength :
814
+ datePartText.length > segmentLength :
815
+ switchToNext;
816
+ }
817
+ }
829
818
  return extend(parseResult, { value: this.value, switchToNext: switchToNext });
830
819
  }
831
820
  }
@@ -853,9 +842,6 @@ var DateObject = /** @class */ (function () {
853
842
  }
854
843
  if (!this.autoCorrectParts) {
855
844
  this.setExisting(symbol, false);
856
- // todo check if string is better
857
- // const padPrefix = padZero(Math.abs(current.length - datePartText.length));
858
- // const paddedDatePartText = padPrefix + datePartText;
859
845
  var datePartValue = void 0;
860
846
  var textToParse = isInCaretMode ? datePartText : current;
861
847
  var parsedValue = parseToInt(textToParse);
@@ -1037,42 +1023,80 @@ var DateObject = /** @class */ (function () {
1037
1023
  var resultText = '';
1038
1024
  var resultFormat = '';
1039
1025
  var format = mask.symbols;
1040
- var _loop_1 = function (formatSymbolIndex) {
1041
- if (this_1.knownParts.indexOf(format[formatSymbolIndex]) === -1 || this_1.getExisting(format[formatSymbolIndex])) {
1042
- resultText = text[formatSymbolIndex] + resultText;
1026
+ var processTextSymbolsEnded = false;
1027
+ var ignoreFormatSymbolsCount = 0;
1028
+ var formattedDates = this.getFormattedInvalidDates(format);
1029
+ for (var formatSymbolIndex = format.length - 1; formatSymbolIndex >= 0; formatSymbolIndex--) {
1030
+ var partsForSegment = this.getPartsForSegment(mask, formatSymbolIndex);
1031
+ if (this.knownParts.indexOf(format[formatSymbolIndex]) === -1 || this.getExisting(format[formatSymbolIndex])) {
1032
+ if (this.autoCorrectParts) {
1033
+ resultText = text[formatSymbolIndex] + resultText;
1034
+ }
1035
+ else {
1036
+ if (text.length !== format.length) {
1037
+ if (processTextSymbolsEnded) {
1038
+ resultText = text[formatSymbolIndex] + resultText;
1039
+ }
1040
+ else if (ignoreFormatSymbolsCount > 0) {
1041
+ resultText = text[formatSymbolIndex] + resultText;
1042
+ ignoreFormatSymbolsCount--;
1043
+ if (ignoreFormatSymbolsCount <= 0) {
1044
+ processTextSymbolsEnded = true;
1045
+ }
1046
+ }
1047
+ else {
1048
+ resultText = (text[formatSymbolIndex + text.length - format.length] || "") + resultText;
1049
+ }
1050
+ }
1051
+ else {
1052
+ resultText = text[formatSymbolIndex] + resultText;
1053
+ }
1054
+ }
1043
1055
  resultFormat = format[formatSymbolIndex] + resultFormat;
1044
1056
  }
1045
1057
  else {
1046
1058
  var symbol = format[formatSymbolIndex];
1047
- while (formatSymbolIndex >= 0 && symbol === format[formatSymbolIndex]) {
1048
- formatSymbolIndex--;
1059
+ var formatSymbolIndexModifier = 0;
1060
+ if (this.autoCorrectParts || (!this.autoCorrectParts && !this.getInvalidDatePartValue(symbol))) {
1061
+ while (formatSymbolIndex >= 0 && symbol === format[formatSymbolIndex]) {
1062
+ formatSymbolIndex--;
1063
+ }
1064
+ formatSymbolIndex++;
1049
1065
  }
1050
- formatSymbolIndex++;
1051
- if (this_1.leadingZero && this_1.leadingZero[symbol]) {
1066
+ if (this.leadingZero && this.leadingZero[symbol]) {
1052
1067
  resultText = '0' + resultText;
1053
1068
  }
1054
1069
  else {
1055
- if (!this_1.autoCorrectParts && this_1.getInvalidDatePartValue(symbol)) {
1056
- // use mask.symbols instead of mask.partMap
1057
- var part_1 = mask.partMap[formatSymbolIndex];
1058
- var pattern = mask.partMap.filter(function (x) { return x.type === part_1.type && x.pattern === part_1.pattern; });
1059
- var segmentText = text.substr(formatSymbolIndex, pattern.length);
1060
- resultText = segmentText + resultText;
1070
+ if (!this.autoCorrectParts && this.getInvalidDatePartValue(symbol)) {
1071
+ var datePartText = this.getInvalidDatePartValue(symbol).toString();
1072
+ if (symbol === "M") {
1073
+ datePartText = (parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
1074
+ if (partsForSegment.length > MONTH_PART_WITH_WORDS_THRESHOLD) {
1075
+ resultText = formattedDates[symbol][formatSymbolIndex] + resultText;
1076
+ }
1077
+ else {
1078
+ datePartText = (parseToInt(this.getInvalidDatePartValue(symbol)) + JS_MONTH_OFFSET).toString();
1079
+ resultText = datePartText + resultText;
1080
+ ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
1081
+ }
1082
+ }
1083
+ else {
1084
+ resultText = datePartText + resultText;
1085
+ formatSymbolIndexModifier = datePartText.length - 1;
1086
+ ignoreFormatSymbolsCount = datePartText.length - partsForSegment.length;
1087
+ }
1061
1088
  }
1062
1089
  else {
1063
- resultText = this_1.dateFieldName(mask.partMap[formatSymbolIndex]) + resultText;
1090
+ resultText = this.dateFieldName(mask.partMap[formatSymbolIndex]) + resultText;
1064
1091
  }
1065
1092
  }
1066
1093
  while (resultFormat.length < resultText.length) {
1067
1094
  resultFormat = format[formatSymbolIndex] + resultFormat;
1068
1095
  }
1096
+ if (formatSymbolIndexModifier !== 0) {
1097
+ formatSymbolIndex = (formatSymbolIndex - formatSymbolIndexModifier) + (text.length - format.length);
1098
+ }
1069
1099
  }
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
1100
  }
1077
1101
  return { text: resultText, format: resultFormat };
1078
1102
  };
@@ -1239,6 +1263,32 @@ var DateObject = /** @class */ (function () {
1239
1263
  DateObject.prototype.markDatePartsAsExisting = function () {
1240
1264
  this.modifyExisting(true);
1241
1265
  };
1266
+ /**
1267
+ * @hidden
1268
+ */
1269
+ DateObject.prototype.getPartsForSegment = function (mask, partIndex) {
1270
+ var segmentPart = mask.partMap[partIndex];
1271
+ var partsForSegment = [];
1272
+ for (var maskPartIndex = partIndex; maskPartIndex < mask.partMap.length; maskPartIndex++) {
1273
+ var part = mask.partMap[maskPartIndex];
1274
+ if (segmentPart.type === part.type && segmentPart.pattern === part.pattern) {
1275
+ partsForSegment.push(part);
1276
+ }
1277
+ else {
1278
+ break;
1279
+ }
1280
+ }
1281
+ for (var maskPartIndex = partIndex - 1; maskPartIndex >= 0; maskPartIndex--) {
1282
+ var part = mask.partMap[maskPartIndex];
1283
+ if (segmentPart.type === part.type && segmentPart.pattern === part.pattern) {
1284
+ partsForSegment.unshift(part);
1285
+ }
1286
+ else {
1287
+ break;
1288
+ }
1289
+ }
1290
+ return partsForSegment;
1291
+ };
1242
1292
  return DateObject;
1243
1293
  }());
1244
1294
  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.destroy();
159
- this.init(this.element, options);
159
+ this.unbindEvents();
160
+ this.init(this.element, this.options);
160
161
  }
161
162
  };
162
163
  /**
@@ -368,24 +369,13 @@ var DateInput = /** @class */ (function (_super) {
368
369
  }
369
370
  }
370
371
  else if (hasCaret) {
371
- if (this.options.format.length !== this.currentFormat.length) {
372
- if (hasDateValueChanged && isPresent(this.dateObject.value)) {
373
- var elementValueLength = this.elementValue.length;
374
- this.forceUpdate();
375
- var selectionOffset = this.elementValue.length - elementValueLength;
376
- this.setSelection({
377
- start: currentSelection.start + selectionOffset,
378
- end: currentSelection.start + selectionOffset
379
- });
372
+ if (hasDateValueChanged && isPresent(this.dateObject.getValue())) {
373
+ if (switchPart) {
374
+ this.switchDateSegment(1);
380
375
  }
381
376
  }
382
377
  else {
383
- if (hasDateValueChanged) {
384
- if (lastParseResultHasNoValue) {
385
- this.restorePreviousInputEventState();
386
- }
387
- }
388
- else {
378
+ if (lastParseResultHasNoValue) {
389
379
  this.restorePreviousInputEventState();
390
380
  }
391
381
  }
@@ -681,6 +671,14 @@ var DateInput = /** @class */ (function (_super) {
681
671
  if (start < 0) {
682
672
  start = 0;
683
673
  }
674
+ if (!this.options.autoCorrectParts && this.currentFormat.length !== this.currentText.length) {
675
+ if (this.currentFormat.length < this.currentText.length) {
676
+ end += this.currentText.length - this.currentFormat.length;
677
+ }
678
+ else {
679
+ end = Math.max(0, end - (this.currentFormat.length - this.currentText.length));
680
+ }
681
+ }
684
682
  return { start: start, end: end };
685
683
  };
686
684
  /**
@@ -704,24 +702,37 @@ var DateInput = /** @class */ (function (_super) {
704
702
  var selection = this.selection;
705
703
  if (this.isInCaretMode()) {
706
704
  var start = selection.start;
707
- var closestNonSeparatorSymbol = this.currentFormat[start];
708
- for (var i = start; i >= 0; i--) {
709
- closestNonSeparatorSymbol = this.currentFormat[i];
710
- if (closestNonSeparatorSymbol !== Constants.formatSeparator) {
711
- start = i;
712
- break;
705
+ var currentSymbol = this.currentFormat[start - (this.elementValue.length - this.currentFormat.length)] ||
706
+ this.currentFormat[start];
707
+ var symbol = "";
708
+ var symbolCandidate = "";
709
+ if (offset < 0) {
710
+ for (var i = start + offset; i >= 0; i--) {
711
+ symbolCandidate = this.currentFormat[i];
712
+ if (symbolCandidate !== Constants.formatSeparator &&
713
+ symbolCandidate !== currentSymbol) {
714
+ start = i;
715
+ symbol = symbolCandidate;
716
+ break;
717
+ }
713
718
  }
714
719
  }
715
- var symbol = void 0;
716
- for (var i = start; i < this.currentFormat.length; i++) {
717
- symbol = this.currentFormat[i];
718
- if (symbol !== Constants.formatSeparator) {
719
- break;
720
+ else {
721
+ for (var i = start + offset; i < this.currentFormat.length; i++) {
722
+ symbolCandidate = this.currentFormat[i];
723
+ if (symbolCandidate !== Constants.formatSeparator &&
724
+ symbolCandidate !== currentSymbol) {
725
+ start = i;
726
+ symbol = symbolCandidate;
727
+ break;
728
+ }
720
729
  }
721
730
  }
722
731
  if (symbol) {
723
732
  this.forceUpdate();
724
733
  this.setSelection(this.selectionBySymbol(symbol));
734
+ this.interactionMode = DateInputInteractionMode.Selection;
735
+ return;
725
736
  }
726
737
  }
727
738
  var _a = this.selection, selectionStart = _a.start, selectionEnd = _a.end;