daterangepicker-4.x 4.10.0 → 4.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/daterangepicker.js +16 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
18
18
|
```html
|
|
19
19
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
20
20
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
21
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.
|
|
22
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.
|
|
21
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.11.2/daterangepicker.min.js"></script>
|
|
22
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.11.2/daterangepicker.min.css" rel="stylesheet" />
|
|
23
23
|
|
|
24
24
|
<input type="text" id="daterange" />
|
|
25
25
|
|
|
@@ -96,6 +96,7 @@ Compared to [inital repository](https://github.com/dangrossman/daterangepicker),
|
|
|
96
96
|
- Added events `dateChange.daterangepicker` and `timeChange.daterangepicker` emitted when user clicks on a date/time
|
|
97
97
|
- Added event `beforeHide.daterangepicker` enables you to keep the picker visible after click on `Apply` or `Cancel` button.
|
|
98
98
|
- Added event `beforeRenderTimePicker.daterangepicker` and `beforeRenderCalendar.daterangepicker` emitted before elements are rendered
|
|
99
|
+
- Added event `violated.daterangepicker` emitted when user input is not valid
|
|
99
100
|
- Added method `setRange(startDate, endDate)` to combine `setStartDate(startDate)` and `setEndDate(endDate)`
|
|
100
101
|
- Added option `minSpan` similar to `maxSpan`
|
|
101
102
|
- Added option `isInvalidTime` similar to `isInvalidDate`
|
|
@@ -616,8 +617,9 @@ Options for DateRangePicker
|
|
|
616
617
|
| 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/> |
|
|
617
618
|
| 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`. |
|
|
618
619
|
| 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`. |
|
|
619
|
-
| minSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | | The
|
|
620
|
-
| maxSpan | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> \| <code>number</code> \| <code>null</code> | | The
|
|
620
|
+
| 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` |
|
|
621
|
+
| 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` |
|
|
622
|
+
| 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` |
|
|
621
623
|
| 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` |
|
|
622
624
|
| 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` |
|
|
623
625
|
| 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/> The start and end dates provided to your callback will be the same single date chosen. |
|
package/daterangepicker.js
CHANGED
|
@@ -55,12 +55,15 @@
|
|
|
55
55
|
* Must be a `luxon.DateTime` or `Date` or `string` according to {@link https://en.wikipedia.org/wiki/ISO_8601|ISO-8601} or a string matching `locale.format`.
|
|
56
56
|
* @property {external:DateTime|external:Date|string|null} maxDate - The latest date a user may select or `null` for no limit.<br/>
|
|
57
57
|
* Must be a `luxon.DateTime` or `Date` or `string` according to {@link https://en.wikipedia.org/wiki/ISO_8601|ISO-8601} or a string matching `locale.format`.
|
|
58
|
-
* @property {external:Duration|string|number|null} minSpan - The
|
|
58
|
+
* @property {external:Duration|string|number|null} minSpan - The minimum span between the selected start and end dates.<br/>
|
|
59
59
|
* Must be a `luxon.Duration` or number of seconds or a string according to {@link https://en.wikipedia.org/wiki/ISO_8601|ISO-8601} duration.<br/>
|
|
60
60
|
* Ignored when `singleDatePicker: true`
|
|
61
|
-
* @property {external:Duration|string|number|null} maxSpan - The
|
|
61
|
+
* @property {external:Duration|string|number|null} maxSpan - The maximum span between the selected start and end dates.<br/>
|
|
62
62
|
* Must be a `luxon.Duration` or number of seconds or a string according to {@link https://en.wikipedia.org/wiki/ISO_8601|ISO-8601} duration.<br/>
|
|
63
63
|
* Ignored when `singleDatePicker: true`
|
|
64
|
+
* @property {external:Duration|string|number|null} defaultSpan - The span which is used when endDate is automatically updated due to wrong user input<br/>
|
|
65
|
+
* Must be a `luxon.Duration` or number of seconds or a string according to {@link https://en.wikipedia.org/wiki/ISO_8601|ISO-8601} duration.<br/>
|
|
66
|
+
* Ignored when `singleDatePicker: true`. Not relevant if `minSpan: null`
|
|
64
67
|
* @property {external:DateTime|external:Date|string|null} initalMonth - Default: `DateTime.now().startOf('month')`<br/>
|
|
65
68
|
* The inital month shown when `startDate: null`. Be aware, the attached `<input>` element must be also empty.<br/>
|
|
66
69
|
* Must be a `luxon.DateTime` or `Date` or `string` according to {@link https://en.wikipedia.org/wiki/ISO_8601|ISO-8601} or a string matching `locale.format`.<br/>
|
|
@@ -204,6 +207,7 @@
|
|
|
204
207
|
this.maxDate = null;
|
|
205
208
|
this.maxSpan = null;
|
|
206
209
|
this.minSpan = null;
|
|
210
|
+
this.defaultSpan = null;
|
|
207
211
|
this.initalMonth = DateTime.now().startOf('month');
|
|
208
212
|
this.autoApply = false;
|
|
209
213
|
this.singleDatePicker = false;
|
|
@@ -386,7 +390,7 @@
|
|
|
386
390
|
}
|
|
387
391
|
|
|
388
392
|
if (!this.singleDatePicker) {
|
|
389
|
-
for (let opt of ['minSpan', 'maxSpan']) {
|
|
393
|
+
for (let opt of ['minSpan', 'maxSpan', 'defaultSpan']) {
|
|
390
394
|
if (['string', 'number', 'object'].includes(typeof options[opt])) {
|
|
391
395
|
if (options[opt] instanceof Duration && options[opt].isValid) {
|
|
392
396
|
this[opt] = options[opt];
|
|
@@ -406,6 +410,13 @@
|
|
|
406
410
|
this.maxSpan = null;
|
|
407
411
|
console.warn(`Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'`);
|
|
408
412
|
}
|
|
413
|
+
if (this.defaultSpan && this.minSpan && this.minSpan > this.defaultSpan) {
|
|
414
|
+
this.defaultSpan = null;
|
|
415
|
+
console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'`);
|
|
416
|
+
} else if (this.defaultSpan && this.maxSpan && this.maxSpan < this.defaultSpan) {
|
|
417
|
+
this.defaultSpan = null;
|
|
418
|
+
console.warn(`Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'`);
|
|
419
|
+
}
|
|
409
420
|
}
|
|
410
421
|
|
|
411
422
|
if (this.timePicker) {
|
|
@@ -1025,7 +1036,7 @@
|
|
|
1025
1036
|
|
|
1026
1037
|
if (this.minSpan) {
|
|
1027
1038
|
// If the endDate falls below those allowed by the minSpan option, expand the range to the allowable period.
|
|
1028
|
-
const minDate = startDate.plus(this.minSpan);
|
|
1039
|
+
const minDate = startDate.plus(this.defaultSpan ?? this.minSpan);
|
|
1029
1040
|
if (endDate < minDate) {
|
|
1030
1041
|
violation = { old: endDate, reason: 'minSpan' };
|
|
1031
1042
|
while (endDate < minDate)
|
|
@@ -1448,7 +1459,7 @@
|
|
|
1448
1459
|
maxDate = this.startDate.plus(this.maxSpan);
|
|
1449
1460
|
|
|
1450
1461
|
if (this.minSpan && side === 'end')
|
|
1451
|
-
minLimit = this.startDate.plus(this.minSpan);
|
|
1462
|
+
minLimit = this.startDate.plus(this.defaultSpan ?? this.minSpan);
|
|
1452
1463
|
|
|
1453
1464
|
if (side === 'start') {
|
|
1454
1465
|
selected = this.startDate;
|