@uxf/datepicker 11.11.3 → 11.25.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.
|
@@ -13,13 +13,13 @@ exports.DatePickerContext = (0, react_1.createContext)({
|
|
|
13
13
|
canGoToYear: () => true,
|
|
14
14
|
firstDayOfWeek: 0,
|
|
15
15
|
focusedDate: null,
|
|
16
|
-
goToDate: () =>
|
|
17
|
-
goToNextMonths: () =>
|
|
18
|
-
goToNextMonthsByOneMonth: () =>
|
|
19
|
-
goToNextYear: () =>
|
|
20
|
-
goToPrevMonths: () =>
|
|
21
|
-
goToPrevMonthsByOneMonth: () =>
|
|
22
|
-
goToPrevYear: () =>
|
|
16
|
+
goToDate: () => [],
|
|
17
|
+
goToNextMonths: () => [],
|
|
18
|
+
goToNextMonthsByOneMonth: () => [],
|
|
19
|
+
goToNextYear: () => [],
|
|
20
|
+
goToPrevMonths: () => [],
|
|
21
|
+
goToPrevMonthsByOneMonth: () => [],
|
|
22
|
+
goToPrevYear: () => [],
|
|
23
23
|
hoveredDate: null,
|
|
24
24
|
isDateBlocked: () => false,
|
|
25
25
|
isDateFocused: () => false,
|
|
@@ -13,13 +13,13 @@ exports.DateRangePickerContext = (0, react_1.createContext)({
|
|
|
13
13
|
canGoToYear: () => true,
|
|
14
14
|
firstDayOfWeek: 0,
|
|
15
15
|
focusedDate: null,
|
|
16
|
-
goToDate: () =>
|
|
17
|
-
goToNextMonths: () =>
|
|
18
|
-
goToNextMonthsByOneMonth: () =>
|
|
19
|
-
goToNextYear: () =>
|
|
20
|
-
goToPrevMonths: () =>
|
|
21
|
-
goToPrevMonthsByOneMonth: () =>
|
|
22
|
-
goToPrevYear: () =>
|
|
16
|
+
goToDate: () => [],
|
|
17
|
+
goToNextMonths: () => [],
|
|
18
|
+
goToNextMonthsByOneMonth: () => [],
|
|
19
|
+
goToNextYear: () => [],
|
|
20
|
+
goToPrevMonths: () => [],
|
|
21
|
+
goToPrevMonthsByOneMonth: () => [],
|
|
22
|
+
goToPrevYear: () => [],
|
|
23
23
|
hoveredDate: null,
|
|
24
24
|
isDateBlocked: () => false,
|
|
25
25
|
isDateFocused: () => false,
|
|
@@ -15,12 +15,12 @@ export interface UseDatePickerNavigationReturnType {
|
|
|
15
15
|
canGoToPrevMonth: boolean;
|
|
16
16
|
canGoToPrevYear: boolean;
|
|
17
17
|
canGoToYear: (month: Date) => boolean;
|
|
18
|
-
goToDate: (date: Date) =>
|
|
19
|
-
goToNextMonths: () =>
|
|
20
|
-
goToNextMonthsByOneMonth: () =>
|
|
21
|
-
goToNextYear: (numYears?: number) =>
|
|
22
|
-
goToPrevMonths: () =>
|
|
23
|
-
goToPrevMonthsByOneMonth: () =>
|
|
24
|
-
goToPrevYear: (numYears?: number) =>
|
|
18
|
+
goToDate: (date: Date) => MonthType[];
|
|
19
|
+
goToNextMonths: () => MonthType[];
|
|
20
|
+
goToNextMonthsByOneMonth: () => MonthType[];
|
|
21
|
+
goToNextYear: (numYears?: number) => MonthType[];
|
|
22
|
+
goToPrevMonths: () => MonthType[];
|
|
23
|
+
goToPrevMonthsByOneMonth: () => MonthType[];
|
|
24
|
+
goToPrevYear: (numYears?: number) => MonthType[];
|
|
25
25
|
}
|
|
26
26
|
export declare function useDatePickerNavigation({ activeMonths, setActiveMonths, setFocusedDate, minBookingDate, maxBookingDate, numberOfMonths, }: UseDatePickerNavigationProps): UseDatePickerNavigationReturnType;
|
|
@@ -7,32 +7,46 @@ 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
9
|
const goToPrevMonths = (0, react_1.useCallback)(() => {
|
|
10
|
-
|
|
10
|
+
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1);
|
|
11
|
+
setActiveMonths(newActiveMonths);
|
|
11
12
|
setFocusedDate(null);
|
|
13
|
+
return newActiveMonths;
|
|
12
14
|
}, [activeMonths, numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
13
15
|
const goToPrevMonthsByOneMonth = (0, react_1.useCallback)(() => {
|
|
14
|
-
|
|
16
|
+
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1, 1);
|
|
17
|
+
setActiveMonths(newActiveMonths);
|
|
15
18
|
setFocusedDate(null);
|
|
19
|
+
return newActiveMonths;
|
|
16
20
|
}, [activeMonths, numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
17
21
|
const goToNextMonths = (0, react_1.useCallback)(() => {
|
|
18
|
-
|
|
22
|
+
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1);
|
|
23
|
+
setActiveMonths(newActiveMonths);
|
|
19
24
|
setFocusedDate(null);
|
|
25
|
+
return newActiveMonths;
|
|
20
26
|
}, [activeMonths, numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
21
27
|
const goToNextMonthsByOneMonth = (0, react_1.useCallback)(() => {
|
|
22
|
-
|
|
28
|
+
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, 1, 1);
|
|
29
|
+
setActiveMonths(newActiveMonths);
|
|
23
30
|
setFocusedDate(null);
|
|
31
|
+
return newActiveMonths;
|
|
24
32
|
}, [activeMonths, numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
25
33
|
const goToDate = (0, react_1.useCallback)((date) => {
|
|
26
|
-
|
|
34
|
+
const newActiveMonths = (0, get_initial_months_1.getInitialMonths)(numberOfMonths, date);
|
|
35
|
+
setActiveMonths(newActiveMonths);
|
|
27
36
|
setFocusedDate(null);
|
|
37
|
+
return newActiveMonths;
|
|
28
38
|
}, [numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
29
39
|
const goToPrevYear = (0, react_1.useCallback)((numYears = 1) => {
|
|
30
|
-
|
|
40
|
+
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -(numYears * 12 - numberOfMonths + 1));
|
|
41
|
+
setActiveMonths(newActiveMonths);
|
|
31
42
|
setFocusedDate(null);
|
|
43
|
+
return newActiveMonths;
|
|
32
44
|
}, [activeMonths, numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
33
45
|
const goToNextYear = (0, react_1.useCallback)((numYears = 1) => {
|
|
34
|
-
|
|
46
|
+
const newActiveMonths = (0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, numYears * 12 - numberOfMonths + 1);
|
|
47
|
+
setActiveMonths(newActiveMonths);
|
|
35
48
|
setFocusedDate(null);
|
|
49
|
+
return newActiveMonths;
|
|
36
50
|
}, [activeMonths, numberOfMonths, setActiveMonths, setFocusedDate]);
|
|
37
51
|
const canGoToPrevMonth = minBookingDate ? !(0, dayjs_en_1.dayjsEn)(activeMonths[0].date).isBefore((0, dayjs_en_1.dayjsEn)(minBookingDate)) : true;
|
|
38
52
|
const canGoToNextMonth = maxBookingDate
|