@wernfried/daterangepicker 5.3.7 → 5.4.1

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.
@@ -86,7 +86,7 @@ class DateRangePicker {
86
86
  dataOptions[name] = ts.isValid && isDate ? ts : JSON.parse(item.value);
87
87
  }
88
88
  options = { ...dataOptions, ...options };
89
- if (["string", "object"].includes(typeof options.button)) {
89
+ if (["string", "object"].includes(typeof options.button) && options.button != null) {
90
90
  let button = options.button;
91
91
  if (typeof button === "string" && document.querySelectorAll(button).length === 1)
92
92
  button = document.querySelector(button);
@@ -177,7 +177,7 @@ class DateRangePicker {
177
177
  else
178
178
  console.error(`Option 'locale.direction' must be 'rtl' or 'ltr'`);
179
179
  }
180
- if (["string", "object"].includes(typeof options.locale.format))
180
+ if (["string", "object"].includes(typeof options.locale.format) && options.locale.format !== null)
181
181
  this.locale.format = options.locale.format;
182
182
  if (Array.isArray(options.locale.daysOfWeek)) {
183
183
  if (options.locale.daysOfWeek.some((x) => typeof x !== "string"))
@@ -314,12 +314,12 @@ class DateRangePicker {
314
314
  if (opt === "endDate" && this.singleDatePicker)
315
315
  continue;
316
316
  if (typeof options[opt] === "object") {
317
- if (DateTime.isDateTime(options[opt]) && options[opt].isValid) {
317
+ if (options[opt] == null) {
318
+ this[opt] = null;
319
+ } else if (DateTime.isDateTime(options[opt])) {
318
320
  this[opt] = options[opt];
319
321
  } else if (options[opt] instanceof Date) {
320
322
  this[opt] = DateTime.fromJSDate(options[opt]);
321
- } else if (options[opt] === null) {
322
- this[opt] = null;
323
323
  } else {
324
324
  console.error(`Option '${opt}' must be a luxon.DateTime or Date or string`);
325
325
  }
@@ -457,7 +457,7 @@ class DateRangePicker {
457
457
  iterator--;
458
458
  }
459
459
  }
460
- if (!this.singleDatePicker && typeof options.ranges === "object") {
460
+ if (!this.singleDatePicker && typeof options.ranges === "object" && options.ranges != null) {
461
461
  for (let range in options.ranges) {
462
462
  let start, end;
463
463
  if (["string", "object"].includes(typeof options.ranges[range][0])) {
@@ -616,7 +616,7 @@ class DateRangePicker {
616
616
  * // -> Calendar selects and shows "today - 3 days"
617
617
  */
618
618
  onViolate: { type: "violate", param: (violation, newDate) => {
619
- return { ...violation, ...{ cancelable: true } };
619
+ return { ...violation, cancelable: true };
620
620
  } },
621
621
  /**
622
622
  * Emitted before the calendar time picker is rendered.
@@ -1334,7 +1334,7 @@ class DateRangePicker {
1334
1334
  html += `<th class="week">${this.locale.weekLabel}</th>`;
1335
1335
  for (let [index, dayOfWeek] of this.locale.daysOfWeek.entries()) {
1336
1336
  html += "<th";
1337
- if (this.weekendDayClasses && this.weekendDayClasses.length && Info.getWeekendWeekdays().includes(index + 1))
1337
+ if (this.weekendDayClasses && this.weekendDayClasses.length && Info.getWeekendWeekdays().includes(calendar[0][index].weekday))
1338
1338
  html += ` class="${this.weekendDayClasses}"`;
1339
1339
  html += `>${dayOfWeek}</th>`;
1340
1340
  }