@wernfried/daterangepicker 4.16.9 → 4.16.10
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/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.16.
|
|
24
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.16.
|
|
23
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.16.10/dist/global/daterangepicker.min.js"></script>
|
|
24
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.16.10/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.16.
|
|
46
|
+
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.16.10/+esm"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.16.
|
|
50
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.16.10/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.16.
|
|
71
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.16.10/css/daterangepicker.bulma.min.css" rel="stylesheet" />
|
|
72
72
|
|
|
73
73
|
<input type="text" id="picker" />
|
|
74
74
|
|
|
@@ -176,6 +176,7 @@ In original daterangepicker this parameter defines whether the `<input>` is upda
|
|
|
176
176
|
- Added option `locale.durationFormat` to show customized label for selected duration, e.g. `'4 Days, 6 Hours, 30 Minutes'`
|
|
177
177
|
- Added option `externalStyle` to use daterangepicker with external CSS Frameworks. Currently only [Bulma](https://bulma.io/) is supported<br/>
|
|
178
178
|
but other frameworks may be added in future releases
|
|
179
|
+
- [Jest](https://jestjs.io/) unit testing
|
|
179
180
|
- ... and maybe some new bugs 😉
|
|
180
181
|
|
|
181
182
|
### Localization
|
|
@@ -223,8 +224,7 @@ You can style this daterangepicker with [Bulma CSS Framework](https://bulma.io/)
|
|
|
223
224
|
Available methods are listed below in [API documentation](#DateRangePicker). You will mainly use
|
|
224
225
|
* [.daterangepicker(options, callback)](#DateRangePicker.daterangepicker)
|
|
225
226
|
* [.setStartDate(startDate)](#DateRangePicker+setStartDate)
|
|
226
|
-
* [.
|
|
227
|
-
* [.setPeriod(startDate, endDate)](#DateRangePicker+setPeriod)
|
|
227
|
+
* [.setRange(startDate, endDate)](#DateRangePicker+setRange)
|
|
228
228
|
* `$(...).data('daterangepicker')` to get the daterangepicker object
|
|
229
229
|
|
|
230
230
|
all other methods are used rarely.
|
|
@@ -267,7 +267,7 @@ Licensed under the [MIT license](LICENSE).
|
|
|
267
267
|
<dl>
|
|
268
268
|
<dt><a href="#event_violated.daterangepicker">"violated.daterangepicker" (this, picker, result, newDate)</a> ⇒ <code>boolean</code></dt>
|
|
269
269
|
<dd><p>Emitted when the date is changed through <code><input></code> element or via <a href="#DateRangePicker+setStartDate">setStartDate</a> or
|
|
270
|
-
<a href="#DateRangePicker+setRange">setRange</a> and date is not valid due to
|
|
270
|
+
<a href="#DateRangePicker+setRange">setRange</a> and date is not valid due to
|
|
271
271
|
<code>minDate</code>, <code>maxDate</code>, <code>minSpan</code>, <code>maxSpan</code>, <code>invalidDate</code> and <code>invalidTime</code> constraints.<br>
|
|
272
272
|
Event is only triggered when date string is valid and date value is changing<br></p>
|
|
273
273
|
</dd>
|
|
@@ -345,12 +345,14 @@ Ranges are not validated against <code>minDate</code>, <code>maxDate</code>, <co
|
|
|
345
345
|
* [DateRangePicker](#DateRangePicker)
|
|
346
346
|
* [new DateRangePicker(element, options, cb)](#new_DateRangePicker_new)
|
|
347
347
|
* _instance_
|
|
348
|
+
* [.startDate](#DateRangePicker+startDate) : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
349
|
+
* [.endDate](#DateRangePicker+endDate) : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
348
350
|
* [.setStartDate(startDate, updateView)](#DateRangePicker+setStartDate) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
349
351
|
* [.setEndDate(endDate, updateView)](#DateRangePicker+setEndDate) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
350
352
|
* [.setRange(startDate, endDate, updateView)](#DateRangePicker+setRange) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
351
353
|
* [.parseDate(value)](#DateRangePicker+parseDate) ⇒ [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
352
354
|
* [.formatDate(date, format)](#DateRangePicker+formatDate) ⇒ <code>string</code>
|
|
353
|
-
* [.validateInput(
|
|
355
|
+
* [.validateInput(range, dipatch)](#DateRangePicker+validateInput) ⇒ [<code>InputViolation</code>](#InputViolation) \| <code>null</code>
|
|
354
356
|
* [.updateView()](#DateRangePicker+updateView)
|
|
355
357
|
* [.show()](#DateRangePicker+show)
|
|
356
358
|
* [.hide()](#DateRangePicker+hide)
|
|
@@ -373,6 +375,18 @@ Ranges are not validated against <code>minDate</code>, <code>maxDate</code>, <co
|
|
|
373
375
|
| options | [<code>Options</code>](#Options) | Object to configure the DateRangePicker |
|
|
374
376
|
| cb | <code>function</code> | Callback function executed when |
|
|
375
377
|
|
|
378
|
+
<a name="DateRangePicker+startDate"></a>
|
|
379
|
+
|
|
380
|
+
### dateRangePicker.startDate : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
381
|
+
startDate
|
|
382
|
+
|
|
383
|
+
**Kind**: instance property of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
384
|
+
<a name="DateRangePicker+endDate"></a>
|
|
385
|
+
|
|
386
|
+
### dateRangePicker.endDate : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
387
|
+
endDate
|
|
388
|
+
|
|
389
|
+
**Kind**: instance property of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
376
390
|
<a name="DateRangePicker+setStartDate"></a>
|
|
377
391
|
|
|
378
392
|
### dateRangePicker.setStartDate(startDate, updateView) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
@@ -461,7 +475,7 @@ Format a DateTime object
|
|
|
461
475
|
|
|
462
476
|
<a name="DateRangePicker+validateInput"></a>
|
|
463
477
|
|
|
464
|
-
### dateRangePicker.validateInput(
|
|
478
|
+
### dateRangePicker.validateInput(range, dipatch) ⇒ [<code>InputViolation</code>](#InputViolation) \| <code>null</code>
|
|
465
479
|
Validate `startDate` and `endDate` against `timePickerStepSize`, `minDate`, `maxDate`,
|
|
466
480
|
`minSpan`, `maxSpan`, `invalidDate` and `invalidTime`.
|
|
467
481
|
|
|
@@ -471,8 +485,8 @@ Validate `startDate` and `endDate` against `timePickerStepSize`, `minDate`, `max
|
|
|
471
485
|
|
|
472
486
|
| Param | Type | Default | Description |
|
|
473
487
|
| --- | --- | --- | --- |
|
|
474
|
-
|
|
|
475
|
-
| dipatch | <code>boolean</code> | <code>false</code> | If
|
|
488
|
+
| range | <code>Array</code> | <code>[startDate,</code> | endDate] - Range to be checked, defaults to current `startDate` and `endDate` |
|
|
489
|
+
| dipatch | <code>boolean</code> | <code>false</code> | If `true` then event "violated.daterangepicker" is dispated.<br> If eventHandler returns `true`, then `null` is returned, otherwiese the object of violations. |
|
|
476
490
|
|
|
477
491
|
**Example**
|
|
478
492
|
```js
|
|
@@ -579,7 +593,7 @@ Initiate a new DateRangePicker
|
|
|
579
593
|
|
|
580
594
|
## "violated.daterangepicker" (this, picker, result, newDate) ⇒ <code>boolean</code>
|
|
581
595
|
Emitted when the date is changed through `<input>` element or via [setStartDate](#DateRangePicker+setStartDate) or
|
|
582
|
-
[setRange](#DateRangePicker+setRange) and date is not valid due to
|
|
596
|
+
[setRange](#DateRangePicker+setRange) and date is not valid due to
|
|
583
597
|
`minDate`, `maxDate`, `minSpan`, `maxSpan`, `invalidDate` and `invalidTime` constraints.<br>
|
|
584
598
|
Event is only triggered when date string is valid and date value is changing<br>
|
|
585
599
|
|
|
@@ -614,7 +628,7 @@ $('#picker').val(DateTime.now().minus({ years: 10 })).toLocaleString(DateTime.DA
|
|
|
614
628
|
// Try to set date outside permitted range by code
|
|
615
629
|
const drp = $('#picker').data('daterangepicker').setStartDate(DateTime.now().minus({ years: 10 })
|
|
616
630
|
|
|
617
|
-
-> Calendar selects and shows "today - 3 days"
|
|
631
|
+
// -> Calendar selects and shows "today - 3 days"
|
|
618
632
|
```
|
|
619
633
|
<a name="event_beforeRenderCalendar.daterangepicker"></a>
|
|
620
634
|
|
|
@@ -886,11 +900,11 @@ A single predefined range
|
|
|
886
900
|
| Name | Type | Description |
|
|
887
901
|
| --- | --- | --- |
|
|
888
902
|
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Violation of startDate |
|
|
889
|
-
| ? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| <code>undefined</code> |
|
|
903
|
+
| endDate? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| <code>undefined</code> | Violation of endDate, if existing |
|
|
890
904
|
| violations | <code>Array</code> | The constraints which violates the input |
|
|
891
905
|
| reason | <code>Array</code> | The type/reson of violation |
|
|
892
906
|
| old | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Old value startDate/endDate |
|
|
893
|
-
| ? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) |
|
|
907
|
+
| new? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Corrected value of startDate/endDate if existing |
|
|
894
908
|
|
|
895
909
|
<a name="callback"></a>
|
|
896
910
|
|
|
@@ -3,7 +3,6 @@ import { $ } from "jquery";
|
|
|
3
3
|
class DateRangePicker {
|
|
4
4
|
#startDate = null;
|
|
5
5
|
#endDate = null;
|
|
6
|
-
#setRange = false;
|
|
7
6
|
constructor(element, options, cb) {
|
|
8
7
|
this.parentEl = "body";
|
|
9
8
|
this.element = $(element);
|
|
@@ -514,9 +513,17 @@ class DateRangePicker {
|
|
|
514
513
|
}
|
|
515
514
|
this.updateElement();
|
|
516
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* startDate
|
|
518
|
+
* @type {external:DateTime}
|
|
519
|
+
*/
|
|
517
520
|
get startDate() {
|
|
518
521
|
return this.#startDate;
|
|
519
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* endDate
|
|
525
|
+
* @type {external:DateTime}
|
|
526
|
+
*/
|
|
520
527
|
get endDate() {
|
|
521
528
|
return this.singleDatePicker ? null : this.#endDate;
|
|
522
529
|
}
|
|
@@ -693,7 +700,7 @@ class DateRangePicker {
|
|
|
693
700
|
}
|
|
694
701
|
/**
|
|
695
702
|
* Emitted when the date is changed through `<input>` element or via {@link #DateRangePicker+setStartDate|setStartDate} or
|
|
696
|
-
* {@link #DateRangePicker+setRange|setRange} and date is not valid due to
|
|
703
|
+
* {@link #DateRangePicker+setRange|setRange} and date is not valid due to
|
|
697
704
|
* `minDate`, `maxDate`, `minSpan`, `maxSpan`, `invalidDate` and `invalidTime` constraints.<br>
|
|
698
705
|
* Event is only triggered when date string is valid and date value is changing<br>
|
|
699
706
|
* @event
|
|
@@ -725,23 +732,23 @@ class DateRangePicker {
|
|
|
725
732
|
* // Try to set date outside permitted range by code
|
|
726
733
|
* const drp = $('#picker').data('daterangepicker').setStartDate(DateTime.now().minus({ years: 10 })
|
|
727
734
|
*
|
|
728
|
-
* -> Calendar selects and shows "today - 3 days"
|
|
735
|
+
* // -> Calendar selects and shows "today - 3 days"
|
|
729
736
|
*/
|
|
730
737
|
/**
|
|
731
738
|
* @typedef InputViolation
|
|
732
739
|
* @type {Object}
|
|
733
740
|
* @property {external:DateTime} startDate - Violation of startDate
|
|
734
|
-
* @property {external:DateTime|undefined}
|
|
741
|
+
* @property {external:DateTime|undefined} endDate? - Violation of endDate, if existing
|
|
735
742
|
* @property {Array} violations - The constraints which violates the input
|
|
736
743
|
* @property {Array} reason - The type/reson of violation
|
|
737
744
|
* @property {external:DateTime} old - Old value startDate/endDate
|
|
738
|
-
* @property {external:DateTime}
|
|
745
|
+
* @property {external:DateTime} new? - Corrected value of startDate/endDate if existing
|
|
739
746
|
*/
|
|
740
747
|
/**
|
|
741
748
|
* Validate `startDate` and `endDate` against `timePickerStepSize`, `minDate`, `maxDate`,
|
|
742
749
|
* `minSpan`, `maxSpan`, `invalidDate` and `invalidTime`.
|
|
743
|
-
* @param {Array} [startDate, endDate] - Range to be checked, defaults to current `startDate` and `endDate`
|
|
744
|
-
* @param {boolean} dipatch=false - If
|
|
750
|
+
* @param {Array} range=[startDate, endDate] - Range to be checked, defaults to current `startDate` and `endDate`
|
|
751
|
+
* @param {boolean} dipatch=false - If `true` then event "violated.daterangepicker" is dispated.<br>
|
|
745
752
|
* If eventHandler returns `true`, then `null` is returned, otherwiese the object of violations.
|
|
746
753
|
* @emits "violated.daterangepicker"
|
|
747
754
|
* @returns {InputViolation|null} - Object of violations and corrected values or `null` if no violation have been found
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DateTime as o,Duration as b,Info as w,Settings as x}from"luxon";import{$ as h}from"jquery";class I{#t=null;#e=null;#i=!1;constructor(s,t,a){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 n=new Intl.DateTimeFormat(o.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!n.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:w.weekdays("short"),monthNames:w.months("long"),firstDay:w.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 f=[];for(let l of["minutes","seconds"])f.push(...[1,2,3,4,5,6,10,12,15,20,30].map(c=>b.fromObject({[l]:c})));f.push(...[1,2,3,4,6].map(l=>b.fromObject({hours:l}))),this.timePicker24Hour&&f.push(...[8,12].map(l=>b.fromObject({hours:l}))),f.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.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day"))),this.singleDatePicker?this.#e=this.#t:this.#e<this.#t&&console.error(`Option 'endDate' ${this.#e} must not be earlier than 'startDate' ${this.#t}`),["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
|
|
1
|
+
import{DateTime as o,Duration as b,Info as w,Settings as x}from"luxon";import{$ as h}from"jquery";class I{#t=null;#e=null;constructor(s,t,a){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 n=new Intl.DateTimeFormat(o.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!n.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:w.weekdays("short"),monthNames:w.months("long"),firstDay:w.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 f=[];for(let l of["minutes","seconds"])f.push(...[1,2,3,4,5,6,10,12,15,20,30].map(c=>b.fromObject({[l]:c})));f.push(...[1,2,3,4,6].map(l=>b.fromObject({hours:l}))),this.timePicker24Hour&&f.push(...[8,12].map(l=>b.fromObject({hours:l}))),f.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.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day"))),this.singleDatePicker?this.#e=this.#t:this.#e<this.#t&&console.error(`Option 'endDate' ${this.#e} must not be earlier than 'startDate' ${this.#t}`),["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
2
|
`,e)}if(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;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;this.#e=c}}}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 d="<ul>";for(let e in this.ranges)d+='<li data-range-key="'+e+'">'+e+"</li>";this.showCustomRangeLabel&&(d+='<li data-range-key="'+this.locale.customRangeLabel+'">'+this.locale.customRangeLabel+"</li>"),d+="</ul>",this.container.find(".ranges").prepend(d),this.container.addClass("show-ranges")}typeof a=="function"&&(this.callback=a),this.timePicker||(this.#t&&(this.#t=this.#t.startOf("day")),this.#e&&(this.#e=this.#e.endOf("day")),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.#t}get endDate(){return this.singleDatePicker?null:this.#e}set startDate(s){this.#t=s}set endDate(s){this.#e=s}setStartDate(s,t=!0){if(!this.singleDatePicker)return setRange(s,this.#e,t);const a=this.#t;let n=this.parseDate(s);if(n.equals(a))return null;const r=this.validateInput([n,null],!0);if(r!=null)if(r.newDate!=null)n=r.newDate.startDate;else return r;return this.#t=n,this.#e=this.#t,this.updateElement(),t&&this.updateView(),r}setEndDate(s,t=!0){return this.singleDatePicker?null:setRange(this.#t,s,t)}setRange(s,t,a=!0){if(this.singleDatePicker)return;this.#e||(this.#e=this.#t);const n=[this.#t,this.#e];let r=[this.parseDate(s),this.parseDate(t)];if(n[0].equals(r[0])&&n[1].equals(r[1])||r[1]>r[0])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;return this.#t=r[0],this.#e=r[1],this.updateElement(),a&&this.updateView(),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 a=o.fromFormat(s,t,{locale:o.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${a}`)}}}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 a=o.now().locale;return s.toFormat(t,{locale:a})}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 a=s==null?this.#t:s[0],n=s==null?this.#e:s[1];if(a==null)return null;let r={startDate:{violations:[]}},i={old:a,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const e=this.timePickerStepSize.as("seconds");a=o.fromSeconds(e*Math.round(a.toSeconds()/e))}else a=a.startOf("day");i.new=a,i.new.equals(i.old)||r.startDate.violations.push(i);const f=this.timePicker?this.timePickerStepSize.as("seconds"):b.fromObject({days:1}).as("seconds");this.minDate&&a<this.minDate?(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/f)*f}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.startDate.violations.push(i)):this.maxDate&&a>this.maxDate&&(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/f)*f}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.startDate.violations.push(i));let d=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&d.push("minute"),this.timePickerOpts.showSeconds&&d.push("second"),this.timePicker24Hour||d.push("ampm")),this.isInvalidDate(a)&&r.startDate.violations.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let e of d)this.isInvalidTime(a,e,"start")&&r.startDate.violations.push({old:a,reason:"isInvalidTime",unit:e});if(this.singleDatePicker){if(r.startDate.violations.length==0)return null;if(t){let e={startDate:a};return this.element.triggerHandler("violated.daterangepicker",[this,r,e])&&(r.newDate=e),r}else return r}if(n==null)return null;if(r.endDate={violations:[]},i={old:n,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const e=this.timePickerStepSize.as("seconds");n=o.fromSeconds(e*Math.round(n.toSeconds()/e))}else n=n.endOf("day");if(i.new=n,i.new.equals(i.old)||r.endDate.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")/f)*f}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i)):this.minDate&&n<this.minDate&&(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/f)*f}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i)),this.maxSpan){const e=a.plus(this.maxSpan);n>e&&(i={old:n,reason:"maxSpan"},n=n.minus({seconds:Math.trunc(e.diff(n).as("seconds")/f)*f}),n>e&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.minSpan){const e=a.plus(this.defaultSpan??this.minSpan);n<e&&(i={old:n,reason:"minSpan"},n=n.plus({seconds:Math.trunc(e.diff(n).as("seconds")/f)*f}),n<e&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.isInvalidDate(n)&&r.endDate.violations.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let e of d)this.isInvalidTime(n,e,"end")&&r.endDate.violations.push({old:n,reason:"isInvalidTime",unit:e});if(r.startDate.violations.length==0&&r.endDate.violations.length==0)return null;if(t){let e={startDate:a,endDate:n};return this.element.triggerHandler("violated.daterangepicker",[this,r,e])&&(r.newDate=e),r}else return r}updateView(){this.timePicker&&(this.element.trigger("beforeRenderTimePicker.daterangepicker",this),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(),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(){if(this.timePicker){var s,t,a;this.#e?(s=parseInt(this.container.find(".start-time .hourselect").val(),10),isNaN(s)&&(s=parseInt(this.container.find(".start-time .hourselect option:last").val(),10)),t=0,this.timePickerOpts.showMinutes&&(t=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(t)&&(t=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)))):(s=parseInt(this.container.find(".end-time .hourselect").val(),10),isNaN(s)&&(s=parseInt(this.container.find(".end-time .hourselect option:last").val(),10)),t=0,this.timePickerOpts.showMinutes&&(t=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(t)&&(t=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:s,minute:t,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:s,minute:t,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.element.trigger("beforeRenderCalendar.daterangepicker",this),this.renderCalendar("left"),this.renderCalendar("right"),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"),a=i.month.endOf("month").startOf("day");var n=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=a;for(var f=0;f<6;f++)i[f]=[];for(;n.weekday!=this.locale.firstDay;)n=n.minus({day:1});for(let m=0,k=-1;m<42;m++,n=n.plus({day:1}))m%7===0&&k++,i[k][m%7]=n.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var d=s==="left"?this.minDate:this.#t,e=this.maxDate,l="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+="<th></th>"),(!d||d<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=(d&&d.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":""}`,(d&&i.firstDay.set({month:u})<d.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&&w.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&&w.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 C=this.isCustomDate(i[m][k]);C!==!1&&(typeof C=="string"?S.push(C):Array.prototype.push.apply(S,C)),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,a,n,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"&&(a=this.#t.plus(this.defaultSpan??this.minSpan)),s==="start")t=this.#t,n=this.minDate;else if(s==="end"){t=this.#e,n=this.#t;var f=this.container.find(".drp-calendar .calendar-time.end-time");f.html()!=""&&(t=t.set({hour:isNaN(t.hour)?f.find(".hourselect option:selected").val():t.hour,minute:isNaN(t.minute)?f.find(".minuteselect option:selected").val():t.minute,second:isNaN(t.second)?f.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 d=t.toFormat("a",{locale:"en-US"});let e=0;this.timePicker24Hour||(e=d==="AM"?1:13);for(var l=e;l<=e+23;l+=this.timePickerOpts.hourStep){let g=t.set({hour:l%24}),y=!1;if(n&&g.set({minute:59})<n&&(y=!0),r&&g.set({minute:0})>r&&(y=!0),a&&g.endOf("hour")<a&&(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"});d==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;n&&y.set({second:59})<n&&(v=!0),r&&y.set({second:0})>r&&(v=!0),a&&y.endOf("minute")<a&&(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;n&&v<n&&(D=!0),r&&v>r&&(D=!0),a&&v<a&&(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;n&&t.startOf("day")<n&&(g=!0),r&&t.endOf("day")>r&&(g=!0),a&&t.startOf("day")<a&&(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+=`>${w.meridiems()[0]}</option><option value="PM"${u}`,t.toFormat("a",{locale:"en-US"})==="PM"&&(i+=" selected"),i+=`>${w.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,a=this.drops,n=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()},n=this.parentEl[0].clientWidth+this.parentEl.offset().left),a){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,a="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",a==="up"),this.opens==="left"){var i=n-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 f=this.element.offset().left-s.left+this.element.outerWidth()/2-r/2;f<0?this.container.css({top:t,right:"auto",left:9}):f+r>h(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:f,right:"auto"})}else{var f=this.element.offset().left-s.left;f+r>h(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:f,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(),this.container.show(),this.move(),this.element.trigger("show.daterangepicker",this),this.isShowing=!0)}hide(){this.isShowing&&(this.#e||(this.#t=this.oldStartDate,this.#e=this.oldEndDate),(this.#t!=this.oldStartDate||this.#e!=this.oldEndDate)&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),!this.element.triggerHandler("beforeHide.daterangepicker",this)&&(h(document).off(".daterangepicker"),h(window).off(".daterangepicker"),this.container.hide(),this.element.trigger("hide.daterangepicker",this),this.isShowing=!1))}toggle(){this.isShowing?this.hide():this.show()}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.element.trigger("outsideClick.daterangepicker",this))}showCalendars(){this.container.addClass("show-calendar"),this.move(),this.element.trigger("showCalendar.daterangepicker",this)}hideCalendars(){this.container.removeClass("show-calendar"),this.element.trigger("hideCalendar.daterangepicker",this)}clickRange(s){var t=s.target.getAttribute("data-range-key");if(this.chosenLabel=t,t==this.locale.customRangeLabel)this.showCalendars();else{var a=this.ranges[t];this.#t=a[0],this.#e=a[1],this.timePicker||(this.#t.startOf("day"),this.#e.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.element.triggerHandler("beforeHide.daterangepicker",this)&&this.updateView(),this.clickApply()}}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()}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()}hoverDate(s){if(!h(s.target).hasClass("available"))return;let t=h(s.target).attr("data-title");const a=t.substring(1,2),n=t.substring(3,4);var i=h(s.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[a][n]:this.rightCalendar.calendar[a][n];const f=this.leftCalendar,d=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")?f.calendar[g][y]:d.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"),a=[this.#t,this.#e],n=this.ranges[t]??[this.#t,this.#e],r=this.leftCalendar,i=this.rightCalendar;this.container.find(".drp-calendar tbody td").each(function(f,d){if(h(d).hasClass("week"))return;const e=h(d).attr("data-title"),l=e.substring(1,2),c=e.substring(3,4),u=h(d).parents(".drp-calendar").hasClass("left")?r.calendar[l][c]:i.calendar[l][c];let g=!1;u.hasSame(n[0],"day")&&(g=h(d).addClass("start-hover").length>0),u.hasSame(a[0],"day")&&(g=h(d).addClass("start-date").length>0),u.hasSame(n[1],"day")&&(g=h(d).addClass("end-hover").length>0),a[1]!=null&&u.hasSame(a[1],"day")&&(g=h(d).addClass("end-date").length>0),u.startOf("day")>=n[0].startOf("day")&&u.startOf("day")<=n[1].startOf("day")&&(g=h(d).addClass("range-hover").length>0),u.startOf("day")>=a[0].startOf("day")&&a[1]!=null&&u.startOf("day")<=a[1].startOf("day")&&(g=h(d).addClass("in-range").length>0),g||(h(d).removeClass("start-hover"),h(d).removeClass("end-hover"),h(d).removeClass("start-date"),h(d).removeClass("end-date"),h(d).removeClass("in-range"),h(d).removeClass("range-hover"))})}leaveRange(s){this.container.find(".drp-calendar tbody td").each(function(t,a){h(a).hasClass("week")||(h(a).removeClass("start-hover"),h(a).removeClass("end-hover"),h(a).removeClass("range-hover"))})}clickDate(s){if(!h(s.target).hasClass("available"))return;var t=h(s.target).attr("data-title"),a=t.substring(1,2),n=t.substring(3,4),r=h(s.target).parents(".drp-calendar"),i=r.hasClass("left")?this.leftCalendar.calendar[a][n]:this.rightCalendar.calendar[a][n];let f;if(this.#e||!this.#t||i<this.#t.startOf("day")){if(this.timePicker){let d=parseInt(this.container.find(".start-time .hourselect").val(),10);isNaN(d)&&(d=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:d,minute:e,second:l})}else i=i.startOf("day");this.#e=null,this.#t=i,f="start"}else if(!this.#e&&i<this.#t)this.#e=this.#t,f="end";else{if(this.timePicker){let d=parseInt(this.container.find(".end-time .hourselect").val(),10);isNaN(d)&&(d=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:d,minute:e,second:l})}else i=i.endOf("day");this.#e=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),f="end"}this.singleDatePicker&&(this.#e=this.#t,!this.timePicker&&this.autoApply&&this.clickApply(),f=null),this.updateView(),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.element.trigger("dateChange.daterangepicker",[this,f])}calculateChosenLabel(){var s=!0,t=0;for(var a in this.ranges){var n=this.timePicker?"hour":"day";if(this.timePicker&&(this.timePickerOpts.showMinutes?n="minute":this.timePickerOpts.showSeconds&&(n="second")),this.#t.startOf(n).equals(this.ranges[a][0].startOf(n))&&this.#e.startOf(n).equals(this.ranges[a][1].startOf(n))){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())}clickApply(){this.hide(),this.element.trigger("apply.daterangepicker",this)}clickCancel(){this.#t=this.oldStartDate,this.#e=this.oldEndDate,this.hide(),this.element.trigger("cancel.daterangepicker",this)}monthOrYearChanged(s){var t=h(s.target).closest(".drp-calendar").hasClass("left"),a=t?"left":"right",n=this.container.find(".drp-calendar."+a),r=parseInt(n.find(".monthselect").val(),10),i=n.find(".yearselect").val();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?(this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars()}timeChanged(s){const t=h(s.target).closest(".calendar-time"),a=t.hasClass("start-time")?"start":"end";var n=parseInt(t.find(".hourselect").val(),10);if(isNaN(n)&&(n=parseInt(t.find(".hourselect option:last").val(),10)),!this.timePicker24Hour){const f=t.find(".ampmselect").val();if(f==null&&t.find(".ampmselect option:last").val(),f!=o.fromFormat(`${n}`,"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 d=o.fromFormat(`${n}`,"H").toFormat("h");n=o.fromFormat(`${d}${f}`,"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))),a==="start"?(this.#t&&(this.#t=this.#t.set({hour:n,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:n,minute:r,second:i})),this.updateCalendars(),this.setApplyBtnState(),this.element.trigger("beforeRenderTimePicker.daterangepicker",this),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.element.trigger("timeChange.daterangepicker",[this,this.singleDatePicker?null:a])}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);if(this.singleDatePicker){let a=o.fromFormat(this.element.val(),s,{locale:o.now().locale});const n=this.#t;if(!a.isValid||n.equals(a))return;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return null;this.#t=a,this.#e=this.#t}else if(!this.singleDatePicker&&t.length===2){const a=[1,2].map(i=>o.fromFormat(t[i],s,{locale:o.now().locale})),n=[this.#t,this.#e];if(!a[0].isValid||!a[1].isValid||n[0].equals(a[0])&&n[1].equals(a[1])||a[1]>a[0])return;const r=this.validateInput([a[0],a[1]],!0);if(r!=null)if(r.newDate!=null)a[0]=r.newDate.startDate,a[1]=r.newDate.endDate;else return;this.#t=a[0],this.#e=a[1]}else return;this.updateView(),this.updateElement(),this.element.trigger("inputChanged.daterangepicker",this)}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 a=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});h(this.altInput[1]).val(a)}}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()}}h.fn.daterangepicker||(h.fn.daterangepicker=function(P,s){const t=h.extend(!0,{},h.fn.daterangepicker.defaultOptions,P);return this.each(function(){const a=h(this);a.data("daterangepicker")&&a.data("daterangepicker").remove(),a.data("daterangepicker",new I(a,t,s))}),this});var F=I;export{F as default};
|
|
@@ -6,7 +6,6 @@ var DateRangePicker = (() => {
|
|
|
6
6
|
class DateRangePicker {
|
|
7
7
|
#startDate = null;
|
|
8
8
|
#endDate = null;
|
|
9
|
-
#setRange = false;
|
|
10
9
|
constructor(element, options, cb) {
|
|
11
10
|
this.parentEl = "body";
|
|
12
11
|
this.element = $(element);
|
|
@@ -517,9 +516,17 @@ var DateRangePicker = (() => {
|
|
|
517
516
|
}
|
|
518
517
|
this.updateElement();
|
|
519
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* startDate
|
|
521
|
+
* @type {external:DateTime}
|
|
522
|
+
*/
|
|
520
523
|
get startDate() {
|
|
521
524
|
return this.#startDate;
|
|
522
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* endDate
|
|
528
|
+
* @type {external:DateTime}
|
|
529
|
+
*/
|
|
523
530
|
get endDate() {
|
|
524
531
|
return this.singleDatePicker ? null : this.#endDate;
|
|
525
532
|
}
|
|
@@ -696,7 +703,7 @@ var DateRangePicker = (() => {
|
|
|
696
703
|
}
|
|
697
704
|
/**
|
|
698
705
|
* Emitted when the date is changed through `<input>` element or via {@link #DateRangePicker+setStartDate|setStartDate} or
|
|
699
|
-
* {@link #DateRangePicker+setRange|setRange} and date is not valid due to
|
|
706
|
+
* {@link #DateRangePicker+setRange|setRange} and date is not valid due to
|
|
700
707
|
* `minDate`, `maxDate`, `minSpan`, `maxSpan`, `invalidDate` and `invalidTime` constraints.<br>
|
|
701
708
|
* Event is only triggered when date string is valid and date value is changing<br>
|
|
702
709
|
* @event
|
|
@@ -728,23 +735,23 @@ var DateRangePicker = (() => {
|
|
|
728
735
|
* // Try to set date outside permitted range by code
|
|
729
736
|
* const drp = $('#picker').data('daterangepicker').setStartDate(DateTime.now().minus({ years: 10 })
|
|
730
737
|
*
|
|
731
|
-
* -> Calendar selects and shows "today - 3 days"
|
|
738
|
+
* // -> Calendar selects and shows "today - 3 days"
|
|
732
739
|
*/
|
|
733
740
|
/**
|
|
734
741
|
* @typedef InputViolation
|
|
735
742
|
* @type {Object}
|
|
736
743
|
* @property {external:DateTime} startDate - Violation of startDate
|
|
737
|
-
* @property {external:DateTime|undefined}
|
|
744
|
+
* @property {external:DateTime|undefined} endDate? - Violation of endDate, if existing
|
|
738
745
|
* @property {Array} violations - The constraints which violates the input
|
|
739
746
|
* @property {Array} reason - The type/reson of violation
|
|
740
747
|
* @property {external:DateTime} old - Old value startDate/endDate
|
|
741
|
-
* @property {external:DateTime}
|
|
748
|
+
* @property {external:DateTime} new? - Corrected value of startDate/endDate if existing
|
|
742
749
|
*/
|
|
743
750
|
/**
|
|
744
751
|
* Validate `startDate` and `endDate` against `timePickerStepSize`, `minDate`, `maxDate`,
|
|
745
752
|
* `minSpan`, `maxSpan`, `invalidDate` and `invalidTime`.
|
|
746
|
-
* @param {Array} [startDate, endDate] - Range to be checked, defaults to current `startDate` and `endDate`
|
|
747
|
-
* @param {boolean} dipatch=false - If
|
|
753
|
+
* @param {Array} range=[startDate, endDate] - Range to be checked, defaults to current `startDate` and `endDate`
|
|
754
|
+
* @param {boolean} dipatch=false - If `true` then event "violated.daterangepicker" is dispated.<br>
|
|
748
755
|
* If eventHandler returns `true`, then `null` is returned, otherwiese the object of violations.
|
|
749
756
|
* @emits "violated.daterangepicker"
|
|
750
757
|
* @returns {InputViolation|null} - Object of violations and corrected values or `null` if no violation have been found
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var DateRangePicker=(()=>{const h=luxon.DateTime,D=luxon.Duration,S=luxon.Info,P=luxon.Settings;class I{#t=null;#e=null;#i=!1;constructor(s,t,a){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 n=new Intl.DateTimeFormat(h.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!n.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 c=[];for(let l of["minutes","seconds"])c.push(...[1,2,3,4,5,6,10,12,15,20,30].map(d=>D.fromObject({[l]:d})));c.push(...[1,2,3,4,6].map(l=>D.fromObject({hours:l}))),this.timePicker24Hour&&c.push(...[8,12].map(l=>D.fromObject({hours:l}))),c.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.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day"))),this.singleDatePicker?this.#e=this.#t:this.#e<this.#t&&console.error(`Option 'endDate' ${this.#e} must not be earlier than 'startDate' ${this.#t}`),["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
|
|
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,a){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 n=new Intl.DateTimeFormat(h.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!n.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 c=[];for(let l of["minutes","seconds"])c.push(...[1,2,3,4,5,6,10,12,15,20,30].map(d=>D.fromObject({[l]:d})));c.push(...[1,2,3,4,6].map(l=>D.fromObject({hours:l}))),this.timePicker24Hour&&c.push(...[8,12].map(l=>D.fromObject({hours:l}))),c.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.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day"))),this.singleDatePicker?this.#e=this.#t:this.#e<this.#t&&console.error(`Option 'endDate' ${this.#e} must not be earlier than 'startDate' ${this.#t}`),["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
2
|
`,e)}if(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;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;this.#e=d}}}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 o="<ul>";for(let e in this.ranges)o+='<li data-range-key="'+e+'">'+e+"</li>";this.showCustomRangeLabel&&(o+='<li data-range-key="'+this.locale.customRangeLabel+'">'+this.locale.customRangeLabel+"</li>"),o+="</ul>",this.container.find(".ranges").prepend(o),this.container.addClass("show-ranges")}typeof a=="function"&&(this.callback=a),this.timePicker||(this.#t&&(this.#t=this.#t.startOf("day")),this.#e&&(this.#e=this.#e.endOf("day")),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.#t}get endDate(){return this.singleDatePicker?null:this.#e}set startDate(s){this.#t=s}set endDate(s){this.#e=s}setStartDate(s,t=!0){if(!this.singleDatePicker)return setRange(s,this.#e,t);const a=this.#t;let n=this.parseDate(s);if(n.equals(a))return null;const r=this.validateInput([n,null],!0);if(r!=null)if(r.newDate!=null)n=r.newDate.startDate;else return r;return this.#t=n,this.#e=this.#t,this.updateElement(),t&&this.updateView(),r}setEndDate(s,t=!0){return this.singleDatePicker?null:setRange(this.#t,s,t)}setRange(s,t,a=!0){if(this.singleDatePicker)return;this.#e||(this.#e=this.#t);const n=[this.#t,this.#e];let r=[this.parseDate(s),this.parseDate(t)];if(n[0].equals(r[0])&&n[1].equals(r[1])||r[1]>r[0])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;return this.#t=r[0],this.#e=r[1],this.updateElement(),a&&this.updateView(),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 a=h.fromFormat(s,t,{locale:h.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${a}`)}}}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 a=h.now().locale;return s.toFormat(t,{locale:a})}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 a=s==null?this.#t:s[0],n=s==null?this.#e:s[1];if(a==null)return null;let r={startDate:{violations:[]}},i={old:a,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const e=this.timePickerStepSize.as("seconds");a=h.fromSeconds(e*Math.round(a.toSeconds()/e))}else a=a.startOf("day");i.new=a,i.new.equals(i.old)||r.startDate.violations.push(i);const c=this.timePicker?this.timePickerStepSize.as("seconds"):D.fromObject({days:1}).as("seconds");this.minDate&&a<this.minDate?(i={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/c)*c}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.startDate.violations.push(i)):this.maxDate&&a>this.maxDate&&(i={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/c)*c}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=a,i.new.equals(i.old)||r.startDate.violations.push(i));let o=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&o.push("minute"),this.timePickerOpts.showSeconds&&o.push("second"),this.timePicker24Hour||o.push("ampm")),this.isInvalidDate(a)&&r.startDate.violations.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let e of o)this.isInvalidTime(a,e,"start")&&r.startDate.violations.push({old:a,reason:"isInvalidTime",unit:e});if(this.singleDatePicker){if(r.startDate.violations.length==0)return null;if(t){let e={startDate:a};return this.element.triggerHandler("violated.daterangepicker",[this,r,e])&&(r.newDate=e),r}else return r}if(n==null)return null;if(r.endDate={violations:[]},i={old:n,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const e=this.timePickerStepSize.as("seconds");n=h.fromSeconds(e*Math.round(n.toSeconds()/e))}else n=n.endOf("day");if(i.new=n,i.new.equals(i.old)||r.endDate.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")/c)*c}),n>this.maxDate&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i)):this.minDate&&n<this.minDate&&(i={old:n,reason:"minDate"},n=n.plus({seconds:Math.trunc(this.minDate.diff(n).as("seconds")/c)*c}),n<this.minDate&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i)),this.maxSpan){const e=a.plus(this.maxSpan);n>e&&(i={old:n,reason:"maxSpan"},n=n.minus({seconds:Math.trunc(e.diff(n).as("seconds")/c)*c}),n>e&&(n=n.minus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.minSpan){const e=a.plus(this.defaultSpan??this.minSpan);n<e&&(i={old:n,reason:"minSpan"},n=n.plus({seconds:Math.trunc(e.diff(n).as("seconds")/c)*c}),n<e&&(n=n.plus(this.timePicker?this.timePickerStepSize:{days:1})),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i))}if(this.isInvalidDate(n)&&r.endDate.violations.push({old:n,reason:"isInvalidDate"}),this.timePicker)for(let e of o)this.isInvalidTime(n,e,"end")&&r.endDate.violations.push({old:n,reason:"isInvalidTime",unit:e});if(r.startDate.violations.length==0&&r.endDate.violations.length==0)return null;if(t){let e={startDate:a,endDate:n};return this.element.triggerHandler("violated.daterangepicker",[this,r,e])&&(r.newDate=e),r}else return r}updateView(){this.timePicker&&(this.element.trigger("beforeRenderTimePicker.daterangepicker",this),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(),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(){if(this.timePicker){var s,t,a;this.#e?(s=parseInt(this.container.find(".start-time .hourselect").val(),10),isNaN(s)&&(s=parseInt(this.container.find(".start-time .hourselect option:last").val(),10)),t=0,this.timePickerOpts.showMinutes&&(t=parseInt(this.container.find(".start-time .minuteselect").val(),10),isNaN(t)&&(t=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)))):(s=parseInt(this.container.find(".end-time .hourselect").val(),10),isNaN(s)&&(s=parseInt(this.container.find(".end-time .hourselect option:last").val(),10)),t=0,this.timePickerOpts.showMinutes&&(t=parseInt(this.container.find(".end-time .minuteselect").val(),10),isNaN(t)&&(t=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:s,minute:t,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:s,minute:t,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.element.trigger("beforeRenderCalendar.daterangepicker",this),this.renderCalendar("left"),this.renderCalendar("right"),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"),a=i.month.endOf("month").startOf("day");var n=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=a;for(var c=0;c<6;c++)i[c]=[];for(;n.weekday!=this.locale.firstDay;)n=n.minus({day:1});for(let f=0,g=-1;f<42;f++,n=n.plus({day:1}))f%7===0&&g++,i[g][f%7]=n.set(r);s==="left"?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var o=s==="left"?this.minDate:this.#t,e=this.maxDate,l="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(l+="<th></th>"),(!o||o<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=(o&&o.year)??this.minYear;let C=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var u=`${C}<select class="monthselect">`,m=1;m<=12;m++)u+=`<option value="${m}"${m===i.firstDay.month?" selected":""}`,(o&&i.firstDay.set({month:m})<o.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>"),C=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var p=`${C}<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 w=this.isCustomDate(i[f][g]);w!==!1&&(typeof w=="string"?b.push(w):Array.prototype.push.apply(b,w)),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,a,n,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"&&(a=this.#t.plus(this.defaultSpan??this.minSpan)),s==="start")t=this.#t,n=this.minDate;else if(s==="end"){t=this.#e,n=this.#t;var c=this.container.find(".drp-calendar .calendar-time.end-time");c.html()!=""&&(t=t.set({hour:isNaN(t.hour)?c.find(".hourselect option:selected").val():t.hour,minute:isNaN(t.minute)?c.find(".minuteselect option:selected").val():t.minute,second:isNaN(t.second)?c.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 o=t.toFormat("a",{locale:"en-US"});let e=0;this.timePicker24Hour||(e=o==="AM"?1:13);for(var l=e;l<=e+23;l+=this.timePickerOpts.hourStep){let p=t.set({hour:l%24}),k=!1;if(n&&p.set({minute:59})<n&&(k=!0),r&&p.set({minute:0})>r&&(k=!0),a&&p.endOf("hour")<a&&(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"});o==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;n&&k.set({second:59})<n&&(y=!0),r&&k.set({second:0})>r&&(y=!0),a&&k.endOf("minute")<a&&(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;n&&y<n&&(v=!0),r&&y>r&&(v=!0),a&&y<a&&(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;n&&t.startOf("day")<n&&(p=!0),r&&t.endOf("day")>r&&(p=!0),a&&t.startOf("day")<a&&(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,a=this.drops,n=$(window).width();switch(this.parentEl.is("body")||(s={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},n=this.parentEl[0].clientWidth+this.parentEl.offset().left),a){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,a="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",a==="up"),this.opens==="left"){var i=n-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 c=this.element.offset().left-s.left+this.element.outerWidth()/2-r/2;c<0?this.container.css({top:t,right:"auto",left:9}):c+r>$(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:c,right:"auto"})}else{var c=this.element.offset().left-s.left;c+r>$(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:c,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(),this.container.show(),this.move(),this.element.trigger("show.daterangepicker",this),this.isShowing=!0)}hide(){this.isShowing&&(this.#e||(this.#t=this.oldStartDate,this.#e=this.oldEndDate),(this.#t!=this.oldStartDate||this.#e!=this.oldEndDate)&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),!this.element.triggerHandler("beforeHide.daterangepicker",this)&&($(document).off(".daterangepicker"),$(window).off(".daterangepicker"),this.container.hide(),this.element.trigger("hide.daterangepicker",this),this.isShowing=!1))}toggle(){this.isShowing?this.hide():this.show()}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.element.trigger("outsideClick.daterangepicker",this))}showCalendars(){this.container.addClass("show-calendar"),this.move(),this.element.trigger("showCalendar.daterangepicker",this)}hideCalendars(){this.container.removeClass("show-calendar"),this.element.trigger("hideCalendar.daterangepicker",this)}clickRange(s){var t=s.target.getAttribute("data-range-key");if(this.chosenLabel=t,t==this.locale.customRangeLabel)this.showCalendars();else{var a=this.ranges[t];this.#t=a[0],this.#e=a[1],this.timePicker||(this.#t.startOf("day"),this.#e.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.element.triggerHandler("beforeHide.daterangepicker",this)&&this.updateView(),this.clickApply()}}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()}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()}hoverDate(s){if(!$(s.target).hasClass("available"))return;let t=$(s.target).attr("data-title");const a=t.substring(1,2),n=t.substring(3,4);var i=$(s.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.calendar[a][n]:this.rightCalendar.calendar[a][n];const c=this.leftCalendar,o=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")?c.calendar[p][k]:o.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"),a=[this.#t,this.#e],n=this.ranges[t]??[this.#t,this.#e],r=this.leftCalendar,i=this.rightCalendar;this.container.find(".drp-calendar tbody td").each(function(c,o){if($(o).hasClass("week"))return;const e=$(o).attr("data-title"),l=e.substring(1,2),d=e.substring(3,4),m=$(o).parents(".drp-calendar").hasClass("left")?r.calendar[l][d]:i.calendar[l][d];let p=!1;m.hasSame(n[0],"day")&&(p=$(o).addClass("start-hover").length>0),m.hasSame(a[0],"day")&&(p=$(o).addClass("start-date").length>0),m.hasSame(n[1],"day")&&(p=$(o).addClass("end-hover").length>0),a[1]!=null&&m.hasSame(a[1],"day")&&(p=$(o).addClass("end-date").length>0),m.startOf("day")>=n[0].startOf("day")&&m.startOf("day")<=n[1].startOf("day")&&(p=$(o).addClass("range-hover").length>0),m.startOf("day")>=a[0].startOf("day")&&a[1]!=null&&m.startOf("day")<=a[1].startOf("day")&&(p=$(o).addClass("in-range").length>0),p||($(o).removeClass("start-hover"),$(o).removeClass("end-hover"),$(o).removeClass("start-date"),$(o).removeClass("end-date"),$(o).removeClass("in-range"),$(o).removeClass("range-hover"))})}leaveRange(s){this.container.find(".drp-calendar tbody td").each(function(t,a){$(a).hasClass("week")||($(a).removeClass("start-hover"),$(a).removeClass("end-hover"),$(a).removeClass("range-hover"))})}clickDate(s){if(!$(s.target).hasClass("available"))return;var t=$(s.target).attr("data-title"),a=t.substring(1,2),n=t.substring(3,4),r=$(s.target).parents(".drp-calendar"),i=r.hasClass("left")?this.leftCalendar.calendar[a][n]:this.rightCalendar.calendar[a][n];let c;if(this.#e||!this.#t||i<this.#t.startOf("day")){if(this.timePicker){let o=parseInt(this.container.find(".start-time .hourselect").val(),10);isNaN(o)&&(o=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:o,minute:e,second:l})}else i=i.startOf("day");this.#e=null,this.#t=i,c="start"}else if(!this.#e&&i<this.#t)this.#e=this.#t,c="end";else{if(this.timePicker){let o=parseInt(this.container.find(".end-time .hourselect").val(),10);isNaN(o)&&(o=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:o,minute:e,second:l})}else i=i.endOf("day");this.#e=i,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),c="end"}this.singleDatePicker&&(this.#e=this.#t,!this.timePicker&&this.autoApply&&this.clickApply(),c=null),this.updateView(),s.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.element.trigger("dateChange.daterangepicker",[this,c])}calculateChosenLabel(){var s=!0,t=0;for(var a in this.ranges){var n=this.timePicker?"hour":"day";if(this.timePicker&&(this.timePickerOpts.showMinutes?n="minute":this.timePickerOpts.showSeconds&&(n="second")),this.#t.startOf(n).equals(this.ranges[a][0].startOf(n))&&this.#e.startOf(n).equals(this.ranges[a][1].startOf(n))){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())}clickApply(){this.hide(),this.element.trigger("apply.daterangepicker",this)}clickCancel(){this.#t=this.oldStartDate,this.#e=this.oldEndDate,this.hide(),this.element.trigger("cancel.daterangepicker",this)}monthOrYearChanged(s){var t=$(s.target).closest(".drp-calendar").hasClass("left"),a=t?"left":"right",n=this.container.find(".drp-calendar."+a),r=parseInt(n.find(".monthselect").val(),10),i=n.find(".yearselect").val();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?(this.leftCalendar.month=this.leftCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(this.rightCalendar.month=this.rightCalendar.month.set({year:i,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars()}timeChanged(s){const t=$(s.target).closest(".calendar-time"),a=t.hasClass("start-time")?"start":"end";var n=parseInt(t.find(".hourselect").val(),10);if(isNaN(n)&&(n=parseInt(t.find(".hourselect option:last").val(),10)),!this.timePicker24Hour){const c=t.find(".ampmselect").val();if(c==null&&t.find(".ampmselect option:last").val(),c!=h.fromFormat(`${n}`,"H").toFormat("a",{locale:"en-US"})){t.find(".hourselect > option").each(function(){const e=$(this).attr("hidden")||!1;$(this).attr("hidden",e)});const o=h.fromFormat(`${n}`,"H").toFormat("h");n=h.fromFormat(`${o}${c}`,"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))),a==="start"?(this.#t&&(this.#t=this.#t.set({hour:n,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:n,minute:r,second:i})),this.updateCalendars(),this.setApplyBtnState(),this.element.trigger("beforeRenderTimePicker.daterangepicker",this),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.element.trigger("timeChange.daterangepicker",[this,this.singleDatePicker?null:a])}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);if(this.singleDatePicker){let a=h.fromFormat(this.element.val(),s,{locale:h.now().locale});const n=this.#t;if(!a.isValid||n.equals(a))return;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return null;this.#t=a,this.#e=this.#t}else if(!this.singleDatePicker&&t.length===2){const a=[1,2].map(i=>h.fromFormat(t[i],s,{locale:h.now().locale})),n=[this.#t,this.#e];if(!a[0].isValid||!a[1].isValid||n[0].equals(a[0])&&n[1].equals(a[1])||a[1]>a[0])return;const r=this.validateInput([a[0],a[1]],!0);if(r!=null)if(r.newDate!=null)a[0]=r.newDate.startDate,a[1]=r.newDate.endDate;else return;this.#t=a[0],this.#e=a[1]}else return;this.updateView(),this.updateElement(),this.element.trigger("inputChanged.daterangepicker",this)}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 a=this.#e.toISO({format:"basic",precision:s,includeOffset:!1});$(this.altInput[1]).val(a)}}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()}}$.fn.daterangepicker||($.fn.daterangepicker=function(O,s){const t=$.extend(!0,{},$.fn.daterangepicker.defaultOptions,O);return this.each(function(){const a=$(this);a.data("daterangepicker")&&a.data("daterangepicker").remove(),a.data("daterangepicker",new I(a,t,s))}),this});})();
|
package/package.json
CHANGED