@wernfried/daterangepicker 5.4.2 → 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.
@@ -2368,21 +2368,34 @@ function outerHeight(el, withMargin = false) {
2368
2368
  const style = getComputedStyle(el);
2369
2369
  return el.offsetHeight + parseFloat(style.marginTop) + parseFloat(style.marginBottom);
2370
2370
  }
2371
- function daterangepicker(elements, options, callback) {
2372
- if (typeof elements === "string")
2373
- return daterangepicker(document.querySelectorAll(elements), options, callback);
2374
- if (elements instanceof HTMLElement)
2375
- elements = [elements];
2376
- if (elements instanceof NodeList || elements instanceof HTMLCollection)
2377
- elements = Array.from(elements);
2378
- if (elements == null)
2379
- return new DateRangePicker(null, options || {}, callback);
2380
- elements.forEach((el) => {
2381
- if (el._daterangepicker && typeof el._daterangepicker.remove === "function")
2382
- el._daterangepicker.remove();
2383
- el._daterangepicker = new DateRangePicker(el, options || {}, callback);
2384
- });
2385
- return elements.length === 1 ? elements[0] : elements;
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
+ }
2386
2399
  }
2387
2400
  function getDateRangePicker(target) {
2388
2401
  if (typeof target === "string")