@wernfried/daterangepicker 5.2.7 → 5.2.10

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.
@@ -16,7 +16,7 @@ var DateRangePicker = (function(exports, luxon2) {
16
16
  this.maxSpan = null;
17
17
  this.minSpan = null;
18
18
  this.defaultSpan = null;
19
- this.initalMonth = luxon2.DateTime.now().startOf("month");
19
+ this.initialMonth = luxon2.DateTime.now().startOf("month");
20
20
  this.autoApply = false;
21
21
  this.singleDatePicker = false;
22
22
  this.singleMonthView = false;
@@ -81,7 +81,7 @@ var DateRangePicker = (function(exports, luxon2) {
81
81
  if (!Object.keys(this).concat(["startDate", "endDate"]).includes(name) || Object.keys(options).includes(name))
82
82
  continue;
83
83
  let ts = luxon2.DateTime.fromISO(item.value);
84
- const isDate = ["startDate", "endDate", "minDate", "maxDate", "initalMonth"].includes(name);
84
+ const isDate = ["startDate", "endDate", "minDate", "maxDate", "initialMonth"].includes(name);
85
85
  dataOptions[name] = ts.isValid && isDate ? ts : JSON.parse(item.value);
86
86
  }
87
87
  options = { ...dataOptions, ...options };
@@ -296,7 +296,7 @@ var DateRangePicker = (function(exports, luxon2) {
296
296
  secondStep: this.timePickerStepSize.seconds
297
297
  };
298
298
  }
299
- for (let opt of ["startDate", "endDate", "minDate", "maxDate", "initalMonth"]) {
299
+ for (let opt of ["startDate", "endDate", "minDate", "maxDate", "initialMonth"]) {
300
300
  if (opt === "endDate" && this.singleDatePicker)
301
301
  continue;
302
302
  if (typeof options[opt] === "object") {
@@ -359,10 +359,10 @@ var DateRangePicker = (function(exports, luxon2) {
359
359
  if (this.#startDate) this.#startDate = this.#startDate.startOf("day");
360
360
  if (this.#endDate) this.#endDate = this.#endDate.endOf("day");
361
361
  }
362
- if (!this.#startDate && this.initalMonth) {
362
+ if (!this.#startDate && this.initialMonth) {
363
363
  this.#endDate = null;
364
364
  if (this.timePicker)
365
- console.error(`Option 'initalMonth' works only with 'timePicker: false'`);
365
+ console.error(`Option 'initialMonth' works only with 'timePicker: false'`);
366
366
  } else {
367
367
  const violations = this.validateInput(null, false);
368
368
  if (violations != null) {
@@ -1153,10 +1153,10 @@ var DateRangePicker = (function(exports, luxon2) {
1153
1153
  }
1154
1154
  }
1155
1155
  } else {
1156
- if (!this.#startDate && this.initalMonth) {
1157
- this.leftCalendar.month = this.initalMonth;
1156
+ if (!this.#startDate && this.initialMonth) {
1157
+ this.leftCalendar.month = this.initialMonth;
1158
1158
  if (!this.singleMonthView)
1159
- this.rightCalendar.month = this.initalMonth.plus({ month: 1 });
1159
+ this.rightCalendar.month = this.initialMonth.plus({ month: 1 });
1160
1160
  } else {
1161
1161
  if (!this.leftCalendar.month.hasSame(this.#startDate, "month") && !this.rightCalendar.month.hasSame(this.#startDate, "month")) {
1162
1162
  this.leftCalendar.month = this.#startDate.startOf("month");
@@ -1239,8 +1239,8 @@ var DateRangePicker = (function(exports, luxon2) {
1239
1239
  if (side === "right" && this.singleMonthView)
1240
1240
  return;
1241
1241
  var calendar = side === "left" ? this.leftCalendar : this.rightCalendar;
1242
- if (calendar.month == null && !this.#startDate && this.initalMonth)
1243
- calendar.month = this.initalMonth.startOf("month");
1242
+ if (calendar.month == null && !this.#startDate && this.initialMonth)
1243
+ calendar.month = this.initialMonth.startOf("month");
1244
1244
  const firstDay = calendar.month.startOf("month");
1245
1245
  const lastDay = calendar.month.endOf("month").startOf("day");
1246
1246
  var theDate = calendar.month.startOf("month").minus({ day: 1 });
@@ -1397,6 +1397,7 @@ var DateRangePicker = (function(exports, luxon2) {
1397
1397
  if (maxDate && selected > maxDate)
1398
1398
  selected = maxDate;
1399
1399
  }
1400
+ let disabled = { hour: false, minute: false, second: false, ampm: false };
1400
1401
  html += `<th colspan="7">`;
1401
1402
  if (this.externalStyle === "bulma")
1402
1403
  html += '<div class="select is-small mx-1">';
@@ -1407,19 +1408,18 @@ var DateRangePicker = (function(exports, luxon2) {
1407
1408
  start = ampm === "AM" ? 1 : 13;
1408
1409
  for (var i = start; i <= start + 23; i += this.timePickerOpts.hourStep) {
1409
1410
  let time = selected.set({ hour: i % 24 });
1410
- let disabled = false;
1411
1411
  if (minDate && time.set({ minute: 59 }) < minDate)
1412
- disabled = true;
1412
+ disabled.hour = true;
1413
1413
  if (maxDate && time.set({ minute: 0 }) > maxDate)
1414
- disabled = true;
1414
+ disabled.hour = true;
1415
1415
  if (minLimit && time.endOf("hour") < minLimit)
1416
- disabled = true;
1417
- if (!disabled && this.isInvalidTime(time, this.singleDatePicker ? null : side, "hour"))
1418
- disabled = true;
1416
+ disabled.hour = true;
1417
+ if (!disabled.hour && this.isInvalidTime(time, this.singleDatePicker ? null : side, "hour"))
1418
+ disabled.hour = true;
1419
1419
  if (this.timePicker24Hour) {
1420
- if (!disabled && i == selected.hour) {
1420
+ if (!disabled.hour && i == selected.hour) {
1421
1421
  html += `<option value="${i}" selected>${i}</option>`;
1422
- } else if (disabled) {
1422
+ } else if (disabled.hour) {
1423
1423
  html += `<option value="${i}" disabled class="disabled">${i}</option>`;
1424
1424
  } else {
1425
1425
  html += `<option value="${i}">${i}</option>`;
@@ -1428,9 +1428,9 @@ var DateRangePicker = (function(exports, luxon2) {
1428
1428
  const i_12 = luxon2.DateTime.fromFormat(`${i % 24}`, "H").toFormat("h");
1429
1429
  const i_ampm = luxon2.DateTime.fromFormat(`${i % 24}`, "H").toFormat("a", { locale: "en-US" });
1430
1430
  if (ampm == i_ampm) {
1431
- if (!disabled && i == selected.hour) {
1431
+ if (!disabled.hour && i == selected.hour) {
1432
1432
  html += `<option ampm="${i_ampm}" value="${i % 24}" selected>${i_12}</option>`;
1433
- } else if (disabled) {
1433
+ } else if (disabled.hour) {
1434
1434
  html += `<option ampm="${i_ampm}" value="${i % 24}" disabled class="disabled">${i_12}</option>`;
1435
1435
  } else {
1436
1436
  html += `<option ampm="${i_ampm}" value="${i % 24}">${i_12}</option>`;
@@ -1451,18 +1451,19 @@ var DateRangePicker = (function(exports, luxon2) {
1451
1451
  for (var i = 0; i < 60; i += this.timePickerOpts.minuteStep) {
1452
1452
  var padded = i < 10 ? "0" + i : i;
1453
1453
  let time = selected.set({ minute: i });
1454
- let disabled = false;
1454
+ if (disabled.hour)
1455
+ disabled.minute = true;
1455
1456
  if (minDate && time.set({ second: 59 }) < minDate)
1456
- disabled = true;
1457
+ disabled.minute = true;
1457
1458
  if (maxDate && time.set({ second: 0 }) > maxDate)
1458
- disabled = true;
1459
+ disabled.minute = true;
1459
1460
  if (minLimit && time.endOf("minute") < minLimit)
1460
- disabled = true;
1461
- if (!disabled && this.isInvalidTime(time, this.singleDatePicker ? null : side, "minute"))
1462
- disabled = true;
1463
- if (selected.minute == i && !disabled) {
1461
+ disabled.minute = true;
1462
+ if (!disabled.minute && this.isInvalidTime(time, this.singleDatePicker ? null : side, "minute"))
1463
+ disabled.minute = true;
1464
+ if (selected.minute == i && !disabled.minute) {
1464
1465
  html += `<option value="${i}" selected>${padded}</option>`;
1465
- } else if (disabled) {
1466
+ } else if (disabled.minute) {
1466
1467
  html += `<option value="${i}" disabled class="disabled">${padded}</option>`;
1467
1468
  } else {
1468
1469
  html += `<option value="${i}">${padded}</option>`;
@@ -1480,18 +1481,19 @@ var DateRangePicker = (function(exports, luxon2) {
1480
1481
  for (var i = 0; i < 60; i += this.timePickerOpts.secondStep) {
1481
1482
  var padded = i < 10 ? "0" + i : i;
1482
1483
  let time = selected.set({ second: i });
1483
- let disabled = false;
1484
+ if (disabled.minute)
1485
+ disabled.second = true;
1484
1486
  if (minDate && time < minDate)
1485
- disabled = true;
1487
+ disabled.second = true;
1486
1488
  if (maxDate && time > maxDate)
1487
- disabled = true;
1489
+ disabled.second = true;
1488
1490
  if (minLimit && time < minLimit)
1489
- disabled = true;
1490
- if (!disabled && this.isInvalidTime(time, this.singleDatePicker ? null : side, "second"))
1491
- disabled = true;
1492
- if (selected.second == i && !disabled) {
1491
+ disabled.second = true;
1492
+ if (!disabled.second && this.isInvalidTime(time, this.singleDatePicker ? null : side, "second"))
1493
+ disabled.second = true;
1494
+ if (selected.second == i && !disabled.second) {
1493
1495
  html += `<option value="${i}" selected>${padded}</option>`;
1494
- } else if (disabled) {
1496
+ } else if (disabled.second) {
1495
1497
  html += `<option value="${i}" disabled class="disabled">${padded}</option>`;
1496
1498
  } else {
1497
1499
  html += `<option value="${i}">${padded}</option>`;
@@ -1507,14 +1509,15 @@ var DateRangePicker = (function(exports, luxon2) {
1507
1509
  html += '<select class="ampmselect">';
1508
1510
  var am_html = "";
1509
1511
  var pm_html = "";
1510
- let disabled = false;
1512
+ if (disabled.hour)
1513
+ disabled.ampm = true;
1511
1514
  if (minDate && selected.startOf("day") < minDate)
1512
- disabled = true;
1515
+ disabled.ampm = true;
1513
1516
  if (maxDate && selected.endOf("day") > maxDate)
1514
- disabled = true;
1517
+ disabled.ampm = true;
1515
1518
  if (minLimit && selected.startOf("day") < minLimit)
1516
- disabled = true;
1517
- if (disabled) {
1519
+ disabled.ampm = true;
1520
+ if (disabled.ampm) {
1518
1521
  am_html = ' disabled class="disabled "';
1519
1522
  pm_html = ' disabled class="disabled"';
1520
1523
  } else {
@@ -1780,7 +1783,7 @@ var DateRangePicker = (function(exports, luxon2) {
1780
1783
  const leftCalendar = this.leftCalendar;
1781
1784
  const rightCalendar = this.rightCalendar;
1782
1785
  const startDate = this.#startDate;
1783
- const initalMonth = this.initalMonth;
1786
+ const initialMonth = this.initialMonth;
1784
1787
  if (!this.#endDate) {
1785
1788
  this.container.querySelectorAll(".drp-calendar tbody td").forEach((el) => {
1786
1789
  if (el.classList.contains("week")) return;
@@ -1789,7 +1792,7 @@ var DateRangePicker = (function(exports, luxon2) {
1789
1792
  const col2 = title2.substring(3, 4);
1790
1793
  const cal2 = el.closest(".drp-calendar");
1791
1794
  const dt = cal2.classList.contains("left") ? leftCalendar.calendar[row2][col2] : rightCalendar.calendar[row2][col2];
1792
- if (!startDate && initalMonth) {
1795
+ if (!startDate && initialMonth) {
1793
1796
  el.classList.remove("in-range");
1794
1797
  } else {
1795
1798
  el.classList.toggle("in-range", dt > startDate && dt < date || dt.hasSame(date, "day"));
@@ -2180,7 +2183,7 @@ var DateRangePicker = (function(exports, luxon2) {
2180
2183
  * @emits external:change
2181
2184
  */
2182
2185
  updateElement() {
2183
- if (this.#startDate == null && this.initalMonth)
2186
+ if (this.#startDate == null && this.initialMonth)
2184
2187
  return;
2185
2188
  if (this.isInputText) {
2186
2189
  let newValue = this.formatDate(this.#startDate);