@uxf/datepicker 10.0.0-beta.35 → 10.0.0-beta.41
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.js +1 -0
- package/contexts/time-picker-context.d.ts +1 -0
- package/contexts/time-picker-context.js +1 -0
- package/hooks/use-date-picker.d.ts +3 -1
- package/hooks/use-date-picker.js +2 -1
- package/hooks/use-date-range-picker.d.ts +2 -0
- package/hooks/use-day.d.ts +2 -1
- package/hooks/use-day.js +5 -3
- package/hooks/use-hour.d.ts +2 -1
- package/hooks/use-hour.js +5 -3
- package/hooks/use-minute.d.ts +2 -1
- package/hooks/use-minute.js +5 -3
- package/hooks/use-time-picker.d.ts +3 -1
- package/hooks/use-time-picker.js +2 -1
- package/package.json +1 -1
|
@@ -10,5 +10,6 @@ export type TimePickerContextProps = {
|
|
|
10
10
|
onHourSelect: (hour: number) => void;
|
|
11
11
|
onMinuteFocus: (minute: number) => void;
|
|
12
12
|
onMinuteSelect: (minute: number) => void;
|
|
13
|
+
preventScroll?: boolean;
|
|
13
14
|
};
|
|
14
15
|
export declare const TimePickerContext: import("react").Context<TimePickerContextProps>;
|
|
@@ -9,6 +9,7 @@ export interface UseDatePickerProps {
|
|
|
9
9
|
minBookingDate?: Date;
|
|
10
10
|
numberOfMonths?: number;
|
|
11
11
|
onDateChange: (data: OnDateChangeType) => void;
|
|
12
|
+
preventScroll?: boolean;
|
|
12
13
|
selectedDate: Date | null;
|
|
13
14
|
unavailableDates?: Date[];
|
|
14
15
|
}
|
|
@@ -26,5 +27,6 @@ export interface UseDatePickerReturnType extends UseDatePickerNavigationReturnTy
|
|
|
26
27
|
onDateHover: (date: Date | null) => void;
|
|
27
28
|
onDateSelect: (date: Date) => void;
|
|
28
29
|
onResetDates: () => void;
|
|
30
|
+
preventScroll?: boolean;
|
|
29
31
|
}
|
|
30
|
-
export declare function useDatePicker({ firstDayOfWeek, initialVisibleMonth, isDateBlocked: isDateBlockedProps, maxBookingDate, minBookingDate, numberOfMonths, onDateChange, selectedDate, unavailableDates, }: UseDatePickerProps): UseDatePickerReturnType;
|
|
32
|
+
export declare function useDatePicker({ firstDayOfWeek, initialVisibleMonth, isDateBlocked: isDateBlockedProps, maxBookingDate, minBookingDate, numberOfMonths, onDateChange, preventScroll, selectedDate, unavailableDates, }: UseDatePickerProps): UseDatePickerReturnType;
|
package/hooks/use-date-picker.js
CHANGED
|
@@ -10,7 +10,7 @@ const is_start_date_1 = require("../utils/is-start-date");
|
|
|
10
10
|
const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
|
|
11
11
|
const is_browser_1 = require("../utils/is-browser");
|
|
12
12
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
13
|
-
function useDatePicker({ firstDayOfWeek = 0, initialVisibleMonth, isDateBlocked: isDateBlockedProps = () => false, maxBookingDate, minBookingDate, numberOfMonths = 1, onDateChange, selectedDate, unavailableDates = [], }) {
|
|
13
|
+
function useDatePicker({ firstDayOfWeek = 0, initialVisibleMonth, isDateBlocked: isDateBlockedProps = () => false, maxBookingDate, minBookingDate, numberOfMonths = 1, onDateChange, preventScroll, selectedDate, unavailableDates = [], }) {
|
|
14
14
|
const [activeMonths, setActiveMonths] = (0, react_1.useState)(() => selectedDate
|
|
15
15
|
? (0, get_initial_months_1.getInitialMonths)(numberOfMonths, selectedDate)
|
|
16
16
|
: (0, get_initial_months_1.getInitialMonths)(numberOfMonths, initialVisibleMonth || null));
|
|
@@ -109,6 +109,7 @@ function useDatePicker({ firstDayOfWeek = 0, initialVisibleMonth, isDateBlocked:
|
|
|
109
109
|
onDateHover,
|
|
110
110
|
onDateSelect,
|
|
111
111
|
onResetDates: onReset,
|
|
112
|
+
preventScroll,
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
exports.useDatePicker = useDatePicker;
|
|
@@ -21,6 +21,7 @@ export interface UseDateRangePickerProps {
|
|
|
21
21
|
minBookingDays?: number;
|
|
22
22
|
numberOfMonths?: number;
|
|
23
23
|
onDatesChange: (data: OnDatesChangeProps) => void;
|
|
24
|
+
preventScroll?: boolean;
|
|
24
25
|
startDate: Date | null;
|
|
25
26
|
unavailableDates?: Date[];
|
|
26
27
|
}
|
|
@@ -41,5 +42,6 @@ export interface UseDateRangePickerReturnType extends UseDatePickerNavigationRet
|
|
|
41
42
|
onDateHover: (date: Date | null) => void;
|
|
42
43
|
onDateSelect: (date: Date) => void;
|
|
43
44
|
onResetDates: () => void;
|
|
45
|
+
preventScroll?: boolean;
|
|
44
46
|
}
|
|
45
47
|
export declare function useDateRangePicker({ changeActiveMonthOnSelect, endDate, exactMinBookingDays, firstDayOfWeek, focusedInput, initialVisibleMonth, isDateBlocked: isDateBlockedProps, maxBookingDate, minBookingDate, minBookingDays, numberOfMonths, onDatesChange, startDate, unavailableDates, }: UseDateRangePickerProps): UseDateRangePickerReturnType;
|
package/hooks/use-day.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface UseDayProps {
|
|
|
11
11
|
onDateFocus: (date: Date) => void;
|
|
12
12
|
onDateHover: (date: Date) => void;
|
|
13
13
|
onDateSelect: (date: Date) => void;
|
|
14
|
+
preventScroll?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export interface UseDayReturnType {
|
|
16
17
|
disabledDate: boolean;
|
|
@@ -24,4 +25,4 @@ export interface UseDayReturnType {
|
|
|
24
25
|
onMouseEnter: () => void;
|
|
25
26
|
tabIndex: number;
|
|
26
27
|
}
|
|
27
|
-
export declare function useDay({ date, dayRef, focusedDate, isDateBlocked, isDateFocused, isDateHovered, isDateInsideRange, isDateSelected, onDateFocus, onDateHover, onDateSelect, }: UseDayProps): UseDayReturnType;
|
|
28
|
+
export declare function useDay({ date, dayRef, focusedDate, isDateBlocked, isDateFocused, isDateHovered, isDateInsideRange, isDateSelected, onDateFocus, onDateHover, onDateSelect, preventScroll, }: UseDayProps): UseDayReturnType;
|
package/hooks/use-day.js
CHANGED
|
@@ -3,16 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useDay = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
|
-
function useDay({ date, dayRef, focusedDate, isDateBlocked, isDateFocused, isDateHovered, isDateInsideRange, isDateSelected, onDateFocus, onDateHover, onDateSelect, }) {
|
|
6
|
+
function useDay({ date, dayRef, focusedDate, isDateBlocked, isDateFocused, isDateHovered, isDateInsideRange, isDateSelected, onDateFocus, onDateHover, onDateSelect, preventScroll, }) {
|
|
7
7
|
const onClick = (0, react_1.useCallback)(() => onDateSelect(date), [date, onDateSelect]);
|
|
8
8
|
const onMouseEnter = (0, react_1.useCallback)(() => onDateHover(date), [date, onDateHover]);
|
|
9
9
|
const disabled = isDateBlocked(date) && !isDateHovered(date);
|
|
10
10
|
const isToday = (0, dayjs_en_1.dayjsEn)().isSame(date, "day");
|
|
11
11
|
(0, react_1.useEffect)(() => {
|
|
12
12
|
if (dayRef && dayRef.current && isDateFocused(date)) {
|
|
13
|
-
dayRef.current.focus(
|
|
13
|
+
dayRef.current.focus({
|
|
14
|
+
preventScroll,
|
|
15
|
+
});
|
|
14
16
|
}
|
|
15
|
-
}, [dayRef, date, isDateFocused]);
|
|
17
|
+
}, [dayRef, date, isDateFocused, preventScroll]);
|
|
16
18
|
const onKeyDown = (0, react_1.useCallback)((e) => {
|
|
17
19
|
if (["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"].includes(e.key)) {
|
|
18
20
|
e.preventDefault();
|
package/hooks/use-hour.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface UseHourProps {
|
|
|
7
7
|
isHourSelected: (hour: number) => boolean;
|
|
8
8
|
onHourFocus: (hour: number) => void;
|
|
9
9
|
onHourSelect: (hour: number) => void;
|
|
10
|
+
preventScroll?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export interface UseHourReturnType {
|
|
12
13
|
isSelected: boolean;
|
|
@@ -14,4 +15,4 @@ export interface UseHourReturnType {
|
|
|
14
15
|
onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
|
|
15
16
|
tabIndex: number;
|
|
16
17
|
}
|
|
17
|
-
export declare function useHour({ hour, hourRef, focusedHour, isHourFocused, isHourSelected, onHourFocus, onHourSelect, }: UseHourProps): UseHourReturnType;
|
|
18
|
+
export declare function useHour({ hour, hourRef, focusedHour, isHourFocused, isHourSelected, onHourFocus, onHourSelect, preventScroll, }: UseHourProps): UseHourReturnType;
|
package/hooks/use-hour.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useHour = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
function useHour({ hour, hourRef, focusedHour, isHourFocused, isHourSelected, onHourFocus, onHourSelect, }) {
|
|
5
|
+
function useHour({ hour, hourRef, focusedHour, isHourFocused, isHourSelected, onHourFocus, onHourSelect, preventScroll, }) {
|
|
6
6
|
const onClick = (0, react_1.useCallback)(() => onHourSelect(hour), [hour, onHourSelect]);
|
|
7
7
|
(0, react_1.useEffect)(() => {
|
|
8
8
|
if (hourRef && hourRef.current && isHourFocused(hour)) {
|
|
9
|
-
hourRef.current.focus(
|
|
9
|
+
hourRef.current.focus({
|
|
10
|
+
preventScroll,
|
|
11
|
+
});
|
|
10
12
|
}
|
|
11
|
-
}, [hourRef, hour, isHourFocused]);
|
|
13
|
+
}, [hourRef, hour, isHourFocused, preventScroll]);
|
|
12
14
|
const onKeyDown = (0, react_1.useCallback)((e) => {
|
|
13
15
|
if (["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"].includes(e.key)) {
|
|
14
16
|
e.preventDefault();
|
package/hooks/use-minute.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface UseMinuteProps {
|
|
|
7
7
|
isMinuteSelected: (minute: number) => boolean;
|
|
8
8
|
onMinuteFocus: (minute: number) => void;
|
|
9
9
|
onMinuteSelect: (minute: number) => void;
|
|
10
|
+
preventScroll?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export interface UseMinuteReturnType {
|
|
12
13
|
isSelected: boolean;
|
|
@@ -14,4 +15,4 @@ export interface UseMinuteReturnType {
|
|
|
14
15
|
onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
|
|
15
16
|
tabIndex: number;
|
|
16
17
|
}
|
|
17
|
-
export declare function useMinute({ minute, minuteRef, focusedMinute, isMinuteFocused, isMinuteSelected, onMinuteFocus, onMinuteSelect, }: UseMinuteProps): UseMinuteReturnType;
|
|
18
|
+
export declare function useMinute({ minute, minuteRef, focusedMinute, isMinuteFocused, isMinuteSelected, onMinuteFocus, onMinuteSelect, preventScroll, }: UseMinuteProps): UseMinuteReturnType;
|
package/hooks/use-minute.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useMinute = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
function useMinute({ minute, minuteRef, focusedMinute, isMinuteFocused, isMinuteSelected, onMinuteFocus, onMinuteSelect, }) {
|
|
5
|
+
function useMinute({ minute, minuteRef, focusedMinute, isMinuteFocused, isMinuteSelected, onMinuteFocus, onMinuteSelect, preventScroll, }) {
|
|
6
6
|
const onClick = (0, react_1.useCallback)(() => onMinuteSelect(minute), [minute, onMinuteSelect]);
|
|
7
7
|
(0, react_1.useEffect)(() => {
|
|
8
8
|
if (minuteRef && minuteRef.current && isMinuteFocused(minute)) {
|
|
9
|
-
minuteRef.current.focus(
|
|
9
|
+
minuteRef.current.focus({
|
|
10
|
+
preventScroll,
|
|
11
|
+
});
|
|
10
12
|
}
|
|
11
|
-
}, [minuteRef, minute, isMinuteFocused]);
|
|
13
|
+
}, [minuteRef, minute, isMinuteFocused, preventScroll]);
|
|
12
14
|
const onKeyDown = (0, react_1.useCallback)((e) => {
|
|
13
15
|
if (["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown"].includes(e.key)) {
|
|
14
16
|
e.preventDefault();
|
|
@@ -6,6 +6,7 @@ export type OnTimeChangeType = TimeType | null;
|
|
|
6
6
|
export interface UseTimePickerProps {
|
|
7
7
|
onSelectCallback?: () => void;
|
|
8
8
|
onTimeChange: (data: OnTimeChangeType) => void;
|
|
9
|
+
preventScroll?: boolean;
|
|
9
10
|
selectedTime: TimeType | null;
|
|
10
11
|
}
|
|
11
12
|
export interface UseTimePickerReturnType {
|
|
@@ -24,5 +25,6 @@ export interface UseTimePickerReturnType {
|
|
|
24
25
|
onHourSelect: (hour: number) => void;
|
|
25
26
|
onMinuteFocus: (minute: number) => void;
|
|
26
27
|
onMinuteSelect: (minute: number) => void;
|
|
28
|
+
preventScroll?: boolean;
|
|
27
29
|
}
|
|
28
|
-
export declare function useTimePicker({ selectedTime, onTimeChange, onSelectCallback, }: UseTimePickerProps): UseTimePickerReturnType;
|
|
30
|
+
export declare function useTimePicker({ selectedTime, onTimeChange, onSelectCallback, preventScroll, }: UseTimePickerProps): UseTimePickerReturnType;
|
package/hooks/use-time-picker.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useTimePicker = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
function useTimePicker({ selectedTime, onTimeChange, onSelectCallback, }) {
|
|
5
|
+
function useTimePicker({ selectedTime, onTimeChange, onSelectCallback, preventScroll, }) {
|
|
6
6
|
var _a, _b;
|
|
7
7
|
const [focusedHour, setFocusedHour] = (0, react_1.useState)((_a = selectedTime === null || selectedTime === void 0 ? void 0 : selectedTime.hour) !== null && _a !== void 0 ? _a : null);
|
|
8
8
|
const [focusedMinute, setFocusedMinute] = (0, react_1.useState)((_b = selectedTime === null || selectedTime === void 0 ? void 0 : selectedTime.minute) !== null && _b !== void 0 ? _b : null);
|
|
@@ -78,6 +78,7 @@ function useTimePicker({ selectedTime, onTimeChange, onSelectCallback, }) {
|
|
|
78
78
|
onHourSelect,
|
|
79
79
|
onMinuteFocus,
|
|
80
80
|
onMinuteSelect,
|
|
81
|
+
preventScroll,
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
exports.useTimePicker = useTimePicker;
|