@wernfried/daterangepicker 5.2.13 → 5.2.14

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.
@@ -246,12 +246,14 @@ class DateRangePicker {
246
246
  this.maxSpan = null;
247
247
  console.warn(`Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'`);
248
248
  }
249
- if (this.defaultSpan && this.minSpan && this.minSpan > this.defaultSpan) {
250
- this.defaultSpan = null;
251
- console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'`);
252
- } else if (this.defaultSpan && this.maxSpan && this.maxSpan < this.defaultSpan) {
253
- this.defaultSpan = null;
254
- console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'`);
249
+ if (this.defaultSpan) {
250
+ if (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.maxSpan && this.maxSpan < this.defaultSpan) {
254
+ this.defaultSpan = null;
255
+ console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'`);
256
+ }
255
257
  }
256
258
  }
257
259
  if (this.timePicker) {
@@ -1082,10 +1084,14 @@ class DateRangePicker {
1082
1084
  }
1083
1085
  }
1084
1086
  if (this.minSpan) {
1085
- const minDate = startDate.plus(this.defaultSpan ?? this.minSpan);
1087
+ const minDate = startDate.plus(this.minSpan);
1086
1088
  if (endDate < minDate) {
1087
1089
  violation = { old: endDate, reason: "minSpan" };
1088
- endDate = endDate.plus({ seconds: Math.trunc(minDate.diff(endDate).as("seconds") / shiftStep) * shiftStep });
1090
+ if (this.defaultSpan) {
1091
+ endDate = endDate.plus({ seconds: Math.trunc(startDate.plus(this.defaultSpan).diff(endDate).as("seconds") / shiftStep) * shiftStep });
1092
+ } else {
1093
+ endDate = endDate.plus({ seconds: Math.trunc(minDate.diff(endDate).as("seconds") / shiftStep) * shiftStep });
1094
+ }
1089
1095
  if (endDate < minDate)
1090
1096
  endDate = endDate.plus(this.timePicker ? this.timePickerStepSize : { days: 1 });
1091
1097
  violation.new = endDate;
@@ -1380,7 +1386,7 @@ class DateRangePicker {
1380
1386
  if (this.maxSpan && (!this.maxDate || this.#startDate.plus(this.maxSpan) < this.maxDate))
1381
1387
  maxDate = this.#startDate.plus(this.maxSpan);
1382
1388
  if (this.minSpan && side === "end")
1383
- minLimit = this.#startDate.plus(this.defaultSpan ?? this.minSpan);
1389
+ minLimit = this.#startDate.plus(this.minSpan);
1384
1390
  if (side === "start") {
1385
1391
  selected = this.#startDate;
1386
1392
  minDate = this.minDate;