@progress/kendo-dateinputs-common 0.2.0-dev.202301131210 → 0.2.0-dev.202301171717
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 +279 -74
- package/dist/es/dateinput/dateinput.js +65 -10
- package/dist/es2015/common/dateobject.js +279 -75
- package/dist/es2015/dateinput/dateinput.js +66 -11
- package/dist/npm/common/dateobject.d.ts +8 -0
- package/dist/npm/common/dateobject.js +279 -74
- package/dist/npm/dateinput/dateinput.d.ts +1 -0
- package/dist/npm/dateinput/dateinput.js +65 -10
- package/dist/systemjs/kendo-dateinputs-common.js +1 -1
- package/package.json +1 -1
|
@@ -31,6 +31,7 @@ var CHANGE = "change";
|
|
|
31
31
|
var defaultDateInputOptions = {
|
|
32
32
|
format: "d",
|
|
33
33
|
allowNulls: false,
|
|
34
|
+
hasPlaceholder: false,
|
|
34
35
|
placeholder: null,
|
|
35
36
|
cycleTime: true,
|
|
36
37
|
locale: null,
|
|
@@ -303,6 +304,24 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
303
304
|
isInCaretMode: hasCaret,
|
|
304
305
|
keyEvent: this.keyDownEvent
|
|
305
306
|
});
|
|
307
|
+
var currentFormatChar = this.formatStateOnKeyDown.format[this.formatStateOnKeyDown.selectionStart] || "";
|
|
308
|
+
if (this.options.allowCaretMode && hasCaret && this.currentFormat.length !== this.elementValue.length) {
|
|
309
|
+
if (currentFormatChar &&
|
|
310
|
+
currentFormatChar.length > 0 &&
|
|
311
|
+
currentFormatChar !== Constants.formatSeparator) {
|
|
312
|
+
if (!diff || diff.length === 0) {
|
|
313
|
+
diff = [];
|
|
314
|
+
diff[0][0] = currentFormatChar;
|
|
315
|
+
diff[0][1] = e.data || "";
|
|
316
|
+
}
|
|
317
|
+
else if (diff[0] && diff[0][0] !== Constants.formatSeparator) {
|
|
318
|
+
if (diff[0][0] !== currentFormatChar) {
|
|
319
|
+
diff[0][0] = currentFormatChar;
|
|
320
|
+
diff[0][1] = e.data || "";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
306
325
|
if (hasCaret && (!diff || diff.length === 0)) {
|
|
307
326
|
this.restorePreviousInputEventState();
|
|
308
327
|
return;
|
|
@@ -344,6 +363,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
344
363
|
var lastParseResultHasNoValue = lastParseResult && !lastParseResult.value;
|
|
345
364
|
var parsingFailedOnDelete = (hasCaret && (isBackspaceKey || isDeleteKey) && lastParseResultHasNoValue);
|
|
346
365
|
var resetPart = lastParseResult ? lastParseResult.resetPart : false;
|
|
366
|
+
var hasInvalidDatePart = lastParseResult ? lastParseResult.hasInvalidDatePart : false;
|
|
347
367
|
var hasDateValueChanged = !isEqual(oldDateObjectValue, this.dateObject.value);
|
|
348
368
|
var symbolForSelection;
|
|
349
369
|
var currentSelection = this.selection;
|
|
@@ -369,14 +389,35 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
369
389
|
}
|
|
370
390
|
}
|
|
371
391
|
else if (hasCaret) {
|
|
372
|
-
if (hasDateValueChanged && isPresent(this.dateObject.getValue())
|
|
392
|
+
if ((hasDateValueChanged && isPresent(this.dateObject.getValue()) ||
|
|
393
|
+
(!hasDateValueChanged && switchPart && isPresent(this.dateObject.getValue())))) {
|
|
373
394
|
if (switchPart) {
|
|
374
395
|
this.switchDateSegment(1);
|
|
375
396
|
}
|
|
397
|
+
else {
|
|
398
|
+
if (this.options.format.length !== this.currentFormat.length &&
|
|
399
|
+
currentFormatChar && currentFormatChar !== "y") {
|
|
400
|
+
var elementValueLength = this.elementValue.length;
|
|
401
|
+
this.forceUpdate();
|
|
402
|
+
var selectionOffset = this.elementValue.length - elementValueLength;
|
|
403
|
+
this.setSelection({
|
|
404
|
+
start: currentSelection.start + selectionOffset,
|
|
405
|
+
end: currentSelection.start + selectionOffset
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
376
409
|
}
|
|
377
410
|
else {
|
|
378
411
|
if (lastParseResultHasNoValue) {
|
|
379
|
-
this.
|
|
412
|
+
var hasLeadingZero = this.dateObject.getLeadingZero()[currentFormatChar];
|
|
413
|
+
if (switchPart) {
|
|
414
|
+
this.switchDateSegment(1);
|
|
415
|
+
}
|
|
416
|
+
else if (e.data === "0" && hasLeadingZero) {
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
this.restorePreviousInputEventState();
|
|
420
|
+
}
|
|
380
421
|
}
|
|
381
422
|
}
|
|
382
423
|
}
|
|
@@ -388,20 +429,25 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
388
429
|
}
|
|
389
430
|
else {
|
|
390
431
|
// the input is not complete, not parsable or not updatable
|
|
391
|
-
if (
|
|
432
|
+
if (originalInteractionMode !== DateInputInteractionMode.Caret && hasDateValueChanged) {
|
|
392
433
|
}
|
|
393
|
-
else if (
|
|
434
|
+
else if (originalInteractionMode !== DateInputInteractionMode.Caret) {
|
|
394
435
|
symbolForSelection = this.currentFormat[currentSelection.start];
|
|
395
436
|
this.forceUpdate();
|
|
396
437
|
this.setSelection(this.selectionBySymbol(symbolForSelection));
|
|
397
438
|
}
|
|
398
|
-
else {
|
|
439
|
+
else if (!hasInvalidDatePart) {
|
|
399
440
|
this.restorePreviousInputEventState();
|
|
400
441
|
}
|
|
401
442
|
}
|
|
402
443
|
}
|
|
403
444
|
else {
|
|
404
|
-
this.
|
|
445
|
+
var hasLeadingZero = this.dateObject.getLeadingZero()[currentFormatChar];
|
|
446
|
+
if (e.data === "0" && hasLeadingZero) {
|
|
447
|
+
}
|
|
448
|
+
else if (!hasInvalidDatePart) {
|
|
449
|
+
this.restorePreviousInputEventState();
|
|
450
|
+
}
|
|
405
451
|
}
|
|
406
452
|
}
|
|
407
453
|
else if (this.options.autoSwitchParts && (switchPart || navigationOnly)) {
|
|
@@ -463,9 +509,14 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
463
509
|
if (this.triggerKeyDown({ event: e })) {
|
|
464
510
|
return;
|
|
465
511
|
}
|
|
512
|
+
var _a = this.selection, start = _a.start, end = _a.end;
|
|
466
513
|
this.keyDownEvent = e;
|
|
467
514
|
this.previousElementValue = this.element.value;
|
|
468
|
-
|
|
515
|
+
this.formatStateOnKeyDown = {
|
|
516
|
+
format: this.currentFormat,
|
|
517
|
+
selectionStart: start,
|
|
518
|
+
selectionEnd: end
|
|
519
|
+
};
|
|
469
520
|
this.previousElementSelection = { start: start, end: end };
|
|
470
521
|
var autoSwitchKeys = (this.options.autoSwitchKeys || [])
|
|
471
522
|
.map(function (x) { return x.toString().toLowerCase().trim(); });
|
|
@@ -735,11 +786,13 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
735
786
|
return;
|
|
736
787
|
}
|
|
737
788
|
}
|
|
789
|
+
this.interactionMode = DateInputInteractionMode.None;
|
|
738
790
|
var _a = this.selection, selectionStart = _a.start, selectionEnd = _a.end;
|
|
739
791
|
if (selectionStart < selectionEnd &&
|
|
740
792
|
this.currentFormat[selectionStart] !== this.currentFormat[selectionEnd - 1]) {
|
|
741
793
|
this.setSelection(this.selectionByIndex(offset > 0 ? selectionStart : selectionEnd - 1));
|
|
742
794
|
this.resetSegmentValue = true;
|
|
795
|
+
this.interactionMode = DateInputInteractionMode.None;
|
|
743
796
|
return;
|
|
744
797
|
}
|
|
745
798
|
var previousFormatSymbol = this.currentFormat[selectionStart];
|
|
@@ -770,6 +823,7 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
770
823
|
this.setSelection({ start: a, end: b });
|
|
771
824
|
this.resetSegmentValue = true;
|
|
772
825
|
}
|
|
826
|
+
this.interactionMode = DateInputInteractionMode.None;
|
|
773
827
|
};
|
|
774
828
|
DateInput.prototype.modifyDateSegmentValue = function (offset, symbol, event) {
|
|
775
829
|
if (symbol === void 0) { symbol = ""; }
|
|
@@ -971,13 +1025,14 @@ var DateInput = /** @class */ (function (_super) {
|
|
|
971
1025
|
var _a = this.dateObject.getTextAndFormat(format), currentText = _a.text, currentFormat = _a.format;
|
|
972
1026
|
this.currentFormat = currentFormat;
|
|
973
1027
|
this.currentText = currentText;
|
|
1028
|
+
var hasPlaceholder = this.options.hasPlaceholder || isPresent(this.options.placeholder);
|
|
974
1029
|
var showPlaceholder = !this.isActive &&
|
|
975
|
-
|
|
1030
|
+
hasPlaceholder &&
|
|
976
1031
|
!this.dateObject.hasValue();
|
|
977
|
-
if (isPresent(this.options.placeholder)) {
|
|
1032
|
+
if (hasPlaceholder && isPresent(this.options.placeholder)) {
|
|
978
1033
|
element.placeholder = this.options.placeholder;
|
|
979
1034
|
}
|
|
980
|
-
var newElementValue =
|
|
1035
|
+
var newElementValue = showPlaceholder ? "" : currentText;
|
|
981
1036
|
this.previousElementValue = this.elementValue;
|
|
982
1037
|
this.setElementValue(newElementValue);
|
|
983
1038
|
if (this.isActive && !this.options.allowCaretMode && this.options.selectNearestSegmentOnFocus) {
|