@uxf/datepicker 11.94.0 → 11.96.0-canary.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 (45) hide show
  1. package/hooks/use-date-picker-navigation.js +12 -12
  2. package/hooks/use-date-picker.js +5 -5
  3. package/hooks/use-date-picker.test.js +1 -1
  4. package/hooks/use-date-range-picker.js +17 -17
  5. package/hooks/use-date-range-picker.test.js +2 -2
  6. package/hooks/use-day.js +11 -11
  7. package/hooks/use-day.test.js +5 -5
  8. package/hooks/use-decade.js +5 -5
  9. package/hooks/use-decade.test.js +21 -21
  10. package/hooks/use-month.js +4 -4
  11. package/hooks/use-month.test.js +81 -81
  12. package/hooks/use-year.js +3 -3
  13. package/hooks/use-year.test.js +27 -27
  14. package/package.json +1 -1
  15. package/utils/can-select-range.js +7 -7
  16. package/utils/dayjs-utils.d.ts +4 -0
  17. package/utils/{dayjs-en.js → dayjs-utils.js} +8 -5
  18. package/utils/get-current-year-month-and-date.js +2 -2
  19. package/utils/get-current-year-month-and-date.test.js +2 -2
  20. package/utils/get-date-intervals.test.js +12 -8
  21. package/utils/get-date-invervals.js +3 -3
  22. package/utils/get-date-month-and-year.js +4 -4
  23. package/utils/get-date-month-and-year.test.js +2 -2
  24. package/utils/get-days.js +9 -9
  25. package/utils/get-days.test.js +121 -121
  26. package/utils/get-each.js +7 -90
  27. package/utils/get-each.test.js +15 -15
  28. package/utils/get-initial-months.js +2 -2
  29. package/utils/get-initial-months.test.js +4 -4
  30. package/utils/get-months.js +4 -4
  31. package/utils/get-months.test.js +26 -26
  32. package/utils/get-next-active-month.js +3 -3
  33. package/utils/get-next-active-month.test.js +14 -14
  34. package/utils/get-weekday-labels.js +4 -4
  35. package/utils/get-weekday-labels.test.js +3 -3
  36. package/utils/get-years.js +2 -2
  37. package/utils/get-years.test.js +10 -10
  38. package/utils/is-date-blocked.js +4 -4
  39. package/utils/is-date-hovered.js +8 -8
  40. package/utils/is-date-inside-range.js +2 -2
  41. package/utils/is-end-date.js +2 -2
  42. package/utils/is-first-or-last-selected-date.js +3 -2
  43. package/utils/is-in-unavailable-dates.js +2 -2
  44. package/utils/is-start-date.js +2 -2
  45. package/utils/dayjs-en.d.ts +0 -3
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_1 = require("@testing-library/react");
4
- const dayjs_en_1 = require("../utils/dayjs-en");
4
+ const dayjs_utils_1 = require("../utils/dayjs-utils");
5
5
  const use_month_1 = require("./use-month");
6
6
  test("useMonth", () => {
7
7
  const { result } = (0, react_1.renderHook)(() => (0, use_month_1.useMonth)({
@@ -10,48 +10,48 @@ test("useMonth", () => {
10
10
  }));
11
11
  expect(result.current.monthLabel).toBe("January 2021");
12
12
  expect(result.current.days).toStrictEqual([
13
- { dayLabel: "27", date: new Date("2020-12-27T00:00:00+01:00"), currentMonth: false },
14
- { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00"), currentMonth: false },
15
- { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00"), currentMonth: false },
16
- { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00"), currentMonth: false },
17
- { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00"), currentMonth: false },
18
- { dayLabel: "01", date: new Date("2021-01-01T00:00:00+01:00"), currentMonth: true },
19
- { dayLabel: "02", date: new Date("2021-01-02T00:00:00+01:00"), currentMonth: true },
20
- { dayLabel: "03", date: new Date("2021-01-03T00:00:00+01:00"), currentMonth: true },
21
- { dayLabel: "04", date: new Date("2021-01-04T00:00:00+01:00"), currentMonth: true },
22
- { dayLabel: "05", date: new Date("2021-01-05T00:00:00+01:00"), currentMonth: true },
23
- { dayLabel: "06", date: new Date("2021-01-06T00:00:00+01:00"), currentMonth: true },
24
- { dayLabel: "07", date: new Date("2021-01-07T00:00:00+01:00"), currentMonth: true },
25
- { dayLabel: "08", date: new Date("2021-01-08T00:00:00+01:00"), currentMonth: true },
26
- { dayLabel: "09", date: new Date("2021-01-09T00:00:00+01:00"), currentMonth: true },
27
- { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00"), currentMonth: true },
28
- { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00"), currentMonth: true },
29
- { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00"), currentMonth: true },
30
- { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00"), currentMonth: true },
31
- { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00"), currentMonth: true },
32
- { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00"), currentMonth: true },
33
- { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00"), currentMonth: true },
34
- { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00"), currentMonth: true },
35
- { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00"), currentMonth: true },
36
- { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00"), currentMonth: true },
37
- { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00"), currentMonth: true },
38
- { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00"), currentMonth: true },
39
- { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00"), currentMonth: true },
40
- { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00"), currentMonth: true },
41
- { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00"), currentMonth: true },
42
- { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00"), currentMonth: true },
43
- { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00"), currentMonth: true },
44
- { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00"), currentMonth: true },
45
- { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00"), currentMonth: true },
46
- { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00"), currentMonth: true },
47
- { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00"), currentMonth: true },
48
- { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00"), currentMonth: true },
49
- { dayLabel: "01", date: new Date("2021-02-01T00:00:00+01:00"), currentMonth: false },
50
- { dayLabel: "02", date: new Date("2021-02-02T00:00:00+01:00"), currentMonth: false },
51
- { dayLabel: "03", date: new Date("2021-02-03T00:00:00+01:00"), currentMonth: false },
52
- { dayLabel: "04", date: new Date("2021-02-04T00:00:00+01:00"), currentMonth: false },
53
- { dayLabel: "05", date: new Date("2021-02-05T00:00:00+01:00"), currentMonth: false },
54
- { dayLabel: "06", date: new Date("2021-02-06T00:00:00+01:00"), currentMonth: false },
13
+ { dayLabel: "27", date: new Date("2020-12-27T00:00:00Z"), currentMonth: false },
14
+ { dayLabel: "28", date: new Date("2020-12-28T00:00:00Z"), currentMonth: false },
15
+ { dayLabel: "29", date: new Date("2020-12-29T00:00:00Z"), currentMonth: false },
16
+ { dayLabel: "30", date: new Date("2020-12-30T00:00:00Z"), currentMonth: false },
17
+ { dayLabel: "31", date: new Date("2020-12-31T00:00:00Z"), currentMonth: false },
18
+ { dayLabel: "01", date: new Date("2021-01-01T00:00:00Z"), currentMonth: true },
19
+ { dayLabel: "02", date: new Date("2021-01-02T00:00:00Z"), currentMonth: true },
20
+ { dayLabel: "03", date: new Date("2021-01-03T00:00:00Z"), currentMonth: true },
21
+ { dayLabel: "04", date: new Date("2021-01-04T00:00:00Z"), currentMonth: true },
22
+ { dayLabel: "05", date: new Date("2021-01-05T00:00:00Z"), currentMonth: true },
23
+ { dayLabel: "06", date: new Date("2021-01-06T00:00:00Z"), currentMonth: true },
24
+ { dayLabel: "07", date: new Date("2021-01-07T00:00:00Z"), currentMonth: true },
25
+ { dayLabel: "08", date: new Date("2021-01-08T00:00:00Z"), currentMonth: true },
26
+ { dayLabel: "09", date: new Date("2021-01-09T00:00:00Z"), currentMonth: true },
27
+ { dayLabel: "10", date: new Date("2021-01-10T00:00:00Z"), currentMonth: true },
28
+ { dayLabel: "11", date: new Date("2021-01-11T00:00:00Z"), currentMonth: true },
29
+ { dayLabel: "12", date: new Date("2021-01-12T00:00:00Z"), currentMonth: true },
30
+ { dayLabel: "13", date: new Date("2021-01-13T00:00:00Z"), currentMonth: true },
31
+ { dayLabel: "14", date: new Date("2021-01-14T00:00:00Z"), currentMonth: true },
32
+ { dayLabel: "15", date: new Date("2021-01-15T00:00:00Z"), currentMonth: true },
33
+ { dayLabel: "16", date: new Date("2021-01-16T00:00:00Z"), currentMonth: true },
34
+ { dayLabel: "17", date: new Date("2021-01-17T00:00:00Z"), currentMonth: true },
35
+ { dayLabel: "18", date: new Date("2021-01-18T00:00:00Z"), currentMonth: true },
36
+ { dayLabel: "19", date: new Date("2021-01-19T00:00:00Z"), currentMonth: true },
37
+ { dayLabel: "20", date: new Date("2021-01-20T00:00:00Z"), currentMonth: true },
38
+ { dayLabel: "21", date: new Date("2021-01-21T00:00:00Z"), currentMonth: true },
39
+ { dayLabel: "22", date: new Date("2021-01-22T00:00:00Z"), currentMonth: true },
40
+ { dayLabel: "23", date: new Date("2021-01-23T00:00:00Z"), currentMonth: true },
41
+ { dayLabel: "24", date: new Date("2021-01-24T00:00:00Z"), currentMonth: true },
42
+ { dayLabel: "25", date: new Date("2021-01-25T00:00:00Z"), currentMonth: true },
43
+ { dayLabel: "26", date: new Date("2021-01-26T00:00:00Z"), currentMonth: true },
44
+ { dayLabel: "27", date: new Date("2021-01-27T00:00:00Z"), currentMonth: true },
45
+ { dayLabel: "28", date: new Date("2021-01-28T00:00:00Z"), currentMonth: true },
46
+ { dayLabel: "29", date: new Date("2021-01-29T00:00:00Z"), currentMonth: true },
47
+ { dayLabel: "30", date: new Date("2021-01-30T00:00:00Z"), currentMonth: true },
48
+ { dayLabel: "31", date: new Date("2021-01-31T00:00:00Z"), currentMonth: true },
49
+ { dayLabel: "01", date: new Date("2021-02-01T00:00:00Z"), currentMonth: false },
50
+ { dayLabel: "02", date: new Date("2021-02-02T00:00:00Z"), currentMonth: false },
51
+ { dayLabel: "03", date: new Date("2021-02-03T00:00:00Z"), currentMonth: false },
52
+ { dayLabel: "04", date: new Date("2021-02-04T00:00:00Z"), currentMonth: false },
53
+ { dayLabel: "05", date: new Date("2021-02-05T00:00:00Z"), currentMonth: false },
54
+ { dayLabel: "06", date: new Date("2021-02-06T00:00:00Z"), currentMonth: false },
55
55
  ]);
56
56
  expect(result.current.weekdayLabels).toStrictEqual(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
57
57
  });
@@ -60,47 +60,47 @@ test("useMonth with custom formats and firstDayOfWeek", () => {
60
60
  year: 2021,
61
61
  month: 0,
62
62
  firstDayOfWeek: 1,
63
- monthLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("MM"),
64
- dayLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("D"),
65
- weekdayLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("dddd"),
63
+ monthLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("MM"),
64
+ dayLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("D"),
65
+ weekdayLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("dddd"),
66
66
  }));
67
67
  expect(result.current.monthLabel).toBe("01");
68
68
  expect(result.current.days).toStrictEqual([
69
- { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00"), currentMonth: false },
70
- { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00"), currentMonth: false },
71
- { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00"), currentMonth: false },
72
- { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00"), currentMonth: false },
73
- { dayLabel: "1", date: new Date("2021-01-01T00:00:00+01:00"), currentMonth: true },
74
- { dayLabel: "2", date: new Date("2021-01-02T00:00:00+01:00"), currentMonth: true },
75
- { dayLabel: "3", date: new Date("2021-01-03T00:00:00+01:00"), currentMonth: true },
76
- { dayLabel: "4", date: new Date("2021-01-04T00:00:00+01:00"), currentMonth: true },
77
- { dayLabel: "5", date: new Date("2021-01-05T00:00:00+01:00"), currentMonth: true },
78
- { dayLabel: "6", date: new Date("2021-01-06T00:00:00+01:00"), currentMonth: true },
79
- { dayLabel: "7", date: new Date("2021-01-07T00:00:00+01:00"), currentMonth: true },
80
- { dayLabel: "8", date: new Date("2021-01-08T00:00:00+01:00"), currentMonth: true },
81
- { dayLabel: "9", date: new Date("2021-01-09T00:00:00+01:00"), currentMonth: true },
82
- { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00"), currentMonth: true },
83
- { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00"), currentMonth: true },
84
- { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00"), currentMonth: true },
85
- { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00"), currentMonth: true },
86
- { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00"), currentMonth: true },
87
- { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00"), currentMonth: true },
88
- { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00"), currentMonth: true },
89
- { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00"), currentMonth: true },
90
- { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00"), currentMonth: true },
91
- { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00"), currentMonth: true },
92
- { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00"), currentMonth: true },
93
- { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00"), currentMonth: true },
94
- { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00"), currentMonth: true },
95
- { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00"), currentMonth: true },
96
- { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00"), currentMonth: true },
97
- { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00"), currentMonth: true },
98
- { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00"), currentMonth: true },
99
- { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00"), currentMonth: true },
100
- { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00"), currentMonth: true },
101
- { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00"), currentMonth: true },
102
- { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00"), currentMonth: true },
103
- { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00"), currentMonth: true },
69
+ { dayLabel: "28", date: new Date("2020-12-28T00:00:00Z"), currentMonth: false },
70
+ { dayLabel: "29", date: new Date("2020-12-29T00:00:00Z"), currentMonth: false },
71
+ { dayLabel: "30", date: new Date("2020-12-30T00:00:00Z"), currentMonth: false },
72
+ { dayLabel: "31", date: new Date("2020-12-31T00:00:00Z"), currentMonth: false },
73
+ { dayLabel: "1", date: new Date("2021-01-01T00:00:00Z"), currentMonth: true },
74
+ { dayLabel: "2", date: new Date("2021-01-02T00:00:00Z"), currentMonth: true },
75
+ { dayLabel: "3", date: new Date("2021-01-03T00:00:00Z"), currentMonth: true },
76
+ { dayLabel: "4", date: new Date("2021-01-04T00:00:00Z"), currentMonth: true },
77
+ { dayLabel: "5", date: new Date("2021-01-05T00:00:00Z"), currentMonth: true },
78
+ { dayLabel: "6", date: new Date("2021-01-06T00:00:00Z"), currentMonth: true },
79
+ { dayLabel: "7", date: new Date("2021-01-07T00:00:00Z"), currentMonth: true },
80
+ { dayLabel: "8", date: new Date("2021-01-08T00:00:00Z"), currentMonth: true },
81
+ { dayLabel: "9", date: new Date("2021-01-09T00:00:00Z"), currentMonth: true },
82
+ { dayLabel: "10", date: new Date("2021-01-10T00:00:00Z"), currentMonth: true },
83
+ { dayLabel: "11", date: new Date("2021-01-11T00:00:00Z"), currentMonth: true },
84
+ { dayLabel: "12", date: new Date("2021-01-12T00:00:00Z"), currentMonth: true },
85
+ { dayLabel: "13", date: new Date("2021-01-13T00:00:00Z"), currentMonth: true },
86
+ { dayLabel: "14", date: new Date("2021-01-14T00:00:00Z"), currentMonth: true },
87
+ { dayLabel: "15", date: new Date("2021-01-15T00:00:00Z"), currentMonth: true },
88
+ { dayLabel: "16", date: new Date("2021-01-16T00:00:00Z"), currentMonth: true },
89
+ { dayLabel: "17", date: new Date("2021-01-17T00:00:00Z"), currentMonth: true },
90
+ { dayLabel: "18", date: new Date("2021-01-18T00:00:00Z"), currentMonth: true },
91
+ { dayLabel: "19", date: new Date("2021-01-19T00:00:00Z"), currentMonth: true },
92
+ { dayLabel: "20", date: new Date("2021-01-20T00:00:00Z"), currentMonth: true },
93
+ { dayLabel: "21", date: new Date("2021-01-21T00:00:00Z"), currentMonth: true },
94
+ { dayLabel: "22", date: new Date("2021-01-22T00:00:00Z"), currentMonth: true },
95
+ { dayLabel: "23", date: new Date("2021-01-23T00:00:00Z"), currentMonth: true },
96
+ { dayLabel: "24", date: new Date("2021-01-24T00:00:00Z"), currentMonth: true },
97
+ { dayLabel: "25", date: new Date("2021-01-25T00:00:00Z"), currentMonth: true },
98
+ { dayLabel: "26", date: new Date("2021-01-26T00:00:00Z"), currentMonth: true },
99
+ { dayLabel: "27", date: new Date("2021-01-27T00:00:00Z"), currentMonth: true },
100
+ { dayLabel: "28", date: new Date("2021-01-28T00:00:00Z"), currentMonth: true },
101
+ { dayLabel: "29", date: new Date("2021-01-29T00:00:00Z"), currentMonth: true },
102
+ { dayLabel: "30", date: new Date("2021-01-30T00:00:00Z"), currentMonth: true },
103
+ { dayLabel: "31", date: new Date("2021-01-31T00:00:00Z"), currentMonth: true },
104
104
  ]);
105
105
  expect(result.current.weekdayLabels).toStrictEqual([
106
106
  "Monday",
package/hooks/use-year.js CHANGED
@@ -4,11 +4,11 @@ exports.yearLabelFormatFn = exports.monthLabelFormatFn = void 0;
4
4
  exports.useYear = useYear;
5
5
  const react_1 = require("react");
6
6
  const create_date_string_1 = require("../utils/create-date-string");
7
- const dayjs_en_1 = require("../utils/dayjs-en");
7
+ const dayjs_utils_1 = require("../utils/dayjs-utils");
8
8
  const get_months_1 = require("../utils/get-months");
9
- const monthLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("MMMM"); // localized
9
+ const monthLabelFormatFn = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("MMMM"); // localized
10
10
  exports.monthLabelFormatFn = monthLabelFormatFn;
11
- const yearLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY");
11
+ const yearLabelFormatFn = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("YYYY");
12
12
  exports.yearLabelFormatFn = yearLabelFormatFn;
13
13
  function useYear({ yearLabelFormat = exports.yearLabelFormatFn, monthLabelFormat = exports.monthLabelFormatFn, year, }) {
14
14
  const months = (0, react_1.useMemo)(() => (0, get_months_1.getMonths)({ year, monthLabelFormat }), [year, monthLabelFormat]);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_1 = require("@testing-library/react");
4
- const dayjs_en_1 = require("../utils/dayjs-en");
4
+ const dayjs_utils_1 = require("../utils/dayjs-utils");
5
5
  const use_year_1 = require("./use-year");
6
6
  test("useYear", () => {
7
7
  const { result } = (0, react_1.renderHook)(() => (0, use_year_1.useYear)({
@@ -9,39 +9,39 @@ test("useYear", () => {
9
9
  }));
10
10
  expect(result.current.yearLabel).toBe("2021");
11
11
  expect(result.current.months).toStrictEqual([
12
- { date: new Date("2021-01-01T00:00:00+01:00"), monthLabel: "January" },
13
- { date: new Date("2021-02-01T00:00:00+01:00"), monthLabel: "February" },
14
- { date: new Date("2021-03-01T00:00:00+01:00"), monthLabel: "March" },
15
- { date: new Date("2021-04-01T00:00:00+02:00"), monthLabel: "April" },
16
- { date: new Date("2021-05-01T00:00:00+02:00"), monthLabel: "May" },
17
- { date: new Date("2021-06-01T00:00:00+02:00"), monthLabel: "June" },
18
- { date: new Date("2021-07-01T00:00:00+02:00"), monthLabel: "July" },
19
- { date: new Date("2021-08-01T00:00:00+02:00"), monthLabel: "August" },
20
- { date: new Date("2021-09-01T00:00:00+02:00"), monthLabel: "September" },
21
- { date: new Date("2021-10-01T00:00:00+02:00"), monthLabel: "October" },
22
- { date: new Date("2021-11-01T00:00:00+01:00"), monthLabel: "November" },
23
- { date: new Date("2021-12-01T00:00:00+01:00"), monthLabel: "December" },
12
+ { date: new Date("2021-01-01T00:00:00Z"), monthLabel: "January" },
13
+ { date: new Date("2021-02-01T00:00:00Z"), monthLabel: "February" },
14
+ { date: new Date("2021-03-01T00:00:00Z"), monthLabel: "March" },
15
+ { date: new Date("2021-04-01T00:00:00Z"), monthLabel: "April" },
16
+ { date: new Date("2021-05-01T00:00:00Z"), monthLabel: "May" },
17
+ { date: new Date("2021-06-01T00:00:00Z"), monthLabel: "June" },
18
+ { date: new Date("2021-07-01T00:00:00Z"), monthLabel: "July" },
19
+ { date: new Date("2021-08-01T00:00:00Z"), monthLabel: "August" },
20
+ { date: new Date("2021-09-01T00:00:00Z"), monthLabel: "September" },
21
+ { date: new Date("2021-10-01T00:00:00Z"), monthLabel: "October" },
22
+ { date: new Date("2021-11-01T00:00:00Z"), monthLabel: "November" },
23
+ { date: new Date("2021-12-01T00:00:00Z"), monthLabel: "December" },
24
24
  ]);
25
25
  });
26
26
  test("useYear with custom formats", () => {
27
27
  const { result } = (0, react_1.renderHook)(() => (0, use_year_1.useYear)({
28
28
  year: 2021,
29
- monthLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("MM"),
30
- yearLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("YY"),
29
+ monthLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("MM"),
30
+ yearLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("YY"),
31
31
  }));
32
32
  expect(result.current.yearLabel).toBe("21");
33
33
  expect(result.current.months).toStrictEqual([
34
- { date: new Date("2021-01-01T00:00:00+01:00"), monthLabel: "01" },
35
- { date: new Date("2021-02-01T00:00:00+01:00"), monthLabel: "02" },
36
- { date: new Date("2021-03-01T00:00:00+01:00"), monthLabel: "03" },
37
- { date: new Date("2021-04-01T00:00:00+02:00"), monthLabel: "04" },
38
- { date: new Date("2021-05-01T00:00:00+02:00"), monthLabel: "05" },
39
- { date: new Date("2021-06-01T00:00:00+02:00"), monthLabel: "06" },
40
- { date: new Date("2021-07-01T00:00:00+02:00"), monthLabel: "07" },
41
- { date: new Date("2021-08-01T00:00:00+02:00"), monthLabel: "08" },
42
- { date: new Date("2021-09-01T00:00:00+02:00"), monthLabel: "09" },
43
- { date: new Date("2021-10-01T00:00:00+02:00"), monthLabel: "10" },
44
- { date: new Date("2021-11-01T00:00:00+01:00"), monthLabel: "11" },
45
- { date: new Date("2021-12-01T00:00:00+01:00"), monthLabel: "12" },
34
+ { date: new Date("2021-01-01T00:00:00Z"), monthLabel: "01" },
35
+ { date: new Date("2021-02-01T00:00:00Z"), monthLabel: "02" },
36
+ { date: new Date("2021-03-01T00:00:00Z"), monthLabel: "03" },
37
+ { date: new Date("2021-04-01T00:00:00Z"), monthLabel: "04" },
38
+ { date: new Date("2021-05-01T00:00:00Z"), monthLabel: "05" },
39
+ { date: new Date("2021-06-01T00:00:00Z"), monthLabel: "06" },
40
+ { date: new Date("2021-07-01T00:00:00Z"), monthLabel: "07" },
41
+ { date: new Date("2021-08-01T00:00:00Z"), monthLabel: "08" },
42
+ { date: new Date("2021-09-01T00:00:00Z"), monthLabel: "09" },
43
+ { date: new Date("2021-10-01T00:00:00Z"), monthLabel: "10" },
44
+ { date: new Date("2021-11-01T00:00:00Z"), monthLabel: "11" },
45
+ { date: new Date("2021-12-01T00:00:00Z"), monthLabel: "12" },
46
46
  ]);
47
47
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/datepicker",
3
- "version": "11.94.0",
3
+ "version": "11.96.0-canary.2",
4
4
  "description": "A set of React hooks to create an awesome datepicker.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.canSelectRange = canSelectRange;
4
- const dayjs_en_1 = require("./dayjs-en");
4
+ const dayjs_utils_1 = require("./dayjs-utils");
5
5
  const get_each_1 = require("./get-each");
6
6
  // eslint-disable-next-line complexity
7
7
  function canSelectRange({ startDate, endDate, isDateBlocked, minBookingDays, exactMinBookingDays, minBookingDate, maxBookingDate, }) {
8
8
  const isStartDateAfterOrEqualMinDate = minBookingDate
9
- ? !(0, dayjs_en_1.dayjsEn)(startDate).isBefore((0, dayjs_en_1.dayjsEn)(minBookingDate).subtract(1, "day"))
9
+ ? !(0, dayjs_utils_1.dayjsEnRaw)(startDate).isBefore((0, dayjs_utils_1.dayjsEnRaw)(minBookingDate).subtract(1, "day"))
10
10
  : true;
11
11
  const isStartDateBeforeOrEqualMaxDate = maxBookingDate
12
- ? !(0, dayjs_en_1.dayjsEn)(startDate)
12
+ ? !(0, dayjs_utils_1.dayjsEnRaw)(startDate)
13
13
  .add(minBookingDays - 1, "day")
14
14
  .isAfter(maxBookingDate)
15
15
  : true;
16
16
  const isEndDatBeforeOrEqualMaxDate = maxBookingDate
17
- ? !(0, dayjs_en_1.dayjsEn)(endDate)
17
+ ? !(0, dayjs_utils_1.dayjsEnRaw)(endDate)
18
18
  .add(minBookingDays - 1, "day")
19
19
  .isAfter(maxBookingDate)
20
20
  : true;
@@ -27,15 +27,15 @@ function canSelectRange({ startDate, endDate, isDateBlocked, minBookingDays, exa
27
27
  else if ((minBookingDays > 1 && !endDate && !exactMinBookingDays) ||
28
28
  (minBookingDays > 0 && exactMinBookingDays) ||
29
29
  (minBookingDays > 0 && exactMinBookingDays && !minBookingDate && !maxBookingDate)) {
30
- return !(0, get_each_1.getEach)(startDate, (0, dayjs_en_1.dayjsEn)(startDate)
30
+ return !(0, get_each_1.getEach)(startDate, (0, dayjs_utils_1.dayjsEnRaw)(startDate)
31
31
  .add(minBookingDays - 1, "day")
32
32
  .toDate(), "day").some((d) => isDateBlocked(d));
33
33
  }
34
34
  else if (endDate && !exactMinBookingDays) {
35
- const minBookingDaysDate = (0, dayjs_en_1.dayjsEn)(startDate)
35
+ const minBookingDaysDate = (0, dayjs_utils_1.dayjsEnRaw)(startDate)
36
36
  .add(minBookingDays - 1, "day")
37
37
  .toDate();
38
- if ((0, dayjs_en_1.dayjsEn)(endDate).isBefore(minBookingDaysDate)) {
38
+ if ((0, dayjs_utils_1.dayjsEnRaw)(endDate).isBefore(minBookingDaysDate)) {
39
39
  return false;
40
40
  }
41
41
  return !(0, get_each_1.getEach)(startDate, endDate, "day").some((d) => isDateBlocked(d));
@@ -0,0 +1,4 @@
1
+ import dayjs, { ConfigType } from "dayjs";
2
+ import "dayjs/locale/en";
3
+ export declare const dayjsEnRaw: (value?: ConfigType) => dayjs.Dayjs;
4
+ export declare const dayjsEnWithTz: (value?: ConfigType, tz?: string) => dayjs.Dayjs;
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.dayjsEn = void 0;
39
+ exports.dayjsEnWithTz = exports.dayjsEnRaw = void 0;
40
40
  const dayjs_1 = __importStar(require("dayjs"));
41
41
  require("dayjs/locale/en");
42
42
  const isBetween_1 = __importDefault(require("dayjs/plugin/isBetween"));
@@ -45,8 +45,11 @@ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
45
45
  (0, dayjs_1.extend)(isBetween_1.default);
46
46
  (0, dayjs_1.extend)(timezone_1.default);
47
47
  (0, dayjs_1.extend)(utc_1.default);
48
- const DEFAULT_TIMEZONE = "Europe/Prague";
49
- const dayjsEn = (value) => {
50
- return dayjs_1.default.tz(value, DEFAULT_TIMEZONE).locale("en");
48
+ const dayjsEnRaw = (value) => {
49
+ return (0, dayjs_1.default)(value).locale("en");
51
50
  };
52
- exports.dayjsEn = dayjsEn;
51
+ exports.dayjsEnRaw = dayjsEnRaw;
52
+ const dayjsEnWithTz = (value, tz = "UTC") => {
53
+ return (0, dayjs_1.default)(value).tz(tz).locale("en");
54
+ };
55
+ exports.dayjsEnWithTz = dayjsEnWithTz;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCurrentYearMonthAndDate = getCurrentYearMonthAndDate;
4
- const dayjs_en_1 = require("./dayjs-en");
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 getCurrentYearMonthAndDate() {
7
- return (0, get_date_month_and_year_1.getDateMonthAndYear)((0, dayjs_en_1.dayjsEn)().startOf("day").toDate());
7
+ return (0, get_date_month_and_year_1.getDateMonthAndYear)((0, dayjs_utils_1.dayjsEnWithTz)().startOf("day").toDate());
8
8
  }
@@ -9,12 +9,12 @@ test("getCurrentYearMonthAndDate", () => {
9
9
  expect((0, get_current_year_month_and_date_1.getCurrentYearMonthAndDate)()).toStrictEqual({
10
10
  year: 2021,
11
11
  month: 7,
12
- date: new Date("2021-08-01T00:00:00+02:00"),
12
+ date: new Date("2021-08-01T00:00:00Z"),
13
13
  });
14
14
  jest.setSystemTime(new Date("2020-02-15"));
15
15
  expect((0, get_current_year_month_and_date_1.getCurrentYearMonthAndDate)()).toStrictEqual({
16
16
  year: 2020,
17
17
  month: 1,
18
- date: new Date("2020-02-01T00:00:00+01:00"),
18
+ date: new Date("2020-02-01T00:00:00Z"),
19
19
  });
20
20
  });
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const dayjs_en_1 = require("./dayjs-en");
3
+ const dayjs_utils_1 = require("./dayjs-utils");
4
4
  const get_date_invervals_1 = require("./get-date-invervals");
5
5
  describe("getDateIntervals", () => {
6
6
  it("should return empty array for empty input", () => {
7
7
  expect((0, get_date_invervals_1.getDateIntervals)([])).toStrictEqual([]);
8
8
  });
9
9
  it("should return single date as an interval", () => {
10
- const date = (0, dayjs_en_1.dayjsEn)("2023-10-12").toDate();
10
+ const date = (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-12").toDate();
11
11
  expect((0, get_date_invervals_1.getDateIntervals)([date])).toStrictEqual([{ start: date, end: date }]);
12
12
  });
13
13
  it("should group contiguous dates into intervals", () => {
14
14
  const dates = [
15
- (0, dayjs_en_1.dayjsEn)("2023-10-12").toDate(),
16
- (0, dayjs_en_1.dayjsEn)("2023-10-13").toDate(),
17
- (0, dayjs_en_1.dayjsEn)("2023-10-14").toDate(),
18
- (0, dayjs_en_1.dayjsEn)("2023-10-16").toDate(),
19
- (0, dayjs_en_1.dayjsEn)("2023-10-17").toDate(),
15
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-12").toDate(),
16
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-13").toDate(),
17
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-14").toDate(),
18
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-16").toDate(),
19
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-17").toDate(),
20
20
  ];
21
21
  const expected = [
22
22
  { start: dates.at(0), end: dates.at(2) },
@@ -25,7 +25,11 @@ describe("getDateIntervals", () => {
25
25
  expect((0, get_date_invervals_1.getDateIntervals)(dates)).toStrictEqual(expected);
26
26
  });
27
27
  it("should handle non-contiguous dates", () => {
28
- const dates = [(0, dayjs_en_1.dayjsEn)("2023-10-12").toDate(), (0, dayjs_en_1.dayjsEn)("2023-10-14").toDate(), (0, dayjs_en_1.dayjsEn)("2023-10-16").toDate()];
28
+ const dates = [
29
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-12").toDate(),
30
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-14").toDate(),
31
+ (0, dayjs_utils_1.dayjsEnWithTz)("2023-10-16").toDate(),
32
+ ];
29
33
  const expected = [
30
34
  { start: dates.at(0), end: dates.at(0) },
31
35
  { start: dates.at(1), end: dates.at(1) },
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDateIntervals = getDateIntervals;
4
4
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
5
- const dayjs_en_1 = require("./dayjs-en");
5
+ const dayjs_utils_1 = require("./dayjs-utils");
6
6
  function getDateIntervals(dates) {
7
7
  const sortedDates = dates.slice().sort((a, b) => a.getTime() - b.getTime());
8
8
  const intervals = [];
@@ -11,9 +11,9 @@ function getDateIntervals(dates) {
11
11
  let currentEnd = firstSortedDate !== null && firstSortedDate !== void 0 ? firstSortedDate : new Date();
12
12
  for (let i = 1; i < sortedDates.length; i++) {
13
13
  const currentDate = sortedDates[i];
14
- const nextDate = (0, dayjs_en_1.dayjsEn)(currentEnd).add(1, "day").toDate();
14
+ const nextDate = (0, dayjs_utils_1.dayjsEnRaw)(currentEnd).add(1, "day").toDate();
15
15
  // If the current date matches the expected next date, it's contiguous
16
- if ((0, dayjs_en_1.dayjsEn)(currentDate).isSame(nextDate, "day")) {
16
+ if ((0, dayjs_utils_1.dayjsEnRaw)(currentDate).isSame(nextDate, "day")) {
17
17
  currentEnd = currentDate;
18
18
  }
19
19
  else {
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDateMonthAndYear = getDateMonthAndYear;
4
- const dayjs_en_1 = require("./dayjs-en");
4
+ const dayjs_utils_1 = require("./dayjs-utils");
5
5
  function getDateMonthAndYear(date) {
6
- const day = (0, dayjs_en_1.dayjsEn)(date).startOf("month").toDate();
7
- const year = (0, dayjs_en_1.dayjsEn)(day).year();
8
- const month = (0, dayjs_en_1.dayjsEn)(day).month();
6
+ const day = (0, dayjs_utils_1.dayjsEnWithTz)(date).startOf("month").toDate();
7
+ const year = (0, dayjs_utils_1.dayjsEnWithTz)(day).year();
8
+ const month = (0, dayjs_utils_1.dayjsEnWithTz)(day).month();
9
9
  return {
10
10
  year,
11
11
  month,
@@ -5,11 +5,11 @@ test("getDateMonthAndYear", () => {
5
5
  expect((0, get_date_month_and_year_1.getDateMonthAndYear)(new Date("2021-08-10"))).toStrictEqual({
6
6
  year: 2021,
7
7
  month: 7,
8
- date: new Date("2021-08-01T00:00:00+02:00"),
8
+ date: new Date("2021-08-01T00:00:00Z"),
9
9
  });
10
10
  expect((0, get_date_month_and_year_1.getDateMonthAndYear)(new Date("2020-02-15"))).toStrictEqual({
11
11
  year: 2020,
12
12
  month: 1,
13
- date: new Date("2020-02-01T00:00:00+01:00"),
13
+ date: new Date("2020-02-01T00:00:00Z"),
14
14
  });
15
15
  });
package/utils/get-days.js CHANGED
@@ -2,18 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDays = getDays;
4
4
  const create_date_string_1 = require("./create-date-string");
5
- const dayjs_en_1 = require("./dayjs-en");
5
+ const dayjs_utils_1 = require("./dayjs-utils");
6
6
  const get_each_1 = require("./get-each");
7
- function getDays({ year, month, firstDayOfWeek = 0, dayLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("DD"), }) {
7
+ function getDays({ year, month, firstDayOfWeek = 0, dayLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("DD"), }) {
8
8
  const date = new Date((0, create_date_string_1.createDateString)(year, month));
9
9
  const lastDayOfWeek = firstDayOfWeek + 7;
10
- const monthStart = (0, dayjs_en_1.dayjsEn)(date).startOf("month").toDate();
11
- const monthStartDay = (0, dayjs_en_1.dayjsEn)(monthStart).day();
12
- const monthEnd = (0, dayjs_en_1.dayjsEn)(date).endOf("month").toDate();
13
- const monthEndDay = (0, dayjs_en_1.dayjsEn)(monthEnd).day();
10
+ const monthStart = (0, dayjs_utils_1.dayjsEnWithTz)(date).startOf("month");
11
+ const monthStartDay = monthStart.day();
12
+ const monthEnd = (0, dayjs_utils_1.dayjsEnWithTz)(date).endOf("month");
13
+ const monthEndDay = monthEnd.day();
14
14
  const prevMonthDaysCount = monthStartDay >= firstDayOfWeek ? monthStartDay - firstDayOfWeek : 6 - firstDayOfWeek + monthStartDay + 1;
15
15
  const prevMonthDays = prevMonthDaysCount > 0
16
- ? (0, get_each_1.getEach)((0, dayjs_en_1.dayjsEn)(monthStart).subtract(prevMonthDaysCount, "days").toDate(), (0, dayjs_en_1.dayjsEn)(monthStart).subtract(1, "day").toDate(), "day").map((d) => ({
16
+ ? (0, get_each_1.getEach)(monthStart.subtract(prevMonthDaysCount, "days").toDate(), monthStart.subtract(1, "day").toDate(), "day").map((d) => ({
17
17
  currentMonth: false,
18
18
  date: d,
19
19
  dayLabel: dayLabelFormat(d),
@@ -21,13 +21,13 @@ function getDays({ year, month, firstDayOfWeek = 0, dayLabelFormat = (date) => (
21
21
  : [];
22
22
  const nextMonthDaysCount = lastDayOfWeek - monthEndDay - 1;
23
23
  const nextMonthDays = nextMonthDaysCount > 0 && nextMonthDaysCount < 7
24
- ? (0, get_each_1.getEach)((0, dayjs_en_1.dayjsEn)(monthEnd).add(1, "day").toDate(), (0, dayjs_en_1.dayjsEn)(monthEnd).add(nextMonthDaysCount, "days").toDate(), "day").map((d) => ({
24
+ ? (0, get_each_1.getEach)(monthEnd.add(1, "day").toDate(), monthEnd.add(nextMonthDaysCount, "days").toDate(), "day").map((d) => ({
25
25
  currentMonth: false,
26
26
  date: d,
27
27
  dayLabel: dayLabelFormat(d),
28
28
  }))
29
29
  : [];
30
- const days = (0, get_each_1.getEach)(monthStart, monthEnd, "day").map((d) => ({
30
+ const days = (0, get_each_1.getEach)(monthStart.toDate(), monthEnd.toDate(), "day").map((d) => ({
31
31
  currentMonth: true,
32
32
  date: d,
33
33
  dayLabel: dayLabelFormat(d),