@wernfried/daterangepicker 5.5.2 → 5.6.0

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.
@@ -454,10 +454,10 @@ var DateRangePicker = (function(exports, luxon2) {
454
454
  this.buttonClasses = options.buttonClasses;
455
455
  }
456
456
  if (typeof options.onOutsideClick === "string") {
457
- if (["cancel", "apply"].includes(options.onOutsideClick))
457
+ if (["cancel", "apply", "hide"].includes(options.onOutsideClick))
458
458
  this.onOutsideClick = options.onOutsideClick;
459
459
  else
460
- console.error(`Option 'onOutsideClick' must be 'cancel' or 'apply'`);
460
+ console.error(`Option 'onOutsideClick' must be 'cancel', 'apply' or 'hide'`);
461
461
  }
462
462
  if (this.locale.firstDay != 1) {
463
463
  let iterator = this.locale.firstDay;
@@ -1698,14 +1698,10 @@ var DateRangePicker = (function(exports, luxon2) {
1698
1698
  */
1699
1699
  hide() {
1700
1700
  if (!this.isShowing) return;
1701
- if (!this.#endDate) {
1701
+ if (!this.#endDate && !this.singleDatePicker) {
1702
1702
  this.#startDate = this.oldStartDate;
1703
1703
  this.#endDate = this.oldEndDate;
1704
1704
  }
1705
- if (typeof this.callback === "function") {
1706
- if (this.#startDate && !this.#startDate.equals(this.oldStartDate ?? luxon2.DateTime) || this.#endDate && !this.singleDatePicker && !this.#endDate.equals(this.oldEndDate ?? luxon2.DateTime))
1707
- this.callback(this.startDate, this.endDate, this.chosenLabel);
1708
- }
1709
1705
  this.updateElement();
1710
1706
  const event = this.triggerEvent(this.#events.onBeforeHide);
1711
1707
  if (event.defaultPrevented)
@@ -1777,8 +1773,12 @@ var DateRangePicker = (function(exports, luxon2) {
1777
1773
  if (this.onOutsideClick === "cancel") {
1778
1774
  this.#startDate = this.oldStartDate;
1779
1775
  this.#endDate = this.oldEndDate;
1776
+ this.hide();
1777
+ } else if (this.onOutsideClick === "apply") {
1778
+ this.clickApply();
1779
+ } else {
1780
+ this.hide();
1780
1781
  }
1781
- this.hide();
1782
1782
  }
1783
1783
  /**
1784
1784
  * Move calendar to previous month
@@ -2141,6 +2141,11 @@ var DateRangePicker = (function(exports, luxon2) {
2141
2141
  * @private
2142
2142
  */
2143
2143
  clickApply() {
2144
+ this.updateElement();
2145
+ if (typeof this.callback === "function") {
2146
+ if (this.#startDate && (this.#endDate || !this.singleDatePicker))
2147
+ this.callback(this.startDate, this.endDate, this.chosenLabel);
2148
+ }
2144
2149
  this.hide();
2145
2150
  this.triggerEvent(this.#events.onApply);
2146
2151
  }