@wernfried/daterangepicker 5.3.8 → 5.4.2

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.
@@ -6,7 +6,7 @@ var DateRangePicker = (function(exports, luxon2) {
6
6
  constructor(element, options, cb) {
7
7
  if (typeof element === "string" && document.querySelectorAll(element).length > 1)
8
8
  throw new RangeError(`Option 'element' must match to one element only`);
9
- this.parentEl = "body";
9
+ this.parentEl = document.querySelector("body");
10
10
  this.element = element instanceof HTMLElement ? element : document.querySelector(element);
11
11
  this.isInputText = this.element instanceof HTMLInputElement && this.element.type === "text";
12
12
  this.button = null;
@@ -161,7 +161,11 @@ var DateRangePicker = (function(exports, luxon2) {
161
161
  options.template = template.join("");
162
162
  this.container = createElementFromHTML(options.template);
163
163
  }
164
- this.parentEl = document.querySelector(typeof options.parentEl === "string" ? options.parentEl : this.parentEl);
164
+ if (options.parentEl instanceof HTMLElement) {
165
+ this.parentEl = options.parentEl;
166
+ } else if (typeof options.parentEl === "string") {
167
+ this.parentEl = document.querySelector(options.parentEl) ?? this.parentEl;
168
+ }
165
169
  this.parentEl.appendChild(this.container);
166
170
  if (typeof options.timePicker === "boolean")
167
171
  this.timePicker = options.timePicker;
@@ -315,12 +319,12 @@ var DateRangePicker = (function(exports, luxon2) {
315
319
  if (opt === "endDate" && this.singleDatePicker)
316
320
  continue;
317
321
  if (typeof options[opt] === "object") {
318
- if (luxon2.DateTime.isDateTime(options[opt]) && options[opt].isValid) {
322
+ if (options[opt] == null) {
323
+ this[opt] = null;
324
+ } else if (luxon2.DateTime.isDateTime(options[opt])) {
319
325
  this[opt] = options[opt];
320
326
  } else if (options[opt] instanceof Date) {
321
327
  this[opt] = luxon2.DateTime.fromJSDate(options[opt]);
322
- } else if (options[opt] === null) {
323
- this[opt] = null;
324
328
  } else {
325
329
  console.error(`Option '${opt}' must be a luxon.DateTime or Date or string`);
326
330
  }
@@ -617,7 +621,7 @@ var DateRangePicker = (function(exports, luxon2) {
617
621
  * // -> Calendar selects and shows "today - 3 days"
618
622
  */
619
623
  onViolate: { type: "violate", param: (violation, newDate) => {
620
- return { ...violation, ...{ cancelable: true } };
624
+ return { ...violation, cancelable: true };
621
625
  } },
622
626
  /**
623
627
  * Emitted before the calendar time picker is rendered.
@@ -1335,7 +1339,7 @@ var DateRangePicker = (function(exports, luxon2) {
1335
1339
  html += `<th class="week">${this.locale.weekLabel}</th>`;
1336
1340
  for (let [index, dayOfWeek] of this.locale.daysOfWeek.entries()) {
1337
1341
  html += "<th";
1338
- if (this.weekendDayClasses && this.weekendDayClasses.length && luxon2.Info.getWeekendWeekdays().includes(index + 1))
1342
+ if (this.weekendDayClasses && this.weekendDayClasses.length && luxon2.Info.getWeekendWeekdays().includes(calendar[0][index].weekday))
1339
1343
  html += ` class="${this.weekendDayClasses}"`;
1340
1344
  html += `>${dayOfWeek}</th>`;
1341
1345
  }