@uxf/datepicker 16.13.1 → 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 (94) 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 +5 -5
  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 +2 -2
  16. package/hooks/use-day.js +22 -22
  17. package/hooks/use-day.test.js +12 -12
  18. package/hooks/use-decade.d.ts +2 -2
  19. package/hooks/use-decade.js +8 -8
  20. package/hooks/use-decade.test.js +6 -6
  21. package/hooks/use-hour.d.ts +1 -1
  22. package/hooks/use-hour.test.js +3 -3
  23. package/hooks/use-hours.test.js +3 -3
  24. package/hooks/use-minute.d.ts +2 -2
  25. package/hooks/use-minute.test.js +3 -3
  26. package/hooks/use-minutes.test.js +3 -3
  27. package/hooks/use-month.d.ts +2 -2
  28. package/hooks/use-month.js +10 -10
  29. package/hooks/use-month.test.js +7 -7
  30. package/hooks/use-time-picker.d.ts +5 -5
  31. package/hooks/use-time-picker.test.js +5 -5
  32. package/hooks/use-year.d.ts +2 -2
  33. package/hooks/use-year.js +7 -7
  34. package/hooks/use-year.test.js +6 -6
  35. package/package.json +5 -5
  36. package/utils/can-select-range.d.ts +5 -5
  37. package/utils/can-select-range.js +8 -8
  38. package/utils/can-select-range.test.js +10 -10
  39. package/utils/date-string.d.ts +1 -1
  40. package/utils/date-string.js +6 -6
  41. package/utils/date-string.test.js +33 -33
  42. package/utils/dayjs-utils.d.ts +1 -1
  43. package/utils/dayjs-utils.js +8 -41
  44. package/utils/dst-robustness.test.js +74 -74
  45. package/utils/get-current-year-month-and-date.d.ts +1 -1
  46. package/utils/get-current-year-month-and-date.js +2 -2
  47. package/utils/get-current-year-month-and-date.test.js +3 -3
  48. package/utils/get-date-intervals.test.js +15 -15
  49. package/utils/get-date-invervals.js +4 -4
  50. package/utils/get-date-month-and-year.d.ts +1 -1
  51. package/utils/get-date-month-and-year.js +4 -4
  52. package/utils/get-date-month-and-year.test.js +3 -3
  53. package/utils/get-days.d.ts +4 -4
  54. package/utils/get-days.js +17 -17
  55. package/utils/get-days.test.js +5 -5
  56. package/utils/get-each.d.ts +1 -1
  57. package/utils/get-each.js +5 -5
  58. package/utils/get-each.test.js +11 -11
  59. package/utils/get-first-active-month.d.ts +1 -1
  60. package/utils/get-first-active-month.js +2 -2
  61. package/utils/get-first-active-month.test.js +5 -5
  62. package/utils/get-initial-months.d.ts +1 -1
  63. package/utils/get-initial-months.js +6 -6
  64. package/utils/get-initial-months.test.js +5 -5
  65. package/utils/get-months.d.ts +1 -1
  66. package/utils/get-months.js +9 -9
  67. package/utils/get-months.test.js +4 -4
  68. package/utils/get-next-active-month.d.ts +1 -1
  69. package/utils/get-next-active-month.js +6 -6
  70. package/utils/get-next-active-month.test.js +9 -9
  71. package/utils/get-weekday-labels.d.ts +1 -1
  72. package/utils/get-weekday-labels.js +6 -6
  73. package/utils/get-weekday-labels.test.d.ts +1 -1
  74. package/utils/get-weekday-labels.test.js +8 -8
  75. package/utils/get-years.d.ts +1 -1
  76. package/utils/get-years.js +6 -6
  77. package/utils/get-years.test.js +5 -5
  78. package/utils/is-date-blocked.d.ts +5 -5
  79. package/utils/is-date-blocked.js +5 -5
  80. package/utils/is-date-blocked.test.js +16 -16
  81. package/utils/is-date-hovered.d.ts +5 -5
  82. package/utils/is-date-hovered.js +7 -7
  83. package/utils/is-date-hovered.test.js +9 -9
  84. package/utils/is-date-inside-range.d.ts +1 -1
  85. package/utils/is-date-selected.test.js +13 -13
  86. package/utils/is-end-date.d.ts +1 -1
  87. package/utils/is-end-date.test.js +10 -10
  88. package/utils/is-first-or-last-selected-date.d.ts +1 -1
  89. package/utils/is-first-or-last-selected-date.test.js +10 -10
  90. package/utils/is-in-unavailable-dates.d.ts +1 -1
  91. package/utils/is-in-unavailable-dates.test.js +9 -9
  92. package/utils/is-start-date.d.ts +1 -1
  93. package/utils/is-start-date.test.js +10 -10
  94. package/utils/types.d.ts +2 -2
package/utils/get-each.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEach = getEach;
4
- const create_date_string_1 = require("./create-date-string");
5
- const date_string_1 = require("./date-string");
4
+ const create_date_string_ts_1 = require("./create-date-string.js");
5
+ const date_string_ts_1 = require("./date-string.js");
6
6
  const DAY_MS = 86400000;
7
7
  function getEach(start, end, type) {
8
8
  if (type === "day") {
@@ -14,7 +14,7 @@ function getEach(start, end, type) {
14
14
  const count = Math.round((endMs - startMs) / DAY_MS) + 1;
15
15
  const results = new Array(count);
16
16
  for (let i = 0; i < count; i++) {
17
- results[i] = (0, date_string_1.toDateString)(new Date(startMs + i * DAY_MS));
17
+ results[i] = (0, date_string_ts_1.toDateString)(new Date(startMs + i * DAY_MS));
18
18
  }
19
19
  return results;
20
20
  }
@@ -28,7 +28,7 @@ function getEach(start, end, type) {
28
28
  const results = new Array(count);
29
29
  for (let i = 0; i < count; i++) {
30
30
  const totalMonths = sm - 1 + i; // 0-indexed from start month
31
- results[i] = (0, create_date_string_1.createDateString)(sy + Math.floor(totalMonths / 12), totalMonths % 12);
31
+ results[i] = (0, create_date_string_ts_1.createDateString)(sy + Math.floor(totalMonths / 12), totalMonths % 12);
32
32
  }
33
33
  return results;
34
34
  }
@@ -40,7 +40,7 @@ function getEach(start, end, type) {
40
40
  }
41
41
  const results = new Array(ey - sy + 1);
42
42
  for (let i = 0; i < results.length; i++) {
43
- results[i] = (0, create_date_string_1.createDateString)(sy + i);
43
+ results[i] = (0, create_date_string_ts_1.createDateString)(sy + i);
44
44
  }
45
45
  return results;
46
46
  }
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const get_each_1 = require("./get-each");
3
+ const get_each_ts_1 = require("./get-each.js");
4
4
  test("getEach day", () => {
5
- expect((0, get_each_1.getEach)("2021-05-05", "2021-05-07", "day")).toStrictEqual(["2021-05-05", "2021-05-06", "2021-05-07"]);
5
+ expect((0, get_each_ts_1.getEach)("2021-05-05", "2021-05-07", "day")).toStrictEqual(["2021-05-05", "2021-05-06", "2021-05-07"]);
6
6
  });
7
7
  test("getEach day — DST fall-back (Oct 25 2026)", () => {
8
- expect((0, get_each_1.getEach)("2026-10-24", "2026-10-26", "day")).toStrictEqual(["2026-10-24", "2026-10-25", "2026-10-26"]);
8
+ expect((0, get_each_ts_1.getEach)("2026-10-24", "2026-10-26", "day")).toStrictEqual(["2026-10-24", "2026-10-25", "2026-10-26"]);
9
9
  });
10
10
  test("getEach day — DST spring-forward (Mar 29 2026)", () => {
11
- expect((0, get_each_1.getEach)("2026-03-28", "2026-03-30", "day")).toStrictEqual(["2026-03-28", "2026-03-29", "2026-03-30"]);
11
+ expect((0, get_each_ts_1.getEach)("2026-03-28", "2026-03-30", "day")).toStrictEqual(["2026-03-28", "2026-03-29", "2026-03-30"]);
12
12
  });
13
13
  test("getEach month", () => {
14
- expect((0, get_each_1.getEach)("2021-05-05", "2021-08-07", "month")).toStrictEqual([
14
+ expect((0, get_each_ts_1.getEach)("2021-05-05", "2021-08-07", "month")).toStrictEqual([
15
15
  "2021-05-01",
16
16
  "2021-06-01",
17
17
  "2021-07-01",
@@ -19,7 +19,7 @@ test("getEach month", () => {
19
19
  ]);
20
20
  });
21
21
  test("getEach month — year boundary", () => {
22
- expect((0, get_each_1.getEach)("2021-11-01", "2022-02-01", "month")).toStrictEqual([
22
+ expect((0, get_each_ts_1.getEach)("2021-11-01", "2022-02-01", "month")).toStrictEqual([
23
23
  "2021-11-01",
24
24
  "2021-12-01",
25
25
  "2022-01-01",
@@ -27,7 +27,7 @@ test("getEach month — year boundary", () => {
27
27
  ]);
28
28
  });
29
29
  test("getEach year", () => {
30
- expect((0, get_each_1.getEach)("2015-05-05", "2020-05-07", "year")).toStrictEqual([
30
+ expect((0, get_each_ts_1.getEach)("2015-05-05", "2020-05-07", "year")).toStrictEqual([
31
31
  "2015-01-01",
32
32
  "2016-01-01",
33
33
  "2017-01-01",
@@ -37,10 +37,10 @@ test("getEach year", () => {
37
37
  ]);
38
38
  });
39
39
  test("getEach single day", () => {
40
- expect((0, get_each_1.getEach)("2021-05-05", "2021-05-05", "day")).toStrictEqual(["2021-05-05"]);
40
+ expect((0, get_each_ts_1.getEach)("2021-05-05", "2021-05-05", "day")).toStrictEqual(["2021-05-05"]);
41
41
  });
42
42
  test("getEach invalid input throws", () => {
43
- expect(() => (0, get_each_1.getEach)("2015-05-05", "2014-05-07", "day")).toThrow("start must precede end");
44
- expect(() => (0, get_each_1.getEach)("2021-06-01", "2021-05-01", "month")).toThrow("start must precede end");
45
- expect(() => (0, get_each_1.getEach)("2020-01-01", "2019-01-01", "year")).toThrow("start must precede end");
43
+ expect(() => (0, get_each_ts_1.getEach)("2015-05-05", "2014-05-07", "day")).toThrow("start must precede end");
44
+ expect(() => (0, get_each_ts_1.getEach)("2021-06-01", "2021-05-01", "month")).toThrow("start must precede end");
45
+ expect(() => (0, get_each_ts_1.getEach)("2020-01-01", "2019-01-01", "year")).toThrow("start must precede end");
46
46
  });
@@ -1,4 +1,4 @@
1
- import { MonthType } from "./types";
1
+ import { MonthType } from "./types.ts";
2
2
  /**
3
3
  * The first month a date picker shows. `activeMonths` always holds at least one month (`getInitialMonths` starts with
4
4
  * one and navigation keeps the count), so the current month is never returned in practice: it only satisfies the
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFirstActiveMonth = getFirstActiveMonth;
4
- const get_current_year_month_and_date_1 = require("./get-current-year-month-and-date");
4
+ const get_current_year_month_and_date_ts_1 = require("./get-current-year-month-and-date.js");
5
5
  /**
6
6
  * The first month a date picker shows. `activeMonths` always holds at least one month (`getInitialMonths` starts with
7
7
  * one and navigation keeps the count), so the current month is never returned in practice: it only satisfies the
@@ -9,5 +9,5 @@ const get_current_year_month_and_date_1 = require("./get-current-year-month-and-
9
9
  */
10
10
  function getFirstActiveMonth(activeMonths) {
11
11
  var _a;
12
- return (_a = activeMonths.at(0)) !== null && _a !== void 0 ? _a : (0, get_current_year_month_and_date_1.getCurrentYearMonthAndDate)();
12
+ return (_a = activeMonths.at(0)) !== null && _a !== void 0 ? _a : (0, get_current_year_month_and_date_ts_1.getCurrentYearMonthAndDate)();
13
13
  }
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const get_first_active_month_1 = require("./get-first-active-month");
4
- const get_initial_months_1 = require("./get-initial-months");
3
+ const get_first_active_month_ts_1 = require("./get-first-active-month.js");
4
+ const get_initial_months_ts_1 = require("./get-initial-months.js");
5
5
  test("returns the first active month", () => {
6
- const months = (0, get_initial_months_1.getInitialMonths)(2, new Date(2021, 9, 15));
7
- expect((0, get_first_active_month_1.getFirstActiveMonth)(months)).toBe(months.at(0));
6
+ const months = (0, get_initial_months_ts_1.getInitialMonths)(2, new Date(2021, 9, 15));
7
+ expect((0, get_first_active_month_ts_1.getFirstActiveMonth)(months)).toBe(months.at(0));
8
8
  });
9
9
  test("falls back to the current month for an empty list", () => {
10
10
  jest.useFakeTimers().setSystemTime(new Date(2024, 1, 10, 12));
11
- expect((0, get_first_active_month_1.getFirstActiveMonth)([])).toMatchObject({ year: 2024, month: 1 });
11
+ expect((0, get_first_active_month_ts_1.getFirstActiveMonth)([])).toMatchObject({ year: 2024, month: 1 });
12
12
  jest.useRealTimers();
13
13
  });
@@ -1,2 +1,2 @@
1
- import { MonthType } from "./types";
1
+ import { MonthType } from "./types.ts";
2
2
  export declare function getInitialMonths(numberOfMonths: number, startDate: Date | null): MonthType[];
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInitialMonths = getInitialMonths;
4
- const date_string_1 = require("./date-string");
5
- const get_current_year_month_and_date_1 = require("./get-current-year-month-and-date");
6
- const get_date_month_and_year_1 = require("./get-date-month-and-year");
4
+ const date_string_ts_1 = require("./date-string.js");
5
+ const get_current_year_month_and_date_ts_1 = require("./get-current-year-month-and-date.js");
6
+ const get_date_month_and_year_ts_1 = require("./get-date-month-and-year.js");
7
7
  function getInitialMonths(numberOfMonths, startDate) {
8
- const firstMonth = startDate ? (0, get_date_month_and_year_1.getDateMonthAndYear)(startDate) : (0, get_current_year_month_and_date_1.getCurrentYearMonthAndDate)();
8
+ const firstMonth = startDate ? (0, get_date_month_and_year_ts_1.getDateMonthAndYear)(startDate) : (0, get_current_year_month_and_date_ts_1.getCurrentYearMonthAndDate)();
9
9
  let months = [firstMonth];
10
10
  if (numberOfMonths > 1) {
11
11
  months = Array.from(Array(numberOfMonths - 1).keys()).reduce((m) => {
12
- const nextDate = (0, date_string_1.fromDateString)((0, date_string_1.addMonths)((0, date_string_1.toDateString)(m[m.length - 1].date), 1));
13
- return m.concat([(0, get_date_month_and_year_1.getDateMonthAndYear)(nextDate)]);
12
+ const nextDate = (0, date_string_ts_1.fromDateString)((0, date_string_ts_1.addMonths)((0, date_string_ts_1.toDateString)(m[m.length - 1].date), 1));
13
+ return m.concat([(0, get_date_month_and_year_ts_1.getDateMonthAndYear)(nextDate)]);
14
14
  }, months);
15
15
  }
16
16
  return months;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const get_initial_months_1 = require("./get-initial-months");
3
+ const get_initial_months_ts_1 = require("./get-initial-months.js");
4
4
  test("getInitialMonths", () => {
5
- expect((0, get_initial_months_1.getInitialMonths)(1, new Date("2021-09-15"))).toStrictEqual([
5
+ expect((0, get_initial_months_ts_1.getInitialMonths)(1, new Date("2021-09-15"))).toStrictEqual([
6
6
  {
7
7
  date: new Date("2021-09-01T00:00:00Z"),
8
8
  month: 8,
@@ -11,7 +11,7 @@ test("getInitialMonths", () => {
11
11
  ]);
12
12
  });
13
13
  test("getInitialMonths 2 months", () => {
14
- expect((0, get_initial_months_1.getInitialMonths)(2, new Date("2021-09-15"))).toStrictEqual([
14
+ expect((0, get_initial_months_ts_1.getInitialMonths)(2, new Date("2021-09-15"))).toStrictEqual([
15
15
  {
16
16
  date: new Date("2021-09-01T00:00:00Z"),
17
17
  month: 8,
@@ -26,7 +26,7 @@ test("getInitialMonths 2 months", () => {
26
26
  });
27
27
  // ensures that it works correctly on DST change
28
28
  test("getInitialMonths March", () => {
29
- expect((0, get_initial_months_1.getInitialMonths)(2, new Date("2021-03-15"))).toStrictEqual([
29
+ expect((0, get_initial_months_ts_1.getInitialMonths)(2, new Date("2021-03-15"))).toStrictEqual([
30
30
  {
31
31
  date: new Date("2021-03-01T00:00:00Z"),
32
32
  month: 2,
@@ -42,7 +42,7 @@ test("getInitialMonths March", () => {
42
42
  test("getInitialMonths without date", () => {
43
43
  jest.useFakeTimers();
44
44
  jest.setSystemTime(new Date("2021-09-15"));
45
- expect((0, get_initial_months_1.getInitialMonths)(1, null)).toStrictEqual([
45
+ expect((0, get_initial_months_ts_1.getInitialMonths)(1, null)).toStrictEqual([
46
46
  {
47
47
  date: new Date("2021-09-01T00:00:00Z"),
48
48
  month: 8,
@@ -1,6 +1,6 @@
1
1
  export interface GetMonthsProps {
2
- year: number;
3
2
  monthLabelFormat?: (date: Date) => string;
3
+ year: number;
4
4
  }
5
5
  export type CalendarMonth = {
6
6
  monthLabel: string;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMonths = getMonths;
4
- const create_date_string_1 = require("./create-date-string");
5
- const date_string_1 = require("./date-string");
6
- const dayjs_utils_1 = require("./dayjs-utils");
7
- const get_each_1 = require("./get-each");
8
- function getMonths({ year, monthLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("MMMM"), }) {
9
- const yearStart = (0, create_date_string_1.createDateString)(year, 0);
10
- const yearEnd = (0, create_date_string_1.createDateString)(year, 11);
11
- return (0, get_each_1.getEach)(yearStart, yearEnd, "month").map((d) => {
12
- const date = (0, date_string_1.fromDateString)(d);
4
+ const create_date_string_ts_1 = require("./create-date-string.js");
5
+ const date_string_ts_1 = require("./date-string.js");
6
+ const dayjs_utils_ts_1 = require("./dayjs-utils.js");
7
+ const get_each_ts_1 = require("./get-each.js");
8
+ function getMonths({ year, monthLabelFormat = (date) => (0, dayjs_utils_ts_1.dayjsEnWithTz)(date).format("MMMM"), }) {
9
+ const yearStart = (0, create_date_string_ts_1.createDateString)(year, 0);
10
+ const yearEnd = (0, create_date_string_ts_1.createDateString)(year, 11);
11
+ return (0, get_each_ts_1.getEach)(yearStart, yearEnd, "month").map((d) => {
12
+ const date = (0, date_string_ts_1.fromDateString)(d);
13
13
  return { date, monthLabel: monthLabelFormat(date) };
14
14
  });
15
15
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const dayjs_utils_1 = require("./dayjs-utils");
4
- const get_months_1 = require("./get-months");
3
+ const dayjs_utils_ts_1 = require("./dayjs-utils.js");
4
+ const get_months_ts_1 = require("./get-months.js");
5
5
  test("getMonths", () => {
6
- expect((0, get_months_1.getMonths)({ year: 2021 })).toStrictEqual([
6
+ expect((0, get_months_ts_1.getMonths)({ year: 2021 })).toStrictEqual([
7
7
  { monthLabel: "January", date: new Date("2021-01-01T00:00:00Z") },
8
8
  { monthLabel: "February", date: new Date("2021-02-01T00:00:00Z") },
9
9
  { monthLabel: "March", date: new Date("2021-03-01T00:00:00Z") },
@@ -19,7 +19,7 @@ test("getMonths", () => {
19
19
  ]);
20
20
  });
21
21
  test("getMonths with custom format", () => {
22
- expect((0, get_months_1.getMonths)({ year: 2021, monthLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("MM") })).toStrictEqual([
22
+ expect((0, get_months_ts_1.getMonths)({ year: 2021, monthLabelFormat: (date) => (0, dayjs_utils_ts_1.dayjsEnWithTz)(date).format("MM") })).toStrictEqual([
23
23
  { monthLabel: "01", date: new Date("2021-01-01T00:00:00Z") },
24
24
  { monthLabel: "02", date: new Date("2021-02-01T00:00:00Z") },
25
25
  { monthLabel: "03", date: new Date("2021-03-01T00:00:00Z") },
@@ -1,2 +1,2 @@
1
- import { MonthType } from "./types";
1
+ import { MonthType } from "./types.ts";
2
2
  export declare function getNextActiveMonth(activeMonth: MonthType[], numberOfMonths: number, counter: number, step?: number): MonthType[];
@@ -1,8 +1,8 @@
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");
5
- const get_date_month_and_year_1 = require("./get-date-month-and-year");
4
+ const date_string_ts_1 = require("./date-string.js");
5
+ const get_date_month_and_year_ts_1 = require("./get-date-month-and-year.js");
6
6
  function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
7
7
  let prevMonth;
8
8
  if (step) {
@@ -11,15 +11,15 @@ 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 prevMonthStr = (0, date_string_ts_1.toDateString)(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
+ prevMonthStr = (0, date_string_ts_1.addMonths)(prevMonthStr, counter);
18
18
  }
19
19
  else {
20
- prevMonthStr = (0, date_string_1.addMonths)(prevMonthStr, counter >= 0 ? 1 : -1);
20
+ prevMonthStr = (0, date_string_ts_1.addMonths)(prevMonthStr, counter >= 0 ? 1 : -1);
21
21
  }
22
- const monthType = (0, get_date_month_and_year_1.getDateMonthAndYear)(new Date(prevMonthStr));
22
+ const monthType = (0, get_date_month_and_year_ts_1.getDateMonthAndYear)(new Date(prevMonthStr));
23
23
  return counter > 0 ? m.concat([monthType]) : [monthType].concat(m);
24
24
  }, []);
25
25
  }
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const get_next_active_month_1 = require("./get-next-active-month");
3
+ const get_next_active_month_ts_1 = require("./get-next-active-month.js");
4
4
  test("getNextActiveMonth", () => {
5
- expect((0, get_next_active_month_1.getNextActiveMonth)([{ year: 2021, month: 0, date: new Date("2021-01-01") }], 1, 1)).toStrictEqual([
5
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([{ year: 2021, month: 0, date: new Date("2021-01-01") }], 1, 1)).toStrictEqual([
6
6
  { year: 2021, month: 1, date: new Date("2021-02-01T00:00:00Z") },
7
7
  ]);
8
- expect((0, get_next_active_month_1.getNextActiveMonth)([{ year: 2021, month: 9, date: new Date("2021-10-01") }], 1, 1)).toStrictEqual([
8
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([{ year: 2021, month: 9, date: new Date("2021-10-01") }], 1, 1)).toStrictEqual([
9
9
  { year: 2021, month: 10, date: new Date("2021-11-01T00:00:00Z") },
10
10
  ]);
11
11
  });
12
12
  test("getNextActiveMonth with 2 months", () => {
13
- expect((0, get_next_active_month_1.getNextActiveMonth)([
13
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([
14
14
  { year: 2021, month: 0, date: new Date("2021-01-01") },
15
15
  { year: 2021, month: 1, date: new Date("2021-02-01") },
16
16
  ], 2, 1)).toStrictEqual([
@@ -19,7 +19,7 @@ test("getNextActiveMonth with 2 months", () => {
19
19
  ]);
20
20
  });
21
21
  test("getNextActiveMonth with 2 months and step", () => {
22
- expect((0, get_next_active_month_1.getNextActiveMonth)([
22
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([
23
23
  { year: 2021, month: 0, date: new Date("2021-01-01") },
24
24
  { year: 2021, month: 1, date: new Date("2021-02-01") },
25
25
  ], 2, 1, 1)).toStrictEqual([
@@ -28,7 +28,7 @@ test("getNextActiveMonth with 2 months and step", () => {
28
28
  ]);
29
29
  });
30
30
  test("getNextActiveMonth with 2 months and counter 0", () => {
31
- expect((0, get_next_active_month_1.getNextActiveMonth)([
31
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([
32
32
  { year: 2021, month: 0, date: new Date("2021-01-01") },
33
33
  { year: 2021, month: 1, date: new Date("2021-02-01") },
34
34
  ], 2, 0)).toStrictEqual([
@@ -37,7 +37,7 @@ test("getNextActiveMonth with 2 months and counter 0", () => {
37
37
  ]);
38
38
  });
39
39
  test("getNextActiveMonth with 2 months and step and counter 0", () => {
40
- expect((0, get_next_active_month_1.getNextActiveMonth)([
40
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([
41
41
  { year: 2021, month: 0, date: new Date("2021-01-01") },
42
42
  { year: 2021, month: 1, date: new Date("2021-02-01") },
43
43
  ], 2, 0, 1)).toStrictEqual([
@@ -46,7 +46,7 @@ test("getNextActiveMonth with 2 months and step and counter 0", () => {
46
46
  ]);
47
47
  });
48
48
  test("getNextActiveMonth with 2 months and negative counter", () => {
49
- expect((0, get_next_active_month_1.getNextActiveMonth)([
49
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([
50
50
  { year: 2021, month: 0, date: new Date("2021-01-01") },
51
51
  { year: 2021, month: 1, date: new Date("2021-02-01") },
52
52
  ], 2, -1)).toStrictEqual([
@@ -55,7 +55,7 @@ test("getNextActiveMonth with 2 months and negative counter", () => {
55
55
  ]);
56
56
  });
57
57
  test("getNextActiveMonth with 2 months and step and negative counter", () => {
58
- expect((0, get_next_active_month_1.getNextActiveMonth)([
58
+ expect((0, get_next_active_month_ts_1.getNextActiveMonth)([
59
59
  { year: 2021, month: 0, date: new Date("2021-01-01") },
60
60
  { year: 2021, month: 1, date: new Date("2021-02-01") },
61
61
  ], 2, -1, 1)).toStrictEqual([
@@ -1,4 +1,4 @@
1
- import { FirstDayOfWeek } from "./types";
1
+ import { FirstDayOfWeek } from "./types.ts";
2
2
  export interface GetWeekdayLabelsProps {
3
3
  firstDayOfWeek?: FirstDayOfWeek;
4
4
  weekdayLabelFormat?: (date: Date) => string;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWeekdayLabels = getWeekdayLabels;
4
- const date_string_1 = require("./date-string");
5
- const dayjs_utils_1 = require("./dayjs-utils");
6
- const get_each_1 = require("./get-each");
7
- function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("dd"), }) {
8
- const now = (0, dayjs_utils_1.dayjsEnWithTz)();
4
+ const date_string_ts_1 = require("./date-string.js");
5
+ const dayjs_utils_ts_1 = require("./dayjs-utils.js");
6
+ const get_each_ts_1 = require("./get-each.js");
7
+ function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_utils_ts_1.dayjsEnWithTz)(date).format("dd"), }) {
8
+ const now = (0, dayjs_utils_ts_1.dayjsEnWithTz)();
9
9
  const start = now.startOf("week").add(firstDayOfWeek, "day").format("YYYY-MM-DD");
10
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)));
11
+ return (0, get_each_ts_1.getEach)(start, end, "day").map((d) => weekdayLabelFormat((0, date_string_ts_1.fromDateString)(d)));
12
12
  }
@@ -1 +1 @@
1
- import "dayjs/locale/cs";
1
+ import "dayjs/locale/cs.js";
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- require("dayjs/locale/cs");
4
- const dayjs_utils_1 = require("./dayjs-utils");
5
- const get_weekday_labels_1 = require("./get-weekday-labels");
3
+ require("dayjs/locale/cs.js");
4
+ const dayjs_utils_ts_1 = require("./dayjs-utils.js");
5
+ const get_weekday_labels_ts_1 = require("./get-weekday-labels.js");
6
6
  test("getWeekdayLabels", () => {
7
- expect((0, get_weekday_labels_1.getWeekdayLabels)({})).toStrictEqual(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
7
+ expect((0, get_weekday_labels_ts_1.getWeekdayLabels)({})).toStrictEqual(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
8
8
  });
9
9
  test("getWeekdayLabels with custom firstDayOfWeek", () => {
10
- expect((0, get_weekday_labels_1.getWeekdayLabels)({ firstDayOfWeek: 1 })).toStrictEqual(["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]);
10
+ expect((0, get_weekday_labels_ts_1.getWeekdayLabels)({ firstDayOfWeek: 1 })).toStrictEqual(["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]);
11
11
  });
12
12
  test("getWeekdayLabels with custom format", () => {
13
- expect((0, get_weekday_labels_1.getWeekdayLabels)({ weekdayLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("dddd") })).toStrictEqual([
13
+ expect((0, get_weekday_labels_ts_1.getWeekdayLabels)({ weekdayLabelFormat: (date) => (0, dayjs_utils_ts_1.dayjsEnWithTz)(date).format("dddd") })).toStrictEqual([
14
14
  "Sunday",
15
15
  "Monday",
16
16
  "Tuesday",
@@ -21,8 +21,8 @@ test("getWeekdayLabels with custom format", () => {
21
21
  ]);
22
22
  });
23
23
  test("getWeekdayLabels with custom format and locale", () => {
24
- expect((0, get_weekday_labels_1.getWeekdayLabels)({
24
+ expect((0, get_weekday_labels_ts_1.getWeekdayLabels)({
25
25
  firstDayOfWeek: 1,
26
- weekdayLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).locale("cs").format("dddd"),
26
+ weekdayLabelFormat: (date) => (0, dayjs_utils_ts_1.dayjsEnWithTz)(date).locale("cs").format("dddd"),
27
27
  })).toStrictEqual(["pondělí", "úterý", "středa", "čtvrtek", "pátek", "sobota", "neděle"]);
28
28
  });
@@ -1,6 +1,6 @@
1
1
  export interface GetYearsProps {
2
- startYear: Date;
3
2
  endYear: Date;
3
+ startYear: Date;
4
4
  yearLabelFormat?: (date: Date) => string;
5
5
  }
6
6
  export type CalendarYear = {
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getYears = getYears;
4
- const date_string_1 = require("./date-string");
5
- const dayjs_utils_1 = require("./dayjs-utils");
6
- const get_each_1 = require("./get-each");
7
- 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);
4
+ const date_string_ts_1 = require("./date-string.js");
5
+ const dayjs_utils_ts_1 = require("./dayjs-utils.js");
6
+ const get_each_ts_1 = require("./get-each.js");
7
+ function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_utils_ts_1.dayjsEnWithTz)(date).format("YYYY"), }) {
8
+ return (0, get_each_ts_1.getEach)((0, date_string_ts_1.toDateString)(startYear), (0, date_string_ts_1.toDateString)(endYear), "year").map((d) => {
9
+ const date = (0, date_string_ts_1.fromDateString)(d);
10
10
  return { date, yearLabel: yearLabelFormat(date) };
11
11
  });
12
12
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const dayjs_utils_1 = require("./dayjs-utils");
4
- const get_years_1 = require("./get-years");
3
+ const dayjs_utils_ts_1 = require("./dayjs-utils.js");
4
+ const get_years_ts_1 = require("./get-years.js");
5
5
  test("getYears", () => {
6
- expect((0, get_years_1.getYears)({ startYear: new Date("2018-08-15"), endYear: new Date("2021-05-03") })).toStrictEqual([
6
+ expect((0, get_years_ts_1.getYears)({ startYear: new Date("2018-08-15"), endYear: new Date("2021-05-03") })).toStrictEqual([
7
7
  { yearLabel: "2018", date: new Date("2018-01-01T00:00:00Z") },
8
8
  { yearLabel: "2019", date: new Date("2019-01-01T00:00:00Z") },
9
9
  { yearLabel: "2020", date: new Date("2020-01-01T00:00:00Z") },
@@ -11,10 +11,10 @@ test("getYears", () => {
11
11
  ]);
12
12
  });
13
13
  test("getYears with custom format", () => {
14
- expect((0, get_years_1.getYears)({
14
+ expect((0, get_years_ts_1.getYears)({
15
15
  startYear: new Date("2018-08-15"),
16
16
  endYear: new Date("2021-05-03"),
17
- yearLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("YY"),
17
+ yearLabelFormat: (date) => (0, dayjs_utils_ts_1.dayjsEnWithTz)(date).format("YY"),
18
18
  })).toStrictEqual([
19
19
  { yearLabel: "18", date: new Date("2018-01-01T00:00:00Z") },
20
20
  { yearLabel: "19", date: new Date("2019-01-01T00:00:00Z") },
@@ -1,12 +1,12 @@
1
- import { DateString } from "@uxf/core/date";
1
+ import { DateString } from "@uxf/core/date/index.js";
2
2
  interface IsDateBlockedProps {
3
3
  date: DateString;
4
- startDate: DateString | null;
5
4
  endDate: DateString | null;
6
- minBookingDays?: number;
7
- minBookingDate?: DateString;
8
- maxBookingDate?: DateString;
9
5
  isDateBlockedFn?: ((date: Date) => boolean) | null;
6
+ maxBookingDate?: DateString;
7
+ minBookingDate?: DateString;
8
+ minBookingDays?: number;
9
+ startDate: DateString | null;
10
10
  unavailableDates?: DateString[];
11
11
  }
12
12
  export declare function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays, unavailableDates, }: IsDateBlockedProps): boolean;
@@ -1,16 +1,16 @@
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");
5
- const is_in_unavailable_dates_1 = require("./is-in-unavailable-dates");
4
+ const date_string_ts_1 = require("./date-string.js");
5
+ const is_in_unavailable_dates_ts_1 = require("./is-in-unavailable-dates.js");
6
6
  function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays = 1, unavailableDates = [], }) {
7
- return Boolean((0, is_in_unavailable_dates_1.isInUnavailableDates)(unavailableDates, date) ||
7
+ return Boolean((0, is_in_unavailable_dates_ts_1.isInUnavailableDates)(unavailableDates, date) ||
8
8
  (minBookingDate && date < minBookingDate) ||
9
9
  (maxBookingDate && date > maxBookingDate) ||
10
10
  (startDate &&
11
11
  !endDate &&
12
12
  minBookingDays > 1 &&
13
13
  date > startDate &&
14
- date < (0, date_string_1.addDays)(startDate, minBookingDays - 1)) ||
15
- (isDateBlockedFn && isDateBlockedFn((0, date_string_1.fromDateString)(date))));
14
+ date < (0, date_string_ts_1.addDays)(startDate, minBookingDays - 1)) ||
15
+ (isDateBlockedFn && isDateBlockedFn((0, date_string_ts_1.fromDateString)(date))));
16
16
  }