@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.
@@ -3659,9 +3659,10 @@ let DatePicker = class DatePicker extends Calendar {
3659
3659
  case 'ArrowDown':
3660
3660
  case 'Home':
3661
3661
  case 'End':
3662
+ case 'Backspace':
3662
3663
  case 'Delete':
3663
3664
  if (this.enableMask && !this.popupObj && !this.readonly) {
3664
- if (e.code !== 'Delete') {
3665
+ if (e.code !== 'Delete' && e.code !== 'Backspace') {
3665
3666
  e.preventDefault();
3666
3667
  }
3667
3668
  this.notify('keyDownHandler', {
@@ -3906,12 +3907,19 @@ let DatePicker = class DatePicker extends Calendar {
3906
3907
  this.show();
3907
3908
  }
3908
3909
  }
3909
- inputHandler() {
3910
+ inputHandler(e) {
3910
3911
  this.isPopupClicked = false;
3911
3912
  if (this.enableMask) {
3912
- this.notify('inputHandler', {
3913
- module: 'MaskedDateTime'
3914
- });
3913
+ if (!isNullOrUndefined(e) && !isNullOrUndefined(e.inputType) && e.inputType === 'insertFromPaste') {
3914
+ this.notify('maskPasteInputHandler', {
3915
+ module: 'MaskedDateTime'
3916
+ });
3917
+ }
3918
+ else {
3919
+ this.notify('inputHandler', {
3920
+ module: 'MaskedDateTime'
3921
+ });
3922
+ }
3915
3923
  }
3916
3924
  }
3917
3925
  inputBlurHandler(e) {
@@ -14367,6 +14375,7 @@ class MaskedDateTime {
14367
14375
  this.parent.on('inputHandler', this.maskInputHandler, this);
14368
14376
  this.parent.on('keyDownHandler', this.maskKeydownHandler, this);
14369
14377
  this.parent.on('clearHandler', this.clearHandler, this);
14378
+ this.parent.on('maskPasteInputHandler', this.maskPasteInputHandler, this);
14370
14379
  }
14371
14380
  removeEventListener() {
14372
14381
  if (this.parent.isDestroyed) {
@@ -14377,6 +14386,7 @@ class MaskedDateTime {
14377
14386
  this.parent.off('inputHandler', this.maskInputHandler);
14378
14387
  this.parent.off('keyDownHandler', this.maskKeydownHandler);
14379
14388
  this.parent.off('clearHandler', this.clearHandler);
14389
+ this.parent.off('maskPasteInputHandler', this.maskPasteInputHandler);
14380
14390
  }
14381
14391
  createMask(mask) {
14382
14392
  this.isDayPart = this.isMonthPart = this.isYearPart = this.isHourPart = this.isMinutePart = this.isSecondsPart = false;
@@ -14467,6 +14477,32 @@ class MaskedDateTime {
14467
14477
  this.parent.inputElement.setSelectionRange(start, end);
14468
14478
  }
14469
14479
  maskKeydownHandler(args) {
14480
+ if (args.e.key === 'Backspace') {
14481
+ const start = this.parent.inputElement.selectionStart;
14482
+ let formatText = '';
14483
+ if (this.validCharacters.indexOf(this.hiddenMask[start]) !== -1) {
14484
+ formatText = this.hiddenMask[start];
14485
+ }
14486
+ switch (formatText) {
14487
+ case 'd':
14488
+ this.dayTypeCount = Math.max(this.dayTypeCount - 1, 0);
14489
+ break;
14490
+ case 'M':
14491
+ this.monthTypeCount = Math.max(this.monthTypeCount - 1, 0);
14492
+ break;
14493
+ case 'H':
14494
+ case 'h':
14495
+ this.hourTypeCount = Math.max(this.hourTypeCount - 1, 0);
14496
+ break;
14497
+ case 'm':
14498
+ this.minuteTypeCount = Math.max(this.minuteTypeCount - 1, 0);
14499
+ break;
14500
+ case 's':
14501
+ this.secondTypeCount = Math.max(this.secondTypeCount - 1, 0);
14502
+ break;
14503
+ }
14504
+ return;
14505
+ }
14470
14506
  this.dayTypeCount = this.monthTypeCount = this.hourTypeCount = this.minuteTypeCount = this.secondTypeCount = 0;
14471
14507
  if (args.e.key === 'Delete') {
14472
14508
  this.isDeleteKey = true;
@@ -14931,6 +14967,25 @@ class MaskedDateTime {
14931
14967
  }
14932
14968
  return formatValueSpecifier;
14933
14969
  }
14970
+ isValidDate(dateString) {
14971
+ const date = new Date(dateString);
14972
+ // Return true if the date is valid, false otherwise
14973
+ return !isNaN(date.getTime());
14974
+ }
14975
+ maskPasteInputHandler() {
14976
+ if (this.isValidDate(this.parent.inputElement.value)) {
14977
+ this.maskDateValue = new Date(this.parent.inputElement.value);
14978
+ this.isDayPart = this.isMonthPart = this.isYearPart = this.isHourPart = this.isMinutePart = this.isSecondsPart = true;
14979
+ this.updateValue();
14980
+ if (!this.isBlur) {
14981
+ this.validCharacterCheck();
14982
+ }
14983
+ return;
14984
+ }
14985
+ else {
14986
+ this.maskInputHandler();
14987
+ }
14988
+ }
14934
14989
  maskInputHandler() {
14935
14990
  let start = this.parent.inputElement.selectionStart;
14936
14991
  let formatText = '';
@@ -14946,7 +15001,6 @@ class MaskedDateTime {
14946
15001
  this.previousHiddenMask = this.hiddenMask;
14947
15002
  this.previousValue = inputValue;
14948
15003
  this.parent.inputElement.value = inputValue;
14949
- this.parent.inputElement.value = inputValue;
14950
15004
  for (let i = 0; i < this.hiddenMask.length; i++) {
14951
15005
  if (formatText === this.hiddenMask[i]) {
14952
15006
  start = i;