@wernfried/daterangepicker 4.16.11 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API_Doc.md +8 -662
- package/README.md +8 -140
- package/dist/esm/daterangepicker.js +30 -15
- package/dist/esm/daterangepicker.min.js +1 -1
- package/dist/global/daterangepicker.js +30 -15
- package/dist/global/daterangepicker.min.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -20,8 +20,8 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
20
20
|
```html
|
|
21
21
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
22
22
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
23
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
24
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
23
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.0/dist/global/daterangepicker.min.js"></script>
|
|
24
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.0/css/daterangepicker.min.css" rel="stylesheet" />
|
|
25
25
|
|
|
26
26
|
<input type="text" id="picker" />
|
|
27
27
|
|
|
@@ -43,11 +43,11 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
43
43
|
"imports": {
|
|
44
44
|
"jquery": "https://cdn.jsdelivr.net/npm/jquery@4.0.0/+esm",
|
|
45
45
|
"luxon": "https://cdn.jsdelivr.net/npm/luxon@3.7.2/+esm",
|
|
46
|
-
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
46
|
+
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.0/+esm"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
50
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.0/css/daterangepicker.min.css" rel="stylesheet" />
|
|
51
51
|
|
|
52
52
|
<input type="text" id="picker" />
|
|
53
53
|
|
|
@@ -68,7 +68,7 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
68
68
|
```html
|
|
69
69
|
<script ...></script>
|
|
70
70
|
<link type="text/css" href="https://cdn.jsdelivr.net/npm/bulma@1.0.4/css/bulma.min.css" rel="stylesheet" />
|
|
71
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.
|
|
71
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.0/css/daterangepicker.bulma.min.css" rel="stylesheet" />
|
|
72
72
|
|
|
73
73
|
<input type="text" id="picker" />
|
|
74
74
|
|
|
@@ -171,11 +171,12 @@ Compared to [inital repository](https://github.com/dangrossman/daterangepicker),
|
|
|
171
171
|
- Added option `singleMonthView` to show single month calendar, useful for shorter ranges
|
|
172
172
|
- Better validation of input parameters, errors are logged to console
|
|
173
173
|
- Highlight range in calendar when hovering over pre-defined ranges
|
|
174
|
-
- Option `autoUpdateInput` defines whether the attached `<input>` element is updated when the user clicks on a date value.<br
|
|
174
|
+
- Option `autoUpdateInput` defines whether the attached `<input>` element is updated when the user clicks on a date value.<br>
|
|
175
175
|
In original daterangepicker this parameter defines whether the `<input>` is updated when the user clicks on `Apply` button.
|
|
176
176
|
- Added option `locale.durationFormat` to show customized label for selected duration, e.g. `'4 Days, 6 Hours, 30 Minutes'`
|
|
177
|
-
- Added option `externalStyle` to use daterangepicker with external CSS Frameworks. Currently only [Bulma](https://bulma.io/) is supported<br
|
|
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
|
+
- [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) Module Import
|
|
179
180
|
- [Jest](https://jestjs.io/) unit testing
|
|
180
181
|
- ... and maybe some new bugs 😉
|
|
181
182
|
|
|
@@ -256,136 +257,3 @@ Licensed under the [MIT license](LICENSE).
|
|
|
256
257
|
|
|
257
258
|
## API Documentation
|
|
258
259
|
[API Documentation](API_Doc.md)
|
|
259
|
-
## Options
|
|
260
|
-
Options for DateRangePicker
|
|
261
|
-
|
|
262
|
-
**Kind**: global typedef
|
|
263
|
-
**Properties**
|
|
264
|
-
|
|
265
|
-
| Name | Type | Default | Description |
|
|
266
|
-
| --- | --- | --- | --- |
|
|
267
|
-
| parentEl | <code>string</code> | <code>"body"</code> | [jQuery selector](https://api.jquery.com/category/selectors/) of the parent element that the date range picker will be added to |
|
|
268
|
-
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> \| <code>null</code> | | Default: `DateTime.now().startOf('day')`<br>The beginning date of the initially selected date range.<br> Must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) or a string matching `locale.format`.<br> Date value is rounded to match option `timePickerStepSize`<br> Option `isInvalidDate` and `isInvalidTime` are not evaluated, you may set date/time which is not selectable in calendar.<br> If the date does not fall into `minDate` and `maxDate` then date is shifted and a warning is written to console.<br> Use `startDate: null` to show calendar without an inital selected date. |
|
|
269
|
-
| endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | | Defautl: `DateTime.now().endOf('day')`<br>The end date of the initially selected date range.<br> Must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) or a string matching `locale.format`.<br> Date value is rounded to match option `timePickerStepSize`<br> Option `isInvalidDate`, `isInvalidTime` and `minSpan`, `maxSpan` are not evaluated, you may set date/time which is not selectable in calendar.<br> If the date does not fall into `minDate` and `maxDate` then date is shifted and a warning is written to console.<br> |
|
|
270
|
-
| minDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> \| <code>null</code> | | The earliest date a user may select or `null` for no limit.<br> Must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) or a string matching `locale.format`. |
|
|
271
|
-
| maxDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> \| <code>null</code> | | The latest date a user may select or `null` for no limit.<br> Must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) or a string matching `locale.format`. |
|
|
272
|
-
| minSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | | The minimum span between the selected start and end dates.<br> Must be a `luxon.Duration` or number of seconds or a string according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) duration.<br> Ignored when `singleDatePicker: true` |
|
|
273
|
-
| maxSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | | The maximum span between the selected start and end dates.<br> Must be a `luxon.Duration` or number of seconds or a string according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) duration.<br> Ignored when `singleDatePicker: true` |
|
|
274
|
-
| defaultSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | | The span which is used when endDate is automatically updated due to wrong user input<br> Must be a `luxon.Duration` or number of seconds or a string according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) duration.<br> Ignored when `singleDatePicker: true`. Not relevant if `minSpan: null` |
|
|
275
|
-
| initalMonth | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> \| <code>null</code> | | Default: `DateTime.now().startOf('month')`<br> The inital month shown when `startDate: null`. Be aware, the attached `<input>` element must be also empty.<br> Must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) or a string matching `locale.format`.<br> When `initalMonth` is used, then `endDate` is ignored and it works only with `timePicker: false` |
|
|
276
|
-
| autoApply | <code>boolean</code> | <code>false</code> | Hide the `Apply` and `Cancel` buttons, and automatically apply a new date range as soon as two dates are clicked.<br> Only useful when `timePicker: false` |
|
|
277
|
-
| singleDatePicker | <code>boolean</code> | <code>false</code> | Show only a single calendar to choose one date, instead of a range picker with two calendars.<br> If `true`, then `endDate` is always `null`. |
|
|
278
|
-
| singleMonthView | <code>boolean</code> | <code>false</code> | Show only a single month calendar, useful when selected ranges are usually short<br> or for smaller viewports like mobile devices.<br> Ignored for `singleDatePicker: true`. |
|
|
279
|
-
| showDropdowns | <code>boolean</code> | <code>false</code> | Show year and month select boxes above calendars to jump to a specific month and year |
|
|
280
|
-
| minYear | <code>number</code> | | Default: `DateTime.now().minus({year:100}).year`<br>The minimum year shown in the dropdowns when `showDropdowns: true` |
|
|
281
|
-
| maxYear | <code>number</code> | | Default: `DateTime.now().plus({year:100}).year`<br>The maximum year shown in the dropdowns when `showDropdowns: true` |
|
|
282
|
-
| showWeekNumbers | <code>boolean</code> | <code>false</code> | Show **localized** week numbers at the start of each week on the calendars |
|
|
283
|
-
| showISOWeekNumbers | <code>boolean</code> | <code>false</code> | Show **ISO** week numbers at the start of each week on the calendars.<br> Takes precedence over localized `showWeekNumbers` |
|
|
284
|
-
| timePicker | <code>boolean</code> | <code>false</code> | Adds select boxes to choose times in addition to dates |
|
|
285
|
-
| timePicker24Hour | <code>boolean</code> | <code>true|false</code> | Use 24-hour instead of 12-hour times, removing the AM/PM selection.<br> Default is derived from current locale [Intl.DateTimeFormat.resolvedOptions.hour12](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#hour12). |
|
|
286
|
-
| timePickerStepSize | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> | | Default: `Duration.fromObject({minutes:1})`<br>Set the time picker step size.<br> Must be a `luxon.Duration` or the number of seconds or a string according to [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) duration.<br> Valid values are 1,2,3,4,5,6,10,12,15,20,30 for `Duration.fromObject({seconds: ...})` and `Duration.fromObject({minutes: ...})` and 1,2,3,4,6,(8,12) for `Duration.fromObject({hours: ...})`.<br> Duration must be greater than `minSpan` and smaller than `maxSpan`.<br> For example `timePickerStepSize: 600` will disable time picker seconds and time picker minutes are set to step size of 10 Minutes.<br> Overwrites `timePickerIncrement` and `timePickerSeconds`, ignored when `timePicker: false` |
|
|
287
|
-
| timePickerSeconds | <code>boolean</code> | <code>boolean</code> | **Deprecated**, use `timePickerStepSize`<br>Show seconds in the timePicker |
|
|
288
|
-
| timePickerIncrement | <code>boolean</code> | <code>1</code> | **Deprecated**, use `timePickerStepSize`<br>Increment of the minutes selection list for times |
|
|
289
|
-
| autoUpdateInput | <code>boolean</code> | <code>true</code> | Indicates whether the date range picker should instantly update the value of the attached `<input>` element when the selected dates change.<br>The `<input>` element will be always updated on `Apply` and reverted when user clicks on `Cancel`. |
|
|
290
|
-
| onOutsideClick | <code>string</code> | <code>"apply"</code> | Defines what picker shall do when user clicks outside the calendar. `'apply'` or `'cancel'`. Event [onOutsideClick.daterangepicker](#event_outsideClick.daterangepicker) is always emitted. |
|
|
291
|
-
| linkedCalendars | <code>boolean</code> | <code>true</code> | When enabled, the two calendars displayed will always be for two sequential months (i.e. January and February), and both will be advanced when clicking the left or right arrows above the calendars.<br> When disabled, the two calendars can be individually advanced and display any month/year |
|
|
292
|
-
| isInvalidDate | <code>function</code> | <code>false</code> | A function that is passed each date in the two calendars before they are displayed,<br> and may return `true` or `false` to indicate whether that date should be available for selection or not.<br> Signature: `isInvalidDate(date)`<br> |
|
|
293
|
-
| isInvalidTime | <code>function</code> | <code>false</code> | A function that is passed each hour/minute/second/am-pm in the two calendars before they are displayed,<br> and may return `true` or `false` to indicate whether that date should be available for selection or not.<br> Signature: `isInvalidTime(time, side, unit)`<br> `side` is `'start'` or `'end'` or `null` for `singleDatePicker: true`<br> `unit` is `'hour'`, `'minute'`, `'second'` or `'ampm'`<br> Hours are always given as 24-hour clock<br> Ensure that your function returns `false` for at least one item. Otherwise the calender is not rendered.<br> |
|
|
294
|
-
| isCustomDate | <code>function</code> | <code>false</code> | A function that is passed each date in the two calendars before they are displayed, and may return a string or array of CSS class names to apply to that date's calendar cell.<br> Signature: `isCustomDate(date)` |
|
|
295
|
-
| altInput | <code>string</code> \| <code>Array</code> | <code>null</code> | A [jQuery selector](https://api.jquery.com/category/selectors/) string for an alternative output (typically hidden) `<input>` element. Uses `altFormat` to format the value.<br> Must be a single string for `singleDatePicker: true` or an array of two strings for `singleDatePicker: false`<br> Example: `['#start', '#end']` |
|
|
296
|
-
| altFormat | <code>function</code> \| <code>string</code> | | The output format used for `altInput`.<br> Default: ISO-8601 basic format without time zone, precisison is derived from `timePicker` and `timePickerStepSize`<br> Example `yyyyMMdd'T'HHmm` for `timePicker=true` and display of Minutes<br> If defined, either a string used with [Format tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) or a function.<br> Examples: `"yyyy:MM:dd'T'HH:mm"`,<br>`(date) => date.toUnixInteger()` |
|
|
297
|
-
| ~~warnings~~ | <code>boolean</code> | | Not used anymore. Listen to event `violated.daterangepicker` to react on invalid input data |
|
|
298
|
-
| applyButtonClasses | <code>string</code> | <code>"btn-primary"</code> | CSS class names that will be added only to the apply button |
|
|
299
|
-
| cancelButtonClasses | <code>string</code> | <code>"btn-default"</code> | CSS class names that will be added only to the cancel button |
|
|
300
|
-
| buttonClasses | <code>string</code> | | Default: `'btn btn-sm'`<br>CSS class names that will be added to both the apply and cancel buttons. |
|
|
301
|
-
| weekendClasses | <code>string</code> | <code>"weekend"</code> | CSS class names that will be used to highlight weekend days.<br> Use `null` or empty string if you don't like to highlight weekend days. |
|
|
302
|
-
| weekendDayClasses | <code>string</code> | <code>"weekend-day"</code> | CSS class names that will be used to highlight weekend day names.<br> Weekend days are evaluated by [Info.getWeekendWeekdays](https://moment.github.io/luxon/api-docs/index.html#infogetweekendweekdays) and depend on current locale settings. Use `null` or empty string if you don't like to highlight weekend day names. |
|
|
303
|
-
| todayClasses | <code>string</code> | <code>"today"</code> | CSS class names that will be used to highlight the current day.<br> Use `null` or empty string if you don't like to highlight the current day. |
|
|
304
|
-
| externalStyle | <code>string</code> | <code>null</code> | External CSS Framework to style the picker. Currently only `'bulma'` is supported. |
|
|
305
|
-
| opens | <code>string</code> | <code>"right"</code> | Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to.<br> `'left' \| 'right' \| 'center'` |
|
|
306
|
-
| drops | <code>string</code> | <code>"down"</code> | Whether the picker appears below or above the HTML element it's attached to.<br> `'down' \| 'up' \| 'auto'` |
|
|
307
|
-
| ranges | <code>object</code> | <code>{}</code> | Set predefined date [Ranges](#Ranges) the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range. |
|
|
308
|
-
| showCustomRangeLabel | <code>boolean</code> | <code>true</code> | Displays "Custom Range" at the end of the list of predefined [Ranges](#Ranges), when the ranges option is used.<br> This option will be highlighted whenever the current date range selection does not match one of the predefined ranges.<br> Clicking it will display the calendars to select a new range. |
|
|
309
|
-
| alwaysShowCalendars | <code>boolean</code> | <code>false</code> | Normally, if you use the ranges option to specify pre-defined date ranges, calendars for choosing a custom date range are not shown until the user clicks "Custom Range".<br> When this option is set to true, the calendars for choosing a custom date range are always shown instead. |
|
|
310
|
-
| showLabel= | <code>boolean</code> | | Shows selected range next to Apply buttons.<br> Defaults to `false` if anchor element is `<input type="text">`, otherwise `true` |
|
|
311
|
-
| locale | <code>object</code> | <code>{}</code> | Allows you to provide localized strings for buttons and labels, customize the date format, and change the first day of week for the calendars. |
|
|
312
|
-
| locale.direction | <code>string</code> | <code>"ltr"</code> | Direction of reading, `'ltr'` or `'rtl'` |
|
|
313
|
-
| locale.format | <code>object</code> \| <code>string</code> | | Default: `DateTime.DATE_SHORT` or `DateTime.DATETIME_SHORT` when `timePicker: true`<br>Date formats. Either given as string, see [Format Tokens](https://moment.github.io/luxon/#/formatting?id=table-of-tokens) or an object according to [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)<br> I recommend to use the luxon [Presets](https://moment.github.io/luxon/#/formatting?id=presets). |
|
|
314
|
-
| locale.separator | <code>string</code> | | Defaut: `' - '`<br>Separator for start and end time |
|
|
315
|
-
| locale.weekLabel | <code>string</code> | <code>"W"</code> | Label for week numbers |
|
|
316
|
-
| locale.daysOfWeek | <code>Array</code> | | Default: `luxon.Info.weekdays('short')`<br>Array with weekday names, from Monday to Sunday |
|
|
317
|
-
| locale.monthNames | <code>Array</code> | | Default: `luxon.Info.months('long')`<br>Array with month names |
|
|
318
|
-
| locale.firstDay | <code>number</code> | | Default: `luxon.Info.getStartOfWeek()`<br>First day of the week, 1 for Monday through 7 for Sunday |
|
|
319
|
-
| locale.applyLabel | <code>string</code> | <code>"Apply"</code> | Label of `Apply` Button |
|
|
320
|
-
| locale.cancelLabel | <code>string</code> | <code>"Cancel"</code> | Label of `Cancel` Button |
|
|
321
|
-
| locale.customRangeLabel | <code>string</code> | <code>"Custom"</code> | Range - Title for custom ranges |
|
|
322
|
-
| locale.durationFormat | <code>object</code> \| <code>string</code> \| <code>function</code> | <code>{}</code> | Format a custom label for selected duration, for example `'5 Days, 12 Hours'`.<br> Define the format either as string, see [Duration.toFormat - Format Tokens](https://moment.github.io/luxon/api-docs/index.html#durationtoformat) or an object according to [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options), see [Duration.toHuamn](https://moment.github.io/luxon/api-docs/index.html#durationtohuman).<br> Or custom function as `(startDate, endDate) => {}` |
|
|
323
|
-
|
|
324
|
-
<a name="Ranges"></a>
|
|
325
|
-
|
|
326
|
-
## Ranges : <code>Object</code>
|
|
327
|
-
A set of predefined ranges.<br>
|
|
328
|
-
Ranges are not validated against `minDate`, `maxDate`, `minSpan`, `maxSpan` or `timePickerStepSize ` constraints.
|
|
329
|
-
|
|
330
|
-
**Kind**: global typedef
|
|
331
|
-
**Properties**
|
|
332
|
-
|
|
333
|
-
| Name | Type | Description |
|
|
334
|
-
| --- | --- | --- |
|
|
335
|
-
| name | <code>string</code> | The name of the range |
|
|
336
|
-
| range | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | Array of 2 elements with `startDate` and `endDate` |
|
|
337
|
-
|
|
338
|
-
**Example**
|
|
339
|
-
```js
|
|
340
|
-
{
|
|
341
|
-
'Today': [DateTime.now().startOf('day'), DateTime.now().endOf('day')],
|
|
342
|
-
'Yesterday': [DateTime.now().startOf('day').minus({days: 1}), DateTime.now().minus({days: 1}).endOf('day')],
|
|
343
|
-
'Last 7 Days': [DateTime.now().startOf('day').minus({days: 6}), DateTime.now()],
|
|
344
|
-
'Last 30 Days': [DateTime.now().startOf('day').minus({days: 29}), DateTime.now()],
|
|
345
|
-
'This Month': [DateTime.now().startOf('day').startOf('month'), DateTime.now().endOf('month')],
|
|
346
|
-
'Last Month': [DateTime.now().startOf('day').minus({months: 1}).startOf('month'), DateTime.now().minus({months: 1}).endOf('month')]
|
|
347
|
-
}
|
|
348
|
-
```
|
|
349
|
-
<a name="Range"></a>
|
|
350
|
-
|
|
351
|
-
## Range : <code>Object</code>
|
|
352
|
-
A single predefined range
|
|
353
|
-
|
|
354
|
-
**Kind**: global typedef
|
|
355
|
-
**Properties**
|
|
356
|
-
|
|
357
|
-
| Name | Type | Description |
|
|
358
|
-
| --- | --- | --- |
|
|
359
|
-
| name | <code>string</code> | The name of the range |
|
|
360
|
-
| range | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | Array of 2 elements with startDate and endDate |
|
|
361
|
-
|
|
362
|
-
**Example**
|
|
363
|
-
```js
|
|
364
|
-
{ Today: [DateTime.now().startOf('day'), DateTime.now().endOf('day')] }
|
|
365
|
-
```
|
|
366
|
-
<a name="InputViolation"></a>
|
|
367
|
-
|
|
368
|
-
## InputViolation : <code>Object</code>
|
|
369
|
-
**Kind**: global typedef
|
|
370
|
-
**Properties**
|
|
371
|
-
|
|
372
|
-
| Name | Type | Description |
|
|
373
|
-
| --- | --- | --- |
|
|
374
|
-
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Violation of startDate |
|
|
375
|
-
| endDate? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| <code>undefined</code> | Violation of endDate, if existing |
|
|
376
|
-
| violations | <code>Array</code> | The constraints which violates the input |
|
|
377
|
-
| reason | <code>Array</code> | The type/reson of violation |
|
|
378
|
-
| old | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Old value startDate/endDate |
|
|
379
|
-
| new? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Corrected value of startDate/endDate if existing |
|
|
380
|
-
|
|
381
|
-
<a name="callback"></a>
|
|
382
|
-
|
|
383
|
-
## callback : <code>function</code>
|
|
384
|
-
**Kind**: global typedef
|
|
385
|
-
|
|
386
|
-
| Param | Type | Description |
|
|
387
|
-
| --- | --- | --- |
|
|
388
|
-
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Selected startDate |
|
|
389
|
-
| endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Selected endDate |
|
|
390
|
-
| range | <code>string</code> | |
|
|
391
|
-
|
|
@@ -464,9 +464,8 @@ class DateRangePicker {
|
|
|
464
464
|
this.container.find(".ranges").prepend(list);
|
|
465
465
|
this.container.addClass("show-ranges");
|
|
466
466
|
}
|
|
467
|
-
if (typeof cb === "function")
|
|
467
|
+
if (typeof cb === "function")
|
|
468
468
|
this.callback = cb;
|
|
469
|
-
}
|
|
470
469
|
if (!this.timePicker) {
|
|
471
470
|
if (this.#startDate)
|
|
472
471
|
this.#startDate = this.#startDate.startOf("day");
|
|
@@ -518,14 +517,14 @@ class DateRangePicker {
|
|
|
518
517
|
* @type {external:DateTime}
|
|
519
518
|
*/
|
|
520
519
|
get startDate() {
|
|
521
|
-
return this.#startDate;
|
|
520
|
+
return this.timePicker ? this.#startDate : this.#startDate.startOf("day");
|
|
522
521
|
}
|
|
523
522
|
/**
|
|
524
523
|
* endDate
|
|
525
524
|
* @type {external:DateTime}
|
|
526
525
|
*/
|
|
527
526
|
get endDate() {
|
|
528
|
-
return this.singleDatePicker ? null : this.#endDate;
|
|
527
|
+
return this.singleDatePicker ? null : this.timePicker ? this.#endDate : this.#endDate.endOf("day");
|
|
529
528
|
}
|
|
530
529
|
set startDate(val) {
|
|
531
530
|
this.#startDate = val;
|
|
@@ -561,6 +560,10 @@ class DateRangePicker {
|
|
|
561
560
|
}
|
|
562
561
|
this.#startDate = newDate;
|
|
563
562
|
this.#endDate = this.#startDate;
|
|
563
|
+
if (!this.timePicker) {
|
|
564
|
+
this.#startDate = this.#startDate.startOf("day");
|
|
565
|
+
this.#endDate = this.#endDate.endOf("day");
|
|
566
|
+
}
|
|
564
567
|
this.updateElement();
|
|
565
568
|
if (updateView)
|
|
566
569
|
this.updateView();
|
|
@@ -599,7 +602,7 @@ class DateRangePicker {
|
|
|
599
602
|
this.#endDate = this.#startDate;
|
|
600
603
|
const oldDate = [this.#startDate, this.#endDate];
|
|
601
604
|
let newDate = [this.parseDate(startDate), this.parseDate(endDate)];
|
|
602
|
-
if (oldDate[0].equals(newDate[0]) && oldDate[1].equals(newDate[1]) || newDate[
|
|
605
|
+
if (oldDate[0].equals(newDate[0]) && oldDate[1].equals(newDate[1]) || newDate[0] > newDate[1])
|
|
603
606
|
return;
|
|
604
607
|
const violations = this.validateInput([newDate[0], newDate[1]], true);
|
|
605
608
|
if (violations != null) {
|
|
@@ -612,6 +615,10 @@ class DateRangePicker {
|
|
|
612
615
|
}
|
|
613
616
|
this.#startDate = newDate[0];
|
|
614
617
|
this.#endDate = newDate[1];
|
|
618
|
+
if (!this.timePicker) {
|
|
619
|
+
this.#startDate = this.#startDate.startOf("day");
|
|
620
|
+
this.#endDate = this.#endDate.endOf("day");
|
|
621
|
+
}
|
|
615
622
|
this.updateElement();
|
|
616
623
|
if (updateView)
|
|
617
624
|
this.updateView();
|
|
@@ -788,12 +795,12 @@ class DateRangePicker {
|
|
|
788
795
|
if (this.timePicker) {
|
|
789
796
|
const secs = this.timePickerStepSize.as("seconds");
|
|
790
797
|
startDate = DateTime.fromSeconds(secs * Math.round(startDate.toSeconds() / secs));
|
|
798
|
+
violation.new = startDate;
|
|
799
|
+
if (!violation.new.equals(violation.old))
|
|
800
|
+
result.startDate.violations.push(violation);
|
|
791
801
|
} else {
|
|
792
802
|
startDate = startDate.startOf("day");
|
|
793
803
|
}
|
|
794
|
-
violation.new = startDate;
|
|
795
|
-
if (!violation.new.equals(violation.old))
|
|
796
|
-
result.startDate.violations.push(violation);
|
|
797
804
|
const shiftStep = this.timePicker ? this.timePickerStepSize.as("seconds") : Duration.fromObject({ days: 1 }).as("seconds");
|
|
798
805
|
if (this.minDate && startDate < this.minDate) {
|
|
799
806
|
violation = { old: startDate, reason: "minDate" };
|
|
@@ -851,12 +858,12 @@ class DateRangePicker {
|
|
|
851
858
|
if (this.timePicker) {
|
|
852
859
|
const secs = this.timePickerStepSize.as("seconds");
|
|
853
860
|
endDate = DateTime.fromSeconds(secs * Math.round(endDate.toSeconds() / secs));
|
|
861
|
+
violation.new = endDate;
|
|
862
|
+
if (!violation.new.equals(violation.old))
|
|
863
|
+
result.endDate.violations.push(violation);
|
|
854
864
|
} else {
|
|
855
865
|
endDate = endDate.endOf("day");
|
|
856
866
|
}
|
|
857
|
-
violation.new = endDate;
|
|
858
|
-
if (!violation.new.equals(violation.old))
|
|
859
|
-
result.endDate.violations.push(violation);
|
|
860
867
|
if (this.maxDate && endDate > this.maxDate) {
|
|
861
868
|
violation = { old: endDate, reason: "maxDate" };
|
|
862
869
|
endDate = endDate.minus({ seconds: Math.trunc(endDate.diff(this.maxDate).as("seconds") / shiftStep) * shiftStep });
|
|
@@ -1483,7 +1490,7 @@ class DateRangePicker {
|
|
|
1483
1490
|
this.#startDate = this.oldStartDate;
|
|
1484
1491
|
this.#endDate = this.oldEndDate;
|
|
1485
1492
|
}
|
|
1486
|
-
if (this.#startDate
|
|
1493
|
+
if (!this.#startDate.equals(this.oldStartDate) || !this.#endDate.equals(this.oldEndDate))
|
|
1487
1494
|
this.callback(this.startDate, this.endDate, this.chosenLabel);
|
|
1488
1495
|
this.updateElement();
|
|
1489
1496
|
if (this.element.triggerHandler("beforeHide.daterangepicker", this))
|
|
@@ -1937,15 +1944,19 @@ class DateRangePicker {
|
|
|
1937
1944
|
if (violations.newDate != null) {
|
|
1938
1945
|
newDate = violations.newDate.startDate;
|
|
1939
1946
|
} else {
|
|
1940
|
-
return
|
|
1947
|
+
return;
|
|
1941
1948
|
}
|
|
1942
1949
|
}
|
|
1943
1950
|
this.#startDate = newDate;
|
|
1944
1951
|
this.#endDate = this.#startDate;
|
|
1952
|
+
if (!this.timePicker) {
|
|
1953
|
+
this.#startDate = this.#startDate.startOf("day");
|
|
1954
|
+
this.#endDate = this.#endDate.endOf("day");
|
|
1955
|
+
}
|
|
1945
1956
|
} else if (!this.singleDatePicker && dateString.length === 2) {
|
|
1946
|
-
const newDate = [
|
|
1957
|
+
const newDate = [0, 1].map((i) => DateTime.fromFormat(dateString[i], format, { locale: DateTime.now().locale }));
|
|
1947
1958
|
const oldDate = [this.#startDate, this.#endDate];
|
|
1948
|
-
if (!newDate[0].isValid || !newDate[1].isValid || (oldDate[0].equals(newDate[0]) && oldDate[1].equals(newDate[1]) || newDate[
|
|
1959
|
+
if (!newDate[0].isValid || !newDate[1].isValid || (oldDate[0].equals(newDate[0]) && oldDate[1].equals(newDate[1]) || newDate[0] > newDate[1]))
|
|
1949
1960
|
return;
|
|
1950
1961
|
const violations = this.validateInput([newDate[0], newDate[1]], true);
|
|
1951
1962
|
if (violations != null) {
|
|
@@ -1958,6 +1969,10 @@ class DateRangePicker {
|
|
|
1958
1969
|
}
|
|
1959
1970
|
this.#startDate = newDate[0];
|
|
1960
1971
|
this.#endDate = newDate[1];
|
|
1972
|
+
if (!this.timePicker) {
|
|
1973
|
+
this.#startDate = this.#startDate.startOf("day");
|
|
1974
|
+
this.#endDate = this.#endDate.endOf("day");
|
|
1975
|
+
}
|
|
1961
1976
|
} else {
|
|
1962
1977
|
return;
|
|
1963
1978
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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
|
-
`,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};
|
|
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.timePicker?this.#t:this.#t.startOf("day")}get endDate(){return this.singleDatePicker?null:this.timePicker?this.#e:this.#e.endOf("day")}set startDate(s){this.#t=s}set endDate(s){this.#e=s}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.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),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[0]>r[1])return;const i=this.validateInput([r[0],r[1]],!0);if(i!=null)if(i.newDate!=null)r[0]=i.newDate.startDate,r[1]=i.newDate.endDate;else return i;return this.#t=r[0],this.#e=r[1],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day")),this.updateElement(),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)),i.new=a,i.new.equals(i.old)||r.startDate.violations.push(i)}else a=a.startOf("day");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)),i.new=n,i.new.equals(i.old)||r.endDate.violations.push(i)}else n=n.endOf("day");if(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.equals(this.oldStartDate)||!this.#e.equals(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;this.#t=a,this.#e=this.#t,this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}else if(!this.singleDatePicker&&t.length===2){const a=[0,1].map(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[0]>a[1])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],this.timePicker||(this.#t=this.#t.startOf("day"),this.#e=this.#e.endOf("day"))}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};
|