@wernfried/daterangepicker 5.4.1 → 5.4.3
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/API_Doc.md +4 -4
- package/README.md +8 -8
- package/dist/cjs/daterangepicker.cjs +34 -17
- 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 +34 -17
- 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 +34 -17
- 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;
|
|
@@ -2364,21 +2368,34 @@ function outerHeight(el, withMargin = false) {
|
|
|
2364
2368
|
const style = getComputedStyle(el);
|
|
2365
2369
|
return el.offsetHeight + parseFloat(style.marginTop) + parseFloat(style.marginBottom);
|
|
2366
2370
|
}
|
|
2367
|
-
function daterangepicker(
|
|
2368
|
-
if (
|
|
2369
|
-
return
|
|
2370
|
-
if (elements instanceof
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2371
|
+
function daterangepicker(element, options, callback) {
|
|
2372
|
+
if (element instanceof HTMLElement) {
|
|
2373
|
+
return new DateRangePicker(element, options || {}, callback);
|
|
2374
|
+
} else if (elements instanceof NodeList || element instanceof HTMLCollection) {
|
|
2375
|
+
const ret = [];
|
|
2376
|
+
for (const el of Array.from(element)) {
|
|
2377
|
+
if (el._daterangepicker && typeof el._daterangepicker.remove === "function")
|
|
2378
|
+
el._daterangepicker.remove();
|
|
2379
|
+
ret.push(new DateRangePicker(el, options || {}, callback));
|
|
2380
|
+
}
|
|
2381
|
+
return ret;
|
|
2382
|
+
} else if (typeof element === "string") {
|
|
2383
|
+
if (document.querySelectorAll(element).length > 1) {
|
|
2384
|
+
const ret = [];
|
|
2385
|
+
for (const el of Array.from(document.querySelectorAll(element))) {
|
|
2386
|
+
if (el._daterangepicker && typeof el._daterangepicker.remove === "function")
|
|
2387
|
+
el._daterangepicker.remove();
|
|
2388
|
+
ret.push(new DateRangePicker(el, options || {}, callback));
|
|
2389
|
+
}
|
|
2390
|
+
return ret;
|
|
2391
|
+
} else if (document.querySelectorAll(element).length === 1) {
|
|
2392
|
+
return new DateRangePicker(element, options || {}, callback);
|
|
2393
|
+
} else {
|
|
2394
|
+
return null;
|
|
2395
|
+
}
|
|
2396
|
+
} else {
|
|
2397
|
+
return null;
|
|
2398
|
+
}
|
|
2382
2399
|
}
|
|
2383
2400
|
function getDateRangePicker(target) {
|
|
2384
2401
|
if (typeof target === "string")
|