@uxf/datepicker 11.111.2 → 11.113.0

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.
Files changed (55) hide show
  1. package/hooks/use-date-picker-navigation.d.ts +4 -3
  2. package/hooks/use-date-picker-navigation.js +30 -34
  3. package/hooks/use-date-picker-navigation.test.js +40 -4
  4. package/hooks/use-date-picker.js +40 -26
  5. package/hooks/use-date-picker.test.js +2 -2
  6. package/hooks/use-date-range-picker.js +103 -76
  7. package/hooks/use-day.js +12 -11
  8. package/hooks/use-decade.js +9 -8
  9. package/jest.dst.config.js +22 -0
  10. package/jest.dst.global-setup.js +14 -0
  11. package/package.json +7 -2
  12. package/utils/can-select-range.d.ts +6 -5
  13. package/utils/can-select-range.js +7 -19
  14. package/utils/can-select-range.test.js +30 -27
  15. package/utils/date-string.d.ts +34 -0
  16. package/utils/date-string.js +64 -0
  17. package/utils/date-string.test.d.ts +1 -0
  18. package/utils/date-string.test.js +63 -0
  19. package/utils/dayjs-utils.d.ts +0 -1
  20. package/utils/dayjs-utils.js +1 -5
  21. package/utils/dst-robustness.test.d.ts +11 -0
  22. package/utils/dst-robustness.test.js +328 -0
  23. package/utils/get-current-year-month-and-date.js +1 -2
  24. package/utils/get-date-invervals.js +2 -5
  25. package/utils/get-date-month-and-year.js +6 -5
  26. package/utils/get-days.js +12 -9
  27. package/utils/get-each.d.ts +2 -1
  28. package/utils/get-each.js +37 -9
  29. package/utils/get-each.test.js +34 -19
  30. package/utils/get-initial-months.js +3 -6
  31. package/utils/get-months.js +7 -7
  32. package/utils/get-next-active-month.js +6 -10
  33. package/utils/get-weekday-labels.js +4 -2
  34. package/utils/get-years.js +5 -4
  35. package/utils/is-date-blocked.d.ts +7 -6
  36. package/utils/is-date-blocked.js +6 -7
  37. package/utils/is-date-blocked.test.js +108 -11
  38. package/utils/is-date-hovered.d.ts +6 -5
  39. package/utils/is-date-hovered.js +17 -24
  40. package/utils/is-date-hovered.test.js +42 -25
  41. package/utils/is-date-inside-range.d.ts +2 -1
  42. package/utils/is-date-inside-range.js +1 -2
  43. package/utils/is-date-selected.test.js +16 -8
  44. package/utils/is-end-date.d.ts +2 -1
  45. package/utils/is-end-date.js +1 -2
  46. package/utils/is-end-date.test.js +11 -6
  47. package/utils/is-first-or-last-selected-date.d.ts +2 -1
  48. package/utils/is-first-or-last-selected-date.js +1 -3
  49. package/utils/is-first-or-last-selected-date.test.js +9 -6
  50. package/utils/is-in-unavailable-dates.d.ts +2 -1
  51. package/utils/is-in-unavailable-dates.js +1 -2
  52. package/utils/is-in-unavailable-dates.test.js +10 -6
  53. package/utils/is-start-date.d.ts +2 -1
  54. package/utils/is-start-date.js +1 -2
  55. package/utils/is-start-date.test.js +12 -6
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNextActiveMonth = getNextActiveMonth;
4
- const dayjs_utils_1 = require("./dayjs-utils");
4
+ const date_string_1 = require("./date-string");
5
5
  const get_date_month_and_year_1 = require("./get-date-month-and-year");
6
6
  function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
7
7
  let prevMonth;
@@ -11,19 +11,15 @@ function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
11
11
  else {
12
12
  prevMonth = counter > 0 ? activeMonth.length - 1 : 0;
13
13
  }
14
- let prevMonthDate = activeMonth[prevMonth].date;
14
+ let prevMonthStr = (0, date_string_1.toDateString)(activeMonth[prevMonth].date);
15
15
  return Array.from(Array(numberOfMonths).keys()).reduce((m) => {
16
16
  if (m.length === 0) {
17
- prevMonthDate = (0, dayjs_utils_1.dayjsEnWithTz)(prevMonthDate).add(counter, "month").startOf("month").toDate();
17
+ prevMonthStr = (0, date_string_1.addMonths)(prevMonthStr, counter);
18
18
  }
19
19
  else {
20
- prevMonthDate = (0, dayjs_utils_1.dayjsEnWithTz)(prevMonthDate)
21
- .add(counter >= 0 ? 1 : -1, "month")
22
- .startOf("month")
23
- .toDate();
20
+ prevMonthStr = (0, date_string_1.addMonths)(prevMonthStr, counter >= 0 ? 1 : -1);
24
21
  }
25
- return counter > 0
26
- ? m.concat([(0, get_date_month_and_year_1.getDateMonthAndYear)(prevMonthDate)])
27
- : [(0, get_date_month_and_year_1.getDateMonthAndYear)(prevMonthDate)].concat(m);
22
+ const monthType = (0, get_date_month_and_year_1.getDateMonthAndYear)(new Date(prevMonthStr));
23
+ return counter > 0 ? m.concat([monthType]) : [monthType].concat(m);
28
24
  }, []);
29
25
  }
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWeekdayLabels = getWeekdayLabels;
4
+ const date_string_1 = require("./date-string");
4
5
  const dayjs_utils_1 = require("./dayjs-utils");
5
6
  const get_each_1 = require("./get-each");
6
7
  function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("dd"), }) {
7
8
  const now = (0, dayjs_utils_1.dayjsEnWithTz)();
8
- const arr = (0, get_each_1.getEach)(now.startOf("week").add(firstDayOfWeek, "day").toDate(), now.endOf("week").add(firstDayOfWeek, "day").toDate(), "day");
9
- return arr.map((date) => weekdayLabelFormat(date));
9
+ const start = now.startOf("week").add(firstDayOfWeek, "day").format("YYYY-MM-DD");
10
+ const end = now.endOf("week").add(firstDayOfWeek, "day").format("YYYY-MM-DD");
11
+ return (0, get_each_1.getEach)(start, end, "day").map((d) => weekdayLabelFormat((0, date_string_1.fromDateString)(d)));
10
12
  }
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getYears = getYears;
4
+ const date_string_1 = require("./date-string");
4
5
  const dayjs_utils_1 = require("./dayjs-utils");
5
6
  const get_each_1 = require("./get-each");
6
7
  function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("YYYY"), }) {
7
- return (0, get_each_1.getEach)(startYear, endYear, "year").map((d) => ({
8
- date: d,
9
- yearLabel: yearLabelFormat(d),
10
- }));
8
+ return (0, get_each_1.getEach)((0, date_string_1.toDateString)(startYear), (0, date_string_1.toDateString)(endYear), "year").map((d) => {
9
+ const date = (0, date_string_1.fromDateString)(d);
10
+ return { date, yearLabel: yearLabelFormat(date) };
11
+ });
11
12
  }
@@ -1,12 +1,13 @@
1
+ import { DateString } from "@uxf/core/date";
1
2
  interface IsDateBlockedProps {
2
- date: Date;
3
- startDate: Date | null;
4
- endDate: Date | null;
3
+ date: DateString;
4
+ startDate: DateString | null;
5
+ endDate: DateString | null;
5
6
  minBookingDays?: number;
6
- minBookingDate?: Date;
7
- maxBookingDate?: Date;
7
+ minBookingDate?: DateString;
8
+ maxBookingDate?: DateString;
8
9
  isDateBlockedFn?: ((date: Date) => boolean) | null;
9
- unavailableDates?: Date[];
10
+ unavailableDates?: DateString[];
10
11
  }
11
12
  export declare function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays, unavailableDates, }: IsDateBlockedProps): boolean;
12
13
  export {};
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateBlocked = isDateBlocked;
4
- const dayjs_utils_1 = require("./dayjs-utils");
4
+ const date_string_1 = require("./date-string");
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
- const compareMaxDate = maxBookingDate;
9
7
  return Boolean((0, is_in_unavailable_dates_1.isInUnavailableDates)(unavailableDates, date) ||
10
- (compareMinDate && date < compareMinDate) ||
11
- (compareMaxDate && date > compareMaxDate) ||
8
+ (minBookingDate && date < minBookingDate) ||
9
+ (maxBookingDate && date > maxBookingDate) ||
12
10
  (startDate &&
13
11
  !endDate &&
14
12
  minBookingDays > 1 &&
15
- (0, dayjs_utils_1.dayjsEnWithTz)(date).isBetween(startDate, (0, dayjs_utils_1.dayjsEnWithTz)(startDate).add(minBookingDays - 1, "day"))) ||
16
- (isDateBlockedFn && isDateBlockedFn(date)));
13
+ date > startDate &&
14
+ date < (0, date_string_1.addDays)(startDate, minBookingDays - 1)) ||
15
+ (isDateBlockedFn && isDateBlockedFn((0, date_string_1.fromDateString)(date))));
17
16
  }
@@ -4,23 +4,23 @@ const is_date_blocked_1 = require("./is-date-blocked");
4
4
  test("isDateBlocked", () => {
5
5
  // custom fn
6
6
  expect((0, is_date_blocked_1.isDateBlocked)({
7
- startDate: new Date("2021-08-08"),
7
+ startDate: "2021-08-08",
8
8
  endDate: null,
9
9
  minBookingDays: 1,
10
10
  minBookingDate: undefined,
11
11
  maxBookingDate: undefined,
12
- date: new Date("2021-08-08"),
12
+ date: "2021-08-08",
13
13
  unavailableDates: undefined,
14
14
  isDateBlockedFn: () => true,
15
15
  })).toBe(true);
16
- // start day only
16
+ // not blocked
17
17
  expect((0, is_date_blocked_1.isDateBlocked)({
18
- startDate: new Date("2021-08-08"),
18
+ startDate: "2021-08-08",
19
19
  endDate: null,
20
20
  minBookingDays: 1,
21
21
  minBookingDate: undefined,
22
22
  maxBookingDate: undefined,
23
- date: new Date("2021-08-08"),
23
+ date: "2021-08-08",
24
24
  unavailableDates: undefined,
25
25
  isDateBlockedFn: undefined,
26
26
  })).toBe(false);
@@ -29,9 +29,9 @@ test("isDateBlocked", () => {
29
29
  startDate: null,
30
30
  endDate: null,
31
31
  minBookingDays: 1,
32
- minBookingDate: new Date("2021-08-10"),
32
+ minBookingDate: "2021-08-10",
33
33
  maxBookingDate: undefined,
34
- date: new Date("2021-08-08"),
34
+ date: "2021-08-08",
35
35
  unavailableDates: undefined,
36
36
  isDateBlockedFn: undefined,
37
37
  })).toBe(true);
@@ -41,8 +41,8 @@ test("isDateBlocked", () => {
41
41
  endDate: null,
42
42
  minBookingDays: 1,
43
43
  minBookingDate: undefined,
44
- maxBookingDate: new Date("2021-08-06"),
45
- date: new Date("2021-08-08"),
44
+ maxBookingDate: "2021-08-06",
45
+ date: "2021-08-08",
46
46
  unavailableDates: undefined,
47
47
  isDateBlockedFn: undefined,
48
48
  })).toBe(true);
@@ -53,8 +53,105 @@ test("isDateBlocked", () => {
53
53
  minBookingDays: 1,
54
54
  minBookingDate: undefined,
55
55
  maxBookingDate: undefined,
56
- date: new Date("2021-08-08"),
57
- unavailableDates: [new Date("2021-08-08")],
56
+ date: "2021-08-08",
57
+ unavailableDates: ["2021-08-08"],
58
58
  isDateBlockedFn: undefined,
59
59
  })).toBe(true);
60
60
  });
61
+ test("isDateBlocked minBookingDays boundary", () => {
62
+ // minBookingDays=1 (default) — never blocks on the between-dates condition
63
+ expect((0, is_date_blocked_1.isDateBlocked)({
64
+ startDate: "2026-01-01",
65
+ endDate: null,
66
+ minBookingDays: 1,
67
+ date: "2026-01-02",
68
+ unavailableDates: undefined,
69
+ isDateBlockedFn: undefined,
70
+ })).toBe(false);
71
+ // minBookingDays=2 — blocks nothing between startDate and startDate+1 (empty set)
72
+ // "2026-01-01" < date < "2026-01-02" has no whole-day solution, so nothing is blocked.
73
+ // Minimum valid endDate is startDate+1 = "2026-01-02" (2-day booking). Correct.
74
+ expect((0, is_date_blocked_1.isDateBlocked)({
75
+ startDate: "2026-01-01",
76
+ endDate: null,
77
+ minBookingDays: 2,
78
+ date: "2026-01-02",
79
+ unavailableDates: undefined,
80
+ isDateBlockedFn: undefined,
81
+ })).toBe(false);
82
+ // minBookingDays=3 — blocks startDate+1 only; startDate+2 is the first valid endDate (3-day booking)
83
+ expect((0, is_date_blocked_1.isDateBlocked)({
84
+ startDate: "2026-01-01",
85
+ endDate: null,
86
+ minBookingDays: 3,
87
+ date: "2026-01-02",
88
+ unavailableDates: undefined,
89
+ isDateBlockedFn: undefined,
90
+ })).toBe(true);
91
+ expect((0, is_date_blocked_1.isDateBlocked)({
92
+ startDate: "2026-01-01",
93
+ endDate: null,
94
+ minBookingDays: 3,
95
+ date: "2026-01-03",
96
+ unavailableDates: undefined,
97
+ isDateBlockedFn: undefined,
98
+ })).toBe(false);
99
+ // minBookingDays=4 — blocks startDate+1 and startDate+2; startDate+3 is the first valid endDate
100
+ expect((0, is_date_blocked_1.isDateBlocked)({
101
+ startDate: "2026-01-01",
102
+ endDate: null,
103
+ minBookingDays: 4,
104
+ date: "2026-01-02",
105
+ unavailableDates: undefined,
106
+ isDateBlockedFn: undefined,
107
+ })).toBe(true);
108
+ expect((0, is_date_blocked_1.isDateBlocked)({
109
+ startDate: "2026-01-01",
110
+ endDate: null,
111
+ minBookingDays: 4,
112
+ date: "2026-01-03",
113
+ unavailableDates: undefined,
114
+ isDateBlockedFn: undefined,
115
+ })).toBe(true);
116
+ expect((0, is_date_blocked_1.isDateBlocked)({
117
+ startDate: "2026-01-01",
118
+ endDate: null,
119
+ minBookingDays: 4,
120
+ date: "2026-01-04",
121
+ unavailableDates: undefined,
122
+ isDateBlockedFn: undefined,
123
+ })).toBe(false);
124
+ // minBookingDays condition is inactive once endDate is set
125
+ expect((0, is_date_blocked_1.isDateBlocked)({
126
+ startDate: "2026-01-01",
127
+ endDate: "2026-01-05",
128
+ minBookingDays: 4,
129
+ date: "2026-01-02",
130
+ unavailableDates: undefined,
131
+ isDateBlockedFn: undefined,
132
+ })).toBe(false);
133
+ });
134
+ test("isDateBlocked DST boundary", () => {
135
+ // date on fall-back day is blocked by minBookingDate on next day
136
+ expect((0, is_date_blocked_1.isDateBlocked)({
137
+ startDate: null,
138
+ endDate: null,
139
+ minBookingDays: 1,
140
+ minBookingDate: "2026-10-26",
141
+ maxBookingDate: undefined,
142
+ date: "2026-10-25",
143
+ unavailableDates: undefined,
144
+ isDateBlockedFn: undefined,
145
+ })).toBe(true);
146
+ // date on fall-back day is NOT blocked when it equals minBookingDate
147
+ expect((0, is_date_blocked_1.isDateBlocked)({
148
+ startDate: null,
149
+ endDate: null,
150
+ minBookingDays: 1,
151
+ minBookingDate: "2026-10-25",
152
+ maxBookingDate: undefined,
153
+ date: "2026-10-25",
154
+ unavailableDates: undefined,
155
+ isDateBlockedFn: undefined,
156
+ })).toBe(false);
157
+ });
@@ -1,9 +1,10 @@
1
+ import { DateString } from "@uxf/core/date";
1
2
  export interface IsDateHoveredProps {
2
- startDate: Date | null;
3
- endDate: Date | null;
4
- date: Date;
5
- isDateBlocked: ((date: Date) => boolean) | null;
6
- hoveredDate: Date | null;
3
+ startDate: DateString | null;
4
+ endDate: DateString | null;
5
+ date: DateString;
6
+ isDateBlocked: ((date: DateString) => boolean) | null;
7
+ hoveredDate: DateString | null;
7
8
  minBookingDays: number;
8
9
  exactMinBookingDays: boolean;
9
10
  }
@@ -1,48 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateHovered = isDateHovered;
4
- const dayjs_utils_1 = require("./dayjs-utils");
4
+ const date_string_1 = require("./date-string");
5
5
  const get_each_1 = require("./get-each");
6
+ function isRangeUnblocked(start, end, isDateBlocked) {
7
+ return !isDateBlocked || !(0, get_each_1.getEach)(start, end, "day").some(isDateBlocked);
8
+ }
6
9
  function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, minBookingDays, exactMinBookingDays, }) {
7
10
  if (
8
11
  // exact min booking days
9
12
  hoveredDate &&
10
13
  minBookingDays > 1 &&
11
14
  exactMinBookingDays &&
12
- (0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(hoveredDate, (0, dayjs_utils_1.dayjsEnRaw)(hoveredDate).add(minBookingDays - 1, "day"))) {
13
- if (!isDateBlocked) {
14
- return true;
15
- }
16
- return !(0, get_each_1.getEach)(hoveredDate, (0, dayjs_utils_1.dayjsEnRaw)(hoveredDate)
17
- .add(minBookingDays - 1, "day")
18
- .toDate(), "day").some((d) => isDateBlocked(d));
15
+ date > hoveredDate &&
16
+ date < (0, date_string_1.addDays)(hoveredDate, minBookingDays - 1)) {
17
+ return isRangeUnblocked(hoveredDate, (0, date_string_1.addDays)(hoveredDate, minBookingDays - 1), isDateBlocked);
19
18
  }
20
19
  else if (
21
- // min booking days
20
+ // min booking days (start date hovered)
22
21
  startDate &&
23
22
  !endDate &&
24
23
  hoveredDate &&
25
- (0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, (0, dayjs_utils_1.dayjsEnRaw)(startDate).add(minBookingDays - 1, "day")) &&
26
- (0, dayjs_utils_1.dayjsEnRaw)(startDate).isSame(hoveredDate, "days") &&
24
+ date > startDate &&
25
+ date < (0, date_string_1.addDays)(startDate, minBookingDays - 1) &&
26
+ startDate === hoveredDate &&
27
27
  minBookingDays > 1) {
28
- if (!isDateBlocked) {
29
- return true;
30
- }
31
- return !(0, get_each_1.getEach)(startDate, (0, dayjs_utils_1.dayjsEnRaw)(startDate)
32
- .add(minBookingDays - 1, "day")
33
- .toDate(), "day").some((d) => isDateBlocked(d));
28
+ return isRangeUnblocked(startDate, (0, date_string_1.addDays)(startDate, minBookingDays - 1), isDateBlocked);
34
29
  }
35
30
  else if (
36
- // normal
31
+ // normal hover range
37
32
  startDate &&
38
33
  !endDate &&
39
34
  hoveredDate &&
40
- !(0, dayjs_utils_1.dayjsEnRaw)(hoveredDate).isBefore(startDate) &&
41
- (0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, hoveredDate)) {
42
- if (!isDateBlocked) {
43
- return true;
44
- }
45
- return !(0, get_each_1.getEach)(startDate, hoveredDate, "day").some((d) => isDateBlocked(d));
35
+ hoveredDate >= startDate &&
36
+ date > startDate &&
37
+ date < hoveredDate) {
38
+ return isRangeUnblocked(startDate, hoveredDate, isDateBlocked);
46
39
  }
47
40
  return false;
48
41
  }
@@ -1,72 +1,89 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const is_date_hovered_1 = require("./is-date-hovered");
4
- test("isDateHovered", () => {
5
- // exact min booking days
4
+ test("isDateHovered — exact min booking days", () => {
5
+ // date within exact range but blocked
6
6
  expect((0, is_date_hovered_1.isDateHovered)({
7
7
  startDate: null,
8
8
  endDate: null,
9
9
  minBookingDays: 5,
10
- date: new Date("2021-08-08"),
11
- hoveredDate: new Date("2021-08-07"),
10
+ date: "2021-08-08",
11
+ hoveredDate: "2021-08-07",
12
12
  exactMinBookingDays: true,
13
13
  isDateBlocked: () => true,
14
14
  })).toBe(false);
15
+ // date within exact range, not blocked
15
16
  expect((0, is_date_hovered_1.isDateHovered)({
16
17
  startDate: null,
17
18
  endDate: null,
18
19
  minBookingDays: 5,
19
- date: new Date("2021-08-08"),
20
- hoveredDate: new Date("2021-08-07"),
20
+ date: "2021-08-08",
21
+ hoveredDate: "2021-08-07",
21
22
  exactMinBookingDays: true,
22
23
  isDateBlocked: () => false,
23
24
  })).toBe(true);
24
- // min booking days
25
+ });
26
+ test("isDateHovered — min booking days", () => {
25
27
  expect((0, is_date_hovered_1.isDateHovered)({
26
- startDate: new Date("2021-08-07"),
28
+ startDate: "2021-08-07",
27
29
  endDate: null,
28
30
  minBookingDays: 5,
29
- date: new Date("2021-08-08"),
30
- hoveredDate: new Date("2021-08-07"),
31
+ date: "2021-08-08",
32
+ hoveredDate: "2021-08-07",
31
33
  exactMinBookingDays: false,
32
34
  isDateBlocked: () => true,
33
35
  })).toBe(false);
34
36
  expect((0, is_date_hovered_1.isDateHovered)({
35
- startDate: new Date("2021-08-07"),
37
+ startDate: "2021-08-07",
36
38
  endDate: null,
37
39
  minBookingDays: 5,
38
- date: new Date("2021-08-08"),
39
- hoveredDate: new Date("2021-08-07"),
40
+ date: "2021-08-08",
41
+ hoveredDate: "2021-08-07",
40
42
  exactMinBookingDays: false,
41
43
  isDateBlocked: () => false,
42
44
  })).toBe(true);
43
- // normal
45
+ });
46
+ test("isDateHovered — normal hover range", () => {
47
+ // blocked
44
48
  expect((0, is_date_hovered_1.isDateHovered)({
45
- startDate: new Date("2021-08-07"),
49
+ startDate: "2021-08-07",
46
50
  endDate: null,
47
51
  minBookingDays: 1,
48
- date: new Date("2021-08-08"),
49
- hoveredDate: new Date("2021-08-09"),
52
+ date: "2021-08-08",
53
+ hoveredDate: "2021-08-09",
50
54
  exactMinBookingDays: false,
51
55
  isDateBlocked: () => true,
52
56
  })).toBe(false);
57
+ // not blocked
53
58
  expect((0, is_date_hovered_1.isDateHovered)({
54
- startDate: new Date("2021-08-07"),
59
+ startDate: "2021-08-07",
55
60
  endDate: null,
56
61
  minBookingDays: 1,
57
- date: new Date("2021-08-08"),
58
- hoveredDate: new Date("2021-08-09"),
62
+ date: "2021-08-08",
63
+ hoveredDate: "2021-08-09",
59
64
  exactMinBookingDays: false,
60
65
  isDateBlocked: () => false,
61
66
  })).toBe(true);
62
- // with endDate
67
+ });
68
+ test("isDateHovered — with endDate returns false", () => {
63
69
  expect((0, is_date_hovered_1.isDateHovered)({
64
- startDate: new Date("2021-08-07"),
65
- endDate: new Date("2021-08-12"),
70
+ startDate: "2021-08-07",
71
+ endDate: "2021-08-12",
66
72
  minBookingDays: 1,
67
- date: new Date("2021-08-08"),
68
- hoveredDate: new Date("2021-08-07"),
73
+ date: "2021-08-08",
74
+ hoveredDate: "2021-08-07",
69
75
  exactMinBookingDays: false,
70
76
  isDateBlocked: () => true,
71
77
  })).toBe(false);
72
78
  });
79
+ test("isDateHovered — DST fall-back boundary", () => {
80
+ expect((0, is_date_hovered_1.isDateHovered)({
81
+ startDate: "2026-10-24",
82
+ endDate: null,
83
+ minBookingDays: 1,
84
+ date: "2026-10-25",
85
+ hoveredDate: "2026-10-26",
86
+ exactMinBookingDays: false,
87
+ isDateBlocked: () => false,
88
+ })).toBe(true);
89
+ });
@@ -1 +1,2 @@
1
- export declare function isDateInsideRange(date: Date, startDate: Date | null, endDate: Date | null): boolean;
1
+ import { DateString } from "@uxf/core/date";
2
+ export declare function isDateInsideRange(date: DateString, startDate: DateString | null, endDate: DateString | null): boolean;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateInsideRange = isDateInsideRange;
4
- const dayjs_utils_1 = require("./dayjs-utils");
5
4
  function isDateInsideRange(date, startDate, endDate) {
6
5
  if (startDate && endDate) {
7
- return (0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, endDate);
6
+ return startDate < date && date < endDate;
8
7
  }
9
8
  return false;
10
9
  }
@@ -2,12 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const is_date_inside_range_1 = require("./is-date-inside-range");
4
4
  test("isDateInsideRange", () => {
5
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), new Date("2021-06-08"), new Date("2021-08-12"))).toBe(true);
6
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), new Date("2021-08-07"), new Date("2021-08-12"))).toBe(true);
7
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), new Date("2021-06-08"), new Date("2021-08-09"))).toBe(true);
8
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), null, null)).toBe(false);
9
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), new Date("2021-06-08"), null)).toBe(false);
10
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), null, new Date("2021-08-09"))).toBe(false);
11
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), new Date("2021-06-08"), new Date("2021-08-01"))).toBe(false);
12
- expect((0, is_date_inside_range_1.isDateInsideRange)(new Date("2021-08-08"), new Date("2021-08-10"), new Date("2021-08-25"))).toBe(false);
5
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", "2021-06-08", "2021-08-12")).toBe(true);
6
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", "2021-08-07", "2021-08-12")).toBe(true);
7
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", "2021-06-08", "2021-08-09")).toBe(true);
8
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", null, null)).toBe(false);
9
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", "2021-06-08", null)).toBe(false);
10
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", null, "2021-08-09")).toBe(false);
11
+ // endpoint not inside (exclusive)
12
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-06-08", "2021-06-08", "2021-08-01")).toBe(false);
13
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-01", "2021-06-08", "2021-08-01")).toBe(false);
14
+ // outside range
15
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", "2021-06-08", "2021-08-01")).toBe(false);
16
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2021-08-08", "2021-08-10", "2021-08-25")).toBe(false);
17
+ });
18
+ test("isDateInsideRange DST boundary (2026-10-25)", () => {
19
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2026-10-25", "2026-10-24", "2026-10-26")).toBe(true);
20
+ expect((0, is_date_inside_range_1.isDateInsideRange)("2026-10-24", "2026-10-24", "2026-10-26")).toBe(false); // exclusive
13
21
  });
@@ -1 +1,2 @@
1
- export declare function isEndDate(date: Date, endDate: Date | null): boolean;
1
+ import { DateString } from "@uxf/core/date";
2
+ export declare function isEndDate(date: DateString, endDate: DateString | null): boolean;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEndDate = isEndDate;
4
- const dayjs_utils_1 = require("./dayjs-utils");
5
4
  function isEndDate(date, endDate) {
6
- return Boolean(endDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(endDate, "day"));
5
+ return date === endDate;
7
6
  }
@@ -2,10 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const is_end_date_1 = require("./is-end-date");
4
4
  test("isEndDate", () => {
5
- expect((0, is_end_date_1.isEndDate)(new Date("2020-08-08"), new Date("2020-08-08"))).toBe(true);
6
- expect((0, is_end_date_1.isEndDate)(new Date("2021-12-15"), new Date("2021-12-15"))).toBe(true);
7
- expect((0, is_end_date_1.isEndDate)(new Date("1999-01-05"), new Date("1999-01-05"))).toBe(true);
8
- expect((0, is_end_date_1.isEndDate)(new Date("2020-08-09"), new Date("2020-08-08"))).toBe(false);
9
- expect((0, is_end_date_1.isEndDate)(new Date("2020-08-10"), new Date("2020-08-08"))).toBe(false);
10
- expect((0, is_end_date_1.isEndDate)(new Date("2021-08-08"), new Date("2020-08-08"))).toBe(false);
5
+ expect((0, is_end_date_1.isEndDate)("2020-08-08", "2020-08-08")).toBe(true);
6
+ expect((0, is_end_date_1.isEndDate)("2021-12-15", "2021-12-15")).toBe(true);
7
+ expect((0, is_end_date_1.isEndDate)("1999-01-05", "1999-01-05")).toBe(true);
8
+ expect((0, is_end_date_1.isEndDate)("2020-08-09", "2020-08-08")).toBe(false);
9
+ expect((0, is_end_date_1.isEndDate)("2020-08-10", "2020-08-08")).toBe(false);
10
+ expect((0, is_end_date_1.isEndDate)("2021-08-08", "2020-08-08")).toBe(false);
11
+ expect((0, is_end_date_1.isEndDate)("2026-10-25", null)).toBe(false);
12
+ });
13
+ test("isEndDate DST fall-back (2026-10-25)", () => {
14
+ expect((0, is_end_date_1.isEndDate)("2026-10-25", "2026-10-25")).toBe(true);
15
+ expect((0, is_end_date_1.isEndDate)("2026-10-26", "2026-10-25")).toBe(false);
11
16
  });
@@ -1 +1,2 @@
1
- export declare function isFirstOrLastSelectedDate(date: Date, startDate: Date | null, endDate: Date | null): boolean;
1
+ import { DateString } from "@uxf/core/date";
2
+ export declare function isFirstOrLastSelectedDate(date: DateString, startDate: DateString | null, endDate: DateString | null): boolean;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isFirstOrLastSelectedDate = isFirstOrLastSelectedDate;
4
- const dayjs_utils_1 = require("./dayjs-utils");
5
4
  function isFirstOrLastSelectedDate(date, startDate, endDate) {
6
- return Boolean((startDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(startDate, "day")) ||
7
- (endDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(endDate, "day")));
5
+ return Boolean((startDate && date === startDate) || (endDate && date === endDate));
8
6
  }
@@ -2,10 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const is_first_or_last_selected_date_1 = require("./is-first-or-last-selected-date");
4
4
  test("isFirstOrLastSelectedDate", () => {
5
- expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)(new Date("2020-08-08"), new Date("2020-05-08"), new Date("2020-08-08"))).toBe(true);
6
- expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)(new Date("2021-12-15"), new Date("2021-12-01"), new Date("2021-12-15"))).toBe(true);
7
- expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)(new Date("1999-01-05"), new Date("1999-01-05"), new Date("1999-03-05"))).toBe(true);
8
- expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)(new Date("2020-08-09"), new Date("2020-08-08"), new Date("2020-08-10"))).toBe(false);
9
- expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)(new Date("2020-08-10"), new Date("2020-08-08"), new Date("2020-12-08"))).toBe(false);
10
- expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)(new Date("2021-08-08"), new Date("2020-08-08"), new Date("2020-01-08"))).toBe(false);
5
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2020-08-08", "2020-05-08", "2020-08-08")).toBe(true);
6
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2021-12-15", "2021-12-01", "2021-12-15")).toBe(true);
7
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("1999-01-05", "1999-01-05", "1999-03-05")).toBe(true);
8
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2020-08-09", "2020-08-08", "2020-08-10")).toBe(false);
9
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2020-08-10", "2020-08-08", "2020-12-08")).toBe(false);
10
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2021-08-08", "2020-08-08", "2020-01-08")).toBe(false);
11
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2026-10-25", "2026-10-25", null)).toBe(true);
12
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2026-10-25", null, "2026-10-25")).toBe(true);
13
+ expect((0, is_first_or_last_selected_date_1.isFirstOrLastSelectedDate)("2026-10-25", null, null)).toBe(false);
11
14
  });
@@ -1 +1,2 @@
1
- export declare function isInUnavailableDates(unavailableDates: Date[] | undefined, date: Date): boolean;
1
+ import { DateString } from "@uxf/core/date";
2
+ export declare function isInUnavailableDates(unavailableDates: DateString[] | undefined, date: DateString): boolean;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isInUnavailableDates = isInUnavailableDates;
4
- const dayjs_utils_1 = require("./dayjs-utils");
5
4
  function isInUnavailableDates(unavailableDates = [], date) {
6
- return unavailableDates.some((_date) => (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(_date, "day"));
5
+ return unavailableDates.some((d) => d === date);
7
6
  }