daterangepicker-4.x 4.2.0 → 4.2.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 +9 -9
- package/daterangepicker.js +18 -13
- 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.2.
|
|
22
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.2.
|
|
21
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.2.2/daterangepicker.min.js"></script>
|
|
22
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.2.2/daterangepicker.min.css" rel="stylesheet" />
|
|
23
23
|
|
|
24
24
|
<input type="text" id="daterange" />
|
|
25
25
|
|
|
@@ -478,14 +478,14 @@ Options for DateRangePicker
|
|
|
478
478
|
| showISOWeekNumbers | <code>boolean</code> | <code>false</code> | Show **ISO** week numbers at the start of each week on the calendars |
|
|
479
479
|
| timePicker | <code>boolean</code> | <code>false</code> | Adds select boxes to choose times in addition to dates |
|
|
480
480
|
| timePicker24Hour | <code>boolean</code> | <code>true</code> | Use 24-hour instead of 12-hour times, removing the AM/PM selection |
|
|
481
|
-
| timePickerStepSize | [<code>Duration</code>](https://moment.github.io/luxon/api-docs/index.html#duration) \| <code>string</code> | | Default: `Duration.fromObject({minutes:1})`<br/>Set the time picker step size.<br/> Must be a `luxon.Duration` or 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
|
|
481
|
+
| 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` |
|
|
482
482
|
| timePickerSeconds | <code>boolean</code> | <code>boolean</code> | **Deprecated**, use `timePickerStepSize`<br/>Show seconds in the timePicker |
|
|
483
483
|
| timePickerIncrement | <code>boolean</code> | <code>1</code> | **Deprecated**, use `timePickerStepSize`<br/>Increment of the minutes selection list for times |
|
|
484
484
|
| 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`. |
|
|
485
|
-
| onOutsideClick | <code>string</code> | <code>"
|
|
485
|
+
| 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. |
|
|
486
486
|
| 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 |
|
|
487
|
-
| 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)
|
|
488
|
-
| 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: `isInvalidDate(time, side, unit)`<br/> `side` is 'start' or 'end' or `null` for `singleDatePicker
|
|
487
|
+
| 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/> Function has no effect on date values set by `startDate`, `endDate`, `ranges`, [setStartDate](#DateRangePicker+setStartDate), [setEndDate](#DateRangePicker+setEndDate). |
|
|
488
|
+
| 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: `isInvalidDate(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/> Function has no effect on time values set by `startDate`, `endDate`, `ranges`, [setStartDate](#DateRangePicker+setStartDate), [setEndDate](#DateRangePicker+setEndDate).<br/> Ensure that your function returns `false` for at least one item. Otherwise the calender is not rendered.<br/> |
|
|
489
489
|
| 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)` |
|
|
490
490
|
| applyButtonClasses | <code>string</code> | <code>"btn-primary"</code> | CSS class names that will be added only to the apply button |
|
|
491
491
|
| cancelButtonClasses | <code>string</code> | <code>"btn-default"</code> | CSS class names that will be added only to the cancel button |
|
|
@@ -500,9 +500,9 @@ Options for DateRangePicker
|
|
|
500
500
|
| locale.format | <code>object</code> \| <code>string</code> | | Default: `DateTime.DATE_SHORT`<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). |
|
|
501
501
|
| locale.separator= | <code>string</code> | | Defaut: `' - '` - Separator for start and end time |
|
|
502
502
|
| locale.weekLabel | <code>string</code> | <code>"W"</code> | Label for week numbers |
|
|
503
|
-
| locale.daysOfWeek | <code>Array</code> | | Default: `
|
|
504
|
-
| locale.monthNames | <code>Array</code> | | Default: `Info.months('long')`<br/>Array with month names |
|
|
505
|
-
| locale.firstDay | <code>number</code> | | Default: `Info.getStartOfWeek()`<br/>First day of the week, 1 for Monday through 7 for Sunday |
|
|
503
|
+
| locale.daysOfWeek | <code>Array</code> | | Default: `luxon.weekdays('short')`<br/>Array with weekday names, from Monday to Sunday |
|
|
504
|
+
| locale.monthNames | <code>Array</code> | | Default: `luxon.Info.months('long')`<br/>Array with month names |
|
|
505
|
+
| locale.firstDay | <code>number</code> | | Default: `luxon.Info.getStartOfWeek()`<br/>First day of the week, 1 for Monday through 7 for Sunday |
|
|
506
506
|
| locale.applyLabel | <code>string</code> | <code>"Apply"</code> | Label of `Apply` Button |
|
|
507
507
|
| locale.cancelLabel | <code>string</code> | <code>"Cancel"</code> | Label of `Cancel` Button |
|
|
508
508
|
| locale.customRangeLabel | <code>string</code> | <code>"Custom"</code> | Range - Title for custom ranges |
|
package/daterangepicker.js
CHANGED
|
@@ -77,32 +77,33 @@
|
|
|
77
77
|
|
|
78
78
|
* @property {boolean} timePicker=false - Adds select boxes to choose times in addition to dates
|
|
79
79
|
* @property {boolean} timePicker24Hour=true - Use 24-hour instead of 12-hour times, removing the AM/PM selection
|
|
80
|
-
* @property {external:Duration|string} timePickerStepSize - Default: `Duration.fromObject({minutes:1})`<br/>Set the time picker step size.<br/>
|
|
81
|
-
* Must be a `luxon.Duration` or number of seconds or a string according to {@link ISO-8601} duration.<br/>
|
|
80
|
+
* @property {external:Duration|string|number} timePickerStepSize - Default: `Duration.fromObject({minutes:1})`<br/>Set the time picker step size.<br/>
|
|
81
|
+
* Must be a `luxon.Duration` or the number of seconds or a string according to {@link ISO-8601} duration.<br/>
|
|
82
82
|
* Valid values are 1,2,3,4,5,6,10,12,15,20,30 for `Duration.fromObject({seconds: ...})` and `Duration.fromObject({minutes: ...})`
|
|
83
83
|
* and 1,2,3,4,6,(8,12) for `Duration.fromObject({hours: ...})`.<br/>
|
|
84
84
|
* Duration must be greater than `minSpan` and smaller than `maxSpan`.<br/>
|
|
85
85
|
* For example `timePickerStepSize: 600` will disable time picker seconds and time picker minutes are set to step size of 10 Minutes.<br/>
|
|
86
|
-
* Overwrites
|
|
86
|
+
* Overwrites `timePickerIncrement` and `timePickerSeconds`
|
|
87
87
|
* @property {boolean} timePickerSeconds=boolean - **Deprecated**, use `timePickerStepSize`<br/>Show seconds in the timePicker
|
|
88
88
|
* @property {boolean} timePickerIncrement=1 - **Deprecated**, use `timePickerStepSize`<br/>Increment of the minutes selection list for times
|
|
89
89
|
|
|
90
90
|
* @property {boolean} autoUpdateInput=true - Indicates whether the date range picker should instantly update the value of the attached `<input>`
|
|
91
91
|
* element when the selected dates change.<br/>The `<input>` element will be always updated on `Apply` and reverted when user clicks on `Cancel`.
|
|
92
|
-
* @property {string} onOutsideClick=
|
|
92
|
+
* @property {string} onOutsideClick=apply - Defines what picker shall do when user clicks outside the calendar.
|
|
93
93
|
* `'apply'` or `'cancel'`. Event {@link #event_outsideClick.daterangepicker|onOutsideClick.daterangepicker} is always emitted.
|
|
94
94
|
* @property {boolean} linkedCalendars=true - When enabled, the two calendars displayed will always be for two sequential months (i.e. January and February),
|
|
95
95
|
* and both will be advanced when clicking the left or right arrows above the calendars.<br/>
|
|
96
96
|
* When disabled, the two calendars can be individually advanced and display any month/year
|
|
97
97
|
* @property {function} isInvalidDate=false - A function that is passed each date in the two calendars before they are displayed,<br/>
|
|
98
98
|
* and may return `true` or `false` to indicate whether that date should be available for selection or not.<br/>
|
|
99
|
-
* Signature: `isInvalidDate(date)
|
|
99
|
+
* Signature: `isInvalidDate(date)`<br/>
|
|
100
100
|
* Function has no effect on date values set by `startDate`, `endDate`, `ranges`, {@link #DateRangePicker+setStartDate|setStartDate}, {@link #DateRangePicker+setEndDate|setEndDate}.
|
|
101
101
|
* @property {function} isInvalidTime=false - A function that is passed each hour/minute/second/am-pm in the two calendars before they are displayed,<br/>
|
|
102
102
|
* and may return `true` or `false` to indicate whether that date should be available for selection or not.<br/>
|
|
103
103
|
* Signature: `isInvalidDate(time, side, unit)`<br/>
|
|
104
|
-
* `side` is 'start' or 'end' or `null` for `singleDatePicker
|
|
104
|
+
* `side` is `'start'` or `'end'` or `null` for `singleDatePicker: true`<br/>
|
|
105
105
|
* `unit` is `'hour'`, `'minute'`, `'second'` or `'ampm'`<br/>
|
|
106
|
+
* Hours are always given as 24-hour clock<br/>
|
|
106
107
|
* Function has no effect on time values set by `startDate`, `endDate`, `ranges`, {@link #DateRangePicker+setStartDate|setStartDate}, {@link #DateRangePicker+setEndDate|setEndDate}.<br/>
|
|
107
108
|
* Ensure that your function returns `false` for at least one item. Otherwise the calender is not rendered.<br/>
|
|
108
109
|
* @property {function} isCustomDate=false - A function that is passed each date in the two calendars before they are displayed,
|
|
@@ -135,9 +136,9 @@
|
|
|
135
136
|
* I recommend to use the luxon [Presets](https://moment.github.io/luxon/#/formatting?id=presets).
|
|
136
137
|
* @property {string} locale.separator= - Defaut: `' - '` - Separator for start and end time
|
|
137
138
|
* @property {string} locale.weekLabel=W - Label for week numbers
|
|
138
|
-
* @property {Array} locale.daysOfWeek - Default: `
|
|
139
|
-
* @property {Array} locale.monthNames - Default: `Info.months('long')`<br/>Array with month names
|
|
140
|
-
* @property {number} locale.firstDay - Default: `Info.getStartOfWeek()`<br/>First day of the week, 1 for Monday through 7 for Sunday
|
|
139
|
+
* @property {Array} locale.daysOfWeek - Default: `luxon.weekdays('short')`<br/>Array with weekday names, from Monday to Sunday
|
|
140
|
+
* @property {Array} locale.monthNames - Default: `luxon.Info.months('long')`<br/>Array with month names
|
|
141
|
+
* @property {number} locale.firstDay - Default: `luxon.Info.getStartOfWeek()`<br/>First day of the week, 1 for Monday through 7 for Sunday
|
|
141
142
|
* @property {string} locale.applyLabel=Apply - Label of `Apply` Button
|
|
142
143
|
* @property {string} locale.cancelLabel=Cancel - Label of `Cancel` Button
|
|
143
144
|
* @property {string} locale.customRangeLabel=Custom Range - Title for custom ranges
|
|
@@ -339,16 +340,17 @@
|
|
|
339
340
|
if (typeof options.timePickerIncrement === 'number') // backward compatibility
|
|
340
341
|
this.timePickerStepSize = Duration.fromObject({ minutes: options.timePickerIncrement });
|
|
341
342
|
|
|
342
|
-
if (['string', 'object'].includes(typeof options.timePickerStepSize)) {
|
|
343
|
-
let duration
|
|
343
|
+
if (['string', 'object', 'number'].includes(typeof options.timePickerStepSize)) {
|
|
344
|
+
let duration;
|
|
344
345
|
if (options.timePickerStepSize instanceof Duration && options.timePickerStepSize.isValid) {
|
|
345
346
|
duration = options.timePickerStepSize;
|
|
346
347
|
} else if (Duration.fromISO(options.timePickerStepSize).isValid) {
|
|
347
348
|
duration = Duration.fromISO(options.timePickerStepSize);
|
|
348
|
-
} else if (typeof options
|
|
349
|
-
duration = Duration.fromObject({ seconds:
|
|
349
|
+
} else if (typeof options.timePickerStepSize === 'number' && Duration.fromObject({ seconds: options.timePickerStepSize }).isValid) {
|
|
350
|
+
duration = Duration.fromObject({ seconds: options.timePickerStepSize });
|
|
350
351
|
} else {
|
|
351
352
|
console.error(`Option 'timePickerStepSize' is not valid`);
|
|
353
|
+
duration = this.timePickerStepSize;
|
|
352
354
|
};
|
|
353
355
|
var valid = [];
|
|
354
356
|
for (let unit of ['minutes', 'seconds'])
|
|
@@ -360,13 +362,16 @@
|
|
|
360
362
|
if (valid.some(x => duration.rescale().equals(x))) {
|
|
361
363
|
if (this.maxSpan && duration > this.maxSpan) {
|
|
362
364
|
console.error(`Option 'timePickerStepSize' ${JSON.stringify(duration.toObject())} must be smaller than 'maxSpan'`);
|
|
365
|
+
duration = this.timePickerStepSize;
|
|
363
366
|
} else if (this.minSpan && duration < this.minSpan) {
|
|
364
367
|
console.error(`Option 'timePickerStepSize' ${JSON.stringify(duration.toObject())} must be greater than 'minSpan'`);
|
|
368
|
+
duration = this.timePickerStepSize;
|
|
365
369
|
} else {
|
|
366
370
|
this.timePickerStepSize = duration.rescale();
|
|
367
371
|
}
|
|
368
372
|
} else {
|
|
369
373
|
console.error(`Option 'timePickerStepSize' ${JSON.stringify(duration.toObject())} is not valid`);
|
|
374
|
+
duration = this.timePickerStepSize;
|
|
370
375
|
}
|
|
371
376
|
}
|
|
372
377
|
|