@uxf/datepicker 16.15.0 → 16.16.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 (88) hide show
  1. package/contexts/date-picker-context.d.ts +1 -1
  2. package/contexts/date-picker-context.js +2 -2
  3. package/contexts/date-range-picker-context.d.ts +1 -1
  4. package/contexts/date-range-picker-context.js +2 -2
  5. package/contexts/time-picker-context.js +2 -2
  6. package/hooks/use-date-picker-navigation.d.ts +2 -2
  7. package/hooks/use-date-picker-navigation.js +22 -22
  8. package/hooks/use-date-picker-navigation.test.js +7 -7
  9. package/hooks/use-date-picker.d.ts +2 -2
  10. package/hooks/use-date-picker.js +32 -32
  11. package/hooks/use-date-picker.test.js +7 -7
  12. package/hooks/use-date-range-picker.d.ts +2 -2
  13. package/hooks/use-date-range-picker.js +62 -62
  14. package/hooks/use-date-range-picker.test.js +16 -16
  15. package/hooks/use-day.d.ts +1 -1
  16. package/hooks/use-day.js +22 -22
  17. package/hooks/use-day.test.js +12 -12
  18. package/hooks/use-decade.d.ts +1 -1
  19. package/hooks/use-decade.js +8 -8
  20. package/hooks/use-decade.test.js +6 -6
  21. package/hooks/use-hour.test.js +3 -3
  22. package/hooks/use-hours.test.js +3 -3
  23. package/hooks/use-minute.test.js +3 -3
  24. package/hooks/use-minutes.test.js +3 -3
  25. package/hooks/use-month.d.ts +2 -2
  26. package/hooks/use-month.js +10 -10
  27. package/hooks/use-month.test.js +7 -7
  28. package/hooks/use-time-picker.test.js +5 -5
  29. package/hooks/use-year.d.ts +1 -1
  30. package/hooks/use-year.js +7 -7
  31. package/hooks/use-year.test.js +6 -6
  32. package/package.json +5 -5
  33. package/utils/can-select-range.d.ts +1 -1
  34. package/utils/can-select-range.js +8 -8
  35. package/utils/can-select-range.test.js +10 -10
  36. package/utils/date-string.d.ts +1 -1
  37. package/utils/date-string.js +6 -6
  38. package/utils/date-string.test.js +33 -33
  39. package/utils/dayjs-utils.d.ts +1 -1
  40. package/utils/dayjs-utils.js +8 -41
  41. package/utils/dst-robustness.test.js +74 -74
  42. package/utils/get-current-year-month-and-date.d.ts +1 -1
  43. package/utils/get-current-year-month-and-date.js +2 -2
  44. package/utils/get-current-year-month-and-date.test.js +3 -3
  45. package/utils/get-date-intervals.test.js +15 -15
  46. package/utils/get-date-invervals.js +4 -4
  47. package/utils/get-date-month-and-year.d.ts +1 -1
  48. package/utils/get-date-month-and-year.js +4 -4
  49. package/utils/get-date-month-and-year.test.js +3 -3
  50. package/utils/get-days.d.ts +1 -1
  51. package/utils/get-days.js +17 -17
  52. package/utils/get-days.test.js +5 -5
  53. package/utils/get-each.d.ts +1 -1
  54. package/utils/get-each.js +5 -5
  55. package/utils/get-each.test.js +11 -11
  56. package/utils/get-first-active-month.d.ts +1 -1
  57. package/utils/get-first-active-month.js +2 -2
  58. package/utils/get-first-active-month.test.js +5 -5
  59. package/utils/get-initial-months.d.ts +1 -1
  60. package/utils/get-initial-months.js +6 -6
  61. package/utils/get-initial-months.test.js +5 -5
  62. package/utils/get-months.js +9 -9
  63. package/utils/get-months.test.js +4 -4
  64. package/utils/get-next-active-month.d.ts +1 -1
  65. package/utils/get-next-active-month.js +6 -6
  66. package/utils/get-next-active-month.test.js +9 -9
  67. package/utils/get-weekday-labels.d.ts +1 -1
  68. package/utils/get-weekday-labels.js +6 -6
  69. package/utils/get-weekday-labels.test.d.ts +1 -1
  70. package/utils/get-weekday-labels.test.js +8 -8
  71. package/utils/get-years.js +6 -6
  72. package/utils/get-years.test.js +5 -5
  73. package/utils/is-date-blocked.d.ts +1 -1
  74. package/utils/is-date-blocked.js +5 -5
  75. package/utils/is-date-blocked.test.js +16 -16
  76. package/utils/is-date-hovered.d.ts +1 -1
  77. package/utils/is-date-hovered.js +7 -7
  78. package/utils/is-date-hovered.test.js +9 -9
  79. package/utils/is-date-inside-range.d.ts +1 -1
  80. package/utils/is-date-selected.test.js +13 -13
  81. package/utils/is-end-date.d.ts +1 -1
  82. package/utils/is-end-date.test.js +10 -10
  83. package/utils/is-first-or-last-selected-date.d.ts +1 -1
  84. package/utils/is-first-or-last-selected-date.test.js +10 -10
  85. package/utils/is-in-unavailable-dates.d.ts +1 -1
  86. package/utils/is-in-unavailable-dates.test.js +9 -9
  87. package/utils/is-start-date.d.ts +1 -1
  88. package/utils/is-start-date.test.js +10 -10
@@ -1,3 +1,3 @@
1
- import { UseDatePickerReturnType } from "../hooks/use-date-picker";
1
+ import { UseDatePickerReturnType } from "../hooks/use-date-picker.ts";
2
2
  export type DatePickerContextProps = UseDatePickerReturnType;
3
3
  export declare const DatePickerContext: import("react").Context<UseDatePickerReturnType>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DatePickerContext = void 0;
4
- const global_context_1 = require("@uxf/core-react/global-context");
5
- exports.DatePickerContext = (0, global_context_1.createGlobalContext)("datepicker/date-picker", {
4
+ const index_js_1 = require("@uxf/core-react/global-context/index.js");
5
+ exports.DatePickerContext = (0, index_js_1.createGlobalContext)("datepicker/date-picker", {
6
6
  activeMonths: [],
7
7
  datesConfig: [],
8
8
  canGoToMonth: () => true,
@@ -1,3 +1,3 @@
1
- import { UseDateRangePickerReturnType } from "../hooks/use-date-range-picker";
1
+ import { UseDateRangePickerReturnType } from "../hooks/use-date-range-picker.ts";
2
2
  export type DatePickerContextProps = UseDateRangePickerReturnType;
3
3
  export declare const DateRangePickerContext: import("react").Context<UseDateRangePickerReturnType>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateRangePickerContext = void 0;
4
- const global_context_1 = require("@uxf/core-react/global-context");
5
- exports.DateRangePickerContext = (0, global_context_1.createGlobalContext)("datepicker/date-range-picker", {
4
+ const index_js_1 = require("@uxf/core-react/global-context/index.js");
5
+ exports.DateRangePickerContext = (0, index_js_1.createGlobalContext)("datepicker/date-range-picker", {
6
6
  activeMonths: [],
7
7
  datesConfig: [],
8
8
  canGoToMonth: () => true,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimePickerContext = void 0;
4
- const global_context_1 = require("@uxf/core-react/global-context");
5
- exports.TimePickerContext = (0, global_context_1.createGlobalContext)("datepicker/time-picker", {
4
+ const index_js_1 = require("@uxf/core-react/global-context/index.js");
5
+ exports.TimePickerContext = (0, index_js_1.createGlobalContext)("datepicker/time-picker", {
6
6
  focusedHour: null,
7
7
  focusedMinute: null,
8
8
  isHourFocused: () => false,
@@ -1,6 +1,6 @@
1
- import { DateString } from "@uxf/core/date";
1
+ import { DateString } from "@uxf/core/date/index.js";
2
2
  import { Dispatch, SetStateAction } from "react";
3
- import { MonthType } from "../utils/types";
3
+ import { MonthType } from "../utils/types.ts";
4
4
  export interface UseDatePickerNavigationProps {
5
5
  activeMonths: MonthType[];
6
6
  maxBookingDate?: DateString;
@@ -2,18 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDatePickerNavigation = useDatePickerNavigation;
4
4
  const compiler_runtime_1 = require("react/compiler-runtime");
5
- const create_date_string_1 = require("../utils/create-date-string");
6
- const date_string_1 = require("../utils/date-string");
7
- const get_first_active_month_1 = require("../utils/get-first-active-month");
8
- const get_initial_months_1 = require("../utils/get-initial-months");
9
- const get_next_active_month_1 = require("../utils/get-next-active-month");
5
+ const create_date_string_ts_1 = require("../utils/create-date-string.js");
6
+ const date_string_ts_1 = require("../utils/date-string.js");
7
+ const get_first_active_month_ts_1 = require("../utils/get-first-active-month.js");
8
+ const get_initial_months_ts_1 = require("../utils/get-initial-months.js");
9
+ const get_next_active_month_ts_1 = require("../utils/get-next-active-month.js");
10
10
  function useDatePickerNavigation(t0) {
11
11
  const $ = (0, compiler_runtime_1.c)(62);
12
12
  const { activeMonths, setActiveMonths, setFocusedDate, minBookingDate, maxBookingDate, numberOfMonths } = t0;
13
13
  let t1;
14
14
  if ($[0] !== activeMonths || $[1] !== numberOfMonths || $[2] !== setActiveMonths || $[3] !== setFocusedDate) {
15
15
  t1 = () => {
16
- const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1);
16
+ const newActiveMonths = (0, get_next_active_month_ts_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1);
17
17
  setActiveMonths(newActiveMonths);
18
18
  setFocusedDate(null);
19
19
  return newActiveMonths;
@@ -31,7 +31,7 @@ function useDatePickerNavigation(t0) {
31
31
  let t2;
32
32
  if ($[5] !== activeMonths || $[6] !== numberOfMonths || $[7] !== setActiveMonths || $[8] !== setFocusedDate) {
33
33
  t2 = () => {
34
- const newActiveMonths_0 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1, 1);
34
+ const newActiveMonths_0 = (0, get_next_active_month_ts_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1, 1);
35
35
  setActiveMonths(newActiveMonths_0);
36
36
  setFocusedDate(null);
37
37
  return newActiveMonths_0;
@@ -49,7 +49,7 @@ function useDatePickerNavigation(t0) {
49
49
  let t3;
50
50
  if ($[10] !== activeMonths || $[11] !== numberOfMonths || $[12] !== setActiveMonths || $[13] !== setFocusedDate) {
51
51
  t3 = () => {
52
- const newActiveMonths_1 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1);
52
+ const newActiveMonths_1 = (0, get_next_active_month_ts_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1);
53
53
  setActiveMonths(newActiveMonths_1);
54
54
  setFocusedDate(null);
55
55
  return newActiveMonths_1;
@@ -67,7 +67,7 @@ function useDatePickerNavigation(t0) {
67
67
  let t4;
68
68
  if ($[15] !== activeMonths || $[16] !== numberOfMonths || $[17] !== setActiveMonths || $[18] !== setFocusedDate) {
69
69
  t4 = () => {
70
- const newActiveMonths_2 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1, 1);
70
+ const newActiveMonths_2 = (0, get_next_active_month_ts_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1, 1);
71
71
  setActiveMonths(newActiveMonths_2);
72
72
  setFocusedDate(null);
73
73
  return newActiveMonths_2;
@@ -85,7 +85,7 @@ function useDatePickerNavigation(t0) {
85
85
  let t5;
86
86
  if ($[20] !== numberOfMonths || $[21] !== setActiveMonths || $[22] !== setFocusedDate) {
87
87
  t5 = date => {
88
- const newActiveMonths_3 = (0, get_initial_months_1.getInitialMonths)(numberOfMonths, date);
88
+ const newActiveMonths_3 = (0, get_initial_months_ts_1.getInitialMonths)(numberOfMonths, date);
89
89
  setActiveMonths(newActiveMonths_3);
90
90
  setFocusedDate(null);
91
91
  return newActiveMonths_3;
@@ -103,7 +103,7 @@ function useDatePickerNavigation(t0) {
103
103
  if ($[24] !== activeMonths || $[25] !== numberOfMonths || $[26] !== setActiveMonths || $[27] !== setFocusedDate) {
104
104
  t6 = t7 => {
105
105
  const numYears = t7 === undefined ? 1 : t7;
106
- const newActiveMonths_4 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -(numYears * 12 - numberOfMonths + 1));
106
+ const newActiveMonths_4 = (0, get_next_active_month_ts_1.getNextActiveMonth)(activeMonths, numberOfMonths, -(numYears * 12 - numberOfMonths + 1));
107
107
  setActiveMonths(newActiveMonths_4);
108
108
  setFocusedDate(null);
109
109
  return newActiveMonths_4;
@@ -122,7 +122,7 @@ function useDatePickerNavigation(t0) {
122
122
  if ($[29] !== activeMonths || $[30] !== numberOfMonths || $[31] !== setActiveMonths || $[32] !== setFocusedDate) {
123
123
  t7 = t8 => {
124
124
  const numYears_0 = t8 === undefined ? 1 : t8;
125
- const newActiveMonths_5 = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, numYears_0 * 12 - numberOfMonths + 1);
125
+ const newActiveMonths_5 = (0, get_next_active_month_ts_1.getNextActiveMonth)(activeMonths, numberOfMonths, numYears_0 * 12 - numberOfMonths + 1);
126
126
  setActiveMonths(newActiveMonths_5);
127
127
  setFocusedDate(null);
128
128
  return newActiveMonths_5;
@@ -142,12 +142,12 @@ function useDatePickerNavigation(t0) {
142
142
  let lastYear;
143
143
  let t8;
144
144
  if ($[34] !== activeMonths || $[35] !== maxBookingDate || $[36] !== minBookingDate) {
145
- const firstMonthStr = (0, date_string_1.toDateString)((0, get_first_active_month_1.getFirstActiveMonth)(activeMonths).date);
146
- const lastMonthStr = (0, date_string_1.toDateString)(activeMonths[activeMonths.length - 1].date);
145
+ const firstMonthStr = (0, date_string_ts_1.toDateString)((0, get_first_active_month_ts_1.getFirstActiveMonth)(activeMonths).date);
146
+ const lastMonthStr = (0, date_string_ts_1.toDateString)(activeMonths[activeMonths.length - 1].date);
147
147
  firstYear = parseInt(firstMonthStr.slice(0, 4), 10);
148
148
  lastYear = parseInt(lastMonthStr.slice(0, 4), 10);
149
149
  canGoToPrevMonth = !minBookingDate || minBookingDate <= firstMonthStr;
150
- t8 = !maxBookingDate || (0, date_string_1.addMonths)(lastMonthStr, 1) <= maxBookingDate;
150
+ t8 = !maxBookingDate || (0, date_string_ts_1.addMonths)(lastMonthStr, 1) <= maxBookingDate;
151
151
  $[34] = activeMonths;
152
152
  $[35] = maxBookingDate;
153
153
  $[36] = minBookingDate;
@@ -163,23 +163,23 @@ function useDatePickerNavigation(t0) {
163
163
  t8 = $[40];
164
164
  }
165
165
  const canGoToNextMonth = t8;
166
- const canGoToPrevYear = !minBookingDate || (0, create_date_string_1.createDateString)(firstYear - 1, 11, 31) >= minBookingDate;
167
- const canGoToNextYear = !maxBookingDate || (0, create_date_string_1.createDateString)(lastYear + 1, 0) <= maxBookingDate;
166
+ const canGoToPrevYear = !minBookingDate || (0, create_date_string_ts_1.createDateString)(firstYear - 1, 11, 31) >= minBookingDate;
167
+ const canGoToNextYear = !maxBookingDate || (0, create_date_string_ts_1.createDateString)(lastYear + 1, 0) <= maxBookingDate;
168
168
  let t9;
169
169
  if ($[41] !== maxBookingDate || $[42] !== minBookingDate) {
170
170
  t9 = (month, type) => {
171
171
  if (!minBookingDate && !maxBookingDate) {
172
172
  return true;
173
173
  }
174
- const ds = (0, date_string_1.toDateString)(month);
174
+ const ds = (0, date_string_ts_1.toDateString)(month);
175
175
  const year = parseInt(ds.slice(0, 4), 10);
176
176
  if (type === "month") {
177
- const afterMin = !minBookingDate || (0, date_string_1.addMonths)(ds, 1) > minBookingDate;
178
- const beforeMax = !maxBookingDate || (0, date_string_1.addDays)(ds, -1) < maxBookingDate;
177
+ const afterMin = !minBookingDate || (0, date_string_ts_1.addMonths)(ds, 1) > minBookingDate;
178
+ const beforeMax = !maxBookingDate || (0, date_string_ts_1.addDays)(ds, -1) < maxBookingDate;
179
179
  return afterMin && beforeMax;
180
180
  }
181
- const afterMin_0 = !minBookingDate || (0, create_date_string_1.createDateString)(year + 1, 0) > minBookingDate;
182
- const beforeMax_0 = !maxBookingDate || (0, create_date_string_1.createDateString)(year - 1, 11, 31) < maxBookingDate;
181
+ const afterMin_0 = !minBookingDate || (0, create_date_string_ts_1.createDateString)(year + 1, 0) > minBookingDate;
182
+ const beforeMax_0 = !maxBookingDate || (0, create_date_string_ts_1.createDateString)(year - 1, 11, 31) < maxBookingDate;
183
183
  return afterMin_0 && beforeMax_0;
184
184
  };
185
185
  $[41] = maxBookingDate;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /** @jest-environment jsdom */
4
4
  const react_1 = require("@testing-library/react");
5
5
  const react_2 = require("react");
6
- const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
6
+ const use_date_picker_navigation_ts_1 = require("./use-date-picker-navigation.js");
7
7
  const ACTIVE_MONTHS = [{ date: new Date("2021-09-01"), month: 8, year: 2021 }];
8
8
  test("base data", () => {
9
- const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
9
+ const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_ts_1.useDatePickerNavigation)({
10
10
  activeMonths: ACTIVE_MONTHS,
11
11
  setActiveMonths: () => undefined,
12
12
  numberOfMonths: 1,
@@ -20,7 +20,7 @@ test("base data", () => {
20
20
  expect(result.current.canGoToYear(new Date("2020-01-01"))).toBe(true);
21
21
  });
22
22
  test("base data with min and max date", () => {
23
- const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
23
+ const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_ts_1.useDatePickerNavigation)({
24
24
  activeMonths: ACTIVE_MONTHS,
25
25
  setActiveMonths: () => undefined,
26
26
  numberOfMonths: 1,
@@ -41,7 +41,7 @@ test("canGoToNextMonth edge cases with maxBookingDate", () => {
41
41
  // maxBookingDate = 1st of next month ("2021-10-01"):
42
42
  // "2021-10-01" <= "2021-10-01" → true → can navigate forward
43
43
  // (October has at least one bookable day)
44
- const { result: result1 } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
44
+ const { result: result1 } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_ts_1.useDatePickerNavigation)({
45
45
  activeMonths: ACTIVE_MONTHS,
46
46
  setActiveMonths: () => undefined,
47
47
  numberOfMonths: 1,
@@ -52,7 +52,7 @@ test("canGoToNextMonth edge cases with maxBookingDate", () => {
52
52
  // maxBookingDate = last day of current month ("2021-09-30"):
53
53
  // "2021-10-01" <= "2021-09-30" → false → cannot navigate forward
54
54
  // (October is entirely past maxBookingDate)
55
- const { result: result2 } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
55
+ const { result: result2 } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_ts_1.useDatePickerNavigation)({
56
56
  activeMonths: ACTIVE_MONTHS,
57
57
  setActiveMonths: () => undefined,
58
58
  numberOfMonths: 1,
@@ -62,7 +62,7 @@ test("canGoToNextMonth edge cases with maxBookingDate", () => {
62
62
  expect(result2.current.canGoToNextMonth).toBe(false);
63
63
  // maxBookingDate = mid-next-month ("2021-10-15"):
64
64
  // "2021-10-01" <= "2021-10-15" → true → can navigate forward
65
- const { result: result3 } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
65
+ const { result: result3 } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_ts_1.useDatePickerNavigation)({
66
66
  activeMonths: ACTIVE_MONTHS,
67
67
  setActiveMonths: () => undefined,
68
68
  numberOfMonths: 1,
@@ -75,7 +75,7 @@ test("actions", () => {
75
75
  const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)([{ month: 8, year: 2021, date: new Date("2021-09-01") }]));
76
76
  const { result, rerender } = (0, react_1.renderHook)(() => {
77
77
  const [activeMonths, setActiveMonths] = state.current;
78
- return (0, use_date_picker_navigation_1.useDatePickerNavigation)({
78
+ return (0, use_date_picker_navigation_ts_1.useDatePickerNavigation)({
79
79
  activeMonths,
80
80
  setActiveMonths,
81
81
  numberOfMonths: 1,
@@ -1,5 +1,5 @@
1
- import { DatesConfig, FirstDayOfWeek, MonthType } from "../utils/types";
2
- import { UseDatePickerNavigationReturnType } from "./use-date-picker-navigation";
1
+ import { DatesConfig, FirstDayOfWeek, MonthType } from "../utils/types.ts";
2
+ import { UseDatePickerNavigationReturnType } from "./use-date-picker-navigation.ts";
3
3
  export type OnDateChangeType = Date | null;
4
4
  export interface UseDatePickerProps {
5
5
  datesConfig?: DatesConfig[];
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDatePicker = useDatePicker;
4
4
  const compiler_runtime_1 = require("react/compiler-runtime");
5
- const use_now_1 = require("@uxf/core-react/hooks/use-now");
5
+ const use_now_js_1 = require("@uxf/core-react/hooks/use-now.js");
6
6
  const react_1 = require("react");
7
- const date_string_1 = require("../utils/date-string");
8
- const get_initial_months_1 = require("../utils/get-initial-months");
9
- const is_date_blocked_1 = require("../utils/is-date-blocked");
10
- const is_date_hovered_1 = require("../utils/is-date-hovered");
11
- const is_in_unavailable_dates_1 = require("../utils/is-in-unavailable-dates");
12
- const is_start_date_1 = require("../utils/is-start-date");
13
- const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
7
+ const date_string_ts_1 = require("../utils/date-string.js");
8
+ const get_initial_months_ts_1 = require("../utils/get-initial-months.js");
9
+ const is_date_blocked_ts_1 = require("../utils/is-date-blocked.js");
10
+ const is_date_hovered_ts_1 = require("../utils/is-date-hovered.js");
11
+ const is_in_unavailable_dates_ts_1 = require("../utils/is-in-unavailable-dates.js");
12
+ const is_start_date_ts_1 = require("../utils/is-start-date.js");
13
+ const use_date_picker_navigation_ts_1 = require("./use-date-picker-navigation.js");
14
14
  function useDatePicker(t0) {
15
15
  const $ = (0, compiler_runtime_1.c)(55);
16
16
  const { datesConfig: t1, firstDayOfWeek: t2, initialVisibleMonth, isDateBlocked: t3, maxBookingDate, minBookingDate, numberOfMonths: t4, onDateChange, preventScroll, selectedDate, timeZone, unavailableDates: t5 } = t0;
@@ -19,10 +19,10 @@ function useDatePicker(t0) {
19
19
  const isDateBlockedProps = t3 === undefined ? _temp : t3;
20
20
  const numberOfMonths = t4 === undefined ? 1 : t4;
21
21
  const unavailableDates = t5 === undefined ? [] : t5;
22
- const now = (0, use_now_1.useNow)();
22
+ const now = (0, use_now_js_1.useNow)();
23
23
  let t6;
24
24
  if ($[0] !== selectedDate) {
25
- t6 = selectedDate ? (0, date_string_1.toDateString)(selectedDate) : null;
25
+ t6 = selectedDate ? (0, date_string_ts_1.toDateString)(selectedDate) : null;
26
26
  $[0] = selectedDate;
27
27
  $[1] = t6;
28
28
  }
@@ -30,13 +30,13 @@ function useDatePicker(t0) {
30
30
  t6 = $[1];
31
31
  }
32
32
  const normalizedSelectedDate = t6;
33
- const normalizedMinBookingDate = minBookingDate ? (0, date_string_1.toDateString)(minBookingDate) : undefined;
34
- const normalizedMaxBookingDate = maxBookingDate ? (0, date_string_1.toDateString)(maxBookingDate) : undefined;
33
+ const normalizedMinBookingDate = minBookingDate ? (0, date_string_ts_1.toDateString)(minBookingDate) : undefined;
34
+ const normalizedMaxBookingDate = maxBookingDate ? (0, date_string_ts_1.toDateString)(maxBookingDate) : undefined;
35
35
  const disabledDatesFromConfig = datesConfig.filter(_temp2).flatMap(_temp3);
36
- const allDisabledDates = [...unavailableDates.map(date_string_1.toDateString), ...disabledDatesFromConfig.map(date_string_1.toDateString)];
36
+ const allDisabledDates = [...unavailableDates.map(date_string_ts_1.toDateString), ...disabledDatesFromConfig.map(date_string_ts_1.toDateString)];
37
37
  let t7;
38
38
  if ($[2] !== initialVisibleMonth || $[3] !== now || $[4] !== numberOfMonths || $[5] !== selectedDate || $[6] !== timeZone) {
39
- t7 = () => { var _a; return (0, get_initial_months_1.getInitialMonths)(numberOfMonths, (_a = selectedDate !== null && selectedDate !== void 0 ? selectedDate : initialVisibleMonth) !== null && _a !== void 0 ? _a : (0, date_string_1.fromDateString)((0, date_string_1.todayDateString)(now, timeZone))); };
39
+ t7 = () => { var _a; return (0, get_initial_months_ts_1.getInitialMonths)(numberOfMonths, (_a = selectedDate !== null && selectedDate !== void 0 ? selectedDate : initialVisibleMonth) !== null && _a !== void 0 ? _a : (0, date_string_ts_1.fromDateString)((0, date_string_ts_1.todayDateString)(now, timeZone))); };
40
40
  $[2] = initialVisibleMonth;
41
41
  $[3] = now;
42
42
  $[4] = numberOfMonths;
@@ -50,15 +50,15 @@ function useDatePicker(t0) {
50
50
  const [activeMonths, setActiveMonths] = (0, react_1.useState)(t7);
51
51
  const [hoveredDate, setHoveredDate] = (0, react_1.useState)(null);
52
52
  const [focusedDate, setFocusedDate] = (0, react_1.useState)(normalizedSelectedDate);
53
- const disabledDatesByUser = date => (0, is_in_unavailable_dates_1.isInUnavailableDates)(allDisabledDates, date) || isDateBlockedProps((0, date_string_1.fromDateString)(date));
53
+ const disabledDatesByUser = date => (0, is_in_unavailable_dates_ts_1.isInUnavailableDates)(allDisabledDates, date) || isDateBlockedProps((0, date_string_ts_1.fromDateString)(date));
54
54
  let t8;
55
55
  if ($[8] !== activeMonths || $[9] !== focusedDate || $[10] !== numberOfMonths) {
56
56
  t8 = date_0 => {
57
- const dateStr = (0, date_string_1.toDateString)(date_0);
57
+ const dateStr = (0, date_string_ts_1.toDateString)(date_0);
58
58
  setFocusedDate(dateStr);
59
- const focusedYYYYMM = (0, date_string_1.toDateString)(date_0).slice(0, 7);
59
+ const focusedYYYYMM = (0, date_string_ts_1.toDateString)(date_0).slice(0, 7);
60
60
  if (!focusedDate || !activeMonths.some(m => `${m.year}-${String(m.month + 1).padStart(2, "0")}` === focusedYYYYMM)) {
61
- setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths, date_0));
61
+ setActiveMonths((0, get_initial_months_ts_1.getInitialMonths)(numberOfMonths, date_0));
62
62
  }
63
63
  };
64
64
  $[8] = activeMonths;
@@ -72,7 +72,7 @@ function useDatePicker(t0) {
72
72
  const onDateFocus = t8;
73
73
  let t9;
74
74
  if ($[12] !== normalizedSelectedDate) {
75
- t9 = date_1 => (0, is_start_date_1.isStartDate)((0, date_string_1.toDateString)(date_1), normalizedSelectedDate);
75
+ t9 = date_1 => (0, is_start_date_ts_1.isStartDate)((0, date_string_ts_1.toDateString)(date_1), normalizedSelectedDate);
76
76
  $[12] = normalizedSelectedDate;
77
77
  $[13] = t9;
78
78
  }
@@ -80,8 +80,8 @@ function useDatePicker(t0) {
80
80
  t9 = $[13];
81
81
  }
82
82
  const _isDateSelected = t9;
83
- const _isDateBlocked = date_2 => (0, is_date_blocked_1.isDateBlocked)({
84
- date: (0, date_string_1.toDateString)(date_2),
83
+ const _isDateBlocked = date_2 => (0, is_date_blocked_ts_1.isDateBlocked)({
84
+ date: (0, date_string_ts_1.toDateString)(date_2),
85
85
  minBookingDate: normalizedMinBookingDate,
86
86
  maxBookingDate: normalizedMaxBookingDate,
87
87
  startDate: normalizedSelectedDate,
@@ -92,7 +92,7 @@ function useDatePicker(t0) {
92
92
  });
93
93
  let t10;
94
94
  if ($[14] !== focusedDate) {
95
- t10 = date_3 => focusedDate !== null && (0, date_string_1.toDateString)(date_3) === focusedDate;
95
+ t10 = date_3 => focusedDate !== null && (0, date_string_ts_1.toDateString)(date_3) === focusedDate;
96
96
  $[14] = focusedDate;
97
97
  $[15] = t10;
98
98
  }
@@ -100,8 +100,8 @@ function useDatePicker(t0) {
100
100
  t10 = $[15];
101
101
  }
102
102
  const isDateFocused = t10;
103
- const _isDateHovered = date_4 => (0, is_date_hovered_1.isDateHovered)({
104
- date: (0, date_string_1.toDateString)(date_4),
103
+ const _isDateHovered = date_4 => (0, is_date_hovered_ts_1.isDateHovered)({
104
+ date: (0, date_string_ts_1.toDateString)(date_4),
105
105
  hoveredDate,
106
106
  startDate: normalizedSelectedDate,
107
107
  endDate: normalizedSelectedDate,
@@ -116,7 +116,7 @@ function useDatePicker(t0) {
116
116
  if ((e.key === "ArrowRight" || e.key === "ArrowLeft" || e.key === "ArrowDown" || e.key === "ArrowUp") && !focusedDate) {
117
117
  const activeMonthDate = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : new Date();
118
118
  onDateFocus(activeMonthDate);
119
- setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths, activeMonthDate));
119
+ setActiveMonths((0, get_initial_months_ts_1.getInitialMonths)(numberOfMonths, activeMonthDate));
120
120
  }
121
121
  };
122
122
  $[16] = activeMonths;
@@ -169,7 +169,7 @@ function useDatePicker(t0) {
169
169
  let t15;
170
170
  if ($[26] !== normalizedSelectedDate || $[27] !== onDateChange || $[28] !== onReset) {
171
171
  t15 = function onDateSelect(date_5) {
172
- const dateStr_0 = (0, date_string_1.toDateString)(date_5);
172
+ const dateStr_0 = (0, date_string_ts_1.toDateString)(date_5);
173
173
  if (dateStr_0 !== normalizedSelectedDate) {
174
174
  onDateChange(date_5);
175
175
  }
@@ -191,7 +191,7 @@ function useDatePicker(t0) {
191
191
  setHoveredDate(null);
192
192
  }
193
193
  else {
194
- const dateStr_1 = (0, date_string_1.toDateString)(date_6);
194
+ const dateStr_1 = (0, date_string_ts_1.toDateString)(date_6);
195
195
  const isNotBlocked = !_isDateBlocked(date_6) || normalizedSelectedDate && dateStr_1 === normalizedSelectedDate;
196
196
  if (isNotBlocked) {
197
197
  setHoveredDate(dateStr_1);
@@ -205,13 +205,13 @@ function useDatePicker(t0) {
205
205
  };
206
206
  let t16;
207
207
  if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
208
- t16 = date_7 => setFocusedDate(date_7 ? (0, date_string_1.toDateString)(date_7) : null);
208
+ t16 = date_7 => setFocusedDate(date_7 ? (0, date_string_ts_1.toDateString)(date_7) : null);
209
209
  $[30] = t16;
210
210
  }
211
211
  else {
212
212
  t16 = $[30];
213
213
  }
214
- const t17 = (0, use_date_picker_navigation_1.useDatePickerNavigation)({
214
+ const t17 = (0, use_date_picker_navigation_ts_1.useDatePickerNavigation)({
215
215
  activeMonths,
216
216
  maxBookingDate: normalizedMaxBookingDate,
217
217
  minBookingDate: normalizedMinBookingDate,
@@ -221,7 +221,7 @@ function useDatePicker(t0) {
221
221
  });
222
222
  let t18;
223
223
  if ($[31] !== focusedDate) {
224
- t18 = focusedDate ? (0, date_string_1.fromDateString)(focusedDate) : null;
224
+ t18 = focusedDate ? (0, date_string_ts_1.fromDateString)(focusedDate) : null;
225
225
  $[31] = focusedDate;
226
226
  $[32] = t18;
227
227
  }
@@ -230,14 +230,14 @@ function useDatePicker(t0) {
230
230
  }
231
231
  let t19;
232
232
  if ($[33] !== hoveredDate) {
233
- t19 = hoveredDate ? (0, date_string_1.fromDateString)(hoveredDate) : null;
233
+ t19 = hoveredDate ? (0, date_string_ts_1.fromDateString)(hoveredDate) : null;
234
234
  $[33] = hoveredDate;
235
235
  $[34] = t19;
236
236
  }
237
237
  else {
238
238
  t19 = $[34];
239
239
  }
240
- const t20 = allDisabledDates.map(date_string_1.fromDateString);
240
+ const t20 = allDisabledDates.map(date_string_ts_1.fromDateString);
241
241
  let t21;
242
242
  if ($[35] !== _isDateBlocked || $[36] !== _isDateHovered || $[37] !== _isDateSelected || $[38] !== activeMonths || $[39] !== datesConfig || $[40] !== firstDayOfWeek || $[41] !== isDateFocused || $[42] !== numberOfMonths || $[43] !== onDateFocus || $[44] !== onDateHover || $[45] !== onDateSelect || $[46] !== onReset || $[47] !== preventScroll || $[48] !== selectedDate || $[49] !== t17 || $[50] !== t18 || $[51] !== t19 || $[52] !== t20 || $[53] !== timeZone) {
243
243
  t21 = {
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /** @jest-environment jsdom */
4
4
  const react_1 = require("@testing-library/react");
5
5
  const react_2 = require("react");
6
- const use_date_picker_1 = require("./use-date-picker");
6
+ const use_date_picker_ts_1 = require("./use-date-picker.js");
7
7
  test("base data", () => {
8
8
  const BASE_DATE = new Date("2021-09-15T00:00:00Z");
9
- const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({
9
+ const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_ts_1.useDatePicker)({
10
10
  selectedDate: BASE_DATE,
11
11
  onDateChange: () => undefined,
12
12
  minBookingDate: new Date("2020-01-01T00:00:00Z"),
@@ -28,7 +28,7 @@ test("date focus", () => {
28
28
  const BASE_DATE = new Date("2021-09-15");
29
29
  const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)(BASE_DATE));
30
30
  const [selectedDate, setSelectedDate] = state.current;
31
- const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({ selectedDate, onDateChange: setSelectedDate }));
31
+ const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_ts_1.useDatePicker)({ selectedDate, onDateChange: setSelectedDate }));
32
32
  const NEW_DATE = new Date("2022-12-22");
33
33
  expect(result.current.isDateFocused(BASE_DATE)).toBe(true);
34
34
  expect(result.current.isDateFocused(NEW_DATE)).toBe(false);
@@ -43,7 +43,7 @@ test("date select", () => {
43
43
  const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)(BASE_DATE));
44
44
  const { result, rerender } = (0, react_1.renderHook)(() => {
45
45
  const [selectedDate, setSelectedDate] = state.current;
46
- return (0, use_date_picker_1.useDatePicker)({ selectedDate, onDateChange: setSelectedDate });
46
+ return (0, use_date_picker_ts_1.useDatePicker)({ selectedDate, onDateChange: setSelectedDate });
47
47
  });
48
48
  const NEW_DATE = new Date("2022-12-22");
49
49
  expect(result.current.isDateSelected(BASE_DATE)).toBe(true);
@@ -82,14 +82,14 @@ describe("time zone", () => {
82
82
  });
83
83
  afterAll(() => jest.useRealTimers());
84
84
  test("opens on the month of today in the given time zone", () => {
85
- const render = (timeZone) => (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({ selectedDate: null, onDateChange: () => undefined, timeZone })).result
85
+ const render = (timeZone) => (0, react_1.renderHook)(() => (0, use_date_picker_ts_1.useDatePicker)({ selectedDate: null, onDateChange: () => undefined, timeZone })).result
86
86
  .current;
87
87
  expect(render("Europe/Prague").activeMonths[0]).toMatchObject({ year: 2026, month: 11 });
88
88
  expect(render("America/Los_Angeles").activeMonths[0]).toMatchObject({ year: 2026, month: 10 });
89
89
  expect(render("Europe/Prague").timeZone).toBe("Europe/Prague");
90
90
  });
91
91
  test("opens on initialVisibleMonth rather than today when nothing is selected", () => {
92
- const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({
92
+ const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_ts_1.useDatePicker)({
93
93
  selectedDate: null,
94
94
  initialVisibleMonth: new Date("2023-05-10"),
95
95
  onDateChange: () => undefined,
@@ -98,7 +98,7 @@ describe("time zone", () => {
98
98
  expect(result.current.activeMonths[0]).toMatchObject({ year: 2023, month: 4 });
99
99
  });
100
100
  test("opens on the selected date rather than initialVisibleMonth", () => {
101
- const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({
101
+ const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_ts_1.useDatePicker)({
102
102
  selectedDate: new Date("2024-03-10"),
103
103
  initialVisibleMonth: new Date("2023-05-10"),
104
104
  onDateChange: () => undefined,
@@ -1,5 +1,5 @@
1
- import { DatesConfig, FirstDayOfWeek, MonthType } from "../utils/types";
2
- import { UseDatePickerNavigationReturnType } from "./use-date-picker-navigation";
1
+ import { DatesConfig, FirstDayOfWeek, MonthType } from "../utils/types.ts";
2
+ import { UseDatePickerNavigationReturnType } from "./use-date-picker-navigation.ts";
3
3
  export declare const START_DATE = "startDate";
4
4
  export declare const END_DATE = "endDate";
5
5
  export type FocusedInput = "startDate" | "endDate" | null;