@syncfusion/ej2-calendars 27.1.48 → 27.1.50

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
  }
@@ -4140,9 +4136,8 @@ let DatePicker = class DatePicker extends Calendar {
4140
4136
  this.inputElement.value = this.inputElement.value.trim();
4141
4137
  }
4142
4138
  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);
4139
+ if (this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions))) {
4140
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions);
4146
4141
  }
4147
4142
  else {
4148
4143
  if (this.calendarMode === 'Gregorian') {
@@ -4151,11 +4146,11 @@ let DatePicker = class DatePicker extends Calendar {
4151
4146
  else {
4152
4147
  formatOptions = { format: format, type: 'dateTime', skeleton: 'yMd', calendar: 'islamic' };
4153
4148
  }
4154
- date = this.globalize.parseDate(this.inputElement.value, formatOptions);
4149
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), formatOptions);
4155
4150
  }
4156
4151
  }
4157
4152
  else {
4158
- date = this.globalize.parseDate(this.inputElement.value, dateOptions);
4153
+ date = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), dateOptions);
4159
4154
  date = (!isNullOrUndefined(date) && isNaN(+date)) ? null : date;
4160
4155
  if (!isNullOrUndefined(this.formatString) && this.inputElement.value !== '' && this.strictMode) {
4161
4156
  if ((this.isPopupClicked || (!this.isPopupClicked && this.inputElement.value === this.previousElementValue))
@@ -4264,6 +4259,20 @@ let DatePicker = class DatePicker extends Calendar {
4264
4259
  this.popupObj.element.className += ' ' + this.cssClass;
4265
4260
  this.setAriaAttributes();
4266
4261
  }
4262
+ getAmPmValue(date) {
4263
+ try {
4264
+ if (typeof date === 'string' && date.trim() !== '') {
4265
+ // Replace am/pm variants with uppercase AM/PM
4266
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, (match) => match.toLocaleUpperCase());
4267
+ }
4268
+ // If date is null, undefined, or an empty string, return a default value or empty string
4269
+ return '';
4270
+ }
4271
+ catch (error) {
4272
+ console.error('Error occurred while processing date:', error);
4273
+ return ''; // Return a default value in case of an error
4274
+ }
4275
+ }
4267
4276
  CalendarSwipeHandler(e) {
4268
4277
  let direction = 0;
4269
4278
  if (this.iconRight) {
@@ -4943,19 +4952,19 @@ let DatePicker = class DatePicker extends Calendar {
4943
4952
  case 'value':
4944
4953
  if (((isNullOrUndefined(this.datepickerOptions) || (this.datepickerOptions['value'] === undefined)) || dynamic)) {
4945
4954
  const value = this.inputElement.getAttribute(prop);
4946
- this.setProperties(setValue(prop, this.globalize.parseDate(value, options), {}), !dynamic);
4955
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(value), options), {}), !dynamic);
4947
4956
  }
4948
4957
  break;
4949
4958
  case 'min':
4950
4959
  if ((+this.min === +new Date(1900, 0, 1)) || dynamic) {
4951
4960
  const min = this.inputElement.getAttribute(prop);
4952
- this.setProperties(setValue(prop, this.globalize.parseDate(min, options), {}), !dynamic);
4961
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(min), options), {}), !dynamic);
4953
4962
  }
4954
4963
  break;
4955
4964
  case 'max':
4956
4965
  if ((+this.max === +new Date(2099, 11, 31)) || dynamic) {
4957
4966
  const max = this.inputElement.getAttribute(prop);
4958
- this.setProperties(setValue(prop, this.globalize.parseDate(max, options), {}), !dynamic);
4967
+ this.setProperties(setValue(prop, this.globalize.parseDate(this.getAmPmValue(max), options), {}), !dynamic);
4959
4968
  }
4960
4969
  break;
4961
4970
  case 'type':
@@ -5830,10 +5839,10 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
5830
5839
  if (this.firstHiddenChild && this.secondHiddenChild) {
5831
5840
  const format = { format: this.formatString, type: 'datetime', skeleton: 'yMd' };
5832
5841
  if (typeof this.startDate === 'string') {
5833
- this.startDate = this.globalize.parseDate(this.startDate, format);
5842
+ this.startDate = this.globalize.parseDate(this.getAmPmValue(this.startDate), format);
5834
5843
  }
5835
5844
  if (typeof this.endDate === 'string') {
5836
- this.endDate = this.globalize.parseDate(this.endDate, format);
5845
+ this.endDate = this.globalize.parseDate(this.getAmPmValue(this.endDate), format);
5837
5846
  }
5838
5847
  this.firstHiddenChild.value = (this.startDate && this.globalize.formatDate(this.startDate, format))
5839
5848
  || (this.inputElement.value);
@@ -6008,7 +6017,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6008
6017
  break;
6009
6018
  case 'min':
6010
6019
  if ((isNullOrUndefined(this.min) || +this.min === +new Date(1900, 0, 1)) || isDynamic) {
6011
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6020
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6012
6021
  this.setProperties(setValue(prop, dateValue, {}), !isDynamic);
6013
6022
  }
6014
6023
  break;
@@ -6017,20 +6026,20 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6017
6026
  break;
6018
6027
  case 'max':
6019
6028
  if ((isNullOrUndefined(this.max) || +this.max === +new Date(2099, 11, 31)) || isDynamic) {
6020
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6029
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6021
6030
  this.setProperties(setValue(prop, dateValue, {}), !isDynamic);
6022
6031
  }
6023
6032
  break;
6024
6033
  case 'startDate':
6025
6034
  if (isNullOrUndefined(this.startDate)) {
6026
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6035
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6027
6036
  this.startValue = dateValue;
6028
6037
  this.setValue();
6029
6038
  }
6030
6039
  break;
6031
6040
  case 'endDate':
6032
6041
  if (isNullOrUndefined(this.endDate)) {
6033
- const dateValue = this.globalize.parseDate(this.inputElement.getAttribute(prop), format);
6042
+ const dateValue = this.globalize.parseDate(this.getAmPmValue(this.inputElement.getAttribute(prop)), format);
6034
6043
  this.endValue = dateValue;
6035
6044
  this.setValue();
6036
6045
  }
@@ -6265,8 +6274,8 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6265
6274
  if (range.length > 1) {
6266
6275
  this.invalidValueString = null;
6267
6276
  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);
6277
+ const start = this.globalize.parseDate(this.getAmPmValue(range[0]), dateOptions);
6278
+ const end = this.globalize.parseDate(this.getAmPmValue(range[1]), dateOptions);
6270
6279
  const startDate = this.getStartEndDate(start, false, range, dateOptions);
6271
6280
  const endDate = this.getStartEndDate(end, true, range, dateOptions);
6272
6281
  if (!isNullOrUndefined(startDate) && !isNaN(+startDate) && !isNullOrUndefined(endDate) && !isNaN(+endDate)) {
@@ -6342,7 +6351,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6342
6351
  }
6343
6352
  getStartEndDate(date, isEnd, range, dateOptions) {
6344
6353
  if (this.depth === 'Month') {
6345
- return this.globalize.parseDate(range[isEnd ? 1 : 0].trim(), dateOptions);
6354
+ return this.globalize.parseDate(this.getAmPmValue(range[isEnd ? 1 : 0]).trim(), dateOptions);
6346
6355
  }
6347
6356
  else if (this.depth === 'Year' && !isNullOrUndefined(date)) {
6348
6357
  return new Date(date.getFullYear(), date.getMonth() + (isEnd ? 1 : 0), isEnd ? 0 : 1);
@@ -9534,6 +9543,20 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9534
9543
  this.updateHeader();
9535
9544
  }
9536
9545
  }
9546
+ getAmPmValue(date) {
9547
+ try {
9548
+ if (typeof date === 'string' && date.trim() !== '') {
9549
+ // Replace am/pm variants with uppercase AM/PM
9550
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, (match) => match.toLocaleUpperCase());
9551
+ }
9552
+ // If date is null, undefined, or an empty string, return a default value or empty string
9553
+ return '';
9554
+ }
9555
+ catch (error) {
9556
+ console.error('Error occurred while processing date:', error);
9557
+ return ''; // Return a default value in case of an error
9558
+ }
9559
+ }
9537
9560
  getStartEndValue(date, isEnd) {
9538
9561
  if (this.depth === 'Month') {
9539
9562
  return this.checkDateValue(new Date(this.checkValue(date)));
@@ -9633,7 +9656,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9633
9656
  break;
9634
9657
  case 'startDate':
9635
9658
  if (typeof newProp.startDate === 'string') {
9636
- newProp.startDate = this.globalize.parseDate(newProp.startDate, format);
9659
+ newProp.startDate = this.globalize.parseDate(this.getAmPmValue(newProp.startDate), format);
9637
9660
  }
9638
9661
  if (+this.initStartDate !== +newProp.startDate) {
9639
9662
  this.startValue = this.getStartEndValue(newProp.startDate, false);
@@ -9643,7 +9666,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9643
9666
  break;
9644
9667
  case 'endDate':
9645
9668
  if (typeof newProp.endDate === 'string') {
9646
- newProp.endDate = this.globalize.parseDate(newProp.endDate, format);
9669
+ newProp.endDate = this.globalize.parseDate(this.getAmPmValue(newProp.endDate), format);
9647
9670
  }
9648
9671
  if (+this.initEndDate !== +newProp.endDate) {
9649
9672
  this.endValue = this.getStartEndValue(newProp.endDate, true);
@@ -10283,18 +10306,18 @@ let TimePicker = class TimePicker extends Component {
10283
10306
  if (!(/^[a-zA-Z0-9- ]*$/).test(value)) {
10284
10307
  valueExpression = this.setCurrentDate(this.getDateObject(value));
10285
10308
  if (isNullOrUndefined(valueExpression)) {
10286
- valueExpression = this.checkDateValue(this.globalize.parseDate(valueString, {
10309
+ valueExpression = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(valueString), {
10287
10310
  format: this.getCldrDateTimeFormat(), type: 'datetime'
10288
10311
  }));
10289
10312
  if (isNullOrUndefined(valueExpression)) {
10290
- valueExpression = this.checkDateValue(this.globalize.parseDate(valueString, {
10313
+ valueExpression = this.checkDateValue(this.globalize.parseDate(this.getAmPmValue(valueString), {
10291
10314
  format: this.formatString, type: 'dateTime', skeleton: 'yMd'
10292
10315
  }));
10293
10316
  }
10294
10317
  }
10295
10318
  }
10296
10319
  }
10297
- valueExp = this.globalize.parseDate(valueString, {
10320
+ valueExp = this.globalize.parseDate(this.getAmPmValue(valueString), {
10298
10321
  format: this.getCldrDateTimeFormat(), type: 'datetime'
10299
10322
  });
10300
10323
  valueExpression = (!isNullOrUndefined(valueExp) && valueExp instanceof Date && !isNaN(+valueExp)) ? valueExp : null;
@@ -10333,6 +10356,20 @@ let TimePicker = class TimePicker extends Component {
10333
10356
  }
10334
10357
  return modules;
10335
10358
  }
10359
+ getAmPmValue(date) {
10360
+ try {
10361
+ if (typeof date === 'string' && date.trim() !== '') {
10362
+ // Replace am/pm variants with uppercase AM/PM
10363
+ return date.replace(/(am|pm|Am|aM|pM|Pm)/g, (match) => match.toLocaleUpperCase());
10364
+ }
10365
+ // If date is null, undefined, or an empty string, return a default value or empty string
10366
+ return '';
10367
+ }
10368
+ catch (error) {
10369
+ console.error('Error occurred while processing date:', error);
10370
+ return ''; // Return a default value in case of an error
10371
+ }
10372
+ }
10336
10373
  cldrFormat(type) {
10337
10374
  let cldrDateTimeString;
10338
10375
  if (this.locale === 'en' || this.locale === 'en-US') {
@@ -11833,10 +11870,10 @@ let TimePicker = class TimePicker extends Component {
11833
11870
  }
11834
11871
  timeParse(today, val) {
11835
11872
  let value;
11836
- value = this.globalize.parseDate(today + ' ' + val, {
11873
+ value = this.globalize.parseDate(this.getAmPmValue(today + ' ' + val), {
11837
11874
  format: this.cldrDateFormat() + ' ' + this.cldrTimeFormat(), type: 'datetime'
11838
11875
  });
11839
- value = isNullOrUndefined(value) ? this.globalize.parseDate(today + ' ' + val, {
11876
+ value = isNullOrUndefined(value) ? this.globalize.parseDate(this.getAmPmValue(today + ' ' + val), {
11840
11877
  format: this.cldrDateFormat() + ' ' + this.dateToNumeric(), type: 'datetime'
11841
11878
  }) : value;
11842
11879
  value = isNullOrUndefined(value) ? value : new Date(value.setMilliseconds(0));
@@ -13019,12 +13056,12 @@ let DateTimePicker = class DateTimePicker extends DatePicker {
13019
13056
  if (this.dateFormatString === '') {
13020
13057
  this.dateFormatString = this.cldrDateTimeFormat();
13021
13058
  }
13022
- dateObject = this.globalize.parseDate(this.inputElement.value, {
13059
+ dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
13023
13060
  format: this.dateFormatString, type: 'datetime'
13024
13061
  });
13025
13062
  }
13026
13063
  else {
13027
- dateObject = this.globalize.parseDate(this.inputElement.value, {
13064
+ dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
13028
13065
  format: this.cldrDateTimeFormat(), type: 'datetime', calendar: 'islamic'
13029
13066
  });
13030
13067
  }