@syncfusion/ej2-calendars 20.4.42 → 20.4.48

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.
@@ -3245,7 +3245,7 @@ let DatePicker = class DatePicker extends Calendar {
3245
3245
  this.createInput();
3246
3246
  this.updateHtmlAttributeToWrapper();
3247
3247
  this.setAllowEdit();
3248
- this.updateInput();
3248
+ this.updateInput(true);
3249
3249
  if (this.enableMask && !this.value && this.maskedDateValue && (this.floatLabelType == 'Always' || !this.floatLabelType || !this.placeholder)) {
3250
3250
  this.updateInputValue(this.maskedDateValue);
3251
3251
  }
@@ -3306,8 +3306,8 @@ let DatePicker = class DatePicker extends Calendar {
3306
3306
  }
3307
3307
  updateInput(isDynamic = false) {
3308
3308
  let formatOptions;
3309
- if (this.value && !this.isCalendar() && !isDynamic) {
3310
- this.disabledDates();
3309
+ if (this.value && !this.isCalendar()) {
3310
+ this.disabledDates(isDynamic);
3311
3311
  }
3312
3312
  if (isNaN(+new Date(this.checkValue(this.value)))) {
3313
3313
  this.setProperties({ value: null }, true);
@@ -4735,14 +4735,16 @@ let DatePicker = class DatePicker extends Calendar {
4735
4735
  getModuleName() {
4736
4736
  return 'datepicker';
4737
4737
  }
4738
- disabledDates() {
4738
+ disabledDates(isDynamic = false) {
4739
4739
  let formatOptions;
4740
4740
  let globalize;
4741
4741
  const valueCopy = this.checkDateValue(this.value) ? new Date(+this.value) : new Date(this.checkValue(this.value));
4742
4742
  const previousValCopy = this.previousDate;
4743
4743
  //calls the Calendar render method to check the disabled dates through renderDayCell event and update the input value accordingly.
4744
4744
  this.minMaxUpdates();
4745
- super.render();
4745
+ if (!isDynamic || (isDynamic && !isNullOrUndefined(this.renderDayCell))) {
4746
+ super.render();
4747
+ }
4746
4748
  this.previousDate = previousValCopy;
4747
4749
  const date = valueCopy && +(valueCopy);
4748
4750
  const dateIdString = '*[id^="/id"]'.replace('/id', '' + date);
@@ -4751,7 +4753,7 @@ let DatePicker = class DatePicker extends Calendar {
4751
4753
  this.setProperties({ value: valueCopy }, true);
4752
4754
  }
4753
4755
  }
4754
- if (!isNullOrUndefined(this.calendarElement.querySelectorAll(dateIdString)[0])) {
4756
+ if (!isNullOrUndefined(this.calendarElement) && !isNullOrUndefined(this.calendarElement.querySelectorAll(dateIdString)[0])) {
4755
4757
  if (this.calendarElement.querySelectorAll(dateIdString)[0].classList.contains('e-disabled')) {
4756
4758
  if (!this.strictMode) {
4757
4759
  this.currentDate = new Date(new Date().setHours(0, 0, 0, 0));
@@ -4812,8 +4814,8 @@ let DatePicker = class DatePicker extends Calendar {
4812
4814
  const isDisabledDate = this.calendarElement &&
4813
4815
  this.calendarElement.querySelectorAll(dateIdString)[0] &&
4814
4816
  this.calendarElement.querySelectorAll(dateIdString)[0].classList.contains('e-disabled');
4815
- if ((!isNullOrUndefined(this.value) && !(+new Date(+this.value).setMilliseconds(0) >= +this.min
4816
- && +new Date(+this.value).setMilliseconds(0) <= +this.max))
4817
+ if ((!isNullOrUndefined(this.value) && !isNullOrUndefined(this.min) && !isNullOrUndefined(this.max) && !(new Date(this.value).setMilliseconds(0) >= new Date(this.min).setMilliseconds(0)
4818
+ && new Date(this.value).setMilliseconds(0) <= new Date(this.max).setMilliseconds(0)))
4817
4819
  || (!this.strictMode && this.inputElement.value !== '' && this.inputElement.value !== this.maskedDateValue && isNullOrUndefined(this.value) || isDisabledDate)) {
4818
4820
  addClass([this.inputWrapper.container], ERROR);
4819
4821
  attributes(this.inputElement, { 'aria-invalid': 'true' });
@@ -5830,7 +5832,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
5830
5832
  this.createControl();
5831
5833
  this.bindCalendarEvents();
5832
5834
  this.updateRange((this.isMobile ? [this.calendarElement] : [this.leftCalendar, this.rightCalendar]));
5833
- if (!isNullOrUndefined(this.endValue) && !isNullOrUndefined(this.startValue) && !isNullOrUndefined(this.renderDayCell)) {
5835
+ if (!isNullOrUndefined(this.endValue) && !isNullOrUndefined(this.startValue) && !isNullOrUndefined(this.renderDayCellArgs) && this.renderDayCellArgs.isDisabled) {
5834
5836
  this.disabledDateRender();
5835
5837
  }
5836
5838
  this.updateHeader();
@@ -6001,8 +6003,10 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6001
6003
  if (range.length > 1) {
6002
6004
  this.invalidValueString = null;
6003
6005
  const dateOptions = { format: this.formatString, type: 'date', skeleton: 'yMd' };
6004
- const startDate = this.globalize.parseDate(range[0].trim(), dateOptions);
6005
- const endDate = this.globalize.parseDate(range[1].trim(), dateOptions);
6006
+ const start = new Date(range[0]);
6007
+ const end = new Date(range[1]);
6008
+ const startDate = this.getStartEndDate(start, false, range, dateOptions);
6009
+ const endDate = this.getStartEndDate(end, true, range, dateOptions);
6006
6010
  if (!isNullOrUndefined(startDate) && !isNaN(+startDate) && !isNullOrUndefined(endDate) && !isNaN(+endDate)) {
6007
6011
  const prevStartVal = this.startValue;
6008
6012
  this.startValue = startDate;
@@ -6074,6 +6078,17 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6074
6078
  }
6075
6079
  this.updateHiddenInput();
6076
6080
  }
6081
+ getStartEndDate(date, isEnd, range, dateOptions) {
6082
+ if (this.depth === 'Month') {
6083
+ return this.globalize.parseDate(range[isEnd ? 1 : 0].trim(), dateOptions);
6084
+ }
6085
+ else if (this.depth === 'Year') {
6086
+ return new Date(date.getFullYear(), date.getMonth() + (isEnd ? 1 : 0), isEnd ? 0 : 1);
6087
+ }
6088
+ else {
6089
+ return new Date(date.getFullYear(), isEnd ? 11 : 0, isEnd ? 31 : 1);
6090
+ }
6091
+ }
6077
6092
  clearRange() {
6078
6093
  this.previousStartValue = this.previousEndValue = null;
6079
6094
  this.currentDate = null;
@@ -6826,7 +6841,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
6826
6841
  if (!this.isMobile) {
6827
6842
  this.removeClassDisabled();
6828
6843
  }
6829
- if (!isNullOrUndefined(this.renderDayCell)) {
6844
+ if (!isNullOrUndefined(this.renderDayCellArgs) && this.renderDayCellArgs.isDisabled) {
6830
6845
  this.disabledDateRender();
6831
6846
  }
6832
6847
  this.trigger('select', this.rangeArgs(event));
@@ -8395,7 +8410,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
8395
8410
  if (!this.strictMode && (isDisabled)) {
8396
8411
  this.clearRange();
8397
8412
  }
8398
- if (!isNullOrUndefined(this.endValue) && !isNullOrUndefined(this.startValue) && !isDisabled && !isNullOrUndefined(this.renderDayCell)) {
8413
+ if (!isNullOrUndefined(this.endValue) && !isNullOrUndefined(this.startValue) && !isDisabled && !isNullOrUndefined(this.renderDayCellArgs) && this.renderDayCellArgs.isDisabled) {
8399
8414
  this.disabledDateRender();
8400
8415
  }
8401
8416
  this.errorClass();
@@ -8888,7 +8903,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
8888
8903
  if (!isNullOrUndefined(this.startValue) && !isNullOrUndefined(this.endValue)) {
8889
8904
  range = (Math.round(Math.abs((this.removeTimeValueFromDate(this.startValue).getTime() -
8890
8905
  this.removeTimeValueFromDate(this.endValue).getTime()) / (1000 * 60 * 60 * 24))) + 1);
8891
- if (!isNullOrUndefined(this.renderDayCell)) {
8906
+ if (!isNullOrUndefined(this.renderDayCellArgs) && this.renderDayCellArgs.isDisabled) {
8892
8907
  this.disabledDateRender();
8893
8908
  }
8894
8909
  if (!isNullOrUndefined(this.disabledDayCnt)) {
@@ -9140,6 +9155,17 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9140
9155
  this.updateHeader();
9141
9156
  }
9142
9157
  }
9158
+ getStartEndValue(date, isEnd) {
9159
+ if (this.depth === 'Month') {
9160
+ return this.checkDateValue(new Date(this.checkValue(date)));
9161
+ }
9162
+ else if (this.depth === 'Year') {
9163
+ return new Date(date.getFullYear(), date.getMonth() + (isEnd ? 1 : 0), isEnd ? 0 : 1);
9164
+ }
9165
+ else {
9166
+ return new Date(date.getFullYear(), isEnd ? 11 : 0, isEnd ? 31 : 1);
9167
+ }
9168
+ }
9143
9169
  /**
9144
9170
  * Called internally if any of the property value changed.
9145
9171
  *
@@ -9228,7 +9254,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9228
9254
  newProp.startDate = this.globalize.parseDate(newProp.startDate, format);
9229
9255
  }
9230
9256
  if (+this.initStartDate !== +newProp.startDate) {
9231
- this.startValue = this.checkDateValue(new Date(this.checkValue(newProp.startDate)));
9257
+ this.startValue = this.getStartEndValue(newProp.startDate, false);
9232
9258
  this.setDate();
9233
9259
  this.setValue();
9234
9260
  }
@@ -9238,7 +9264,7 @@ let DateRangePicker = class DateRangePicker extends CalendarBase {
9238
9264
  newProp.endDate = this.globalize.parseDate(newProp.endDate, format);
9239
9265
  }
9240
9266
  if (+this.initEndDate !== +newProp.endDate) {
9241
- this.endValue = this.checkDateValue(new Date(this.checkValue(newProp.endDate)));
9267
+ this.endValue = this.getStartEndValue(newProp.endDate, true);
9242
9268
  this.setDate();
9243
9269
  this.setValue();
9244
9270
  }
@@ -12192,7 +12218,7 @@ let DateTimePicker = class DateTimePicker extends DatePicker {
12192
12218
  module: "MaskedDateTime",
12193
12219
  });
12194
12220
  }
12195
- this.setValue();
12221
+ this.setValue(true);
12196
12222
  if (this.enableMask && !this.value && this.maskedDateValue && (this.floatLabelType == 'Always' || !this.floatLabelType || !this.placeholder)) {
12197
12223
  Input.setValue(this.maskedDateValue, this.inputElement, this.floatLabelType, this.showClearButton);
12198
12224
  }
@@ -12211,7 +12237,7 @@ let DateTimePicker = class DateTimePicker extends DatePicker {
12211
12237
  }
12212
12238
  this.renderComplete();
12213
12239
  }
12214
- setValue() {
12240
+ setValue(isDynamic = false) {
12215
12241
  this.initValue = this.validateMinMaxRange(this.value);
12216
12242
  if (!this.strictMode && this.isDateObject(this.initValue)) {
12217
12243
  const value = this.validateMinMaxRange(this.initValue);
@@ -12225,7 +12251,7 @@ let DateTimePicker = class DateTimePicker extends DatePicker {
12225
12251
  }
12226
12252
  }
12227
12253
  this.valueWithMinutes = this.value;
12228
- super.updateInput();
12254
+ super.updateInput(isDynamic);
12229
12255
  }
12230
12256
  validateMinMaxRange(value) {
12231
12257
  let result = value;