@uxf/datepicker 11.25.0 → 11.32.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.
- package/contexts/date-picker-context.d.ts +0 -1
- package/contexts/date-range-picker-context.d.ts +0 -1
- package/contexts/time-picker-context.d.ts +0 -1
- package/hooks/use-date-picker-navigation.js +8 -4
- package/hooks/use-date-picker-navigation.test.js +13 -13
- package/hooks/use-date-picker.js +5 -5
- package/hooks/use-date-picker.test.js +12 -12
- package/hooks/use-date-range-picker.js +6 -5
- package/hooks/use-date-range-picker.test.js +11 -11
- package/hooks/use-day.js +4 -4
- package/hooks/use-day.test.js +10 -10
- package/hooks/use-decade.js +2 -2
- package/hooks/use-decade.test.js +3 -3
- package/hooks/use-hour.js +1 -2
- package/hooks/use-hour.test.js +6 -6
- package/hooks/use-hours.js +2 -2
- package/hooks/use-hours.test.js +3 -3
- package/hooks/use-minute.js +1 -2
- package/hooks/use-minute.test.js +6 -6
- package/hooks/use-minutes.js +2 -2
- package/hooks/use-minutes.test.js +3 -3
- package/hooks/use-month.js +2 -2
- package/hooks/use-month.test.js +3 -3
- package/hooks/use-time-picker.js +1 -2
- package/hooks/use-time-picker.test.js +17 -17
- package/hooks/use-year.js +2 -2
- package/hooks/use-year.test.js +3 -3
- package/package.json +6 -6
- package/utils/can-select-range.js +1 -2
- package/utils/get-current-year-month-and-date.js +1 -2
- package/utils/get-date-invervals.js +6 -5
- package/utils/get-date-month-and-year.js +1 -2
- package/utils/get-days.js +1 -2
- package/utils/get-each.js +1 -2
- package/utils/get-initial-months.js +1 -2
- package/utils/get-months.js +1 -2
- package/utils/get-next-active-month.js +1 -2
- package/utils/get-weekday-labels.js +1 -2
- package/utils/get-years.js +1 -2
- package/utils/is-browser.js +1 -1
- package/utils/is-date-blocked.js +2 -3
- package/utils/is-date-hovered.js +1 -2
- package/utils/is-date-inside-range.js +1 -2
- package/utils/is-end-date.js +2 -3
- package/utils/is-first-or-last-selected-date.js +2 -4
- package/utils/is-in-unavailable-dates.js +1 -2
- package/utils/is-start-date.js +2 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { UseDateRangePickerReturnType } from "../hooks/use-date-range-picker";
|
|
3
2
|
export type DatePickerContextProps = UseDateRangePickerReturnType;
|
|
4
3
|
export declare const DateRangePickerContext: import("react").Context<UseDateRangePickerReturnType>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useDatePickerNavigation =
|
|
3
|
+
exports.useDatePickerNavigation = useDatePickerNavigation;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
6
|
const get_initial_months_1 = require("../utils/get-initial-months");
|
|
7
7
|
const get_next_active_month_1 = require("../utils/get-next-active-month");
|
|
8
8
|
function useDatePickerNavigation({ activeMonths, setActiveMonths, setFocusedDate, minBookingDate, maxBookingDate, numberOfMonths, }) {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
9
10
|
const goToPrevMonths = (0, react_1.useCallback)(() => {
|
|
10
11
|
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1);
|
|
11
12
|
setActiveMonths(newActiveMonths);
|
|
@@ -48,14 +49,18 @@ function useDatePickerNavigation({ activeMonths, setActiveMonths, setFocusedDate
|
|
|
48
49
|
setFocusedDate(null);
|
|
49
50
|
return newActiveMonths;
|
|
50
51
|
}, [activeMonths, numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
51
|
-
const canGoToPrevMonth = minBookingDate
|
|
52
|
+
const canGoToPrevMonth = minBookingDate
|
|
53
|
+
? !(0, dayjs_en_1.dayjsEn)((_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : new Date()).isBefore((0, dayjs_en_1.dayjsEn)(minBookingDate))
|
|
54
|
+
: true;
|
|
52
55
|
const canGoToNextMonth = maxBookingDate
|
|
53
56
|
? !(0, dayjs_en_1.dayjsEn)(activeMonths[activeMonths.length - 1].date)
|
|
54
57
|
.endOf("month")
|
|
55
58
|
.isAfter((0, dayjs_en_1.dayjsEn)(maxBookingDate))
|
|
56
59
|
: true;
|
|
57
60
|
const canGoToPrevYear = minBookingDate
|
|
58
|
-
? !(0, dayjs_en_1.dayjsEn)(activeMonths
|
|
61
|
+
? !(0, dayjs_en_1.dayjsEn)((_d = (_c = activeMonths.at(0)) === null || _c === void 0 ? void 0 : _c.date) !== null && _d !== void 0 ? _d : new Date())
|
|
62
|
+
.startOf("year")
|
|
63
|
+
.isBefore((0, dayjs_en_1.dayjsEn)(minBookingDate))
|
|
59
64
|
: true;
|
|
60
65
|
const canGoToNextYear = maxBookingDate
|
|
61
66
|
? !(0, dayjs_en_1.dayjsEn)(activeMonths[activeMonths.length - 1].date)
|
|
@@ -95,4 +100,3 @@ function useDatePickerNavigation({ activeMonths, setActiveMonths, setFocusedDate
|
|
|
95
100
|
goToPrevYear,
|
|
96
101
|
};
|
|
97
102
|
}
|
|
98
|
-
exports.useDatePickerNavigation = useDatePickerNavigation;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
|
+
const react_2 = require("react");
|
|
5
5
|
const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
|
|
6
6
|
const ACTIVE_MONTHS = [{ date: new Date("2021-09-01"), month: 8, year: 2021 }];
|
|
7
7
|
test("base data", () => {
|
|
8
|
-
const { result } = (0,
|
|
8
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
|
|
9
9
|
activeMonths: ACTIVE_MONTHS,
|
|
10
10
|
setActiveMonths: () => undefined,
|
|
11
11
|
numberOfMonths: 1,
|
|
@@ -19,7 +19,7 @@ test("base data", () => {
|
|
|
19
19
|
expect(result.current.canGoToYear(new Date("2020-01-01"))).toBe(true);
|
|
20
20
|
});
|
|
21
21
|
test("base data with min and max date", () => {
|
|
22
|
-
const { result } = (0,
|
|
22
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
|
|
23
23
|
activeMonths: ACTIVE_MONTHS,
|
|
24
24
|
setActiveMonths: () => undefined,
|
|
25
25
|
numberOfMonths: 1,
|
|
@@ -35,8 +35,8 @@ test("base data with min and max date", () => {
|
|
|
35
35
|
expect(result.current.canGoToYear(new Date("2026-01-01"))).toBe(false);
|
|
36
36
|
});
|
|
37
37
|
test("actions", () => {
|
|
38
|
-
const { result: state } = (0,
|
|
39
|
-
const { result, rerender } = (0,
|
|
38
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)([{ month: 8, year: 2021, date: new Date("2021-09-01") }]));
|
|
39
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_date_picker_navigation_1.useDatePickerNavigation)({
|
|
40
40
|
activeMonths: state.current[0],
|
|
41
41
|
setActiveMonths: (data) => state.current[1](data),
|
|
42
42
|
numberOfMonths: 1,
|
|
@@ -46,28 +46,28 @@ test("actions", () => {
|
|
|
46
46
|
}));
|
|
47
47
|
// go to year 2020
|
|
48
48
|
expect(result.current.canGoToPrevYear).toBe(true);
|
|
49
|
-
(0,
|
|
49
|
+
(0, react_1.act)(() => {
|
|
50
50
|
result.current.goToPrevYear();
|
|
51
51
|
rerender();
|
|
52
52
|
});
|
|
53
53
|
expect(result.current.canGoToPrevYear).toBe(false);
|
|
54
54
|
expect(result.current.canGoToNextYear).toBe(true);
|
|
55
55
|
// go to year 2022
|
|
56
|
-
(0,
|
|
56
|
+
(0, react_1.act)(() => {
|
|
57
57
|
result.current.goToNextYear(2);
|
|
58
58
|
rerender();
|
|
59
59
|
});
|
|
60
60
|
expect(result.current.canGoToPrevYear).toBe(true);
|
|
61
61
|
expect(result.current.canGoToNextYear).toBe(false);
|
|
62
62
|
// go back to year 2021
|
|
63
|
-
(0,
|
|
63
|
+
(0, react_1.act)(() => {
|
|
64
64
|
result.current.goToPrevYear();
|
|
65
65
|
rerender();
|
|
66
66
|
});
|
|
67
67
|
expect(result.current.canGoToPrevYear).toBe(true);
|
|
68
68
|
expect(result.current.canGoToNextYear).toBe(true);
|
|
69
69
|
// go to prev month
|
|
70
|
-
(0,
|
|
70
|
+
(0, react_1.act)(() => {
|
|
71
71
|
result.current.goToPrevMonths();
|
|
72
72
|
result.current.goToPrevMonthsByOneMonth();
|
|
73
73
|
rerender();
|
|
@@ -75,7 +75,7 @@ test("actions", () => {
|
|
|
75
75
|
expect(result.current.canGoToPrevMonth).toBe(true);
|
|
76
76
|
expect(result.current.canGoToNextMonth).toBe(true);
|
|
77
77
|
// go to next month
|
|
78
|
-
(0,
|
|
78
|
+
(0, react_1.act)(() => {
|
|
79
79
|
result.current.goToNextMonths();
|
|
80
80
|
result.current.goToNextMonthsByOneMonth();
|
|
81
81
|
rerender();
|
|
@@ -83,13 +83,13 @@ test("actions", () => {
|
|
|
83
83
|
expect(result.current.canGoToPrevMonth).toBe(true);
|
|
84
84
|
expect(result.current.canGoToNextMonth).toBe(true);
|
|
85
85
|
// go to month
|
|
86
|
-
(0,
|
|
86
|
+
(0, react_1.act)(() => {
|
|
87
87
|
result.current.goToDate(new Date("2020-12-30"));
|
|
88
88
|
rerender();
|
|
89
89
|
});
|
|
90
90
|
expect(result.current.canGoToPrevMonth).toBe(false);
|
|
91
91
|
expect(result.current.canGoToNextMonth).toBe(true);
|
|
92
|
-
(0,
|
|
92
|
+
(0, react_1.act)(() => {
|
|
93
93
|
result.current.goToDate(new Date("2022-03-01"));
|
|
94
94
|
rerender();
|
|
95
95
|
});
|
package/hooks/use-date-picker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useDatePicker =
|
|
3
|
+
exports.useDatePicker = useDatePicker;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
6
|
const get_initial_months_1 = require("../utils/get-initial-months");
|
|
@@ -52,11 +52,12 @@ function useDatePicker({ datesConfig = [], firstDayOfWeek = 0, initialVisibleMon
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
function handleKeyDown(e) {
|
|
55
|
+
var _a, _b;
|
|
55
56
|
if ((e.key === "ArrowRight" || e.key === "ArrowLeft" || e.key === "ArrowDown" || e.key === "ArrowUp") &&
|
|
56
57
|
!focusedDate) {
|
|
57
|
-
const
|
|
58
|
-
onDateFocus(
|
|
59
|
-
setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths,
|
|
58
|
+
const activeMonthDate = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : new Date();
|
|
59
|
+
onDateFocus(activeMonthDate);
|
|
60
|
+
setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths, activeMonthDate));
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
window.addEventListener("keydown", handleKeyDown);
|
|
@@ -116,4 +117,3 @@ function useDatePicker({ datesConfig = [], firstDayOfWeek = 0, initialVisibleMon
|
|
|
116
117
|
unavailableDates: disabledDates,
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
|
-
exports.useDatePicker = useDatePicker;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
|
+
const react_2 = require("react");
|
|
5
5
|
const use_date_picker_1 = require("./use-date-picker");
|
|
6
6
|
test("base data", () => {
|
|
7
7
|
const BASE_DATE = new Date("2021-09-15");
|
|
8
|
-
const { result } = (0,
|
|
8
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({
|
|
9
9
|
selectedDate: BASE_DATE,
|
|
10
10
|
onDateChange: () => undefined,
|
|
11
11
|
minBookingDate: new Date("2020-01-01"),
|
|
@@ -25,12 +25,12 @@ test("base data", () => {
|
|
|
25
25
|
});
|
|
26
26
|
test("date focus", () => {
|
|
27
27
|
const BASE_DATE = new Date("2021-09-15");
|
|
28
|
-
const { result: state } = (0,
|
|
29
|
-
const { result } = (0,
|
|
28
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)(BASE_DATE));
|
|
29
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({ selectedDate: state.current[0], onDateChange: (date) => state.current[1](date) }));
|
|
30
30
|
const NEW_DATE = new Date("2022-12-22");
|
|
31
31
|
expect(result.current.isDateFocused(BASE_DATE)).toBe(true);
|
|
32
32
|
expect(result.current.isDateFocused(NEW_DATE)).toBe(false);
|
|
33
|
-
(0,
|
|
33
|
+
(0, react_1.act)(() => {
|
|
34
34
|
result.current.onDateFocus(NEW_DATE);
|
|
35
35
|
});
|
|
36
36
|
expect(result.current.isDateFocused(NEW_DATE)).toBe(true);
|
|
@@ -38,31 +38,31 @@ test("date focus", () => {
|
|
|
38
38
|
});
|
|
39
39
|
test("date select", () => {
|
|
40
40
|
const BASE_DATE = new Date("2021-09-15");
|
|
41
|
-
const { result: state } = (0,
|
|
42
|
-
const { result, rerender } = (0,
|
|
41
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)(BASE_DATE));
|
|
42
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_date_picker_1.useDatePicker)({ selectedDate: state.current[0], onDateChange: (date) => state.current[1](date) }));
|
|
43
43
|
const NEW_DATE = new Date("2022-12-22");
|
|
44
44
|
expect(result.current.isDateSelected(BASE_DATE)).toBe(true);
|
|
45
45
|
expect(result.current.isDateSelected(NEW_DATE)).toBe(false);
|
|
46
|
-
(0,
|
|
46
|
+
(0, react_1.act)(() => {
|
|
47
47
|
result.current.onDateSelect(NEW_DATE);
|
|
48
48
|
rerender();
|
|
49
49
|
});
|
|
50
50
|
expect(result.current.isDateSelected(NEW_DATE)).toBe(true);
|
|
51
51
|
expect(result.current.isDateSelected(BASE_DATE)).toBe(false);
|
|
52
52
|
// select another
|
|
53
|
-
(0,
|
|
53
|
+
(0, react_1.act)(() => {
|
|
54
54
|
result.current.onDateSelect(BASE_DATE);
|
|
55
55
|
rerender();
|
|
56
56
|
});
|
|
57
57
|
expect(result.current.isDateSelected(BASE_DATE)).toBe(true);
|
|
58
58
|
// select save (deselect)
|
|
59
|
-
(0,
|
|
59
|
+
(0, react_1.act)(() => {
|
|
60
60
|
result.current.onDateSelect(BASE_DATE);
|
|
61
61
|
rerender();
|
|
62
62
|
});
|
|
63
63
|
expect(result.current.isDateSelected(BASE_DATE)).toBe(false);
|
|
64
64
|
// reset
|
|
65
|
-
(0,
|
|
65
|
+
(0, react_1.act)(() => {
|
|
66
66
|
result.current.onDateSelect(BASE_DATE);
|
|
67
67
|
result.current.onResetDates();
|
|
68
68
|
rerender();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.END_DATE = exports.START_DATE = void 0;
|
|
4
|
+
exports.useDateRangePicker = useDateRangePicker;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const can_select_range_1 = require("../utils/can-select-range");
|
|
6
7
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
@@ -61,11 +62,12 @@ function useDateRangePicker({ changeActiveMonthOnSelect = false, datesConfig = [
|
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
function handleKeyDown(e) {
|
|
65
|
+
var _a, _b;
|
|
64
66
|
if ((e.key === "ArrowRight" || e.key === "ArrowLeft" || e.key === "ArrowDown" || e.key === "ArrowUp") &&
|
|
65
67
|
!focusedDate) {
|
|
66
|
-
const
|
|
67
|
-
onDateFocus(
|
|
68
|
-
setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths,
|
|
68
|
+
const activeMonthDate = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : new Date();
|
|
69
|
+
onDateFocus(activeMonthDate);
|
|
70
|
+
setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths, activeMonthDate));
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
window.addEventListener("keydown", handleKeyDown);
|
|
@@ -226,4 +228,3 @@ function useDateRangePicker({ changeActiveMonthOnSelect = false, datesConfig = [
|
|
|
226
228
|
unavailableDates: disabledDates,
|
|
227
229
|
};
|
|
228
230
|
}
|
|
229
|
-
exports.useDateRangePicker = useDateRangePicker;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
|
+
const react_2 = require("react");
|
|
5
5
|
const use_date_range_picker_1 = require("./use-date-range-picker");
|
|
6
6
|
beforeAll(() => {
|
|
7
7
|
jest.useFakeTimers();
|
|
8
8
|
jest.setSystemTime(new Date("2021-09-25"));
|
|
9
9
|
});
|
|
10
10
|
test("base data", () => {
|
|
11
|
-
const { result } = (0,
|
|
11
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_date_range_picker_1.useDateRangePicker)({
|
|
12
12
|
startDate: null,
|
|
13
13
|
endDate: null,
|
|
14
14
|
onDatesChange: () => undefined,
|
|
@@ -35,8 +35,8 @@ test("base data", () => {
|
|
|
35
35
|
});
|
|
36
36
|
test("date focus", () => {
|
|
37
37
|
const BASE_DATE = new Date("2021-09-15");
|
|
38
|
-
const { result: state } = (0,
|
|
39
|
-
const { result } = (0,
|
|
38
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)({ startDate: null, endDate: null, focusedInput: "startDate" }));
|
|
39
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_date_range_picker_1.useDateRangePicker)({
|
|
40
40
|
startDate: state.current[0].startDate,
|
|
41
41
|
endDate: state.current[0].endDate,
|
|
42
42
|
onDatesChange: (data) => state.current[1](data),
|
|
@@ -46,7 +46,7 @@ test("date focus", () => {
|
|
|
46
46
|
const NEW_DATE = new Date("2022-12-22");
|
|
47
47
|
expect(result.current.isDateFocused(BASE_DATE)).toBe(false);
|
|
48
48
|
expect(result.current.isDateFocused(NEW_DATE)).toBe(false);
|
|
49
|
-
(0,
|
|
49
|
+
(0, react_1.act)(() => {
|
|
50
50
|
result.current.onDateFocus(NEW_DATE);
|
|
51
51
|
});
|
|
52
52
|
expect(result.current.isDateFocused(NEW_DATE)).toBe(true);
|
|
@@ -54,8 +54,8 @@ test("date focus", () => {
|
|
|
54
54
|
});
|
|
55
55
|
test("date select", () => {
|
|
56
56
|
const BASE_DATE = new Date("2021-09-15");
|
|
57
|
-
const { result: state } = (0,
|
|
58
|
-
const { result, rerender } = (0,
|
|
57
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)({ startDate: null, endDate: null, focusedInput: "startDate" }));
|
|
58
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_date_range_picker_1.useDateRangePicker)({
|
|
59
59
|
startDate: state.current[0].startDate,
|
|
60
60
|
endDate: state.current[0].endDate,
|
|
61
61
|
onDatesChange: (data) => state.current[1](data),
|
|
@@ -65,20 +65,20 @@ test("date select", () => {
|
|
|
65
65
|
const NEW_DATE = new Date("2022-12-22");
|
|
66
66
|
expect(result.current.isDateSelected(BASE_DATE)).toBe(false);
|
|
67
67
|
expect(result.current.isDateSelected(NEW_DATE)).toBe(false);
|
|
68
|
-
(0,
|
|
68
|
+
(0, react_1.act)(() => {
|
|
69
69
|
result.current.onDateSelect(NEW_DATE);
|
|
70
70
|
rerender();
|
|
71
71
|
});
|
|
72
72
|
expect(result.current.isDateSelected(NEW_DATE)).toBe(true);
|
|
73
73
|
expect(result.current.isDateSelected(BASE_DATE)).toBe(false);
|
|
74
74
|
// select another
|
|
75
|
-
(0,
|
|
75
|
+
(0, react_1.act)(() => {
|
|
76
76
|
result.current.onDateSelect(BASE_DATE);
|
|
77
77
|
rerender();
|
|
78
78
|
});
|
|
79
79
|
expect(result.current.isDateSelected(BASE_DATE)).toBe(true);
|
|
80
80
|
// reset
|
|
81
|
-
(0,
|
|
81
|
+
(0, react_1.act)(() => {
|
|
82
82
|
result.current.onDateSelect(BASE_DATE);
|
|
83
83
|
result.current.onResetDates();
|
|
84
84
|
rerender();
|
package/hooks/use-day.js
CHANGED
|
@@ -3,14 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useDay =
|
|
6
|
+
exports.useDay = useDay;
|
|
7
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
7
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
10
11
|
const get_date_invervals_1 = require("../utils/get-date-invervals");
|
|
11
12
|
function useDay({ date, datesConfig, dayRef, focusedDate, isDateBlocked, isDateFocused, isDateHovered, isDateInsideRange, isDateSelected, onDateFocus, onDateHover, onDateSelect, preventScroll, unavailableDates, }) {
|
|
12
13
|
var _a;
|
|
13
|
-
const disabledDatesFromConfig = (_a = datesConfig === null || datesConfig === void 0 ? void 0 : datesConfig.filter((config) => config.isDisabled).flatMap((config) => config.dates)) !== null && _a !== void 0 ? _a :
|
|
14
|
+
const disabledDatesFromConfig = (_a = datesConfig === null || datesConfig === void 0 ? void 0 : datesConfig.filter((config) => config.isDisabled).flatMap((config) => config.dates)) !== null && _a !== void 0 ? _a : empty_array_1.EMPTY_ARRAY;
|
|
14
15
|
// merge and filter duplicates
|
|
15
16
|
const disabledDates = [...unavailableDates, ...disabledDatesFromConfig].filter((day, index, self) => index === self.findIndex((d) => d.getTime() === day.getTime()));
|
|
16
17
|
const onClick = (0, react_1.useCallback)(() => onDateSelect(date), [date, onDateSelect]);
|
|
@@ -64,7 +65,7 @@ function useDay({ date, datesConfig, dayRef, focusedDate, isDateBlocked, isDateF
|
|
|
64
65
|
return acc;
|
|
65
66
|
}, []);
|
|
66
67
|
return {
|
|
67
|
-
flags: flags !== null && flags !== void 0 ? flags :
|
|
68
|
+
flags: flags !== null && flags !== void 0 ? flags : empty_array_1.EMPTY_ARRAY,
|
|
68
69
|
disabledDate: disabled,
|
|
69
70
|
isFirstDisabled: _isFirstUnavailableDate(),
|
|
70
71
|
isHovered: isDateHovered(date),
|
|
@@ -79,4 +80,3 @@ function useDay({ date, datesConfig, dayRef, focusedDate, isDateBlocked, isDateF
|
|
|
79
80
|
tabIndex: focusedDate === null || isDateFocused(date) ? 0 : -1,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
|
-
exports.useDay = useDay;
|
package/hooks/use-day.test.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const react_1 = require("@testing-library/react");
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
-
const
|
|
8
|
+
const react_2 = require("react");
|
|
9
9
|
const use_day_1 = require("./use-day");
|
|
10
10
|
const e = { preventDefault: () => undefined, key: undefined };
|
|
11
11
|
beforeAll(() => {
|
|
@@ -13,7 +13,7 @@ beforeAll(() => {
|
|
|
13
13
|
jest.setSystemTime(new Date("2021-09-06"));
|
|
14
14
|
});
|
|
15
15
|
test("useDay", () => {
|
|
16
|
-
const { result } = (0,
|
|
16
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_day_1.useDay)({
|
|
17
17
|
date: new Date("2021-09-05"),
|
|
18
18
|
datesConfig: [],
|
|
19
19
|
focusedDate: null,
|
|
@@ -38,7 +38,7 @@ test("useDay", () => {
|
|
|
38
38
|
expect(result.current.isWithinHoverRange).toBe(false);
|
|
39
39
|
});
|
|
40
40
|
test("useDay with unavailableDates", () => {
|
|
41
|
-
const { result } = (0,
|
|
41
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_day_1.useDay)({
|
|
42
42
|
date: new Date("2021-09-05"),
|
|
43
43
|
datesConfig: [],
|
|
44
44
|
focusedDate: null,
|
|
@@ -63,7 +63,7 @@ test("useDay with unavailableDates", () => {
|
|
|
63
63
|
expect(result.current.isWithinHoverRange).toBe(false);
|
|
64
64
|
});
|
|
65
65
|
test("useDay with datesConfig", () => {
|
|
66
|
-
const { result } = (0,
|
|
66
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_day_1.useDay)({
|
|
67
67
|
date: new Date("2021-09-05"),
|
|
68
68
|
datesConfig: [{ dates: [new Date("2021-09-05")], flag: "custom-classname", isDisabled: true }],
|
|
69
69
|
focusedDate: null,
|
|
@@ -93,8 +93,8 @@ test("actions", () => {
|
|
|
93
93
|
let selectedDate = null;
|
|
94
94
|
let focusedDate = null;
|
|
95
95
|
const insideRangeDate = null;
|
|
96
|
-
const { result: ref } = (0,
|
|
97
|
-
const { result, rerender } = (0,
|
|
96
|
+
const { result: ref } = (0, react_1.renderHook)(() => (0, react_2.useRef)(null));
|
|
97
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_day_1.useDay)({
|
|
98
98
|
date: new Date("2021-09-05"),
|
|
99
99
|
datesConfig: [],
|
|
100
100
|
dayRef: ref.current,
|
|
@@ -111,7 +111,7 @@ test("actions", () => {
|
|
|
111
111
|
}));
|
|
112
112
|
// hover
|
|
113
113
|
expect(result.current.isHovered).toBe(false);
|
|
114
|
-
(0,
|
|
114
|
+
(0, react_1.act)(() => {
|
|
115
115
|
result.current.onMouseEnter();
|
|
116
116
|
rerender();
|
|
117
117
|
});
|
|
@@ -119,7 +119,7 @@ test("actions", () => {
|
|
|
119
119
|
expect(result.current.tabIndex).toBe(0);
|
|
120
120
|
// select
|
|
121
121
|
expect(result.current.isSelected).toBe(false);
|
|
122
|
-
(0,
|
|
122
|
+
(0, react_1.act)(() => {
|
|
123
123
|
if (result.current.onClick) {
|
|
124
124
|
result.current.onClick();
|
|
125
125
|
}
|
|
@@ -128,7 +128,7 @@ test("actions", () => {
|
|
|
128
128
|
expect(result.current.isSelected).toBe(true);
|
|
129
129
|
expect(result.current.isInsideRange).toBe(false);
|
|
130
130
|
// keyDown
|
|
131
|
-
(0,
|
|
131
|
+
(0, react_1.act)(() => {
|
|
132
132
|
e.key = "ArrowRight";
|
|
133
133
|
result.current.onKeyDown(e);
|
|
134
134
|
e.key = "ArrowLeft";
|
package/hooks/use-decade.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.decadeLabelFormatFn = exports.yearLabelFormatFn = void 0;
|
|
4
|
+
exports.useDecade = useDecade;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
7
|
const get_years_1 = require("../utils/get-years");
|
|
@@ -18,4 +19,3 @@ function useDecade({ yearLabelFormat = exports.yearLabelFormatFn, decadeLabelFor
|
|
|
18
19
|
decadeLabel: decadeLabelFormat(startYear, endYear),
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
exports.useDecade = useDecade;
|
package/hooks/use-decade.test.js
CHANGED
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const react_1 = require("@testing-library/react");
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
8
|
const use_decade_1 = require("./use-decade");
|
|
9
9
|
test("useDecade", () => {
|
|
10
|
-
const { result } = (0,
|
|
10
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_decade_1.useDecade)({
|
|
11
11
|
year: 2021,
|
|
12
12
|
}));
|
|
13
13
|
expect(result.current.decadeLabel).toBe("2017 – 2025");
|
|
@@ -24,7 +24,7 @@ test("useDecade", () => {
|
|
|
24
24
|
]);
|
|
25
25
|
});
|
|
26
26
|
test("useDecade with custom formats", () => {
|
|
27
|
-
const { result } = (0,
|
|
27
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_decade_1.useDecade)({
|
|
28
28
|
year: 2021,
|
|
29
29
|
decadeLabelFormat: (start, end) => `${(0, dayjs_1.default)(start).format("YY")} - ${(0, dayjs_1.default)(end).format("YY")}`,
|
|
30
30
|
yearLabelFormat: (date) => (0, dayjs_1.default)(date).format("YY"),
|
package/hooks/use-hour.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useHour =
|
|
3
|
+
exports.useHour = useHour;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useHour({ hour, hourRef, focusedHour, isHourFocused, isHourSelected, onHourFocus, onHourSelect, preventScroll, }) {
|
|
6
6
|
const onClick = (0, react_1.useCallback)(() => onHourSelect(hour), [hour, onHourSelect]);
|
|
@@ -37,4 +37,3 @@ function useHour({ hour, hourRef, focusedHour, isHourFocused, isHourSelected, on
|
|
|
37
37
|
tabIndex: focusedHour === null || isHourFocused(hour) ? 0 : -1,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
exports.useHour = useHour;
|
package/hooks/use-hour.test.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
|
+
const react_2 = require("react");
|
|
5
5
|
const use_hour_1 = require("./use-hour");
|
|
6
6
|
test("useHour", () => {
|
|
7
|
-
const { result } = (0,
|
|
7
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_hour_1.useHour)({
|
|
8
8
|
hour: 5,
|
|
9
9
|
focusedHour: null,
|
|
10
10
|
isHourFocused: () => false,
|
|
@@ -18,8 +18,8 @@ test("useHour", () => {
|
|
|
18
18
|
test("actions", () => {
|
|
19
19
|
let selectedHour = null;
|
|
20
20
|
let focusedHour = null;
|
|
21
|
-
const { result: ref } = (0,
|
|
22
|
-
const { result, rerender } = (0,
|
|
21
|
+
const { result: ref } = (0, react_1.renderHook)(() => (0, react_2.useRef)(null));
|
|
22
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_hour_1.useHour)({
|
|
23
23
|
hour: 30,
|
|
24
24
|
focusedHour: null,
|
|
25
25
|
isHourFocused: (hour) => focusedHour === hour,
|
|
@@ -31,7 +31,7 @@ test("actions", () => {
|
|
|
31
31
|
expect(result.current.tabIndex).toBe(0);
|
|
32
32
|
// select
|
|
33
33
|
expect(result.current.isSelected).toBe(false);
|
|
34
|
-
(0,
|
|
34
|
+
(0, react_1.act)(() => {
|
|
35
35
|
if (result.current.onClick) {
|
|
36
36
|
result.current.onClick();
|
|
37
37
|
}
|
package/hooks/use-hours.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.labelFormatFn = void 0;
|
|
4
|
+
exports.useHours = useHours;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const labelFormatFn = (hour) => hour.toString().padStart(2, "0");
|
|
6
7
|
exports.labelFormatFn = labelFormatFn;
|
|
@@ -12,4 +13,3 @@ function useHours({ labelFormat = exports.labelFormatFn }) {
|
|
|
12
13
|
hours,
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
exports.useHours = useHours;
|
package/hooks/use-hours.test.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
4
|
const use_hours_1 = require("./use-hours");
|
|
5
5
|
test("useHours", () => {
|
|
6
|
-
const { result } = (0,
|
|
6
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_hours_1.useHours)({}));
|
|
7
7
|
expect(result.current.hours).toStrictEqual([
|
|
8
8
|
{ label: "00", value: 0 },
|
|
9
9
|
{ label: "01", value: 1 },
|
|
@@ -32,7 +32,7 @@ test("useHours", () => {
|
|
|
32
32
|
]);
|
|
33
33
|
});
|
|
34
34
|
test("useMinutes with custom format", () => {
|
|
35
|
-
const { result } = (0,
|
|
35
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_hours_1.useHours)({
|
|
36
36
|
labelFormat: (hour) => "--" + hour + "--",
|
|
37
37
|
}));
|
|
38
38
|
expect(result.current.hours).toStrictEqual([
|
package/hooks/use-minute.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMinute =
|
|
3
|
+
exports.useMinute = useMinute;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useMinute({ minute, minuteRef, focusedMinute, isMinuteFocused, isMinuteSelected, onMinuteFocus, onMinuteSelect, preventScroll, }) {
|
|
6
6
|
const onClick = (0, react_1.useCallback)(() => onMinuteSelect(minute), [minute, onMinuteSelect]);
|
|
@@ -37,4 +37,3 @@ function useMinute({ minute, minuteRef, focusedMinute, isMinuteFocused, isMinute
|
|
|
37
37
|
tabIndex: focusedMinute === null || isMinuteFocused(minute) ? 0 : -1,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
exports.useMinute = useMinute;
|
package/hooks/use-minute.test.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
|
+
const react_2 = require("react");
|
|
5
5
|
const use_minute_1 = require("./use-minute");
|
|
6
6
|
test("useMinute", () => {
|
|
7
|
-
const { result } = (0,
|
|
7
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_minute_1.useMinute)({
|
|
8
8
|
minute: 30,
|
|
9
9
|
focusedMinute: null,
|
|
10
10
|
isMinuteFocused: () => false,
|
|
@@ -18,8 +18,8 @@ test("useMinute", () => {
|
|
|
18
18
|
test("actions", () => {
|
|
19
19
|
let selectedMinute = null;
|
|
20
20
|
let focusedMinute = null;
|
|
21
|
-
const { result: ref } = (0,
|
|
22
|
-
const { result, rerender } = (0,
|
|
21
|
+
const { result: ref } = (0, react_1.renderHook)(() => (0, react_2.useRef)(null));
|
|
22
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_minute_1.useMinute)({
|
|
23
23
|
minute: 30,
|
|
24
24
|
focusedMinute: null,
|
|
25
25
|
isMinuteFocused: (minute) => focusedMinute === minute,
|
|
@@ -31,7 +31,7 @@ test("actions", () => {
|
|
|
31
31
|
expect(result.current.tabIndex).toBe(0);
|
|
32
32
|
// select
|
|
33
33
|
expect(result.current.isSelected).toBe(false);
|
|
34
|
-
(0,
|
|
34
|
+
(0, react_1.act)(() => {
|
|
35
35
|
if (result.current.onClick) {
|
|
36
36
|
result.current.onClick();
|
|
37
37
|
}
|
package/hooks/use-minutes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.labelFormatFn = void 0;
|
|
4
|
+
exports.useMinutes = useMinutes;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const labelFormatFn = (hour) => hour.toString().padStart(2, "0");
|
|
6
7
|
exports.labelFormatFn = labelFormatFn;
|
|
@@ -12,4 +13,3 @@ function useMinutes({ labelFormat = exports.labelFormatFn }) {
|
|
|
12
13
|
minutes,
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
exports.useMinutes = useMinutes;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
4
|
const use_minutes_1 = require("./use-minutes");
|
|
5
5
|
test("useMinutes", () => {
|
|
6
|
-
const { result } = (0,
|
|
6
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_minutes_1.useMinutes)({}));
|
|
7
7
|
expect(result.current.minutes).toStrictEqual([
|
|
8
8
|
{ label: "00", value: 0 },
|
|
9
9
|
{ label: "05", value: 5 },
|
|
@@ -20,7 +20,7 @@ test("useMinutes", () => {
|
|
|
20
20
|
]);
|
|
21
21
|
});
|
|
22
22
|
test("useMinutes with custom format", () => {
|
|
23
|
-
const { result } = (0,
|
|
23
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_minutes_1.useMinutes)({
|
|
24
24
|
labelFormat: (minute) => "--" + minute + "--",
|
|
25
25
|
}));
|
|
26
26
|
expect(result.current.minutes).toStrictEqual([
|
package/hooks/use-month.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.monthLabelFormatFn = exports.weekdayLabelFormatFn = exports.dayLabelFormatFn = void 0;
|
|
4
|
+
exports.useMonth = useMonth;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
7
|
const get_days_1 = require("../utils/get-days");
|
|
@@ -20,4 +21,3 @@ function useMonth({ dayLabelFormat = exports.dayLabelFormatFn, firstDayOfWeek =
|
|
|
20
21
|
weekdayLabels,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
exports.useMonth = useMonth;
|
package/hooks/use-month.test.js
CHANGED
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const react_1 = require("@testing-library/react");
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
8
|
const use_month_1 = require("./use-month");
|
|
9
9
|
test("useMonth", () => {
|
|
10
|
-
const { result } = (0,
|
|
10
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_month_1.useMonth)({
|
|
11
11
|
year: 2021,
|
|
12
12
|
month: 0,
|
|
13
13
|
}));
|
|
@@ -59,7 +59,7 @@ test("useMonth", () => {
|
|
|
59
59
|
expect(result.current.weekdayLabels).toStrictEqual(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
|
|
60
60
|
});
|
|
61
61
|
test("useMonth with custom formats and firstDayOfWeek", () => {
|
|
62
|
-
const { result } = (0,
|
|
62
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_month_1.useMonth)({
|
|
63
63
|
year: 2021,
|
|
64
64
|
month: 0,
|
|
65
65
|
firstDayOfWeek: 1,
|
package/hooks/use-time-picker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useTimePicker =
|
|
3
|
+
exports.useTimePicker = useTimePicker;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
function useTimePicker({ selectedTime, onTimeChange, onSelectCallback, preventScroll, }) {
|
|
6
6
|
var _a, _b;
|
|
@@ -81,4 +81,3 @@ function useTimePicker({ selectedTime, onTimeChange, onSelectCallback, preventSc
|
|
|
81
81
|
preventScroll,
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
exports.useTimePicker = useTimePicker;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const react_1 = require("@testing-library/react");
|
|
4
|
+
const react_2 = require("react");
|
|
5
5
|
const use_time_picker_1 = require("./use-time-picker");
|
|
6
6
|
test("base data", () => {
|
|
7
7
|
const BASE_TIME = { hour: 12, minute: 57 };
|
|
8
|
-
const { result } = (0,
|
|
8
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_time_picker_1.useTimePicker)({
|
|
9
9
|
selectedTime: BASE_TIME,
|
|
10
10
|
onTimeChange: () => undefined,
|
|
11
11
|
}));
|
|
@@ -14,14 +14,14 @@ test("base data", () => {
|
|
|
14
14
|
});
|
|
15
15
|
test("time focus", () => {
|
|
16
16
|
const BASE_TIME = { hour: 12, minute: 57 };
|
|
17
|
-
const { result: state } = (0,
|
|
18
|
-
const { result } = (0,
|
|
17
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)(BASE_TIME));
|
|
18
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_time_picker_1.useTimePicker)({ selectedTime: state.current[0], onTimeChange: (time) => state.current[1](time) }));
|
|
19
19
|
const NEW_TIME = { hour: 13, minute: 15 };
|
|
20
20
|
expect(result.current.isHourFocused(BASE_TIME.hour)).toBe(true);
|
|
21
21
|
expect(result.current.isHourFocused(NEW_TIME.hour)).toBe(false);
|
|
22
22
|
expect(result.current.isMinuteFocused(BASE_TIME.minute)).toBe(true);
|
|
23
23
|
expect(result.current.isMinuteFocused(NEW_TIME.minute)).toBe(false);
|
|
24
|
-
(0,
|
|
24
|
+
(0, react_1.act)(() => {
|
|
25
25
|
result.current.onHourFocus(NEW_TIME.hour);
|
|
26
26
|
result.current.onMinuteFocus(NEW_TIME.minute);
|
|
27
27
|
});
|
|
@@ -32,14 +32,14 @@ test("time focus", () => {
|
|
|
32
32
|
});
|
|
33
33
|
test("time select", () => {
|
|
34
34
|
const BASE_TIME = { hour: 12, minute: 57 };
|
|
35
|
-
const { result: state } = (0,
|
|
36
|
-
const { result, rerender } = (0,
|
|
35
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)(BASE_TIME));
|
|
36
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_time_picker_1.useTimePicker)({ selectedTime: state.current[0], onTimeChange: (time) => state.current[1](time) }));
|
|
37
37
|
const NEW_TIME = { hour: 13, minute: 15 };
|
|
38
38
|
expect(result.current.isHourSelected(BASE_TIME.hour)).toBe(true);
|
|
39
39
|
expect(result.current.isHourSelected(NEW_TIME.hour)).toBe(false);
|
|
40
40
|
expect(result.current.isMinuteSelected(BASE_TIME.minute)).toBe(true);
|
|
41
41
|
expect(result.current.isMinuteSelected(NEW_TIME.minute)).toBe(false);
|
|
42
|
-
(0,
|
|
42
|
+
(0, react_1.act)(() => {
|
|
43
43
|
result.current.onTimeSelect(NEW_TIME);
|
|
44
44
|
rerender();
|
|
45
45
|
});
|
|
@@ -50,34 +50,34 @@ test("time select", () => {
|
|
|
50
50
|
});
|
|
51
51
|
test("time navigation", () => {
|
|
52
52
|
const BASE_TIME = { hour: 1, minute: 58 };
|
|
53
|
-
const { result: state } = (0,
|
|
54
|
-
const { result, rerender } = (0,
|
|
55
|
-
(0,
|
|
53
|
+
const { result: state } = (0, react_1.renderHook)(() => (0, react_2.useState)(BASE_TIME));
|
|
54
|
+
const { result, rerender } = (0, react_1.renderHook)(() => (0, use_time_picker_1.useTimePicker)({ selectedTime: state.current[0], onTimeChange: (time) => state.current[1](time) }));
|
|
55
|
+
(0, react_1.act)(() => {
|
|
56
56
|
result.current.goToPrevHour();
|
|
57
57
|
rerender();
|
|
58
58
|
});
|
|
59
59
|
expect(state.current[0]).toStrictEqual({ hour: 0, minute: 58 });
|
|
60
|
-
(0,
|
|
60
|
+
(0, react_1.act)(() => {
|
|
61
61
|
result.current.goToNextMinute();
|
|
62
62
|
rerender();
|
|
63
63
|
});
|
|
64
64
|
expect(state.current[0]).toStrictEqual({ hour: 0, minute: 59 });
|
|
65
|
-
(0,
|
|
65
|
+
(0, react_1.act)(() => {
|
|
66
66
|
result.current.goToPrevHour();
|
|
67
67
|
rerender();
|
|
68
68
|
});
|
|
69
69
|
expect(state.current[0]).toStrictEqual({ hour: 23, minute: 59 });
|
|
70
|
-
(0,
|
|
70
|
+
(0, react_1.act)(() => {
|
|
71
71
|
result.current.goToNextHour();
|
|
72
72
|
rerender();
|
|
73
73
|
});
|
|
74
74
|
expect(state.current[0]).toStrictEqual({ hour: 0, minute: 59 });
|
|
75
|
-
(0,
|
|
75
|
+
(0, react_1.act)(() => {
|
|
76
76
|
result.current.goToNextMinute();
|
|
77
77
|
rerender();
|
|
78
78
|
});
|
|
79
79
|
expect(state.current[0]).toStrictEqual({ hour: 1, minute: 0 });
|
|
80
|
-
(0,
|
|
80
|
+
(0, react_1.act)(() => {
|
|
81
81
|
result.current.goToPrevMinute();
|
|
82
82
|
rerender();
|
|
83
83
|
});
|
package/hooks/use-year.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.yearLabelFormatFn = exports.monthLabelFormatFn = void 0;
|
|
4
|
+
exports.useYear = useYear;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
7
|
const get_months_1 = require("../utils/get-months");
|
|
@@ -15,4 +16,3 @@ function useYear({ yearLabelFormat = exports.yearLabelFormatFn, monthLabelFormat
|
|
|
15
16
|
yearLabel: yearLabelFormat(new Date(year, 0)),
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
exports.useYear = useYear;
|
package/hooks/use-year.test.js
CHANGED
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const react_1 = require("@testing-library/react");
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
8
|
const use_year_1 = require("./use-year");
|
|
9
9
|
test("useYear", () => {
|
|
10
|
-
const { result } = (0,
|
|
10
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_year_1.useYear)({
|
|
11
11
|
year: 2021,
|
|
12
12
|
}));
|
|
13
13
|
expect(result.current.yearLabel).toBe("2021");
|
|
@@ -27,7 +27,7 @@ test("useYear", () => {
|
|
|
27
27
|
]);
|
|
28
28
|
});
|
|
29
29
|
test("useYear with custom formats", () => {
|
|
30
|
-
const { result } = (0,
|
|
30
|
+
const { result } = (0, react_1.renderHook)(() => (0, use_year_1.useYear)({
|
|
31
31
|
year: 2021,
|
|
32
32
|
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MM"),
|
|
33
33
|
yearLabelFormat: (date) => (0, dayjs_1.default)(date).format("YY"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/datepicker",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.32.0",
|
|
4
4
|
"description": "A set of React hooks to create an awesome datepicker.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"react-dom": ">=18.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@testing-library/react
|
|
29
|
-
"@types/react": "18.
|
|
30
|
-
"@types/react-dom": "18.
|
|
31
|
-
"react": "18.
|
|
32
|
-
"react-dom": "18.
|
|
28
|
+
"@testing-library/react": "16.0.0",
|
|
29
|
+
"@types/react": "18.3.5",
|
|
30
|
+
"@types/react-dom": "18.3.0",
|
|
31
|
+
"react": "18.3.1",
|
|
32
|
+
"react-dom": "18.3.1"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.canSelectRange =
|
|
3
|
+
exports.canSelectRange = canSelectRange;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
6
|
// eslint-disable-next-line complexity
|
|
@@ -42,4 +42,3 @@ function canSelectRange({ startDate, endDate, isDateBlocked, minBookingDays, exa
|
|
|
42
42
|
}
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
|
-
exports.canSelectRange = canSelectRange;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCurrentYearMonthAndDate =
|
|
3
|
+
exports.getCurrentYearMonthAndDate = getCurrentYearMonthAndDate;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
6
6
|
function getCurrentYearMonthAndDate() {
|
|
7
7
|
return (0, get_date_month_and_year_1.getDateMonthAndYear)((0, dayjs_en_1.dayjsEn)().startOf("day").toDate());
|
|
8
8
|
}
|
|
9
|
-
exports.getCurrentYearMonthAndDate = getCurrentYearMonthAndDate;
|
|
@@ -3,13 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDateIntervals =
|
|
6
|
+
exports.getDateIntervals = getDateIntervals;
|
|
7
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
7
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
9
|
function getDateIntervals(dates) {
|
|
9
10
|
const sortedDates = dates.slice().sort((a, b) => a.getTime() - b.getTime());
|
|
10
11
|
const intervals = [];
|
|
11
|
-
|
|
12
|
-
let
|
|
12
|
+
const firstSortedDate = sortedDates.at(0);
|
|
13
|
+
let currentStart = firstSortedDate !== null && firstSortedDate !== void 0 ? firstSortedDate : new Date();
|
|
14
|
+
let currentEnd = firstSortedDate !== null && firstSortedDate !== void 0 ? firstSortedDate : new Date();
|
|
13
15
|
for (let i = 1; i < sortedDates.length; i++) {
|
|
14
16
|
const currentDate = sortedDates[i];
|
|
15
17
|
const nextDate = (0, dayjs_1.default)(currentEnd).add(1, "day").toDate();
|
|
@@ -23,10 +25,9 @@ function getDateIntervals(dates) {
|
|
|
23
25
|
currentEnd = currentDate;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
if (
|
|
28
|
+
if ((0, is_not_nil_1.isNotNil)(firstSortedDate)) {
|
|
27
29
|
// Push the last interval
|
|
28
30
|
intervals.push({ start: currentStart, end: currentEnd });
|
|
29
31
|
}
|
|
30
32
|
return intervals;
|
|
31
33
|
}
|
|
32
|
-
exports.getDateIntervals = getDateIntervals;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDateMonthAndYear =
|
|
3
|
+
exports.getDateMonthAndYear = getDateMonthAndYear;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
function getDateMonthAndYear(date) {
|
|
6
6
|
const day = (0, dayjs_en_1.dayjsEn)(date).startOf("month").toDate();
|
|
@@ -12,4 +12,3 @@ function getDateMonthAndYear(date) {
|
|
|
12
12
|
date: day,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
exports.getDateMonthAndYear = getDateMonthAndYear;
|
package/utils/get-days.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDays =
|
|
3
|
+
exports.getDays = getDays;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
6
|
function getDays({ year, month, firstDayOfWeek = 0, dayLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("DD"), }) {
|
|
@@ -33,4 +33,3 @@ function getDays({ year, month, firstDayOfWeek = 0, dayLabelFormat = (date) => (
|
|
|
33
33
|
}));
|
|
34
34
|
return [...prevMonthDays, ...days, ...nextMonthDays];
|
|
35
35
|
}
|
|
36
|
-
exports.getDays = getDays;
|
package/utils/get-each.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEach =
|
|
3
|
+
exports.getEach = getEach;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
function getEach(start, end, type, arr = [(0, dayjs_en_1.dayjsEn)(start).startOf(type).toDate()]) {
|
|
6
6
|
if ((0, dayjs_en_1.dayjsEn)(start).isAfter(end)) {
|
|
@@ -12,4 +12,3 @@ function getEach(start, end, type, arr = [(0, dayjs_en_1.dayjsEn)(start).startOf
|
|
|
12
12
|
}
|
|
13
13
|
return getEach(next, end, type, arr.concat(next));
|
|
14
14
|
}
|
|
15
|
-
exports.getEach = getEach;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInitialMonths =
|
|
3
|
+
exports.getInitialMonths = getInitialMonths;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_current_year_month_and_date_1 = require("./get-current-year-month-and-date");
|
|
6
6
|
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
@@ -18,4 +18,3 @@ function getInitialMonths(numberOfMonths, startDate) {
|
|
|
18
18
|
}
|
|
19
19
|
return months;
|
|
20
20
|
}
|
|
21
|
-
exports.getInitialMonths = getInitialMonths;
|
package/utils/get-months.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMonths =
|
|
3
|
+
exports.getMonths = getMonths;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
6
|
function getMonths({ year, monthLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("MMMM"), }) {
|
|
@@ -12,4 +12,3 @@ function getMonths({ year, monthLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(
|
|
|
12
12
|
monthLabel: monthLabelFormat(d),
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
15
|
-
exports.getMonths = getMonths;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNextActiveMonth =
|
|
3
|
+
exports.getNextActiveMonth = getNextActiveMonth;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
6
6
|
function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
|
|
@@ -26,4 +26,3 @@ function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
|
|
|
26
26
|
: [(0, get_date_month_and_year_1.getDateMonthAndYear)(prevMonthDate)].concat(m);
|
|
27
27
|
}, []);
|
|
28
28
|
}
|
|
29
|
-
exports.getNextActiveMonth = getNextActiveMonth;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getWeekdayLabels =
|
|
3
|
+
exports.getWeekdayLabels = getWeekdayLabels;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
6
|
function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("dd"), }) {
|
|
@@ -8,4 +8,3 @@ function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (
|
|
|
8
8
|
const arr = (0, get_each_1.getEach)((0, dayjs_en_1.dayjsEn)(now).startOf("week").add(firstDayOfWeek, "day").toDate(), (0, dayjs_en_1.dayjsEn)(now).endOf("week").add(firstDayOfWeek, "day").toDate(), "day");
|
|
9
9
|
return arr.map((date) => weekdayLabelFormat(date));
|
|
10
10
|
}
|
|
11
|
-
exports.getWeekdayLabels = getWeekdayLabels;
|
package/utils/get-years.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getYears =
|
|
3
|
+
exports.getYears = getYears;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
6
|
function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY"), }) {
|
|
@@ -9,4 +9,3 @@ function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_en
|
|
|
9
9
|
yearLabel: yearLabelFormat(d),
|
|
10
10
|
}));
|
|
11
11
|
}
|
|
12
|
-
exports.getYears = getYears;
|
package/utils/is-browser.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBrowser = void 0;
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
5
|
-
exports.isBrowser =
|
|
5
|
+
exports.isBrowser = Boolean(typeof window !== "undefined" && window.document && window.document.createElement);
|
package/utils/is-date-blocked.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDateBlocked =
|
|
3
|
+
exports.isDateBlocked = isDateBlocked;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const is_in_unavailable_dates_1 = require("./is-in-unavailable-dates");
|
|
6
6
|
function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays = 1, unavailableDates = [], }) {
|
|
@@ -10,7 +10,7 @@ function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn,
|
|
|
10
10
|
const compareMaxDate = maxBookingDate
|
|
11
11
|
? new Date(maxBookingDate.getFullYear(), maxBookingDate.getMonth(), maxBookingDate.getDate(), 0, 0, 0)
|
|
12
12
|
: maxBookingDate;
|
|
13
|
-
return
|
|
13
|
+
return Boolean((0, is_in_unavailable_dates_1.isInUnavailableDates)(unavailableDates, date) ||
|
|
14
14
|
(compareMinDate && (0, dayjs_en_1.dayjsEn)(date).isBefore(compareMinDate)) ||
|
|
15
15
|
(compareMaxDate && (0, dayjs_en_1.dayjsEn)(date).isAfter(compareMaxDate)) ||
|
|
16
16
|
(startDate &&
|
|
@@ -19,4 +19,3 @@ function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn,
|
|
|
19
19
|
(0, dayjs_en_1.dayjsEn)(date).isBetween(startDate, (0, dayjs_en_1.dayjsEn)(startDate).add(minBookingDays - 2, "day"))) ||
|
|
20
20
|
(isDateBlockedFn && isDateBlockedFn(date)));
|
|
21
21
|
}
|
|
22
|
-
exports.isDateBlocked = isDateBlocked;
|
package/utils/is-date-hovered.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDateHovered =
|
|
3
|
+
exports.isDateHovered = isDateHovered;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
const get_each_1 = require("./get-each");
|
|
6
6
|
function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, minBookingDays, exactMinBookingDays, }) {
|
|
@@ -37,4 +37,3 @@ function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, m
|
|
|
37
37
|
}
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
|
-
exports.isDateHovered = isDateHovered;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDateInsideRange =
|
|
3
|
+
exports.isDateInsideRange = isDateInsideRange;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
function isDateInsideRange(date, startDate, endDate) {
|
|
6
6
|
if (startDate && endDate) {
|
|
@@ -8,4 +8,3 @@ function isDateInsideRange(date, startDate, endDate) {
|
|
|
8
8
|
}
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
|
-
exports.isDateInsideRange = isDateInsideRange;
|
package/utils/is-end-date.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEndDate =
|
|
3
|
+
exports.isEndDate = isEndDate;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
function isEndDate(date, endDate) {
|
|
6
|
-
return
|
|
6
|
+
return Boolean(endDate && (0, dayjs_en_1.dayjsEn)(date).isSame(endDate, "day"));
|
|
7
7
|
}
|
|
8
|
-
exports.isEndDate = isEndDate;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFirstOrLastSelectedDate =
|
|
3
|
+
exports.isFirstOrLastSelectedDate = isFirstOrLastSelectedDate;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
function isFirstOrLastSelectedDate(date, startDate, endDate) {
|
|
6
|
-
return
|
|
7
|
-
(endDate && (0, dayjs_en_1.dayjsEn)(date).isSame(endDate, "day")));
|
|
6
|
+
return Boolean((startDate && (0, dayjs_en_1.dayjsEn)(date).isSame(startDate, "day")) || (endDate && (0, dayjs_en_1.dayjsEn)(date).isSame(endDate, "day")));
|
|
8
7
|
}
|
|
9
|
-
exports.isFirstOrLastSelectedDate = isFirstOrLastSelectedDate;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isInUnavailableDates =
|
|
3
|
+
exports.isInUnavailableDates = isInUnavailableDates;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
function isInUnavailableDates(unavailableDates = [], date) {
|
|
6
6
|
return unavailableDates.some((_date) => (0, dayjs_en_1.dayjsEn)(date).isSame(_date, "day"));
|
|
7
7
|
}
|
|
8
|
-
exports.isInUnavailableDates = isInUnavailableDates;
|
package/utils/is-start-date.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isStartDate =
|
|
3
|
+
exports.isStartDate = isStartDate;
|
|
4
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
5
|
function isStartDate(date, startDate) {
|
|
6
|
-
return
|
|
6
|
+
return Boolean(startDate && (0, dayjs_en_1.dayjsEn)(date).isSame(startDate, "day"));
|
|
7
7
|
}
|
|
8
|
-
exports.isStartDate = isStartDate;
|