@uxf/datepicker 11.111.0-canary.1 → 11.111.2

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 +3 -4
  2. package/hooks/use-date-picker-navigation.js +34 -30
  3. package/hooks/use-date-picker-navigation.test.js +4 -40
  4. package/hooks/use-date-picker.js +26 -40
  5. package/hooks/use-date-picker.test.js +2 -2
  6. package/hooks/use-date-range-picker.js +76 -103
  7. package/hooks/use-day.js +11 -12
  8. package/hooks/use-decade.js +8 -9
  9. package/package.json +4 -9
  10. package/utils/can-select-range.d.ts +5 -6
  11. package/utils/can-select-range.js +19 -7
  12. package/utils/can-select-range.test.js +27 -30
  13. package/utils/dayjs-utils.d.ts +1 -0
  14. package/utils/dayjs-utils.js +5 -1
  15. package/utils/get-current-year-month-and-date.js +2 -1
  16. package/utils/get-date-invervals.js +5 -2
  17. package/utils/get-date-month-and-year.js +5 -6
  18. package/utils/get-days.js +9 -12
  19. package/utils/get-each.d.ts +1 -2
  20. package/utils/get-each.js +9 -37
  21. package/utils/get-each.test.js +19 -34
  22. package/utils/get-initial-months.js +6 -3
  23. package/utils/get-months.js +7 -7
  24. package/utils/get-next-active-month.js +10 -6
  25. package/utils/get-weekday-labels.js +2 -4
  26. package/utils/get-years.js +4 -5
  27. package/utils/is-date-blocked.d.ts +6 -7
  28. package/utils/is-date-blocked.js +7 -6
  29. package/utils/is-date-blocked.test.js +11 -108
  30. package/utils/is-date-hovered.d.ts +5 -6
  31. package/utils/is-date-hovered.js +24 -17
  32. package/utils/is-date-hovered.test.js +25 -42
  33. package/utils/is-date-inside-range.d.ts +1 -2
  34. package/utils/is-date-inside-range.js +2 -1
  35. package/utils/is-date-selected.test.js +8 -16
  36. package/utils/is-end-date.d.ts +1 -2
  37. package/utils/is-end-date.js +2 -1
  38. package/utils/is-end-date.test.js +6 -11
  39. package/utils/is-first-or-last-selected-date.d.ts +1 -2
  40. package/utils/is-first-or-last-selected-date.js +3 -1
  41. package/utils/is-first-or-last-selected-date.test.js +6 -9
  42. package/utils/is-in-unavailable-dates.d.ts +1 -2
  43. package/utils/is-in-unavailable-dates.js +2 -1
  44. package/utils/is-in-unavailable-dates.test.js +6 -10
  45. package/utils/is-start-date.d.ts +1 -2
  46. package/utils/is-start-date.js +2 -1
  47. package/utils/is-start-date.test.js +6 -12
  48. package/jest.dst.config.js +0 -22
  49. package/jest.dst.global-setup.js +0 -14
  50. package/utils/date-string.d.ts +0 -34
  51. package/utils/date-string.js +0 -64
  52. package/utils/date-string.test.d.ts +0 -1
  53. package/utils/date-string.test.js +0 -63
  54. package/utils/dst-robustness.test.d.ts +0 -11
  55. package/utils/dst-robustness.test.js +0 -328
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNextActiveMonth = getNextActiveMonth;
4
- const date_string_1 = require("./date-string");
4
+ const dayjs_utils_1 = require("./dayjs-utils");
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,15 +11,19 @@ function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
11
11
  else {
12
12
  prevMonth = counter > 0 ? activeMonth.length - 1 : 0;
13
13
  }
14
- let prevMonthStr = (0, date_string_1.toDateString)(activeMonth[prevMonth].date);
14
+ let prevMonthDate = activeMonth[prevMonth].date;
15
15
  return Array.from(Array(numberOfMonths).keys()).reduce((m) => {
16
16
  if (m.length === 0) {
17
- prevMonthStr = (0, date_string_1.addMonths)(prevMonthStr, counter);
17
+ prevMonthDate = (0, dayjs_utils_1.dayjsEnWithTz)(prevMonthDate).add(counter, "month").startOf("month").toDate();
18
18
  }
19
19
  else {
20
- prevMonthStr = (0, date_string_1.addMonths)(prevMonthStr, counter >= 0 ? 1 : -1);
20
+ prevMonthDate = (0, dayjs_utils_1.dayjsEnWithTz)(prevMonthDate)
21
+ .add(counter >= 0 ? 1 : -1, "month")
22
+ .startOf("month")
23
+ .toDate();
21
24
  }
22
- const monthType = (0, get_date_month_and_year_1.getDateMonthAndYear)(new Date(prevMonthStr));
23
- return counter > 0 ? m.concat([monthType]) : [monthType].concat(m);
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);
24
28
  }, []);
25
29
  }
@@ -1,12 +1,10 @@
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");
5
4
  const dayjs_utils_1 = require("./dayjs-utils");
6
5
  const get_each_1 = require("./get-each");
7
6
  function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("dd"), }) {
8
7
  const now = (0, dayjs_utils_1.dayjsEnWithTz)();
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)));
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));
12
10
  }
@@ -1,12 +1,11 @@
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");
5
4
  const dayjs_utils_1 = require("./dayjs-utils");
6
5
  const get_each_1 = require("./get-each");
7
6
  function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("YYYY"), }) {
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
- });
7
+ return (0, get_each_1.getEach)(startYear, endYear, "year").map((d) => ({
8
+ date: d,
9
+ yearLabel: yearLabelFormat(d),
10
+ }));
12
11
  }
@@ -1,13 +1,12 @@
1
- import { DateString } from "@uxf/core/date";
2
1
  interface IsDateBlockedProps {
3
- date: DateString;
4
- startDate: DateString | null;
5
- endDate: DateString | null;
2
+ date: Date;
3
+ startDate: Date | null;
4
+ endDate: Date | null;
6
5
  minBookingDays?: number;
7
- minBookingDate?: DateString;
8
- maxBookingDate?: DateString;
6
+ minBookingDate?: Date;
7
+ maxBookingDate?: Date;
9
8
  isDateBlockedFn?: ((date: Date) => boolean) | null;
10
- unavailableDates?: DateString[];
9
+ unavailableDates?: Date[];
11
10
  }
12
11
  export declare function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays, unavailableDates, }: IsDateBlockedProps): boolean;
13
12
  export {};
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateBlocked = isDateBlocked;
4
- const date_string_1 = require("./date-string");
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
+ const compareMaxDate = maxBookingDate;
7
9
  return Boolean((0, is_in_unavailable_dates_1.isInUnavailableDates)(unavailableDates, date) ||
8
- (minBookingDate && date < minBookingDate) ||
9
- (maxBookingDate && date > maxBookingDate) ||
10
+ (compareMinDate && date < compareMinDate) ||
11
+ (compareMaxDate && date > compareMaxDate) ||
10
12
  (startDate &&
11
13
  !endDate &&
12
14
  minBookingDays > 1 &&
13
- date > startDate &&
14
- date < (0, date_string_1.addDays)(startDate, minBookingDays - 1)) ||
15
- (isDateBlockedFn && isDateBlockedFn((0, date_string_1.fromDateString)(date))));
15
+ (0, dayjs_utils_1.dayjsEnWithTz)(date).isBetween(startDate, (0, dayjs_utils_1.dayjsEnWithTz)(startDate).add(minBookingDays - 1, "day"))) ||
16
+ (isDateBlockedFn && isDateBlockedFn(date)));
16
17
  }
@@ -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: "2021-08-08",
7
+ startDate: new Date("2021-08-08"),
8
8
  endDate: null,
9
9
  minBookingDays: 1,
10
10
  minBookingDate: undefined,
11
11
  maxBookingDate: undefined,
12
- date: "2021-08-08",
12
+ date: new Date("2021-08-08"),
13
13
  unavailableDates: undefined,
14
14
  isDateBlockedFn: () => true,
15
15
  })).toBe(true);
16
- // not blocked
16
+ // start day only
17
17
  expect((0, is_date_blocked_1.isDateBlocked)({
18
- startDate: "2021-08-08",
18
+ startDate: new Date("2021-08-08"),
19
19
  endDate: null,
20
20
  minBookingDays: 1,
21
21
  minBookingDate: undefined,
22
22
  maxBookingDate: undefined,
23
- date: "2021-08-08",
23
+ date: new 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: "2021-08-10",
32
+ minBookingDate: new Date("2021-08-10"),
33
33
  maxBookingDate: undefined,
34
- date: "2021-08-08",
34
+ date: new 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: "2021-08-06",
45
- date: "2021-08-08",
44
+ maxBookingDate: new Date("2021-08-06"),
45
+ date: new Date("2021-08-08"),
46
46
  unavailableDates: undefined,
47
47
  isDateBlockedFn: undefined,
48
48
  })).toBe(true);
@@ -53,105 +53,8 @@ test("isDateBlocked", () => {
53
53
  minBookingDays: 1,
54
54
  minBookingDate: undefined,
55
55
  maxBookingDate: undefined,
56
- date: "2021-08-08",
57
- unavailableDates: ["2021-08-08"],
56
+ date: new Date("2021-08-08"),
57
+ unavailableDates: [new Date("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,10 +1,9 @@
1
- import { DateString } from "@uxf/core/date";
2
1
  export interface IsDateHoveredProps {
3
- startDate: DateString | null;
4
- endDate: DateString | null;
5
- date: DateString;
6
- isDateBlocked: ((date: DateString) => boolean) | null;
7
- hoveredDate: DateString | null;
2
+ startDate: Date | null;
3
+ endDate: Date | null;
4
+ date: Date;
5
+ isDateBlocked: ((date: Date) => boolean) | null;
6
+ hoveredDate: Date | null;
8
7
  minBookingDays: number;
9
8
  exactMinBookingDays: boolean;
10
9
  }
@@ -1,41 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateHovered = isDateHovered;
4
- const date_string_1 = require("./date-string");
4
+ const dayjs_utils_1 = require("./dayjs-utils");
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
- }
9
6
  function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, minBookingDays, exactMinBookingDays, }) {
10
7
  if (
11
8
  // exact min booking days
12
9
  hoveredDate &&
13
10
  minBookingDays > 1 &&
14
11
  exactMinBookingDays &&
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);
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));
18
19
  }
19
20
  else if (
20
- // min booking days (start date hovered)
21
+ // min booking days
21
22
  startDate &&
22
23
  !endDate &&
23
24
  hoveredDate &&
24
- date > startDate &&
25
- date < (0, date_string_1.addDays)(startDate, minBookingDays - 1) &&
26
- startDate === 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") &&
27
27
  minBookingDays > 1) {
28
- return isRangeUnblocked(startDate, (0, date_string_1.addDays)(startDate, minBookingDays - 1), isDateBlocked);
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));
29
34
  }
30
35
  else if (
31
- // normal hover range
36
+ // normal
32
37
  startDate &&
33
38
  !endDate &&
34
39
  hoveredDate &&
35
- hoveredDate >= startDate &&
36
- date > startDate &&
37
- date < hoveredDate) {
38
- return isRangeUnblocked(startDate, hoveredDate, isDateBlocked);
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));
39
46
  }
40
47
  return false;
41
48
  }
@@ -1,89 +1,72 @@
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 — exact min booking days", () => {
5
- // date within exact range but blocked
4
+ test("isDateHovered", () => {
5
+ // exact min booking days
6
6
  expect((0, is_date_hovered_1.isDateHovered)({
7
7
  startDate: null,
8
8
  endDate: null,
9
9
  minBookingDays: 5,
10
- date: "2021-08-08",
11
- hoveredDate: "2021-08-07",
10
+ date: new Date("2021-08-08"),
11
+ hoveredDate: new Date("2021-08-07"),
12
12
  exactMinBookingDays: true,
13
13
  isDateBlocked: () => true,
14
14
  })).toBe(false);
15
- // date within exact range, not blocked
16
15
  expect((0, is_date_hovered_1.isDateHovered)({
17
16
  startDate: null,
18
17
  endDate: null,
19
18
  minBookingDays: 5,
20
- date: "2021-08-08",
21
- hoveredDate: "2021-08-07",
19
+ date: new Date("2021-08-08"),
20
+ hoveredDate: new Date("2021-08-07"),
22
21
  exactMinBookingDays: true,
23
22
  isDateBlocked: () => false,
24
23
  })).toBe(true);
25
- });
26
- test("isDateHovered — min booking days", () => {
24
+ // min booking days
27
25
  expect((0, is_date_hovered_1.isDateHovered)({
28
- startDate: "2021-08-07",
26
+ startDate: new Date("2021-08-07"),
29
27
  endDate: null,
30
28
  minBookingDays: 5,
31
- date: "2021-08-08",
32
- hoveredDate: "2021-08-07",
29
+ date: new Date("2021-08-08"),
30
+ hoveredDate: new Date("2021-08-07"),
33
31
  exactMinBookingDays: false,
34
32
  isDateBlocked: () => true,
35
33
  })).toBe(false);
36
34
  expect((0, is_date_hovered_1.isDateHovered)({
37
- startDate: "2021-08-07",
35
+ startDate: new Date("2021-08-07"),
38
36
  endDate: null,
39
37
  minBookingDays: 5,
40
- date: "2021-08-08",
41
- hoveredDate: "2021-08-07",
38
+ date: new Date("2021-08-08"),
39
+ hoveredDate: new Date("2021-08-07"),
42
40
  exactMinBookingDays: false,
43
41
  isDateBlocked: () => false,
44
42
  })).toBe(true);
45
- });
46
- test("isDateHovered — normal hover range", () => {
47
- // blocked
43
+ // normal
48
44
  expect((0, is_date_hovered_1.isDateHovered)({
49
- startDate: "2021-08-07",
45
+ startDate: new Date("2021-08-07"),
50
46
  endDate: null,
51
47
  minBookingDays: 1,
52
- date: "2021-08-08",
53
- hoveredDate: "2021-08-09",
48
+ date: new Date("2021-08-08"),
49
+ hoveredDate: new Date("2021-08-09"),
54
50
  exactMinBookingDays: false,
55
51
  isDateBlocked: () => true,
56
52
  })).toBe(false);
57
- // not blocked
58
53
  expect((0, is_date_hovered_1.isDateHovered)({
59
- startDate: "2021-08-07",
54
+ startDate: new Date("2021-08-07"),
60
55
  endDate: null,
61
56
  minBookingDays: 1,
62
- date: "2021-08-08",
63
- hoveredDate: "2021-08-09",
57
+ date: new Date("2021-08-08"),
58
+ hoveredDate: new Date("2021-08-09"),
64
59
  exactMinBookingDays: false,
65
60
  isDateBlocked: () => false,
66
61
  })).toBe(true);
67
- });
68
- test("isDateHovered — with endDate returns false", () => {
62
+ // with endDate
69
63
  expect((0, is_date_hovered_1.isDateHovered)({
70
- startDate: "2021-08-07",
71
- endDate: "2021-08-12",
64
+ startDate: new Date("2021-08-07"),
65
+ endDate: new Date("2021-08-12"),
72
66
  minBookingDays: 1,
73
- date: "2021-08-08",
74
- hoveredDate: "2021-08-07",
67
+ date: new Date("2021-08-08"),
68
+ hoveredDate: new Date("2021-08-07"),
75
69
  exactMinBookingDays: false,
76
70
  isDateBlocked: () => true,
77
71
  })).toBe(false);
78
72
  });
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,2 +1 @@
1
- import { DateString } from "@uxf/core/date";
2
- export declare function isDateInsideRange(date: DateString, startDate: DateString | null, endDate: DateString | null): boolean;
1
+ export declare function isDateInsideRange(date: Date, startDate: Date | null, endDate: Date | null): boolean;
@@ -1,9 +1,10 @@
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");
4
5
  function isDateInsideRange(date, startDate, endDate) {
5
6
  if (startDate && endDate) {
6
- return startDate < date && date < endDate;
7
+ return (0, dayjs_utils_1.dayjsEnRaw)(date).isBetween(startDate, endDate);
7
8
  }
8
9
  return false;
9
10
  }
@@ -2,20 +2,12 @@
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)("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
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);
21
13
  });
@@ -1,2 +1 @@
1
- import { DateString } from "@uxf/core/date";
2
- export declare function isEndDate(date: DateString, endDate: DateString | null): boolean;
1
+ export declare function isEndDate(date: Date, endDate: Date | null): boolean;
@@ -1,6 +1,7 @@
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");
4
5
  function isEndDate(date, endDate) {
5
- return date === endDate;
6
+ return Boolean(endDate && (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(endDate, "day"));
6
7
  }
@@ -2,15 +2,10 @@
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)("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);
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);
16
11
  });
@@ -1,2 +1 @@
1
- import { DateString } from "@uxf/core/date";
2
- export declare function isFirstOrLastSelectedDate(date: DateString, startDate: DateString | null, endDate: DateString | null): boolean;
1
+ export declare function isFirstOrLastSelectedDate(date: Date, startDate: Date | null, endDate: Date | null): boolean;
@@ -1,6 +1,8 @@
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");
4
5
  function isFirstOrLastSelectedDate(date, startDate, endDate) {
5
- return Boolean((startDate && date === startDate) || (endDate && date === 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")));
6
8
  }
@@ -2,13 +2,10 @@
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)("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);
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);
14
11
  });
@@ -1,2 +1 @@
1
- import { DateString } from "@uxf/core/date";
2
- export declare function isInUnavailableDates(unavailableDates: DateString[] | undefined, date: DateString): boolean;
1
+ export declare function isInUnavailableDates(unavailableDates: Date[] | undefined, date: Date): boolean;
@@ -1,6 +1,7 @@
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");
4
5
  function isInUnavailableDates(unavailableDates = [], date) {
5
- return unavailableDates.some((d) => d === date);
6
+ return unavailableDates.some((_date) => (0, dayjs_utils_1.dayjsEnRaw)(date).isSame(_date, "day"));
6
7
  }