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