@wernfried/daterangepicker 5.2.12 → 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;
@@ -1127,8 +1133,12 @@ class DateRangePicker {
1127
1133
  this.triggerEvent(this.#events.onBeforeRenderTimePicker);
1128
1134
  this.renderTimePicker("start");
1129
1135
  this.renderTimePicker("end");
1130
- this.container.querySelectorAll(".calendar-time.end-time select").disabled = !this.#endDate;
1131
- this.container.querySelectorAll(".calendar-time.end-time select").classList.toggle("disabled", !this.#endDate);
1136
+ this.container.querySelectorAll(".calendar-time.end-time select").forEach((el) => {
1137
+ el.disabled = !this.#endDate;
1138
+ });
1139
+ this.container.querySelectorAll(".calendar-time.end-time select").forEach((el) => {
1140
+ el.classList.toggle("disabled", !this.#endDate);
1141
+ });
1132
1142
  }
1133
1143
  this.updateLabel();
1134
1144
  this.updateMonthsInView();
@@ -1376,7 +1386,7 @@ class DateRangePicker {
1376
1386
  if (this.maxSpan && (!this.maxDate || this.#startDate.plus(this.maxSpan) < this.maxDate))
1377
1387
  maxDate = this.#startDate.plus(this.maxSpan);
1378
1388
  if (this.minSpan && side === "end")
1379
- minLimit = this.#startDate.plus(this.defaultSpan ?? this.minSpan);
1389
+ minLimit = this.#startDate.plus(this.minSpan);
1380
1390
  if (side === "start") {
1381
1391
  selected = this.#startDate;
1382
1392
  minDate = this.minDate;