daterangepicker-4.x 4.2.2 → 4.2.3

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 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.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" />
21
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.2.3/daterangepicker.min.js"></script>
22
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.2.3/daterangepicker.min.css" rel="stylesheet" />
23
23
 
24
24
  <input type="text" id="daterange" />
25
25
 
@@ -107,6 +107,16 @@ In original daterangepicker this parameter defines whether the `<input>` is upda
107
107
  - Added option `locale.durationFormat` to show customized label for selected duration, e.g. `'4 Days, 6 Hours, 30 Minutes'`
108
108
  - ... and maybe some new bugs 😉
109
109
 
110
+ ## Methods
111
+
112
+ Available methods are listed below in [API documentation](#DateRangePicker). You will mainly use
113
+ * [.daterangepicker(options, callback)](#DateRangePicker.daterangepicker)
114
+ * [.setStartDate(startDate)](#DateRangePicker+setStartDate)
115
+ * [.setEndDate(endDate)](#DateRangePicker+setEndDate)
116
+ * [.setPeriod(startDate, endDate)](#DateRangePicker+setPeriod)
117
+
118
+ all other methods are used rarely.
119
+
110
120
  ### Differences between `moment` and `luxon` library
111
121
  This table lists a few important differences between datarangepicker using moment and luxon. Check them carefully when you migrate from older daterangepicker.
112
122
 
@@ -154,8 +164,7 @@ Licensed under the [MIT license](LICENSE).
154
164
  </dd>
155
165
  <dt><a href="#event_outsideClick.daterangepicker">"outsideClick.daterangepicker" (this)</a></dt>
156
166
  <dd><p>Emitted when user clicks outside the picker.
157
- Picker values is not updated, you may trigger <a href="#event_apply.daterangepicker">&quot;apply.daterangepicker&quot;</a>
158
- or <a href="#event_cancel.daterangepicker">&quot;cancel.daterangepicker&quot;</a> in your EventHandler.</p>
167
+ Use option <code>onOutsideClick</code> to define the default action, then you may not need to handle this event.</p>
159
168
  </dd>
160
169
  <dt><a href="#event_showCalendar.daterangepicker">"showCalendar.daterangepicker" (this)</a></dt>
161
170
  <dd><p>Emitted when the calendar(s) are shown.
@@ -208,7 +217,10 @@ use <a href="#event_timeChange.daterangepicker">&quot;timeChange.daterangepicker
208
217
  * [.setEndDate(endDate, isValid)](#DateRangePicker+setEndDate)
209
218
  * [.setPeriod(startDate, endDate, isValid)](#DateRangePicker+setPeriod)
210
219
  * [.updateView()](#DateRangePicker+updateView)
211
- * [.outsideClick(e)](#DateRangePicker+outsideClick)
220
+ * [.showCalendars()](#DateRangePicker+showCalendars)
221
+ * [.hideCalendars()](#DateRangePicker+hideCalendars)
222
+ * [.updateElement()](#DateRangePicker+updateElement)
223
+ * [.remove()](#DateRangePicker+remove)
212
224
  * _static_
213
225
  * [.daterangepicker(options, callback)](#DateRangePicker.daterangepicker) ⇒
214
226
 
@@ -218,7 +230,7 @@ use <a href="#event_timeChange.daterangepicker">&quot;timeChange.daterangepicker
218
230
 
219
231
  | Param | Type | Description |
220
232
  | --- | --- | --- |
221
- | element | [<code>jQuery</code>](https://learn.jquery.com/using-jquery-core/jquery-object/) | jQuery selector of the parent element that the date range picker will be added to |
233
+ | 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 |
222
234
  | options | [<code>Options</code>](#Options) | Object to configure the DateRangePicker |
223
235
  | cb | <code>function</code> | Callback function executed when |
224
236
 
@@ -308,18 +320,33 @@ Updates the picker when calendar is initiated or any date has been selected.
308
320
  Could be useful after running [setStartDate](#DateRangePicker+setStartDate) or [setEndDate](#DateRangePicker+setEndDate)
309
321
 
310
322
  **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
311
- <a name="DateRangePicker+outsideClick"></a>
323
+ <a name="DateRangePicker+showCalendars"></a>
312
324
 
313
- ### dateRangePicker.outsideClick(e)
314
- Closes the picker when user clicks outside
325
+ ### dateRangePicker.showCalendars()
326
+ Shows calendar when user selects "Custom Ranges"
315
327
 
316
328
  **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
317
- **Emits**: <code>event:&quot;outsideClick.daterangepicker&quot;</code>
329
+ **Emits**: <code>event:&quot;showCalendar.daterangepicker&quot;</code>
330
+ <a name="DateRangePicker+hideCalendars"></a>
318
331
 
319
- | Param | Type | Description |
320
- | --- | --- | --- |
321
- | e | [<code>jQuery</code>](https://learn.jquery.com/using-jquery-core/jquery-object/) | The Event target |
332
+ ### dateRangePicker.hideCalendars()
333
+ Hides calendar when user selects a predefined range
334
+
335
+ **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
336
+ **Emits**: <code>event:&quot;hideCalendar.daterangepicker&quot;</code>
337
+ <a name="DateRangePicker+updateElement"></a>
338
+
339
+ ### dateRangePicker.updateElement()
340
+ Update attached `<input>` element with selected value
341
+
342
+ **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
343
+ **Emits**: [<code>change</code>](https://api.jquery.com/change/)
344
+ <a name="DateRangePicker+remove"></a>
345
+
346
+ ### dateRangePicker.remove()
347
+ Removes the picker from document
322
348
 
349
+ **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
323
350
  <a name="DateRangePicker.daterangepicker"></a>
324
351
 
325
352
  ### DateRangePicker.daterangepicker(options, callback) ⇒
@@ -331,7 +358,7 @@ Initiate a new DateRangePicker
331
358
  | Param | Type | Description |
332
359
  | --- | --- | --- |
333
360
  | options | [<code>Options</code>](#Options) | Object to configure the DateRangePicker |
334
- | callback | [<code>callback</code>](#callback) | Callback function executed when date is changed. As alternative listen to the ["apply.daterangepicker"](#event_apply.daterangepicker) event |
361
+ | 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 |
335
362
 
336
363
  <a name="event_show.daterangepicker"></a>
337
364
 
@@ -371,8 +398,7 @@ Emitted when the picker is hidden
371
398
 
372
399
  ## "outsideClick.daterangepicker" (this)
373
400
  Emitted when user clicks outside the picker.
374
- Picker values is not updated, you may trigger ["apply.daterangepicker"](#event_apply.daterangepicker)
375
- or ["cancel.daterangepicker"](#event_cancel.daterangepicker) in your EventHandler.
401
+ Use option `onOutsideClick` to define the default action, then you may not need to handle this event.
376
402
 
377
403
  **Kind**: event emitted
378
404
 
@@ -1046,7 +1046,7 @@
1046
1046
  },
1047
1047
 
1048
1048
  /**
1049
- * Displays the months
1049
+ * Shows calendar months based on selected date values
1050
1050
  * @private
1051
1051
  */
1052
1052
  updateMonthsInView: function () {
@@ -1086,7 +1086,7 @@
1086
1086
  },
1087
1087
 
1088
1088
  /**
1089
- * Updates the custome ranges
1089
+ * Updates the selected day value from calendar with selected time values
1090
1090
  * @private
1091
1091
  */
1092
1092
  updateCalendars: function () {
@@ -1569,7 +1569,7 @@
1569
1569
  },
1570
1570
 
1571
1571
  /**
1572
- * Update the linke `<input>` element with selected date
1572
+ * Disable the `Apply` button if no date value is selected
1573
1573
  * @private
1574
1574
  */
1575
1575
  updateFormInputs: function () {
@@ -1582,7 +1582,7 @@
1582
1582
  },
1583
1583
 
1584
1584
  /**
1585
- * Positions the calendar
1585
+ * Place the picker at the right place in the document
1586
1586
  * @private
1587
1587
  */
1588
1588
  move: function () {
@@ -1784,6 +1784,7 @@
1784
1784
  * Closes the picker when user clicks outside
1785
1785
  * @param {external:jQuery} e - The Event target
1786
1786
  * @emits "outsideClick.daterangepicker"
1787
+ * @private
1787
1788
  */
1788
1789
  outsideClick: function (e) {
1789
1790
  var target = $(e.target);
@@ -1805,8 +1806,7 @@
1805
1806
 
1806
1807
  /**
1807
1808
  * Emitted when user clicks outside the picker.
1808
- * Picker values is not updated, you may trigger {@link #event_apply.daterangepicker|"apply.daterangepicker"}
1809
- * or {@link #event_cancel.daterangepicker|"cancel.daterangepicker"} in your EventHandler.
1809
+ * Use option `onOutsideClick` to define the default action, then you may not need to handle this event.
1810
1810
  * @event
1811
1811
  * @name "outsideClick.daterangepicker"
1812
1812
  * @param {DateRangePicker} this - The daterangepicker object
@@ -1817,7 +1817,6 @@
1817
1817
  /**
1818
1818
  * Shows calendar when user selects "Custom Ranges"
1819
1819
  * @emits "showCalendar.daterangepicker"
1820
- * @private
1821
1820
  */
1822
1821
  showCalendars: function () {
1823
1822
  this.container.addClass('show-calendar');
@@ -1835,7 +1834,6 @@
1835
1834
  /**
1836
1835
  * Hides calendar when user selects a predefined range
1837
1836
  * @emits "hideCalendar.daterangepicker"
1838
- * @private
1839
1837
  */
1840
1838
  hideCalendars: function () {
1841
1839
  this.container.removeClass('show-calendar');
@@ -2114,7 +2112,6 @@
2114
2112
 
2115
2113
  /**
2116
2114
  * Hightlight selected predefined range in calendar
2117
- * @param {external:jQuery} e - The Event target
2118
2115
  * @private
2119
2116
  */
2120
2117
  calculateChosenLabel: function () {
@@ -2310,10 +2307,12 @@
2310
2307
  },
2311
2308
 
2312
2309
  /**
2313
- * User inserted value into `<input>`
2310
+ * Update the picker with value from attached `<input>` element.
2311
+ * Error is written to console if input string cannot be parsed as a valid date/range
2312
+ * @param {external:jQuery} e - The Event target
2314
2313
  * @private
2315
2314
  */
2316
- elementChanged: function () {
2315
+ elementChanged: function (e) {
2317
2316
  if (!this.element.is('input')) return;
2318
2317
  if (!this.element.val().length) return;
2319
2318
 
@@ -2331,7 +2330,10 @@
2331
2330
  end = start;
2332
2331
  }
2333
2332
 
2334
- if (!start.isValid || !end.isValid) return;
2333
+ if (!start.isValid || !end.isValid) {
2334
+ console.error(`Input string '${dateString}' is not valid`);
2335
+ return;
2336
+ }
2335
2337
 
2336
2338
  this.setStartDate(start, false);
2337
2339
  this.setEndDate(end, false);
@@ -2339,7 +2341,7 @@
2339
2341
  },
2340
2342
 
2341
2343
  /**
2342
- * Handles key press
2344
+ * Handles key press, IE 11 compatibility
2343
2345
  * @param {external:jQuery} e - The Event target
2344
2346
  * @private
2345
2347
  */
@@ -2359,8 +2361,8 @@
2359
2361
  },
2360
2362
 
2361
2363
  /**
2362
- * Update linked `<input>` element with selected value
2363
- * @private
2364
+ * Update attached `<input>` element with selected value
2365
+ * @emits external:change
2364
2366
  */
2365
2367
  updateElement: function () {
2366
2368
  if (this.startDate == null && this.initalMonth)
@@ -2379,8 +2381,7 @@
2379
2381
  },
2380
2382
 
2381
2383
  /**
2382
- * Remove the picker from document
2383
- * @private
2384
+ * Removes the picker from document
2384
2385
  */
2385
2386
  remove: function () {
2386
2387
  this.container.remove();
@@ -2402,8 +2403,9 @@
2402
2403
  * @name DateRangePicker.daterangepicker
2403
2404
  * @function
2404
2405
  * @param {Options} options - Object to configure the DateRangePicker
2405
- * @param {callback} callback - Callback function executed when date is changed.
2406
- * As alternative listen to the {@link #event_apply.daterangepicker|"apply.daterangepicker"} event
2406
+ * @param {callback} callback - Callback function executed when date is changed.<br/>
2407
+ * Callback function is executed if selected date values has changed, before picker is hidden and before the attached `<input>` element is updated.
2408
+ * As alternative listen to the {@link #event_apply.daterangepicker|"apply.daterangepicker"} event
2407
2409
  * @returns DateRangePicker
2408
2410
  */
2409
2411
  $.fn.daterangepicker = function (options, callback) {
@@ -2423,10 +2425,13 @@
2423
2425
 
2424
2426
 
2425
2427
  /** @external jQuery
2426
- @see {@link https://learn.jquery.com/using-jquery-core/jquery-object/|jQuery} */
2428
+ @see {@link https://api.jquery.com/Types/#jQuery/|jQuery} */
2427
2429
 
2428
2430
  /** @external Selector
2429
- @see {@link https://learn.jquery.com/using-jquery-core/jquery-object/|jQuery Selector} */
2431
+ @see {@link https://api.jquery.com/category/selectors/|jQuery Selector} */
2432
+
2433
+ /** @external change
2434
+ @see {@link https://api.jquery.com/change/|change event} */
2430
2435
 
2431
2436
  /** @external DateTime
2432
2437
  @see {@link https://moment.github.io/luxon/api-docs/index.html#datetime|DateTime} */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daterangepicker-4.x",
3
- "version": "4.2.2",
3
+ "version": "4.2.3",
4
4
  "description": "Date range picker with time component and pre-defined ranges",
5
5
  "main": "daterangepicker.js",
6
6
  "style": "daterangepicker.css",