@wernfried/daterangepicker 5.2.17 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API_Doc.md +13 -11
- package/README.md +71 -69
- package/dist/cjs/daterangepicker.cjs +37 -16
- package/dist/cjs/daterangepicker.cjs.map +1 -1
- package/dist/cjs/daterangepicker.min.cjs +1 -1
- package/dist/cjs/daterangepicker.min.cjs.map +1 -1
- package/dist/esm/daterangepicker.js +37 -16
- package/dist/esm/daterangepicker.js.map +1 -1
- package/dist/esm/daterangepicker.min.js +1 -1
- package/dist/esm/daterangepicker.min.js.map +1 -1
- package/dist/global/daterangepicker.js +37 -16
- package/dist/global/daterangepicker.js.map +1 -1
- package/dist/global/daterangepicker.min.js +1 -1
- package/dist/global/daterangepicker.min.js.map +1 -1
- package/package.json +3 -3
package/API_Doc.md
CHANGED
|
@@ -125,7 +125,7 @@ Ranges are not validated against <code>minDate</code>, <code>maxDate</code>, <co
|
|
|
125
125
|
|
|
126
126
|
| Param | Type | Description |
|
|
127
127
|
| --- | --- | --- |
|
|
128
|
-
| element | <code>string</code> \| [<code>HTMLElement</code>](https://developer.mozilla.org/de/docs/Web/API/HTMLElement) | A DOM HTMLElement or querySelector string of element where DateRangePicker is attached. Often a `<input>` element. |
|
|
128
|
+
| element | <code>string</code> \| [<code>HTMLElement</code>](https://developer.mozilla.org/de/docs/Web/API/HTMLElement) | A DOM HTMLElement or CSS querySelector string of element where DateRangePicker is attached. Often a `<input type="text">` element. Element `<input>` and `<button>` shows the DateRangePicker on click, other elements toggle the DateRangePicker. |
|
|
129
129
|
| options | [<code>Options</code>](#Options) | Object to configure the DateRangePicker |
|
|
130
130
|
| cb | <code>function</code> | Callback function executed when new date values applied |
|
|
131
131
|
|
|
@@ -634,14 +634,14 @@ Options for DateRangePicker
|
|
|
634
634
|
|
|
635
635
|
| Name | Type | Default | Description |
|
|
636
636
|
| --- | --- | --- | --- |
|
|
637
|
-
| parentEl | <code>string</code> \| [<code>HTMLElement</code>](https://developer.mozilla.org/de/docs/Web/API/HTMLElement) | <code>"body"</code> | [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors) or `HTMLElement` of the parent element that the
|
|
637
|
+
| parentEl | <code>string</code> \| [<code>HTMLElement</code>](https://developer.mozilla.org/de/docs/Web/API/HTMLElement) | <code>"body"</code> | [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors) or `HTMLElement` of the parent element that the DateRangePicker will be added to |
|
|
638
638
|
| 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 initial selected date. |
|
|
639
|
-
| 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> | |
|
|
640
|
-
| 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> |
|
|
641
|
-
| 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> |
|
|
642
|
-
| minSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> |
|
|
643
|
-
| maxSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> |
|
|
644
|
-
| defaultSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> |
|
|
639
|
+
| 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> | | Default: `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> |
|
|
640
|
+
| 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> | <code></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`. |
|
|
641
|
+
| 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> | <code></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`. |
|
|
642
|
+
| minSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | <code></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` |
|
|
643
|
+
| maxSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | <code></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` |
|
|
644
|
+
| defaultSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | <code></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` |
|
|
645
645
|
| initialMonth | [<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 to be shown. Only relevant for `startDate: null`. Be aware, the attached `<input>` element must also be 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> Works only with `timePicker: false` |
|
|
646
646
|
| 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` |
|
|
647
647
|
| 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`. |
|
|
@@ -651,10 +651,12 @@ Options for DateRangePicker
|
|
|
651
651
|
| maxYear | <code>number</code> | | Default: `DateTime.now().plus({year:100}).year`<br>The maximum year shown in the dropdowns when `showDropdowns: true` |
|
|
652
652
|
| showWeekNumbers | <code>boolean</code> | <code>false</code> | Show **localized** week numbers at the start of each week on the calendars |
|
|
653
653
|
| 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` |
|
|
654
|
+
| button | <code>string</code> \| <code>external:HTMLButtonElement</code> | <code>null</code> | A dedicated element to show the DateRangePicker on click.<br> Main reason of this option is to prevent hide/flicker of the picker on `outsideClick()` |
|
|
655
|
+
| showOnClick | <code>boolean</code> | <code>true</code> | Shows/toggle the DateRangePicker on click or focus at `element`.<br> You may want to set it to `false` only when option `button` is provided or when you use `show()` programmatically. |
|
|
654
656
|
| timePicker | <code>boolean</code> | <code>false</code> | Adds select boxes to choose times in addition to dates |
|
|
655
|
-
| timePicker24Hour | <code>boolean</code> |
|
|
657
|
+
| timePicker24Hour | <code>boolean</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). |
|
|
656
658
|
| 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. |
|
|
657
|
-
| autoUpdateInput | <code>boolean</code> | <code>true</code> | Indicates whether the
|
|
659
|
+
| autoUpdateInput | <code>boolean</code> | <code>true</code> | Indicates whether the DateRangePicker 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`. |
|
|
658
660
|
| onOutsideClick | <code>string</code> | <code>"apply"</code> | Defines what picker shall do when user clicks outside the calendar. `'apply'` or `'cancel'`. Event [onOutsideClick](#event_outsideClick) is always emitted. |
|
|
659
661
|
| 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 |
|
|
660
662
|
| 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> |
|
|
@@ -673,7 +675,7 @@ Options for DateRangePicker
|
|
|
673
675
|
| 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. |
|
|
674
676
|
| 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. |
|
|
675
677
|
| 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. |
|
|
676
|
-
| showLabel
|
|
678
|
+
| showLabel | <code>boolean</code> | | Shows selected range next to Apply buttons.<br> Defaults to `false` if anchor element is `<input type="text">`, otherwise `true` |
|
|
677
679
|
| 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. |
|
|
678
680
|
| locale.direction | <code>string</code> | <code>"ltr"</code> | Direction of reading, `'ltr'` or `'rtl'` |
|
|
679
681
|
| 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). |
|
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
19
19
|
#### Global import with `<script>` tags
|
|
20
20
|
```html
|
|
21
21
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
22
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
23
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
22
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/dist/global/daterangepicker.min.js"></script>
|
|
23
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/css/daterangepicker.min.css" rel="stylesheet" />
|
|
24
24
|
|
|
25
25
|
<input type="text" id="picker" />
|
|
26
26
|
|
|
@@ -40,11 +40,11 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
40
40
|
{
|
|
41
41
|
"imports": {
|
|
42
42
|
"luxon": "https://cdn.jsdelivr.net/npm/luxon@3.7.2/+esm",
|
|
43
|
-
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
43
|
+
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/+esm"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
</script>
|
|
47
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
47
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/css/daterangepicker.min.css" rel="stylesheet" />
|
|
48
48
|
|
|
49
49
|
<input type="text" id="picker" />
|
|
50
50
|
|
|
@@ -63,9 +63,9 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
63
63
|
#### Style with Bulma
|
|
64
64
|
```html
|
|
65
65
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
66
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
66
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/dist/global/daterangepicker.min.js"></script>
|
|
67
67
|
<link type="text/css" href="https://cdn.jsdelivr.net/npm/bulma@1.0.4/css/bulma.min.css" rel="stylesheet" />
|
|
68
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
68
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/css/daterangepicker.bulma.min.css" rel="stylesheet" />
|
|
69
69
|
|
|
70
70
|
<input type="text" id="picker" />
|
|
71
71
|
|
|
@@ -121,8 +121,8 @@ Initialisation with jQuery is supported in version 5.x
|
|
|
121
121
|
```html
|
|
122
122
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
123
123
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
124
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
125
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker
|
|
124
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/dist/global/daterangepicker.min.js"></script>
|
|
125
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@%npm_package_version%/css/daterangepicker.min.css" rel="stylesheet" />
|
|
126
126
|
|
|
127
127
|
<input type="text" id="picker" />
|
|
128
128
|
|
|
@@ -340,64 +340,66 @@ Licensed under the [MIT license](LICENSE).
|
|
|
340
340
|
[API Documentation](API_Doc.md)
|
|
341
341
|
|
|
342
342
|
|
|
343
|
-
## Options
|
|
344
|
-
Options for DateRangePicker
|
|
345
|
-
|
|
346
|
-
**Kind**: global typedef
|
|
347
|
-
**Properties**
|
|
348
|
-
|
|
349
|
-
| Name | Type | Default | Description |
|
|
350
|
-
| --- | --- | --- | --- |
|
|
351
|
-
| parentEl | <code>string</code> \| [<code>HTMLElement</code>](https://developer.mozilla.org/de/docs/Web/API/HTMLElement) | <code>"body"</code> | [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors) or `HTMLElement` of the parent element that the
|
|
352
|
-
| 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 initial selected date. |
|
|
353
|
-
| 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> | |
|
|
354
|
-
| 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> |
|
|
355
|
-
| 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> |
|
|
356
|
-
| minSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> |
|
|
357
|
-
| maxSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> |
|
|
358
|
-
| defaultSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> |
|
|
359
|
-
| initialMonth | [<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 to be shown. Only relevant for `startDate: null`. Be aware, the attached `<input>` element must also be 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> Works only with `timePicker: false` |
|
|
360
|
-
| 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` |
|
|
361
|
-
| 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`. |
|
|
362
|
-
| 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`. |
|
|
363
|
-
| showDropdowns | <code>boolean</code> | <code>false</code> | Show year and month select boxes above calendars to jump to a specific month and year |
|
|
364
|
-
| minYear | <code>number</code> | | Default: `DateTime.now().minus({year:100}).year`<br>The minimum year shown in the dropdowns when `showDropdowns: true` |
|
|
365
|
-
| maxYear | <code>number</code> | | Default: `DateTime.now().plus({year:100}).year`<br>The maximum year shown in the dropdowns when `showDropdowns: true` |
|
|
366
|
-
| showWeekNumbers | <code>boolean</code> | <code>false</code> | Show **localized** week numbers at the start of each week on the calendars |
|
|
367
|
-
| 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` |
|
|
368
|
-
|
|
|
369
|
-
|
|
|
370
|
-
|
|
|
371
|
-
|
|
|
372
|
-
|
|
|
373
|
-
|
|
|
374
|
-
|
|
|
375
|
-
|
|
|
376
|
-
|
|
|
377
|
-
|
|
|
378
|
-
|
|
|
379
|
-
|
|
|
380
|
-
|
|
|
381
|
-
|
|
|
382
|
-
|
|
|
383
|
-
|
|
|
384
|
-
|
|
|
385
|
-
|
|
|
386
|
-
|
|
|
387
|
-
|
|
|
388
|
-
|
|
|
389
|
-
|
|
|
390
|
-
|
|
|
391
|
-
|
|
|
392
|
-
|
|
|
393
|
-
| locale
|
|
394
|
-
| locale.
|
|
395
|
-
| locale.
|
|
396
|
-
| locale.
|
|
397
|
-
| locale.
|
|
398
|
-
| locale.
|
|
399
|
-
| locale.
|
|
400
|
-
| locale.
|
|
401
|
-
| locale.
|
|
402
|
-
| locale.
|
|
403
|
-
|
|
343
|
+
## Options
|
|
344
|
+
Options for DateRangePicker
|
|
345
|
+
|
|
346
|
+
**Kind**: global typedef
|
|
347
|
+
**Properties**
|
|
348
|
+
|
|
349
|
+
| Name | Type | Default | Description |
|
|
350
|
+
| --- | --- | --- | --- |
|
|
351
|
+
| parentEl | <code>string</code> \| [<code>HTMLElement</code>](https://developer.mozilla.org/de/docs/Web/API/HTMLElement) | <code>"body"</code> | [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors) or `HTMLElement` of the parent element that the DateRangePicker will be added to |
|
|
352
|
+
| 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 initial selected date. |
|
|
353
|
+
| 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> | | Default: `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> |
|
|
354
|
+
| 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> | <code></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`. |
|
|
355
|
+
| 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> | <code></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`. |
|
|
356
|
+
| minSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | <code></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` |
|
|
357
|
+
| maxSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | <code></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` |
|
|
358
|
+
| defaultSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | <code></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` |
|
|
359
|
+
| initialMonth | [<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 to be shown. Only relevant for `startDate: null`. Be aware, the attached `<input>` element must also be 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> Works only with `timePicker: false` |
|
|
360
|
+
| 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` |
|
|
361
|
+
| 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`. |
|
|
362
|
+
| 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`. |
|
|
363
|
+
| showDropdowns | <code>boolean</code> | <code>false</code> | Show year and month select boxes above calendars to jump to a specific month and year |
|
|
364
|
+
| minYear | <code>number</code> | | Default: `DateTime.now().minus({year:100}).year`<br>The minimum year shown in the dropdowns when `showDropdowns: true` |
|
|
365
|
+
| maxYear | <code>number</code> | | Default: `DateTime.now().plus({year:100}).year`<br>The maximum year shown in the dropdowns when `showDropdowns: true` |
|
|
366
|
+
| showWeekNumbers | <code>boolean</code> | <code>false</code> | Show **localized** week numbers at the start of each week on the calendars |
|
|
367
|
+
| 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` |
|
|
368
|
+
| button | <code>string</code> \| <code>external:HTMLButtonElement</code> | <code>null</code> | A dedicated element to show the DateRangePicker on click.<br> Main reason of this option is to prevent hide/flicker of the picker on `outsideClick()` |
|
|
369
|
+
| showOnClick | <code>boolean</code> | <code>true</code> | Shows/toggle the DateRangePicker on click or focus at `element`.<br> You may want to set it to `false` only when option `button` is provided or when you use `show()` programmatically. |
|
|
370
|
+
| timePicker | <code>boolean</code> | <code>false</code> | Adds select boxes to choose times in addition to dates |
|
|
371
|
+
| timePicker24Hour | <code>boolean</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). |
|
|
372
|
+
| 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. |
|
|
373
|
+
| autoUpdateInput | <code>boolean</code> | <code>true</code> | Indicates whether the DateRangePicker 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`. |
|
|
374
|
+
| onOutsideClick | <code>string</code> | <code>"apply"</code> | Defines what picker shall do when user clicks outside the calendar. `'apply'` or `'cancel'`. Event [onOutsideClick](#event_outsideClick) is always emitted. |
|
|
375
|
+
| 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 |
|
|
376
|
+
| 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> |
|
|
377
|
+
| 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> |
|
|
378
|
+
| 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)` |
|
|
379
|
+
| altInput | <code>string</code> \| <code>Array</code> \| [<code>HTMLInputElement</code>](https://developer.mozilla.org/de/docs/Web/API/HTMLInputElement) | <code>null</code> | A [Document querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector#selectors)<br> string or `HTMLElement` for an alternative output (typically hidden) `<input>` element. Uses `altFormat` to format the value.<br> Must be a single string/HTMLElement for `singleDatePicker: true` or an array of two strings or HTMLElement for `singleDatePicker: false`<br> Example: `['#start', '#end']` |
|
|
380
|
+
| 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()` |
|
|
381
|
+
| applyButtonClasses | <code>string</code> | <code>"btn-primary"</code> | CSS class names that will be added only to the apply button |
|
|
382
|
+
| cancelButtonClasses | <code>string</code> | <code>"btn-default"</code> | CSS class names that will be added only to the cancel button |
|
|
383
|
+
| buttonClasses | <code>string</code> | | Default: `'btn btn-sm'`<br>CSS class names that will be added to both the apply and cancel buttons. |
|
|
384
|
+
| 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. |
|
|
385
|
+
| 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. |
|
|
386
|
+
| 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. |
|
|
387
|
+
| 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'` |
|
|
388
|
+
| 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'` |
|
|
389
|
+
| 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. |
|
|
390
|
+
| 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. |
|
|
391
|
+
| 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. |
|
|
392
|
+
| showLabel | <code>boolean</code> | | Shows selected range next to Apply buttons.<br> Defaults to `false` if anchor element is `<input type="text">`, otherwise `true` |
|
|
393
|
+
| 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. |
|
|
394
|
+
| locale.direction | <code>string</code> | <code>"ltr"</code> | Direction of reading, `'ltr'` or `'rtl'` |
|
|
395
|
+
| 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). |
|
|
396
|
+
| locale.separator | <code>string</code> | | Defaut: `' - '`<br>Separator for start and end time |
|
|
397
|
+
| locale.weekLabel | <code>string</code> | <code>"W"</code> | Label for week numbers |
|
|
398
|
+
| locale.daysOfWeek | <code>Array</code> | | Default: `luxon.Info.weekdays('short')`<br>Array with weekday names, from Monday to Sunday |
|
|
399
|
+
| locale.monthNames | <code>Array</code> | | Default: `luxon.Info.months('long')`<br>Array with month names |
|
|
400
|
+
| locale.firstDay | <code>number</code> | | Default: `luxon.Info.getStartOfWeek()`<br>First day of the week, 1 for Monday through 7 for Sunday |
|
|
401
|
+
| locale.applyLabel | <code>string</code> | <code>"Apply"</code> | Label of `Apply` Button |
|
|
402
|
+
| locale.cancelLabel | <code>string</code> | <code>"Cancel"</code> | Label of `Cancel` Button |
|
|
403
|
+
| locale.customRangeLabel | <code>string</code> | <code>"Custom"</code> | Range - Title for custom ranges |
|
|
404
|
+
| 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) => {}` |
|
|
405
|
+
|
|
@@ -9,6 +9,8 @@ class DateRangePicker {
|
|
|
9
9
|
this.parentEl = "body";
|
|
10
10
|
this.element = element instanceof HTMLElement ? element : document.querySelector(element);
|
|
11
11
|
this.isInputText = this.element instanceof HTMLInputElement && this.element.type === "text";
|
|
12
|
+
this.button = null;
|
|
13
|
+
this.showOnClick = true;
|
|
12
14
|
this.#startDate = luxon.DateTime.now().startOf("day");
|
|
13
15
|
this.#endDate = luxon.DateTime.now().plus({ day: 1 }).startOf("day");
|
|
14
16
|
this.minDate = null;
|
|
@@ -85,6 +87,16 @@ class DateRangePicker {
|
|
|
85
87
|
dataOptions[name] = ts.isValid && isDate ? ts : JSON.parse(item.value);
|
|
86
88
|
}
|
|
87
89
|
options = { ...dataOptions, ...options };
|
|
90
|
+
if (["string", "object"].includes(typeof options.button)) {
|
|
91
|
+
let button = options.button;
|
|
92
|
+
if (typeof button === "string" && document.querySelectorAll(button).length === 1)
|
|
93
|
+
button = document.querySelector(button);
|
|
94
|
+
if (button instanceof HTMLButtonElement) {
|
|
95
|
+
this.button = button;
|
|
96
|
+
} else {
|
|
97
|
+
console.error(`Option 'button' cannot resolved to a HTMLButtonElement`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
88
100
|
if (typeof options.singleDatePicker === "boolean")
|
|
89
101
|
this.singleDatePicker = options.singleDatePicker;
|
|
90
102
|
if (!this.singleDatePicker && typeof options.singleMonthView === "boolean") {
|
|
@@ -164,13 +176,13 @@ class DateRangePicker {
|
|
|
164
176
|
if (["rtl", "ltr"].includes(options.locale.direction))
|
|
165
177
|
this.locale.direction = options.locale.direction;
|
|
166
178
|
else
|
|
167
|
-
console.error(`Option '
|
|
179
|
+
console.error(`Option 'locale.direction' must be 'rtl' or 'ltr'`);
|
|
168
180
|
}
|
|
169
181
|
if (["string", "object"].includes(typeof options.locale.format))
|
|
170
182
|
this.locale.format = options.locale.format;
|
|
171
183
|
if (Array.isArray(options.locale.daysOfWeek)) {
|
|
172
184
|
if (options.locale.daysOfWeek.some((x) => typeof x !== "string"))
|
|
173
|
-
console.error(`Option '
|
|
185
|
+
console.error(`Option 'locale.daysOfWeek' must be an array of strings`);
|
|
174
186
|
else
|
|
175
187
|
this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
|
|
176
188
|
}
|
|
@@ -202,7 +214,8 @@ class DateRangePicker {
|
|
|
202
214
|
"alwaysShowCalendars",
|
|
203
215
|
"autoApply",
|
|
204
216
|
"autoUpdateInput",
|
|
205
|
-
"showLabel"
|
|
217
|
+
"showLabel",
|
|
218
|
+
"showOnClick"
|
|
206
219
|
]) {
|
|
207
220
|
if (typeof options[key2] === "boolean")
|
|
208
221
|
this[key2] = options[key2];
|
|
@@ -419,13 +432,13 @@ class DateRangePicker {
|
|
|
419
432
|
if (["left", "right", "center"].includes(options.opens))
|
|
420
433
|
this.opens = options.opens;
|
|
421
434
|
else
|
|
422
|
-
console.error(`Option '
|
|
435
|
+
console.error(`Option 'opens' must be 'left', 'right' or 'center'`);
|
|
423
436
|
}
|
|
424
437
|
if (typeof options.drops === "string") {
|
|
425
438
|
if (["up", "down", "auto"].includes(options.drops))
|
|
426
439
|
this.drops = options.drops;
|
|
427
440
|
else
|
|
428
|
-
console.error(`Option '
|
|
441
|
+
console.error(`Option 'drops' must be 'up', 'down' or 'auto'`);
|
|
429
442
|
}
|
|
430
443
|
if (Array.isArray(options.buttonClasses)) {
|
|
431
444
|
this.buttonClasses = options.buttonClasses.join(" ");
|
|
@@ -436,7 +449,7 @@ class DateRangePicker {
|
|
|
436
449
|
if (["cancel", "apply"].includes(options.onOutsideClick))
|
|
437
450
|
this.onOutsideClick = options.onOutsideClick;
|
|
438
451
|
else
|
|
439
|
-
console.error(`Option '
|
|
452
|
+
console.error(`Option 'onOutsideClick' must be 'cancel' or 'apply'`);
|
|
440
453
|
}
|
|
441
454
|
if (this.locale.firstDay != 1) {
|
|
442
455
|
let iterator = this.locale.firstDay;
|
|
@@ -526,15 +539,19 @@ class DateRangePicker {
|
|
|
526
539
|
this.addListener(".ranges", "mouseleave", "li", this.leaveRange.bind(this));
|
|
527
540
|
this.addListener(".drp-buttons", "click", "button.applyBtn", this.clickApply.bind(this));
|
|
528
541
|
this.addListener(".drp-buttons", "click", "button.cancelBtn", this.clickCancel.bind(this));
|
|
529
|
-
if (this.
|
|
530
|
-
this.element.
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
542
|
+
if (this.showOnClick) {
|
|
543
|
+
if (this.element.matches("input") || this.element.matches("button")) {
|
|
544
|
+
this.element.addEventListener("click", this.#showProxy);
|
|
545
|
+
this.element.addEventListener("focus", this.#showProxy);
|
|
546
|
+
this.element.addEventListener("keyup", this.#elementChangedProxy);
|
|
547
|
+
this.element.addEventListener("keydown", this.#keydownProxy);
|
|
548
|
+
} else {
|
|
549
|
+
this.element.addEventListener("click", this.#toggleProxy);
|
|
550
|
+
this.element.addEventListener("keydown", this.#toggleProxy);
|
|
551
|
+
}
|
|
537
552
|
}
|
|
553
|
+
if (this.button)
|
|
554
|
+
this.button.addEventListener("click", this.#showProxy);
|
|
538
555
|
this.updateElement();
|
|
539
556
|
}
|
|
540
557
|
/**
|
|
@@ -1732,7 +1749,9 @@ class DateRangePicker {
|
|
|
1732
1749
|
outsideClick(e) {
|
|
1733
1750
|
const target = e.target;
|
|
1734
1751
|
function closest2(el, selector) {
|
|
1735
|
-
|
|
1752
|
+
if (selector == null)
|
|
1753
|
+
return null;
|
|
1754
|
+
let parent = el;
|
|
1736
1755
|
while (parent) {
|
|
1737
1756
|
if (parent == selector)
|
|
1738
1757
|
return parent;
|
|
@@ -1742,7 +1761,7 @@ class DateRangePicker {
|
|
|
1742
1761
|
}
|
|
1743
1762
|
if (
|
|
1744
1763
|
// ie modal dialog fix
|
|
1745
|
-
e.type === "focusin" || closest2(target, this.element) || closest2(target, this.container) || target.closest(".calendar-table")
|
|
1764
|
+
e.type === "focusin" || closest2(target, this.element) || closest2(target, this.container) || closest2(target, this.button) || target.closest(".calendar-table")
|
|
1746
1765
|
) return;
|
|
1747
1766
|
const event = this.triggerEvent(this.#events.onOutsideClick);
|
|
1748
1767
|
if (event.defaultPrevented)
|
|
@@ -2053,6 +2072,8 @@ class DateRangePicker {
|
|
|
2053
2072
|
}
|
|
2054
2073
|
} else if (this.#endDate) {
|
|
2055
2074
|
this.#endDate = this.#endDate.set({ hour, minute, second });
|
|
2075
|
+
if (this.#endDate < this.#startDate)
|
|
2076
|
+
this.#endDate = this.#startDate.plus(this.minSpan ?? luxon.Duration.fromObject({}));
|
|
2056
2077
|
}
|
|
2057
2078
|
this.updateCalendars(false);
|
|
2058
2079
|
this.setApplyBtnState();
|