@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.
@@ -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;
@@ -2365,21 +2369,34 @@ var DateRangePicker = (function(exports, luxon2) {
2365
2369
  const style = getComputedStyle(el);
2366
2370
  return el.offsetHeight + parseFloat(style.marginTop) + parseFloat(style.marginBottom);
2367
2371
  }
2368
- function daterangepicker(elements, options, callback) {
2369
- if (typeof elements === "string")
2370
- return daterangepicker(document.querySelectorAll(elements), options, callback);
2371
- if (elements instanceof HTMLElement)
2372
- elements = [elements];
2373
- if (elements instanceof NodeList || elements instanceof HTMLCollection)
2374
- elements = Array.from(elements);
2375
- if (elements == null)
2376
- return new DateRangePicker2(null, options || {}, callback);
2377
- elements.forEach((el) => {
2378
- if (el._daterangepicker && typeof el._daterangepicker.remove === "function")
2379
- el._daterangepicker.remove();
2380
- el._daterangepicker = new DateRangePicker2(el, options || {}, callback);
2381
- });
2382
- return elements.length === 1 ? elements[0] : elements;
2372
+ function daterangepicker(element, options, callback) {
2373
+ if (element instanceof HTMLElement) {
2374
+ return new DateRangePicker2(element, options || {}, callback);
2375
+ } else if (elements instanceof NodeList || element instanceof HTMLCollection) {
2376
+ const ret = [];
2377
+ for (const el of Array.from(element)) {
2378
+ if (el._daterangepicker && typeof el._daterangepicker.remove === "function")
2379
+ el._daterangepicker.remove();
2380
+ ret.push(new DateRangePicker2(el, options || {}, callback));
2381
+ }
2382
+ return ret;
2383
+ } else if (typeof element === "string") {
2384
+ if (document.querySelectorAll(element).length > 1) {
2385
+ const ret = [];
2386
+ for (const el of Array.from(document.querySelectorAll(element))) {
2387
+ if (el._daterangepicker && typeof el._daterangepicker.remove === "function")
2388
+ el._daterangepicker.remove();
2389
+ ret.push(new DateRangePicker2(el, options || {}, callback));
2390
+ }
2391
+ return ret;
2392
+ } else if (document.querySelectorAll(element).length === 1) {
2393
+ return new DateRangePicker2(element, options || {}, callback);
2394
+ } else {
2395
+ return null;
2396
+ }
2397
+ } else {
2398
+ return null;
2399
+ }
2383
2400
  }
2384
2401
  function getDateRangePicker(target) {
2385
2402
  if (typeof target === "string")