@wernfried/daterangepicker 5.5.2 → 5.6.1
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 +1 -1
- package/README.md +9 -9
- package/dist/cjs/daterangepicker.cjs +13 -8
- 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 +13 -8
- 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 +13 -8
- package/dist/global/daterangepicker.js.map +1 -1
- package/dist/global/daterangepicker.min.js +1 -1
- package/dist/global/daterangepicker.min.js.map +1 -1
- package/package.json +1 -1
package/API_Doc.md
CHANGED
|
@@ -694,7 +694,7 @@ Options for DateRangePicker
|
|
|
694
694
|
| 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). |
|
|
695
695
|
| 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. |
|
|
696
696
|
| 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`. |
|
|
697
|
-
| onOutsideClick | <code>string</code> | <code>"apply"</code> | Defines what picker shall do when user clicks outside the calendar. `
|
|
697
|
+
| onOutsideClick | <code>string</code> | <code>"apply"</code> | Defines what picker shall do when user clicks outside the calendar. `cancel`, `apply` or `hide`. Event [onOutsideClick](#event_outsideClick) is always emitted;<br> `cancel` reverts to previous date values. Note, `apply` is only useful with `autoApply: false`, otherwise date values will apply multiple times<br> If you like to do nothing, call `event.preventDefault()` in the event listener. |
|
|
698
698
|
| 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 |
|
|
699
699
|
| 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> |
|
|
700
700
|
| 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> |
|
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@5.
|
|
23
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.
|
|
22
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/dist/global/daterangepicker.min.js"></script>
|
|
23
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/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@5.
|
|
43
|
+
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/+esm"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
</script>
|
|
47
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.
|
|
47
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/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@5.
|
|
66
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/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@5.
|
|
68
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/css/daterangepicker.bulma.min.css" rel="stylesheet" />
|
|
69
69
|
|
|
70
70
|
<input type="text" id="picker" />
|
|
71
71
|
|
|
@@ -122,8 +122,8 @@ Initialisation with jQuery is supported in version 5.x
|
|
|
122
122
|
```html
|
|
123
123
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
124
124
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
125
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.
|
|
126
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.
|
|
125
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/dist/global/daterangepicker.min.js"></script>
|
|
126
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@5.6.1/css/daterangepicker.min.css" rel="stylesheet" />
|
|
127
127
|
|
|
128
128
|
<input type="text" id="picker" />
|
|
129
129
|
|
|
@@ -372,7 +372,7 @@ Options for DateRangePicker
|
|
|
372
372
|
| 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). |
|
|
373
373
|
| 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. |
|
|
374
374
|
| 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`. |
|
|
375
|
-
| onOutsideClick | <code>string</code> | <code>"apply"</code> | Defines what picker shall do when user clicks outside the calendar. `
|
|
375
|
+
| onOutsideClick | <code>string</code> | <code>"apply"</code> | Defines what picker shall do when user clicks outside the calendar. `cancel`, `apply` or `hide`. Event [onOutsideClick](#event_outsideClick) is always emitted;<br> `cancel` reverts to previous date values. Note, `apply` is only useful with `autoApply: false`, otherwise date values will apply multiple times<br> If you like to do nothing, call `event.preventDefault()` in the event listener. |
|
|
376
376
|
| 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 |
|
|
377
377
|
| 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> |
|
|
378
378
|
| 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> |
|
|
@@ -454,10 +454,10 @@ class DateRangePicker {
|
|
|
454
454
|
this.buttonClasses = options.buttonClasses;
|
|
455
455
|
}
|
|
456
456
|
if (typeof options.onOutsideClick === "string") {
|
|
457
|
-
if (["cancel", "apply"].includes(options.onOutsideClick))
|
|
457
|
+
if (["cancel", "apply", "hide"].includes(options.onOutsideClick))
|
|
458
458
|
this.onOutsideClick = options.onOutsideClick;
|
|
459
459
|
else
|
|
460
|
-
console.error(`Option 'onOutsideClick' must be 'cancel' or '
|
|
460
|
+
console.error(`Option 'onOutsideClick' must be 'cancel', 'apply' or 'hide'`);
|
|
461
461
|
}
|
|
462
462
|
if (this.locale.firstDay != 1) {
|
|
463
463
|
let iterator = this.locale.firstDay;
|
|
@@ -1698,14 +1698,10 @@ class DateRangePicker {
|
|
|
1698
1698
|
*/
|
|
1699
1699
|
hide() {
|
|
1700
1700
|
if (!this.isShowing) return;
|
|
1701
|
-
if (!this.#endDate) {
|
|
1701
|
+
if (!this.#endDate && !this.singleDatePicker) {
|
|
1702
1702
|
this.#startDate = this.oldStartDate;
|
|
1703
1703
|
this.#endDate = this.oldEndDate;
|
|
1704
1704
|
}
|
|
1705
|
-
if (typeof this.callback === "function") {
|
|
1706
|
-
if (this.#startDate && !this.#startDate.equals(this.oldStartDate ?? luxon.DateTime) || this.#endDate && !this.singleDatePicker && !this.#endDate.equals(this.oldEndDate ?? luxon.DateTime))
|
|
1707
|
-
this.callback(this.startDate, this.endDate, this.chosenLabel);
|
|
1708
|
-
}
|
|
1709
1705
|
this.updateElement();
|
|
1710
1706
|
const event = this.triggerEvent(this.#events.onBeforeHide);
|
|
1711
1707
|
if (event.defaultPrevented)
|
|
@@ -1777,8 +1773,12 @@ class DateRangePicker {
|
|
|
1777
1773
|
if (this.onOutsideClick === "cancel") {
|
|
1778
1774
|
this.#startDate = this.oldStartDate;
|
|
1779
1775
|
this.#endDate = this.oldEndDate;
|
|
1776
|
+
this.hide();
|
|
1777
|
+
} else if (this.onOutsideClick === "apply") {
|
|
1778
|
+
this.clickApply();
|
|
1779
|
+
} else {
|
|
1780
|
+
this.hide();
|
|
1780
1781
|
}
|
|
1781
|
-
this.hide();
|
|
1782
1782
|
}
|
|
1783
1783
|
/**
|
|
1784
1784
|
* Move calendar to previous month
|
|
@@ -2141,6 +2141,11 @@ class DateRangePicker {
|
|
|
2141
2141
|
* @private
|
|
2142
2142
|
*/
|
|
2143
2143
|
clickApply() {
|
|
2144
|
+
this.updateElement();
|
|
2145
|
+
if (typeof this.callback === "function") {
|
|
2146
|
+
if (this.#startDate && (this.#endDate || !this.singleDatePicker))
|
|
2147
|
+
this.callback(this.startDate, this.endDate, this.chosenLabel);
|
|
2148
|
+
}
|
|
2144
2149
|
this.hide();
|
|
2145
2150
|
this.triggerEvent(this.#events.onApply);
|
|
2146
2151
|
}
|