@wernfried/daterangepicker 4.18.0 → 4.19.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 +22 -13
- package/README.md +6 -40
- package/dist/esm/daterangepicker.js +45 -33
- package/dist/esm/daterangepicker.min.js +1 -1
- package/dist/global/daterangepicker.js +45 -33
- package/dist/global/daterangepicker.min.js +1 -1
- package/package.json +1 -1
package/API_Doc.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
## Events
|
|
9
9
|
|
|
10
10
|
<dl>
|
|
11
|
-
<dt><a href="#
|
|
11
|
+
<dt><a href="#event_violate.daterangepicker">"violate.daterangepicker" (picker, result, newDate)</a> ⇒ <code>boolean</code></dt>
|
|
12
12
|
<dd><p>Emitted when the date is changed through <code><input></code> element or via <a href="#DateRangePicker+setStartDate">setStartDate</a> or
|
|
13
13
|
<a href="#DateRangePicker+setRange">setRange</a> and date is not valid due to
|
|
14
14
|
<code>minDate</code>, <code>maxDate</code>, <code>minSpan</code>, <code>maxSpan</code>, <code>invalidDate</code> and <code>invalidTime</code> constraints.<br>
|
|
@@ -51,10 +51,10 @@ Only useful when <a href="#Ranges">Ranges</a> are used.</p>
|
|
|
51
51
|
<dt><a href="#event_cancel.daterangepicker">"cancel.daterangepicker" (this)</a></dt>
|
|
52
52
|
<dd><p>Emitted when the <code>Cancel</code> button is clicked</p>
|
|
53
53
|
</dd>
|
|
54
|
-
<dt><a href="#
|
|
54
|
+
<dt><a href="#event_inputChange.daterangepicker">"inputChange.daterangepicker" (this)</a></dt>
|
|
55
55
|
<dd><p>Emitted when the date is changed through <code><input></code> element. Event is only triggered when date string is valid and date value has changed</p>
|
|
56
56
|
</dd>
|
|
57
|
-
<dt><a href="#
|
|
57
|
+
<dt><a href="#event_monthViewChange.daterangepicker">"monthViewChange.daterangepicker" (this, left, right)</a></dt>
|
|
58
58
|
<dd><p>Emitted after month view changed, for example by click on 'prev' or 'next'</p>
|
|
59
59
|
</dd>
|
|
60
60
|
<dt><a href="#event_beforeRenderTimePicker.daterangepicker">"beforeRenderTimePicker.daterangepicker" (this)</a></dt>
|
|
@@ -92,13 +92,14 @@ Ranges are not validated against <code>minDate</code>, <code>maxDate</code>, <co
|
|
|
92
92
|
* _instance_
|
|
93
93
|
* [.startDate](#DateRangePicker+startDate) : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
94
94
|
* [.endDate](#DateRangePicker+endDate) : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
95
|
+
* [.events](#DateRangePicker+events)
|
|
95
96
|
* [.setStartDate(startDate, updateView)](#DateRangePicker+setStartDate) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
96
97
|
* [.setEndDate(endDate, updateView)](#DateRangePicker+setEndDate) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
97
98
|
* [.setRange(startDate, endDate, updateView)](#DateRangePicker+setRange) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
98
99
|
* [.parseDate(value)](#DateRangePicker+parseDate) ⇒ [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
99
100
|
* [.formatDate(date, format)](#DateRangePicker+formatDate) ⇒ <code>string</code>
|
|
100
101
|
* [.validateInput(range, dipatch)](#DateRangePicker+validateInput) ⇒ [<code>InputViolation</code>](#InputViolation) \| <code>null</code>
|
|
101
|
-
* [.updateView(
|
|
102
|
+
* [.updateView(monthChange)](#DateRangePicker+updateView)
|
|
102
103
|
* [.show()](#DateRangePicker+show)
|
|
103
104
|
* [.hide()](#DateRangePicker+hide)
|
|
104
105
|
* [.toggle()](#DateRangePicker+toggle)
|
|
@@ -131,6 +132,12 @@ startDate
|
|
|
131
132
|
### dateRangePicker.endDate : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
132
133
|
endDate
|
|
133
134
|
|
|
135
|
+
**Kind**: instance property of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
136
|
+
<a name="DateRangePicker+events"></a>
|
|
137
|
+
|
|
138
|
+
### dateRangePicker.events
|
|
139
|
+
Getter for all DateRangePickerEvents
|
|
140
|
+
|
|
134
141
|
**Kind**: instance property of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
135
142
|
<a name="DateRangePicker+setStartDate"></a>
|
|
136
143
|
|
|
@@ -262,7 +269,7 @@ result => {
|
|
|
262
269
|
```
|
|
263
270
|
<a name="DateRangePicker+updateView"></a>
|
|
264
271
|
|
|
265
|
-
### dateRangePicker.updateView(
|
|
272
|
+
### dateRangePicker.updateView(monthChange)
|
|
266
273
|
Updates the picker when calendar is initiated or any date has been selected.
|
|
267
274
|
Could be useful after running [setStartDate](#DateRangePicker+setStartDate) or [setRange](#DateRangePicker+setEndDate)
|
|
268
275
|
|
|
@@ -271,7 +278,7 @@ Could be useful after running [setStartDate](#DateRangePicker+setStartDate) or [
|
|
|
271
278
|
|
|
272
279
|
| Param | Type | Description |
|
|
273
280
|
| --- | --- | --- |
|
|
274
|
-
|
|
|
281
|
+
| monthChange | <code>boolean</code> | If `true` then monthView changed |
|
|
275
282
|
|
|
276
283
|
<a name="DateRangePicker+show"></a>
|
|
277
284
|
|
|
@@ -339,9 +346,9 @@ Initiate a new DateRangePicker
|
|
|
339
346
|
| options | [<code>Options</code>](#Options) | Object to configure the DateRangePicker |
|
|
340
347
|
| callback | [<code>callback</code>](#callback) | Callback function executed when date is changed.<br> Callback function is executed if selected date values has changed, before picker is hidden and before the attached `<input>` element is updated. As alternative listen to the ["apply.daterangepicker"](#event_apply.daterangepicker) event |
|
|
341
348
|
|
|
342
|
-
<a name="
|
|
349
|
+
<a name="event_violate.daterangepicker"></a>
|
|
343
350
|
|
|
344
|
-
## "
|
|
351
|
+
## "violate.daterangepicker" (picker, result, newDate) ⇒ <code>boolean</code>
|
|
345
352
|
Emitted when the date is changed through `<input>` element or via [setStartDate](#DateRangePicker+setStartDate) or
|
|
346
353
|
[setRange](#DateRangePicker+setRange) and date is not valid due to
|
|
347
354
|
`minDate`, `maxDate`, `minSpan`, `maxSpan`, `invalidDate` and `invalidTime` constraints.<br>
|
|
@@ -367,7 +374,7 @@ $('#picker').daterangepicker({
|
|
|
367
374
|
locale: {
|
|
368
375
|
format: DateTime.DATETIME_SHORT
|
|
369
376
|
}
|
|
370
|
-
}).on('
|
|
377
|
+
}).on('violate.daterangepicker', (ev, picker, result, newDate) => {
|
|
371
378
|
newDate.startDate = DateTime.now().minus({ days: 3 }).startOf('day');
|
|
372
379
|
return true;
|
|
373
380
|
});
|
|
@@ -515,9 +522,9 @@ Emitted when the `Cancel` button is clicked
|
|
|
515
522
|
| --- | --- | --- |
|
|
516
523
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
517
524
|
|
|
518
|
-
<a name="
|
|
525
|
+
<a name="event_inputChange.daterangepicker"></a>
|
|
519
526
|
|
|
520
|
-
## "
|
|
527
|
+
## "inputChange.daterangepicker" (this)
|
|
521
528
|
Emitted when the date is changed through `<input>` element. Event is only triggered when date string is valid and date value has changed
|
|
522
529
|
|
|
523
530
|
**Kind**: event emitted
|
|
@@ -526,9 +533,9 @@ Emitted when the date is changed through `<input>` element. Event is only trigge
|
|
|
526
533
|
| --- | --- | --- |
|
|
527
534
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
528
535
|
|
|
529
|
-
<a name="
|
|
536
|
+
<a name="event_monthViewChange.daterangepicker"></a>
|
|
530
537
|
|
|
531
|
-
## "
|
|
538
|
+
## "monthViewChange.daterangepicker" (this, left, right)
|
|
532
539
|
Emitted after month view changed, for example by click on 'prev' or 'next'
|
|
533
540
|
|
|
534
541
|
**Kind**: event emitted
|
|
@@ -536,6 +543,8 @@ Emitted after month view changed, for example by click on 'prev' or 'next'
|
|
|
536
543
|
| Param | Type | Description |
|
|
537
544
|
| --- | --- | --- |
|
|
538
545
|
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
546
|
+
| left | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | For day of left-hand calendar |
|
|
547
|
+
| right | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| <code>null</code> | For day of right-hand calendar |
|
|
539
548
|
|
|
540
549
|
<a name="event_beforeRenderTimePicker.daterangepicker"></a>
|
|
541
550
|
|
package/README.md
CHANGED
|
@@ -20,8 +20,8 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
20
20
|
```html
|
|
21
21
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
22
22
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
23
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
24
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
23
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.19.0/dist/global/daterangepicker.min.js"></script>
|
|
24
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.19.0/css/daterangepicker.min.css" rel="stylesheet" />
|
|
25
25
|
|
|
26
26
|
<input type="text" id="picker" />
|
|
27
27
|
|
|
@@ -43,11 +43,11 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
43
43
|
"imports": {
|
|
44
44
|
"jquery": "https://cdn.jsdelivr.net/npm/jquery@4.0.0/+esm",
|
|
45
45
|
"luxon": "https://cdn.jsdelivr.net/npm/luxon@3.7.2/+esm",
|
|
46
|
-
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
46
|
+
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.19.0/+esm"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
50
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.19.0/css/daterangepicker.min.css" rel="stylesheet" />
|
|
51
51
|
|
|
52
52
|
<input type="text" id="picker" />
|
|
53
53
|
|
|
@@ -68,7 +68,7 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
68
68
|
```html
|
|
69
69
|
<script ...></script>
|
|
70
70
|
<link type="text/css" href="https://cdn.jsdelivr.net/npm/bulma@1.0.4/css/bulma.min.css" rel="stylesheet" />
|
|
71
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
71
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.19.0/css/daterangepicker.bulma.min.css" rel="stylesheet" />
|
|
72
72
|
|
|
73
73
|
<input type="text" id="picker" />
|
|
74
74
|
|
|
@@ -222,41 +222,7 @@ You can style this daterangepicker with [Bulma CSS Framework](https://bulma.io/)
|
|
|
222
222
|
|
|
223
223
|
## Methods
|
|
224
224
|
|
|
225
|
-
Available methods are listed
|
|
226
|
-
* [.daterangepicker(options, callback)](#DateRangePicker.daterangepicker)
|
|
227
|
-
* [.setStartDate(startDate)](#DateRangePicker+setStartDate)
|
|
228
|
-
* [.setRange(startDate, endDate)](#DateRangePicker+setRange)
|
|
229
|
-
* `$(...).data('daterangepicker')` to get the daterangepicker object
|
|
230
|
-
|
|
231
|
-
all other methods are used rarely.
|
|
232
|
-
|
|
233
|
-
### Differences between `moment` and `luxon` library
|
|
234
|
-
This table lists a few important differences between datarangepicker using moment and luxon. Check them carefully when you migrate from older daterangepicker.
|
|
235
|
-
|
|
236
|
-
| Parameter | moment | luxon |
|
|
237
|
-
| ----------------------- | --------------------------------------------------- | ----------------- |
|
|
238
|
-
| `locale.daysOfWeek` | [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] | [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ] |
|
|
239
|
-
| `locale.firstDay` | 0-6 (Sunday to Saturday) | 1 for Monday through 7 for Sunday |
|
|
240
|
-
| to ISO-8601 String | `toISOString()` | `toISO()` |
|
|
241
|
-
| to [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `toDate()` | `toJSDate()` |
|
|
242
|
-
| from ISO-8601 String | `moment(...)` | `DateIme.fromISO(...)` |
|
|
243
|
-
| from [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `moment(...)` | `DateIme.fromJSDate(...)` |
|
|
244
|
-
| current day | `moment()` | `DateTime.now()` |
|
|
245
|
-
| format to string | `format(...)` | `toFormat(...)` |
|
|
246
|
-
| format tokens | `'YYYY-MM-DD'` | `'yyyy-MM-dd'` |
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
## License
|
|
250
|
-
|
|
251
|
-
The MIT License (MIT)
|
|
252
|
-
|
|
253
|
-
Copyright (c) 2012-2019 Dan Grossman<br/>
|
|
254
|
-
Copyright (c) 2025 Wernfried Domscheit
|
|
255
|
-
|
|
256
|
-
Licensed under the [MIT license](LICENSE).
|
|
257
|
-
|
|
258
|
-
## API Documentation
|
|
259
|
-
[API Documentation](API_Doc.md)
|
|
225
|
+
Available methods are listed in detail at [API Documentation](API_Doc.md). You will mainly use
|
|
260
226
|
## Options
|
|
261
227
|
Options for DateRangePicker
|
|
262
228
|
|
|
@@ -542,7 +542,7 @@ class DateRangePicker {
|
|
|
542
542
|
* `minDate`, `maxDate`, `minSpan`, `maxSpan`, `invalidDate` and `invalidTime` constraints.<br>
|
|
543
543
|
* Event is only triggered when date string is valid and date value is changing<br>
|
|
544
544
|
* @event
|
|
545
|
-
* @name "
|
|
545
|
+
* @name "violate.daterangepicker"
|
|
546
546
|
* @param {DateRangePicker} picker - The daterangepicker object
|
|
547
547
|
* @param {InputViolation} result - The violation object, see example of `validateInput()`
|
|
548
548
|
* @param {Object} newDate - Object of {startDate, endDate}
|
|
@@ -558,7 +558,7 @@ class DateRangePicker {
|
|
|
558
558
|
* locale: {
|
|
559
559
|
* format: DateTime.DATETIME_SHORT
|
|
560
560
|
* }
|
|
561
|
-
* }).on('
|
|
561
|
+
* }).on('violate.daterangepicker', (ev, picker, result, newDate) => {
|
|
562
562
|
* newDate.startDate = DateTime.now().minus({ days: 3 }).startOf('day');
|
|
563
563
|
* return true;
|
|
564
564
|
* });
|
|
@@ -571,7 +571,7 @@ class DateRangePicker {
|
|
|
571
571
|
*
|
|
572
572
|
* // -> Calendar selects and shows "today - 3 days"
|
|
573
573
|
*/
|
|
574
|
-
|
|
574
|
+
onViolate: { type: "violate.daterangepicker", param: (...args) => [this, ...args] },
|
|
575
575
|
/**
|
|
576
576
|
* Emitted before the calendar time picker is rendered.
|
|
577
577
|
* @event
|
|
@@ -663,18 +663,26 @@ class DateRangePicker {
|
|
|
663
663
|
/**
|
|
664
664
|
* Emitted when the date is changed through `<input>` element. Event is only triggered when date string is valid and date value has changed
|
|
665
665
|
* @event
|
|
666
|
-
* @name "
|
|
666
|
+
* @name "inputChange.daterangepicker"
|
|
667
667
|
* @param {DateRangePicker} this - The daterangepicker object
|
|
668
668
|
*/
|
|
669
|
-
|
|
669
|
+
onInputChange: { type: "inputChange.daterangepicker", param: this },
|
|
670
670
|
/**
|
|
671
671
|
* Emitted after month view changed, for example by click on 'prev' or 'next'
|
|
672
672
|
* @event
|
|
673
|
-
* @name "
|
|
673
|
+
* @name "monthViewChange.daterangepicker"
|
|
674
674
|
* @param {DateRangePicker} this - The daterangepicker object
|
|
675
|
+
* @param {external:DateTime} left - For day of left-hand calendar
|
|
676
|
+
* @param {external:DateTime|null} right - For day of right-hand calendar
|
|
675
677
|
*/
|
|
676
|
-
|
|
678
|
+
onMonthViewChange: {
|
|
679
|
+
type: "monthViewChange.daterangepicker",
|
|
680
|
+
param: (left, right) => [this, left.startOf("month"), right ? right.startOf("month") : null]
|
|
681
|
+
}
|
|
677
682
|
};
|
|
683
|
+
/**
|
|
684
|
+
* Getter for all DateRangePickerEvents
|
|
685
|
+
*/
|
|
678
686
|
get events() {
|
|
679
687
|
return this.#events;
|
|
680
688
|
}
|
|
@@ -705,7 +713,7 @@ class DateRangePicker {
|
|
|
705
713
|
return violations;
|
|
706
714
|
}
|
|
707
715
|
}
|
|
708
|
-
const
|
|
716
|
+
const monthChange = !this.#startDate.hasSame(newDate, "month");
|
|
709
717
|
this.#startDate = newDate;
|
|
710
718
|
this.#endDate = this.#startDate;
|
|
711
719
|
if (!this.timePicker) {
|
|
@@ -714,7 +722,7 @@ class DateRangePicker {
|
|
|
714
722
|
}
|
|
715
723
|
this.updateElement();
|
|
716
724
|
if (updateView)
|
|
717
|
-
this.updateView(
|
|
725
|
+
this.updateView(monthChange);
|
|
718
726
|
return violations;
|
|
719
727
|
}
|
|
720
728
|
/**
|
|
@@ -761,7 +769,7 @@ class DateRangePicker {
|
|
|
761
769
|
return violations;
|
|
762
770
|
}
|
|
763
771
|
}
|
|
764
|
-
const
|
|
772
|
+
const monthChange = !this.#startDate.hasSame(newDate[0], "month") || !this.#endDate.hasSame(newDate[1], "month");
|
|
765
773
|
this.#startDate = newDate[0];
|
|
766
774
|
this.#endDate = newDate[1];
|
|
767
775
|
if (!this.timePicker) {
|
|
@@ -770,7 +778,7 @@ class DateRangePicker {
|
|
|
770
778
|
}
|
|
771
779
|
this.updateElement();
|
|
772
780
|
if (updateView)
|
|
773
|
-
this.updateView(
|
|
781
|
+
this.updateView(monthChange);
|
|
774
782
|
return violations;
|
|
775
783
|
}
|
|
776
784
|
/**
|
|
@@ -955,7 +963,7 @@ class DateRangePicker {
|
|
|
955
963
|
return null;
|
|
956
964
|
if (dipatch) {
|
|
957
965
|
let newValues = { startDate };
|
|
958
|
-
const ret = this.triggerHandler(this.#events.
|
|
966
|
+
const ret = this.triggerHandler(this.#events.onViolate, result, newValues);
|
|
959
967
|
if (ret) {
|
|
960
968
|
result.newDate = newValues;
|
|
961
969
|
return result;
|
|
@@ -1031,7 +1039,7 @@ class DateRangePicker {
|
|
|
1031
1039
|
return null;
|
|
1032
1040
|
if (dipatch) {
|
|
1033
1041
|
let newValues = { startDate, endDate };
|
|
1034
|
-
const ret = this.triggerHandler(this.#events.
|
|
1042
|
+
const ret = this.triggerHandler(this.#events.onViolate, result, newValues);
|
|
1035
1043
|
if (ret) {
|
|
1036
1044
|
result.newDate = newValues;
|
|
1037
1045
|
return result;
|
|
@@ -1045,10 +1053,10 @@ class DateRangePicker {
|
|
|
1045
1053
|
/**
|
|
1046
1054
|
* Updates the picker when calendar is initiated or any date has been selected.
|
|
1047
1055
|
* Could be useful after running {@link #DateRangePicker+setStartDate|setStartDate} or {@link #DateRangePicker+setEndDate|setRange}
|
|
1048
|
-
* @param {boolean}
|
|
1056
|
+
* @param {boolean} monthChange - If `true` then monthView changed
|
|
1049
1057
|
* @emits "beforeRenderTimePicker.daterangepicker"
|
|
1050
1058
|
*/
|
|
1051
|
-
updateView(
|
|
1059
|
+
updateView(monthChange) {
|
|
1052
1060
|
if (this.timePicker) {
|
|
1053
1061
|
this.triggerEvent(this.#events.onBeforeRenderTimePicker);
|
|
1054
1062
|
this.renderTimePicker("start");
|
|
@@ -1061,7 +1069,7 @@ class DateRangePicker {
|
|
|
1061
1069
|
}
|
|
1062
1070
|
this.updateLabel();
|
|
1063
1071
|
this.updateMonthsInView();
|
|
1064
|
-
this.updateCalendars(
|
|
1072
|
+
this.updateCalendars(monthChange);
|
|
1065
1073
|
this.setApplyBtnState();
|
|
1066
1074
|
}
|
|
1067
1075
|
/**
|
|
@@ -1100,11 +1108,11 @@ class DateRangePicker {
|
|
|
1100
1108
|
/**
|
|
1101
1109
|
* Updates the selected day value from calendar with selected time values
|
|
1102
1110
|
* @emits "beforeRenderCalendar.daterangepicker"
|
|
1103
|
-
* @emits "
|
|
1104
|
-
* @param {boolean}
|
|
1111
|
+
* @emits "monthViewChange.daterangepicker"
|
|
1112
|
+
* @param {boolean} monthChange - If `true` then monthView changed
|
|
1105
1113
|
* @private
|
|
1106
1114
|
*/
|
|
1107
|
-
updateCalendars(
|
|
1115
|
+
updateCalendars(monthChange) {
|
|
1108
1116
|
if (this.timePicker) {
|
|
1109
1117
|
var hour, minute, second;
|
|
1110
1118
|
if (this.#endDate) {
|
|
@@ -1151,8 +1159,12 @@ class DateRangePicker {
|
|
|
1151
1159
|
this.triggerEvent(this.#events.onBeforeRenderCalendar);
|
|
1152
1160
|
this.renderCalendar("left");
|
|
1153
1161
|
this.renderCalendar("right");
|
|
1154
|
-
if (
|
|
1155
|
-
this.triggerEvent(
|
|
1162
|
+
if (monthChange)
|
|
1163
|
+
this.triggerEvent(
|
|
1164
|
+
this.#events.onMonthViewChange,
|
|
1165
|
+
this.leftCalendar.month,
|
|
1166
|
+
this.singleMonthView || this.singleDatePicker ? null : this.rightCalendar.month
|
|
1167
|
+
);
|
|
1156
1168
|
this.container.find(".ranges li").removeClass("active");
|
|
1157
1169
|
if (this.#endDate == null) return;
|
|
1158
1170
|
this.calculateChosenLabel();
|
|
@@ -1807,7 +1819,7 @@ class DateRangePicker {
|
|
|
1807
1819
|
this.showCalendars();
|
|
1808
1820
|
} else {
|
|
1809
1821
|
var newDate = this.ranges[label];
|
|
1810
|
-
const
|
|
1822
|
+
const monthChange = !this.#startDate.hasSame(newDate[0], "month") || !this.#endDate.hasSame(newDate[1], "month");
|
|
1811
1823
|
this.#startDate = newDate[0];
|
|
1812
1824
|
this.#endDate = newDate[1];
|
|
1813
1825
|
if (!this.timePicker) {
|
|
@@ -1817,7 +1829,7 @@ class DateRangePicker {
|
|
|
1817
1829
|
if (!this.alwaysShowCalendars)
|
|
1818
1830
|
this.hideCalendars();
|
|
1819
1831
|
if (this.triggerHandler(this.#events.onBeforeHide))
|
|
1820
|
-
this.updateView(
|
|
1832
|
+
this.updateView(monthChange);
|
|
1821
1833
|
this.clickApply();
|
|
1822
1834
|
}
|
|
1823
1835
|
}
|
|
@@ -2001,7 +2013,7 @@ class DateRangePicker {
|
|
|
2001
2013
|
var isLeft = $(e.target).closest(".drp-calendar").hasClass("left"), leftOrRight = isLeft ? "left" : "right", cal = this.container.find(".drp-calendar." + leftOrRight);
|
|
2002
2014
|
var month = parseInt(cal.find(".monthselect").val(), 10);
|
|
2003
2015
|
var year = cal.find(".yearselect").val();
|
|
2004
|
-
let
|
|
2016
|
+
let monthChange = false;
|
|
2005
2017
|
if (!isLeft) {
|
|
2006
2018
|
if (year < this.#startDate.year || year == this.#startDate.year && month < this.#startDate.month) {
|
|
2007
2019
|
month = this.#startDate.month;
|
|
@@ -2021,17 +2033,17 @@ class DateRangePicker {
|
|
|
2021
2033
|
}
|
|
2022
2034
|
}
|
|
2023
2035
|
if (isLeft) {
|
|
2024
|
-
|
|
2036
|
+
monthChange = !DateTime.fromObject({ year, month }).hasSame(this.leftCalendar.month, "month");
|
|
2025
2037
|
this.leftCalendar.month = this.leftCalendar.month.set({ year, month });
|
|
2026
2038
|
if (this.linkedCalendars)
|
|
2027
2039
|
this.rightCalendar.month = this.leftCalendar.month.plus({ month: 1 });
|
|
2028
2040
|
} else {
|
|
2029
|
-
|
|
2041
|
+
monthChange = !DateTime.fromObject({ year, month }).hasSame(this.leftCalendar.month, "month");
|
|
2030
2042
|
this.rightCalendar.month = this.rightCalendar.month.set({ year, month });
|
|
2031
2043
|
if (this.linkedCalendars)
|
|
2032
2044
|
this.leftCalendar.month = this.rightCalendar.month.minus({ month: 1 });
|
|
2033
2045
|
}
|
|
2034
|
-
this.updateCalendars(
|
|
2046
|
+
this.updateCalendars(monthChange);
|
|
2035
2047
|
}
|
|
2036
2048
|
/**
|
|
2037
2049
|
* User clicked `Apply` button
|
|
@@ -2057,7 +2069,7 @@ class DateRangePicker {
|
|
|
2057
2069
|
/**
|
|
2058
2070
|
* Update the picker with value from `<input>` element.<br>
|
|
2059
2071
|
* Input values must be given in format of `locale.format`. Invalid values are handles by `violated.daterangepicker` Event
|
|
2060
|
-
* @emits "
|
|
2072
|
+
* @emits "inputChange.daterangepicker"
|
|
2061
2073
|
* @private
|
|
2062
2074
|
*/
|
|
2063
2075
|
elementChanged() {
|
|
@@ -2065,7 +2077,7 @@ class DateRangePicker {
|
|
|
2065
2077
|
if (!this.element.val().length) return;
|
|
2066
2078
|
const format = typeof this.locale.format === "string" ? this.locale.format : DateTime.parseFormatForOpts(this.locale.format);
|
|
2067
2079
|
const dateString = this.element.val().split(this.locale.separator);
|
|
2068
|
-
let
|
|
2080
|
+
let monthChange = false;
|
|
2069
2081
|
if (this.singleDatePicker) {
|
|
2070
2082
|
let newDate = DateTime.fromFormat(this.element.val(), format, { locale: DateTime.now().locale });
|
|
2071
2083
|
const oldDate = this.#startDate;
|
|
@@ -2079,7 +2091,7 @@ class DateRangePicker {
|
|
|
2079
2091
|
return;
|
|
2080
2092
|
}
|
|
2081
2093
|
}
|
|
2082
|
-
|
|
2094
|
+
monthChange = !this.#startDate.hasSame(newDate, "month");
|
|
2083
2095
|
this.#startDate = newDate;
|
|
2084
2096
|
this.#endDate = this.#startDate;
|
|
2085
2097
|
if (!this.timePicker) {
|
|
@@ -2100,7 +2112,7 @@ class DateRangePicker {
|
|
|
2100
2112
|
return;
|
|
2101
2113
|
}
|
|
2102
2114
|
}
|
|
2103
|
-
|
|
2115
|
+
monthChange = !this.#startDate.hasSame(newDate[0], "month") || !this.#endDate.hasSame(newDate[1], "month");
|
|
2104
2116
|
this.#startDate = newDate[0];
|
|
2105
2117
|
this.#endDate = newDate[1];
|
|
2106
2118
|
if (!this.timePicker) {
|
|
@@ -2110,9 +2122,9 @@ class DateRangePicker {
|
|
|
2110
2122
|
} else {
|
|
2111
2123
|
return;
|
|
2112
2124
|
}
|
|
2113
|
-
this.updateView(
|
|
2125
|
+
this.updateView(monthChange);
|
|
2114
2126
|
this.updateElement();
|
|
2115
|
-
this.triggerEvent(this.#events.
|
|
2127
|
+
this.triggerEvent(this.#events.onInputChange);
|
|
2116
2128
|
}
|
|
2117
2129
|
/**
|
|
2118
2130
|
* Handles key press, IE 11 compatibility
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{DateTime as o,Duration as b,Info as C,Settings as x}from"luxon";import{$ as h}from"jquery";class I{#t=null;#e=null;constructor(s,t,n){this.parentEl="body",this.element=h(s),this.#t=o.now().startOf("day"),this.#e=o.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initalMonth=o.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=o.now().minus({year:100}).year,this.maxYear=o.now().plus({year:100}).year,this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.showLabel=!h(this.element).is("input:text"),this.timePicker=!1;const a=new Intl.DateTimeFormat(o.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=b.fromObject({minutes:1}),this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.isInvalidDate=null,this.isInvalidTime=null,this.isCustomDate=null,this.onOutsideClick="apply",this.opens=this.element.hasClass("pull-right")?"left":"right",this.drops=this.element.hasClass("dropup")?"up":"down",this.buttonClasses="btn btn-sm",this.applyButtonClasses="btn-primary",this.cancelButtonClasses="btn-default",this.weekendClasses="weekend",this.weekendDayClasses="weekend-day",this.todayClasses="today",this.altInput=null,this.altFormat=null,this.externalStyle=null,this.ranges={},this.locale={direction:"ltr",format:o.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:C.weekdays("short"),monthNames:C.months("long"),firstDay:C.getStartOfWeek(),durationFormat:null},this.callback=function(){},this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof t!="object"||t===null)&&(t={}),t=h.extend(this.element.data(),t),typeof t.singleDatePicker=="boolean"&&(this.singleDatePicker=t.singleDatePicker),!this.singleDatePicker&&typeof t.singleMonthView=="boolean"?this.singleMonthView=t.singleMonthView:this.singleMonthView=!1,typeof t.externalStyle=="string"&&["bulma"].includes(t.externalStyle)&&(this.externalStyle=t.externalStyle),typeof t.template!="string"&&!(t.template instanceof h)){let e=['<div class="daterangepicker">','<div class="ranges"></div>','<div class="drp-calendar left">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time start-time"></tr>'];this.singleMonthView&&e.push('<tr class="calendar-time end-time"></tr>'),e.push("</tfoot>","</table>","</div>"),e.push('<div class="drp-calendar right">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time end-time"></tr>',"</tfoot>","</table>","</div>"),e.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?e.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):e.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),e.push("</div></div>"),t.template=e.join("")}if(this.parentEl=t.parentEl&&h(t.parentEl).length?h(t.parentEl):h(this.parentEl),this.container=h(t.template).appendTo(this.parentEl),typeof t.timePicker=="boolean"&&(this.timePicker=t.timePicker),this.timePicker&&(this.locale.format=o.DATETIME_SHORT),typeof t.locale=="object"){for(let e of["separator","applyLabel","cancelLabel","weekLabel"])typeof t.locale[e]=="string"&&(this.locale[e]=t.locale[e]);if(typeof t.locale.direction=="string"&&(["rtl","ltr"].includes(t.locale.direction)?this.locale.direction=t.locale.direction:console.error("Option 'options.locale.direction' must be 'rtl' or 'ltr'")),["string","object"].includes(typeof t.locale.format)&&(this.locale.format=t.locale.format),Array.isArray(t.locale.daysOfWeek)&&(t.locale.daysOfWeek.some(e=>typeof e!="string")?console.error("Option 'options.locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=t.locale.daysOfWeek.slice()),Array.isArray(t.locale.monthNames)&&(t.locale.monthNames.some(e=>typeof e!="string")?console.error("Option 'locale.monthNames' must be an array of strings"):this.locale.monthNames=t.locale.monthNames.slice()),typeof t.locale.firstDay=="number"&&(this.locale.firstDay=t.locale.firstDay),typeof t.locale.customRangeLabel=="string"){var r=document.createElement("textarea");r.innerHTML=t.locale.customRangeLabel;var i=r.value;this.locale.customRangeLabel=i}["string","object","function"].includes(typeof t.locale.durationFormat)&&t.locale.durationFormat!=null&&(this.locale.durationFormat=t.locale.durationFormat)}this.container.addClass(this.locale.direction);for(let e of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel"])typeof t[e]=="boolean"&&(this[e]=t[e]);for(let e of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof t[e]=="string"?this[e]=t[e]:["weekendClasses","weekendDayClasses","todayClasses"].includes(e)&&t[e]===null&&(this[e]=t[e]);for(let e of["minYear","maxYear"])typeof t[e]=="number"&&(this[e]=t[e]);for(let e of["isInvalidDate","isInvalidTime","isCustomDate"])typeof t[e]=="function"?this[e]=t[e]:this[e]=function(){return!1};if(!this.singleDatePicker){for(let e of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof t[e])&&(b.isDuration(t[e])&&t[e].isValid?this[e]=t[e]:b.fromISO(t[e]).isValid?this[e]=b.fromISO(t[e]):typeof t[e]=="number"&&b.fromObject({seconds:t[e]}).isValid?this[e]=b.fromObject({seconds:t[e]}):t[e]===null?this[e]=null:console.error(`Option '${key}' is not valid`));this.minSpan&&this.maxSpan&&this.minSpan>this.maxSpan&&(this.minSpan=null,this.maxSpan=null,console.warn("Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'")),this.defaultSpan&&this.minSpan&&this.minSpan>this.defaultSpan?(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'")):this.defaultSpan&&this.maxSpan&&this.maxSpan<this.defaultSpan&&(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'"))}if(this.timePicker){if(typeof t.timePickerSeconds=="boolean"&&(this.timePickerStepSize=b.fromObject({[t.timePickerSeconds?"seconds":"minutes"]:1})),typeof t.timePickerIncrement=="number"&&(this.timePickerStepSize=b.fromObject({minutes:t.timePickerIncrement})),["string","object","number"].includes(typeof t.timePickerStepSize)){let e;b.isDuration(t.timePickerStepSize)&&t.timePickerStepSize.isValid?e=t.timePickerStepSize:b.fromISO(t.timePickerStepSize).isValid?e=b.fromISO(t.timePickerStepSize):typeof t.timePickerStepSize=="number"&&b.fromObject({seconds:t.timePickerStepSize}).isValid?e=b.fromObject({seconds:t.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),e=this.timePickerStepSize);var d=[];for(let l of["minutes","seconds"])d.push(...[1,2,3,4,5,6,10,12,15,20,30].map(c=>b.fromObject({[l]:c})));d.push(...[1,2,3,4,6].map(l=>b.fromObject({hours:l}))),this.timePicker24Hour&&d.push(...[8,12].map(l=>b.fromObject({hours:l}))),d.some(l=>e.rescale().equals(l))?this.timePickerStepSize=e.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(e.toObject())} is not valid`)}this.maxSpan&&this.timePickerStepSize>this.maxSpan&&console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`),this.timePickerOpts={showMinutes:this.timePickerStepSize<b.fromObject({hours:1}),showSeconds:this.timePickerStepSize<b.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=b.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=b.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let e of["startDate","endDate","minDate","maxDate","initalMonth"])if(!(e==="endDate"&&this.singleDatePicker)){if(typeof t[e]=="object")o.isDateTime(t[e])&&t[e].isValid?this[e]=t[e]:t[e]instanceof Date?this[e]=o.fromJSDate(t[e]):t[e]===null?this[e]=null:console.error(`Option '${e}' must be a luxon.DateTime or Date or string`);else if(typeof t[e]=="string"){const l=typeof this.locale.format=="string"?this.locale.format:o.parseFormatForOpts(this.locale.format);if(o.fromISO(t[e]).isValid)this[e]=o.fromISO(t[e]);else if(o.fromFormat(t[e],l,{locale:o.now().locale}).isValid)this[e]=o.fromFormat(t[e],l,{locale:o.now().locale});else{const c=o.fromFormat(t[e],l,{locale:o.now().locale}).invalidExplanation;console.error(`Option '${e}' is not a valid string: ${c}`)}}}if(h(this.element).is("input:text")){const e=h(this.element).val();if(e!=""){const l=typeof this.locale.format=="string"?this.locale.format:o.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof t.startDate>"u"){const c=o.fromFormat(e,l,{locale:o.now().locale});c.isValid?this.#t=c:console.error(`Value "${e}" in <input> is not a valid string: ${c.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof t.startDate>"u"&&typeof t.endDate>"u"){const c=e.split(this.locale.separator);if(c.length===2){const p=o.fromFormat(c[0],l,{locale:o.now().locale}),u=o.fromFormat(c[1],l,{locale:o.now().locale});p.isValid&&u.isValid?(this.#t=p,this.#e=u):console.error(`Value in <input> is not a valid string: ${p.invalidExplanation} - ${u.invalidExplanation}`)}else console.error(`Value "${e}" in <input> is not a valid string`)}}}if(this.singleDatePicker?this.#e=this.#t:this.#e<this.#t&&console.error(`Option 'endDate' ${this.#e} must not be earlier than 'startDate' ${this.#t}`),this.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day")),this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),t.warnings!==void 0&&console.warn("Option 'warnings' not used anymore. Listen to event 'violated.daterangepicker'"),!this.#t&&this.initalMonth)this.#e=null,this.timePicker&&console.error("Option 'initalMonth' works only with 'timePicker: false'");else{const e=this.validateInput(null,!1);if(e!=null){let l=e.startDate.violations;if(l.length>0)if(l.some(c=>c.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#t}" violates ${l.find(c=>c.reason.startsWith("isInvalid")).reason}`);else{const c=l.filter(p=>p.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#t} to ${c}`),this.#t=c}if(!this.singleDatePicker&&(l=e.endDate.violations.filter(c=>c.new!=null),l.length>0))if(l.some(c=>c.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#e}" violates ${l.find(c=>c.reason.startsWith("isInvalid")).reason}`);else{const c=l.filter(p=>p.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#e} to ${c}`),this.#e=c}}}if(["function","string"].includes(typeof t.altFormat)&&(this.altFormat=t.altFormat),typeof t.altInput=="string"||Array.isArray(t.altInput))if(this.singleDatePicker&&typeof t.altInput=="string")this.altInput=h(t.altInput).is("input:text")?t.altInput:null;else if(!this.singleDatePicker&&Array.isArray(t.altInput)&&t.altInput.length===2)this.altInput=t.altInput.every(e=>typeof e=="string"&&h(e).is("input:text"))?t.altInput:null;else{const e='Value of "altInput" must be '+(this.singleDatePicker?"a string":"an array of two string elements");console.error(`Option 'altInput' ${JSON.stringify(t.altInput)} is not valid
|
|
2
|
-
`,e)}if(typeof t.opens=="string"&&(["left","right","center"].includes(t.opens)?this.opens=t.opens:console.error("Option 'options.opens' must be 'left', 'right' or 'center'")),typeof t.drops=="string"&&(["drop","down","auto"].includes(t.drops)?this.drops=t.drops:console.error("Option 'options.drops' must be 'drop', 'down' or 'auto'")),Array.isArray(t.buttonClasses)?this.buttonClasses=t.buttonClasses.join(" "):typeof t.buttonClasses=="string"&&(this.buttonClasses=t.buttonClasses),typeof t.onOutsideClick=="string"&&(["cancel","apply"].includes(t.onOutsideClick)?this.onOutsideClick=t.onOutsideClick:console.error("Option 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let e=this.locale.firstDay;for(;e>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),e--}if(!this.singleDatePicker&&typeof t.ranges=="object"){for(let e in t.ranges){let l,c;if(["string","object"].includes(typeof t.ranges[e][0])&&(o.isDateTime(t.ranges[e][0])&&t.ranges[e][0].isValid?l=t.ranges[e][0]:t.ranges[e][0]instanceof Date?l=o.fromJSDate(t.ranges[e][0]):typeof t.ranges[e][0]=="string"&&o.fromISO(t.ranges[e][0]).isValid?l=o.fromISO(t.ranges[e][0]):console.error(`Option ranges['${e}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof t.ranges[e][1])&&(o.isDateTime(t.ranges[e][1])&&t.ranges[e][1].isValid?c=t.ranges[e][1]:t.ranges[e][1]instanceof Date?c=o.fromJSDate(t.ranges[e][1]):typeof t.ranges[e][1]=="string"&&o.fromISO(t.ranges[e][1]).isValid?c=o.fromISO(t.ranges[e][1]):console.error(`Option ranges['${e}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(l==null||c==null)){t.ranges[e]=[l,c];var r=document.createElement("textarea");r.innerHTML=e,this.ranges[r.value]=[l,c]}}var f="<ul>";for(let e in this.ranges)f+='<li data-range-key="'+e+'">'+e+"</li>";this.showCustomRangeLabel&&(f+='<li data-range-key="'+this.locale.customRangeLabel+'">'+this.locale.customRangeLabel+"</li>"),f+="</ul>",this.container.find(".ranges").prepend(f),this.container.addClass("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.find(".calendar-time").hide(),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.addClass("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.addClass("single"),this.container.find(".drp-calendar.left").addClass("single"),this.container.find(".drp-calendar.left").show(),this.container.find(".drp-calendar.right").hide(),!this.timePicker&&this.autoApply&&this.container.addClass("auto-apply")),(typeof t.ranges>"u"&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyButtonClasses.length&&this.container.find(".applyBtn").addClass(this.applyButtonClasses),this.cancelButtonClasses.length&&this.container.find(".cancelBtn").addClass(this.cancelButtonClasses),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".drp-calendar").on("click.daterangepicker",".prev",this.clickPrev.bind(this)).on("click.daterangepicker",".next",this.clickNext.bind(this)).on("mousedown.daterangepicker","td.available",this.clickDate.bind(this)).on("mouseenter.daterangepicker","td.available",this.hoverDate.bind(this)).on("change.daterangepicker","select.yearselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.monthselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.container.find(".ranges").on("click.daterangepicker","li",this.clickRange.bind(this)).on("mouseenter.daterangepicker","li",this.hoverRange.bind(this)).on("mouseleave.daterangepicker","li",this.leaveRange.bind(this)),this.container.find(".drp-buttons").on("click.daterangepicker","button.applyBtn",this.clickApply.bind(this)).on("click.daterangepicker","button.cancelBtn",this.clickCancel.bind(this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":this.show.bind(this),"focus.daterangepicker":this.show.bind(this),"keyup.daterangepicker":this.elementChanged.bind(this),"keydown.daterangepicker":this.keydown.bind(this)}):(this.element.on("click.daterangepicker",this.toggle.bind(this)),this.element.on("keydown.daterangepicker",this.toggle.bind(this))),this.updateElement()}get startDate(){return this.timePicker?this.#t:this.#t.startOf("day")}get endDate(){return this.singleDatePicker?null:this.timePicker?this.#e:this.#e.endOf("day")}set startDate(s){this.#t=s}set endDate(s){this.#e=s}#i={onViolated:{type:"violated.daterangepicker",param:(...s)=>[this,...s]},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker.daterangepicker",param:this},onBeforeRenderCalendar:{type:"beforeRenderCalendar.daterangepicker",param:this},onShow:{type:"show.daterangepicker",param:this},onBeforeHide:{type:"beforeHide.daterangepicker",param:this},onHide:{type:"hide.daterangepicker",param:this},onShowCalendar:{type:"showCalendar.daterangepicker",param:this},onHideCalendar:{type:"hideCalendar.daterangepicker",param:this},onOutsideClick:{type:"outsideClick.daterangepicker",param:this},onDateChange:{type:"dateChange.daterangepicker",param:s=>[this,s]},onTimeChange:{type:"timeChange.daterangepicker",param:s=>[this,s]},onApply:{type:"apply.daterangepicker",param:this},onCancel:{type:"cancel.daterangepicker",param:this},onInputChanged:{type:"inputChanged.daterangepicker",param:this},onMonthViewChanged:{type:"monthViewChanged.daterangepicker",param:this}};get events(){return this.#i}setStartDate(s,t=!0){if(!this.singleDatePicker)return setRange(s,this.#e,t);const n=this.#t;let a=this.parseDate(s);if(a.equals(n))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const i=!this.#t.hasSame(a,"month");return this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),t&&this.updateView(i),r}setEndDate(s,t=!0){return this.singleDatePicker?null:setRange(this.#t,s,t)}setRange(s,t,n=!0){if(this.singleDatePicker)return;this.#e||(this.#e=this.#t);const a=[this.#t,this.#e];let r=[this.parseDate(s),this.parseDate(t)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const i=this.validateInput([r[0],r[1]],!0);if(i!=null)if(i.newDate!=null)r[0]=i.newDate.startDate,r[1]=i.newDate.endDate;else return i;const d=!this.#t.hasSame(r[0],"month")||!this.#e.hasSame(r[1],"month");return this.#t=r[0],this.#e=r[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),n&&this.updateView(d),i}parseDate(s){if(typeof s=="object"){if(o.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return o.fromJSDate(s);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof s=="string"){const t=typeof this.locale.format=="string"?this.locale.format:o.parseFormatForOpts(this.locale.format);if(o.fromISO(s).isValid)return o.fromISO(s);if(o.fromFormat(s,t,{locale:o.now().locale}).isValid)return o.fromFormat(s,t,{locale:o.now().locale});{const n=o.fromFormat(s,t,{locale:o.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${n}`)}}}logDate(s){return this.timePicker?s.toISO({suppressMilliseconds:!0}):s.toISODate()}formatDate(s,t=this.locale.format){if(typeof t=="object")return s.toLocaleString(t);if(x.defaultLocale===null){const n=o.now().locale;return s.toFormat(t,{locale:n})}else return s.toFormat(t)}updateLabel(){if(this.showLabel){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.container.find(".drp-selected").html(s)}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#e){this.container.find(".drp-duration-label").html("");return}if(typeof this.locale.durationFormat=="function")this.container.find(".drp-duration-label").html(this.locale.durationFormat(this.#t,this.#e));else{let s=this.#e.plus({milliseconds:1}).diff(this.#t).rescale().set({milliseconds:0});this.timePicker||(s=s.set({seconds:0,minutes:0,hours:0})),s=s.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.find(".drp-duration-label").html(s.toHuman(this.locale.durationFormat)):this.container.find(".drp-duration-label").html(s.toFormat(this.locale.durationFormat))}}}validateInput(s,t=!1){let n=s==null?this.#t:s[0],a=s==null?this.#e:s[1];if(n==null)return null;let r={startDate:{violations:[]}},i={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const e=this.timePickerStepSize.as("seconds");n=o.fromSeconds(e*Math.round(n.toSeconds()/e)),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)}else n=n.startOf("day");const d=this.timePicker?this.timePickerStepSize.as("seconds"):b.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/d)*d}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)):this.maxDate&&n>this.maxDate&&(i={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/d)*d}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i));let f=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&f.push("minute"),this.timePickerOpts.showSeconds&&f.push("second"),this.timePicker24Hour||f.push("ampm")),this.isInvalidDate(n)&&r.startDate.violations.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let e of f)this.isInvalidTime(n,e,"start")&&r.startDate.violations.push({old:n,reason:"isInvalidTime",unit:e});if(this.singleDatePicker){if(r.startDate.violations.length==0)return null;if(t){let e={startDate:n};return this.triggerHandler(this.#i.onViolated,r,e)&&(r.newDate=e),r}else return r}if(a==null)return null;if(r.endDate={violations:[]},i={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const e=this.timePickerStepSize.as("seconds");a=o.fromSeconds(e*Math.round(a.toSeconds()/e)),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/d)*d}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)):this.minDate&&a<this.minDate&&(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/d)*d}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)),this.maxSpan){const e=n.plus(this.maxSpan);a>e&&(i={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(e.diff(a).as("seconds")/d)*d}),a>e&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.minSpan){const e=n.plus(this.defaultSpan??this.minSpan);a<e&&(i={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(e.diff(a).as("seconds")/d)*d}),a<e&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.isInvalidDate(a)&&r.endDate.violations.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let e of f)this.isInvalidTime(a,e,"end")&&r.endDate.violations.push({old:a,reason:"isInvalidTime",unit:e});if(r.startDate.violations.length==0&&r.endDate.violations.length==0)return null;if(t){let e={startDate:n,endDate:a};return this.triggerHandler(this.#i.onViolated,r,e)&&(r.newDate=e),r}else return r}updateView(s){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.#e?this.container.find(".calendar-time.end-time select").prop("disabled",!1).removeClass("disabled"):this.container.find(".calendar-time.end-time select").prop("disabled",!0).addClass("disabled")),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(s),this.setApplyBtnState()}updateMonthsInView(){if(this.#e){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month"))&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#t.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#e.hasSame(this.#t,"month")?this.rightCalendar.month=this.#e.startOf("month"):this.rightCalendar.month=this.#t.startOf("month").plus({month:1}))}else!this.#t&&this.initalMonth?(this.leftCalendar.month=this.initalMonth,this.singleMonthView||(this.rightCalendar.month=this.initalMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#t,"month")&&!this.rightCalendar.month.hasSame(this.#t,"month")&&(this.leftCalendar.month=this.#t.startOf("month"),this.rightCalendar.month=this.#t.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(s){if(this.timePicker){var t,n,a;this.#e?(t=parseInt(this.container.find(".start-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".start-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".start-time .secondselect option:last").val(),10)))):(t=parseInt(this.container.find(".end-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".end-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".end-time .secondselect option:last").val(),10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:t,minute:n,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:t,minute:n,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),s&&this.triggerEvent(this.#i.onMonthViewChanged),this.container.find(".ranges li").removeClass("active"),this.#e!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var i=s==="left"?this.leftCalendar:this.rightCalendar;i.month==null&&!this.#t&&this.initalMonth&&(i.month=this.initalMonth.startOf("month"));const t=i.month.startOf("month"),n=i.month.endOf("month").startOf("day");var a=i.month.startOf("month").minus({day:1});const r={hour:i.month.hour,minute:i.month.minute,second:i.month.second};var i=[];i.firstDay=t,i.lastDay=n;for(var d=0;d<6;d++)i[d]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let m=0,k=-1;m<42;m++,a=a.plus({day:1}))m%7===0&&k++,i[k][m%7]=a.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var f=s==="left"?this.minDate:this.#t,e=this.maxDate,l="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+="<th></th>"),(!f||f<i.firstDay)&&(!this.linkedCalendars||s==="left")?l+='<th class="prev available"><span></span></th>':l+="<th></th>";var c=`${this.locale.monthNames[i.firstDay.month-1]} ${i.firstDay.year}`;if(this.showDropdowns){const m=(e&&e.year)??this.maxYear,k=(f&&f.year)??this.minYear;let O=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var p=`${O}<select class="monthselect">`,u=1;u<=12;u++)p+=`<option value="${u}"${u===i.firstDay.month?" selected":""}`,(f&&i.firstDay.set({month:u})<f.startOf("month")||e&&i.firstDay.set({month:u})>e.endOf("month"))&&(p+=" disabled"),p+=`>${this.locale.monthNames[u-1]}</option>`;p+="</select>",this.externalStyle==="bulma"&&(p+="</div>"),O=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var g=`${O}<select class="yearselect">`,y=k;y<=m;y++)g+=`<option value="${y}"${y===i.firstDay.year?" selected":""}>${y}</option>`;g+="</select>",this.externalStyle==="bulma"&&(g+="</div>"),c=p+g}l+='<th colspan="5" class="month">'+c+"</th>",(!e||e>i.lastDay.endOf("day"))&&(!this.linkedCalendars||s==="right"||this.singleDatePicker||this.singleMonthView)?l+='<th class="next available"><span></span></th>':l+="<th></th>",l+="</tr>",l+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[m,k]of this.locale.daysOfWeek.entries())l+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&C.getWeekendWeekdays().includes(m+1)&&(l+=` class="${this.weekendDayClasses}"`),l+=`>${k}</th>`;if(l+="</tr>",this.container.find(".drp-calendar."+s+" .calendar-table thead").html(l),l="",this.#e==null&&this.maxSpan){var v=this.#t.plus(this.maxSpan).endOf("day");(!e||v<e)&&(e=v)}var D;this.#e==null&&this.minSpan&&(D=this.#t.plus(this.minSpan).startOf("day"));for(let m=0;m<6;m++){l+="<tr>",this.showISOWeekNumbers?l+='<td class="week">'+i[m][0].weekNumber+"</td>":this.showWeekNumbers&&(l+='<td class="week">'+i[m][0].localWeekNumber+"</td>");for(let k=0;k<7;k++){var S=[];this.todayClasses&&this.todayClasses.length&&i[m][k].hasSame(o.now(),"day")&&S.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&C.getWeekendWeekdays().includes(i[m][k].weekday)&&S.push(this.weekendClasses),i[m][k].month!=i[1][1].month&&S.push("off","ends"),this.minDate&&i[m][k].startOf("day")<this.minDate.startOf("day")&&S.push("off","disabled"),e&&i[m][k].startOf("day")>e.startOf("day")&&S.push("off","disabled"),D&&i[m][k].startOf("day")>this.#t.startOf("day")&&i[m][k].startOf("day")<D.startOf("day")&&S.push("off","disabled"),this.isInvalidDate(i[m][k])&&S.push("off","disabled"),this.#t!=null&&i[m][k].hasSame(this.#t,"day")&&S.push("active","start-date"),this.#e!=null&&i[m][k].hasSame(this.#e,"day")&&S.push("active","end-date"),this.#e!=null&&i[m][k]>this.#t&&i[m][k]<this.#e&&S.push("in-range");var w=this.isCustomDate(i[m][k]);w!==!1&&(typeof w=="string"?S.push(w):Array.prototype.push.apply(S,w)),S.includes("disabled")||S.push("available"),l+=`<td class="${S.join(" ")}" data-title="r${m}c${k}">${i[m][k].day}</td>`}l+="</tr>"}this.container.find(".drp-calendar."+s+" .calendar-table tbody").html(l)}renderTimePicker(s){if(s==="end"&&!this.#e)return;var t,n,a,r=this.maxDate;let i="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(i+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#t.plus(this.maxSpan)<this.maxDate)&&(r=this.#t.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#t.plus(this.defaultSpan??this.minSpan)),s==="start")t=this.#t,a=this.minDate;else if(s==="end"){t=this.#e,a=this.#t;var d=this.container.find(".drp-calendar .calendar-time.end-time");d.html()!=""&&(t=t.set({hour:isNaN(t.hour)?d.find(".hourselect option:selected").val():t.hour,minute:isNaN(t.minute)?d.find(".minuteselect option:selected").val():t.minute,second:isNaN(t.second)?d.find(".secondselect option:selected").val():t.second})),t<this.#t&&(t=this.#t),r&&t>r&&(t=r)}i+='<th colspan="7">',this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="hourselect">';const f=t.toFormat("a",{locale:"en-US"});let e=0;this.timePicker24Hour||(e=f==="AM"?1:13);for(var l=e;l<=e+23;l+=this.timePickerOpts.hourStep){let g=t.set({hour:l%24}),y=!1;if(a&&g.set({minute:59})<a&&(y=!0),r&&g.set({minute:0})>r&&(y=!0),n&&g.endOf("hour")<n&&(y=!0),!y&&this.isInvalidTime(g,this.singleDatePicker?null:s,"hour")&&(y=!0),this.timePicker24Hour)!y&&l==t.hour?i+=`<option value="${l}" selected>${l}</option>`:y?i+=`<option value="${l}" disabled class="disabled">${l}</option>`:i+=`<option value="${l}">${l}</option>`;else{const v=o.fromFormat(`${l%24}`,"H").toFormat("h"),D=o.fromFormat(`${l%24}`,"H").toFormat("a",{locale:"en-US"});f==D?!y&&l==t.hour?i+=`<option ampm="${D}" value="${l%24}" selected>${v}</option>`:y?i+=`<option ampm="${D}" value="${l%24}" disabled class="disabled">${v}</option>`:i+=`<option ampm="${D}" value="${l%24}">${v}</option>`:i+=`<option ampm="${D}" hidden="hidden" value="${l%24}">${v}</option>`}}if(i+="</select>",this.externalStyle==="bulma"&&(i+="</div>"),this.timePickerOpts.showMinutes){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="minuteselect">';for(var l=0;l<60;l+=this.timePickerOpts.minuteStep){var c=l<10?"0"+l:l;let y=t.set({minute:l}),v=!1;a&&y.set({second:59})<a&&(v=!0),r&&y.set({second:0})>r&&(v=!0),n&&y.endOf("minute")<n&&(v=!0),!v&&this.isInvalidTime(y,this.singleDatePicker?null:s,"minute")&&(v=!0),t.minute==l&&!v?i+=`<option value="${l}" selected>${c}</option>`:v?i+=`<option value="${l}" disabled class="disabled">${c}</option>`:i+=`<option value="${l}">${c}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(this.timePickerOpts.showSeconds){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="secondselect">';for(var l=0;l<60;l+=this.timePickerOpts.secondStep){var c=l<10?"0"+l:l;let v=t.set({second:l}),D=!1;a&&v<a&&(D=!0),r&&v>r&&(D=!0),n&&v<n&&(D=!0),!D&&this.isInvalidTime(v,this.singleDatePicker?null:s,"second")&&(D=!0),t.second==l&&!D?i+=`<option value="${l}" selected>${c}</option>`:D?i+=`<option value="${l}" disabled class="disabled">${c}</option>`:i+=`<option value="${l}">${c}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="ampmselect">';var p="",u="";let g=!1;a&&t.startOf("day")<a&&(g=!0),r&&t.endOf("day")>r&&(g=!0),n&&t.startOf("day")<n&&(g=!0),g?(p=' disabled class="disabled "',u=' disabled class="disabled"'):this.isInvalidTime(t,this.singleDatePicker?null:s,"ampm")&&(t.toFormat("a",{locale:"en-US"})==="AM"?u=' disabled class="disabled"':p=' disabled class="disabled"'),i+=`<option value="AM"${p}`,t.toFormat("a",{locale:"en-US"})==="AM"&&(i+=" selected"),i+=`>${C.meridiems()[0]}</option><option value="PM"${u}`,t.toFormat("a",{locale:"en-US"})==="PM"&&(i+=" selected"),i+=`>${C.meridiems()[1]}</option>`,i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}i+="</div></th>",this.container.find(`.drp-calendar .calendar-time.${s}-time`).html(i)}setApplyBtnState(){this.singleDatePicker||this.#e&&this.#t<=this.#e?this.container.find("button.applyBtn").prop("disabled",!1):this.container.find("button.applyBtn").prop("disabled",!0)}move(){var s={top:0,left:0},t,n=this.drops,a=h(window).width();switch(this.parentEl.is("body")||(s={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},a=this.parentEl[0].clientWidth+this.parentEl.offset().left),n){case"auto":t=this.element.offset().top+this.element.outerHeight()-s.top,t+this.container.outerHeight()>=this.parentEl[0].scrollHeight&&(t=this.element.offset().top-this.container.outerHeight()-s.top,n="up");break;case"up":t=this.element.offset().top-this.container.outerHeight()-s.top;break;default:t=this.element.offset().top+this.element.outerHeight()-s.top;break}this.container.css({top:0,left:0,right:"auto"});var r=this.container.outerWidth();if(this.container.toggleClass("drop-up",n==="up"),this.opens==="left"){var i=a-this.element.offset().left-this.element.outerWidth();r+i>h(window).width()?this.container.css({top:t,right:"auto",left:9}):this.container.css({top:t,right:i,left:"auto"})}else if(this.opens==="center"){var d=this.element.offset().left-s.left+this.element.outerWidth()/2-r/2;d<0?this.container.css({top:t,right:"auto",left:9}):d+r>h(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:d,right:"auto"})}else{var d=this.element.offset().left-s.left;d+r>h(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:d,right:"auto"})}}show(){this.isShowing||(this._outsideClickProxy=function(s){this.outsideClick(s)}.bind(this),h(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),h(window).on("resize.daterangepicker",function(s){this.move(s)}.bind(this)),this.oldStartDate=this.#t,this.oldEndDate=this.#e,this.updateView(!1),this.container.show(),this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){this.isShowing&&(this.#e||(this.#t=this.oldStartDate,this.#e=this.oldEndDate),(!this.#t.equals(this.oldStartDate)||!this.#e.equals(this.oldEndDate))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),!this.triggerHandler(this.#i.onBeforeHide)&&(h(document).off(".daterangepicker"),h(window).off(".daterangepicker"),this.container.hide(),this.triggerEvent(this.#i.onHide),this.isShowing=!1))}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.addClass("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.removeClass("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(s){var t=h(s.target);s.type==="focusin"||t.closest(this.element).length||t.closest(this.container).length||t.closest(".calendar-table").length||(this.onOutsideClick==="cancel"&&(this.#t=this.oldStartDate,this.#e=this.oldEndDate),this.hide(),this.triggerEvent(this.#i.onOutsideClick))}clickPrev(s){var t=h(s.target).parents(".drp-calendar");t.hasClass("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(s){var t=h(s.target).parents(".drp-calendar");t.hasClass("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(s){if(!h(s.target).hasClass("available"))return;let t=h(s.target).attr("data-title");const n=t.substring(1,2),a=t.substring(3,4);var i=h(s.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const d=this.leftCalendar,f=this.rightCalendar,e=this.#t,l=this.initalMonth;this.#e||this.container.find(".drp-calendar tbody td").each(function(c,p){if(h(p).hasClass("week"))return;const u=h(p).attr("data-title"),g=u.substring(1,2),y=u.substring(3,4),D=h(p).parents(".drp-calendar").hasClass("left")?d.calendar[g][y]:f.calendar[g][y];!e&&l?h(p).removeClass("in-range"):D>e&&D<i||D.hasSame(i,"day")?h(p).addClass("in-range"):h(p).removeClass("in-range")})}hoverRange(s){const t=s.target.getAttribute("data-range-key"),n=[this.#t,this.#e],a=this.ranges[t]??[this.#t,this.#e],r=this.leftCalendar,i=this.rightCalendar;this.container.find(".drp-calendar tbody td").each(function(d,f){if(h(f).hasClass("week"))return;const e=h(f).attr("data-title"),l=e.substring(1,2),c=e.substring(3,4),u=h(f).parents(".drp-calendar").hasClass("left")?r.calendar[l][c]:i.calendar[l][c];let g=!1;u.hasSame(a[0],"day")&&(g=h(f).addClass("start-hover").length>0),u.hasSame(n[0],"day")&&(g=h(f).addClass("start-date").length>0),u.hasSame(a[1],"day")&&(g=h(f).addClass("end-hover").length>0),n[1]!=null&&u.hasSame(n[1],"day")&&(g=h(f).addClass("end-date").length>0),u.startOf("day")>=a[0].startOf("day")&&u.startOf("day")<=a[1].startOf("day")&&(g=h(f).addClass("range-hover").length>0),u.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&u.startOf("day")<=n[1].startOf("day")&&(g=h(f).addClass("in-range").length>0),g||(h(f).removeClass("start-hover"),h(f).removeClass("end-hover"),h(f).removeClass("start-date"),h(f).removeClass("end-date"),h(f).removeClass("in-range"),h(f).removeClass("range-hover"))})}leaveRange(s){this.container.find(".drp-calendar tbody td").each(function(t,n){h(n).hasClass("week")||(h(n).removeClass("start-hover"),h(n).removeClass("end-hover"),h(n).removeClass("range-hover"))})}clickRange(s){var t=s.target.getAttribute("data-range-key");if(this.chosenLabel=t,t==this.locale.customRangeLabel)this.showCalendars();else{var n=this.ranges[t];const a=!this.#t.hasSame(n[0],"month")||!this.#e.hasSame(n[1],"month");this.#t=n[0],this.#e=n[1],this.timePicker||(this.#t.startOf("day"),this.#e.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerHandler(this.#i.onBeforeHide)&&this.updateView(a),this.clickApply()}}clickDate(s){if(!h(s.target).hasClass("available"))return;var t=h(s.target).attr("data-title"),n=t.substring(1,2),a=t.substring(3,4),r=h(s.target).parents(".drp-calendar"),i=r.hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];let d;if(this.#e||!this.#t||i<this.#t.startOf("day")){if(this.timePicker){let f=parseInt(this.container.find(".start-time .hourselect").val(),10);isNaN(f)&&(f=parseInt(this.container.find(".start-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".start-time .secondselect option:last").val(),10))),i=i.set({hour:f,minute:e,second:l})}else i=i.startOf("day");this.#e=null,this.#t=i,d="start"}else if(!this.#e&&i<this.#t)this.#e=this.#t,d="end";else{if(this.timePicker){let f=parseInt(this.container.find(".end-time .hourselect").val(),10);isNaN(f)&&(f=parseInt(this.container.find(".end-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".end-time .secondselect option:last").val(),10))),i=i.set({hour:f,minute:e,second:l})}else i=i.endOf("day");this.#e=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),d="end"}this.singleDatePicker&&(this.#e=this.#t,!this.timePicker&&this.autoApply&&this.clickApply(),d=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,d)}calculateChosenLabel(){var s=!0,t=0;for(var n in this.ranges){var a=this.timePicker?"hour":"day";if(this.timePicker&&(this.timePickerOpts.showMinutes?a="minute":this.timePickerOpts.showSeconds&&(a="second")),this.#t.startOf(a).equals(this.ranges[n][0].startOf(a))&&this.#e.startOf(a).equals(this.ranges[n][1].startOf(a))){s=!1,this.chosenLabel=this.container.find(".ranges li:eq("+t+")").addClass("active").attr("data-range-key");break}t++}s&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").attr("data-range-key"):this.chosenLabel=null,this.showCalendars())}timeChanged(s){const t=h(s.target).closest(".calendar-time"),n=t.hasClass("start-time")?"start":"end";var a=parseInt(t.find(".hourselect").val(),10);if(isNaN(a)&&(a=parseInt(t.find(".hourselect option:last").val(),10)),!this.timePicker24Hour){const d=t.find(".ampmselect").val();if(d==null&&t.find(".ampmselect option:last").val(),d!=o.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){t.find(".hourselect > option").each(function(){const e=h(this).attr("hidden")||!1;h(this).attr("hidden",e)});const f=o.fromFormat(`${a}`,"H").toFormat("h");a=o.fromFormat(`${f}${d}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(t.find(".minuteselect").val(),10),isNaN(r)&&(r=parseInt(t.find(".minuteselect option:last").val(),10)));var i=0;this.timePickerOpts.showSeconds&&(i=parseInt(t.find(".secondselect").val(),10),isNaN(i)&&(i=parseInt(t.find(".secondselect option:last").val(),10))),n==="start"?(this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:i})),this.singleDatePicker?this.#e=this.#t:this.#e&&this.#e.hasSame(this.#t,"day")&&this.#e<this.#t&&(this.#e=this.#t)):this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:i})),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,this.singleDatePicker?null:n)}monthOrYearChanged(s){var t=h(s.target).closest(".drp-calendar").hasClass("left"),n=t?"left":"right",a=this.container.find(".drp-calendar."+n),r=parseInt(a.find(".monthselect").val(),10),i=a.find(".yearselect").val();let d=!1;t||(i<this.#t.year||i==this.#t.year&&r<this.#t.month)&&(r=this.#t.month,i=this.#t.year),this.minDate&&(i<this.minDate.year||i==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,i=this.minDate.year),this.maxDate&&(i>this.maxDate.year||i==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,i=this.maxDate.year),t?(d=!o.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(d=!o.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(d)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#t=this.oldStartDate,this.#e=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.element.is("input:text")||!this.element.val().length)return;const s=typeof this.locale.format=="string"?this.locale.format:o.parseFormatForOpts(this.locale.format),t=this.element.val().split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=o.fromFormat(this.element.val(),s,{locale:o.now().locale});const r=this.#t;if(!a.isValid||r.equals(a))return;const i=this.validateInput([a,null],!0);if(i!=null)if(i.newDate!=null)a=i.newDate.startDate;else return;n=!this.#t.hasSame(a,"month"),this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else if(!this.singleDatePicker&&t.length===2){const a=[0,1].map(d=>o.fromFormat(t[d],s,{locale:o.now().locale})),r=[this.#t,this.#e];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const i=this.validateInput([a[0],a[1]],!0);if(i!=null)if(i.newDate!=null)a[0]=i.newDate.startDate,a[1]=i.newDate.endDate;else return;n=!this.#t.hasSame(a[0],"month")||!this.#e.hasSame(a[1],"month"),this.#t=a[0],this.#e=a[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else return;this.updateView(n),this.updateElement(),this.triggerEvent(this.#i.onInputChanged)}keydown(s){(s.keyCode===9||s.keyCode===13)&&this.hide(),s.keyCode===27&&(s.preventDefault(),s.stopPropagation(),this.hide())}updateElement(){if(!(this.#t==null&&this.initalMonth))if(this.element.is("input:text")){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.updateAltInput(),s!==this.element.val()&&this.element.val(s).trigger("change")}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.singleDatePicker&&h(this.altInput[1]).val(null),this.altFormat==null){let s="day";this.timePicker&&(this.timePickerOpts.showSeconds?s="second":this.timePickerOpts.showMinutes?s="minute":s="hour");const t=this.#t.toISO({format:"basic",precision:s,includeOffset:!1});if(h(this.singleDatePicker?this.altInput:this.altInput[0]).val(t),!this.singleDatePicker&&this.#e){const n=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});h(this.altInput[1]).val(n)}}else{const s=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);if(h(this.singleDatePicker?this.altInput:this.altInput[0]).val(s),!this.singleDatePicker&&this.#e){const t=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);h(this.altInput[1]).val(t)}}}remove(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}triggerEvent(s,...t){if(t.length===0)this.element.trigger(s.type,s.param);else{const n=s.param(...t);this.element.trigger(s.type,n)}}triggerHandler(s,...t){if(t.length===0)return this.element.triggerHandler(s.type,s.param);{const n=s.param(...t);return this.element.triggerHandler(s.type,n)}}}h.fn.daterangepicker||(h.fn.daterangepicker=function(P,s){const t=h.extend(!0,{},h.fn.daterangepicker.defaultOptions,P);return this.each(function(){const n=h(this);n.data("daterangepicker")&&n.data("daterangepicker").remove(),n.data("daterangepicker",new I(n,t,s))}),this});var V=I;export{V as default};
|
|
2
|
+
`,e)}if(typeof t.opens=="string"&&(["left","right","center"].includes(t.opens)?this.opens=t.opens:console.error("Option 'options.opens' must be 'left', 'right' or 'center'")),typeof t.drops=="string"&&(["drop","down","auto"].includes(t.drops)?this.drops=t.drops:console.error("Option 'options.drops' must be 'drop', 'down' or 'auto'")),Array.isArray(t.buttonClasses)?this.buttonClasses=t.buttonClasses.join(" "):typeof t.buttonClasses=="string"&&(this.buttonClasses=t.buttonClasses),typeof t.onOutsideClick=="string"&&(["cancel","apply"].includes(t.onOutsideClick)?this.onOutsideClick=t.onOutsideClick:console.error("Option 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let e=this.locale.firstDay;for(;e>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),e--}if(!this.singleDatePicker&&typeof t.ranges=="object"){for(let e in t.ranges){let l,c;if(["string","object"].includes(typeof t.ranges[e][0])&&(o.isDateTime(t.ranges[e][0])&&t.ranges[e][0].isValid?l=t.ranges[e][0]:t.ranges[e][0]instanceof Date?l=o.fromJSDate(t.ranges[e][0]):typeof t.ranges[e][0]=="string"&&o.fromISO(t.ranges[e][0]).isValid?l=o.fromISO(t.ranges[e][0]):console.error(`Option ranges['${e}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof t.ranges[e][1])&&(o.isDateTime(t.ranges[e][1])&&t.ranges[e][1].isValid?c=t.ranges[e][1]:t.ranges[e][1]instanceof Date?c=o.fromJSDate(t.ranges[e][1]):typeof t.ranges[e][1]=="string"&&o.fromISO(t.ranges[e][1]).isValid?c=o.fromISO(t.ranges[e][1]):console.error(`Option ranges['${e}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(l==null||c==null)){t.ranges[e]=[l,c];var r=document.createElement("textarea");r.innerHTML=e,this.ranges[r.value]=[l,c]}}var f="<ul>";for(let e in this.ranges)f+='<li data-range-key="'+e+'">'+e+"</li>";this.showCustomRangeLabel&&(f+='<li data-range-key="'+this.locale.customRangeLabel+'">'+this.locale.customRangeLabel+"</li>"),f+="</ul>",this.container.find(".ranges").prepend(f),this.container.addClass("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.find(".calendar-time").hide(),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.addClass("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.addClass("single"),this.container.find(".drp-calendar.left").addClass("single"),this.container.find(".drp-calendar.left").show(),this.container.find(".drp-calendar.right").hide(),!this.timePicker&&this.autoApply&&this.container.addClass("auto-apply")),(typeof t.ranges>"u"&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyButtonClasses.length&&this.container.find(".applyBtn").addClass(this.applyButtonClasses),this.cancelButtonClasses.length&&this.container.find(".cancelBtn").addClass(this.cancelButtonClasses),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".drp-calendar").on("click.daterangepicker",".prev",this.clickPrev.bind(this)).on("click.daterangepicker",".next",this.clickNext.bind(this)).on("mousedown.daterangepicker","td.available",this.clickDate.bind(this)).on("mouseenter.daterangepicker","td.available",this.hoverDate.bind(this)).on("change.daterangepicker","select.yearselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.monthselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.container.find(".ranges").on("click.daterangepicker","li",this.clickRange.bind(this)).on("mouseenter.daterangepicker","li",this.hoverRange.bind(this)).on("mouseleave.daterangepicker","li",this.leaveRange.bind(this)),this.container.find(".drp-buttons").on("click.daterangepicker","button.applyBtn",this.clickApply.bind(this)).on("click.daterangepicker","button.cancelBtn",this.clickCancel.bind(this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":this.show.bind(this),"focus.daterangepicker":this.show.bind(this),"keyup.daterangepicker":this.elementChanged.bind(this),"keydown.daterangepicker":this.keydown.bind(this)}):(this.element.on("click.daterangepicker",this.toggle.bind(this)),this.element.on("keydown.daterangepicker",this.toggle.bind(this))),this.updateElement()}get startDate(){return this.timePicker?this.#t:this.#t.startOf("day")}get endDate(){return this.singleDatePicker?null:this.timePicker?this.#e:this.#e.endOf("day")}set startDate(s){this.#t=s}set endDate(s){this.#e=s}#i={onViolate:{type:"violate.daterangepicker",param:(...s)=>[this,...s]},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker.daterangepicker",param:this},onBeforeRenderCalendar:{type:"beforeRenderCalendar.daterangepicker",param:this},onShow:{type:"show.daterangepicker",param:this},onBeforeHide:{type:"beforeHide.daterangepicker",param:this},onHide:{type:"hide.daterangepicker",param:this},onShowCalendar:{type:"showCalendar.daterangepicker",param:this},onHideCalendar:{type:"hideCalendar.daterangepicker",param:this},onOutsideClick:{type:"outsideClick.daterangepicker",param:this},onDateChange:{type:"dateChange.daterangepicker",param:s=>[this,s]},onTimeChange:{type:"timeChange.daterangepicker",param:s=>[this,s]},onApply:{type:"apply.daterangepicker",param:this},onCancel:{type:"cancel.daterangepicker",param:this},onInputChange:{type:"inputChange.daterangepicker",param:this},onMonthViewChange:{type:"monthViewChange.daterangepicker",param:(s,t)=>[this,s.startOf("month"),t?t.startOf("month"):null]}};get events(){return this.#i}setStartDate(s,t=!0){if(!this.singleDatePicker)return setRange(s,this.#e,t);const n=this.#t;let a=this.parseDate(s);if(a.equals(n))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const i=!this.#t.hasSame(a,"month");return this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),t&&this.updateView(i),r}setEndDate(s,t=!0){return this.singleDatePicker?null:setRange(this.#t,s,t)}setRange(s,t,n=!0){if(this.singleDatePicker)return;this.#e||(this.#e=this.#t);const a=[this.#t,this.#e];let r=[this.parseDate(s),this.parseDate(t)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const i=this.validateInput([r[0],r[1]],!0);if(i!=null)if(i.newDate!=null)r[0]=i.newDate.startDate,r[1]=i.newDate.endDate;else return i;const d=!this.#t.hasSame(r[0],"month")||!this.#e.hasSame(r[1],"month");return this.#t=r[0],this.#e=r[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),n&&this.updateView(d),i}parseDate(s){if(typeof s=="object"){if(o.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return o.fromJSDate(s);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof s=="string"){const t=typeof this.locale.format=="string"?this.locale.format:o.parseFormatForOpts(this.locale.format);if(o.fromISO(s).isValid)return o.fromISO(s);if(o.fromFormat(s,t,{locale:o.now().locale}).isValid)return o.fromFormat(s,t,{locale:o.now().locale});{const n=o.fromFormat(s,t,{locale:o.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${n}`)}}}logDate(s){return this.timePicker?s.toISO({suppressMilliseconds:!0}):s.toISODate()}formatDate(s,t=this.locale.format){if(typeof t=="object")return s.toLocaleString(t);if(x.defaultLocale===null){const n=o.now().locale;return s.toFormat(t,{locale:n})}else return s.toFormat(t)}updateLabel(){if(this.showLabel){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.container.find(".drp-selected").html(s)}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#e){this.container.find(".drp-duration-label").html("");return}if(typeof this.locale.durationFormat=="function")this.container.find(".drp-duration-label").html(this.locale.durationFormat(this.#t,this.#e));else{let s=this.#e.plus({milliseconds:1}).diff(this.#t).rescale().set({milliseconds:0});this.timePicker||(s=s.set({seconds:0,minutes:0,hours:0})),s=s.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.find(".drp-duration-label").html(s.toHuman(this.locale.durationFormat)):this.container.find(".drp-duration-label").html(s.toFormat(this.locale.durationFormat))}}}validateInput(s,t=!1){let n=s==null?this.#t:s[0],a=s==null?this.#e:s[1];if(n==null)return null;let r={startDate:{violations:[]}},i={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const e=this.timePickerStepSize.as("seconds");n=o.fromSeconds(e*Math.round(n.toSeconds()/e)),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)}else n=n.startOf("day");const d=this.timePicker?this.timePickerStepSize.as("seconds"):b.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/d)*d}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)):this.maxDate&&n>this.maxDate&&(i={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/d)*d}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i));let f=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&f.push("minute"),this.timePickerOpts.showSeconds&&f.push("second"),this.timePicker24Hour||f.push("ampm")),this.isInvalidDate(n)&&r.startDate.violations.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let e of f)this.isInvalidTime(n,e,"start")&&r.startDate.violations.push({old:n,reason:"isInvalidTime",unit:e});if(this.singleDatePicker){if(r.startDate.violations.length==0)return null;if(t){let e={startDate:n};return this.triggerHandler(this.#i.onViolate,r,e)&&(r.newDate=e),r}else return r}if(a==null)return null;if(r.endDate={violations:[]},i={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const e=this.timePickerStepSize.as("seconds");a=o.fromSeconds(e*Math.round(a.toSeconds()/e)),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/d)*d}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)):this.minDate&&a<this.minDate&&(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/d)*d}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)),this.maxSpan){const e=n.plus(this.maxSpan);a>e&&(i={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(e.diff(a).as("seconds")/d)*d}),a>e&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.minSpan){const e=n.plus(this.defaultSpan??this.minSpan);a<e&&(i={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(e.diff(a).as("seconds")/d)*d}),a<e&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.isInvalidDate(a)&&r.endDate.violations.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let e of f)this.isInvalidTime(a,e,"end")&&r.endDate.violations.push({old:a,reason:"isInvalidTime",unit:e});if(r.startDate.violations.length==0&&r.endDate.violations.length==0)return null;if(t){let e={startDate:n,endDate:a};return this.triggerHandler(this.#i.onViolate,r,e)&&(r.newDate=e),r}else return r}updateView(s){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.#e?this.container.find(".calendar-time.end-time select").prop("disabled",!1).removeClass("disabled"):this.container.find(".calendar-time.end-time select").prop("disabled",!0).addClass("disabled")),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(s),this.setApplyBtnState()}updateMonthsInView(){if(this.#e){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month"))&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#t.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#e.hasSame(this.#t,"month")?this.rightCalendar.month=this.#e.startOf("month"):this.rightCalendar.month=this.#t.startOf("month").plus({month:1}))}else!this.#t&&this.initalMonth?(this.leftCalendar.month=this.initalMonth,this.singleMonthView||(this.rightCalendar.month=this.initalMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#t,"month")&&!this.rightCalendar.month.hasSame(this.#t,"month")&&(this.leftCalendar.month=this.#t.startOf("month"),this.rightCalendar.month=this.#t.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(s){if(this.timePicker){var t,n,a;this.#e?(t=parseInt(this.container.find(".start-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".start-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".start-time .secondselect option:last").val(),10)))):(t=parseInt(this.container.find(".end-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".end-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".end-time .secondselect option:last").val(),10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:t,minute:n,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:t,minute:n,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),s&&this.triggerEvent(this.#i.onMonthViewChange,this.leftCalendar.month,this.singleMonthView||this.singleDatePicker?null:this.rightCalendar.month),this.container.find(".ranges li").removeClass("active"),this.#e!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var i=s==="left"?this.leftCalendar:this.rightCalendar;i.month==null&&!this.#t&&this.initalMonth&&(i.month=this.initalMonth.startOf("month"));const t=i.month.startOf("month"),n=i.month.endOf("month").startOf("day");var a=i.month.startOf("month").minus({day:1});const r={hour:i.month.hour,minute:i.month.minute,second:i.month.second};var i=[];i.firstDay=t,i.lastDay=n;for(var d=0;d<6;d++)i[d]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let m=0,k=-1;m<42;m++,a=a.plus({day:1}))m%7===0&&k++,i[k][m%7]=a.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var f=s==="left"?this.minDate:this.#t,e=this.maxDate,l="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+="<th></th>"),(!f||f<i.firstDay)&&(!this.linkedCalendars||s==="left")?l+='<th class="prev available"><span></span></th>':l+="<th></th>";var c=`${this.locale.monthNames[i.firstDay.month-1]} ${i.firstDay.year}`;if(this.showDropdowns){const m=(e&&e.year)??this.maxYear,k=(f&&f.year)??this.minYear;let O=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var p=`${O}<select class="monthselect">`,u=1;u<=12;u++)p+=`<option value="${u}"${u===i.firstDay.month?" selected":""}`,(f&&i.firstDay.set({month:u})<f.startOf("month")||e&&i.firstDay.set({month:u})>e.endOf("month"))&&(p+=" disabled"),p+=`>${this.locale.monthNames[u-1]}</option>`;p+="</select>",this.externalStyle==="bulma"&&(p+="</div>"),O=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var g=`${O}<select class="yearselect">`,y=k;y<=m;y++)g+=`<option value="${y}"${y===i.firstDay.year?" selected":""}>${y}</option>`;g+="</select>",this.externalStyle==="bulma"&&(g+="</div>"),c=p+g}l+='<th colspan="5" class="month">'+c+"</th>",(!e||e>i.lastDay.endOf("day"))&&(!this.linkedCalendars||s==="right"||this.singleDatePicker||this.singleMonthView)?l+='<th class="next available"><span></span></th>':l+="<th></th>",l+="</tr>",l+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[m,k]of this.locale.daysOfWeek.entries())l+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&C.getWeekendWeekdays().includes(m+1)&&(l+=` class="${this.weekendDayClasses}"`),l+=`>${k}</th>`;if(l+="</tr>",this.container.find(".drp-calendar."+s+" .calendar-table thead").html(l),l="",this.#e==null&&this.maxSpan){var v=this.#t.plus(this.maxSpan).endOf("day");(!e||v<e)&&(e=v)}var D;this.#e==null&&this.minSpan&&(D=this.#t.plus(this.minSpan).startOf("day"));for(let m=0;m<6;m++){l+="<tr>",this.showISOWeekNumbers?l+='<td class="week">'+i[m][0].weekNumber+"</td>":this.showWeekNumbers&&(l+='<td class="week">'+i[m][0].localWeekNumber+"</td>");for(let k=0;k<7;k++){var S=[];this.todayClasses&&this.todayClasses.length&&i[m][k].hasSame(o.now(),"day")&&S.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&C.getWeekendWeekdays().includes(i[m][k].weekday)&&S.push(this.weekendClasses),i[m][k].month!=i[1][1].month&&S.push("off","ends"),this.minDate&&i[m][k].startOf("day")<this.minDate.startOf("day")&&S.push("off","disabled"),e&&i[m][k].startOf("day")>e.startOf("day")&&S.push("off","disabled"),D&&i[m][k].startOf("day")>this.#t.startOf("day")&&i[m][k].startOf("day")<D.startOf("day")&&S.push("off","disabled"),this.isInvalidDate(i[m][k])&&S.push("off","disabled"),this.#t!=null&&i[m][k].hasSame(this.#t,"day")&&S.push("active","start-date"),this.#e!=null&&i[m][k].hasSame(this.#e,"day")&&S.push("active","end-date"),this.#e!=null&&i[m][k]>this.#t&&i[m][k]<this.#e&&S.push("in-range");var w=this.isCustomDate(i[m][k]);w!==!1&&(typeof w=="string"?S.push(w):Array.prototype.push.apply(S,w)),S.includes("disabled")||S.push("available"),l+=`<td class="${S.join(" ")}" data-title="r${m}c${k}">${i[m][k].day}</td>`}l+="</tr>"}this.container.find(".drp-calendar."+s+" .calendar-table tbody").html(l)}renderTimePicker(s){if(s==="end"&&!this.#e)return;var t,n,a,r=this.maxDate;let i="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(i+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#t.plus(this.maxSpan)<this.maxDate)&&(r=this.#t.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#t.plus(this.defaultSpan??this.minSpan)),s==="start")t=this.#t,a=this.minDate;else if(s==="end"){t=this.#e,a=this.#t;var d=this.container.find(".drp-calendar .calendar-time.end-time");d.html()!=""&&(t=t.set({hour:isNaN(t.hour)?d.find(".hourselect option:selected").val():t.hour,minute:isNaN(t.minute)?d.find(".minuteselect option:selected").val():t.minute,second:isNaN(t.second)?d.find(".secondselect option:selected").val():t.second})),t<this.#t&&(t=this.#t),r&&t>r&&(t=r)}i+='<th colspan="7">',this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="hourselect">';const f=t.toFormat("a",{locale:"en-US"});let e=0;this.timePicker24Hour||(e=f==="AM"?1:13);for(var l=e;l<=e+23;l+=this.timePickerOpts.hourStep){let g=t.set({hour:l%24}),y=!1;if(a&&g.set({minute:59})<a&&(y=!0),r&&g.set({minute:0})>r&&(y=!0),n&&g.endOf("hour")<n&&(y=!0),!y&&this.isInvalidTime(g,this.singleDatePicker?null:s,"hour")&&(y=!0),this.timePicker24Hour)!y&&l==t.hour?i+=`<option value="${l}" selected>${l}</option>`:y?i+=`<option value="${l}" disabled class="disabled">${l}</option>`:i+=`<option value="${l}">${l}</option>`;else{const v=o.fromFormat(`${l%24}`,"H").toFormat("h"),D=o.fromFormat(`${l%24}`,"H").toFormat("a",{locale:"en-US"});f==D?!y&&l==t.hour?i+=`<option ampm="${D}" value="${l%24}" selected>${v}</option>`:y?i+=`<option ampm="${D}" value="${l%24}" disabled class="disabled">${v}</option>`:i+=`<option ampm="${D}" value="${l%24}">${v}</option>`:i+=`<option ampm="${D}" hidden="hidden" value="${l%24}">${v}</option>`}}if(i+="</select>",this.externalStyle==="bulma"&&(i+="</div>"),this.timePickerOpts.showMinutes){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="minuteselect">';for(var l=0;l<60;l+=this.timePickerOpts.minuteStep){var c=l<10?"0"+l:l;let y=t.set({minute:l}),v=!1;a&&y.set({second:59})<a&&(v=!0),r&&y.set({second:0})>r&&(v=!0),n&&y.endOf("minute")<n&&(v=!0),!v&&this.isInvalidTime(y,this.singleDatePicker?null:s,"minute")&&(v=!0),t.minute==l&&!v?i+=`<option value="${l}" selected>${c}</option>`:v?i+=`<option value="${l}" disabled class="disabled">${c}</option>`:i+=`<option value="${l}">${c}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(this.timePickerOpts.showSeconds){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="secondselect">';for(var l=0;l<60;l+=this.timePickerOpts.secondStep){var c=l<10?"0"+l:l;let v=t.set({second:l}),D=!1;a&&v<a&&(D=!0),r&&v>r&&(D=!0),n&&v<n&&(D=!0),!D&&this.isInvalidTime(v,this.singleDatePicker?null:s,"second")&&(D=!0),t.second==l&&!D?i+=`<option value="${l}" selected>${c}</option>`:D?i+=`<option value="${l}" disabled class="disabled">${c}</option>`:i+=`<option value="${l}">${c}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="ampmselect">';var p="",u="";let g=!1;a&&t.startOf("day")<a&&(g=!0),r&&t.endOf("day")>r&&(g=!0),n&&t.startOf("day")<n&&(g=!0),g?(p=' disabled class="disabled "',u=' disabled class="disabled"'):this.isInvalidTime(t,this.singleDatePicker?null:s,"ampm")&&(t.toFormat("a",{locale:"en-US"})==="AM"?u=' disabled class="disabled"':p=' disabled class="disabled"'),i+=`<option value="AM"${p}`,t.toFormat("a",{locale:"en-US"})==="AM"&&(i+=" selected"),i+=`>${C.meridiems()[0]}</option><option value="PM"${u}`,t.toFormat("a",{locale:"en-US"})==="PM"&&(i+=" selected"),i+=`>${C.meridiems()[1]}</option>`,i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}i+="</div></th>",this.container.find(`.drp-calendar .calendar-time.${s}-time`).html(i)}setApplyBtnState(){this.singleDatePicker||this.#e&&this.#t<=this.#e?this.container.find("button.applyBtn").prop("disabled",!1):this.container.find("button.applyBtn").prop("disabled",!0)}move(){var s={top:0,left:0},t,n=this.drops,a=h(window).width();switch(this.parentEl.is("body")||(s={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},a=this.parentEl[0].clientWidth+this.parentEl.offset().left),n){case"auto":t=this.element.offset().top+this.element.outerHeight()-s.top,t+this.container.outerHeight()>=this.parentEl[0].scrollHeight&&(t=this.element.offset().top-this.container.outerHeight()-s.top,n="up");break;case"up":t=this.element.offset().top-this.container.outerHeight()-s.top;break;default:t=this.element.offset().top+this.element.outerHeight()-s.top;break}this.container.css({top:0,left:0,right:"auto"});var r=this.container.outerWidth();if(this.container.toggleClass("drop-up",n==="up"),this.opens==="left"){var i=a-this.element.offset().left-this.element.outerWidth();r+i>h(window).width()?this.container.css({top:t,right:"auto",left:9}):this.container.css({top:t,right:i,left:"auto"})}else if(this.opens==="center"){var d=this.element.offset().left-s.left+this.element.outerWidth()/2-r/2;d<0?this.container.css({top:t,right:"auto",left:9}):d+r>h(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:d,right:"auto"})}else{var d=this.element.offset().left-s.left;d+r>h(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:d,right:"auto"})}}show(){this.isShowing||(this._outsideClickProxy=function(s){this.outsideClick(s)}.bind(this),h(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),h(window).on("resize.daterangepicker",function(s){this.move(s)}.bind(this)),this.oldStartDate=this.#t,this.oldEndDate=this.#e,this.updateView(!1),this.container.show(),this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){this.isShowing&&(this.#e||(this.#t=this.oldStartDate,this.#e=this.oldEndDate),(!this.#t.equals(this.oldStartDate)||!this.#e.equals(this.oldEndDate))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),!this.triggerHandler(this.#i.onBeforeHide)&&(h(document).off(".daterangepicker"),h(window).off(".daterangepicker"),this.container.hide(),this.triggerEvent(this.#i.onHide),this.isShowing=!1))}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.addClass("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.removeClass("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(s){var t=h(s.target);s.type==="focusin"||t.closest(this.element).length||t.closest(this.container).length||t.closest(".calendar-table").length||(this.onOutsideClick==="cancel"&&(this.#t=this.oldStartDate,this.#e=this.oldEndDate),this.hide(),this.triggerEvent(this.#i.onOutsideClick))}clickPrev(s){var t=h(s.target).parents(".drp-calendar");t.hasClass("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(s){var t=h(s.target).parents(".drp-calendar");t.hasClass("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(s){if(!h(s.target).hasClass("available"))return;let t=h(s.target).attr("data-title");const n=t.substring(1,2),a=t.substring(3,4);var i=h(s.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const d=this.leftCalendar,f=this.rightCalendar,e=this.#t,l=this.initalMonth;this.#e||this.container.find(".drp-calendar tbody td").each(function(c,p){if(h(p).hasClass("week"))return;const u=h(p).attr("data-title"),g=u.substring(1,2),y=u.substring(3,4),D=h(p).parents(".drp-calendar").hasClass("left")?d.calendar[g][y]:f.calendar[g][y];!e&&l?h(p).removeClass("in-range"):D>e&&D<i||D.hasSame(i,"day")?h(p).addClass("in-range"):h(p).removeClass("in-range")})}hoverRange(s){const t=s.target.getAttribute("data-range-key"),n=[this.#t,this.#e],a=this.ranges[t]??[this.#t,this.#e],r=this.leftCalendar,i=this.rightCalendar;this.container.find(".drp-calendar tbody td").each(function(d,f){if(h(f).hasClass("week"))return;const e=h(f).attr("data-title"),l=e.substring(1,2),c=e.substring(3,4),u=h(f).parents(".drp-calendar").hasClass("left")?r.calendar[l][c]:i.calendar[l][c];let g=!1;u.hasSame(a[0],"day")&&(g=h(f).addClass("start-hover").length>0),u.hasSame(n[0],"day")&&(g=h(f).addClass("start-date").length>0),u.hasSame(a[1],"day")&&(g=h(f).addClass("end-hover").length>0),n[1]!=null&&u.hasSame(n[1],"day")&&(g=h(f).addClass("end-date").length>0),u.startOf("day")>=a[0].startOf("day")&&u.startOf("day")<=a[1].startOf("day")&&(g=h(f).addClass("range-hover").length>0),u.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&u.startOf("day")<=n[1].startOf("day")&&(g=h(f).addClass("in-range").length>0),g||(h(f).removeClass("start-hover"),h(f).removeClass("end-hover"),h(f).removeClass("start-date"),h(f).removeClass("end-date"),h(f).removeClass("in-range"),h(f).removeClass("range-hover"))})}leaveRange(s){this.container.find(".drp-calendar tbody td").each(function(t,n){h(n).hasClass("week")||(h(n).removeClass("start-hover"),h(n).removeClass("end-hover"),h(n).removeClass("range-hover"))})}clickRange(s){var t=s.target.getAttribute("data-range-key");if(this.chosenLabel=t,t==this.locale.customRangeLabel)this.showCalendars();else{var n=this.ranges[t];const a=!this.#t.hasSame(n[0],"month")||!this.#e.hasSame(n[1],"month");this.#t=n[0],this.#e=n[1],this.timePicker||(this.#t.startOf("day"),this.#e.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerHandler(this.#i.onBeforeHide)&&this.updateView(a),this.clickApply()}}clickDate(s){if(!h(s.target).hasClass("available"))return;var t=h(s.target).attr("data-title"),n=t.substring(1,2),a=t.substring(3,4),r=h(s.target).parents(".drp-calendar"),i=r.hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];let d;if(this.#e||!this.#t||i<this.#t.startOf("day")){if(this.timePicker){let f=parseInt(this.container.find(".start-time .hourselect").val(),10);isNaN(f)&&(f=parseInt(this.container.find(".start-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".start-time .secondselect option:last").val(),10))),i=i.set({hour:f,minute:e,second:l})}else i=i.startOf("day");this.#e=null,this.#t=i,d="start"}else if(!this.#e&&i<this.#t)this.#e=this.#t,d="end";else{if(this.timePicker){let f=parseInt(this.container.find(".end-time .hourselect").val(),10);isNaN(f)&&(f=parseInt(this.container.find(".end-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".end-time .secondselect option:last").val(),10))),i=i.set({hour:f,minute:e,second:l})}else i=i.endOf("day");this.#e=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),d="end"}this.singleDatePicker&&(this.#e=this.#t,!this.timePicker&&this.autoApply&&this.clickApply(),d=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,d)}calculateChosenLabel(){var s=!0,t=0;for(var n in this.ranges){var a=this.timePicker?"hour":"day";if(this.timePicker&&(this.timePickerOpts.showMinutes?a="minute":this.timePickerOpts.showSeconds&&(a="second")),this.#t.startOf(a).equals(this.ranges[n][0].startOf(a))&&this.#e.startOf(a).equals(this.ranges[n][1].startOf(a))){s=!1,this.chosenLabel=this.container.find(".ranges li:eq("+t+")").addClass("active").attr("data-range-key");break}t++}s&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").attr("data-range-key"):this.chosenLabel=null,this.showCalendars())}timeChanged(s){const t=h(s.target).closest(".calendar-time"),n=t.hasClass("start-time")?"start":"end";var a=parseInt(t.find(".hourselect").val(),10);if(isNaN(a)&&(a=parseInt(t.find(".hourselect option:last").val(),10)),!this.timePicker24Hour){const d=t.find(".ampmselect").val();if(d==null&&t.find(".ampmselect option:last").val(),d!=o.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){t.find(".hourselect > option").each(function(){const e=h(this).attr("hidden")||!1;h(this).attr("hidden",e)});const f=o.fromFormat(`${a}`,"H").toFormat("h");a=o.fromFormat(`${f}${d}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(t.find(".minuteselect").val(),10),isNaN(r)&&(r=parseInt(t.find(".minuteselect option:last").val(),10)));var i=0;this.timePickerOpts.showSeconds&&(i=parseInt(t.find(".secondselect").val(),10),isNaN(i)&&(i=parseInt(t.find(".secondselect option:last").val(),10))),n==="start"?(this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:i})),this.singleDatePicker?this.#e=this.#t:this.#e&&this.#e.hasSame(this.#t,"day")&&this.#e<this.#t&&(this.#e=this.#t)):this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:i})),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,this.singleDatePicker?null:n)}monthOrYearChanged(s){var t=h(s.target).closest(".drp-calendar").hasClass("left"),n=t?"left":"right",a=this.container.find(".drp-calendar."+n),r=parseInt(a.find(".monthselect").val(),10),i=a.find(".yearselect").val();let d=!1;t||(i<this.#t.year||i==this.#t.year&&r<this.#t.month)&&(r=this.#t.month,i=this.#t.year),this.minDate&&(i<this.minDate.year||i==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,i=this.minDate.year),this.maxDate&&(i>this.maxDate.year||i==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,i=this.maxDate.year),t?(d=!o.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(d=!o.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(d)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#t=this.oldStartDate,this.#e=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.element.is("input:text")||!this.element.val().length)return;const s=typeof this.locale.format=="string"?this.locale.format:o.parseFormatForOpts(this.locale.format),t=this.element.val().split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=o.fromFormat(this.element.val(),s,{locale:o.now().locale});const r=this.#t;if(!a.isValid||r.equals(a))return;const i=this.validateInput([a,null],!0);if(i!=null)if(i.newDate!=null)a=i.newDate.startDate;else return;n=!this.#t.hasSame(a,"month"),this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else if(!this.singleDatePicker&&t.length===2){const a=[0,1].map(d=>o.fromFormat(t[d],s,{locale:o.now().locale})),r=[this.#t,this.#e];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const i=this.validateInput([a[0],a[1]],!0);if(i!=null)if(i.newDate!=null)a[0]=i.newDate.startDate,a[1]=i.newDate.endDate;else return;n=!this.#t.hasSame(a[0],"month")||!this.#e.hasSame(a[1],"month"),this.#t=a[0],this.#e=a[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else return;this.updateView(n),this.updateElement(),this.triggerEvent(this.#i.onInputChange)}keydown(s){(s.keyCode===9||s.keyCode===13)&&this.hide(),s.keyCode===27&&(s.preventDefault(),s.stopPropagation(),this.hide())}updateElement(){if(!(this.#t==null&&this.initalMonth))if(this.element.is("input:text")){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.updateAltInput(),s!==this.element.val()&&this.element.val(s).trigger("change")}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.singleDatePicker&&h(this.altInput[1]).val(null),this.altFormat==null){let s="day";this.timePicker&&(this.timePickerOpts.showSeconds?s="second":this.timePickerOpts.showMinutes?s="minute":s="hour");const t=this.#t.toISO({format:"basic",precision:s,includeOffset:!1});if(h(this.singleDatePicker?this.altInput:this.altInput[0]).val(t),!this.singleDatePicker&&this.#e){const n=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});h(this.altInput[1]).val(n)}}else{const s=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);if(h(this.singleDatePicker?this.altInput:this.altInput[0]).val(s),!this.singleDatePicker&&this.#e){const t=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);h(this.altInput[1]).val(t)}}}remove(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}triggerEvent(s,...t){if(t.length===0)this.element.trigger(s.type,s.param);else{const n=s.param(...t);this.element.trigger(s.type,n)}}triggerHandler(s,...t){if(t.length===0)return this.element.triggerHandler(s.type,s.param);{const n=s.param(...t);return this.element.triggerHandler(s.type,n)}}}h.fn.daterangepicker||(h.fn.daterangepicker=function(P,s){const t=h.extend(!0,{},h.fn.daterangepicker.defaultOptions,P);return this.each(function(){const n=h(this);n.data("daterangepicker")&&n.data("daterangepicker").remove(),n.data("daterangepicker",new I(n,t,s))}),this});var V=I;export{V as default};
|
|
@@ -545,7 +545,7 @@ var DateRangePicker = (() => {
|
|
|
545
545
|
* `minDate`, `maxDate`, `minSpan`, `maxSpan`, `invalidDate` and `invalidTime` constraints.<br>
|
|
546
546
|
* Event is only triggered when date string is valid and date value is changing<br>
|
|
547
547
|
* @event
|
|
548
|
-
* @name "
|
|
548
|
+
* @name "violate.daterangepicker"
|
|
549
549
|
* @param {DateRangePicker} picker - The daterangepicker object
|
|
550
550
|
* @param {InputViolation} result - The violation object, see example of `validateInput()`
|
|
551
551
|
* @param {Object} newDate - Object of {startDate, endDate}
|
|
@@ -561,7 +561,7 @@ var DateRangePicker = (() => {
|
|
|
561
561
|
* locale: {
|
|
562
562
|
* format: DateTime.DATETIME_SHORT
|
|
563
563
|
* }
|
|
564
|
-
* }).on('
|
|
564
|
+
* }).on('violate.daterangepicker', (ev, picker, result, newDate) => {
|
|
565
565
|
* newDate.startDate = DateTime.now().minus({ days: 3 }).startOf('day');
|
|
566
566
|
* return true;
|
|
567
567
|
* });
|
|
@@ -574,7 +574,7 @@ var DateRangePicker = (() => {
|
|
|
574
574
|
*
|
|
575
575
|
* // -> Calendar selects and shows "today - 3 days"
|
|
576
576
|
*/
|
|
577
|
-
|
|
577
|
+
onViolate: { type: "violate.daterangepicker", param: (...args) => [this, ...args] },
|
|
578
578
|
/**
|
|
579
579
|
* Emitted before the calendar time picker is rendered.
|
|
580
580
|
* @event
|
|
@@ -666,18 +666,26 @@ var DateRangePicker = (() => {
|
|
|
666
666
|
/**
|
|
667
667
|
* Emitted when the date is changed through `<input>` element. Event is only triggered when date string is valid and date value has changed
|
|
668
668
|
* @event
|
|
669
|
-
* @name "
|
|
669
|
+
* @name "inputChange.daterangepicker"
|
|
670
670
|
* @param {DateRangePicker} this - The daterangepicker object
|
|
671
671
|
*/
|
|
672
|
-
|
|
672
|
+
onInputChange: { type: "inputChange.daterangepicker", param: this },
|
|
673
673
|
/**
|
|
674
674
|
* Emitted after month view changed, for example by click on 'prev' or 'next'
|
|
675
675
|
* @event
|
|
676
|
-
* @name "
|
|
676
|
+
* @name "monthViewChange.daterangepicker"
|
|
677
677
|
* @param {DateRangePicker} this - The daterangepicker object
|
|
678
|
+
* @param {external:DateTime} left - For day of left-hand calendar
|
|
679
|
+
* @param {external:DateTime|null} right - For day of right-hand calendar
|
|
678
680
|
*/
|
|
679
|
-
|
|
681
|
+
onMonthViewChange: {
|
|
682
|
+
type: "monthViewChange.daterangepicker",
|
|
683
|
+
param: (left, right) => [this, left.startOf("month"), right ? right.startOf("month") : null]
|
|
684
|
+
}
|
|
680
685
|
};
|
|
686
|
+
/**
|
|
687
|
+
* Getter for all DateRangePickerEvents
|
|
688
|
+
*/
|
|
681
689
|
get events() {
|
|
682
690
|
return this.#events;
|
|
683
691
|
}
|
|
@@ -708,7 +716,7 @@ var DateRangePicker = (() => {
|
|
|
708
716
|
return violations;
|
|
709
717
|
}
|
|
710
718
|
}
|
|
711
|
-
const
|
|
719
|
+
const monthChange = !this.#startDate.hasSame(newDate, "month");
|
|
712
720
|
this.#startDate = newDate;
|
|
713
721
|
this.#endDate = this.#startDate;
|
|
714
722
|
if (!this.timePicker) {
|
|
@@ -717,7 +725,7 @@ var DateRangePicker = (() => {
|
|
|
717
725
|
}
|
|
718
726
|
this.updateElement();
|
|
719
727
|
if (updateView)
|
|
720
|
-
this.updateView(
|
|
728
|
+
this.updateView(monthChange);
|
|
721
729
|
return violations;
|
|
722
730
|
}
|
|
723
731
|
/**
|
|
@@ -764,7 +772,7 @@ var DateRangePicker = (() => {
|
|
|
764
772
|
return violations;
|
|
765
773
|
}
|
|
766
774
|
}
|
|
767
|
-
const
|
|
775
|
+
const monthChange = !this.#startDate.hasSame(newDate[0], "month") || !this.#endDate.hasSame(newDate[1], "month");
|
|
768
776
|
this.#startDate = newDate[0];
|
|
769
777
|
this.#endDate = newDate[1];
|
|
770
778
|
if (!this.timePicker) {
|
|
@@ -773,7 +781,7 @@ var DateRangePicker = (() => {
|
|
|
773
781
|
}
|
|
774
782
|
this.updateElement();
|
|
775
783
|
if (updateView)
|
|
776
|
-
this.updateView(
|
|
784
|
+
this.updateView(monthChange);
|
|
777
785
|
return violations;
|
|
778
786
|
}
|
|
779
787
|
/**
|
|
@@ -958,7 +966,7 @@ var DateRangePicker = (() => {
|
|
|
958
966
|
return null;
|
|
959
967
|
if (dipatch) {
|
|
960
968
|
let newValues = { startDate };
|
|
961
|
-
const ret = this.triggerHandler(this.#events.
|
|
969
|
+
const ret = this.triggerHandler(this.#events.onViolate, result, newValues);
|
|
962
970
|
if (ret) {
|
|
963
971
|
result.newDate = newValues;
|
|
964
972
|
return result;
|
|
@@ -1034,7 +1042,7 @@ var DateRangePicker = (() => {
|
|
|
1034
1042
|
return null;
|
|
1035
1043
|
if (dipatch) {
|
|
1036
1044
|
let newValues = { startDate, endDate };
|
|
1037
|
-
const ret = this.triggerHandler(this.#events.
|
|
1045
|
+
const ret = this.triggerHandler(this.#events.onViolate, result, newValues);
|
|
1038
1046
|
if (ret) {
|
|
1039
1047
|
result.newDate = newValues;
|
|
1040
1048
|
return result;
|
|
@@ -1048,10 +1056,10 @@ var DateRangePicker = (() => {
|
|
|
1048
1056
|
/**
|
|
1049
1057
|
* Updates the picker when calendar is initiated or any date has been selected.
|
|
1050
1058
|
* Could be useful after running {@link #DateRangePicker+setStartDate|setStartDate} or {@link #DateRangePicker+setEndDate|setRange}
|
|
1051
|
-
* @param {boolean}
|
|
1059
|
+
* @param {boolean} monthChange - If `true` then monthView changed
|
|
1052
1060
|
* @emits "beforeRenderTimePicker.daterangepicker"
|
|
1053
1061
|
*/
|
|
1054
|
-
updateView(
|
|
1062
|
+
updateView(monthChange) {
|
|
1055
1063
|
if (this.timePicker) {
|
|
1056
1064
|
this.triggerEvent(this.#events.onBeforeRenderTimePicker);
|
|
1057
1065
|
this.renderTimePicker("start");
|
|
@@ -1064,7 +1072,7 @@ var DateRangePicker = (() => {
|
|
|
1064
1072
|
}
|
|
1065
1073
|
this.updateLabel();
|
|
1066
1074
|
this.updateMonthsInView();
|
|
1067
|
-
this.updateCalendars(
|
|
1075
|
+
this.updateCalendars(monthChange);
|
|
1068
1076
|
this.setApplyBtnState();
|
|
1069
1077
|
}
|
|
1070
1078
|
/**
|
|
@@ -1103,11 +1111,11 @@ var DateRangePicker = (() => {
|
|
|
1103
1111
|
/**
|
|
1104
1112
|
* Updates the selected day value from calendar with selected time values
|
|
1105
1113
|
* @emits "beforeRenderCalendar.daterangepicker"
|
|
1106
|
-
* @emits "
|
|
1107
|
-
* @param {boolean}
|
|
1114
|
+
* @emits "monthViewChange.daterangepicker"
|
|
1115
|
+
* @param {boolean} monthChange - If `true` then monthView changed
|
|
1108
1116
|
* @private
|
|
1109
1117
|
*/
|
|
1110
|
-
updateCalendars(
|
|
1118
|
+
updateCalendars(monthChange) {
|
|
1111
1119
|
if (this.timePicker) {
|
|
1112
1120
|
var hour, minute, second;
|
|
1113
1121
|
if (this.#endDate) {
|
|
@@ -1154,8 +1162,12 @@ var DateRangePicker = (() => {
|
|
|
1154
1162
|
this.triggerEvent(this.#events.onBeforeRenderCalendar);
|
|
1155
1163
|
this.renderCalendar("left");
|
|
1156
1164
|
this.renderCalendar("right");
|
|
1157
|
-
if (
|
|
1158
|
-
this.triggerEvent(
|
|
1165
|
+
if (monthChange)
|
|
1166
|
+
this.triggerEvent(
|
|
1167
|
+
this.#events.onMonthViewChange,
|
|
1168
|
+
this.leftCalendar.month,
|
|
1169
|
+
this.singleMonthView || this.singleDatePicker ? null : this.rightCalendar.month
|
|
1170
|
+
);
|
|
1159
1171
|
this.container.find(".ranges li").removeClass("active");
|
|
1160
1172
|
if (this.#endDate == null) return;
|
|
1161
1173
|
this.calculateChosenLabel();
|
|
@@ -1810,7 +1822,7 @@ var DateRangePicker = (() => {
|
|
|
1810
1822
|
this.showCalendars();
|
|
1811
1823
|
} else {
|
|
1812
1824
|
var newDate = this.ranges[label];
|
|
1813
|
-
const
|
|
1825
|
+
const monthChange = !this.#startDate.hasSame(newDate[0], "month") || !this.#endDate.hasSame(newDate[1], "month");
|
|
1814
1826
|
this.#startDate = newDate[0];
|
|
1815
1827
|
this.#endDate = newDate[1];
|
|
1816
1828
|
if (!this.timePicker) {
|
|
@@ -1820,7 +1832,7 @@ var DateRangePicker = (() => {
|
|
|
1820
1832
|
if (!this.alwaysShowCalendars)
|
|
1821
1833
|
this.hideCalendars();
|
|
1822
1834
|
if (this.triggerHandler(this.#events.onBeforeHide))
|
|
1823
|
-
this.updateView(
|
|
1835
|
+
this.updateView(monthChange);
|
|
1824
1836
|
this.clickApply();
|
|
1825
1837
|
}
|
|
1826
1838
|
}
|
|
@@ -2004,7 +2016,7 @@ var DateRangePicker = (() => {
|
|
|
2004
2016
|
var isLeft = $(e.target).closest(".drp-calendar").hasClass("left"), leftOrRight = isLeft ? "left" : "right", cal = this.container.find(".drp-calendar." + leftOrRight);
|
|
2005
2017
|
var month = parseInt(cal.find(".monthselect").val(), 10);
|
|
2006
2018
|
var year = cal.find(".yearselect").val();
|
|
2007
|
-
let
|
|
2019
|
+
let monthChange = false;
|
|
2008
2020
|
if (!isLeft) {
|
|
2009
2021
|
if (year < this.#startDate.year || year == this.#startDate.year && month < this.#startDate.month) {
|
|
2010
2022
|
month = this.#startDate.month;
|
|
@@ -2024,17 +2036,17 @@ var DateRangePicker = (() => {
|
|
|
2024
2036
|
}
|
|
2025
2037
|
}
|
|
2026
2038
|
if (isLeft) {
|
|
2027
|
-
|
|
2039
|
+
monthChange = !DateTime.fromObject({ year, month }).hasSame(this.leftCalendar.month, "month");
|
|
2028
2040
|
this.leftCalendar.month = this.leftCalendar.month.set({ year, month });
|
|
2029
2041
|
if (this.linkedCalendars)
|
|
2030
2042
|
this.rightCalendar.month = this.leftCalendar.month.plus({ month: 1 });
|
|
2031
2043
|
} else {
|
|
2032
|
-
|
|
2044
|
+
monthChange = !DateTime.fromObject({ year, month }).hasSame(this.leftCalendar.month, "month");
|
|
2033
2045
|
this.rightCalendar.month = this.rightCalendar.month.set({ year, month });
|
|
2034
2046
|
if (this.linkedCalendars)
|
|
2035
2047
|
this.leftCalendar.month = this.rightCalendar.month.minus({ month: 1 });
|
|
2036
2048
|
}
|
|
2037
|
-
this.updateCalendars(
|
|
2049
|
+
this.updateCalendars(monthChange);
|
|
2038
2050
|
}
|
|
2039
2051
|
/**
|
|
2040
2052
|
* User clicked `Apply` button
|
|
@@ -2060,7 +2072,7 @@ var DateRangePicker = (() => {
|
|
|
2060
2072
|
/**
|
|
2061
2073
|
* Update the picker with value from `<input>` element.<br>
|
|
2062
2074
|
* Input values must be given in format of `locale.format`. Invalid values are handles by `violated.daterangepicker` Event
|
|
2063
|
-
* @emits "
|
|
2075
|
+
* @emits "inputChange.daterangepicker"
|
|
2064
2076
|
* @private
|
|
2065
2077
|
*/
|
|
2066
2078
|
elementChanged() {
|
|
@@ -2068,7 +2080,7 @@ var DateRangePicker = (() => {
|
|
|
2068
2080
|
if (!this.element.val().length) return;
|
|
2069
2081
|
const format = typeof this.locale.format === "string" ? this.locale.format : DateTime.parseFormatForOpts(this.locale.format);
|
|
2070
2082
|
const dateString = this.element.val().split(this.locale.separator);
|
|
2071
|
-
let
|
|
2083
|
+
let monthChange = false;
|
|
2072
2084
|
if (this.singleDatePicker) {
|
|
2073
2085
|
let newDate = DateTime.fromFormat(this.element.val(), format, { locale: DateTime.now().locale });
|
|
2074
2086
|
const oldDate = this.#startDate;
|
|
@@ -2082,7 +2094,7 @@ var DateRangePicker = (() => {
|
|
|
2082
2094
|
return;
|
|
2083
2095
|
}
|
|
2084
2096
|
}
|
|
2085
|
-
|
|
2097
|
+
monthChange = !this.#startDate.hasSame(newDate, "month");
|
|
2086
2098
|
this.#startDate = newDate;
|
|
2087
2099
|
this.#endDate = this.#startDate;
|
|
2088
2100
|
if (!this.timePicker) {
|
|
@@ -2103,7 +2115,7 @@ var DateRangePicker = (() => {
|
|
|
2103
2115
|
return;
|
|
2104
2116
|
}
|
|
2105
2117
|
}
|
|
2106
|
-
|
|
2118
|
+
monthChange = !this.#startDate.hasSame(newDate[0], "month") || !this.#endDate.hasSame(newDate[1], "month");
|
|
2107
2119
|
this.#startDate = newDate[0];
|
|
2108
2120
|
this.#endDate = newDate[1];
|
|
2109
2121
|
if (!this.timePicker) {
|
|
@@ -2113,9 +2125,9 @@ var DateRangePicker = (() => {
|
|
|
2113
2125
|
} else {
|
|
2114
2126
|
return;
|
|
2115
2127
|
}
|
|
2116
|
-
this.updateView(
|
|
2128
|
+
this.updateView(monthChange);
|
|
2117
2129
|
this.updateElement();
|
|
2118
|
-
this.triggerEvent(this.#events.
|
|
2130
|
+
this.triggerEvent(this.#events.onInputChange);
|
|
2119
2131
|
}
|
|
2120
2132
|
/**
|
|
2121
2133
|
* Handles key press, IE 11 compatibility
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var DateRangePicker=(()=>{const h=luxon.DateTime,D=luxon.Duration,S=luxon.Info,P=luxon.Settings;class I{#t=null;#e=null;constructor(s,t,n){this.parentEl="body",this.element=$(s),this.#t=h.now().startOf("day"),this.#e=h.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initalMonth=h.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=h.now().minus({year:100}).year,this.maxYear=h.now().plus({year:100}).year,this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.showLabel=!$(this.element).is("input:text"),this.timePicker=!1;const a=new Intl.DateTimeFormat(h.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=D.fromObject({minutes:1}),this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.isInvalidDate=null,this.isInvalidTime=null,this.isCustomDate=null,this.onOutsideClick="apply",this.opens=this.element.hasClass("pull-right")?"left":"right",this.drops=this.element.hasClass("dropup")?"up":"down",this.buttonClasses="btn btn-sm",this.applyButtonClasses="btn-primary",this.cancelButtonClasses="btn-default",this.weekendClasses="weekend",this.weekendDayClasses="weekend-day",this.todayClasses="today",this.altInput=null,this.altFormat=null,this.externalStyle=null,this.ranges={},this.locale={direction:"ltr",format:h.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:S.weekdays("short"),monthNames:S.months("long"),firstDay:S.getStartOfWeek(),durationFormat:null},this.callback=function(){},this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof t!="object"||t===null)&&(t={}),t=$.extend(this.element.data(),t),typeof t.singleDatePicker=="boolean"&&(this.singleDatePicker=t.singleDatePicker),!this.singleDatePicker&&typeof t.singleMonthView=="boolean"?this.singleMonthView=t.singleMonthView:this.singleMonthView=!1,typeof t.externalStyle=="string"&&["bulma"].includes(t.externalStyle)&&(this.externalStyle=t.externalStyle),typeof t.template!="string"&&!(t.template instanceof $)){let e=['<div class="daterangepicker">','<div class="ranges"></div>','<div class="drp-calendar left">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time start-time"></tr>'];this.singleMonthView&&e.push('<tr class="calendar-time end-time"></tr>'),e.push("</tfoot>","</table>","</div>"),e.push('<div class="drp-calendar right">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time end-time"></tr>',"</tfoot>","</table>","</div>"),e.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?e.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):e.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),e.push("</div></div>"),t.template=e.join("")}if(this.parentEl=t.parentEl&&$(t.parentEl).length?$(t.parentEl):$(this.parentEl),this.container=$(t.template).appendTo(this.parentEl),typeof t.timePicker=="boolean"&&(this.timePicker=t.timePicker),this.timePicker&&(this.locale.format=h.DATETIME_SHORT),typeof t.locale=="object"){for(let e of["separator","applyLabel","cancelLabel","weekLabel"])typeof t.locale[e]=="string"&&(this.locale[e]=t.locale[e]);if(typeof t.locale.direction=="string"&&(["rtl","ltr"].includes(t.locale.direction)?this.locale.direction=t.locale.direction:console.error("Option 'options.locale.direction' must be 'rtl' or 'ltr'")),["string","object"].includes(typeof t.locale.format)&&(this.locale.format=t.locale.format),Array.isArray(t.locale.daysOfWeek)&&(t.locale.daysOfWeek.some(e=>typeof e!="string")?console.error("Option 'options.locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=t.locale.daysOfWeek.slice()),Array.isArray(t.locale.monthNames)&&(t.locale.monthNames.some(e=>typeof e!="string")?console.error("Option 'locale.monthNames' must be an array of strings"):this.locale.monthNames=t.locale.monthNames.slice()),typeof t.locale.firstDay=="number"&&(this.locale.firstDay=t.locale.firstDay),typeof t.locale.customRangeLabel=="string"){var r=document.createElement("textarea");r.innerHTML=t.locale.customRangeLabel;var i=r.value;this.locale.customRangeLabel=i}["string","object","function"].includes(typeof t.locale.durationFormat)&&t.locale.durationFormat!=null&&(this.locale.durationFormat=t.locale.durationFormat)}this.container.addClass(this.locale.direction);for(let e of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel"])typeof t[e]=="boolean"&&(this[e]=t[e]);for(let e of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof t[e]=="string"?this[e]=t[e]:["weekendClasses","weekendDayClasses","todayClasses"].includes(e)&&t[e]===null&&(this[e]=t[e]);for(let e of["minYear","maxYear"])typeof t[e]=="number"&&(this[e]=t[e]);for(let e of["isInvalidDate","isInvalidTime","isCustomDate"])typeof t[e]=="function"?this[e]=t[e]:this[e]=function(){return!1};if(!this.singleDatePicker){for(let e of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof t[e])&&(D.isDuration(t[e])&&t[e].isValid?this[e]=t[e]:D.fromISO(t[e]).isValid?this[e]=D.fromISO(t[e]):typeof t[e]=="number"&&D.fromObject({seconds:t[e]}).isValid?this[e]=D.fromObject({seconds:t[e]}):t[e]===null?this[e]=null:console.error(`Option '${key}' is not valid`));this.minSpan&&this.maxSpan&&this.minSpan>this.maxSpan&&(this.minSpan=null,this.maxSpan=null,console.warn("Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'")),this.defaultSpan&&this.minSpan&&this.minSpan>this.defaultSpan?(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'")):this.defaultSpan&&this.maxSpan&&this.maxSpan<this.defaultSpan&&(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'"))}if(this.timePicker){if(typeof t.timePickerSeconds=="boolean"&&(this.timePickerStepSize=D.fromObject({[t.timePickerSeconds?"seconds":"minutes"]:1})),typeof t.timePickerIncrement=="number"&&(this.timePickerStepSize=D.fromObject({minutes:t.timePickerIncrement})),["string","object","number"].includes(typeof t.timePickerStepSize)){let e;D.isDuration(t.timePickerStepSize)&&t.timePickerStepSize.isValid?e=t.timePickerStepSize:D.fromISO(t.timePickerStepSize).isValid?e=D.fromISO(t.timePickerStepSize):typeof t.timePickerStepSize=="number"&&D.fromObject({seconds:t.timePickerStepSize}).isValid?e=D.fromObject({seconds:t.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),e=this.timePickerStepSize);var o=[];for(let l of["minutes","seconds"])o.push(...[1,2,3,4,5,6,10,12,15,20,30].map(d=>D.fromObject({[l]:d})));o.push(...[1,2,3,4,6].map(l=>D.fromObject({hours:l}))),this.timePicker24Hour&&o.push(...[8,12].map(l=>D.fromObject({hours:l}))),o.some(l=>e.rescale().equals(l))?this.timePickerStepSize=e.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(e.toObject())} is not valid`)}this.maxSpan&&this.timePickerStepSize>this.maxSpan&&console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`),this.timePickerOpts={showMinutes:this.timePickerStepSize<D.fromObject({hours:1}),showSeconds:this.timePickerStepSize<D.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=D.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=D.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let e of["startDate","endDate","minDate","maxDate","initalMonth"])if(!(e==="endDate"&&this.singleDatePicker)){if(typeof t[e]=="object")h.isDateTime(t[e])&&t[e].isValid?this[e]=t[e]:t[e]instanceof Date?this[e]=h.fromJSDate(t[e]):t[e]===null?this[e]=null:console.error(`Option '${e}' must be a luxon.DateTime or Date or string`);else if(typeof t[e]=="string"){const l=typeof this.locale.format=="string"?this.locale.format:h.parseFormatForOpts(this.locale.format);if(h.fromISO(t[e]).isValid)this[e]=h.fromISO(t[e]);else if(h.fromFormat(t[e],l,{locale:h.now().locale}).isValid)this[e]=h.fromFormat(t[e],l,{locale:h.now().locale});else{const d=h.fromFormat(t[e],l,{locale:h.now().locale}).invalidExplanation;console.error(`Option '${e}' is not a valid string: ${d}`)}}}if($(this.element).is("input:text")){const e=$(this.element).val();if(e!=""){const l=typeof this.locale.format=="string"?this.locale.format:h.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof t.startDate>"u"){const d=h.fromFormat(e,l,{locale:h.now().locale});d.isValid?this.#t=d:console.error(`Value "${e}" in <input> is not a valid string: ${d.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof t.startDate>"u"&&typeof t.endDate>"u"){const d=e.split(this.locale.separator);if(d.length===2){const u=h.fromFormat(d[0],l,{locale:h.now().locale}),m=h.fromFormat(d[1],l,{locale:h.now().locale});u.isValid&&m.isValid?(this.#t=u,this.#e=m):console.error(`Value in <input> is not a valid string: ${u.invalidExplanation} - ${m.invalidExplanation}`)}else console.error(`Value "${e}" in <input> is not a valid string`)}}}if(this.singleDatePicker?this.#e=this.#t:this.#e<this.#t&&console.error(`Option 'endDate' ${this.#e} must not be earlier than 'startDate' ${this.#t}`),this.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day")),this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),t.warnings!==void 0&&console.warn("Option 'warnings' not used anymore. Listen to event 'violated.daterangepicker'"),!this.#t&&this.initalMonth)this.#e=null,this.timePicker&&console.error("Option 'initalMonth' works only with 'timePicker: false'");else{const e=this.validateInput(null,!1);if(e!=null){let l=e.startDate.violations;if(l.length>0)if(l.some(d=>d.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#t}" violates ${l.find(d=>d.reason.startsWith("isInvalid")).reason}`);else{const d=l.filter(u=>u.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#t} to ${d}`),this.#t=d}if(!this.singleDatePicker&&(l=e.endDate.violations.filter(d=>d.new!=null),l.length>0))if(l.some(d=>d.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#e}" violates ${l.find(d=>d.reason.startsWith("isInvalid")).reason}`);else{const d=l.filter(u=>u.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#e} to ${d}`),this.#e=d}}}if(["function","string"].includes(typeof t.altFormat)&&(this.altFormat=t.altFormat),typeof t.altInput=="string"||Array.isArray(t.altInput))if(this.singleDatePicker&&typeof t.altInput=="string")this.altInput=$(t.altInput).is("input:text")?t.altInput:null;else if(!this.singleDatePicker&&Array.isArray(t.altInput)&&t.altInput.length===2)this.altInput=t.altInput.every(e=>typeof e=="string"&&$(e).is("input:text"))?t.altInput:null;else{const e='Value of "altInput" must be '+(this.singleDatePicker?"a string":"an array of two string elements");console.error(`Option 'altInput' ${JSON.stringify(t.altInput)} is not valid
|
|
2
|
-
`,e)}if(typeof t.opens=="string"&&(["left","right","center"].includes(t.opens)?this.opens=t.opens:console.error("Option 'options.opens' must be 'left', 'right' or 'center'")),typeof t.drops=="string"&&(["drop","down","auto"].includes(t.drops)?this.drops=t.drops:console.error("Option 'options.drops' must be 'drop', 'down' or 'auto'")),Array.isArray(t.buttonClasses)?this.buttonClasses=t.buttonClasses.join(" "):typeof t.buttonClasses=="string"&&(this.buttonClasses=t.buttonClasses),typeof t.onOutsideClick=="string"&&(["cancel","apply"].includes(t.onOutsideClick)?this.onOutsideClick=t.onOutsideClick:console.error("Option 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let e=this.locale.firstDay;for(;e>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),e--}if(!this.singleDatePicker&&typeof t.ranges=="object"){for(let e in t.ranges){let l,d;if(["string","object"].includes(typeof t.ranges[e][0])&&(h.isDateTime(t.ranges[e][0])&&t.ranges[e][0].isValid?l=t.ranges[e][0]:t.ranges[e][0]instanceof Date?l=h.fromJSDate(t.ranges[e][0]):typeof t.ranges[e][0]=="string"&&h.fromISO(t.ranges[e][0]).isValid?l=h.fromISO(t.ranges[e][0]):console.error(`Option ranges['${e}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof t.ranges[e][1])&&(h.isDateTime(t.ranges[e][1])&&t.ranges[e][1].isValid?d=t.ranges[e][1]:t.ranges[e][1]instanceof Date?d=h.fromJSDate(t.ranges[e][1]):typeof t.ranges[e][1]=="string"&&h.fromISO(t.ranges[e][1]).isValid?d=h.fromISO(t.ranges[e][1]):console.error(`Option ranges['${e}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(l==null||d==null)){t.ranges[e]=[l,d];var r=document.createElement("textarea");r.innerHTML=e,this.ranges[r.value]=[l,d]}}var c="<ul>";for(let e in this.ranges)c+='<li data-range-key="'+e+'">'+e+"</li>";this.showCustomRangeLabel&&(c+='<li data-range-key="'+this.locale.customRangeLabel+'">'+this.locale.customRangeLabel+"</li>"),c+="</ul>",this.container.find(".ranges").prepend(c),this.container.addClass("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.find(".calendar-time").hide(),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.addClass("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.addClass("single"),this.container.find(".drp-calendar.left").addClass("single"),this.container.find(".drp-calendar.left").show(),this.container.find(".drp-calendar.right").hide(),!this.timePicker&&this.autoApply&&this.container.addClass("auto-apply")),(typeof t.ranges>"u"&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyButtonClasses.length&&this.container.find(".applyBtn").addClass(this.applyButtonClasses),this.cancelButtonClasses.length&&this.container.find(".cancelBtn").addClass(this.cancelButtonClasses),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".drp-calendar").on("click.daterangepicker",".prev",this.clickPrev.bind(this)).on("click.daterangepicker",".next",this.clickNext.bind(this)).on("mousedown.daterangepicker","td.available",this.clickDate.bind(this)).on("mouseenter.daterangepicker","td.available",this.hoverDate.bind(this)).on("change.daterangepicker","select.yearselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.monthselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.container.find(".ranges").on("click.daterangepicker","li",this.clickRange.bind(this)).on("mouseenter.daterangepicker","li",this.hoverRange.bind(this)).on("mouseleave.daterangepicker","li",this.leaveRange.bind(this)),this.container.find(".drp-buttons").on("click.daterangepicker","button.applyBtn",this.clickApply.bind(this)).on("click.daterangepicker","button.cancelBtn",this.clickCancel.bind(this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":this.show.bind(this),"focus.daterangepicker":this.show.bind(this),"keyup.daterangepicker":this.elementChanged.bind(this),"keydown.daterangepicker":this.keydown.bind(this)}):(this.element.on("click.daterangepicker",this.toggle.bind(this)),this.element.on("keydown.daterangepicker",this.toggle.bind(this))),this.updateElement()}get startDate(){return this.timePicker?this.#t:this.#t.startOf("day")}get endDate(){return this.singleDatePicker?null:this.timePicker?this.#e:this.#e.endOf("day")}set startDate(s){this.#t=s}set endDate(s){this.#e=s}#i={onViolated:{type:"violated.daterangepicker",param:(...s)=>[this,...s]},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker.daterangepicker",param:this},onBeforeRenderCalendar:{type:"beforeRenderCalendar.daterangepicker",param:this},onShow:{type:"show.daterangepicker",param:this},onBeforeHide:{type:"beforeHide.daterangepicker",param:this},onHide:{type:"hide.daterangepicker",param:this},onShowCalendar:{type:"showCalendar.daterangepicker",param:this},onHideCalendar:{type:"hideCalendar.daterangepicker",param:this},onOutsideClick:{type:"outsideClick.daterangepicker",param:this},onDateChange:{type:"dateChange.daterangepicker",param:s=>[this,s]},onTimeChange:{type:"timeChange.daterangepicker",param:s=>[this,s]},onApply:{type:"apply.daterangepicker",param:this},onCancel:{type:"cancel.daterangepicker",param:this},onInputChanged:{type:"inputChanged.daterangepicker",param:this},onMonthViewChanged:{type:"monthViewChanged.daterangepicker",param:this}};get events(){return this.#i}setStartDate(s,t=!0){if(!this.singleDatePicker)return setRange(s,this.#e,t);const n=this.#t;let a=this.parseDate(s);if(a.equals(n))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const i=!this.#t.hasSame(a,"month");return this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),t&&this.updateView(i),r}setEndDate(s,t=!0){return this.singleDatePicker?null:setRange(this.#t,s,t)}setRange(s,t,n=!0){if(this.singleDatePicker)return;this.#e||(this.#e=this.#t);const a=[this.#t,this.#e];let r=[this.parseDate(s),this.parseDate(t)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const i=this.validateInput([r[0],r[1]],!0);if(i!=null)if(i.newDate!=null)r[0]=i.newDate.startDate,r[1]=i.newDate.endDate;else return i;const o=!this.#t.hasSame(r[0],"month")||!this.#e.hasSame(r[1],"month");return this.#t=r[0],this.#e=r[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),n&&this.updateView(o),i}parseDate(s){if(typeof s=="object"){if(h.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return h.fromJSDate(s);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof s=="string"){const t=typeof this.locale.format=="string"?this.locale.format:h.parseFormatForOpts(this.locale.format);if(h.fromISO(s).isValid)return h.fromISO(s);if(h.fromFormat(s,t,{locale:h.now().locale}).isValid)return h.fromFormat(s,t,{locale:h.now().locale});{const n=h.fromFormat(s,t,{locale:h.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${n}`)}}}logDate(s){return this.timePicker?s.toISO({suppressMilliseconds:!0}):s.toISODate()}formatDate(s,t=this.locale.format){if(typeof t=="object")return s.toLocaleString(t);if(P.defaultLocale===null){const n=h.now().locale;return s.toFormat(t,{locale:n})}else return s.toFormat(t)}updateLabel(){if(this.showLabel){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.container.find(".drp-selected").html(s)}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#e){this.container.find(".drp-duration-label").html("");return}if(typeof this.locale.durationFormat=="function")this.container.find(".drp-duration-label").html(this.locale.durationFormat(this.#t,this.#e));else{let s=this.#e.plus({milliseconds:1}).diff(this.#t).rescale().set({milliseconds:0});this.timePicker||(s=s.set({seconds:0,minutes:0,hours:0})),s=s.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.find(".drp-duration-label").html(s.toHuman(this.locale.durationFormat)):this.container.find(".drp-duration-label").html(s.toFormat(this.locale.durationFormat))}}}validateInput(s,t=!1){let n=s==null?this.#t:s[0],a=s==null?this.#e:s[1];if(n==null)return null;let r={startDate:{violations:[]}},i={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const e=this.timePickerStepSize.as("seconds");n=h.fromSeconds(e*Math.round(n.toSeconds()/e)),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)}else n=n.startOf("day");const o=this.timePicker?this.timePickerStepSize.as("seconds"):D.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/o)*o}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)):this.maxDate&&n>this.maxDate&&(i={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/o)*o}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i));let c=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&c.push("minute"),this.timePickerOpts.showSeconds&&c.push("second"),this.timePicker24Hour||c.push("ampm")),this.isInvalidDate(n)&&r.startDate.violations.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let e of c)this.isInvalidTime(n,e,"start")&&r.startDate.violations.push({old:n,reason:"isInvalidTime",unit:e});if(this.singleDatePicker){if(r.startDate.violations.length==0)return null;if(t){let e={startDate:n};return this.triggerHandler(this.#i.onViolated,r,e)&&(r.newDate=e),r}else return r}if(a==null)return null;if(r.endDate={violations:[]},i={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const e=this.timePickerStepSize.as("seconds");a=h.fromSeconds(e*Math.round(a.toSeconds()/e)),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/o)*o}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)):this.minDate&&a<this.minDate&&(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/o)*o}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)),this.maxSpan){const e=n.plus(this.maxSpan);a>e&&(i={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(e.diff(a).as("seconds")/o)*o}),a>e&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.minSpan){const e=n.plus(this.defaultSpan??this.minSpan);a<e&&(i={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(e.diff(a).as("seconds")/o)*o}),a<e&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.isInvalidDate(a)&&r.endDate.violations.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let e of c)this.isInvalidTime(a,e,"end")&&r.endDate.violations.push({old:a,reason:"isInvalidTime",unit:e});if(r.startDate.violations.length==0&&r.endDate.violations.length==0)return null;if(t){let e={startDate:n,endDate:a};return this.triggerHandler(this.#i.onViolated,r,e)&&(r.newDate=e),r}else return r}updateView(s){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.#e?this.container.find(".calendar-time.end-time select").prop("disabled",!1).removeClass("disabled"):this.container.find(".calendar-time.end-time select").prop("disabled",!0).addClass("disabled")),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(s),this.setApplyBtnState()}updateMonthsInView(){if(this.#e){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month"))&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#t.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#e.hasSame(this.#t,"month")?this.rightCalendar.month=this.#e.startOf("month"):this.rightCalendar.month=this.#t.startOf("month").plus({month:1}))}else!this.#t&&this.initalMonth?(this.leftCalendar.month=this.initalMonth,this.singleMonthView||(this.rightCalendar.month=this.initalMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#t,"month")&&!this.rightCalendar.month.hasSame(this.#t,"month")&&(this.leftCalendar.month=this.#t.startOf("month"),this.rightCalendar.month=this.#t.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(s){if(this.timePicker){var t,n,a;this.#e?(t=parseInt(this.container.find(".start-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".start-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".start-time .secondselect option:last").val(),10)))):(t=parseInt(this.container.find(".end-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".end-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".end-time .secondselect option:last").val(),10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:t,minute:n,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:t,minute:n,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),s&&this.triggerEvent(this.#i.onMonthViewChanged),this.container.find(".ranges li").removeClass("active"),this.#e!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var i=s==="left"?this.leftCalendar:this.rightCalendar;i.month==null&&!this.#t&&this.initalMonth&&(i.month=this.initalMonth.startOf("month"));const t=i.month.startOf("month"),n=i.month.endOf("month").startOf("day");var a=i.month.startOf("month").minus({day:1});const r={hour:i.month.hour,minute:i.month.minute,second:i.month.second};var i=[];i.firstDay=t,i.lastDay=n;for(var o=0;o<6;o++)i[o]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let f=0,g=-1;f<42;f++,a=a.plus({day:1}))f%7===0&&g++,i[g][f%7]=a.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var c=s==="left"?this.minDate:this.#t,e=this.maxDate,l="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+="<th></th>"),(!c||c<i.firstDay)&&(!this.linkedCalendars||s==="left")?l+='<th class="prev available"><span></span></th>':l+="<th></th>";var d=`${this.locale.monthNames[i.firstDay.month-1]} ${i.firstDay.year}`;if(this.showDropdowns){const f=(e&&e.year)??this.maxYear,g=(c&&c.year)??this.minYear;let w=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var u=`${w}<select class="monthselect">`,m=1;m<=12;m++)u+=`<option value="${m}"${m===i.firstDay.month?" selected":""}`,(c&&i.firstDay.set({month:m})<c.startOf("month")||e&&i.firstDay.set({month:m})>e.endOf("month"))&&(u+=" disabled"),u+=`>${this.locale.monthNames[m-1]}</option>`;u+="</select>",this.externalStyle==="bulma"&&(u+="</div>"),w=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var p=`${w}<select class="yearselect">`,k=g;k<=f;k++)p+=`<option value="${k}"${k===i.firstDay.year?" selected":""}>${k}</option>`;p+="</select>",this.externalStyle==="bulma"&&(p+="</div>"),d=u+p}l+='<th colspan="5" class="month">'+d+"</th>",(!e||e>i.lastDay.endOf("day"))&&(!this.linkedCalendars||s==="right"||this.singleDatePicker||this.singleMonthView)?l+='<th class="next available"><span></span></th>':l+="<th></th>",l+="</tr>",l+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[f,g]of this.locale.daysOfWeek.entries())l+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&S.getWeekendWeekdays().includes(f+1)&&(l+=` class="${this.weekendDayClasses}"`),l+=`>${g}</th>`;if(l+="</tr>",this.container.find(".drp-calendar."+s+" .calendar-table thead").html(l),l="",this.#e==null&&this.maxSpan){var y=this.#t.plus(this.maxSpan).endOf("day");(!e||y<e)&&(e=y)}var v;this.#e==null&&this.minSpan&&(v=this.#t.plus(this.minSpan).startOf("day"));for(let f=0;f<6;f++){l+="<tr>",this.showISOWeekNumbers?l+='<td class="week">'+i[f][0].weekNumber+"</td>":this.showWeekNumbers&&(l+='<td class="week">'+i[f][0].localWeekNumber+"</td>");for(let g=0;g<7;g++){var b=[];this.todayClasses&&this.todayClasses.length&&i[f][g].hasSame(h.now(),"day")&&b.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&S.getWeekendWeekdays().includes(i[f][g].weekday)&&b.push(this.weekendClasses),i[f][g].month!=i[1][1].month&&b.push("off","ends"),this.minDate&&i[f][g].startOf("day")<this.minDate.startOf("day")&&b.push("off","disabled"),e&&i[f][g].startOf("day")>e.startOf("day")&&b.push("off","disabled"),v&&i[f][g].startOf("day")>this.#t.startOf("day")&&i[f][g].startOf("day")<v.startOf("day")&&b.push("off","disabled"),this.isInvalidDate(i[f][g])&&b.push("off","disabled"),this.#t!=null&&i[f][g].hasSame(this.#t,"day")&&b.push("active","start-date"),this.#e!=null&&i[f][g].hasSame(this.#e,"day")&&b.push("active","end-date"),this.#e!=null&&i[f][g]>this.#t&&i[f][g]<this.#e&&b.push("in-range");var C=this.isCustomDate(i[f][g]);C!==!1&&(typeof C=="string"?b.push(C):Array.prototype.push.apply(b,C)),b.includes("disabled")||b.push("available"),l+=`<td class="${b.join(" ")}" data-title="r${f}c${g}">${i[f][g].day}</td>`}l+="</tr>"}this.container.find(".drp-calendar."+s+" .calendar-table tbody").html(l)}renderTimePicker(s){if(s==="end"&&!this.#e)return;var t,n,a,r=this.maxDate;let i="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(i+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#t.plus(this.maxSpan)<this.maxDate)&&(r=this.#t.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#t.plus(this.defaultSpan??this.minSpan)),s==="start")t=this.#t,a=this.minDate;else if(s==="end"){t=this.#e,a=this.#t;var o=this.container.find(".drp-calendar .calendar-time.end-time");o.html()!=""&&(t=t.set({hour:isNaN(t.hour)?o.find(".hourselect option:selected").val():t.hour,minute:isNaN(t.minute)?o.find(".minuteselect option:selected").val():t.minute,second:isNaN(t.second)?o.find(".secondselect option:selected").val():t.second})),t<this.#t&&(t=this.#t),r&&t>r&&(t=r)}i+='<th colspan="7">',this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="hourselect">';const c=t.toFormat("a",{locale:"en-US"});let e=0;this.timePicker24Hour||(e=c==="AM"?1:13);for(var l=e;l<=e+23;l+=this.timePickerOpts.hourStep){let p=t.set({hour:l%24}),k=!1;if(a&&p.set({minute:59})<a&&(k=!0),r&&p.set({minute:0})>r&&(k=!0),n&&p.endOf("hour")<n&&(k=!0),!k&&this.isInvalidTime(p,this.singleDatePicker?null:s,"hour")&&(k=!0),this.timePicker24Hour)!k&&l==t.hour?i+=`<option value="${l}" selected>${l}</option>`:k?i+=`<option value="${l}" disabled class="disabled">${l}</option>`:i+=`<option value="${l}">${l}</option>`;else{const y=h.fromFormat(`${l%24}`,"H").toFormat("h"),v=h.fromFormat(`${l%24}`,"H").toFormat("a",{locale:"en-US"});c==v?!k&&l==t.hour?i+=`<option ampm="${v}" value="${l%24}" selected>${y}</option>`:k?i+=`<option ampm="${v}" value="${l%24}" disabled class="disabled">${y}</option>`:i+=`<option ampm="${v}" value="${l%24}">${y}</option>`:i+=`<option ampm="${v}" hidden="hidden" value="${l%24}">${y}</option>`}}if(i+="</select>",this.externalStyle==="bulma"&&(i+="</div>"),this.timePickerOpts.showMinutes){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="minuteselect">';for(var l=0;l<60;l+=this.timePickerOpts.minuteStep){var d=l<10?"0"+l:l;let k=t.set({minute:l}),y=!1;a&&k.set({second:59})<a&&(y=!0),r&&k.set({second:0})>r&&(y=!0),n&&k.endOf("minute")<n&&(y=!0),!y&&this.isInvalidTime(k,this.singleDatePicker?null:s,"minute")&&(y=!0),t.minute==l&&!y?i+=`<option value="${l}" selected>${d}</option>`:y?i+=`<option value="${l}" disabled class="disabled">${d}</option>`:i+=`<option value="${l}">${d}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(this.timePickerOpts.showSeconds){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="secondselect">';for(var l=0;l<60;l+=this.timePickerOpts.secondStep){var d=l<10?"0"+l:l;let y=t.set({second:l}),v=!1;a&&y<a&&(v=!0),r&&y>r&&(v=!0),n&&y<n&&(v=!0),!v&&this.isInvalidTime(y,this.singleDatePicker?null:s,"second")&&(v=!0),t.second==l&&!v?i+=`<option value="${l}" selected>${d}</option>`:v?i+=`<option value="${l}" disabled class="disabled">${d}</option>`:i+=`<option value="${l}">${d}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="ampmselect">';var u="",m="";let p=!1;a&&t.startOf("day")<a&&(p=!0),r&&t.endOf("day")>r&&(p=!0),n&&t.startOf("day")<n&&(p=!0),p?(u=' disabled class="disabled "',m=' disabled class="disabled"'):this.isInvalidTime(t,this.singleDatePicker?null:s,"ampm")&&(t.toFormat("a",{locale:"en-US"})==="AM"?m=' disabled class="disabled"':u=' disabled class="disabled"'),i+=`<option value="AM"${u}`,t.toFormat("a",{locale:"en-US"})==="AM"&&(i+=" selected"),i+=`>${S.meridiems()[0]}</option><option value="PM"${m}`,t.toFormat("a",{locale:"en-US"})==="PM"&&(i+=" selected"),i+=`>${S.meridiems()[1]}</option>`,i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}i+="</div></th>",this.container.find(`.drp-calendar .calendar-time.${s}-time`).html(i)}setApplyBtnState(){this.singleDatePicker||this.#e&&this.#t<=this.#e?this.container.find("button.applyBtn").prop("disabled",!1):this.container.find("button.applyBtn").prop("disabled",!0)}move(){var s={top:0,left:0},t,n=this.drops,a=$(window).width();switch(this.parentEl.is("body")||(s={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},a=this.parentEl[0].clientWidth+this.parentEl.offset().left),n){case"auto":t=this.element.offset().top+this.element.outerHeight()-s.top,t+this.container.outerHeight()>=this.parentEl[0].scrollHeight&&(t=this.element.offset().top-this.container.outerHeight()-s.top,n="up");break;case"up":t=this.element.offset().top-this.container.outerHeight()-s.top;break;default:t=this.element.offset().top+this.element.outerHeight()-s.top;break}this.container.css({top:0,left:0,right:"auto"});var r=this.container.outerWidth();if(this.container.toggleClass("drop-up",n==="up"),this.opens==="left"){var i=a-this.element.offset().left-this.element.outerWidth();r+i>$(window).width()?this.container.css({top:t,right:"auto",left:9}):this.container.css({top:t,right:i,left:"auto"})}else if(this.opens==="center"){var o=this.element.offset().left-s.left+this.element.outerWidth()/2-r/2;o<0?this.container.css({top:t,right:"auto",left:9}):o+r>$(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:o,right:"auto"})}else{var o=this.element.offset().left-s.left;o+r>$(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:o,right:"auto"})}}show(){this.isShowing||(this._outsideClickProxy=function(s){this.outsideClick(s)}.bind(this),$(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),$(window).on("resize.daterangepicker",function(s){this.move(s)}.bind(this)),this.oldStartDate=this.#t,this.oldEndDate=this.#e,this.updateView(!1),this.container.show(),this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){this.isShowing&&(this.#e||(this.#t=this.oldStartDate,this.#e=this.oldEndDate),(!this.#t.equals(this.oldStartDate)||!this.#e.equals(this.oldEndDate))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),!this.triggerHandler(this.#i.onBeforeHide)&&($(document).off(".daterangepicker"),$(window).off(".daterangepicker"),this.container.hide(),this.triggerEvent(this.#i.onHide),this.isShowing=!1))}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.addClass("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.removeClass("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(s){var t=$(s.target);s.type==="focusin"||t.closest(this.element).length||t.closest(this.container).length||t.closest(".calendar-table").length||(this.onOutsideClick==="cancel"&&(this.#t=this.oldStartDate,this.#e=this.oldEndDate),this.hide(),this.triggerEvent(this.#i.onOutsideClick))}clickPrev(s){var t=$(s.target).parents(".drp-calendar");t.hasClass("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(s){var t=$(s.target).parents(".drp-calendar");t.hasClass("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(s){if(!$(s.target).hasClass("available"))return;let t=$(s.target).attr("data-title");const n=t.substring(1,2),a=t.substring(3,4);var i=$(s.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const o=this.leftCalendar,c=this.rightCalendar,e=this.#t,l=this.initalMonth;this.#e||this.container.find(".drp-calendar tbody td").each(function(d,u){if($(u).hasClass("week"))return;const m=$(u).attr("data-title"),p=m.substring(1,2),k=m.substring(3,4),v=$(u).parents(".drp-calendar").hasClass("left")?o.calendar[p][k]:c.calendar[p][k];!e&&l?$(u).removeClass("in-range"):v>e&&v<i||v.hasSame(i,"day")?$(u).addClass("in-range"):$(u).removeClass("in-range")})}hoverRange(s){const t=s.target.getAttribute("data-range-key"),n=[this.#t,this.#e],a=this.ranges[t]??[this.#t,this.#e],r=this.leftCalendar,i=this.rightCalendar;this.container.find(".drp-calendar tbody td").each(function(o,c){if($(c).hasClass("week"))return;const e=$(c).attr("data-title"),l=e.substring(1,2),d=e.substring(3,4),m=$(c).parents(".drp-calendar").hasClass("left")?r.calendar[l][d]:i.calendar[l][d];let p=!1;m.hasSame(a[0],"day")&&(p=$(c).addClass("start-hover").length>0),m.hasSame(n[0],"day")&&(p=$(c).addClass("start-date").length>0),m.hasSame(a[1],"day")&&(p=$(c).addClass("end-hover").length>0),n[1]!=null&&m.hasSame(n[1],"day")&&(p=$(c).addClass("end-date").length>0),m.startOf("day")>=a[0].startOf("day")&&m.startOf("day")<=a[1].startOf("day")&&(p=$(c).addClass("range-hover").length>0),m.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&m.startOf("day")<=n[1].startOf("day")&&(p=$(c).addClass("in-range").length>0),p||($(c).removeClass("start-hover"),$(c).removeClass("end-hover"),$(c).removeClass("start-date"),$(c).removeClass("end-date"),$(c).removeClass("in-range"),$(c).removeClass("range-hover"))})}leaveRange(s){this.container.find(".drp-calendar tbody td").each(function(t,n){$(n).hasClass("week")||($(n).removeClass("start-hover"),$(n).removeClass("end-hover"),$(n).removeClass("range-hover"))})}clickRange(s){var t=s.target.getAttribute("data-range-key");if(this.chosenLabel=t,t==this.locale.customRangeLabel)this.showCalendars();else{var n=this.ranges[t];const a=!this.#t.hasSame(n[0],"month")||!this.#e.hasSame(n[1],"month");this.#t=n[0],this.#e=n[1],this.timePicker||(this.#t.startOf("day"),this.#e.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerHandler(this.#i.onBeforeHide)&&this.updateView(a),this.clickApply()}}clickDate(s){if(!$(s.target).hasClass("available"))return;var t=$(s.target).attr("data-title"),n=t.substring(1,2),a=t.substring(3,4),r=$(s.target).parents(".drp-calendar"),i=r.hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];let o;if(this.#e||!this.#t||i<this.#t.startOf("day")){if(this.timePicker){let c=parseInt(this.container.find(".start-time .hourselect").val(),10);isNaN(c)&&(c=parseInt(this.container.find(".start-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".start-time .secondselect option:last").val(),10))),i=i.set({hour:c,minute:e,second:l})}else i=i.startOf("day");this.#e=null,this.#t=i,o="start"}else if(!this.#e&&i<this.#t)this.#e=this.#t,o="end";else{if(this.timePicker){let c=parseInt(this.container.find(".end-time .hourselect").val(),10);isNaN(c)&&(c=parseInt(this.container.find(".end-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".end-time .secondselect option:last").val(),10))),i=i.set({hour:c,minute:e,second:l})}else i=i.endOf("day");this.#e=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),o="end"}this.singleDatePicker&&(this.#e=this.#t,!this.timePicker&&this.autoApply&&this.clickApply(),o=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,o)}calculateChosenLabel(){var s=!0,t=0;for(var n in this.ranges){var a=this.timePicker?"hour":"day";if(this.timePicker&&(this.timePickerOpts.showMinutes?a="minute":this.timePickerOpts.showSeconds&&(a="second")),this.#t.startOf(a).equals(this.ranges[n][0].startOf(a))&&this.#e.startOf(a).equals(this.ranges[n][1].startOf(a))){s=!1,this.chosenLabel=this.container.find(".ranges li:eq("+t+")").addClass("active").attr("data-range-key");break}t++}s&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").attr("data-range-key"):this.chosenLabel=null,this.showCalendars())}timeChanged(s){const t=$(s.target).closest(".calendar-time"),n=t.hasClass("start-time")?"start":"end";var a=parseInt(t.find(".hourselect").val(),10);if(isNaN(a)&&(a=parseInt(t.find(".hourselect option:last").val(),10)),!this.timePicker24Hour){const o=t.find(".ampmselect").val();if(o==null&&t.find(".ampmselect option:last").val(),o!=h.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){t.find(".hourselect > option").each(function(){const e=$(this).attr("hidden")||!1;$(this).attr("hidden",e)});const c=h.fromFormat(`${a}`,"H").toFormat("h");a=h.fromFormat(`${c}${o}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(t.find(".minuteselect").val(),10),isNaN(r)&&(r=parseInt(t.find(".minuteselect option:last").val(),10)));var i=0;this.timePickerOpts.showSeconds&&(i=parseInt(t.find(".secondselect").val(),10),isNaN(i)&&(i=parseInt(t.find(".secondselect option:last").val(),10))),n==="start"?(this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:i})),this.singleDatePicker?this.#e=this.#t:this.#e&&this.#e.hasSame(this.#t,"day")&&this.#e<this.#t&&(this.#e=this.#t)):this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:i})),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,this.singleDatePicker?null:n)}monthOrYearChanged(s){var t=$(s.target).closest(".drp-calendar").hasClass("left"),n=t?"left":"right",a=this.container.find(".drp-calendar."+n),r=parseInt(a.find(".monthselect").val(),10),i=a.find(".yearselect").val();let o=!1;t||(i<this.#t.year||i==this.#t.year&&r<this.#t.month)&&(r=this.#t.month,i=this.#t.year),this.minDate&&(i<this.minDate.year||i==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,i=this.minDate.year),this.maxDate&&(i>this.maxDate.year||i==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,i=this.maxDate.year),t?(o=!h.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(o=!h.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(o)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#t=this.oldStartDate,this.#e=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.element.is("input:text")||!this.element.val().length)return;const s=typeof this.locale.format=="string"?this.locale.format:h.parseFormatForOpts(this.locale.format),t=this.element.val().split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=h.fromFormat(this.element.val(),s,{locale:h.now().locale});const r=this.#t;if(!a.isValid||r.equals(a))return;const i=this.validateInput([a,null],!0);if(i!=null)if(i.newDate!=null)a=i.newDate.startDate;else return;n=!this.#t.hasSame(a,"month"),this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else if(!this.singleDatePicker&&t.length===2){const a=[0,1].map(o=>h.fromFormat(t[o],s,{locale:h.now().locale})),r=[this.#t,this.#e];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const i=this.validateInput([a[0],a[1]],!0);if(i!=null)if(i.newDate!=null)a[0]=i.newDate.startDate,a[1]=i.newDate.endDate;else return;n=!this.#t.hasSame(a[0],"month")||!this.#e.hasSame(a[1],"month"),this.#t=a[0],this.#e=a[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else return;this.updateView(n),this.updateElement(),this.triggerEvent(this.#i.onInputChanged)}keydown(s){(s.keyCode===9||s.keyCode===13)&&this.hide(),s.keyCode===27&&(s.preventDefault(),s.stopPropagation(),this.hide())}updateElement(){if(!(this.#t==null&&this.initalMonth))if(this.element.is("input:text")){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.updateAltInput(),s!==this.element.val()&&this.element.val(s).trigger("change")}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.singleDatePicker&&$(this.altInput[1]).val(null),this.altFormat==null){let s="day";this.timePicker&&(this.timePickerOpts.showSeconds?s="second":this.timePickerOpts.showMinutes?s="minute":s="hour");const t=this.#t.toISO({format:"basic",precision:s,includeOffset:!1});if($(this.singleDatePicker?this.altInput:this.altInput[0]).val(t),!this.singleDatePicker&&this.#e){const n=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});$(this.altInput[1]).val(n)}}else{const s=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);if($(this.singleDatePicker?this.altInput:this.altInput[0]).val(s),!this.singleDatePicker&&this.#e){const t=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);$(this.altInput[1]).val(t)}}}remove(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}triggerEvent(s,...t){if(t.length===0)this.element.trigger(s.type,s.param);else{const n=s.param(...t);this.element.trigger(s.type,n)}}triggerHandler(s,...t){if(t.length===0)return this.element.triggerHandler(s.type,s.param);{const n=s.param(...t);return this.element.triggerHandler(s.type,n)}}}$.fn.daterangepicker||($.fn.daterangepicker=function(O,s){const t=$.extend(!0,{},$.fn.daterangepicker.defaultOptions,O);return this.each(function(){const n=$(this);n.data("daterangepicker")&&n.data("daterangepicker").remove(),n.data("daterangepicker",new I(n,t,s))}),this});})();
|
|
2
|
+
`,e)}if(typeof t.opens=="string"&&(["left","right","center"].includes(t.opens)?this.opens=t.opens:console.error("Option 'options.opens' must be 'left', 'right' or 'center'")),typeof t.drops=="string"&&(["drop","down","auto"].includes(t.drops)?this.drops=t.drops:console.error("Option 'options.drops' must be 'drop', 'down' or 'auto'")),Array.isArray(t.buttonClasses)?this.buttonClasses=t.buttonClasses.join(" "):typeof t.buttonClasses=="string"&&(this.buttonClasses=t.buttonClasses),typeof t.onOutsideClick=="string"&&(["cancel","apply"].includes(t.onOutsideClick)?this.onOutsideClick=t.onOutsideClick:console.error("Option 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let e=this.locale.firstDay;for(;e>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),e--}if(!this.singleDatePicker&&typeof t.ranges=="object"){for(let e in t.ranges){let l,d;if(["string","object"].includes(typeof t.ranges[e][0])&&(h.isDateTime(t.ranges[e][0])&&t.ranges[e][0].isValid?l=t.ranges[e][0]:t.ranges[e][0]instanceof Date?l=h.fromJSDate(t.ranges[e][0]):typeof t.ranges[e][0]=="string"&&h.fromISO(t.ranges[e][0]).isValid?l=h.fromISO(t.ranges[e][0]):console.error(`Option ranges['${e}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof t.ranges[e][1])&&(h.isDateTime(t.ranges[e][1])&&t.ranges[e][1].isValid?d=t.ranges[e][1]:t.ranges[e][1]instanceof Date?d=h.fromJSDate(t.ranges[e][1]):typeof t.ranges[e][1]=="string"&&h.fromISO(t.ranges[e][1]).isValid?d=h.fromISO(t.ranges[e][1]):console.error(`Option ranges['${e}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(l==null||d==null)){t.ranges[e]=[l,d];var r=document.createElement("textarea");r.innerHTML=e,this.ranges[r.value]=[l,d]}}var c="<ul>";for(let e in this.ranges)c+='<li data-range-key="'+e+'">'+e+"</li>";this.showCustomRangeLabel&&(c+='<li data-range-key="'+this.locale.customRangeLabel+'">'+this.locale.customRangeLabel+"</li>"),c+="</ul>",this.container.find(".ranges").prepend(c),this.container.addClass("show-ranges")}typeof n=="function"&&(this.callback=n),this.timePicker||this.container.find(".calendar-time").hide(),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.addClass("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.addClass("single"),this.container.find(".drp-calendar.left").addClass("single"),this.container.find(".drp-calendar.left").show(),this.container.find(".drp-calendar.right").hide(),!this.timePicker&&this.autoApply&&this.container.addClass("auto-apply")),(typeof t.ranges>"u"&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyButtonClasses.length&&this.container.find(".applyBtn").addClass(this.applyButtonClasses),this.cancelButtonClasses.length&&this.container.find(".cancelBtn").addClass(this.cancelButtonClasses),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".drp-calendar").on("click.daterangepicker",".prev",this.clickPrev.bind(this)).on("click.daterangepicker",".next",this.clickNext.bind(this)).on("mousedown.daterangepicker","td.available",this.clickDate.bind(this)).on("mouseenter.daterangepicker","td.available",this.hoverDate.bind(this)).on("change.daterangepicker","select.yearselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.monthselect",this.monthOrYearChanged.bind(this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.container.find(".ranges").on("click.daterangepicker","li",this.clickRange.bind(this)).on("mouseenter.daterangepicker","li",this.hoverRange.bind(this)).on("mouseleave.daterangepicker","li",this.leaveRange.bind(this)),this.container.find(".drp-buttons").on("click.daterangepicker","button.applyBtn",this.clickApply.bind(this)).on("click.daterangepicker","button.cancelBtn",this.clickCancel.bind(this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":this.show.bind(this),"focus.daterangepicker":this.show.bind(this),"keyup.daterangepicker":this.elementChanged.bind(this),"keydown.daterangepicker":this.keydown.bind(this)}):(this.element.on("click.daterangepicker",this.toggle.bind(this)),this.element.on("keydown.daterangepicker",this.toggle.bind(this))),this.updateElement()}get startDate(){return this.timePicker?this.#t:this.#t.startOf("day")}get endDate(){return this.singleDatePicker?null:this.timePicker?this.#e:this.#e.endOf("day")}set startDate(s){this.#t=s}set endDate(s){this.#e=s}#i={onViolate:{type:"violate.daterangepicker",param:(...s)=>[this,...s]},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker.daterangepicker",param:this},onBeforeRenderCalendar:{type:"beforeRenderCalendar.daterangepicker",param:this},onShow:{type:"show.daterangepicker",param:this},onBeforeHide:{type:"beforeHide.daterangepicker",param:this},onHide:{type:"hide.daterangepicker",param:this},onShowCalendar:{type:"showCalendar.daterangepicker",param:this},onHideCalendar:{type:"hideCalendar.daterangepicker",param:this},onOutsideClick:{type:"outsideClick.daterangepicker",param:this},onDateChange:{type:"dateChange.daterangepicker",param:s=>[this,s]},onTimeChange:{type:"timeChange.daterangepicker",param:s=>[this,s]},onApply:{type:"apply.daterangepicker",param:this},onCancel:{type:"cancel.daterangepicker",param:this},onInputChange:{type:"inputChange.daterangepicker",param:this},onMonthViewChange:{type:"monthViewChange.daterangepicker",param:(s,t)=>[this,s.startOf("month"),t?t.startOf("month"):null]}};get events(){return this.#i}setStartDate(s,t=!0){if(!this.singleDatePicker)return setRange(s,this.#e,t);const n=this.#t;let a=this.parseDate(s);if(a.equals(n))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const i=!this.#t.hasSame(a,"month");return this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),t&&this.updateView(i),r}setEndDate(s,t=!0){return this.singleDatePicker?null:setRange(this.#t,s,t)}setRange(s,t,n=!0){if(this.singleDatePicker)return;this.#e||(this.#e=this.#t);const a=[this.#t,this.#e];let r=[this.parseDate(s),this.parseDate(t)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const i=this.validateInput([r[0],r[1]],!0);if(i!=null)if(i.newDate!=null)r[0]=i.newDate.startDate,r[1]=i.newDate.endDate;else return i;const o=!this.#t.hasSame(r[0],"month")||!this.#e.hasSame(r[1],"month");return this.#t=r[0],this.#e=r[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),n&&this.updateView(o),i}parseDate(s){if(typeof s=="object"){if(h.isDateTime(s)&&s.isValid)return s;if(s instanceof Date)return h.fromJSDate(s);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof s=="string"){const t=typeof this.locale.format=="string"?this.locale.format:h.parseFormatForOpts(this.locale.format);if(h.fromISO(s).isValid)return h.fromISO(s);if(h.fromFormat(s,t,{locale:h.now().locale}).isValid)return h.fromFormat(s,t,{locale:h.now().locale});{const n=h.fromFormat(s,t,{locale:h.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${n}`)}}}logDate(s){return this.timePicker?s.toISO({suppressMilliseconds:!0}):s.toISODate()}formatDate(s,t=this.locale.format){if(typeof t=="object")return s.toLocaleString(t);if(P.defaultLocale===null){const n=h.now().locale;return s.toFormat(t,{locale:n})}else return s.toFormat(t)}updateLabel(){if(this.showLabel){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.container.find(".drp-selected").html(s)}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#e){this.container.find(".drp-duration-label").html("");return}if(typeof this.locale.durationFormat=="function")this.container.find(".drp-duration-label").html(this.locale.durationFormat(this.#t,this.#e));else{let s=this.#e.plus({milliseconds:1}).diff(this.#t).rescale().set({milliseconds:0});this.timePicker||(s=s.set({seconds:0,minutes:0,hours:0})),s=s.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.find(".drp-duration-label").html(s.toHuman(this.locale.durationFormat)):this.container.find(".drp-duration-label").html(s.toFormat(this.locale.durationFormat))}}}validateInput(s,t=!1){let n=s==null?this.#t:s[0],a=s==null?this.#e:s[1];if(n==null)return null;let r={startDate:{violations:[]}},i={old:n,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const e=this.timePickerStepSize.as("seconds");n=h.fromSeconds(e*Math.round(n.toSeconds()/e)),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)}else n=n.startOf("day");const o=this.timePicker?this.timePickerStepSize.as("seconds"):D.fromObject({days:1}).as("seconds");this.minDate&&n<this.minDate?(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/o)*o}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i)):this.maxDate&&n>this.maxDate&&(i={old:n,reason:"maxDate"},n=n.minus({seconds:Math.trunc(n.diff(this.maxDate).as("seconds")/o)*o}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.startDate.violations.push(i));let c=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&c.push("minute"),this.timePickerOpts.showSeconds&&c.push("second"),this.timePicker24Hour||c.push("ampm")),this.isInvalidDate(n)&&r.startDate.violations.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let e of c)this.isInvalidTime(n,e,"start")&&r.startDate.violations.push({old:n,reason:"isInvalidTime",unit:e});if(this.singleDatePicker){if(r.startDate.violations.length==0)return null;if(t){let e={startDate:n};return this.triggerHandler(this.#i.onViolate,r,e)&&(r.newDate=e),r}else return r}if(a==null)return null;if(r.endDate={violations:[]},i={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const e=this.timePickerStepSize.as("seconds");a=h.fromSeconds(e*Math.round(a.toSeconds()/e)),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/o)*o}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)):this.minDate&&a<this.minDate&&(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/o)*o}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i)),this.maxSpan){const e=n.plus(this.maxSpan);a>e&&(i={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(e.diff(a).as("seconds")/o)*o}),a>e&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.minSpan){const e=n.plus(this.defaultSpan??this.minSpan);a<e&&(i={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(e.diff(a).as("seconds")/o)*o}),a<e&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.isInvalidDate(a)&&r.endDate.violations.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let e of c)this.isInvalidTime(a,e,"end")&&r.endDate.violations.push({old:a,reason:"isInvalidTime",unit:e});if(r.startDate.violations.length==0&&r.endDate.violations.length==0)return null;if(t){let e={startDate:n,endDate:a};return this.triggerHandler(this.#i.onViolate,r,e)&&(r.newDate=e),r}else return r}updateView(s){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.#e?this.container.find(".calendar-time.end-time select").prop("disabled",!1).removeClass("disabled"):this.container.find(".calendar-time.end-time select").prop("disabled",!0).addClass("disabled")),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(s),this.setApplyBtnState()}updateMonthsInView(){if(this.#e){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month"))&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#t.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#e.hasSame(this.#t,"month")?this.rightCalendar.month=this.#e.startOf("month"):this.rightCalendar.month=this.#t.startOf("month").plus({month:1}))}else!this.#t&&this.initalMonth?(this.leftCalendar.month=this.initalMonth,this.singleMonthView||(this.rightCalendar.month=this.initalMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#t,"month")&&!this.rightCalendar.month.hasSame(this.#t,"month")&&(this.leftCalendar.month=this.#t.startOf("month"),this.rightCalendar.month=this.#t.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(s){if(this.timePicker){var t,n,a;this.#e?(t=parseInt(this.container.find(".start-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".start-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".start-time .secondselect option:last").val(),10)))):(t=parseInt(this.container.find(".end-time .hourselect").val(),10),isNaN(t)&&(t=parseInt(this.container.find(".end-time .hourselect option:last").val(),10)),n=0,this.timePickerOpts.showMinutes&&(n=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(n)&&(n=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(a)&&(a=parseInt(this.container.find(".end-time .secondselect option:last").val(),10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:t,minute:n,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:t,minute:n,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),s&&this.triggerEvent(this.#i.onMonthViewChange,this.leftCalendar.month,this.singleMonthView||this.singleDatePicker?null:this.rightCalendar.month),this.container.find(".ranges li").removeClass("active"),this.#e!=null&&this.calculateChosenLabel()}renderCalendar(s){if(s==="right"&&this.singleMonthView)return;var i=s==="left"?this.leftCalendar:this.rightCalendar;i.month==null&&!this.#t&&this.initalMonth&&(i.month=this.initalMonth.startOf("month"));const t=i.month.startOf("month"),n=i.month.endOf("month").startOf("day");var a=i.month.startOf("month").minus({day:1});const r={hour:i.month.hour,minute:i.month.minute,second:i.month.second};var i=[];i.firstDay=t,i.lastDay=n;for(var o=0;o<6;o++)i[o]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let f=0,g=-1;f<42;f++,a=a.plus({day:1}))f%7===0&&g++,i[g][f%7]=a.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var c=s==="left"?this.minDate:this.#t,e=this.maxDate,l="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+="<th></th>"),(!c||c<i.firstDay)&&(!this.linkedCalendars||s==="left")?l+='<th class="prev available"><span></span></th>':l+="<th></th>";var d=`${this.locale.monthNames[i.firstDay.month-1]} ${i.firstDay.year}`;if(this.showDropdowns){const f=(e&&e.year)??this.maxYear,g=(c&&c.year)??this.minYear;let w=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var u=`${w}<select class="monthselect">`,m=1;m<=12;m++)u+=`<option value="${m}"${m===i.firstDay.month?" selected":""}`,(c&&i.firstDay.set({month:m})<c.startOf("month")||e&&i.firstDay.set({month:m})>e.endOf("month"))&&(u+=" disabled"),u+=`>${this.locale.monthNames[m-1]}</option>`;u+="</select>",this.externalStyle==="bulma"&&(u+="</div>"),w=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var p=`${w}<select class="yearselect">`,k=g;k<=f;k++)p+=`<option value="${k}"${k===i.firstDay.year?" selected":""}>${k}</option>`;p+="</select>",this.externalStyle==="bulma"&&(p+="</div>"),d=u+p}l+='<th colspan="5" class="month">'+d+"</th>",(!e||e>i.lastDay.endOf("day"))&&(!this.linkedCalendars||s==="right"||this.singleDatePicker||this.singleMonthView)?l+='<th class="next available"><span></span></th>':l+="<th></th>",l+="</tr>",l+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[f,g]of this.locale.daysOfWeek.entries())l+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&S.getWeekendWeekdays().includes(f+1)&&(l+=` class="${this.weekendDayClasses}"`),l+=`>${g}</th>`;if(l+="</tr>",this.container.find(".drp-calendar."+s+" .calendar-table thead").html(l),l="",this.#e==null&&this.maxSpan){var y=this.#t.plus(this.maxSpan).endOf("day");(!e||y<e)&&(e=y)}var v;this.#e==null&&this.minSpan&&(v=this.#t.plus(this.minSpan).startOf("day"));for(let f=0;f<6;f++){l+="<tr>",this.showISOWeekNumbers?l+='<td class="week">'+i[f][0].weekNumber+"</td>":this.showWeekNumbers&&(l+='<td class="week">'+i[f][0].localWeekNumber+"</td>");for(let g=0;g<7;g++){var b=[];this.todayClasses&&this.todayClasses.length&&i[f][g].hasSame(h.now(),"day")&&b.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&S.getWeekendWeekdays().includes(i[f][g].weekday)&&b.push(this.weekendClasses),i[f][g].month!=i[1][1].month&&b.push("off","ends"),this.minDate&&i[f][g].startOf("day")<this.minDate.startOf("day")&&b.push("off","disabled"),e&&i[f][g].startOf("day")>e.startOf("day")&&b.push("off","disabled"),v&&i[f][g].startOf("day")>this.#t.startOf("day")&&i[f][g].startOf("day")<v.startOf("day")&&b.push("off","disabled"),this.isInvalidDate(i[f][g])&&b.push("off","disabled"),this.#t!=null&&i[f][g].hasSame(this.#t,"day")&&b.push("active","start-date"),this.#e!=null&&i[f][g].hasSame(this.#e,"day")&&b.push("active","end-date"),this.#e!=null&&i[f][g]>this.#t&&i[f][g]<this.#e&&b.push("in-range");var C=this.isCustomDate(i[f][g]);C!==!1&&(typeof C=="string"?b.push(C):Array.prototype.push.apply(b,C)),b.includes("disabled")||b.push("available"),l+=`<td class="${b.join(" ")}" data-title="r${f}c${g}">${i[f][g].day}</td>`}l+="</tr>"}this.container.find(".drp-calendar."+s+" .calendar-table tbody").html(l)}renderTimePicker(s){if(s==="end"&&!this.#e)return;var t,n,a,r=this.maxDate;let i="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(i+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#t.plus(this.maxSpan)<this.maxDate)&&(r=this.#t.plus(this.maxSpan)),this.minSpan&&s==="end"&&(n=this.#t.plus(this.defaultSpan??this.minSpan)),s==="start")t=this.#t,a=this.minDate;else if(s==="end"){t=this.#e,a=this.#t;var o=this.container.find(".drp-calendar .calendar-time.end-time");o.html()!=""&&(t=t.set({hour:isNaN(t.hour)?o.find(".hourselect option:selected").val():t.hour,minute:isNaN(t.minute)?o.find(".minuteselect option:selected").val():t.minute,second:isNaN(t.second)?o.find(".secondselect option:selected").val():t.second})),t<this.#t&&(t=this.#t),r&&t>r&&(t=r)}i+='<th colspan="7">',this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="hourselect">';const c=t.toFormat("a",{locale:"en-US"});let e=0;this.timePicker24Hour||(e=c==="AM"?1:13);for(var l=e;l<=e+23;l+=this.timePickerOpts.hourStep){let p=t.set({hour:l%24}),k=!1;if(a&&p.set({minute:59})<a&&(k=!0),r&&p.set({minute:0})>r&&(k=!0),n&&p.endOf("hour")<n&&(k=!0),!k&&this.isInvalidTime(p,this.singleDatePicker?null:s,"hour")&&(k=!0),this.timePicker24Hour)!k&&l==t.hour?i+=`<option value="${l}" selected>${l}</option>`:k?i+=`<option value="${l}" disabled class="disabled">${l}</option>`:i+=`<option value="${l}">${l}</option>`;else{const y=h.fromFormat(`${l%24}`,"H").toFormat("h"),v=h.fromFormat(`${l%24}`,"H").toFormat("a",{locale:"en-US"});c==v?!k&&l==t.hour?i+=`<option ampm="${v}" value="${l%24}" selected>${y}</option>`:k?i+=`<option ampm="${v}" value="${l%24}" disabled class="disabled">${y}</option>`:i+=`<option ampm="${v}" value="${l%24}">${y}</option>`:i+=`<option ampm="${v}" hidden="hidden" value="${l%24}">${y}</option>`}}if(i+="</select>",this.externalStyle==="bulma"&&(i+="</div>"),this.timePickerOpts.showMinutes){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="minuteselect">';for(var l=0;l<60;l+=this.timePickerOpts.minuteStep){var d=l<10?"0"+l:l;let k=t.set({minute:l}),y=!1;a&&k.set({second:59})<a&&(y=!0),r&&k.set({second:0})>r&&(y=!0),n&&k.endOf("minute")<n&&(y=!0),!y&&this.isInvalidTime(k,this.singleDatePicker?null:s,"minute")&&(y=!0),t.minute==l&&!y?i+=`<option value="${l}" selected>${d}</option>`:y?i+=`<option value="${l}" disabled class="disabled">${d}</option>`:i+=`<option value="${l}">${d}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(this.timePickerOpts.showSeconds){i+=" : ",this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="secondselect">';for(var l=0;l<60;l+=this.timePickerOpts.secondStep){var d=l<10?"0"+l:l;let y=t.set({second:l}),v=!1;a&&y<a&&(v=!0),r&&y>r&&(v=!0),n&&y<n&&(v=!0),!v&&this.isInvalidTime(y,this.singleDatePicker?null:s,"second")&&(v=!0),t.second==l&&!v?i+=`<option value="${l}" selected>${d}</option>`:v?i+=`<option value="${l}" disabled class="disabled">${d}</option>`:i+=`<option value="${l}">${d}</option>`}i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(i+='<div class="select is-small mx-1">'),i+='<select class="ampmselect">';var u="",m="";let p=!1;a&&t.startOf("day")<a&&(p=!0),r&&t.endOf("day")>r&&(p=!0),n&&t.startOf("day")<n&&(p=!0),p?(u=' disabled class="disabled "',m=' disabled class="disabled"'):this.isInvalidTime(t,this.singleDatePicker?null:s,"ampm")&&(t.toFormat("a",{locale:"en-US"})==="AM"?m=' disabled class="disabled"':u=' disabled class="disabled"'),i+=`<option value="AM"${u}`,t.toFormat("a",{locale:"en-US"})==="AM"&&(i+=" selected"),i+=`>${S.meridiems()[0]}</option><option value="PM"${m}`,t.toFormat("a",{locale:"en-US"})==="PM"&&(i+=" selected"),i+=`>${S.meridiems()[1]}</option>`,i+="</select>",this.externalStyle==="bulma"&&(i+="</div>")}i+="</div></th>",this.container.find(`.drp-calendar .calendar-time.${s}-time`).html(i)}setApplyBtnState(){this.singleDatePicker||this.#e&&this.#t<=this.#e?this.container.find("button.applyBtn").prop("disabled",!1):this.container.find("button.applyBtn").prop("disabled",!0)}move(){var s={top:0,left:0},t,n=this.drops,a=$(window).width();switch(this.parentEl.is("body")||(s={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},a=this.parentEl[0].clientWidth+this.parentEl.offset().left),n){case"auto":t=this.element.offset().top+this.element.outerHeight()-s.top,t+this.container.outerHeight()>=this.parentEl[0].scrollHeight&&(t=this.element.offset().top-this.container.outerHeight()-s.top,n="up");break;case"up":t=this.element.offset().top-this.container.outerHeight()-s.top;break;default:t=this.element.offset().top+this.element.outerHeight()-s.top;break}this.container.css({top:0,left:0,right:"auto"});var r=this.container.outerWidth();if(this.container.toggleClass("drop-up",n==="up"),this.opens==="left"){var i=a-this.element.offset().left-this.element.outerWidth();r+i>$(window).width()?this.container.css({top:t,right:"auto",left:9}):this.container.css({top:t,right:i,left:"auto"})}else if(this.opens==="center"){var o=this.element.offset().left-s.left+this.element.outerWidth()/2-r/2;o<0?this.container.css({top:t,right:"auto",left:9}):o+r>$(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:o,right:"auto"})}else{var o=this.element.offset().left-s.left;o+r>$(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:o,right:"auto"})}}show(){this.isShowing||(this._outsideClickProxy=function(s){this.outsideClick(s)}.bind(this),$(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),$(window).on("resize.daterangepicker",function(s){this.move(s)}.bind(this)),this.oldStartDate=this.#t,this.oldEndDate=this.#e,this.updateView(!1),this.container.show(),this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){this.isShowing&&(this.#e||(this.#t=this.oldStartDate,this.#e=this.oldEndDate),(!this.#t.equals(this.oldStartDate)||!this.#e.equals(this.oldEndDate))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),!this.triggerHandler(this.#i.onBeforeHide)&&($(document).off(".daterangepicker"),$(window).off(".daterangepicker"),this.container.hide(),this.triggerEvent(this.#i.onHide),this.isShowing=!1))}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.addClass("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.removeClass("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(s){var t=$(s.target);s.type==="focusin"||t.closest(this.element).length||t.closest(this.container).length||t.closest(".calendar-table").length||(this.onOutsideClick==="cancel"&&(this.#t=this.oldStartDate,this.#e=this.oldEndDate),this.hide(),this.triggerEvent(this.#i.onOutsideClick))}clickPrev(s){var t=$(s.target).parents(".drp-calendar");t.hasClass("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(s){var t=$(s.target).parents(".drp-calendar");t.hasClass("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(s){if(!$(s.target).hasClass("available"))return;let t=$(s.target).attr("data-title");const n=t.substring(1,2),a=t.substring(3,4);var i=$(s.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];const o=this.leftCalendar,c=this.rightCalendar,e=this.#t,l=this.initalMonth;this.#e||this.container.find(".drp-calendar tbody td").each(function(d,u){if($(u).hasClass("week"))return;const m=$(u).attr("data-title"),p=m.substring(1,2),k=m.substring(3,4),v=$(u).parents(".drp-calendar").hasClass("left")?o.calendar[p][k]:c.calendar[p][k];!e&&l?$(u).removeClass("in-range"):v>e&&v<i||v.hasSame(i,"day")?$(u).addClass("in-range"):$(u).removeClass("in-range")})}hoverRange(s){const t=s.target.getAttribute("data-range-key"),n=[this.#t,this.#e],a=this.ranges[t]??[this.#t,this.#e],r=this.leftCalendar,i=this.rightCalendar;this.container.find(".drp-calendar tbody td").each(function(o,c){if($(c).hasClass("week"))return;const e=$(c).attr("data-title"),l=e.substring(1,2),d=e.substring(3,4),m=$(c).parents(".drp-calendar").hasClass("left")?r.calendar[l][d]:i.calendar[l][d];let p=!1;m.hasSame(a[0],"day")&&(p=$(c).addClass("start-hover").length>0),m.hasSame(n[0],"day")&&(p=$(c).addClass("start-date").length>0),m.hasSame(a[1],"day")&&(p=$(c).addClass("end-hover").length>0),n[1]!=null&&m.hasSame(n[1],"day")&&(p=$(c).addClass("end-date").length>0),m.startOf("day")>=a[0].startOf("day")&&m.startOf("day")<=a[1].startOf("day")&&(p=$(c).addClass("range-hover").length>0),m.startOf("day")>=n[0].startOf("day")&&n[1]!=null&&m.startOf("day")<=n[1].startOf("day")&&(p=$(c).addClass("in-range").length>0),p||($(c).removeClass("start-hover"),$(c).removeClass("end-hover"),$(c).removeClass("start-date"),$(c).removeClass("end-date"),$(c).removeClass("in-range"),$(c).removeClass("range-hover"))})}leaveRange(s){this.container.find(".drp-calendar tbody td").each(function(t,n){$(n).hasClass("week")||($(n).removeClass("start-hover"),$(n).removeClass("end-hover"),$(n).removeClass("range-hover"))})}clickRange(s){var t=s.target.getAttribute("data-range-key");if(this.chosenLabel=t,t==this.locale.customRangeLabel)this.showCalendars();else{var n=this.ranges[t];const a=!this.#t.hasSame(n[0],"month")||!this.#e.hasSame(n[1],"month");this.#t=n[0],this.#e=n[1],this.timePicker||(this.#t.startOf("day"),this.#e.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerHandler(this.#i.onBeforeHide)&&this.updateView(a),this.clickApply()}}clickDate(s){if(!$(s.target).hasClass("available"))return;var t=$(s.target).attr("data-title"),n=t.substring(1,2),a=t.substring(3,4),r=$(s.target).parents(".drp-calendar"),i=r.hasClass("left")?this.leftCalendar.calendar[n][a]:this.rightCalendar.calendar[n][a];let o;if(this.#e||!this.#t||i<this.#t.startOf("day")){if(this.timePicker){let c=parseInt(this.container.find(".start-time .hourselect").val(),10);isNaN(c)&&(c=parseInt(this.container.find(".start-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".start-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".start-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".start-time .secondselect option:last").val(),10))),i=i.set({hour:c,minute:e,second:l})}else i=i.startOf("day");this.#e=null,this.#t=i,o="start"}else if(!this.#e&&i<this.#t)this.#e=this.#t,o="end";else{if(this.timePicker){let c=parseInt(this.container.find(".end-time .hourselect").val(),10);isNaN(c)&&(c=parseInt(this.container.find(".end-time .hourselect option:last").val(),10));let e=0;this.timePickerOpts.showMinutes&&(e=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".end-time .minuteselect option:last").val(),10)));let l=0;this.timePickerOpts.showSeconds&&(l=parseInt(this.container.find(".end-time .secondselect").val(),10),isNaN(l)&&(l=parseInt(this.container.find(".end-time .secondselect option:last").val(),10))),i=i.set({hour:c,minute:e,second:l})}else i=i.endOf("day");this.#e=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),o="end"}this.singleDatePicker&&(this.#e=this.#t,!this.timePicker&&this.autoApply&&this.clickApply(),o=null),this.updateView(!1),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,o)}calculateChosenLabel(){var s=!0,t=0;for(var n in this.ranges){var a=this.timePicker?"hour":"day";if(this.timePicker&&(this.timePickerOpts.showMinutes?a="minute":this.timePickerOpts.showSeconds&&(a="second")),this.#t.startOf(a).equals(this.ranges[n][0].startOf(a))&&this.#e.startOf(a).equals(this.ranges[n][1].startOf(a))){s=!1,this.chosenLabel=this.container.find(".ranges li:eq("+t+")").addClass("active").attr("data-range-key");break}t++}s&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").attr("data-range-key"):this.chosenLabel=null,this.showCalendars())}timeChanged(s){const t=$(s.target).closest(".calendar-time"),n=t.hasClass("start-time")?"start":"end";var a=parseInt(t.find(".hourselect").val(),10);if(isNaN(a)&&(a=parseInt(t.find(".hourselect option:last").val(),10)),!this.timePicker24Hour){const o=t.find(".ampmselect").val();if(o==null&&t.find(".ampmselect option:last").val(),o!=h.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){t.find(".hourselect > option").each(function(){const e=$(this).attr("hidden")||!1;$(this).attr("hidden",e)});const c=h.fromFormat(`${a}`,"H").toFormat("h");a=h.fromFormat(`${c}${o}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(t.find(".minuteselect").val(),10),isNaN(r)&&(r=parseInt(t.find(".minuteselect option:last").val(),10)));var i=0;this.timePickerOpts.showSeconds&&(i=parseInt(t.find(".secondselect").val(),10),isNaN(i)&&(i=parseInt(t.find(".secondselect option:last").val(),10))),n==="start"?(this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:i})),this.singleDatePicker?this.#e=this.#t:this.#e&&this.#e.hasSame(this.#t,"day")&&this.#e<this.#t&&(this.#e=this.#t)):this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:i})),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,this.singleDatePicker?null:n)}monthOrYearChanged(s){var t=$(s.target).closest(".drp-calendar").hasClass("left"),n=t?"left":"right",a=this.container.find(".drp-calendar."+n),r=parseInt(a.find(".monthselect").val(),10),i=a.find(".yearselect").val();let o=!1;t||(i<this.#t.year||i==this.#t.year&&r<this.#t.month)&&(r=this.#t.month,i=this.#t.year),this.minDate&&(i<this.minDate.year||i==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,i=this.minDate.year),this.maxDate&&(i>this.maxDate.year||i==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,i=this.maxDate.year),t?(o=!h.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(o=!h.fromObject({year:i,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(o)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#t=this.oldStartDate,this.#e=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.element.is("input:text")||!this.element.val().length)return;const s=typeof this.locale.format=="string"?this.locale.format:h.parseFormatForOpts(this.locale.format),t=this.element.val().split(this.locale.separator);let n=!1;if(this.singleDatePicker){let a=h.fromFormat(this.element.val(),s,{locale:h.now().locale});const r=this.#t;if(!a.isValid||r.equals(a))return;const i=this.validateInput([a,null],!0);if(i!=null)if(i.newDate!=null)a=i.newDate.startDate;else return;n=!this.#t.hasSame(a,"month"),this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else if(!this.singleDatePicker&&t.length===2){const a=[0,1].map(o=>h.fromFormat(t[o],s,{locale:h.now().locale})),r=[this.#t,this.#e];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const i=this.validateInput([a[0],a[1]],!0);if(i!=null)if(i.newDate!=null)a[0]=i.newDate.startDate,a[1]=i.newDate.endDate;else return;n=!this.#t.hasSame(a[0],"month")||!this.#e.hasSame(a[1],"month"),this.#t=a[0],this.#e=a[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else return;this.updateView(n),this.updateElement(),this.triggerEvent(this.#i.onInputChange)}keydown(s){(s.keyCode===9||s.keyCode===13)&&this.hide(),s.keyCode===27&&(s.preventDefault(),s.stopPropagation(),this.hide())}updateElement(){if(!(this.#t==null&&this.initalMonth))if(this.element.is("input:text")){let s=this.formatDate(this.#t);this.singleDatePicker||(s+=this.locale.separator,this.#e&&(s+=this.formatDate(this.#e))),this.updateAltInput(),s!==this.element.val()&&this.element.val(s).trigger("change")}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.singleDatePicker&&$(this.altInput[1]).val(null),this.altFormat==null){let s="day";this.timePicker&&(this.timePickerOpts.showSeconds?s="second":this.timePickerOpts.showMinutes?s="minute":s="hour");const t=this.#t.toISO({format:"basic",precision:s,includeOffset:!1});if($(this.singleDatePicker?this.altInput:this.altInput[0]).val(t),!this.singleDatePicker&&this.#e){const n=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});$(this.altInput[1]).val(n)}}else{const s=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);if($(this.singleDatePicker?this.altInput:this.altInput[0]).val(s),!this.singleDatePicker&&this.#e){const t=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);$(this.altInput[1]).val(t)}}}remove(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}triggerEvent(s,...t){if(t.length===0)this.element.trigger(s.type,s.param);else{const n=s.param(...t);this.element.trigger(s.type,n)}}triggerHandler(s,...t){if(t.length===0)return this.element.triggerHandler(s.type,s.param);{const n=s.param(...t);return this.element.triggerHandler(s.type,n)}}}$.fn.daterangepicker||($.fn.daterangepicker=function(O,s){const t=$.extend(!0,{},$.fn.daterangepicker.defaultOptions,O);return this.each(function(){const n=$(this);n.data("daterangepicker")&&n.data("daterangepicker").remove(),n.data("daterangepicker",new I(n,t,s))}),this});})();
|
package/package.json
CHANGED