@uxf/datepicker 10.0.0-beta.9 → 10.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/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-navigation.js +1 -1
- package/hooks/use-date-picker.d.ts +3 -1
- package/hooks/use-date-picker.js +4 -3
- package/hooks/use-date-range-picker.d.ts +2 -0
- package/hooks/use-date-range-picker.js +2 -2
- package/hooks/use-day.d.ts +2 -1
- package/hooks/use-day.js +5 -3
- package/hooks/use-decade.js +1 -1
- 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-month.js +1 -1
- package/hooks/use-time-picker.d.ts +3 -1
- package/hooks/use-time-picker.js +2 -1
- package/hooks/use-year.js +1 -1
- package/package.json +10 -16
- package/utils/can-select-range.js +1 -1
- package/utils/get-current-year-month-and-date.js +1 -1
- package/utils/get-days.js +1 -1
- package/utils/get-initial-months.js +1 -1
- package/utils/get-months.js +1 -1
- package/utils/get-next-active-month.js +1 -1
- package/utils/get-weekday-labels.js +1 -1
- package/utils/get-weekday-labels.test.js +1 -1
- package/utils/get-years.js +1 -1
- package/utils/is-date-blocked.js +1 -1
- package/utils/is-date-hovered.js +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>;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDatePickerNavigation = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
5
6
|
const get_initial_months_1 = require("../utils/get-initial-months");
|
|
6
7
|
const get_next_active_month_1 = require("../utils/get-next-active-month");
|
|
7
|
-
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
8
8
|
function useDatePickerNavigation({ activeMonths, setActiveMonths, setFocusedDate, minBookingDate, maxBookingDate, numberOfMonths, }) {
|
|
9
9
|
const goToPrevMonths = (0, react_1.useCallback)(() => {
|
|
10
10
|
setActiveMonths((0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1));
|
|
@@ -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
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDatePicker = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
5
6
|
const get_initial_months_1 = require("../utils/get-initial-months");
|
|
7
|
+
const is_browser_1 = require("../utils/is-browser");
|
|
6
8
|
const is_date_blocked_1 = require("../utils/is-date-blocked");
|
|
7
9
|
const is_date_hovered_1 = require("../utils/is-date-hovered");
|
|
8
10
|
const is_in_unavailable_dates_1 = require("../utils/is-in-unavailable-dates");
|
|
9
11
|
const is_start_date_1 = require("../utils/is-start-date");
|
|
10
12
|
const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
|
|
11
|
-
|
|
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;
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useDateRangePicker = exports.END_DATE = exports.START_DATE = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const can_select_range_1 = require("../utils/can-select-range");
|
|
6
|
+
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
7
|
const get_initial_months_1 = require("../utils/get-initial-months");
|
|
8
|
+
const is_browser_1 = require("../utils/is-browser");
|
|
7
9
|
const is_date_blocked_1 = require("../utils/is-date-blocked");
|
|
8
10
|
const is_date_hovered_1 = require("../utils/is-date-hovered");
|
|
9
11
|
const is_date_inside_range_1 = require("../utils/is-date-inside-range");
|
|
@@ -12,8 +14,6 @@ const is_first_or_last_selected_date_1 = require("../utils/is-first-or-last-sele
|
|
|
12
14
|
const is_in_unavailable_dates_1 = require("../utils/is-in-unavailable-dates");
|
|
13
15
|
const is_start_date_1 = require("../utils/is-start-date");
|
|
14
16
|
const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
|
|
15
|
-
const is_browser_1 = require("../utils/is-browser");
|
|
16
|
-
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
17
17
|
exports.START_DATE = "startDate";
|
|
18
18
|
exports.END_DATE = "endDate";
|
|
19
19
|
function useDateRangePicker({ changeActiveMonthOnSelect = false, endDate, exactMinBookingDays = false, firstDayOfWeek = 0, focusedInput, initialVisibleMonth, isDateBlocked: isDateBlockedProps = () => false, maxBookingDate, minBookingDate, minBookingDays = 1, numberOfMonths = 2, onDatesChange, startDate, unavailableDates = [], }) {
|
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-decade.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDecade = exports.decadeLabelFormatFn = exports.yearLabelFormatFn = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const get_years_1 = require("../utils/get-years");
|
|
6
5
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
|
+
const get_years_1 = require("../utils/get-years");
|
|
7
7
|
const yearLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY");
|
|
8
8
|
exports.yearLabelFormatFn = yearLabelFormatFn;
|
|
9
9
|
const decadeLabelFormatFn = (start, end) => `${(0, dayjs_en_1.dayjsEn)(start).format("YYYY")} \u2013 ${(0, dayjs_en_1.dayjsEn)(end).format("YYYY")}`;
|
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();
|
package/hooks/use-month.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useMonth = exports.monthLabelFormatFn = exports.weekdayLabelFormatFn = exports.dayLabelFormatFn = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
5
6
|
const get_days_1 = require("../utils/get-days");
|
|
6
7
|
const get_weekday_labels_1 = require("../utils/get-weekday-labels");
|
|
7
|
-
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
8
8
|
const dayLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("DD");
|
|
9
9
|
exports.dayLabelFormatFn = dayLabelFormatFn;
|
|
10
10
|
const weekdayLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("dd"); // localization
|
|
@@ -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;
|
package/hooks/use-year.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useYear = exports.yearLabelFormatFn = exports.monthLabelFormatFn = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const get_months_1 = require("../utils/get-months");
|
|
6
5
|
const dayjs_en_1 = require("../utils/dayjs-en");
|
|
6
|
+
const get_months_1 = require("../utils/get-months");
|
|
7
7
|
const monthLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("MMMM"); // localized
|
|
8
8
|
exports.monthLabelFormatFn = monthLabelFormatFn;
|
|
9
9
|
const yearLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY");
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/datepicker",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "A set of React hooks to create an awesome datepicker.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc -P tsconfig.json",
|
|
8
|
-
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
9
|
-
"jest": "jest --coverage=true"
|
|
8
|
+
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
10
9
|
},
|
|
11
10
|
"publishConfig": {
|
|
12
11
|
"access": "public"
|
|
@@ -15,26 +14,21 @@
|
|
|
15
14
|
"type": "git",
|
|
16
15
|
"url": "git+https://gitlab.com/uxf-npm/datepicker.git"
|
|
17
16
|
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@testing-library/react-hooks": "^7.0.1",
|
|
20
|
-
"@types/react": "18.2.6",
|
|
21
|
-
"eslint": "^8.8.0",
|
|
22
|
-
"react": "18.2.0"
|
|
23
|
-
},
|
|
24
17
|
"author": "UX Fans s.r.o.",
|
|
25
18
|
"license": "ISC",
|
|
26
19
|
"bugs": {
|
|
27
20
|
"url": "https://gitlab.com/uxf-npm/datepicker/issues"
|
|
28
21
|
},
|
|
29
22
|
"homepage": "https://gitlab.com/uxf-npm/datepicker#readme",
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"dayjs": "^1.11.5"
|
|
32
|
-
},
|
|
33
23
|
"peerDependencies": {
|
|
34
|
-
"react": ">=
|
|
24
|
+
"react": ">=18.2.0",
|
|
25
|
+
"react-dom": ">=18.2.0"
|
|
35
26
|
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@testing-library/react-hooks": "7.0.2",
|
|
29
|
+
"@types/react": "18.2.27",
|
|
30
|
+
"@types/react-dom": "18.2.12",
|
|
31
|
+
"react": "18.2.0",
|
|
32
|
+
"react-dom": "18.2.0"
|
|
39
33
|
}
|
|
40
34
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.canSelectRange = void 0;
|
|
4
|
-
const get_each_1 = require("./get-each");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
|
+
const get_each_1 = require("./get-each");
|
|
6
6
|
// eslint-disable-next-line complexity
|
|
7
7
|
function canSelectRange({ startDate, endDate, isDateBlocked, minBookingDays, exactMinBookingDays, minBookingDate, maxBookingDate, }) {
|
|
8
8
|
const isStartDateAfterOrEqualMinDate = minBookingDate
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentYearMonthAndDate = void 0;
|
|
4
|
-
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
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
|
}
|
package/utils/get-days.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDays = void 0;
|
|
4
|
-
const get_each_1 = require("./get-each");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
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"), }) {
|
|
7
7
|
const date = new Date(year, month);
|
|
8
8
|
const lastDayOfWeek = firstDayOfWeek + 7;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInitialMonths = void 0;
|
|
4
|
+
const dayjs_en_1 = require("./dayjs-en");
|
|
4
5
|
const get_current_year_month_and_date_1 = require("./get-current-year-month-and-date");
|
|
5
6
|
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
6
|
-
const dayjs_en_1 = require("./dayjs-en");
|
|
7
7
|
function getInitialMonths(numberOfMonths, startDate) {
|
|
8
8
|
const firstMonth = startDate ? (0, get_date_month_and_year_1.getDateMonthAndYear)(startDate) : (0, get_current_year_month_and_date_1.getCurrentYearMonthAndDate)();
|
|
9
9
|
let prevMonthDate = firstMonth.date;
|
package/utils/get-months.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMonths = void 0;
|
|
4
|
-
const get_each_1 = require("./get-each");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
|
+
const get_each_1 = require("./get-each");
|
|
6
6
|
function getMonths({ year, monthLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("MMMM"), }) {
|
|
7
7
|
const date = new Date(year, 0);
|
|
8
8
|
const yearStart = (0, dayjs_en_1.dayjsEn)(date).startOf("year").toDate();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNextActiveMonth = void 0;
|
|
4
|
-
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
|
+
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
6
6
|
function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
|
|
7
7
|
let prevMonth;
|
|
8
8
|
if (step) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getWeekdayLabels = void 0;
|
|
4
|
-
const get_each_1 = require("./get-each");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
|
+
const get_each_1 = require("./get-each");
|
|
6
6
|
function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("dd"), }) {
|
|
7
7
|
const now = new 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");
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
|
-
const get_weekday_labels_1 = require("./get-weekday-labels");
|
|
8
7
|
require("dayjs/locale/cs");
|
|
8
|
+
const get_weekday_labels_1 = require("./get-weekday-labels");
|
|
9
9
|
test("getWeekdayLabels", () => {
|
|
10
10
|
expect((0, get_weekday_labels_1.getWeekdayLabels)({})).toStrictEqual(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
|
|
11
11
|
});
|
package/utils/get-years.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getYears = void 0;
|
|
4
|
-
const get_each_1 = require("./get-each");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
|
+
const get_each_1 = require("./get-each");
|
|
6
6
|
function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY"), }) {
|
|
7
7
|
return (0, get_each_1.getEach)(startYear, endYear, "year").map((d) => ({
|
|
8
8
|
date: d,
|
package/utils/is-date-blocked.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDateBlocked = void 0;
|
|
4
|
-
const is_in_unavailable_dates_1 = require("./is-in-unavailable-dates");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
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 = [], }) {
|
|
7
7
|
const compareMinDate = minBookingDate
|
|
8
8
|
? new Date(minBookingDate.getFullYear(), minBookingDate.getMonth(), minBookingDate.getDate(), 0, 0, 0)
|
package/utils/is-date-hovered.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDateHovered = void 0;
|
|
4
|
-
const get_each_1 = require("./get-each");
|
|
5
4
|
const dayjs_en_1 = require("./dayjs-en");
|
|
5
|
+
const get_each_1 = require("./get-each");
|
|
6
6
|
function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, minBookingDays, exactMinBookingDays, }) {
|
|
7
7
|
if (
|
|
8
8
|
// exact min booking days
|