@uxf/datepicker 13.0.0 → 14.0.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/hooks/use-date-picker.js +15 -14
- package/hooks/use-date-range-picker.js +15 -14
- package/package.json +11 -5
package/hooks/use-date-picker.js
CHANGED
|
@@ -58,21 +58,22 @@ function useDatePicker({ datesConfig = [], firstDayOfWeek = 0, initialVisibleMon
|
|
|
58
58
|
exactMinBookingDays: false,
|
|
59
59
|
isDateBlocked: disabledDatesByUser,
|
|
60
60
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
61
|
+
// An effect event, so the listener stays attached while the focused date and the visible months change.
|
|
62
|
+
const onKeyDown = (0, react_1.useEffectEvent)((e) => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
if ((e.key === "ArrowRight" || e.key === "ArrowLeft" || e.key === "ArrowDown" || e.key === "ArrowUp") &&
|
|
65
|
+
!focusedDate) {
|
|
66
|
+
const activeMonthDate = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : new Date();
|
|
67
|
+
onDateFocus(activeMonthDate);
|
|
68
|
+
setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths, activeMonthDate));
|
|
70
69
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
});
|
|
71
|
+
(0, react_1.useEffect)(() => {
|
|
72
|
+
const handleKeyDown = (e) => onKeyDown(e);
|
|
73
|
+
const controller = new AbortController();
|
|
74
|
+
window.addEventListener("keydown", handleKeyDown, { signal: controller.signal });
|
|
75
|
+
return () => controller.abort();
|
|
76
|
+
}, []);
|
|
76
77
|
const onReset = (0, react_1.useCallback)(() => {
|
|
77
78
|
onDateChange(null);
|
|
78
79
|
}, [onDateChange]);
|
|
@@ -77,21 +77,22 @@ function useDateRangePicker({ changeActiveMonthOnSelect = false, datesConfig = [
|
|
|
77
77
|
exactMinBookingDays,
|
|
78
78
|
isDateBlocked: disabledDatesByUser,
|
|
79
79
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
80
|
+
// An effect event, so the listener stays attached while the focused date and the visible months change.
|
|
81
|
+
const onKeyDown = (0, react_1.useEffectEvent)((e) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
if ((e.key === "ArrowRight" || e.key === "ArrowLeft" || e.key === "ArrowDown" || e.key === "ArrowUp") &&
|
|
84
|
+
!focusedDate) {
|
|
85
|
+
const activeMonthDate = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.date) !== null && _b !== void 0 ? _b : new Date();
|
|
86
|
+
onDateFocus(activeMonthDate);
|
|
87
|
+
setActiveMonths((0, get_initial_months_1.getInitialMonths)(numberOfMonths, activeMonthDate));
|
|
89
88
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
});
|
|
90
|
+
(0, react_1.useEffect)(() => {
|
|
91
|
+
const handleKeyDown = (e) => onKeyDown(e);
|
|
92
|
+
const controller = new AbortController();
|
|
93
|
+
window.addEventListener("keydown", handleKeyDown, { signal: controller.signal });
|
|
94
|
+
return () => controller.abort();
|
|
95
|
+
}, []);
|
|
95
96
|
const onResetDates = (0, react_1.useCallback)(() => {
|
|
96
97
|
onDatesChange({
|
|
97
98
|
startDate: null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/datepicker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "A set of React hooks to create an awesome datepicker.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,17 +26,23 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://gitlab.com/uxf-npm/datepicker#readme",
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@uxf/core": "
|
|
30
|
-
"@uxf/core-react": "
|
|
29
|
+
"@uxf/core": "14.0.0",
|
|
30
|
+
"@uxf/core-react": "14.0.0",
|
|
31
31
|
"dayjs": "^1.11.23",
|
|
32
|
+
"next": ">=16.0.0",
|
|
32
33
|
"react": "^19.3.0",
|
|
33
34
|
"react-dom": "^19.3.0"
|
|
34
35
|
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"next": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
35
41
|
"devDependencies": {
|
|
36
42
|
"@types/react": "19.3.0",
|
|
37
43
|
"@types/react-dom": "19.3.0",
|
|
38
|
-
"@uxf/core": "
|
|
39
|
-
"@uxf/core-react": "
|
|
44
|
+
"@uxf/core": "14.0.0",
|
|
45
|
+
"@uxf/core-react": "14.0.0",
|
|
40
46
|
"dayjs": "^1.11.23",
|
|
41
47
|
"react": "19.3.0",
|
|
42
48
|
"react-dom": "19.3.0"
|