@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.
@@ -483,22 +483,19 @@ let CalendarBase = class CalendarBase extends Component {
483
483
  this.effect = '';
484
484
  switch (e.action) {
485
485
  case 'moveLeft':
486
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
487
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
486
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
488
487
  this.keyboardNavigate(-1, view, e, this.max, this.min);
489
488
  e.preventDefault();
490
489
  }
491
490
  break;
492
491
  case 'moveRight':
493
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
494
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
492
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
495
493
  this.keyboardNavigate(1, view, e, this.max, this.min);
496
494
  e.preventDefault();
497
495
  }
498
496
  break;
499
497
  case 'moveUp':
500
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
501
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
498
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
502
499
  if (view === 0) {
503
500
  this.keyboardNavigate(-7, view, e, this.max, this.min); // move the current date to the previous seven days.
504
501
  }
@@ -509,8 +506,7 @@ let CalendarBase = class CalendarBase extends Component {
509
506
  }
510
507
  break;
511
508
  case 'moveDown':
512
- if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target) &&
513
- e.target.classList.length > 0 && e.target.classList.contains(CONTENTTABLE)) {
509
+ if (this.getModuleName() !== 'daterangepicker' && !isNullOrUndefined(e.target)) {
514
510
  if (view === 0) {
515
511
  this.keyboardNavigate(7, view, e, this.max, this.min);
516
512
  }
@@ -1039,7 +1035,7 @@ let CalendarBase = class CalendarBase extends Component {
1039
1035
  return this.createElement('td', attrs);
1040
1036
  }
1041
1037
  firstDay(date) {
1042
- const collection = this.currentView() !== 'Decade' ? this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERMONTH + '') :
1038
+ const collection = this.currentView() !== 'Decade' ? this.tableBodyElement.querySelectorAll('td:not(.' + OTHERMONTH + '):not(.' + WEEKNUMBER + ')') :
1043
1039
  this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERDECADE + '');
1044
1040
  if (collection.length) {
1045
1041
  for (let i = 0; i < collection.length; i++) {
@@ -1070,7 +1066,7 @@ let CalendarBase = class CalendarBase extends Component {
1070
1066
  }
1071
1067
  findLastDay(date) {
1072
1068
  const collection = this.currentView() === 'Decade' ? this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERDECADE + '') :
1073
- this.tableBodyElement.querySelectorAll('td' + ':not(.' + OTHERMONTH + '');
1069
+ this.tableBodyElement.querySelectorAll('td:not(.' + OTHERMONTH + '):not(.' + WEEKNUMBER + ')');
1074
1070
  if (collection.length) {
1075
1071
  for (let i = collection.length - 1; i >= 0; i--) {
1076
1072
  if (!collection[i].classList.contains(DISABLED)) {
@@ -3547,9 +3543,9 @@ let DatePicker = class DatePicker extends Calendar {
3547
3543
  formatOptions = { format: this.formatString, type: 'dateTime', skeleton: 'yMd', calendar: 'islamic' };
3548
3544
  }
3549
3545
  }
3550
- returnDate = this.checkDateValue(this.globalize.parseDate(val, formatOptions));
3546
+ returnDate = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(val), formatOptions));
3551
3547
  if (isNullOrUndefined(returnDate) && (this.getModuleName() === 'datetimepicker')) {
3552
- returnDate = this.checkDateValue(this.globalize.parseDate(val, formatDateTime));
3548
+ returnDate = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(val), formatDateTime));
3553
3549
  }
3554
3550
  return returnDate;
3555
3551
  }
@@ -3663,9 +3659,10 @@ let DatePicker = class DatePicker extends Calendar {
3663
3659
  case 'ArrowDown':
3664
3660
  case 'Home':
3665
3661
  case 'End':
3662
+ case 'Backspace':
3666
3663
  case 'Delete':
3667
3664
  if (this.enableMask && !this.popupObj && !this.readonly) {
3668
- if (e.code !== 'Delete') {
3665
+ if (e.code !== 'Delete' && e.code !== 'Backspace') {
3669
3666
  e.preventDefault();
3670
3667
  }
3671
3668
  this.notify('keyDownHandler', {
@@ -4140,9 +4137,8 @@ let DatePicker = class DatePicker extends Calendar {
4140
4137
  this.inputElement.value = this.inputElement.value.trim();
4141
4138
  }
4142
4139
  if ((this.getModuleName() === 'datetimepicker')) {
4143
- if (this.checkDateValue(this.globalize.parseDate(this.inputElement.value, dateOptions))) {
4144
- const modifiedValue = this.inputElement.value.replace(/(am|pm|Am|aM|pM|Pm)/g, (match) => match.toLocaleUpperCase());
4145
- date = this.globalize.parseDate(modifiedValue, dateOptions);
4140
+ if (this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions))) {
4141
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions);
4146
4142
  }
4147
4143
  else {
4148
4144
  if (this.calendarMode === 'Gregorian') {
@@ -4151,11 +4147,11 @@ let DatePicker = class DatePicker extends Calendar {
4151
4147
  else {
4152
4148
  formatOptions = { format: format, type: 'dateTime', skeleton: 'yMd', calendar: 'islamic' };
4153
4149
  }
4154
- date = this.globalize.parseDate(this.inputElement.value, formatOptions);
4150
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), formatOptions);
4155
4151
  }
4156
4152
  }
4157
4153
  else {
4158
- date = this.globalize.parseDate(this.inputElement.value, dateOptions);
4154
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions);
4159
4155
  date = (!isNullOrUndefined(date) && isNaN(+date)) ? null : date;
4160
4156
  if (!isNullOrUndefined(this.formatString) && this.inputElement.value !== '' && this.strictMode) {
4161
4157
  if ((this.isPopupClicked || (!this.isPopupClicked && this.inputElement.value === this.previousElementValue))
@@ -4264,6 +4260,20 @@ let DatePicker = class DatePicker extends Calendar {
4264
4260
  this.popupObj.element.className += ' ' + this.cssClass;
4265
4261
  this.setAriaAttributes();
4266
4262
  }
4263
+ getAmPmValue(date) {
4264
+ try {
4265
+ if (typeof date === 'string' && date.trim() !== '') {
4266
+ // Replace am/pm variants with uppercase AM/PM
4267
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, (match) => match.toLocaleUpperCase());
4268
+ }
4269
+ // If date is null, undefined, or an empty string, return a default value or empty string
4270
+ return '';
4271
+ }
4272
+ catch (error) {
4273
+ console.error('Error occurred while processing date:', error);
4274
+ return ''; // Return a default value in case of an error
4275
+ }
4276
+ }
4267
4277
  CalendarSwipeHandler(e) {
4268
4278
  let direction = 0;
4269
4279
  if (this.iconRight) {
@@ -4943,19 +4953,19 @@ let DatePicker = class DatePicker extends Calendar {
4943
4953
  case 'value':
4944
4954
  if (((isNullOrUndefined(this.datepickerOptions) || (this.datepickerOptions['value'] === undefined)) || dynamic)) {
4945
4955
  const value = this.inputElement.getAttribute(prop);
4946
- this.setProperties(setValue(prop, this.globalize.parseDate(value, options), {}), !dynamic);
4956
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(value), options), {}), !dynamic);
4947
4957
  }
4948
4958
  break;
4949
4959
  case 'min':
4950
4960
  if ((+this.min === +new Date(1900, 0, 1)) || dynamic) {
4951
4961
  const min = this.inputElement.getAttribute(prop);
4952
- this.setProperties(setValue(prop, this.globalize.parseDate(min, options), {}), !dynamic);
4962
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(min), options), {}), !dynamic);
4953
4963
  }
4954
4964
  break;
4955
4965
  case 'max':
4956
4966
  if ((+this.max === +new Date(2099, 11, 31)) || dynamic) {
4957
4967
  const max = this.inputElement.getAttribute(prop);
4958
- this.setProperties(setValue(prop, this.globalize.parseDate(max, options), {}), !dynamic);
4968
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(max), options), {}), !dynamic);
4959
4969
  }
4960
4970
  break;
4961
4971
  case 'type':
@@ -5830,10 +5840,10 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
5830
5840
  if (this.firstHiddenChild && this.secondHiddenChild) {
5831
5841
  const format = { format: this.formatString, type: 'datetime', skeleton: 'yMd' };
5832
5842
  if (typeof this.startDate === 'string') {
5833
- this.startDate = this.globalize.parseDate(this.startDate, format);
5843
+ this.startDate = this.globalize.parseDate(this.getAmPmValue(this.startDate), format);
5834
5844
  }
5835
5845
  if (typeof this.endDate === 'string') {
5836
- this.endDate = this.globalize.parseDate(this.endDate, format);
5846
+ this.endDate = this.globalize.parseDate(this.getAmPmValue(this.endDate), format);
5837
5847
  }
5838
5848
  this.firstHiddenChild.value = (this.startDate && this.globalize.formatDate(this.startDate, format))
5839
5849
  || (this.inputElement.value);
@@ -6008,7 +6018,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6008
6018
  break;
6009
6019
  case 'min':
6010
6020
  if ((isNullOrUndefined(this.min) || +this.min === +new Date(1900, 0, 1)) || isDynamic) {
6011
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6021
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6012
6022
  this.setProperties(setValue(prop, dateValue, {}), !isDynamic);
6013
6023
  }
6014
6024
  break;
@@ -6017,20 +6027,20 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6017
6027
  break;
6018
6028
  case 'max':
6019
6029
  if ((isNullOrUndefined(this.max) || +this.max === +new Date(2099, 11, 31)) || isDynamic) {
6020
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6030
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6021
6031
  this.setProperties(setValue(prop, dateValue, {}), !isDynamic);
6022
6032
  }
6023
6033
  break;
6024
6034
  case 'startDate':
6025
6035
  if (isNullOrUndefined(this.startDate)) {
6026
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6036
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6027
6037
  this.startValue = dateValue;
6028
6038
  this.setValue();
6029
6039
  }
6030
6040
  break;
6031
6041
  case 'endDate':
6032
6042
  if (isNullOrUndefined(this.endDate)) {
6033
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6043
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6034
6044
  this.endValue = dateValue;
6035
6045
  this.setValue();
6036
6046
  }
@@ -6265,8 +6275,8 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6265
6275
  if (range.length > 1) {
6266
6276
  this.invalidValueString = null;
6267
6277
  const dateOptions = { format: this.formatString, type: 'date', skeleton: 'yMd' };
6268
- const start = this.globalize.parseDate(range[0], dateOptions);
6269
- const end = this.globalize.parseDate(range[1], dateOptions);
6278
+ const start = this.globalize.parseDate(this.getAmPmValue(range[0]), dateOptions);
6279
+ const end = this.globalize.parseDate(this.getAmPmValue(range[1]), dateOptions);
6270
6280
  const startDate = this.getStartEndDate(start, false, range, dateOptions);
6271
6281
  const endDate = this.getStartEndDate(end, true, range, dateOptions);
6272
6282
  if (!isNullOrUndefined(startDate) && !isNaN(+startDate) && !isNullOrUndefined(endDate) && !isNaN(+endDate)) {
@@ -6342,7 +6352,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6342
6352
  }
6343
6353
  getStartEndDate(date, isEnd, range, dateOptions) {
6344
6354
  if (this.depth === 'Month') {
6345
- return this.globalize.parseDate(range[isEnd ? 1 : 0].trim(), dateOptions);
6355
+ return this.globalize.parseDate(this.getAmPmValue(range[isEnd ? 1 : 0]).trim(), dateOptions);
6346
6356
  }
6347
6357
  else if (this.depth === 'Year' && !isNullOrUndefined(date)) {
6348
6358
  return new Date(date.getFullYear(), date.getMonth() + (isEnd ? 1 : 0), isEnd ? 0 : 1);
@@ -9534,6 +9544,20 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9534
9544
  this.updateHeader();
9535
9545
  }
9536
9546
  }
9547
+ getAmPmValue(date) {
9548
+ try {
9549
+ if (typeof date === 'string' && date.trim() !== '') {
9550
+ // Replace am/pm variants with uppercase AM/PM
9551
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, (match) => match.toLocaleUpperCase());
9552
+ }
9553
+ // If date is null, undefined, or an empty string, return a default value or empty string
9554
+ return '';
9555
+ }
9556
+ catch (error) {
9557
+ console.error('Error occurred while processing date:', error);
9558
+ return ''; // Return a default value in case of an error
9559
+ }
9560
+ }
9537
9561
  getStartEndValue(date, isEnd) {
9538
9562
  if (this.depth === 'Month') {
9539
9563
  return this.checkDateValue(new Date(this.checkValue(date)));
@@ -9633,7 +9657,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9633
9657
  break;
9634
9658
  case 'startDate':
9635
9659
  if (typeof newProp.startDate === 'string') {
9636
- newProp.startDate = this.globalize.parseDate(newProp.startDate, format);
9660
+ newProp.startDate = this.globalize.parseDate(this.getAmPmValue(newProp.startDate), format);
9637
9661
  }
9638
9662
  if (+this.initStartDate !== +newProp.startDate) {
9639
9663
  this.startValue = this.getStartEndValue(newProp.startDate, false);
@@ -9643,7 +9667,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9643
9667
  break;
9644
9668
  case 'endDate':
9645
9669
  if (typeof newProp.endDate === 'string') {
9646
- newProp.endDate = this.globalize.parseDate(newProp.endDate, format);
9670
+ newProp.endDate = this.globalize.parseDate(this.getAmPmValue(newProp.endDate), format);
9647
9671
  }
9648
9672
  if (+this.initEndDate !== +newProp.endDate) {
9649
9673
  this.endValue = this.getStartEndValue(newProp.endDate, true);
@@ -10283,18 +10307,18 @@ let TimePicker = class TimePicker extends Component {
10283
10307
  if (!(/^[a-zA-Z0-9- ]*$/).test(value)) {
10284
10308
  valueExpression = this.setCurrentDate(this.getDateObject(value));
10285
10309
  if (isNullOrUndefined(valueExpression)) {
10286
- valueExpression = this.checkDateValue(this.globalize.parseDate(valueString, {
10310
+ valueExpression = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(valueString), {
10287
10311
  format: this.getCldrDateTimeFormat(), type: 'datetime'
10288
10312
  }));
10289
10313
  if (isNullOrUndefined(valueExpression)) {
10290
- valueExpression = this.checkDateValue(this.globalize.parseDate(valueString, {
10314
+ valueExpression = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(valueString), {
10291
10315
  format: this.formatString, type: 'dateTime', skeleton: 'yMd'
10292
10316
  }));
10293
10317
  }
10294
10318
  }
10295
10319
  }
10296
10320
  }
10297
- valueExp = this.globalize.parseDate(valueString, {
10321
+ valueExp = this.globalize.parseDate(this.getAmPmValue(valueString), {
10298
10322
  format: this.getCldrDateTimeFormat(), type: 'datetime'
10299
10323
  });
10300
10324
  valueExpression = (!isNullOrUndefined(valueExp) && valueExp instanceof Date && !isNaN(+valueExp)) ? valueExp : null;
@@ -10333,6 +10357,20 @@ let TimePicker = class TimePicker extends Component {
10333
10357
  }
10334
10358
  return modules;
10335
10359
  }
10360
+ getAmPmValue(date) {
10361
+ try {
10362
+ if (typeof date === 'string' && date.trim() !== '') {
10363
+ // Replace am/pm variants with uppercase AM/PM
10364
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, (match) => match.toLocaleUpperCase());
10365
+ }
10366
+ // If date is null, undefined, or an empty string, return a default value or empty string
10367
+ return '';
10368
+ }
10369
+ catch (error) {
10370
+ console.error('Error occurred while processing date:', error);
10371
+ return ''; // Return a default value in case of an error
10372
+ }
10373
+ }
10336
10374
  cldrFormat(type) {
10337
10375
  let cldrDateTimeString;
10338
10376
  if (this.locale === 'en' || this.locale === 'en-US') {
@@ -11833,10 +11871,10 @@ let TimePicker = class TimePicker extends Component {
11833
11871
  }
11834
11872
  timeParse(today, val) {
11835
11873
  let value;
11836
- value = this.globalize.parseDate(today + ' ' + val, {
11874
+ value = this.globalize.parseDate(this.getAmPmValue(today + ' ' + val), {
11837
11875
  format: this.cldrDateFormat() + ' ' + this.cldrTimeFormat(), type: 'datetime'
11838
11876
  });
11839
- value = isNullOrUndefined(value) ? this.globalize.parseDate(today + ' ' + val, {
11877
+ value = isNullOrUndefined(value) ? this.globalize.parseDate(this.getAmPmValue(today + ' ' + val), {
11840
11878
  format: this.cldrDateFormat() + ' ' + this.dateToNumeric(), type: 'datetime'
11841
11879
  }) : value;
11842
11880
  value = isNullOrUndefined(value) ? value : new Date(value.setMilliseconds(0));
@@ -13019,12 +13057,12 @@ let DateTimePicker = class DateTimePicker extends DatePicker {
13019
13057
  if (this.dateFormatString === '') {
13020
13058
  this.dateFormatString = this.cldrDateTimeFormat();
13021
13059
  }
13022
- dateObject = this.globalize.parseDate(this.inputElement.value, {
13060
+ dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
13023
13061
  format: this.dateFormatString, type: 'datetime'
13024
13062
  });
13025
13063
  }
13026
13064
  else {
13027
- dateObject = this.globalize.parseDate(this.inputElement.value, {
13065
+ dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
13028
13066
  format: this.cldrDateTimeFormat(), type: 'datetime', calendar: 'islamic'
13029
13067
  });
13030
13068
  }
@@ -14430,6 +14468,32 @@ class MaskedDateTime {
14430
14468
  this.parent.inputElement.setSelectionRange(start, end);
14431
14469
  }
14432
14470
  maskKeydownHandler(args) {
14471
+ if (args.e.key === 'Backspace') {
14472
+ const start = this.parent.inputElement.selectionStart;
14473
+ let formatText = '';
14474
+ if (this.validCharacters.indexOf(this.hiddenMask[start]) !== -1) {
14475
+ formatText = this.hiddenMask[start];
14476
+ }
14477
+ switch (formatText) {
14478
+ case 'd':
14479
+ this.dayTypeCount = Math.max(this.dayTypeCount - 1, 0);
14480
+ break;
14481
+ case 'M':
14482
+ this.monthTypeCount = Math.max(this.monthTypeCount - 1, 0);
14483
+ break;
14484
+ case 'H':
14485
+ case 'h':
14486
+ this.hourTypeCount = Math.max(this.hourTypeCount - 1, 0);
14487
+ break;
14488
+ case 'm':
14489
+ this.minuteTypeCount = Math.max(this.minuteTypeCount - 1, 0);
14490
+ break;
14491
+ case 's':
14492
+ this.secondTypeCount = Math.max(this.secondTypeCount - 1, 0);
14493
+ break;
14494
+ }
14495
+ return;
14496
+ }
14433
14497
  this.dayTypeCount = this.monthTypeCount = this.hourTypeCount = this.minuteTypeCount = this.secondTypeCount = 0;
14434
14498
  if (args.e.key === 'Delete') {
14435
14499
  this.isDeleteKey = true;