daterangepicker-4.x 4.4.3 → 4.4.4
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 +3 -3
- package/daterangepicker.js +47 -43
- 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.4.
|
|
22
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.4.
|
|
21
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.4.4/daterangepicker.min.js"></script>
|
|
22
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.4.4/daterangepicker.min.css" rel="stylesheet" />
|
|
23
23
|
|
|
24
24
|
<input type="text" id="daterange" />
|
|
25
25
|
|
|
@@ -565,7 +565,7 @@ Options for DateRangePicker
|
|
|
565
565
|
| 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` |
|
|
566
566
|
| timePicker | <code>boolean</code> | <code>false</code> | Adds select boxes to choose times in addition to dates |
|
|
567
567
|
| timePicker24Hour | <code>boolean</code> | <code>true</code> | Use 24-hour instead of 12-hour times, removing the AM/PM selection |
|
|
568
|
-
| 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](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` |
|
|
568
|
+
| 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](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` |
|
|
569
569
|
| timePickerSeconds | <code>boolean</code> | <code>boolean</code> | **Deprecated**, use `timePickerStepSize`<br/>Show seconds in the timePicker |
|
|
570
570
|
| timePickerIncrement | <code>boolean</code> | <code>1</code> | **Deprecated**, use `timePickerStepSize`<br/>Increment of the minutes selection list for times |
|
|
571
571
|
| 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`. |
|
package/daterangepicker.js
CHANGED
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
* and 1,2,3,4,6,(8,12) for `Duration.fromObject({hours: ...})`.<br/>
|
|
85
85
|
* Duration must be greater than `minSpan` and smaller than `maxSpan`.<br/>
|
|
86
86
|
* For example `timePickerStepSize: 600` will disable time picker seconds and time picker minutes are set to step size of 10 Minutes.<br/>
|
|
87
|
-
* Overwrites `timePickerIncrement` and `timePickerSeconds`
|
|
87
|
+
* Overwrites `timePickerIncrement` and `timePickerSeconds`, ignored when `timePicker: false`
|
|
88
88
|
* @property {boolean} timePickerSeconds=boolean - **Deprecated**, use `timePickerStepSize`<br/>Show seconds in the timePicker
|
|
89
89
|
* @property {boolean} timePickerIncrement=1 - **Deprecated**, use `timePickerStepSize`<br/>Increment of the minutes selection list for times
|
|
90
90
|
|
|
@@ -379,46 +379,48 @@
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
382
|
+
if (this.timePicker) {
|
|
383
|
+
if (typeof options.timePickerSeconds === 'boolean') // backward compatibility
|
|
384
|
+
this.timePickerStepSize = Duration.fromObject({ [options.timePickerSeconds ? 'seconds' : 'minutes']: 1 });
|
|
385
|
+
if (typeof options.timePickerIncrement === 'number') // backward compatibility
|
|
386
|
+
this.timePickerStepSize = Duration.fromObject({ minutes: options.timePickerIncrement });
|
|
387
|
+
|
|
388
|
+
if (['string', 'object', 'number'].includes(typeof options.timePickerStepSize)) {
|
|
389
|
+
let duration;
|
|
390
|
+
if (options.timePickerStepSize instanceof Duration && options.timePickerStepSize.isValid) {
|
|
391
|
+
duration = options.timePickerStepSize;
|
|
392
|
+
} else if (Duration.fromISO(options.timePickerStepSize).isValid) {
|
|
393
|
+
duration = Duration.fromISO(options.timePickerStepSize);
|
|
394
|
+
} else if (typeof options.timePickerStepSize === 'number' && Duration.fromObject({ seconds: options.timePickerStepSize }).isValid) {
|
|
395
|
+
duration = Duration.fromObject({ seconds: options.timePickerStepSize });
|
|
396
|
+
} else {
|
|
397
|
+
console.error(`Option 'timePickerStepSize' is not valid`);
|
|
398
|
+
duration = this.timePickerStepSize;
|
|
399
|
+
};
|
|
400
|
+
var valid = [];
|
|
401
|
+
for (let unit of ['minutes', 'seconds'])
|
|
402
|
+
valid.push(...[1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30].map(x => { return Duration.fromObject({ [unit]: x }) }));
|
|
403
|
+
valid.push(...[1, 2, 3, 4, 6].map(x => { return Duration.fromObject({ hours: x }) }));
|
|
404
|
+
if (this.timePicker24Hour)
|
|
405
|
+
valid.push(...[8, 12].map(x => { return Duration.fromObject({ hours: x }) }));
|
|
406
|
+
|
|
407
|
+
if (valid.some(x => duration.rescale().equals(x))) {
|
|
408
|
+
this.timePickerStepSize = duration.rescale();
|
|
409
|
+
} else {
|
|
410
|
+
console.error(`Option 'timePickerStepSize' ${JSON.stringify(duration.toObject())} is not valid`);
|
|
411
|
+
}
|
|
410
412
|
}
|
|
413
|
+
if (this.maxSpan && this.timePickerStepSize > this.maxSpan)
|
|
414
|
+
console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`);
|
|
415
|
+
|
|
416
|
+
this.timePickerOpts = {
|
|
417
|
+
showMinutes: this.timePickerStepSize < Duration.fromObject({ hours: 1 }),
|
|
418
|
+
showSeconds: this.timePickerStepSize < Duration.fromObject({ minutes: 1 }),
|
|
419
|
+
hourStep: this.timePickerStepSize >= Duration.fromObject({ hours: 1 }) ? this.timePickerStepSize.hours : 1,
|
|
420
|
+
minuteStep: this.timePickerStepSize >= Duration.fromObject({ minutes: 1 }) ? this.timePickerStepSize.minutes : 1,
|
|
421
|
+
secondStep: this.timePickerStepSize.seconds
|
|
422
|
+
};
|
|
411
423
|
}
|
|
412
|
-
if (this.timePicker && this.maxSpan && this.timePickerStepSize > this.maxSpan)
|
|
413
|
-
console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`);
|
|
414
|
-
|
|
415
|
-
this.timePickerOpts = {
|
|
416
|
-
showMinutes: this.timePickerStepSize < Duration.fromObject({ hours: 1 }),
|
|
417
|
-
showSeconds: this.timePickerStepSize < Duration.fromObject({ minutes: 1 }),
|
|
418
|
-
hourStep: this.timePickerStepSize >= Duration.fromObject({ hours: 1 }) ? this.timePickerStepSize.hours : 1,
|
|
419
|
-
minuteStep: this.timePickerStepSize >= Duration.fromObject({ minutes: 1 }) ? this.timePickerStepSize.minutes : 1,
|
|
420
|
-
secondStep: this.timePickerStepSize.seconds
|
|
421
|
-
};
|
|
422
424
|
|
|
423
425
|
for (let opt of ['startDate', 'endDate', 'minDate', 'maxDate', 'initalMonth']) {
|
|
424
426
|
if (opt == 'endDate' && this.singleDatePicker)
|
|
@@ -2158,10 +2160,12 @@
|
|
|
2158
2160
|
var i = 0;
|
|
2159
2161
|
for (var range in this.ranges) {
|
|
2160
2162
|
var unit = this.timePicker ? 'hour' : 'day';
|
|
2161
|
-
if (this.
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2163
|
+
if (this.timePicker) {
|
|
2164
|
+
if (this.timePickerOpts.showMinutes) {
|
|
2165
|
+
unit = 'minute';
|
|
2166
|
+
} else if (this.timePickerOpts.showSeconds) {
|
|
2167
|
+
unit = 'second';
|
|
2168
|
+
}
|
|
2165
2169
|
}
|
|
2166
2170
|
if (this.startDate.startOf(unit) == this.ranges[range][0].startOf(unit) == this.endDate.startOf(unit) == this.ranges[range][1].startOf(unit)) {
|
|
2167
2171
|
customRange = false;
|