@wernfried/daterangepicker 5.2.5 → 5.2.7

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.
@@ -65,8 +65,7 @@ class DateRangePicker {
65
65
  };
66
66
  if (this.element == null)
67
67
  return;
68
- this.callback = function() {
69
- };
68
+ this.callback = null;
70
69
  this.isShowing = false;
71
70
  this.leftCalendar = {};
72
71
  this.rightCalendar = {};
@@ -764,7 +763,7 @@ class DateRangePicker {
764
763
  */
765
764
  setStartDate(startDate, updateView = true) {
766
765
  if (!this.singleDatePicker)
767
- return setRange(startDate, this.#endDate, updateView);
766
+ return this.setRange(startDate, this.#endDate, updateView);
768
767
  const oldDate = this.#startDate;
769
768
  let newDate = this.parseDate(startDate);
770
769
  if (newDate.equals(oldDate))
@@ -801,7 +800,7 @@ class DateRangePicker {
801
800
  * drp.setEndDate(DateTime.now().startOf('hour'));
802
801
  */
803
802
  setEndDate(endDate, updateView = true) {
804
- return this.singleDatePicker ? null : setRange(this.#startDate, endDate, updateView);
803
+ return this.singleDatePicker ? null : this.setRange(this.#startDate, endDate, updateView);
805
804
  }
806
805
  /**
807
806
  * Sets the date range picker's currently selected start date to the provided date.<br>
@@ -879,6 +878,8 @@ class DateRangePicker {
879
878
  * @returns {string} - Formatted date string
880
879
  */
881
880
  formatDate(date, format = this.locale.format) {
881
+ if (date === null)
882
+ return null;
882
883
  if (typeof format === "object") {
883
884
  return date.toLocaleString(format);
884
885
  } else {
@@ -1655,8 +1656,10 @@ class DateRangePicker {
1655
1656
  this.#startDate = this.oldStartDate;
1656
1657
  this.#endDate = this.oldEndDate;
1657
1658
  }
1658
- if (!this.#startDate.equals(this.oldStartDate ?? DateTime) || !this.#endDate.equals(this.oldEndDate ?? DateTime))
1659
- this.callback(this.startDate, this.endDate, this.chosenLabel);
1659
+ if (typeof this.callback === "function") {
1660
+ if (this.#startDate && !this.#startDate.equals(this.oldStartDate ?? DateTime) || this.#endDate && !this.singleDatePicker && !this.#endDate.equals(this.oldEndDate ?? DateTime))
1661
+ this.callback(this.startDate, this.endDate, this.chosenLabel);
1662
+ }
1660
1663
  this.updateElement();
1661
1664
  const event = this.triggerEvent(this.#events.onBeforeHide);
1662
1665
  if (event.defaultPrevented)