@wernfried/daterangepicker 5.2.7 → 5.2.8
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 +2 -2
- package/README.md +10 -10
- package/dist/cjs/daterangepicker.cjs +13 -13
- 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 +13 -13
- 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 +13 -13
- 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
|
@@ -15,7 +15,7 @@ class DateRangePicker {
|
|
|
15
15
|
this.maxSpan = null;
|
|
16
16
|
this.minSpan = null;
|
|
17
17
|
this.defaultSpan = null;
|
|
18
|
-
this.
|
|
18
|
+
this.initialMonth = DateTime.now().startOf("month");
|
|
19
19
|
this.autoApply = false;
|
|
20
20
|
this.singleDatePicker = false;
|
|
21
21
|
this.singleMonthView = false;
|
|
@@ -80,7 +80,7 @@ class DateRangePicker {
|
|
|
80
80
|
if (!Object.keys(this).concat(["startDate", "endDate"]).includes(name) || Object.keys(options).includes(name))
|
|
81
81
|
continue;
|
|
82
82
|
let ts = DateTime.fromISO(item.value);
|
|
83
|
-
const isDate = ["startDate", "endDate", "minDate", "maxDate", "
|
|
83
|
+
const isDate = ["startDate", "endDate", "minDate", "maxDate", "initialMonth"].includes(name);
|
|
84
84
|
dataOptions[name] = ts.isValid && isDate ? ts : JSON.parse(item.value);
|
|
85
85
|
}
|
|
86
86
|
options = { ...dataOptions, ...options };
|
|
@@ -295,7 +295,7 @@ class DateRangePicker {
|
|
|
295
295
|
secondStep: this.timePickerStepSize.seconds
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
for (let opt of ["startDate", "endDate", "minDate", "maxDate", "
|
|
298
|
+
for (let opt of ["startDate", "endDate", "minDate", "maxDate", "initialMonth"]) {
|
|
299
299
|
if (opt === "endDate" && this.singleDatePicker)
|
|
300
300
|
continue;
|
|
301
301
|
if (typeof options[opt] === "object") {
|
|
@@ -358,10 +358,10 @@ class DateRangePicker {
|
|
|
358
358
|
if (this.#startDate) this.#startDate = this.#startDate.startOf("day");
|
|
359
359
|
if (this.#endDate) this.#endDate = this.#endDate.endOf("day");
|
|
360
360
|
}
|
|
361
|
-
if (!this.#startDate && this.
|
|
361
|
+
if (!this.#startDate && this.initialMonth) {
|
|
362
362
|
this.#endDate = null;
|
|
363
363
|
if (this.timePicker)
|
|
364
|
-
console.error(`Option '
|
|
364
|
+
console.error(`Option 'initialMonth' works only with 'timePicker: false'`);
|
|
365
365
|
} else {
|
|
366
366
|
const violations = this.validateInput(null, false);
|
|
367
367
|
if (violations != null) {
|
|
@@ -1152,10 +1152,10 @@ class DateRangePicker {
|
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
} else {
|
|
1155
|
-
if (!this.#startDate && this.
|
|
1156
|
-
this.leftCalendar.month = this.
|
|
1155
|
+
if (!this.#startDate && this.initialMonth) {
|
|
1156
|
+
this.leftCalendar.month = this.initialMonth;
|
|
1157
1157
|
if (!this.singleMonthView)
|
|
1158
|
-
this.rightCalendar.month = this.
|
|
1158
|
+
this.rightCalendar.month = this.initialMonth.plus({ month: 1 });
|
|
1159
1159
|
} else {
|
|
1160
1160
|
if (!this.leftCalendar.month.hasSame(this.#startDate, "month") && !this.rightCalendar.month.hasSame(this.#startDate, "month")) {
|
|
1161
1161
|
this.leftCalendar.month = this.#startDate.startOf("month");
|
|
@@ -1238,8 +1238,8 @@ class DateRangePicker {
|
|
|
1238
1238
|
if (side === "right" && this.singleMonthView)
|
|
1239
1239
|
return;
|
|
1240
1240
|
var calendar = side === "left" ? this.leftCalendar : this.rightCalendar;
|
|
1241
|
-
if (calendar.month == null && !this.#startDate && this.
|
|
1242
|
-
calendar.month = this.
|
|
1241
|
+
if (calendar.month == null && !this.#startDate && this.initialMonth)
|
|
1242
|
+
calendar.month = this.initialMonth.startOf("month");
|
|
1243
1243
|
const firstDay = calendar.month.startOf("month");
|
|
1244
1244
|
const lastDay = calendar.month.endOf("month").startOf("day");
|
|
1245
1245
|
var theDate = calendar.month.startOf("month").minus({ day: 1 });
|
|
@@ -1779,7 +1779,7 @@ class DateRangePicker {
|
|
|
1779
1779
|
const leftCalendar = this.leftCalendar;
|
|
1780
1780
|
const rightCalendar = this.rightCalendar;
|
|
1781
1781
|
const startDate = this.#startDate;
|
|
1782
|
-
const
|
|
1782
|
+
const initialMonth = this.initialMonth;
|
|
1783
1783
|
if (!this.#endDate) {
|
|
1784
1784
|
this.container.querySelectorAll(".drp-calendar tbody td").forEach((el) => {
|
|
1785
1785
|
if (el.classList.contains("week")) return;
|
|
@@ -1788,7 +1788,7 @@ class DateRangePicker {
|
|
|
1788
1788
|
const col2 = title2.substring(3, 4);
|
|
1789
1789
|
const cal2 = el.closest(".drp-calendar");
|
|
1790
1790
|
const dt = cal2.classList.contains("left") ? leftCalendar.calendar[row2][col2] : rightCalendar.calendar[row2][col2];
|
|
1791
|
-
if (!startDate &&
|
|
1791
|
+
if (!startDate && initialMonth) {
|
|
1792
1792
|
el.classList.remove("in-range");
|
|
1793
1793
|
} else {
|
|
1794
1794
|
el.classList.toggle("in-range", dt > startDate && dt < date || dt.hasSame(date, "day"));
|
|
@@ -2179,7 +2179,7 @@ class DateRangePicker {
|
|
|
2179
2179
|
* @emits external:change
|
|
2180
2180
|
*/
|
|
2181
2181
|
updateElement() {
|
|
2182
|
-
if (this.#startDate == null && this.
|
|
2182
|
+
if (this.#startDate == null && this.initialMonth)
|
|
2183
2183
|
return;
|
|
2184
2184
|
if (this.isInputText) {
|
|
2185
2185
|
let newValue = this.formatDate(this.#startDate);
|