daterangepicker-4.x 4.1.8 → 4.1.9

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.1.8/daterangepicker.min.js"></script>
22
- <link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.1.8/daterangepicker.min.css" rel="stylesheet" />
21
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.1.9/daterangepicker.min.js"></script>
22
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.1.9/daterangepicker.min.css" rel="stylesheet" />
23
23
 
24
24
  <input type="text" id="daterange" />
25
25
 
@@ -215,9 +215,9 @@ use <a href="#event_timeChange.daterangepicker">&quot;timeChange.daterangepicker
215
215
  * [DateRangePicker](#DateRangePicker)
216
216
  * [new DateRangePicker(element, options, cb)](#new_DateRangePicker_new)
217
217
  * _instance_
218
- * [.setStartDate(startDate)](#DateRangePicker+setStartDate)
219
- * [.setEndDate(endDate)](#DateRangePicker+setEndDate)
220
- * [.setPeriod(startDate, endDate)](#DateRangePicker+setPeriod)
218
+ * [.setStartDate(startDate, isValid)](#DateRangePicker+setStartDate)
219
+ * [.setEndDate(endDate, isValid)](#DateRangePicker+setEndDate)
220
+ * [.setPeriod(startDate, endDate, isValid)](#DateRangePicker+setPeriod)
221
221
  * [.updateView()](#DateRangePicker+updateView)
222
222
  * [.outsideClick(e)](#DateRangePicker+outsideClick)
223
223
  * _static_
@@ -235,7 +235,7 @@ use <a href="#event_timeChange.daterangepicker">&quot;timeChange.daterangepicker
235
235
 
236
236
  <a name="DateRangePicker+setStartDate"></a>
237
237
 
238
- ### dateRangePicker.setStartDate(startDate)
238
+ ### dateRangePicker.setStartDate(startDate, isValid)
239
239
  Sets the date range picker's currently selected start date to the provided date.<br/>
240
240
  `startDate` must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](ISO-8601) or
241
241
  a string matching `locale.format`.
@@ -250,9 +250,10 @@ If the `startDate` does not fall into `minDate` and `maxDate` then `startDate` i
250
250
  - `RangeError` for invalid date values.
251
251
 
252
252
 
253
- | Param | Type | Description |
254
- | --- | --- | --- |
255
- | 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 |
253
+ | Param | Type | Default | Description |
254
+ | --- | --- | --- | --- |
255
+ | 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 |
256
+ | isValid | <code>boolean</code> | <code>false</code> | If `true` then the `startDate` is not checked against `minDate` and `maxDate`<br/> Use this option only if you are really sure about the value you put in. |
256
257
 
257
258
  **Example**
258
259
  ```js
@@ -262,7 +263,7 @@ drp.setStartDate(DateTime.now().startOf('hour'));
262
263
  ```
263
264
  <a name="DateRangePicker+setEndDate"></a>
264
265
 
265
- ### dateRangePicker.setEndDate(endDate)
266
+ ### dateRangePicker.setEndDate(endDate, isValid)
266
267
  Sets the date range picker's currently selected end date to the provided date.<br/>
267
268
  `endDate` must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](ISO-8601) or
268
269
  a string matching`locale.format`.
@@ -278,9 +279,10 @@ then `endDate` is shifted and a warning is written to console.
278
279
  - `RangeError` for invalid date values.
279
280
 
280
281
 
281
- | Param | Type | Description |
282
- | --- | --- | --- |
283
- | 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 |
282
+ | Param | Type | Default | Description |
283
+ | --- | --- | --- | --- |
284
+ | 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 |
285
+ | isValid | <code>boolean</code> | <code>false</code> | If `true` then the `endDate` is not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/> Use this option only if you are really sure about the value you put in. |
284
286
 
285
287
  **Example**
286
288
  ```js
@@ -289,7 +291,7 @@ drp.setEndDate('2025-03-28T18:30:00');
289
291
  ```
290
292
  <a name="DateRangePicker+setPeriod"></a>
291
293
 
292
- ### dateRangePicker.setPeriod(startDate, endDate)
294
+ ### dateRangePicker.setPeriod(startDate, endDate, isValid)
293
295
  Shortcut for [setStartDate](#DateRangePicker+setStartDate) and [setEndDate](#DateRangePicker+setEndDate)
294
296
 
295
297
  **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
@@ -298,10 +300,11 @@ Shortcut for [setStartDate](#DateRangePicker+setStartDate) and [setEndDate](#Dat
298
300
  - `RangeError` for invalid date values.
299
301
 
300
302
 
301
- | Param | Type | Description |
302
- | --- | --- | --- |
303
- | 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 |
304
- | 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 |
303
+ | Param | Type | Default | Description |
304
+ | --- | --- | --- | --- |
305
+ | 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 |
306
+ | 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 |
307
+ | isValid | <code>boolean</code> | <code>false</code> | If `true` then the `startDate` and `endDate` are not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/> Use this option only if you are really sure about the value you put in. |
305
308
 
306
309
  **Example**
307
310
  ```js
@@ -685,12 +685,14 @@
685
685
  * Functions `isInvalidDate` and `isInvalidTime` are not evaluated, you may set date/time which is not selectable in calendar.<br/>
686
686
  * If the `startDate` does not fall into `minDate` and `maxDate` then `startDate` is shifted and a warning is written to console.
687
687
  * @param {external:DateTime|external:Date|string} startDate - startDate to be set
688
+ * @param {boolean} isValid=false - If `true` then the `startDate` is not checked against `minDate` and `maxDate`<br/>
689
+ * Use this option only if you are really sure about the value you put in.
688
690
  * @throws `RangeError` for invalid date values.
689
691
  * @example const DateTime = luxon.DateTime;
690
692
  * const drp = $('#picker').data('daterangepicker');
691
693
  * drp.setStartDate(DateTime.now().startOf('hour'));
692
694
  */
693
- setStartDate: function (startDate, isValid) {
695
+ setStartDate: function (startDate, isValid = false) {
694
696
  // If isValid == true, then value is selected from calendar and stepSize, minDate, maxDate are already considered
695
697
  if (isValid === undefined || !isValid) {
696
698
  if (typeof startDate === 'object') {
@@ -734,11 +736,13 @@
734
736
  * If the `endDate` does not fall into `minDate` and `maxDate` or into `minSpan` and `maxSpan`
735
737
  * then `endDate` is shifted and a warning is written to console.
736
738
  * @param {external:DateTime|external:Date|string} endDate - endDate to be set
739
+ * @param {boolean} isValid=false - If `true` then the `endDate` is not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/>
740
+ * Use this option only if you are really sure about the value you put in.
737
741
  * @throws `RangeError` for invalid date values.
738
742
  * @example const drp = $('#picker').data('daterangepicker');
739
743
  * drp.setEndDate('2025-03-28T18:30:00');
740
744
  */
741
- setEndDate: function (endDate, isValid) {
745
+ setEndDate: function (endDate, isValid = false) {
742
746
  // If isValid == true, then value is selected from calendar and stepSize, minDate, maxDate are already considered
743
747
  if (isValid === undefined || !isValid) {
744
748
  if (typeof endDate === 'object') {
@@ -792,17 +796,21 @@
792
796
  * Shortcut for {@link #DateRangePicker+setStartDate|setStartDate} and {@link #DateRangePicker+setEndDate|setEndDate}
793
797
  * @param {external:DateTime|external:Date|string} startDate - startDate to be set
794
798
  * @param {external:DateTime|external:Date|string} endDate - endDate to be set
799
+ * @param {boolean} isValid=false - If `true` then the `startDate` and `endDate` are not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/>
800
+ * Use this option only if you are really sure about the value you put in.
795
801
  * @throws `RangeError` for invalid date values.
796
802
  * @example const DateTime = luxon.DateTime;
797
803
  * const drp = $('#picker').data('daterangepicker');
798
804
  * drp.setPeriod(DateTime.now().startOf('week'), DateTime.now().startOf('week').plus({days: 10}));
799
805
  */
800
- setPeriod: function (startDate, endDate) {
806
+ setPeriod: function (startDate, endDate, isValid = false) {
801
807
  if (this.singleDatePicker) {
802
- this.setStartDate(startDate, false);
808
+ this.setStartDate(startDate, isValid);
803
809
  } else {
804
- this.setStartDate(startDate, false);
805
- this.setEndDate(endDate, false);
810
+ this.setStartDate(startDate, true);
811
+ this.setEndDate(endDate, true);
812
+ if (!isValid)
813
+ this.constrainDate();
806
814
  }
807
815
  },
808
816
 
@@ -898,6 +906,9 @@
898
906
  }
899
907
  }
900
908
 
909
+ if (endDate == null)
910
+ return;
911
+
901
912
  if (stepSize && this.timePicker) {
902
913
  // Round time to step size
903
914
  const secs = this.timePickerStepSize.as('seconds');
@@ -2357,7 +2368,7 @@
2357
2368
  * @param {external:DateTime} endDate - Selected endDate
2358
2369
  * @param {string} range
2359
2370
  */
2360
-
2371
+
2361
2372
  /**
2362
2373
  * Initiate a new DateRangePicker
2363
2374
  * @name DateRangePicker.daterangepicker
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daterangepicker-4.x",
3
- "version": "4.1.8",
3
+ "version": "4.1.9",
4
4
  "description": "Date range picker with time component and pre-defined ranges",
5
5
  "main": "daterangepicker.js",
6
6
  "style": "daterangepicker.css",