daterangepicker-4.x 4.9.4 → 4.9.6

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.9.4/daterangepicker.min.js"></script>
22
- <link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.9.4/daterangepicker.min.css" rel="stylesheet" />
21
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.9.6/daterangepicker.min.js"></script>
22
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.9.6/daterangepicker.min.css" rel="stylesheet" />
23
23
 
24
24
  <input type="text" id="daterange" />
25
25
 
@@ -608,7 +608,7 @@ Options for DateRangePicker
608
608
  | 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` |
609
609
  | 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` |
610
610
  | 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/> The start and end dates provided to your callback will be the same single date chosen. |
611
- | singleMonthView | <code>boolean</code> | <code>false</code> | Show only a single month calendar, useful when typically selected ranges are rather short.<br/> Ignored for `singleDatePicker: true`. |
611
+ | 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`. |
612
612
  | showDropdowns | <code>boolean</code> | <code>false</code> | Show year and month select boxes above calendars to jump to a specific month and year |
613
613
  | minYear | <code>number</code> | | Default: `DateTime.now().minus({year:100}).year`<br/>The minimum year shown in the dropdowns when `showDropdowns: true` |
614
614
  | maxYear | <code>number</code> | | Default: `DateTime.now().plus({year:100}).year`<br/>The maximum year shown in the dropdowns when `showDropdowns: true` |
@@ -70,7 +70,8 @@
70
70
  * Only useful when `timePicker: false`
71
71
  * @property {boolean} singleDatePicker=false - Show only a single calendar to choose one date, instead of a range picker with two calendars.<br/>
72
72
  * The start and end dates provided to your callback will be the same single date chosen.
73
- * @property {boolean} singleMonthView=false - Show only a single month calendar, useful when typically selected ranges are rather short.<br/>
73
+ * @property {boolean} singleMonthView=false - Show only a single month calendar, useful when selected ranges are usually short<br/>
74
+ * or for smaller viewports like mobile devices.<br/>
74
75
  * Ignored for `singleDatePicker: true`.
75
76
  * @property {boolean} showDropdowns=false - Show year and month select boxes above calendars to jump to a specific month and year
76
77
  * @property {number} minYear - Default: `DateTime.now().minus({year:100}).year`<br/>The minimum year shown in the dropdowns when `showDropdowns: true`
@@ -453,7 +454,7 @@
453
454
  }
454
455
 
455
456
  for (let opt of ['startDate', 'endDate', 'minDate', 'maxDate', 'initalMonth']) {
456
- if (opt == 'endDate' && this.singleDatePicker)
457
+ if (opt === 'endDate' && this.singleDatePicker)
457
458
  continue;
458
459
  if (typeof options[opt] === 'object') {
459
460
  if (options[opt] instanceof DateTime && options[opt].isValid) {
@@ -492,7 +493,7 @@
492
493
  if (val != '') {
493
494
  const split = val.split(this.locale.separator);
494
495
  const format = typeof this.locale.format === 'string' ? this.locale.format : DateTime.parseFormatForOpts(this.locale.format);
495
- if (split.length == 2) {
496
+ if (split.length === 2) {
496
497
  start = DateTime.fromFormat(split[0], format, { locale: DateTime.now().locale });
497
498
  end = DateTime.fromFormat(split[1], format, { locale: DateTime.now().locale });
498
499
  } else if (this.singleDatePicker) {
@@ -525,7 +526,7 @@
525
526
  if (['object', 'string'].includes(typeof options.altInput) && options.altInput != null) {
526
527
  if (this.singleDatePicker && typeof options.altInput === 'string') {
527
528
  this.altInput = options.altInput
528
- } else if (!this.singleDatePicker && Array.isArray(options.altInput) && options.altInput.length == 2) {
529
+ } else if (!this.singleDatePicker && Array.isArray(options.altInput) && options.altInput.length === 2) {
529
530
  this.altInput = options.altInput;
530
531
  }
531
532
  }
@@ -978,7 +979,7 @@
978
979
  }
979
980
  }
980
981
 
981
- if (result.startDate.modified.length == 0)
982
+ if (result.startDate.modified.length === 0)
982
983
  delete result.startDate.modified;
983
984
 
984
985
  if (this.singleDatePicker) {
@@ -1090,7 +1091,7 @@
1090
1091
  }
1091
1092
  }
1092
1093
 
1093
- if (result.endDate.modified.length == 0)
1094
+ if (result.endDate.modified.length === 0)
1094
1095
  delete result.endDate.modified;
1095
1096
 
1096
1097
  if (range === undefined) {
@@ -1263,13 +1264,13 @@
1263
1264
  * @private
1264
1265
  */
1265
1266
  renderCalendar: function (side) {
1266
- if (side == 'right' && this.singleMonthView)
1267
+ if (side === 'right' && this.singleMonthView)
1267
1268
  return;
1268
1269
 
1269
1270
  //
1270
1271
  // Build the matrix of dates that will populate the calendar
1271
1272
  //
1272
- var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
1273
+ var calendar = side === 'left' ? this.leftCalendar : this.rightCalendar;
1273
1274
  if (calendar.month == null && !this.startDate && this.initalMonth)
1274
1275
  calendar.month = this.initalMonth.startOf('month');
1275
1276
 
@@ -1297,7 +1298,7 @@
1297
1298
  }
1298
1299
 
1299
1300
  //make the calendar object available to hoverDate/clickDate
1300
- if (side == 'left') {
1301
+ if (side === 'left') {
1301
1302
  this.leftCalendar.calendar = calendar;
1302
1303
  } else {
1303
1304
  this.rightCalendar.calendar = calendar;
@@ -1307,10 +1308,10 @@
1307
1308
  // Display the calendar
1308
1309
  //
1309
1310
 
1310
- var minDate = side == 'left' ? this.minDate : this.startDate;
1311
+ var minDate = side === 'left' ? this.minDate : this.startDate;
1311
1312
  var maxDate = this.maxDate;
1312
- var selected = side == 'left' ? this.startDate : this.endDate;
1313
- var arrow = this.locale.direction == 'ltr' ? { left: 'chevron-left', right: 'chevron-right' } : { left: 'chevron-right', right: 'chevron-left' };
1313
+ var selected = side === 'left' ? this.startDate : this.endDate;
1314
+ var arrow = this.locale.direction === 'ltr' ? { left: 'chevron-left', right: 'chevron-right' } : { left: 'chevron-right', right: 'chevron-left' };
1314
1315
 
1315
1316
  var html = '<table class="table-condensed">';
1316
1317
  html += '<thead>';
@@ -1320,7 +1321,7 @@
1320
1321
  if (this.showWeekNumbers || this.showISOWeekNumbers)
1321
1322
  html += '<th></th>';
1322
1323
 
1323
- if ((!minDate || minDate < calendar.firstDay) && (!this.linkedCalendars || side == 'left')) {
1324
+ if ((!minDate || minDate < calendar.firstDay) && (!this.linkedCalendars || side === 'left')) {
1324
1325
  html += '<th class="prev available"><span></span></th>';
1325
1326
  } else {
1326
1327
  html += '<th></th>';
@@ -1350,7 +1351,7 @@
1350
1351
  }
1351
1352
 
1352
1353
  html += '<th colspan="5" class="month">' + dateHtml + '</th>';
1353
- if ((!maxDate || maxDate > calendar.lastDay.endOf('day')) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker || this.singleMonthView)) {
1354
+ if ((!maxDate || maxDate > calendar.lastDay.endOf('day')) && (!this.linkedCalendars || side === 'right' || this.singleDatePicker || this.singleMonthView)) {
1354
1355
  html += '<th class="next available"><span></span></th>';
1355
1356
  } else {
1356
1357
  html += '<th></th>';
@@ -1483,7 +1484,7 @@
1483
1484
 
1484
1485
  // Don't bother updating the time picker if it's currently disabled
1485
1486
  // because an end date hasn't been clicked yet
1486
- if (side == 'end' && !this.endDate) return;
1487
+ if (side === 'end' && !this.endDate) return;
1487
1488
 
1488
1489
  var selected, minLimit, minDate, maxDate = this.maxDate;
1489
1490
  let html = '';
@@ -1491,13 +1492,13 @@
1491
1492
  if (this.maxSpan && (!this.maxDate || this.startDate.plus(this.maxSpan) < this.maxDate))
1492
1493
  maxDate = this.startDate.plus(this.maxSpan);
1493
1494
 
1494
- if (this.minSpan && side == 'end')
1495
+ if (this.minSpan && side === 'end')
1495
1496
  minLimit = this.startDate.plus(this.minSpan);
1496
1497
 
1497
- if (side == 'start') {
1498
+ if (side === 'start') {
1498
1499
  selected = this.startDate;
1499
1500
  minDate = this.minDate;
1500
- } else if (side == 'end') {
1501
+ } else if (side === 'end') {
1501
1502
  selected = this.endDate;
1502
1503
  minDate = this.startDate;
1503
1504
 
@@ -1523,13 +1524,13 @@
1523
1524
  //
1524
1525
 
1525
1526
  //if (this.singleMonthView) // to do: localization options
1526
- // html = `<span style="font-family: arial; font-size: 12px;">${side == 'start' ? 'Start' : 'End'}: </span>`;
1527
+ // html = `<span style="font-family: arial; font-size: 12px;">${side === 'start' ? 'Start' : 'End'}: </span>`;
1527
1528
 
1528
1529
  html += '<select class="hourselect">';
1529
1530
  const ampm = selected.toFormat('a', { locale: 'en-US' });
1530
1531
  let start = 0;
1531
1532
  if (!this.timePicker24Hour)
1532
- start = ampm == 'AM' ? 1 : 13;
1533
+ start = ampm === 'AM' ? 1 : 13;
1533
1534
 
1534
1535
  for (var i = start; i <= start + 23; i += this.timePickerOpts.hourStep) {
1535
1536
  let time = selected.set({ hour: i % 24 });
@@ -1658,7 +1659,7 @@
1658
1659
  pm_html = ' disabled="disabled" class="disabled"';
1659
1660
  } else {
1660
1661
  if (this.isInvalidTime(selected, this.singleDatePicker ? null : side, 'ampm')) {
1661
- if (selected.toFormat('a', { locale: 'en-US' }) == 'AM') {
1662
+ if (selected.toFormat('a', { locale: 'en-US' }) === 'AM') {
1662
1663
  pm_html = ' disabled="disabled" class="disabled"';
1663
1664
  } else {
1664
1665
  am_html = ' disabled="disabled" class="disabled"';
@@ -1667,10 +1668,10 @@
1667
1668
  }
1668
1669
 
1669
1670
  html += `<option value="AM"${am_html}`;
1670
- if (selected.toFormat('a', { locale: 'en-US' }) == 'AM')
1671
+ if (selected.toFormat('a', { locale: 'en-US' }) === 'AM')
1671
1672
  html += ' selected="selected"';
1672
1673
  html += `>${Info.meridiems()[0]}</option><option value="PM"${pm_html}`;
1673
- if (selected.toFormat('a', { locale: 'en-US' }) == 'PM')
1674
+ if (selected.toFormat('a', { locale: 'en-US' }) === 'PM')
1674
1675
  html += ' selected="selected"';
1675
1676
  html += `>${Info.meridiems()[1]}</option>`;
1676
1677
 
@@ -1736,9 +1737,9 @@
1736
1737
  });
1737
1738
  var containerWidth = this.container.outerWidth();
1738
1739
 
1739
- this.container.toggleClass('drop-up', drops == 'up');
1740
+ this.container.toggleClass('drop-up', drops === 'up');
1740
1741
 
1741
- if (this.opens == 'left') {
1742
+ if (this.opens === 'left') {
1742
1743
  var containerRight = parentRightEdge - this.element.offset().left - this.element.outerWidth();
1743
1744
  if (containerWidth + containerRight > $(window).width()) {
1744
1745
  this.container.css({
@@ -1753,7 +1754,7 @@
1753
1754
  left: 'auto'
1754
1755
  });
1755
1756
  }
1756
- } else if (this.opens == 'center') {
1757
+ } else if (this.opens === 'center') {
1757
1758
  var containerLeft = this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2 - containerWidth / 2;
1758
1759
  if (containerLeft < 0) {
1759
1760
  this.container.css({
@@ -1904,13 +1905,13 @@
1904
1905
  // itself then call this.hide()
1905
1906
  if (
1906
1907
  // ie modal dialog fix
1907
- e.type == "focusin" ||
1908
+ e.type === "focusin" ||
1908
1909
  target.closest(this.element).length ||
1909
1910
  target.closest(this.container).length ||
1910
1911
  target.closest('.calendar-table').length
1911
1912
  ) return;
1912
1913
 
1913
- if (this.onOutsideClick == 'cancel') {
1914
+ if (this.onOutsideClick === 'cancel') {
1914
1915
  this.startDate = this.oldStartDate;
1915
1916
  this.endDate = this.oldEndDate;
1916
1917
  }
@@ -2244,7 +2245,7 @@
2244
2245
  unit = 'second';
2245
2246
  }
2246
2247
  }
2247
- if (this.startDate.startOf(unit) == this.ranges[range][0].startOf(unit) == this.endDate.startOf(unit) == this.ranges[range][1].startOf(unit)) {
2248
+ if (this.startDate.startOf(unit).equals(this.ranges[range][0].startOf(unit)) && this.endDate.startOf(unit).equals(this.ranges[range][1].startOf(unit))) {
2248
2249
  customRange = false;
2249
2250
  this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
2250
2251
  break;
@@ -2386,7 +2387,7 @@
2386
2387
  second = parseInt(time.find('.secondselect option:last').val(), 10);
2387
2388
  }
2388
2389
 
2389
- if (side == 'start') {
2390
+ if (side === 'start') {
2390
2391
  if (this.startDate) {
2391
2392
  let start = this.startDate.set({ hour: hour, minute: minute, second: second });
2392
2393
  this.setStartDate(start, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daterangepicker-4.x",
3
- "version": "4.9.4",
3
+ "version": "4.9.6",
4
4
  "description": "Date range picker with time component and pre-defined ranges",
5
5
  "main": "daterangepicker.js",
6
6
  "style": "daterangepicker.css",