@uxf/datepicker 11.110.0 → 11.110.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/package.json
CHANGED
|
@@ -35,10 +35,10 @@ function canSelectRange({ startDate, endDate, isDateBlocked, minBookingDays, exa
|
|
|
35
35
|
.toDate(), "day").some(isDateBlocked);
|
|
36
36
|
}
|
|
37
37
|
else if (endDate && !exactMinBookingDays) {
|
|
38
|
-
const minBookingDaysDate = (0, dayjs_utils_1.
|
|
38
|
+
const minBookingDaysDate = (0, dayjs_utils_1.dayjsEnWithTz)(startDate)
|
|
39
39
|
.add(minBookingDays - 1, "day")
|
|
40
40
|
.toDate();
|
|
41
|
-
if ((0, dayjs_utils_1.
|
|
41
|
+
if ((0, dayjs_utils_1.dayjsEnWithTz)(endDate).isBefore(minBookingDaysDate)) {
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
if (!isDateBlocked) {
|
|
@@ -82,4 +82,13 @@ test("canSelectRange", () => {
|
|
|
82
82
|
exactMinBookingDays: true,
|
|
83
83
|
isDateBlocked: () => false,
|
|
84
84
|
})).toBe(true);
|
|
85
|
+
expect((0, can_select_range_1.canSelectRange)({
|
|
86
|
+
startDate: new Date("2026-10-25"),
|
|
87
|
+
endDate: new Date("2026-10-26"),
|
|
88
|
+
minBookingDays: 2,
|
|
89
|
+
minBookingDate: undefined,
|
|
90
|
+
maxBookingDate: undefined,
|
|
91
|
+
exactMinBookingDays: false,
|
|
92
|
+
isDateBlocked: () => false,
|
|
93
|
+
})).toBe(true);
|
|
85
94
|
});
|
package/utils/is-date-blocked.js
CHANGED
|
@@ -4,18 +4,14 @@ exports.isDateBlocked = isDateBlocked;
|
|
|
4
4
|
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
const is_in_unavailable_dates_1 = require("./is-in-unavailable-dates");
|
|
6
6
|
function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays = 1, unavailableDates = [], }) {
|
|
7
|
-
const compareMinDate = minBookingDate
|
|
8
|
-
|
|
9
|
-
: minBookingDate;
|
|
10
|
-
const compareMaxDate = maxBookingDate
|
|
11
|
-
? new Date(maxBookingDate.getFullYear(), maxBookingDate.getMonth(), maxBookingDate.getDate(), 0, 0, 0)
|
|
12
|
-
: maxBookingDate;
|
|
7
|
+
const compareMinDate = minBookingDate;
|
|
8
|
+
const compareMaxDate = maxBookingDate;
|
|
13
9
|
return Boolean((0, is_in_unavailable_dates_1.isInUnavailableDates)(unavailableDates, date) ||
|
|
14
|
-
(compareMinDate &&
|
|
15
|
-
(compareMaxDate &&
|
|
10
|
+
(compareMinDate && date < compareMinDate) ||
|
|
11
|
+
(compareMaxDate && date > compareMaxDate) ||
|
|
16
12
|
(startDate &&
|
|
17
13
|
!endDate &&
|
|
18
14
|
minBookingDays > 1 &&
|
|
19
|
-
(0, dayjs_utils_1.
|
|
15
|
+
(0, dayjs_utils_1.dayjsEnWithTz)(date).isBetween(startDate, (0, dayjs_utils_1.dayjsEnWithTz)(startDate).add(minBookingDays - 1, "day"))) ||
|
|
20
16
|
(isDateBlockedFn && isDateBlockedFn(date)));
|
|
21
17
|
}
|