@syncfusion/ej2-calendars 27.1.50 → 27.1.52

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.
@@ -3700,9 +3700,10 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
3700
3700
  case 'ArrowDown':
3701
3701
  case 'Home':
3702
3702
  case 'End':
3703
+ case 'Backspace':
3703
3704
  case 'Delete':
3704
3705
  if (this.enableMask && !this.popupObj && !this.readonly) {
3705
- if (e.code !== 'Delete') {
3706
+ if (e.code !== 'Delete' && e.code !== 'Backspace') {
3706
3707
  e.preventDefault();
3707
3708
  }
3708
3709
  this.notify('keyDownHandler', {
@@ -3949,12 +3950,19 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
3949
3950
  this.show();
3950
3951
  }
3951
3952
  };
3952
- DatePicker.prototype.inputHandler = function () {
3953
+ DatePicker.prototype.inputHandler = function (e) {
3953
3954
  this.isPopupClicked = false;
3954
3955
  if (this.enableMask) {
3955
- this.notify('inputHandler', {
3956
- module: 'MaskedDateTime'
3957
- });
3956
+ if (!isNullOrUndefined(e) && !isNullOrUndefined(e.inputType) && e.inputType === 'insertFromPaste') {
3957
+ this.notify('maskPasteInputHandler', {
3958
+ module: 'MaskedDateTime'
3959
+ });
3960
+ }
3961
+ else {
3962
+ this.notify('inputHandler', {
3963
+ module: 'MaskedDateTime'
3964
+ });
3965
+ }
3958
3966
  }
3959
3967
  };
3960
3968
  DatePicker.prototype.inputBlurHandler = function (e) {
@@ -14515,6 +14523,7 @@ var MaskedDateTime = /** @__PURE__ @class */ (function () {
14515
14523
  this.parent.on('inputHandler', this.maskInputHandler, this);
14516
14524
  this.parent.on('keyDownHandler', this.maskKeydownHandler, this);
14517
14525
  this.parent.on('clearHandler', this.clearHandler, this);
14526
+ this.parent.on('maskPasteInputHandler', this.maskPasteInputHandler, this);
14518
14527
  };
14519
14528
  MaskedDateTime.prototype.removeEventListener = function () {
14520
14529
  if (this.parent.isDestroyed) {
@@ -14525,6 +14534,7 @@ var MaskedDateTime = /** @__PURE__ @class */ (function () {
14525
14534
  this.parent.off('inputHandler', this.maskInputHandler);
14526
14535
  this.parent.off('keyDownHandler', this.maskKeydownHandler);
14527
14536
  this.parent.off('clearHandler', this.clearHandler);
14537
+ this.parent.off('maskPasteInputHandler', this.maskPasteInputHandler);
14528
14538
  };
14529
14539
  MaskedDateTime.prototype.createMask = function (mask) {
14530
14540
  this.isDayPart = this.isMonthPart = this.isYearPart = this.isHourPart = this.isMinutePart = this.isSecondsPart = false;
@@ -14615,6 +14625,32 @@ var MaskedDateTime = /** @__PURE__ @class */ (function () {
14615
14625
  this.parent.inputElement.setSelectionRange(start, end);
14616
14626
  };
14617
14627
  MaskedDateTime.prototype.maskKeydownHandler = function (args) {
14628
+ if (args.e.key === 'Backspace') {
14629
+ var start = this.parent.inputElement.selectionStart;
14630
+ var formatText = '';
14631
+ if (this.validCharacters.indexOf(this.hiddenMask[start]) !== -1) {
14632
+ formatText = this.hiddenMask[start];
14633
+ }
14634
+ switch (formatText) {
14635
+ case 'd':
14636
+ this.dayTypeCount = Math.max(this.dayTypeCount - 1, 0);
14637
+ break;
14638
+ case 'M':
14639
+ this.monthTypeCount = Math.max(this.monthTypeCount - 1, 0);
14640
+ break;
14641
+ case 'H':
14642
+ case 'h':
14643
+ this.hourTypeCount = Math.max(this.hourTypeCount - 1, 0);
14644
+ break;
14645
+ case 'm':
14646
+ this.minuteTypeCount = Math.max(this.minuteTypeCount - 1, 0);
14647
+ break;
14648
+ case 's':
14649
+ this.secondTypeCount = Math.max(this.secondTypeCount - 1, 0);
14650
+ break;
14651
+ }
14652
+ return;
14653
+ }
14618
14654
  this.dayTypeCount = this.monthTypeCount = this.hourTypeCount = this.minuteTypeCount = this.secondTypeCount = 0;
14619
14655
  if (args.e.key === 'Delete') {
14620
14656
  this.isDeleteKey = true;
@@ -15080,6 +15116,25 @@ var MaskedDateTime = /** @__PURE__ @class */ (function () {
15080
15116
  }
15081
15117
  return formatValueSpecifier;
15082
15118
  };
15119
+ MaskedDateTime.prototype.isValidDate = function (dateString) {
15120
+ var date = new Date(dateString);
15121
+ // Return true if the date is valid, false otherwise
15122
+ return !isNaN(date.getTime());
15123
+ };
15124
+ MaskedDateTime.prototype.maskPasteInputHandler = function () {
15125
+ if (this.isValidDate(this.parent.inputElement.value)) {
15126
+ this.maskDateValue = new Date(this.parent.inputElement.value);
15127
+ this.isDayPart = this.isMonthPart = this.isYearPart = this.isHourPart = this.isMinutePart = this.isSecondsPart = true;
15128
+ this.updateValue();
15129
+ if (!this.isBlur) {
15130
+ this.validCharacterCheck();
15131
+ }
15132
+ return;
15133
+ }
15134
+ else {
15135
+ this.maskInputHandler();
15136
+ }
15137
+ };
15083
15138
  MaskedDateTime.prototype.maskInputHandler = function () {
15084
15139
  var start = this.parent.inputElement.selectionStart;
15085
15140
  var formatText = '';
@@ -15095,7 +15150,6 @@ var MaskedDateTime = /** @__PURE__ @class */ (function () {
15095
15150
  this.previousHiddenMask = this.hiddenMask;
15096
15151
  this.previousValue = inputValue;
15097
15152
  this.parent.inputElement.value = inputValue;
15098
- this.parent.inputElement.value = inputValue;
15099
15153
  for (var i = 0; i < this.hiddenMask.length; i++) {
15100
15154
  if (formatText === this.hiddenMask[i]) {
15101
15155
  start = i;