@syncfusion/ej2-calendars 27.1.48 → 27.1.51

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.
@@ -499,22 +499,19 @@ var CalendarBase = /** @__PURE__ @class */ (function (_super) {
499
499
  this.effect = '';
500
500
  switch (e.action) {
501
501
  case 'moveLeft':
502
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
503
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
502
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
504
503
  this.keyboardNavigate(-1, view, e, this.max, this.min);
505
504
  e.preventDefault();
506
505
  }
507
506
  break;
508
507
  case 'moveRight':
509
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
510
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
508
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
511
509
  this.keyboardNavigate(1, view, e, this.max, this.min);
512
510
  e.preventDefault();
513
511
  }
514
512
  break;
515
513
  case 'moveUp':
516
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
517
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
514
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
518
515
  if (view === 0) {
519
516
  this.keyboardNavigate(-7, view, e, this.max, this.min); // move the current date to the previous seven days.
520
517
  }
@@ -525,8 +522,7 @@ var CalendarBase = /** @__PURE__ @class */ (function (_super) {
525
522
  }
526
523
  break;
527
524
  case 'moveDown':
528
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
529
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
525
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
530
526
  if (view === 0) {
531
527
  this.keyboardNavigate(7, view, e, this.max, this.min);
532
528
  }
@@ -1056,7 +1052,7 @@ var CalendarBase = /** @__PURE__ @class */ (function (_super) {
1056
1052
  return this.createElement('td', attrs);
1057
1053
  };
1058
1054
  CalendarBase.prototype.firstDay = function (date) {
1059
- var collection = this.currentView() !== 'Decade' ? this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERMONTH + '') :
1055
+ var collection = this.currentView() !== 'Decade' ? this.tableBodyElement.querySelectorAll('td:not(.' + OTHERMONTH + '):not(.' + WEEKNUMBER + ')') :
1060
1056
  this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERDECADE + '');
1061
1057
  if (collection.length) {
1062
1058
  for (var i = 0; i < collection.length; i++) {
@@ -1087,7 +1083,7 @@ var CalendarBase = /** @__PURE__ @class */ (function (_super) {
1087
1083
  };
1088
1084
  CalendarBase.prototype.findLastDay = function (date) {
1089
1085
  var collection = this.currentView() === 'Decade' ? this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERDECADE + '') :
1090
- this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERMONTH + '');
1086
+ this.tableBodyElement.querySelectorAll('td:not(.' + OTHERMONTH + '):not(.' + WEEKNUMBER + ')');
1091
1087
  if (collection.length) {
1092
1088
  for (var i = collection.length - 1; i >= 0; i--) {
1093
1089
  if (!collection[i].classList.contains(DISABLED)) {
@@ -3588,9 +3584,9 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
3588
3584
  formatOptions = { format: this.formatString, type: 'dateTime', skeleton: 'yMd', calendar: 'islamic' };
3589
3585
  }
3590
3586
  }
3591
- returnDate = this.checkDateValue(this.globalize.parseDate(val, formatOptions));
3587
+ returnDate = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(val), formatOptions));
3592
3588
  if (isNullOrUndefined(returnDate) && (this.getModuleName() === 'datetimepicker')) {
3593
- returnDate = this.checkDateValue(this.globalize.parseDate(val, formatDateTime));
3589
+ returnDate = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(val), formatDateTime));
3594
3590
  }
3595
3591
  return returnDate;
3596
3592
  };
@@ -3704,9 +3700,10 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
3704
3700
  case 'ArrowDown':
3705
3701
  case 'Home':
3706
3702
  case 'End':
3703
+ case 'Backspace':
3707
3704
  case 'Delete':
3708
3705
  if (this.enableMask && !this.popupObj && !this.readonly) {
3709
- if (e.code !== 'Delete') {
3706
+ if (e.code !== 'Delete' && e.code !== 'Backspace') {
3710
3707
  e.preventDefault();
3711
3708
  }
3712
3709
  this.notify('keyDownHandler', {
@@ -4183,9 +4180,8 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
4183
4180
  this.inputElement.value = this.inputElement.value.trim();
4184
4181
  }
4185
4182
  if ((this.getModuleName() === 'datetimepicker')) {
4186
- if (this.checkDateValue(this.globalize.parseDate(this.inputElement.value, dateOptions))) {
4187
- var modifiedValue = this.inputElement.value.replace(/(am|pm|Am|aM|pM|Pm)/g, function (match) { return match.toLocaleUpperCase(); });
4188
- date = this.globalize.parseDate(modifiedValue, dateOptions);
4183
+ if (this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions))) {
4184
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions);
4189
4185
  }
4190
4186
  else {
4191
4187
  if (this.calendarMode === 'Gregorian') {
@@ -4194,11 +4190,11 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
4194
4190
  else {
4195
4191
  formatOptions = { format: format, type: 'dateTime', skeleton: 'yMd', calendar: 'islamic' };
4196
4192
  }
4197
- date = this.globalize.parseDate(this.inputElement.value, formatOptions);
4193
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), formatOptions);
4198
4194
  }
4199
4195
  }
4200
4196
  else {
4201
- date = this.globalize.parseDate(this.inputElement.value, dateOptions);
4197
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions);
4202
4198
  date = (!isNullOrUndefined(date) && isNaN(+date)) ? null : date;
4203
4199
  if (!isNullOrUndefined(this.formatString) && this.inputElement.value !== '' && this.strictMode) {
4204
4200
  if ((this.isPopupClicked || (!this.isPopupClicked && this.inputElement.value === this.previousElementValue))
@@ -4308,6 +4304,20 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
4308
4304
  this.popupObj.element.className += ' ' + this.cssClass;
4309
4305
  this.setAriaAttributes();
4310
4306
  };
4307
+ DatePicker.prototype.getAmPmValue = function (date) {
4308
+ try {
4309
+ if (typeof date === 'string' && date.trim() !== '') {
4310
+ // Replace am/pm variants with uppercase AM/PM
4311
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, function (match) { return match.toLocaleUpperCase(); });
4312
+ }
4313
+ // If date is null, undefined, or an empty string, return a default value or empty string
4314
+ return '';
4315
+ }
4316
+ catch (error) {
4317
+ console.error('Error occurred while processing date:', error);
4318
+ return ''; // Return a default value in case of an error
4319
+ }
4320
+ };
4311
4321
  DatePicker.prototype.CalendarSwipeHandler = function (e) {
4312
4322
  var direction = 0;
4313
4323
  if (this.iconRight) {
@@ -4990,19 +5000,19 @@ var DatePicker = /** @__PURE__ @class */ (function (_super) {
4990
5000
  case 'value':
4991
5001
  if (((isNullOrUndefined(this.datepickerOptions) || (this.datepickerOptions['value'] === undefined)) || dynamic)) {
4992
5002
  var value = this.inputElement.getAttribute(prop);
4993
- this.setProperties(setValue(prop, this.globalize.parseDate(value, options), {}), !dynamic);
5003
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(value), options), {}), !dynamic);
4994
5004
  }
4995
5005
  break;
4996
5006
  case 'min':
4997
5007
  if ((+this.min === +new Date(1900, 0, 1)) || dynamic) {
4998
5008
  var min = this.inputElement.getAttribute(prop);
4999
- this.setProperties(setValue(prop, this.globalize.parseDate(min, options), {}), !dynamic);
5009
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(min), options), {}), !dynamic);
5000
5010
  }
5001
5011
  break;
5002
5012
  case 'max':
5003
5013
  if ((+this.max === +new Date(2099, 11, 31)) || dynamic) {
5004
5014
  var max = this.inputElement.getAttribute(prop);
5005
- this.setProperties(setValue(prop, this.globalize.parseDate(max, options), {}), !dynamic);
5015
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(max), options), {}), !dynamic);
5006
5016
  }
5007
5017
  break;
5008
5018
  case 'type':
@@ -5905,10 +5915,10 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
5905
5915
  if (this.firstHiddenChild && this.secondHiddenChild) {
5906
5916
  var format = { format: this.formatString, type: 'datetime', skeleton: 'yMd' };
5907
5917
  if (typeof this.startDate === 'string') {
5908
- this.startDate = this.globalize.parseDate(this.startDate, format);
5918
+ this.startDate = this.globalize.parseDate(this.getAmPmValue(this.startDate), format);
5909
5919
  }
5910
5920
  if (typeof this.endDate === 'string') {
5911
- this.endDate = this.globalize.parseDate(this.endDate, format);
5921
+ this.endDate = this.globalize.parseDate(this.getAmPmValue(this.endDate), format);
5912
5922
  }
5913
5923
  this.firstHiddenChild.value = (this.startDate && this.globalize.formatDate(this.startDate, format))
5914
5924
  || (this.inputElement.value);
@@ -6084,7 +6094,7 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
6084
6094
  break;
6085
6095
  case 'min':
6086
6096
  if ((isNullOrUndefined(this.min) || +this.min === +new Date(1900, 0, 1)) || isDynamic) {
6087
- var dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6097
+ var dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6088
6098
  this.setProperties(setValue(prop, dateValue, {}), !isDynamic);
6089
6099
  }
6090
6100
  break;
@@ -6093,20 +6103,20 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
6093
6103
  break;
6094
6104
  case 'max':
6095
6105
  if ((isNullOrUndefined(this.max) || +this.max === +new Date(2099, 11, 31)) || isDynamic) {
6096
- var dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6106
+ var dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6097
6107
  this.setProperties(setValue(prop, dateValue, {}), !isDynamic);
6098
6108
  }
6099
6109
  break;
6100
6110
  case 'startDate':
6101
6111
  if (isNullOrUndefined(this.startDate)) {
6102
- var dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6112
+ var dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6103
6113
  this.startValue = dateValue;
6104
6114
  this.setValue();
6105
6115
  }
6106
6116
  break;
6107
6117
  case 'endDate':
6108
6118
  if (isNullOrUndefined(this.endDate)) {
6109
- var dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6119
+ var dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6110
6120
  this.endValue = dateValue;
6111
6121
  this.setValue();
6112
6122
  }
@@ -6341,8 +6351,8 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
6341
6351
  if (range.length > 1) {
6342
6352
  this.invalidValueString = null;
6343
6353
  var dateOptions = { format: this.formatString, type: 'date', skeleton: 'yMd' };
6344
- var start = this.globalize.parseDate(range[0], dateOptions);
6345
- var end = this.globalize.parseDate(range[1], dateOptions);
6354
+ var start = this.globalize.parseDate(this.getAmPmValue(range[0]), dateOptions);
6355
+ var end = this.globalize.parseDate(this.getAmPmValue(range[1]), dateOptions);
6346
6356
  var startDate = this.getStartEndDate(start, false, range, dateOptions);
6347
6357
  var endDate = this.getStartEndDate(end, true, range, dateOptions);
6348
6358
  if (!isNullOrUndefined(startDate) && !isNaN(+startDate) && !isNullOrUndefined(endDate) && !isNaN(+endDate)) {
@@ -6418,7 +6428,7 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
6418
6428
  };
6419
6429
  DateRangePicker.prototype.getStartEndDate = function (date, isEnd, range, dateOptions) {
6420
6430
  if (this.depth === 'Month') {
6421
- return this.globalize.parseDate(range[isEnd ? 1 : 0].trim(), dateOptions);
6431
+ return this.globalize.parseDate(this.getAmPmValue(range[isEnd ? 1 : 0]).trim(), dateOptions);
6422
6432
  }
6423
6433
  else if (this.depth === 'Year' && !isNullOrUndefined(date)) {
6424
6434
  return new Date(date.getFullYear(), date.getMonth() + (isEnd ? 1 : 0), isEnd ? 0 : 1);
@@ -9629,6 +9639,20 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
9629
9639
  this.updateHeader();
9630
9640
  }
9631
9641
  };
9642
+ DateRangePicker.prototype.getAmPmValue = function (date) {
9643
+ try {
9644
+ if (typeof date === 'string' && date.trim() !== '') {
9645
+ // Replace am/pm variants with uppercase AM/PM
9646
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, function (match) { return match.toLocaleUpperCase(); });
9647
+ }
9648
+ // If date is null, undefined, or an empty string, return a default value or empty string
9649
+ return '';
9650
+ }
9651
+ catch (error) {
9652
+ console.error('Error occurred while processing date:', error);
9653
+ return ''; // Return a default value in case of an error
9654
+ }
9655
+ };
9632
9656
  DateRangePicker.prototype.getStartEndValue = function (date, isEnd) {
9633
9657
  if (this.depth === 'Month') {
9634
9658
  return this.checkDateValue(new Date(this.checkValue(date)));
@@ -9729,7 +9753,7 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
9729
9753
  break;
9730
9754
  case 'startDate':
9731
9755
  if (typeof newProp.startDate === 'string') {
9732
- newProp.startDate = this.globalize.parseDate(newProp.startDate, format);
9756
+ newProp.startDate = this.globalize.parseDate(this.getAmPmValue(newProp.startDate), format);
9733
9757
  }
9734
9758
  if (+this.initStartDate !== +newProp.startDate) {
9735
9759
  this.startValue = this.getStartEndValue(newProp.startDate, false);
@@ -9739,7 +9763,7 @@ var DateRangePicker = /** @__PURE__ @class */ (function (_super) {
9739
9763
  break;
9740
9764
  case 'endDate':
9741
9765
  if (typeof newProp.endDate === 'string') {
9742
- newProp.endDate = this.globalize.parseDate(newProp.endDate, format);
9766
+ newProp.endDate = this.globalize.parseDate(this.getAmPmValue(newProp.endDate), format);
9743
9767
  }
9744
9768
  if (+this.initEndDate !== +newProp.endDate) {
9745
9769
  this.endValue = this.getStartEndValue(newProp.endDate, true);
@@ -10400,18 +10424,18 @@ var TimePicker = /** @__PURE__ @class */ (function (_super) {
10400
10424
  if (!(/^[a-zA-Z0-9- ]*$/).test(value)) {
10401
10425
  valueExpression = this.setCurrentDate(this.getDateObject(value));
10402
10426
  if (isNullOrUndefined(valueExpression)) {
10403
- valueExpression = this.checkDateValue(this.globalize.parseDate(valueString, {
10427
+ valueExpression = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(valueString), {
10404
10428
  format: this.getCldrDateTimeFormat(), type: 'datetime'
10405
10429
  }));
10406
10430
  if (isNullOrUndefined(valueExpression)) {
10407
- valueExpression = this.checkDateValue(this.globalize.parseDate(valueString, {
10431
+ valueExpression = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(valueString), {
10408
10432
  format: this.formatString, type: 'dateTime', skeleton: 'yMd'
10409
10433
  }));
10410
10434
  }
10411
10435
  }
10412
10436
  }
10413
10437
  }
10414
- valueExp = this.globalize.parseDate(valueString, {
10438
+ valueExp = this.globalize.parseDate(this.getAmPmValue(valueString), {
10415
10439
  format: this.getCldrDateTimeFormat(), type: 'datetime'
10416
10440
  });
10417
10441
  valueExpression = (!isNullOrUndefined(valueExp) && valueExp instanceof Date && !isNaN(+valueExp)) ? valueExp : null;
@@ -10450,6 +10474,20 @@ var TimePicker = /** @__PURE__ @class */ (function (_super) {
10450
10474
  }
10451
10475
  return modules;
10452
10476
  };
10477
+ TimePicker.prototype.getAmPmValue = function (date) {
10478
+ try {
10479
+ if (typeof date === 'string' && date.trim() !== '') {
10480
+ // Replace am/pm variants with uppercase AM/PM
10481
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, function (match) { return match.toLocaleUpperCase(); });
10482
+ }
10483
+ // If date is null, undefined, or an empty string, return a default value or empty string
10484
+ return '';
10485
+ }
10486
+ catch (error) {
10487
+ console.error('Error occurred while processing date:', error);
10488
+ return ''; // Return a default value in case of an error
10489
+ }
10490
+ };
10453
10491
  TimePicker.prototype.cldrFormat = function (type) {
10454
10492
  var cldrDateTimeString;
10455
10493
  if (this.locale === 'en' || this.locale === 'en-US') {
@@ -11955,10 +11993,10 @@ var TimePicker = /** @__PURE__ @class */ (function (_super) {
11955
11993
  };
11956
11994
  TimePicker.prototype.timeParse = function (today, val) {
11957
11995
  var value;
11958
- value = this.globalize.parseDate(today + ' ' + val, {
11996
+ value = this.globalize.parseDate(this.getAmPmValue(today + ' ' + val), {
11959
11997
  format: this.cldrDateFormat() + ' ' + this.cldrTimeFormat(), type: 'datetime'
11960
11998
  });
11961
- value = isNullOrUndefined(value) ? this.globalize.parseDate(today + ' ' + val, {
11999
+ value = isNullOrUndefined(value) ? this.globalize.parseDate(this.getAmPmValue(today + ' ' + val), {
11962
12000
  format: this.cldrDateFormat() + ' ' + this.dateToNumeric(), type: 'datetime'
11963
12001
  }) : value;
11964
12002
  value = isNullOrUndefined(value) ? value : new Date(value.setMilliseconds(0));
@@ -13161,12 +13199,12 @@ var DateTimePicker = /** @__PURE__ @class */ (function (_super) {
13161
13199
  if (this.dateFormatString === '') {
13162
13200
  this.dateFormatString = this.cldrDateTimeFormat();
13163
13201
  }
13164
- dateObject = this.globalize.parseDate(this.inputElement.value, {
13202
+ dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
13165
13203
  format: this.dateFormatString, type: 'datetime'
13166
13204
  });
13167
13205
  }
13168
13206
  else {
13169
- dateObject = this.globalize.parseDate(this.inputElement.value, {
13207
+ dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
13170
13208
  format: this.cldrDateTimeFormat(), type: 'datetime', calendar: 'islamic'
13171
13209
  });
13172
13210
  }
@@ -14578,6 +14616,32 @@ var MaskedDateTime = /** @__PURE__ @class */ (function () {
14578
14616
  this.parent.inputElement.setSelectionRange(start, end);
14579
14617
  };
14580
14618
  MaskedDateTime.prototype.maskKeydownHandler = function (args) {
14619
+ if (args.e.key === 'Backspace') {
14620
+ var start = this.parent.inputElement.selectionStart;
14621
+ var formatText = '';
14622
+ if (this.validCharacters.indexOf(this.hiddenMask[start]) !== -1) {
14623
+ formatText = this.hiddenMask[start];
14624
+ }
14625
+ switch (formatText) {
14626
+ case 'd':
14627
+ this.dayTypeCount = Math.max(this.dayTypeCount - 1, 0);
14628
+ break;
14629
+ case 'M':
14630
+ this.monthTypeCount = Math.max(this.monthTypeCount - 1, 0);
14631
+ break;
14632
+ case 'H':
14633
+ case 'h':
14634
+ this.hourTypeCount = Math.max(this.hourTypeCount - 1, 0);
14635
+ break;
14636
+ case 'm':
14637
+ this.minuteTypeCount = Math.max(this.minuteTypeCount - 1, 0);
14638
+ break;
14639
+ case 's':
14640
+ this.secondTypeCount = Math.max(this.secondTypeCount - 1, 0);
14641
+ break;
14642
+ }
14643
+ return;
14644
+ }
14581
14645
  this.dayTypeCount = this.monthTypeCount = this.hourTypeCount = this.minuteTypeCount = this.secondTypeCount = 0;
14582
14646
  if (args.e.key === 'Delete') {
14583
14647
  this.isDeleteKey = true;