@wernfried/daterangepicker 5.2.18 → 5.3.0
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 +13 -11
- package/README.md +12 -10
- package/dist/cjs/daterangepicker.cjs +35 -16
- 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 +35 -16
- 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 +35 -16
- 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
|
@@ -9,6 +9,8 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
9
9
|
this.parentEl = "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
|
+
this.button = null;
|
|
13
|
+
this.showOnClick = true;
|
|
12
14
|
this.#startDate = luxon2.DateTime.now().startOf("day");
|
|
13
15
|
this.#endDate = luxon2.DateTime.now().plus({ day: 1 }).startOf("day");
|
|
14
16
|
this.minDate = null;
|
|
@@ -85,6 +87,16 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
85
87
|
dataOptions[name] = ts.isValid && isDate ? ts : JSON.parse(item.value);
|
|
86
88
|
}
|
|
87
89
|
options = { ...dataOptions, ...options };
|
|
90
|
+
if (["string", "object"].includes(typeof options.button)) {
|
|
91
|
+
let button = options.button;
|
|
92
|
+
if (typeof button === "string" && document.querySelectorAll(button).length === 1)
|
|
93
|
+
button = document.querySelector(button);
|
|
94
|
+
if (button instanceof HTMLButtonElement) {
|
|
95
|
+
this.button = button;
|
|
96
|
+
} else {
|
|
97
|
+
console.error(`Option 'button' cannot resolved to a HTMLButtonElement`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
88
100
|
if (typeof options.singleDatePicker === "boolean")
|
|
89
101
|
this.singleDatePicker = options.singleDatePicker;
|
|
90
102
|
if (!this.singleDatePicker && typeof options.singleMonthView === "boolean") {
|
|
@@ -164,13 +176,13 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
164
176
|
if (["rtl", "ltr"].includes(options.locale.direction))
|
|
165
177
|
this.locale.direction = options.locale.direction;
|
|
166
178
|
else
|
|
167
|
-
console.error(`Option '
|
|
179
|
+
console.error(`Option 'locale.direction' must be 'rtl' or 'ltr'`);
|
|
168
180
|
}
|
|
169
181
|
if (["string", "object"].includes(typeof options.locale.format))
|
|
170
182
|
this.locale.format = options.locale.format;
|
|
171
183
|
if (Array.isArray(options.locale.daysOfWeek)) {
|
|
172
184
|
if (options.locale.daysOfWeek.some((x) => typeof x !== "string"))
|
|
173
|
-
console.error(`Option '
|
|
185
|
+
console.error(`Option 'locale.daysOfWeek' must be an array of strings`);
|
|
174
186
|
else
|
|
175
187
|
this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
|
|
176
188
|
}
|
|
@@ -202,7 +214,8 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
202
214
|
"alwaysShowCalendars",
|
|
203
215
|
"autoApply",
|
|
204
216
|
"autoUpdateInput",
|
|
205
|
-
"showLabel"
|
|
217
|
+
"showLabel",
|
|
218
|
+
"showOnClick"
|
|
206
219
|
]) {
|
|
207
220
|
if (typeof options[key2] === "boolean")
|
|
208
221
|
this[key2] = options[key2];
|
|
@@ -419,13 +432,13 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
419
432
|
if (["left", "right", "center"].includes(options.opens))
|
|
420
433
|
this.opens = options.opens;
|
|
421
434
|
else
|
|
422
|
-
console.error(`Option '
|
|
435
|
+
console.error(`Option 'opens' must be 'left', 'right' or 'center'`);
|
|
423
436
|
}
|
|
424
437
|
if (typeof options.drops === "string") {
|
|
425
438
|
if (["up", "down", "auto"].includes(options.drops))
|
|
426
439
|
this.drops = options.drops;
|
|
427
440
|
else
|
|
428
|
-
console.error(`Option '
|
|
441
|
+
console.error(`Option 'drops' must be 'up', 'down' or 'auto'`);
|
|
429
442
|
}
|
|
430
443
|
if (Array.isArray(options.buttonClasses)) {
|
|
431
444
|
this.buttonClasses = options.buttonClasses.join(" ");
|
|
@@ -436,7 +449,7 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
436
449
|
if (["cancel", "apply"].includes(options.onOutsideClick))
|
|
437
450
|
this.onOutsideClick = options.onOutsideClick;
|
|
438
451
|
else
|
|
439
|
-
console.error(`Option '
|
|
452
|
+
console.error(`Option 'onOutsideClick' must be 'cancel' or 'apply'`);
|
|
440
453
|
}
|
|
441
454
|
if (this.locale.firstDay != 1) {
|
|
442
455
|
let iterator = this.locale.firstDay;
|
|
@@ -526,15 +539,19 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
526
539
|
this.addListener(".ranges", "mouseleave", "li", this.leaveRange.bind(this));
|
|
527
540
|
this.addListener(".drp-buttons", "click", "button.applyBtn", this.clickApply.bind(this));
|
|
528
541
|
this.addListener(".drp-buttons", "click", "button.cancelBtn", this.clickCancel.bind(this));
|
|
529
|
-
if (this.
|
|
530
|
-
this.element.
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
542
|
+
if (this.showOnClick) {
|
|
543
|
+
if (this.element.matches("input") || this.element.matches("button")) {
|
|
544
|
+
this.element.addEventListener("click", this.#showProxy);
|
|
545
|
+
this.element.addEventListener("focus", this.#showProxy);
|
|
546
|
+
this.element.addEventListener("keyup", this.#elementChangedProxy);
|
|
547
|
+
this.element.addEventListener("keydown", this.#keydownProxy);
|
|
548
|
+
} else {
|
|
549
|
+
this.element.addEventListener("click", this.#toggleProxy);
|
|
550
|
+
this.element.addEventListener("keydown", this.#toggleProxy);
|
|
551
|
+
}
|
|
537
552
|
}
|
|
553
|
+
if (this.button)
|
|
554
|
+
this.button.addEventListener("click", this.#showProxy);
|
|
538
555
|
this.updateElement();
|
|
539
556
|
}
|
|
540
557
|
/**
|
|
@@ -1732,7 +1749,9 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
1732
1749
|
outsideClick(e) {
|
|
1733
1750
|
const target = e.target;
|
|
1734
1751
|
function closest2(el, selector) {
|
|
1735
|
-
|
|
1752
|
+
if (selector == null)
|
|
1753
|
+
return null;
|
|
1754
|
+
let parent = el;
|
|
1736
1755
|
while (parent) {
|
|
1737
1756
|
if (parent == selector)
|
|
1738
1757
|
return parent;
|
|
@@ -1742,7 +1761,7 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
1742
1761
|
}
|
|
1743
1762
|
if (
|
|
1744
1763
|
// ie modal dialog fix
|
|
1745
|
-
e.type === "focusin" || closest2(target, this.element) || closest2(target, this.container) || target.closest(".calendar-table")
|
|
1764
|
+
e.type === "focusin" || closest2(target, this.element) || closest2(target, this.container) || closest2(target, this.button) || target.closest(".calendar-table")
|
|
1746
1765
|
) return;
|
|
1747
1766
|
const event = this.triggerEvent(this.#events.onOutsideClick);
|
|
1748
1767
|
if (event.defaultPrevented)
|