@wernfried/daterangepicker 4.17.0 → 4.17.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 +662 -8
- package/README.md +138 -5
- package/package.json +1 -2
package/API_Doc.md
CHANGED
|
@@ -1,8 +1,662 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
## Classes
|
|
2
|
+
|
|
3
|
+
<dl>
|
|
4
|
+
<dt><a href="#DateRangePicker">DateRangePicker</a></dt>
|
|
5
|
+
<dd></dd>
|
|
6
|
+
</dl>
|
|
7
|
+
|
|
8
|
+
## Events
|
|
9
|
+
|
|
10
|
+
<dl>
|
|
11
|
+
<dt><a href="#event_violated.daterangepicker">"violated.daterangepicker" (this, picker, result, newDate)</a> ⇒ <code>boolean</code></dt>
|
|
12
|
+
<dd><p>Emitted when the date is changed through <code><input></code> element or via <a href="#DateRangePicker+setStartDate">setStartDate</a> or
|
|
13
|
+
<a href="#DateRangePicker+setRange">setRange</a> and date is not valid due to
|
|
14
|
+
<code>minDate</code>, <code>maxDate</code>, <code>minSpan</code>, <code>maxSpan</code>, <code>invalidDate</code> and <code>invalidTime</code> constraints.<br>
|
|
15
|
+
Event is only triggered when date string is valid and date value is changing<br></p>
|
|
16
|
+
</dd>
|
|
17
|
+
<dt><a href="#event_beforeRenderCalendar.daterangepicker">"beforeRenderCalendar.daterangepicker" (this)</a></dt>
|
|
18
|
+
<dd><p>Emitted before the calendar is rendered.
|
|
19
|
+
Useful to remove any manually added elements.</p>
|
|
20
|
+
</dd>
|
|
21
|
+
<dt><a href="#event_beforeRenderTimePicker.daterangepicker">"beforeRenderTimePicker.daterangepicker" (this)</a></dt>
|
|
22
|
+
<dd><p>Emitted before the TimePicker is rendered.
|
|
23
|
+
Useful to remove any manually added elements.</p>
|
|
24
|
+
</dd>
|
|
25
|
+
<dt><a href="#event_show.daterangepicker">"show.daterangepicker" (this)</a></dt>
|
|
26
|
+
<dd><p>Emitted when the picker is shown</p>
|
|
27
|
+
</dd>
|
|
28
|
+
<dt><a href="#event_beforeHide.daterangepicker">"beforeHide.daterangepicker" (this)</a> ⇒ <code>boolean</code></dt>
|
|
29
|
+
<dd><p>Emitted before the picker will hide. When EventHandler returns <code>true</code>, then picker remains visible</p>
|
|
30
|
+
</dd>
|
|
31
|
+
<dt><a href="#event_hide.daterangepicker">"hide.daterangepicker" (this)</a></dt>
|
|
32
|
+
<dd><p>Emitted when the picker is hidden</p>
|
|
33
|
+
</dd>
|
|
34
|
+
<dt><a href="#event_outsideClick.daterangepicker">"outsideClick.daterangepicker" (this)</a></dt>
|
|
35
|
+
<dd><p>Emitted when user clicks outside the picker.
|
|
36
|
+
Use option <code>onOutsideClick</code> to define the default action, then you may not need to handle this event.</p>
|
|
37
|
+
</dd>
|
|
38
|
+
<dt><a href="#event_showCalendar.daterangepicker">"showCalendar.daterangepicker" (this)</a></dt>
|
|
39
|
+
<dd><p>Emitted when the calendar(s) are shown.
|
|
40
|
+
Only useful when <a href="#Ranges">Ranges</a> are used.</p>
|
|
41
|
+
</dd>
|
|
42
|
+
<dt><a href="#event_hideCalendar.daterangepicker">"hideCalendar.daterangepicker" (this)</a></dt>
|
|
43
|
+
<dd><p>Emitted when the calendar(s) are hidden.
|
|
44
|
+
Only useful when <a href="#Ranges">Ranges</a> are used.</p>
|
|
45
|
+
</dd>
|
|
46
|
+
<dt><a href="#event_dateChange.daterangepicker">"dateChange.daterangepicker" (this, side)</a></dt>
|
|
47
|
+
<dd><p>Emitted when the date changed. Does not trigger when time is changed,
|
|
48
|
+
use <a href="#event_timeChange.daterangepicker">"timeChange.daterangepicker"</a> to handle it</p>
|
|
49
|
+
</dd>
|
|
50
|
+
<dt><a href="#event_apply.daterangepicker">"apply.daterangepicker" (this)</a></dt>
|
|
51
|
+
<dd><p>Emitted when the <code>Apply</code> button is clicked, or when a predefined <a href="#Ranges">Ranges</a> is clicked</p>
|
|
52
|
+
</dd>
|
|
53
|
+
<dt><a href="#event_cancel.daterangepicker">"cancel.daterangepicker" (this)</a></dt>
|
|
54
|
+
<dd><p>Emitted when the <code>Cancel</code> button is clicked</p>
|
|
55
|
+
</dd>
|
|
56
|
+
<dt><a href="#event_timeChange.daterangepicker">"timeChange.daterangepicker" (this, side)</a></dt>
|
|
57
|
+
<dd><p>Emitted when the time changed. Does not trigger when date is changed</p>
|
|
58
|
+
</dd>
|
|
59
|
+
<dt><a href="#event_inputChanged.daterangepicker">"inputChanged.daterangepicker" (this)</a></dt>
|
|
60
|
+
<dd><p>Emitted when the date is changed through <code><input></code> element. Event is only triggered when date string is valid and date value has changed</p>
|
|
61
|
+
</dd>
|
|
62
|
+
</dl>
|
|
63
|
+
|
|
64
|
+
## Typedefs
|
|
65
|
+
|
|
66
|
+
<dl>
|
|
67
|
+
<dt><a href="#Options">Options</a></dt>
|
|
68
|
+
<dd><p>Options for DateRangePicker</p>
|
|
69
|
+
</dd>
|
|
70
|
+
<dt><a href="#Ranges">Ranges</a> : <code>Object</code></dt>
|
|
71
|
+
<dd><p>A set of predefined ranges.<br>
|
|
72
|
+
Ranges are not validated against <code>minDate</code>, <code>maxDate</code>, <code>minSpan</code>, <code>maxSpan</code> or <code>timePickerStepSize </code> constraints.</p>
|
|
73
|
+
</dd>
|
|
74
|
+
<dt><a href="#Range">Range</a> : <code>Object</code></dt>
|
|
75
|
+
<dd><p>A single predefined range</p>
|
|
76
|
+
</dd>
|
|
77
|
+
<dt><a href="#InputViolation">InputViolation</a> : <code>Object</code></dt>
|
|
78
|
+
<dd></dd>
|
|
79
|
+
<dt><a href="#callback">callback</a> : <code>function</code></dt>
|
|
80
|
+
<dd></dd>
|
|
81
|
+
</dl>
|
|
82
|
+
|
|
83
|
+
<a name="DateRangePicker"></a>
|
|
84
|
+
|
|
85
|
+
## DateRangePicker
|
|
86
|
+
**Kind**: global class
|
|
87
|
+
|
|
88
|
+
* [DateRangePicker](#DateRangePicker)
|
|
89
|
+
* [new DateRangePicker(element, options, cb)](#new_DateRangePicker_new)
|
|
90
|
+
* _instance_
|
|
91
|
+
* [.startDate](#DateRangePicker+startDate) : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
92
|
+
* [.endDate](#DateRangePicker+endDate) : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
93
|
+
* [.setStartDate(startDate, updateView)](#DateRangePicker+setStartDate) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
94
|
+
* [.setEndDate(endDate, updateView)](#DateRangePicker+setEndDate) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
95
|
+
* [.setRange(startDate, endDate, updateView)](#DateRangePicker+setRange) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
96
|
+
* [.parseDate(value)](#DateRangePicker+parseDate) ⇒ [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
97
|
+
* [.formatDate(date, format)](#DateRangePicker+formatDate) ⇒ <code>string</code>
|
|
98
|
+
* [.validateInput(range, dipatch)](#DateRangePicker+validateInput) ⇒ [<code>InputViolation</code>](#InputViolation) \| <code>null</code>
|
|
99
|
+
* [.updateView()](#DateRangePicker+updateView)
|
|
100
|
+
* [.show()](#DateRangePicker+show)
|
|
101
|
+
* [.hide()](#DateRangePicker+hide)
|
|
102
|
+
* [.toggle()](#DateRangePicker+toggle)
|
|
103
|
+
* [.showCalendars()](#DateRangePicker+showCalendars)
|
|
104
|
+
* [.hideCalendars()](#DateRangePicker+hideCalendars)
|
|
105
|
+
* [.updateElement()](#DateRangePicker+updateElement)
|
|
106
|
+
* [.updateAltInput()](#DateRangePicker+updateAltInput)
|
|
107
|
+
* [.remove()](#DateRangePicker+remove)
|
|
108
|
+
* _static_
|
|
109
|
+
* [.daterangepicker(options, callback)](#DateRangePicker.daterangepicker) ⇒
|
|
110
|
+
|
|
111
|
+
<a name="new_DateRangePicker_new"></a>
|
|
112
|
+
|
|
113
|
+
### new DateRangePicker(element, options, cb)
|
|
114
|
+
|
|
115
|
+
| Param | Type | Description |
|
|
116
|
+
| --- | --- | --- |
|
|
117
|
+
| element | [<code>jQuery</code>](https://api.jquery.com/Types/#jQuery/) | jQuery selector of the parent element that the date range picker will be added to |
|
|
118
|
+
| options | [<code>Options</code>](#Options) | Object to configure the DateRangePicker |
|
|
119
|
+
| cb | <code>function</code> | Callback function executed when |
|
|
120
|
+
|
|
121
|
+
<a name="DateRangePicker+startDate"></a>
|
|
122
|
+
|
|
123
|
+
### dateRangePicker.startDate : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
124
|
+
startDate
|
|
125
|
+
|
|
126
|
+
**Kind**: instance property of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
127
|
+
<a name="DateRangePicker+endDate"></a>
|
|
128
|
+
|
|
129
|
+
### dateRangePicker.endDate : [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
130
|
+
endDate
|
|
131
|
+
|
|
132
|
+
**Kind**: instance property of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
133
|
+
<a name="DateRangePicker+setStartDate"></a>
|
|
134
|
+
|
|
135
|
+
### dateRangePicker.setStartDate(startDate, updateView) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
136
|
+
Sets the date range picker's currently selected start date to the provided date.<br>
|
|
137
|
+
`startDate` must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](ISO-8601) or a string matching `locale.format`.<br>
|
|
138
|
+
Invalid date values are handled by [violated](#DateRangePicker+violated) Event
|
|
139
|
+
|
|
140
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
141
|
+
**Returns**: [<code>InputViolation</code>](#InputViolation) - - Object of violations or `null` if no violation have been found
|
|
142
|
+
|
|
143
|
+
| Param | Type | Default | Description |
|
|
144
|
+
| --- | --- | --- | --- |
|
|
145
|
+
| 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> | | startDate to be set. In case of ranges, the current `endDate` is used. |
|
|
146
|
+
| updateView | <code>boolean</code> | <code>true</code> | If `true`, then calendar UI is updated to new value. Otherwise only internal values are set. |
|
|
147
|
+
|
|
148
|
+
**Example**
|
|
149
|
+
```js
|
|
150
|
+
const drp = $('#picker').data('daterangepicker');
|
|
151
|
+
drp.setStartDate(DateTime.now().startOf('hour'));
|
|
152
|
+
```
|
|
153
|
+
<a name="DateRangePicker+setEndDate"></a>
|
|
154
|
+
|
|
155
|
+
### dateRangePicker.setEndDate(endDate, updateView) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
156
|
+
Sets the date range picker's currently selected start date to the provided date.<br>
|
|
157
|
+
`endDate` must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](ISO-8601) or a string matching `locale.format`.<br>
|
|
158
|
+
Invalid date values are handled by [violated](#DateRangePicker+violated) Event
|
|
159
|
+
|
|
160
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
161
|
+
**Returns**: [<code>InputViolation</code>](#InputViolation) - - Object of violations or `null` if no violation have been found
|
|
162
|
+
|
|
163
|
+
| Param | Type | Default | Description |
|
|
164
|
+
| --- | --- | --- | --- |
|
|
165
|
+
| 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> | | endDate to be set. In case of ranges, the current `startDate` is used. |
|
|
166
|
+
| updateView | <code>boolean</code> | <code>true</code> | If `true`, then calendar UI is updated to new value. Otherwise only internal values are set. |
|
|
167
|
+
|
|
168
|
+
**Example**
|
|
169
|
+
```js
|
|
170
|
+
const drp = $('#picker').data('daterangepicker');
|
|
171
|
+
drp.setEndDate(DateTime.now().startOf('hour'));
|
|
172
|
+
```
|
|
173
|
+
<a name="DateRangePicker+setRange"></a>
|
|
174
|
+
|
|
175
|
+
### dateRangePicker.setRange(startDate, endDate, updateView) ⇒ [<code>InputViolation</code>](#InputViolation)
|
|
176
|
+
Sets the date range picker's currently selected start date to the provided date.<br>
|
|
177
|
+
`startDate` and `endDate` must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](ISO-8601) or a string matching `locale.format`.<br>
|
|
178
|
+
Invalid date values are handled by [violated](#DateRangePicker+violated) Event
|
|
179
|
+
|
|
180
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
181
|
+
**Returns**: [<code>InputViolation</code>](#InputViolation) - - Object of violations or `null` if no violation have been found
|
|
182
|
+
|
|
183
|
+
| Param | Type | Default | Description |
|
|
184
|
+
| --- | --- | --- | --- |
|
|
185
|
+
| 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> | | startDate to be set |
|
|
186
|
+
| 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> | | endDate to be set |
|
|
187
|
+
| updateView | <code>boolean</code> | <code>true</code> | If `true`, then calendar UI is updated to new value. Otherwise only internal values are set. |
|
|
188
|
+
|
|
189
|
+
**Example**
|
|
190
|
+
```js
|
|
191
|
+
const drp = $('#picker').data('daterangepicker');
|
|
192
|
+
drp.setRange(DateTime.now().startOf('hour'), DateTime.now().endOf('day'));
|
|
193
|
+
```
|
|
194
|
+
<a name="DateRangePicker+parseDate"></a>
|
|
195
|
+
|
|
196
|
+
### dateRangePicker.parseDate(value) ⇒ [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime)
|
|
197
|
+
Parse date value
|
|
198
|
+
|
|
199
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
200
|
+
**Returns**: [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) - - DateTime object
|
|
201
|
+
|
|
202
|
+
| Param | Type | Description |
|
|
203
|
+
| --- | --- | --- |
|
|
204
|
+
| value | <code>sting</code> \| [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| <code>Date</code> | The value to be parsed |
|
|
205
|
+
|
|
206
|
+
<a name="DateRangePicker+formatDate"></a>
|
|
207
|
+
|
|
208
|
+
### dateRangePicker.formatDate(date, format) ⇒ <code>string</code>
|
|
209
|
+
Format a DateTime object
|
|
210
|
+
|
|
211
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
212
|
+
**Returns**: <code>string</code> - - Formatted date string
|
|
213
|
+
|
|
214
|
+
| Param | Type | Default | Description |
|
|
215
|
+
| --- | --- | --- | --- |
|
|
216
|
+
| date | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | | The DateTime to format |
|
|
217
|
+
| format | <code>object</code> \| <code>string</code> | <code>this.locale.format</code> | The format option |
|
|
218
|
+
|
|
219
|
+
<a name="DateRangePicker+validateInput"></a>
|
|
220
|
+
|
|
221
|
+
### dateRangePicker.validateInput(range, dipatch) ⇒ [<code>InputViolation</code>](#InputViolation) \| <code>null</code>
|
|
222
|
+
Validate `startDate` and `endDate` against `timePickerStepSize`, `minDate`, `maxDate`,
|
|
223
|
+
`minSpan`, `maxSpan`, `invalidDate` and `invalidTime`.
|
|
224
|
+
|
|
225
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
226
|
+
**Returns**: [<code>InputViolation</code>](#InputViolation) \| <code>null</code> - - Object of violations and corrected values or `null` if no violation have been found
|
|
227
|
+
**Emits**: <code>event:"violated.daterangepicker"</code>
|
|
228
|
+
|
|
229
|
+
| Param | Type | Default | Description |
|
|
230
|
+
| --- | --- | --- | --- |
|
|
231
|
+
| range | <code>Array</code> | | `[startDate, endDate]`<br>Range to be checked, defaults to current `startDate` and `endDate` |
|
|
232
|
+
| dipatch | <code>boolean</code> | <code>false</code> | If `true` then event "violated.daterangepicker" is dispated.<br> If eventHandler returns `true`, then `null` is returned, otherwiese the object of violations. |
|
|
233
|
+
|
|
234
|
+
**Example**
|
|
235
|
+
```js
|
|
236
|
+
options => {
|
|
237
|
+
minDate: DateTime.now().minus({months: 3}).startOf('day'),
|
|
238
|
+
maxDate: DateTime.now().minus({day: 3}).startOf('day'),
|
|
239
|
+
minSpan: Duration.fromObject({days: 7}),
|
|
240
|
+
maxSpan: Duration.fromObject({days: 70}),
|
|
241
|
+
timePickerStepSize: Duration.fromObject({hours: 1})
|
|
242
|
+
}
|
|
243
|
+
const result = validateInput(DateTime.now(), DateTime.now().plus({day: 3}));
|
|
244
|
+
|
|
245
|
+
result => {
|
|
246
|
+
startDate: {
|
|
247
|
+
violations: [
|
|
248
|
+
{ old: "2026-03-13T10:35:52", reason: "timePickerStepSize", new: "2026-03-13T11:00:00" },
|
|
249
|
+
{ old: "2026-03-13T11:00:00", reason: "maxDate", new: "2026-03-10T00:00:00" }
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
endDate: {
|
|
253
|
+
violations: [
|
|
254
|
+
{ old: "2026-03-16T10:35:52", reason: "stepSize", new: "2026-03-16T11:00:00" },
|
|
255
|
+
{ old: "2026-03-16T11:00:00", reason: "maxDate", new: "2026-03-10T00:00:00" },
|
|
256
|
+
{ old: "2026-03-10T00:00:00", reason: "minSpan", new: "2026-03-17T00:00:00" }
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
<a name="DateRangePicker+updateView"></a>
|
|
262
|
+
|
|
263
|
+
### dateRangePicker.updateView()
|
|
264
|
+
Updates the picker when calendar is initiated or any date has been selected.
|
|
265
|
+
Could be useful after running [setStartDate](#DateRangePicker+setStartDate) or [setRange](#DateRangePicker+setEndDate)
|
|
266
|
+
|
|
267
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
268
|
+
**Emits**: <code>event:"beforeRenderTimePicker.daterangepicker"</code>
|
|
269
|
+
<a name="DateRangePicker+show"></a>
|
|
270
|
+
|
|
271
|
+
### dateRangePicker.show()
|
|
272
|
+
Shows the picker
|
|
273
|
+
|
|
274
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
275
|
+
**Emits**: <code>event:"show.daterangepicker"</code>
|
|
276
|
+
<a name="DateRangePicker+hide"></a>
|
|
277
|
+
|
|
278
|
+
### dateRangePicker.hide()
|
|
279
|
+
Hides the picker
|
|
280
|
+
|
|
281
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
282
|
+
**Emits**: <code>event:"beforeHide.daterangepicker"</code>, <code>event:"hide.daterangepicker"</code>
|
|
283
|
+
<a name="DateRangePicker+toggle"></a>
|
|
284
|
+
|
|
285
|
+
### dateRangePicker.toggle()
|
|
286
|
+
Toggles visibility of the picker
|
|
287
|
+
|
|
288
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
289
|
+
<a name="DateRangePicker+showCalendars"></a>
|
|
290
|
+
|
|
291
|
+
### dateRangePicker.showCalendars()
|
|
292
|
+
Shows calendar when user selects "Custom Ranges"
|
|
293
|
+
|
|
294
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
295
|
+
**Emits**: <code>event:"showCalendar.daterangepicker"</code>
|
|
296
|
+
<a name="DateRangePicker+hideCalendars"></a>
|
|
297
|
+
|
|
298
|
+
### dateRangePicker.hideCalendars()
|
|
299
|
+
Hides calendar when user selects a predefined range
|
|
300
|
+
|
|
301
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
302
|
+
**Emits**: <code>event:"hideCalendar.daterangepicker"</code>
|
|
303
|
+
<a name="DateRangePicker+updateElement"></a>
|
|
304
|
+
|
|
305
|
+
### dateRangePicker.updateElement()
|
|
306
|
+
Update attached `<input>` element with selected value
|
|
307
|
+
|
|
308
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
309
|
+
**Emits**: [<code>change</code>](https://api.jquery.com/change/)
|
|
310
|
+
<a name="DateRangePicker+updateAltInput"></a>
|
|
311
|
+
|
|
312
|
+
### dateRangePicker.updateAltInput()
|
|
313
|
+
Update altInput `<input>` element with selected value
|
|
314
|
+
|
|
315
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
316
|
+
<a name="DateRangePicker+remove"></a>
|
|
317
|
+
|
|
318
|
+
### dateRangePicker.remove()
|
|
319
|
+
Removes the picker from document
|
|
320
|
+
|
|
321
|
+
**Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
322
|
+
<a name="DateRangePicker.daterangepicker"></a>
|
|
323
|
+
|
|
324
|
+
### DateRangePicker.daterangepicker(options, callback) ⇒
|
|
325
|
+
Initiate a new DateRangePicker
|
|
326
|
+
|
|
327
|
+
**Kind**: static method of [<code>DateRangePicker</code>](#DateRangePicker)
|
|
328
|
+
**Returns**: DateRangePicker
|
|
329
|
+
|
|
330
|
+
| Param | Type | Description |
|
|
331
|
+
| --- | --- | --- |
|
|
332
|
+
| options | [<code>Options</code>](#Options) | Object to configure the DateRangePicker |
|
|
333
|
+
| callback | [<code>callback</code>](#callback) | Callback function executed when date is changed.<br> Callback function is executed if selected date values has changed, before picker is hidden and before the attached `<input>` element is updated. As alternative listen to the ["apply.daterangepicker"](#event_apply.daterangepicker) event |
|
|
334
|
+
|
|
335
|
+
<a name="event_violated.daterangepicker"></a>
|
|
336
|
+
|
|
337
|
+
## "violated.daterangepicker" (this, picker, result, newDate) ⇒ <code>boolean</code>
|
|
338
|
+
Emitted when the date is changed through `<input>` element or via [setStartDate](#DateRangePicker+setStartDate) or
|
|
339
|
+
[setRange](#DateRangePicker+setRange) and date is not valid due to
|
|
340
|
+
`minDate`, `maxDate`, `minSpan`, `maxSpan`, `invalidDate` and `invalidTime` constraints.<br>
|
|
341
|
+
Event is only triggered when date string is valid and date value is changing<br>
|
|
342
|
+
|
|
343
|
+
**Kind**: event emitted
|
|
344
|
+
**Returns**: <code>boolean</code> - =undefined - If handler returns `true`, then values from `newDate` object are used
|
|
345
|
+
|
|
346
|
+
| Param | Type | Description |
|
|
347
|
+
| --- | --- | --- |
|
|
348
|
+
| this | <code>Object</code> | The event object |
|
|
349
|
+
| picker | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
350
|
+
| result | [<code>InputViolation</code>](#InputViolation) | The violation object, see example of `validateInput()` |
|
|
351
|
+
| newDate | <code>Object</code> | Object of {startDate, endDate} |
|
|
352
|
+
|
|
353
|
+
**Example**
|
|
354
|
+
```js
|
|
355
|
+
$('#picker').daterangepicker({
|
|
356
|
+
startDate: DateTime.now(),
|
|
357
|
+
// allow only dates from current year
|
|
358
|
+
minDate: DateTime.now().startOf('year'),
|
|
359
|
+
manDate: DateTime.now().endOf('year'),
|
|
360
|
+
singleDatePicker: true,
|
|
361
|
+
locale: {
|
|
362
|
+
format: DateTime.DATETIME_SHORT
|
|
363
|
+
}
|
|
364
|
+
}).on('violated.daterangepicker', (ev, picker, result, newDate) => {
|
|
365
|
+
newDate.startDate = DateTime.now().minus({ days: 3 }).startOf('day');
|
|
366
|
+
return true;
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// Try to set date outside permitted range at <input> elemet
|
|
370
|
+
$('#picker').val(DateTime.now().minus({ years: 10 })).toLocaleString(DateTime.DATETIME_SHORT).trigger('keyup');
|
|
371
|
+
// Try to set date outside permitted range by code
|
|
372
|
+
const drp = $('#picker').data('daterangepicker').setStartDate(DateTime.now().minus({ years: 10 })
|
|
373
|
+
|
|
374
|
+
// -> Calendar selects and shows "today - 3 days"
|
|
375
|
+
```
|
|
376
|
+
<a name="event_beforeRenderCalendar.daterangepicker"></a>
|
|
377
|
+
|
|
378
|
+
## "beforeRenderCalendar.daterangepicker" (this)
|
|
379
|
+
Emitted before the calendar is rendered.
|
|
380
|
+
Useful to remove any manually added elements.
|
|
381
|
+
|
|
382
|
+
**Kind**: event emitted
|
|
383
|
+
|
|
384
|
+
| Param | Type | Description |
|
|
385
|
+
| --- | --- | --- |
|
|
386
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
387
|
+
|
|
388
|
+
<a name="event_beforeRenderTimePicker.daterangepicker"></a>
|
|
389
|
+
|
|
390
|
+
## "beforeRenderTimePicker.daterangepicker" (this)
|
|
391
|
+
Emitted before the TimePicker is rendered.
|
|
392
|
+
Useful to remove any manually added elements.
|
|
393
|
+
|
|
394
|
+
**Kind**: event emitted
|
|
395
|
+
|
|
396
|
+
| Param | Type | Description |
|
|
397
|
+
| --- | --- | --- |
|
|
398
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
399
|
+
|
|
400
|
+
<a name="event_show.daterangepicker"></a>
|
|
401
|
+
|
|
402
|
+
## "show.daterangepicker" (this)
|
|
403
|
+
Emitted when the picker is shown
|
|
404
|
+
|
|
405
|
+
**Kind**: event emitted
|
|
406
|
+
|
|
407
|
+
| Param | Type | Description |
|
|
408
|
+
| --- | --- | --- |
|
|
409
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
410
|
+
|
|
411
|
+
<a name="event_beforeHide.daterangepicker"></a>
|
|
412
|
+
|
|
413
|
+
## "beforeHide.daterangepicker" (this) ⇒ <code>boolean</code>
|
|
414
|
+
Emitted before the picker will hide. When EventHandler returns `true`, then picker remains visible
|
|
415
|
+
|
|
416
|
+
**Kind**: event emitted
|
|
417
|
+
**Returns**: <code>boolean</code> - cancel - If `true`, then the picker remains visible
|
|
418
|
+
|
|
419
|
+
| Param | Type | Description |
|
|
420
|
+
| --- | --- | --- |
|
|
421
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
422
|
+
|
|
423
|
+
<a name="event_hide.daterangepicker"></a>
|
|
424
|
+
|
|
425
|
+
## "hide.daterangepicker" (this)
|
|
426
|
+
Emitted when the picker is hidden
|
|
427
|
+
|
|
428
|
+
**Kind**: event emitted
|
|
429
|
+
|
|
430
|
+
| Param | Type | Description |
|
|
431
|
+
| --- | --- | --- |
|
|
432
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
433
|
+
|
|
434
|
+
<a name="event_outsideClick.daterangepicker"></a>
|
|
435
|
+
|
|
436
|
+
## "outsideClick.daterangepicker" (this)
|
|
437
|
+
Emitted when user clicks outside the picker.
|
|
438
|
+
Use option `onOutsideClick` to define the default action, then you may not need to handle this event.
|
|
439
|
+
|
|
440
|
+
**Kind**: event emitted
|
|
441
|
+
|
|
442
|
+
| Param | Type | Description |
|
|
443
|
+
| --- | --- | --- |
|
|
444
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
445
|
+
|
|
446
|
+
<a name="event_showCalendar.daterangepicker"></a>
|
|
447
|
+
|
|
448
|
+
## "showCalendar.daterangepicker" (this)
|
|
449
|
+
Emitted when the calendar(s) are shown.
|
|
450
|
+
Only useful when [Ranges](#Ranges) are used.
|
|
451
|
+
|
|
452
|
+
**Kind**: event emitted
|
|
453
|
+
|
|
454
|
+
| Param | Type | Description |
|
|
455
|
+
| --- | --- | --- |
|
|
456
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
457
|
+
|
|
458
|
+
<a name="event_hideCalendar.daterangepicker"></a>
|
|
459
|
+
|
|
460
|
+
## "hideCalendar.daterangepicker" (this)
|
|
461
|
+
Emitted when the calendar(s) are hidden.
|
|
462
|
+
Only useful when [Ranges](#Ranges) are used.
|
|
463
|
+
|
|
464
|
+
**Kind**: event emitted
|
|
465
|
+
|
|
466
|
+
| Param | Type | Description |
|
|
467
|
+
| --- | --- | --- |
|
|
468
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
469
|
+
|
|
470
|
+
<a name="event_dateChange.daterangepicker"></a>
|
|
471
|
+
|
|
472
|
+
## "dateChange.daterangepicker" (this, side)
|
|
473
|
+
Emitted when the date changed. Does not trigger when time is changed,
|
|
474
|
+
use ["timeChange.daterangepicker"](#event_timeChange.daterangepicker) to handle it
|
|
475
|
+
|
|
476
|
+
**Kind**: event emitted
|
|
477
|
+
|
|
478
|
+
| Param | Type | Description |
|
|
479
|
+
| --- | --- | --- |
|
|
480
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
481
|
+
| side | <code>string</code> | Either `'start'` or `'end'` indicating whether startDate or endDate was changed. `null` when `singleDatePicker: true` |
|
|
482
|
+
|
|
483
|
+
<a name="event_apply.daterangepicker"></a>
|
|
484
|
+
|
|
485
|
+
## "apply.daterangepicker" (this)
|
|
486
|
+
Emitted when the `Apply` button is clicked, or when a predefined [Ranges](#Ranges) is clicked
|
|
487
|
+
|
|
488
|
+
**Kind**: event emitted
|
|
489
|
+
|
|
490
|
+
| Param | Type | Description |
|
|
491
|
+
| --- | --- | --- |
|
|
492
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
493
|
+
|
|
494
|
+
<a name="event_cancel.daterangepicker"></a>
|
|
495
|
+
|
|
496
|
+
## "cancel.daterangepicker" (this)
|
|
497
|
+
Emitted when the `Cancel` button is clicked
|
|
498
|
+
|
|
499
|
+
**Kind**: event emitted
|
|
500
|
+
|
|
501
|
+
| Param | Type | Description |
|
|
502
|
+
| --- | --- | --- |
|
|
503
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
504
|
+
|
|
505
|
+
<a name="event_timeChange.daterangepicker"></a>
|
|
506
|
+
|
|
507
|
+
## "timeChange.daterangepicker" (this, side)
|
|
508
|
+
Emitted when the time changed. Does not trigger when date is changed
|
|
509
|
+
|
|
510
|
+
**Kind**: event emitted
|
|
511
|
+
|
|
512
|
+
| Param | Type | Description |
|
|
513
|
+
| --- | --- | --- |
|
|
514
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
515
|
+
| side | <code>string</code> | Either `'start'` or `'end'` indicating whether startDate or endDate was changed |
|
|
516
|
+
|
|
517
|
+
<a name="event_inputChanged.daterangepicker"></a>
|
|
518
|
+
|
|
519
|
+
## "inputChanged.daterangepicker" (this)
|
|
520
|
+
Emitted when the date is changed through `<input>` element. Event is only triggered when date string is valid and date value has changed
|
|
521
|
+
|
|
522
|
+
**Kind**: event emitted
|
|
523
|
+
|
|
524
|
+
| Param | Type | Description |
|
|
525
|
+
| --- | --- | --- |
|
|
526
|
+
| this | [<code>DateRangePicker</code>](#DateRangePicker) | The daterangepicker object |
|
|
527
|
+
|
|
528
|
+
<a name="Options"></a>
|
|
529
|
+
|
|
530
|
+
## Options
|
|
531
|
+
Options for DateRangePicker
|
|
532
|
+
|
|
533
|
+
**Kind**: global typedef
|
|
534
|
+
**Properties**
|
|
535
|
+
|
|
536
|
+
| Name | Type | Default | Description |
|
|
537
|
+
| --- | --- | --- | --- |
|
|
538
|
+
| parentEl | <code>string</code> | <code>"body"</code> | [jQuery selector](https://api.jquery.com/category/selectors/) of the parent element that the date range picker will be added to |
|
|
539
|
+
| 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 inital selected date. |
|
|
540
|
+
| 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> |
|
|
541
|
+
| 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`. |
|
|
542
|
+
| 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`. |
|
|
543
|
+
| 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` |
|
|
544
|
+
| 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` |
|
|
545
|
+
| 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` |
|
|
546
|
+
| 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` |
|
|
547
|
+
| 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` |
|
|
548
|
+
| 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`. |
|
|
549
|
+
| 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`. |
|
|
550
|
+
| showDropdowns | <code>boolean</code> | <code>false</code> | Show year and month select boxes above calendars to jump to a specific month and year |
|
|
551
|
+
| minYear | <code>number</code> | | Default: `DateTime.now().minus({year:100}).year`<br>The minimum year shown in the dropdowns when `showDropdowns: true` |
|
|
552
|
+
| maxYear | <code>number</code> | | Default: `DateTime.now().plus({year:100}).year`<br>The maximum year shown in the dropdowns when `showDropdowns: true` |
|
|
553
|
+
| showWeekNumbers | <code>boolean</code> | <code>false</code> | Show **localized** week numbers at the start of each week on the calendars |
|
|
554
|
+
| 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` |
|
|
555
|
+
| timePicker | <code>boolean</code> | <code>false</code> | Adds select boxes to choose times in addition to dates |
|
|
556
|
+
| timePicker24Hour | <code>boolean</code> | <code>true|false</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). |
|
|
557
|
+
| 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.<br> Overwrites `timePickerIncrement` and `timePickerSeconds`, ignored when `timePicker: false` |
|
|
558
|
+
| timePickerSeconds | <code>boolean</code> | <code>boolean</code> | **Deprecated**, use `timePickerStepSize`<br>Show seconds in the timePicker |
|
|
559
|
+
| timePickerIncrement | <code>boolean</code> | <code>1</code> | **Deprecated**, use `timePickerStepSize`<br>Increment of the minutes selection list for times |
|
|
560
|
+
| 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`. |
|
|
561
|
+
| 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. |
|
|
562
|
+
| 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 |
|
|
563
|
+
| 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> |
|
|
564
|
+
| 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> |
|
|
565
|
+
| 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)` |
|
|
566
|
+
| altInput | <code>string</code> \| <code>Array</code> | <code>null</code> | A [jQuery selector](https://api.jquery.com/category/selectors/) string for an alternative output (typically hidden) `<input>` element. Uses `altFormat` to format the value.<br> Must be a single string for `singleDatePicker: true` or an array of two strings for `singleDatePicker: false`<br> Example: `['#start', '#end']` |
|
|
567
|
+
| 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()` |
|
|
568
|
+
| ~~warnings~~ | <code>boolean</code> | | Not used anymore. Listen to event `violated.daterangepicker` to react on invalid input data |
|
|
569
|
+
| applyButtonClasses | <code>string</code> | <code>"btn-primary"</code> | CSS class names that will be added only to the apply button |
|
|
570
|
+
| cancelButtonClasses | <code>string</code> | <code>"btn-default"</code> | CSS class names that will be added only to the cancel button |
|
|
571
|
+
| buttonClasses | <code>string</code> | | Default: `'btn btn-sm'`<br>CSS class names that will be added to both the apply and cancel buttons. |
|
|
572
|
+
| 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. |
|
|
573
|
+
| 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. |
|
|
574
|
+
| 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. |
|
|
575
|
+
| externalStyle | <code>string</code> | <code>null</code> | External CSS Framework to style the picker. Currently only `'bulma'` is supported. |
|
|
576
|
+
| 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'` |
|
|
577
|
+
| 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'` |
|
|
578
|
+
| 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. |
|
|
579
|
+
| 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. |
|
|
580
|
+
| 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. |
|
|
581
|
+
| showLabel= | <code>boolean</code> | | Shows selected range next to Apply buttons.<br> Defaults to `false` if anchor element is `<input type="text">`, otherwise `true` |
|
|
582
|
+
| 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. |
|
|
583
|
+
| locale.direction | <code>string</code> | <code>"ltr"</code> | Direction of reading, `'ltr'` or `'rtl'` |
|
|
584
|
+
| 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). |
|
|
585
|
+
| locale.separator | <code>string</code> | | Defaut: `' - '`<br>Separator for start and end time |
|
|
586
|
+
| locale.weekLabel | <code>string</code> | <code>"W"</code> | Label for week numbers |
|
|
587
|
+
| locale.daysOfWeek | <code>Array</code> | | Default: `luxon.Info.weekdays('short')`<br>Array with weekday names, from Monday to Sunday |
|
|
588
|
+
| locale.monthNames | <code>Array</code> | | Default: `luxon.Info.months('long')`<br>Array with month names |
|
|
589
|
+
| locale.firstDay | <code>number</code> | | Default: `luxon.Info.getStartOfWeek()`<br>First day of the week, 1 for Monday through 7 for Sunday |
|
|
590
|
+
| locale.applyLabel | <code>string</code> | <code>"Apply"</code> | Label of `Apply` Button |
|
|
591
|
+
| locale.cancelLabel | <code>string</code> | <code>"Cancel"</code> | Label of `Cancel` Button |
|
|
592
|
+
| locale.customRangeLabel | <code>string</code> | <code>"Custom"</code> | Range - Title for custom ranges |
|
|
593
|
+
| 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) => {}` |
|
|
594
|
+
|
|
595
|
+
<a name="Ranges"></a>
|
|
596
|
+
|
|
597
|
+
## Ranges : <code>Object</code>
|
|
598
|
+
A set of predefined ranges.<br>
|
|
599
|
+
Ranges are not validated against `minDate`, `maxDate`, `minSpan`, `maxSpan` or `timePickerStepSize ` constraints.
|
|
600
|
+
|
|
601
|
+
**Kind**: global typedef
|
|
602
|
+
**Properties**
|
|
603
|
+
|
|
604
|
+
| Name | Type | Description |
|
|
605
|
+
| --- | --- | --- |
|
|
606
|
+
| name | <code>string</code> | The name of the range |
|
|
607
|
+
| range | [<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> | Array of 2 elements with `startDate` and `endDate` |
|
|
608
|
+
|
|
609
|
+
**Example**
|
|
610
|
+
```js
|
|
611
|
+
{
|
|
612
|
+
'Today': [DateTime.now().startOf('day'), DateTime.now().endOf('day')],
|
|
613
|
+
'Yesterday': [DateTime.now().startOf('day').minus({days: 1}), DateTime.now().minus({days: 1}).endOf('day')],
|
|
614
|
+
'Last 7 Days': [DateTime.now().startOf('day').minus({days: 6}), DateTime.now()],
|
|
615
|
+
'Last 30 Days': [DateTime.now().startOf('day').minus({days: 29}), DateTime.now()],
|
|
616
|
+
'This Month': [DateTime.now().startOf('day').startOf('month'), DateTime.now().endOf('month')],
|
|
617
|
+
'Last Month': [DateTime.now().startOf('day').minus({months: 1}).startOf('month'), DateTime.now().minus({months: 1}).endOf('month')]
|
|
618
|
+
}
|
|
619
|
+
```
|
|
620
|
+
<a name="Range"></a>
|
|
621
|
+
|
|
622
|
+
## Range : <code>Object</code>
|
|
623
|
+
A single predefined range
|
|
624
|
+
|
|
625
|
+
**Kind**: global typedef
|
|
626
|
+
**Properties**
|
|
627
|
+
|
|
628
|
+
| Name | Type | Description |
|
|
629
|
+
| --- | --- | --- |
|
|
630
|
+
| name | <code>string</code> | The name of the range |
|
|
631
|
+
| range | [<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> | Array of 2 elements with startDate and endDate |
|
|
632
|
+
|
|
633
|
+
**Example**
|
|
634
|
+
```js
|
|
635
|
+
{ Today: [DateTime.now().startOf('day'), DateTime.now().endOf('day')] }
|
|
636
|
+
```
|
|
637
|
+
<a name="InputViolation"></a>
|
|
638
|
+
|
|
639
|
+
## InputViolation : <code>Object</code>
|
|
640
|
+
**Kind**: global typedef
|
|
641
|
+
**Properties**
|
|
642
|
+
|
|
643
|
+
| Name | Type | Description |
|
|
644
|
+
| --- | --- | --- |
|
|
645
|
+
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Violation of startDate |
|
|
646
|
+
| endDate? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| <code>undefined</code> | Violation of endDate, if existing |
|
|
647
|
+
| violations | <code>Array</code> | The constraints which violates the input |
|
|
648
|
+
| reason | <code>Array</code> | The type/reson of violation |
|
|
649
|
+
| old | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Old value startDate/endDate |
|
|
650
|
+
| new? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Corrected value of startDate/endDate if existing |
|
|
651
|
+
|
|
652
|
+
<a name="callback"></a>
|
|
653
|
+
|
|
654
|
+
## callback : <code>function</code>
|
|
655
|
+
**Kind**: global typedef
|
|
656
|
+
|
|
657
|
+
| Param | Type | Description |
|
|
658
|
+
| --- | --- | --- |
|
|
659
|
+
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Selected startDate |
|
|
660
|
+
| endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Selected endDate |
|
|
661
|
+
| range | <code>string</code> | |
|
|
662
|
+
|
package/README.md
CHANGED
|
@@ -20,8 +20,8 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
20
20
|
```html
|
|
21
21
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
22
22
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
|
|
23
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
24
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
23
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.1/dist/global/daterangepicker.min.js"></script>
|
|
24
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.1/css/daterangepicker.min.css" rel="stylesheet" />
|
|
25
25
|
|
|
26
26
|
<input type="text" id="picker" />
|
|
27
27
|
|
|
@@ -43,11 +43,11 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
43
43
|
"imports": {
|
|
44
44
|
"jquery": "https://cdn.jsdelivr.net/npm/jquery@4.0.0/+esm",
|
|
45
45
|
"luxon": "https://cdn.jsdelivr.net/npm/luxon@3.7.2/+esm",
|
|
46
|
-
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
46
|
+
"daterangepicker": "https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.1/+esm"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
50
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.1/css/daterangepicker.min.css" rel="stylesheet" />
|
|
51
51
|
|
|
52
52
|
<input type="text" id="picker" />
|
|
53
53
|
|
|
@@ -68,7 +68,7 @@ Above samples are based on the [original repository](https://github.com/dangross
|
|
|
68
68
|
```html
|
|
69
69
|
<script ...></script>
|
|
70
70
|
<link type="text/css" href="https://cdn.jsdelivr.net/npm/bulma@1.0.4/css/bulma.min.css" rel="stylesheet" />
|
|
71
|
-
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.
|
|
71
|
+
<link type="text/css" href="https://cdn.jsdelivr.net/npm/@wernfried/daterangepicker@4.17.1/css/daterangepicker.bulma.min.css" rel="stylesheet" />
|
|
72
72
|
|
|
73
73
|
<input type="text" id="picker" />
|
|
74
74
|
|
|
@@ -257,3 +257,136 @@ Licensed under the [MIT license](LICENSE).
|
|
|
257
257
|
|
|
258
258
|
## API Documentation
|
|
259
259
|
[API Documentation](API_Doc.md)
|
|
260
|
+
## Options
|
|
261
|
+
Options for DateRangePicker
|
|
262
|
+
|
|
263
|
+
**Kind**: global typedef
|
|
264
|
+
**Properties**
|
|
265
|
+
|
|
266
|
+
| Name | Type | Default | Description |
|
|
267
|
+
| --- | --- | --- | --- |
|
|
268
|
+
| parentEl | <code>string</code> | <code>"body"</code> | [jQuery selector](https://api.jquery.com/category/selectors/) of the parent element that the date range picker will be added to |
|
|
269
|
+
| 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 inital selected date. |
|
|
270
|
+
| 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> |
|
|
271
|
+
| 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`. |
|
|
272
|
+
| 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`. |
|
|
273
|
+
| 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` |
|
|
274
|
+
| 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` |
|
|
275
|
+
| 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` |
|
|
276
|
+
| 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` |
|
|
277
|
+
| 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` |
|
|
278
|
+
| 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`. |
|
|
279
|
+
| 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`. |
|
|
280
|
+
| showDropdowns | <code>boolean</code> | <code>false</code> | Show year and month select boxes above calendars to jump to a specific month and year |
|
|
281
|
+
| minYear | <code>number</code> | | Default: `DateTime.now().minus({year:100}).year`<br>The minimum year shown in the dropdowns when `showDropdowns: true` |
|
|
282
|
+
| maxYear | <code>number</code> | | Default: `DateTime.now().plus({year:100}).year`<br>The maximum year shown in the dropdowns when `showDropdowns: true` |
|
|
283
|
+
| showWeekNumbers | <code>boolean</code> | <code>false</code> | Show **localized** week numbers at the start of each week on the calendars |
|
|
284
|
+
| 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` |
|
|
285
|
+
| timePicker | <code>boolean</code> | <code>false</code> | Adds select boxes to choose times in addition to dates |
|
|
286
|
+
| timePicker24Hour | <code>boolean</code> | <code>true|false</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). |
|
|
287
|
+
| 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.<br> Overwrites `timePickerIncrement` and `timePickerSeconds`, ignored when `timePicker: false` |
|
|
288
|
+
| timePickerSeconds | <code>boolean</code> | <code>boolean</code> | **Deprecated**, use `timePickerStepSize`<br>Show seconds in the timePicker |
|
|
289
|
+
| timePickerIncrement | <code>boolean</code> | <code>1</code> | **Deprecated**, use `timePickerStepSize`<br>Increment of the minutes selection list for times |
|
|
290
|
+
| 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`. |
|
|
291
|
+
| 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. |
|
|
292
|
+
| 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 |
|
|
293
|
+
| 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> |
|
|
294
|
+
| 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> |
|
|
295
|
+
| 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)` |
|
|
296
|
+
| altInput | <code>string</code> \| <code>Array</code> | <code>null</code> | A [jQuery selector](https://api.jquery.com/category/selectors/) string for an alternative output (typically hidden) `<input>` element. Uses `altFormat` to format the value.<br> Must be a single string for `singleDatePicker: true` or an array of two strings for `singleDatePicker: false`<br> Example: `['#start', '#end']` |
|
|
297
|
+
| 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()` |
|
|
298
|
+
| ~~warnings~~ | <code>boolean</code> | | Not used anymore. Listen to event `violated.daterangepicker` to react on invalid input data |
|
|
299
|
+
| applyButtonClasses | <code>string</code> | <code>"btn-primary"</code> | CSS class names that will be added only to the apply button |
|
|
300
|
+
| cancelButtonClasses | <code>string</code> | <code>"btn-default"</code> | CSS class names that will be added only to the cancel button |
|
|
301
|
+
| buttonClasses | <code>string</code> | | Default: `'btn btn-sm'`<br>CSS class names that will be added to both the apply and cancel buttons. |
|
|
302
|
+
| 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. |
|
|
303
|
+
| 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. |
|
|
304
|
+
| 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. |
|
|
305
|
+
| externalStyle | <code>string</code> | <code>null</code> | External CSS Framework to style the picker. Currently only `'bulma'` is supported. |
|
|
306
|
+
| 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'` |
|
|
307
|
+
| 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'` |
|
|
308
|
+
| 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. |
|
|
309
|
+
| 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. |
|
|
310
|
+
| 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. |
|
|
311
|
+
| showLabel= | <code>boolean</code> | | Shows selected range next to Apply buttons.<br> Defaults to `false` if anchor element is `<input type="text">`, otherwise `true` |
|
|
312
|
+
| 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. |
|
|
313
|
+
| locale.direction | <code>string</code> | <code>"ltr"</code> | Direction of reading, `'ltr'` or `'rtl'` |
|
|
314
|
+
| 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). |
|
|
315
|
+
| locale.separator | <code>string</code> | | Defaut: `' - '`<br>Separator for start and end time |
|
|
316
|
+
| locale.weekLabel | <code>string</code> | <code>"W"</code> | Label for week numbers |
|
|
317
|
+
| locale.daysOfWeek | <code>Array</code> | | Default: `luxon.Info.weekdays('short')`<br>Array with weekday names, from Monday to Sunday |
|
|
318
|
+
| locale.monthNames | <code>Array</code> | | Default: `luxon.Info.months('long')`<br>Array with month names |
|
|
319
|
+
| locale.firstDay | <code>number</code> | | Default: `luxon.Info.getStartOfWeek()`<br>First day of the week, 1 for Monday through 7 for Sunday |
|
|
320
|
+
| locale.applyLabel | <code>string</code> | <code>"Apply"</code> | Label of `Apply` Button |
|
|
321
|
+
| locale.cancelLabel | <code>string</code> | <code>"Cancel"</code> | Label of `Cancel` Button |
|
|
322
|
+
| locale.customRangeLabel | <code>string</code> | <code>"Custom"</code> | Range - Title for custom ranges |
|
|
323
|
+
| 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) => {}` |
|
|
324
|
+
|
|
325
|
+
<a name="Ranges"></a>
|
|
326
|
+
|
|
327
|
+
## Ranges : <code>Object</code>
|
|
328
|
+
A set of predefined ranges.<br>
|
|
329
|
+
Ranges are not validated against `minDate`, `maxDate`, `minSpan`, `maxSpan` or `timePickerStepSize ` constraints.
|
|
330
|
+
|
|
331
|
+
**Kind**: global typedef
|
|
332
|
+
**Properties**
|
|
333
|
+
|
|
334
|
+
| Name | Type | Description |
|
|
335
|
+
| --- | --- | --- |
|
|
336
|
+
| name | <code>string</code> | The name of the range |
|
|
337
|
+
| range | [<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> | Array of 2 elements with `startDate` and `endDate` |
|
|
338
|
+
|
|
339
|
+
**Example**
|
|
340
|
+
```js
|
|
341
|
+
{
|
|
342
|
+
'Today': [DateTime.now().startOf('day'), DateTime.now().endOf('day')],
|
|
343
|
+
'Yesterday': [DateTime.now().startOf('day').minus({days: 1}), DateTime.now().minus({days: 1}).endOf('day')],
|
|
344
|
+
'Last 7 Days': [DateTime.now().startOf('day').minus({days: 6}), DateTime.now()],
|
|
345
|
+
'Last 30 Days': [DateTime.now().startOf('day').minus({days: 29}), DateTime.now()],
|
|
346
|
+
'This Month': [DateTime.now().startOf('day').startOf('month'), DateTime.now().endOf('month')],
|
|
347
|
+
'Last Month': [DateTime.now().startOf('day').minus({months: 1}).startOf('month'), DateTime.now().minus({months: 1}).endOf('month')]
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
<a name="Range"></a>
|
|
351
|
+
|
|
352
|
+
## Range : <code>Object</code>
|
|
353
|
+
A single predefined range
|
|
354
|
+
|
|
355
|
+
**Kind**: global typedef
|
|
356
|
+
**Properties**
|
|
357
|
+
|
|
358
|
+
| Name | Type | Description |
|
|
359
|
+
| --- | --- | --- |
|
|
360
|
+
| name | <code>string</code> | The name of the range |
|
|
361
|
+
| range | [<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> | Array of 2 elements with startDate and endDate |
|
|
362
|
+
|
|
363
|
+
**Example**
|
|
364
|
+
```js
|
|
365
|
+
{ Today: [DateTime.now().startOf('day'), DateTime.now().endOf('day')] }
|
|
366
|
+
```
|
|
367
|
+
<a name="InputViolation"></a>
|
|
368
|
+
|
|
369
|
+
## InputViolation : <code>Object</code>
|
|
370
|
+
**Kind**: global typedef
|
|
371
|
+
**Properties**
|
|
372
|
+
|
|
373
|
+
| Name | Type | Description |
|
|
374
|
+
| --- | --- | --- |
|
|
375
|
+
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Violation of startDate |
|
|
376
|
+
| endDate? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| <code>undefined</code> | Violation of endDate, if existing |
|
|
377
|
+
| violations | <code>Array</code> | The constraints which violates the input |
|
|
378
|
+
| reason | <code>Array</code> | The type/reson of violation |
|
|
379
|
+
| old | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Old value startDate/endDate |
|
|
380
|
+
| new? | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Corrected value of startDate/endDate if existing |
|
|
381
|
+
|
|
382
|
+
<a name="callback"></a>
|
|
383
|
+
|
|
384
|
+
## callback : <code>function</code>
|
|
385
|
+
**Kind**: global typedef
|
|
386
|
+
|
|
387
|
+
| Param | Type | Description |
|
|
388
|
+
| --- | --- | --- |
|
|
389
|
+
| startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Selected startDate |
|
|
390
|
+
| endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) | Selected endDate |
|
|
391
|
+
| range | <code>string</code> | |
|
|
392
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wernfried/daterangepicker",
|
|
3
|
-
"version": "4.17.
|
|
3
|
+
"version": "4.17.1",
|
|
4
4
|
"description": "Date range picker with time component and pre-defined ranges",
|
|
5
5
|
"main": "dist/global/daterangepicker.js",
|
|
6
6
|
"module": "dist/esm/daterangepicker.js",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"jest": "^30.3.0",
|
|
40
40
|
"jest-environment-jsdom": "^30.3.0",
|
|
41
41
|
"jsdoc-to-markdown": "^9.1.3",
|
|
42
|
-
"jsdoc2md": "^1.0.0",
|
|
43
42
|
"minify": "^15.2.0"
|
|
44
43
|
},
|
|
45
44
|
"author": {
|