@wernfried/daterangepicker 5.8.0 → 5.8.1

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.
@@ -881,11 +881,29 @@ class DateRangePicker {
881
881
  * @param {sting|external:DateTime|Date} month - The month to be shown, if null then current month is selected.
882
882
  */
883
883
  clearDate(month) {
884
- const initialMonth = this.parseDate(month ?? this.#startDate.startOf("month"));
884
+ if (this.#startDate == null && this.#endDate == null)
885
+ return;
886
+ const monthChange = month !== void 0 && !this.parseDate(month).hasSame(this.#startDate, "month");
887
+ if (monthChange)
888
+ this.#startDate = this.parseDate(month);
889
+ this.updateMonthsInView();
885
890
  this.oldStartDate = this.#startDate;
886
891
  this.oldEndDate = this.#endDate;
887
892
  this.#startDate = null;
888
893
  this.#endDate = null;
894
+ this.updateCalendars(monthChange);
895
+ this.setApplyBtnState();
896
+ if (this.timePicker) {
897
+ this.triggerEvent(this.#events.onBeforeRenderTimePicker);
898
+ this.renderTimePicker("start");
899
+ this.renderTimePicker("end");
900
+ this.container.querySelectorAll(".calendar-time.end-time select").forEach((el) => {
901
+ el.disabled = !this.#endDate;
902
+ });
903
+ this.container.querySelectorAll(".calendar-time.end-time select").forEach((el) => {
904
+ el.classList.toggle("disabled", !this.#endDate);
905
+ });
906
+ }
889
907
  if (this.isInputText)
890
908
  this.element.value = "";
891
909
  if (!this.singleDatePicker)
@@ -898,7 +916,6 @@ class DateRangePicker {
898
916
  this.altInput[1].value = "";
899
917
  }
900
918
  }
901
- this.updateView(!initialMonth.hasSame(this.oldStartDate, "month"));
902
919
  }
903
920
  /**
904
921
  * Parse date value