@wernfried/daterangepicker 5.6.1 → 5.7.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 +14 -1
- package/README.md +9 -9
- package/dist/cjs/daterangepicker.cjs +82 -46
- package/dist/cjs/daterangepicker.cjs.map +1 -1
- package/dist/cjs/daterangepicker.min.cjs +1 -1
- package/dist/cjs/daterangepicker.min.cjs.map +1 -1
- package/dist/esm/daterangepicker.js +82 -46
- package/dist/esm/daterangepicker.js.map +1 -1
- package/dist/esm/daterangepicker.min.js +1 -1
- package/dist/esm/daterangepicker.min.js.map +1 -1
- package/dist/global/daterangepicker.js +82 -46
- package/dist/global/daterangepicker.js.map +1 -1
- package/dist/global/daterangepicker.min.js +1 -1
- package/dist/global/daterangepicker.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -384,8 +384,6 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
384
384
|
}
|
|
385
385
|
if (!this.#startDate && this.initialMonth) {
|
|
386
386
|
this.#endDate = null;
|
|
387
|
-
if (this.timePicker)
|
|
388
|
-
console.error(`Option 'initialMonth' works only with 'timePicker: false'`);
|
|
389
387
|
} else {
|
|
390
388
|
const violations = this.validateInput(null, false);
|
|
391
389
|
if (violations != null) {
|
|
@@ -418,15 +416,15 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
418
416
|
if (this.singleDatePicker) {
|
|
419
417
|
if (typeof options.altInput === "string") {
|
|
420
418
|
const el = document.querySelector(options.altInput);
|
|
421
|
-
this.altInput = el instanceof HTMLInputElement && el.type
|
|
419
|
+
this.altInput = el instanceof HTMLInputElement && ["text", "hidden"].includes(el.type) ? el : null;
|
|
422
420
|
} else if (options.altInput instanceof HTMLElement) {
|
|
423
|
-
this.altInput = options.altInput instanceof HTMLInputElement && options.altInput.type
|
|
421
|
+
this.altInput = options.altInput instanceof HTMLInputElement && ["text", "hidden"].includes(options.altInput.type) ? options.altInput : null;
|
|
424
422
|
}
|
|
425
423
|
} else if (!this.singleDatePicker && Array.isArray(options.altInput) && options.altInput.length === 2) {
|
|
426
424
|
this.altInput = [];
|
|
427
425
|
for (let item of options.altInput) {
|
|
428
426
|
const el = typeof item === "string" ? document.querySelector(item) : item;
|
|
429
|
-
if (el instanceof HTMLInputElement && el.type
|
|
427
|
+
if (el instanceof HTMLInputElement && ["text", "hidden"].includes(el.type))
|
|
430
428
|
this.altInput.push(el);
|
|
431
429
|
}
|
|
432
430
|
if (this.altInput.length !== 2)
|
|
@@ -872,6 +870,31 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
872
870
|
this.updateView(monthChange);
|
|
873
871
|
return violations;
|
|
874
872
|
}
|
|
873
|
+
/**
|
|
874
|
+
* Clear selected date values.
|
|
875
|
+
* Does not invoke callback function, disables "Apply" button
|
|
876
|
+
* @param {sting|external:DateTime|Date} month - The month to be shown, if null then current month is selected.
|
|
877
|
+
*/
|
|
878
|
+
clearDate(month) {
|
|
879
|
+
const initialMonth = this.parseDate(month ?? this.#startDate.startOf("month"));
|
|
880
|
+
this.oldStartDate = this.#startDate;
|
|
881
|
+
this.oldEndDate = this.#endDate;
|
|
882
|
+
this.#startDate = null;
|
|
883
|
+
this.#endDate = null;
|
|
884
|
+
if (this.isInputText)
|
|
885
|
+
this.element.value = "";
|
|
886
|
+
if (!this.singleDatePicker)
|
|
887
|
+
this.chosenLabel = null;
|
|
888
|
+
if (this.altInput) {
|
|
889
|
+
if (this.singleDatePicker) {
|
|
890
|
+
this.altInput.value = "";
|
|
891
|
+
} else {
|
|
892
|
+
this.altInput[0].value = "";
|
|
893
|
+
this.altInput[1].value = "";
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
this.updateView(!initialMonth.hasSame(this.oldStartDate, "month"));
|
|
897
|
+
}
|
|
875
898
|
/**
|
|
876
899
|
* Parse date value
|
|
877
900
|
* @param {sting|external:DateTime|Date} value - The value to be parsed
|
|
@@ -884,7 +907,7 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
884
907
|
} else if (value instanceof Date) {
|
|
885
908
|
return luxon2.DateTime.fromJSDate(value);
|
|
886
909
|
} else {
|
|
887
|
-
throw RangeError(`Value must be a luxon.DateTime or Date or string`);
|
|
910
|
+
throw RangeError(`Value must be a luxon.DateTime or Date or string. Or use clearDate() to clear date values`);
|
|
888
911
|
}
|
|
889
912
|
} else if (typeof value === "string") {
|
|
890
913
|
const format = typeof this.locale.format === "string" ? this.locale.format : luxon2.DateTime.parseFormatForOpts(this.locale.format);
|
|
@@ -1214,42 +1237,48 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
1214
1237
|
updateCalendars(monthChange) {
|
|
1215
1238
|
if (this.timePicker) {
|
|
1216
1239
|
var hour, minute, second;
|
|
1217
|
-
if (this.#endDate) {
|
|
1218
|
-
|
|
1219
|
-
if (
|
|
1220
|
-
|
|
1221
|
-
minute = 0;
|
|
1222
|
-
if (this.timePickerOpts.showMinutes) {
|
|
1223
|
-
minute = parseInt(this.container.querySelector(".start-time .minuteselect").value, 10);
|
|
1224
|
-
if (isNaN(minute))
|
|
1225
|
-
minute = parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value, 10);
|
|
1226
|
-
}
|
|
1227
|
-
second = 0;
|
|
1228
|
-
if (this.timePickerOpts.showSeconds) {
|
|
1229
|
-
second = parseInt(this.container.querySelector(".start-time .secondselect").value, 10);
|
|
1230
|
-
if (isNaN(second))
|
|
1231
|
-
second = parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value, 10);
|
|
1232
|
-
}
|
|
1240
|
+
if (this.#startDate == null && this.#endDate == null) {
|
|
1241
|
+
this.leftCalendar.month = this.leftCalendar.month.set({ hour: 0, minute: 0, second: 0 });
|
|
1242
|
+
if (!this.singleMonthView)
|
|
1243
|
+
this.rightCalendar.month = this.rightCalendar.month.set({ hour: 0, minute: 0, second: 0 });
|
|
1233
1244
|
} else {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1245
|
+
if (this.#endDate) {
|
|
1246
|
+
hour = parseInt(this.container.querySelector(".start-time .hourselect").value, 10);
|
|
1247
|
+
if (isNaN(hour))
|
|
1248
|
+
hour = parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value, 10);
|
|
1249
|
+
minute = 0;
|
|
1250
|
+
if (this.timePickerOpts.showMinutes) {
|
|
1251
|
+
minute = parseInt(this.container.querySelector(".start-time .minuteselect").value, 10);
|
|
1252
|
+
if (isNaN(minute))
|
|
1253
|
+
minute = parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value, 10);
|
|
1254
|
+
}
|
|
1255
|
+
second = 0;
|
|
1256
|
+
if (this.timePickerOpts.showSeconds) {
|
|
1257
|
+
second = parseInt(this.container.querySelector(".start-time .secondselect").value, 10);
|
|
1258
|
+
if (isNaN(second))
|
|
1259
|
+
second = parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value, 10);
|
|
1260
|
+
}
|
|
1261
|
+
} else {
|
|
1262
|
+
hour = parseInt(this.container.querySelector(".end-time .hourselect").value, 10);
|
|
1263
|
+
if (isNaN(hour))
|
|
1264
|
+
hour = parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value, 10);
|
|
1265
|
+
minute = 0;
|
|
1266
|
+
if (this.timePickerOpts.showMinutes) {
|
|
1267
|
+
minute = parseInt(this.container.querySelector(".end-time .minuteselect").value, 10);
|
|
1268
|
+
if (isNaN(minute))
|
|
1269
|
+
minute = parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value, 10);
|
|
1270
|
+
}
|
|
1271
|
+
second = 0;
|
|
1272
|
+
if (this.timePickerOpts.showSeconds) {
|
|
1273
|
+
second = parseInt(this.container.querySelector(".end-time .secondselect").value, 10);
|
|
1274
|
+
if (isNaN(second))
|
|
1275
|
+
second = parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value, 10);
|
|
1276
|
+
}
|
|
1248
1277
|
}
|
|
1278
|
+
this.leftCalendar.month = this.leftCalendar.month.set({ hour, minute, second });
|
|
1279
|
+
if (!this.singleMonthView)
|
|
1280
|
+
this.rightCalendar.month = this.rightCalendar.month.set({ hour, minute, second });
|
|
1249
1281
|
}
|
|
1250
|
-
this.leftCalendar.month = this.leftCalendar.month.set({ hour, minute, second });
|
|
1251
|
-
if (!this.singleMonthView)
|
|
1252
|
-
this.rightCalendar.month = this.rightCalendar.month.set({ hour, minute, second });
|
|
1253
1282
|
} else {
|
|
1254
1283
|
this.leftCalendar.month = this.leftCalendar.month.set({ hour: 0, minute: 0, second: 0 });
|
|
1255
1284
|
if (!this.singleMonthView)
|
|
@@ -1404,20 +1433,27 @@ var DateRangePicker = (function(exports, luxon2) {
|
|
|
1404
1433
|
* @emits "beforeRenderTimePicker"
|
|
1405
1434
|
*/
|
|
1406
1435
|
renderTimePicker(side) {
|
|
1407
|
-
if (side === "end" && !this.#endDate) return;
|
|
1436
|
+
if (side === "end" && !this.#endDate && this.#startDate) return;
|
|
1408
1437
|
var selected, minLimit, minDate, maxDate = this.maxDate;
|
|
1409
1438
|
let html = "";
|
|
1410
1439
|
if (this.showWeekNumbers || this.showISOWeekNumbers)
|
|
1411
1440
|
html += "<th></th>";
|
|
1412
|
-
if (this
|
|
1413
|
-
maxDate
|
|
1414
|
-
|
|
1415
|
-
|
|
1441
|
+
if (this.#startDate) {
|
|
1442
|
+
if (this.maxSpan && (!this.maxDate || this.#startDate.plus(this.maxSpan) < this.maxDate))
|
|
1443
|
+
maxDate = this.#startDate.plus(this.maxSpan);
|
|
1444
|
+
if (this.minSpan && side === "end")
|
|
1445
|
+
minLimit = this.#startDate.plus(this.minSpan);
|
|
1446
|
+
} else {
|
|
1447
|
+
if (this.maxSpan && (!this.maxDate || this.initialMonth.plus(this.maxSpan) < this.maxDate))
|
|
1448
|
+
maxDate = this.initialMonth.plus(this.maxSpan);
|
|
1449
|
+
if (this.minSpan && side === "end")
|
|
1450
|
+
minLimit = this.initialMonth.plus(this.minSpan);
|
|
1451
|
+
}
|
|
1416
1452
|
if (side === "start") {
|
|
1417
|
-
selected = this.#startDate;
|
|
1453
|
+
selected = this.#startDate ?? this.initialMonth.startOf("day");
|
|
1418
1454
|
minDate = this.minDate;
|
|
1419
1455
|
} else if (side === "end") {
|
|
1420
|
-
selected = this.#endDate;
|
|
1456
|
+
selected = this.#endDate ?? this.initialMonth.startOf("day");
|
|
1421
1457
|
minDate = this.#startDate;
|
|
1422
1458
|
let timeSelector = this.container.querySelector(".drp-calendar .calendar-time.end-time");
|
|
1423
1459
|
if (timeSelector.innerHTML != "") {
|