@wernfried/daterangepicker 5.2.13 → 5.2.17

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.
@@ -247,12 +247,14 @@ var DateRangePicker = (function(exports, luxon2) {
247
247
  this.maxSpan = null;
248
248
  console.warn(`Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'`);
249
249
  }
250
- if (this.defaultSpan && this.minSpan && this.minSpan > this.defaultSpan) {
251
- this.defaultSpan = null;
252
- console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'`);
253
- } else if (this.defaultSpan && this.maxSpan && this.maxSpan < this.defaultSpan) {
254
- this.defaultSpan = null;
255
- console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'`);
250
+ if (this.defaultSpan) {
251
+ if (this.minSpan && this.minSpan > this.defaultSpan) {
252
+ this.defaultSpan = null;
253
+ console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'`);
254
+ } else if (this.maxSpan && this.maxSpan < this.defaultSpan) {
255
+ this.defaultSpan = null;
256
+ console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'`);
257
+ }
256
258
  }
257
259
  }
258
260
  if (this.timePicker) {
@@ -1083,10 +1085,14 @@ var DateRangePicker = (function(exports, luxon2) {
1083
1085
  }
1084
1086
  }
1085
1087
  if (this.minSpan) {
1086
- const minDate = startDate.plus(this.defaultSpan ?? this.minSpan);
1088
+ const minDate = startDate.plus(this.minSpan);
1087
1089
  if (endDate < minDate) {
1088
1090
  violation = { old: endDate, reason: "minSpan" };
1089
- endDate = endDate.plus({ seconds: Math.trunc(minDate.diff(endDate).as("seconds") / shiftStep) * shiftStep });
1091
+ if (this.defaultSpan) {
1092
+ endDate = startDate.plus({ seconds: Math.trunc(this.defaultSpan.as("seconds") / shiftStep) * shiftStep });
1093
+ } else {
1094
+ endDate = startDate.plus({ seconds: Math.trunc(this.minSpan.as("seconds") / shiftStep) * shiftStep });
1095
+ }
1090
1096
  if (endDate < minDate)
1091
1097
  endDate = endDate.plus(this.timePicker ? this.timePickerStepSize : { days: 1 });
1092
1098
  violation.new = endDate;
@@ -1381,7 +1387,7 @@ var DateRangePicker = (function(exports, luxon2) {
1381
1387
  if (this.maxSpan && (!this.maxDate || this.#startDate.plus(this.maxSpan) < this.maxDate))
1382
1388
  maxDate = this.#startDate.plus(this.maxSpan);
1383
1389
  if (this.minSpan && side === "end")
1384
- minLimit = this.#startDate.plus(this.defaultSpan ?? this.minSpan);
1390
+ minLimit = this.#startDate.plus(this.minSpan);
1385
1391
  if (side === "start") {
1386
1392
  selected = this.#startDate;
1387
1393
  minDate = this.minDate;
@@ -2036,8 +2042,14 @@ var DateRangePicker = (function(exports, luxon2) {
2036
2042
  this.#startDate = this.#startDate.set({ hour, minute, second });
2037
2043
  if (this.singleDatePicker) {
2038
2044
  this.#endDate = this.#startDate;
2039
- } else if (this.#endDate && this.#endDate.hasSame(this.#startDate, "day") && this.#endDate < this.#startDate) {
2040
- this.#endDate = this.#startDate;
2045
+ } else if (this.#endDate && this.#endDate.hasSame(this.#startDate, "day")) {
2046
+ if (this.defaultSpan && this.#endDate < this.#startDate.plus(this.minSpan)) {
2047
+ this.#endDate = this.#startDate.plus(this.defaultSpan);
2048
+ } else if (this.minSpan && this.#endDate < this.#startDate.plus(this.minSpan)) {
2049
+ this.#endDate = this.#startDate.plus(this.minSpan);
2050
+ } else if (this.#endDate < this.#startDate) {
2051
+ this.#endDate = this.#startDate;
2052
+ }
2041
2053
  }
2042
2054
  } else if (this.#endDate) {
2043
2055
  this.#endDate = this.#endDate.set({ hour, minute, second });