@uxf/ui 11.60.4 → 11.61.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/calendar/calendar-navigation.d.ts +2 -1
- package/calendar/calendar-navigation.js +12 -5
- package/css/calendar.css +15 -8
- package/css/date-range-picker.css +5 -0
- package/date-picker/date-picker-content.d.ts +2 -0
- package/date-picker/date-picker-content.js +4 -4
- package/date-picker/date-picker-decade.d.ts +4 -1
- package/date-picker/date-picker-decade.js +24 -9
- package/date-picker/date-picker-month.d.ts +2 -1
- package/date-picker/date-picker-month.js +16 -9
- package/date-picker/date-picker-year.d.ts +2 -0
- package/date-picker/date-picker-year.js +23 -9
- package/date-picker/date-picker.d.ts +2 -0
- package/date-picker/date-picker.js +1 -1
- package/date-picker/types.d.ts +10 -0
- package/date-picker-input/date-picker-input.d.ts +2 -0
- package/date-picker-input/date-picker-input.js +1 -1
- package/date-picker-input/date-picker-input.stories.js +10 -1
- package/date-range-picker/date-range-picker-content.js +1 -1
- package/date-range-picker/date-range-picker-decade.d.ts +4 -1
- package/date-range-picker/date-range-picker-decade.js +28 -8
- package/date-range-picker/date-range-picker-month.d.ts +2 -0
- package/date-range-picker/date-range-picker-month.js +21 -8
- package/date-range-picker/date-range-picker-year.d.ts +2 -0
- package/date-range-picker/date-range-picker-year.js +17 -7
- package/date-range-picker-input/date-range-picker-input.stories.js +1 -1
- package/icons-config.js +5 -0
- package/package.json +2 -2
|
@@ -2,7 +2,8 @@ import { FC } from "react";
|
|
|
2
2
|
import { ButtonProps } from "../button";
|
|
3
3
|
export interface CalendarNavigationProps {
|
|
4
4
|
prevButtonProps: ButtonProps;
|
|
5
|
-
|
|
5
|
+
monthButtonProps: ButtonProps;
|
|
6
|
+
yearButtonProps: ButtonProps;
|
|
6
7
|
nextButtonProps: ButtonProps;
|
|
7
8
|
}
|
|
8
9
|
export declare const CalendarNavigation: FC<CalendarNavigationProps>;
|
|
@@ -9,11 +9,18 @@ const button_1 = require("../button");
|
|
|
9
9
|
const icon_1 = require("../icon");
|
|
10
10
|
const CalendarNavigation = (props) => {
|
|
11
11
|
return (react_1.default.createElement("div", { className: "uxf-calendar-navigation" },
|
|
12
|
-
react_1.default.createElement(
|
|
13
|
-
react_1.default.createElement(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
react_1.default.createElement(
|
|
12
|
+
react_1.default.createElement("div", { className: "uxf-calendar-navigation__month-year-buttons-wrapper" },
|
|
13
|
+
react_1.default.createElement(button_1.Button, { className: "uxf-calendar-navigation__month-button", color: "default", size: "sm", variant: "text", ...props.monthButtonProps },
|
|
14
|
+
props.monthButtonProps.children,
|
|
15
|
+
react_1.default.createElement(icon_1.Icon, { name: "caretDown", size: 16 })),
|
|
16
|
+
react_1.default.createElement(button_1.Button, { className: "uxf-calendar-navigation__year-button", color: "default", size: "sm", variant: "text", ...props.yearButtonProps },
|
|
17
|
+
props.yearButtonProps.children,
|
|
18
|
+
react_1.default.createElement(icon_1.Icon, { name: "caretDown", size: 16 }))),
|
|
19
|
+
react_1.default.createElement("div", { className: "uxf-calendar-navigation__prev-next-buttons-wrapper" },
|
|
20
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, size: "sm", variant: "text", ...props.prevButtonProps },
|
|
21
|
+
react_1.default.createElement(icon_1.Icon, { name: "angle-left", size: 16 })),
|
|
22
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, size: "sm", variant: "text", ...props.nextButtonProps },
|
|
23
|
+
react_1.default.createElement(icon_1.Icon, { name: "angle-right", size: 16 })))));
|
|
17
24
|
};
|
|
18
25
|
exports.CalendarNavigation = CalendarNavigation;
|
|
19
26
|
exports.CalendarNavigation.displayName = "UxfUiCalendarNavigation";
|
package/css/calendar.css
CHANGED
|
@@ -252,15 +252,22 @@
|
|
|
252
252
|
justify-content: space-between;
|
|
253
253
|
margin-bottom: theme("spacing.4");
|
|
254
254
|
|
|
255
|
-
&
|
|
256
|
-
|
|
255
|
+
&__year-button,
|
|
256
|
+
&__month-button {
|
|
257
|
+
gap: theme("spacing.1");
|
|
257
258
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
:root .dark & {
|
|
263
|
-
@apply text-darkMedium is-hoverable:text-darkHigh;
|
|
259
|
+
&.is-disabled {
|
|
260
|
+
background-color: theme("colors.neutral_surface_muted");
|
|
261
|
+
color: theme("colors.base_text_high_emphasis");
|
|
264
262
|
}
|
|
265
263
|
}
|
|
264
|
+
|
|
265
|
+
&__prev-next-buttons-wrapper {
|
|
266
|
+
display: flex;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
&__month-year-buttons-wrapper {
|
|
270
|
+
display: flex;
|
|
271
|
+
gap: theme("spacing.2");
|
|
272
|
+
}
|
|
266
273
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { MonthType } from "@uxf/datepicker/utils/types";
|
|
2
2
|
import { CSSProperties, FC, PropsWithChildren, ReactNode } from "react";
|
|
3
|
+
import { CustomButtonTitles } from "./types";
|
|
3
4
|
export interface DatePickerContentProps {
|
|
4
5
|
bottomContent?: ReactNode;
|
|
5
6
|
onMonthChange?: (months: MonthType[]) => void;
|
|
6
7
|
style?: CSSProperties;
|
|
8
|
+
customButtonTitles?: CustomButtonTitles;
|
|
7
9
|
}
|
|
8
10
|
export declare const DatePickerContent: FC<PropsWithChildren<DatePickerContentProps>>;
|
|
@@ -45,10 +45,10 @@ const DatePickerContent = (props) => {
|
|
|
45
45
|
setViewMode("year");
|
|
46
46
|
}, [goToDate, setViewMode]);
|
|
47
47
|
const datePickerComponents = (0, react_1.useMemo)(() => ({
|
|
48
|
-
month: activeMonths.map((month) => (react_1.default.createElement(date_picker_month_1.DatePickerMonth, { key: `${month.year}-${month.month}`, onMonthChange: onMonthChange, setViewMode: setViewMode }))),
|
|
49
|
-
year: react_1.default.createElement(date_picker_year_1.DatePickerYear, { onMonthSelect: (date) => onMonthSelect(date), onYearSelect: onYearSelect }),
|
|
50
|
-
decade: react_1.default.createElement(date_picker_decade_1.DatePickerDecade, { onYearSelect: (date) => onDecadeYearSelect(date) }),
|
|
51
|
-
}), [activeMonths, onYearSelect, onMonthChange, onMonthSelect, onDecadeYearSelect]);
|
|
48
|
+
month: activeMonths.map((month) => (react_1.default.createElement(date_picker_month_1.DatePickerMonth, { customButtonTitles: props.customButtonTitles, key: `${month.year}-${month.month}`, onMonthChange: onMonthChange, setViewMode: setViewMode }))),
|
|
49
|
+
year: (react_1.default.createElement(date_picker_year_1.DatePickerYear, { customButtonTitles: props.customButtonTitles, onMonthSelect: (date) => onMonthSelect(date), onYearSelect: onYearSelect })),
|
|
50
|
+
decade: (react_1.default.createElement(date_picker_decade_1.DatePickerDecade, { customButtonTitles: props.customButtonTitles, onYearSelect: (date) => onDecadeYearSelect(date), setViewMode: setViewMode })),
|
|
51
|
+
}), [activeMonths, props.customButtonTitles, onYearSelect, onMonthChange, onMonthSelect, onDecadeYearSelect]);
|
|
52
52
|
return (react_1.default.createElement("div", { className: "uxf-date-picker", style: props.style },
|
|
53
53
|
props.children,
|
|
54
54
|
datePickerComponents[viewMode],
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import { CustomButtonTitles, ViewModeType } from "./types";
|
|
2
3
|
interface DatePickerDecadeProps {
|
|
4
|
+
customButtonTitles?: CustomButtonTitles;
|
|
3
5
|
onYearSelect: (date: Date) => void;
|
|
6
|
+
setViewMode: Dispatch<SetStateAction<ViewModeType>>;
|
|
4
7
|
}
|
|
5
8
|
export declare const DatePickerDecade: React.NamedExoticComponent<DatePickerDecadeProps>;
|
|
6
9
|
export {};
|
|
@@ -31,15 +31,17 @@ const classes_1 = require("@uxf/core/constants/classes");
|
|
|
31
31
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
32
|
const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-context");
|
|
33
33
|
const use_decade_1 = require("@uxf/datepicker/hooks/use-decade");
|
|
34
|
+
const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
34
35
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
35
36
|
const react_1 = __importStar(require("react"));
|
|
36
37
|
const calendar_1 = require("../calendar");
|
|
37
38
|
exports.DatePickerDecade = (0, react_1.memo)((props) => {
|
|
38
|
-
var _a, _b;
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
39
40
|
const { onYearSelect } = props;
|
|
40
|
-
const { canGoToYear, goToNextYear, goToPrevYear, activeMonths } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
41
|
+
const { canGoToYear, goToNextYear, goToPrevYear, activeMonths, firstDayOfWeek, selectedDate } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
41
42
|
const currentYear = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.year) !== null && _b !== void 0 ? _b : new Date().getFullYear();
|
|
42
|
-
const
|
|
43
|
+
const currentMonth = (_d = (_c = activeMonths.at(0)) === null || _c === void 0 ? void 0 : _c.month) !== null && _d !== void 0 ? _d : new Date().getMonth();
|
|
44
|
+
const { years } = (0, use_decade_1.useDecade)({
|
|
43
45
|
year: currentYear,
|
|
44
46
|
});
|
|
45
47
|
const canGoToPrevDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).subtract(5, "years").toDate());
|
|
@@ -59,16 +61,29 @@ exports.DatePickerDecade = (0, react_1.memo)((props) => {
|
|
|
59
61
|
onYearSelect(date);
|
|
60
62
|
}
|
|
61
63
|
}, [canGoToYear, onYearSelect]);
|
|
64
|
+
const { monthLabel } = (0, use_month_1.useMonth)({
|
|
65
|
+
dayLabelFormat: (date) => (0, dayjs_1.default)(date).format("D"),
|
|
66
|
+
firstDayOfWeek,
|
|
67
|
+
month: currentMonth,
|
|
68
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
69
|
+
year: currentYear,
|
|
70
|
+
});
|
|
71
|
+
const handleSetMonthViewMode = (0, react_1.useCallback)(() => props.setViewMode("year"), [props]);
|
|
62
72
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
63
|
-
react_1.default.createElement(calendar_1.CalendarNavigation, {
|
|
73
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { monthButtonProps: {
|
|
74
|
+
children: monthLabel,
|
|
75
|
+
onClick: handleSetMonthViewMode,
|
|
76
|
+
title: (_f = (_e = props.customButtonTitles) === null || _e === void 0 ? void 0 : _e.selectMonth) !== null && _f !== void 0 ? _f : "Vybrat měsíc",
|
|
77
|
+
}, nextButtonProps: {
|
|
64
78
|
onClick: handleGoToNextDecadeClick,
|
|
65
|
-
title: "Vpřed",
|
|
79
|
+
title: (_h = (_g = props.customButtonTitles) === null || _g === void 0 ? void 0 : _g.nextDecade) !== null && _h !== void 0 ? _h : "Vpřed",
|
|
66
80
|
}, prevButtonProps: {
|
|
67
81
|
onClick: handleGoToPrevDecadeClick,
|
|
68
|
-
title: "Zpět",
|
|
69
|
-
},
|
|
70
|
-
children:
|
|
82
|
+
title: (_k = (_j = props.customButtonTitles) === null || _j === void 0 ? void 0 : _j.prevDecade) !== null && _k !== void 0 ? _k : "Zpět",
|
|
83
|
+
}, yearButtonProps: {
|
|
84
|
+
children: currentYear,
|
|
85
|
+
isDisabled: true,
|
|
71
86
|
} }),
|
|
72
|
-
react_1.default.createElement("div", { className: "uxf-calendar__decade" }, years.map((year) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-year", !canGoToYear(year.date) && classes_1.CLASSES.IS_DISABLED), key: year.yearLabel, onClick: handleSelectYear(year.date), type: "button" }, year.yearLabel))))));
|
|
87
|
+
react_1.default.createElement("div", { className: "uxf-calendar__decade" }, years.map((year) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-year", !canGoToYear(year.date) && classes_1.CLASSES.IS_DISABLED, (0, dayjs_1.default)(year.date).year() === (0, dayjs_1.default)(selectedDate).year() && "uxf-calendar__cell--selected"), key: year.yearLabel, onClick: handleSelectYear(year.date), type: "button" }, year.yearLabel))))));
|
|
73
88
|
});
|
|
74
89
|
exports.DatePickerDecade.displayName = "UxfUiDatePickerDecade";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { MonthType } from "@uxf/datepicker/utils/types";
|
|
2
2
|
import React, { Dispatch, SetStateAction } from "react";
|
|
3
|
-
import { ViewModeType } from "./types";
|
|
3
|
+
import { CustomButtonTitles, ViewModeType } from "./types";
|
|
4
4
|
interface DatePickerMonthProps {
|
|
5
5
|
onMonthChange?: (months: MonthType[]) => void;
|
|
6
6
|
setViewMode: Dispatch<SetStateAction<ViewModeType>>;
|
|
7
|
+
customButtonTitles?: CustomButtonTitles;
|
|
7
8
|
}
|
|
8
9
|
export declare const DatePickerMonth: React.NamedExoticComponent<DatePickerMonthProps>;
|
|
9
10
|
export {};
|
|
@@ -33,7 +33,7 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
33
33
|
const react_1 = __importStar(require("react"));
|
|
34
34
|
const calendar_1 = require("../calendar");
|
|
35
35
|
exports.DatePickerMonth = (0, react_1.memo)((props) => {
|
|
36
|
-
var _a, _b, _c, _d;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
37
37
|
const { setViewMode } = props;
|
|
38
38
|
const datePickerProps = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
39
39
|
const onMonthChange = props.onMonthChange;
|
|
@@ -44,7 +44,7 @@ exports.DatePickerMonth = (0, react_1.memo)((props) => {
|
|
|
44
44
|
dayLabelFormat: (date) => (0, dayjs_1.default)(date).format("D"),
|
|
45
45
|
firstDayOfWeek,
|
|
46
46
|
month: currentMonth,
|
|
47
|
-
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM
|
|
47
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
48
48
|
weekdayLabelFormat: (date) => (0, dayjs_1.default)(date).format("dd"),
|
|
49
49
|
year: currentYear,
|
|
50
50
|
});
|
|
@@ -59,19 +59,26 @@ exports.DatePickerMonth = (0, react_1.memo)((props) => {
|
|
|
59
59
|
const handleMonthClick = (0, react_1.useCallback)(() => {
|
|
60
60
|
setViewMode("year");
|
|
61
61
|
}, [setViewMode]);
|
|
62
|
+
const handleSetYearViewModeClick = (0, react_1.useCallback)(() => {
|
|
63
|
+
setViewMode("decade");
|
|
64
|
+
}, [setViewMode]);
|
|
62
65
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
63
|
-
react_1.default.createElement(calendar_1.CalendarNavigation, {
|
|
66
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { monthButtonProps: {
|
|
67
|
+
children: monthLabel,
|
|
68
|
+
onClick: handleMonthClick,
|
|
69
|
+
title: (_f = (_e = props.customButtonTitles) === null || _e === void 0 ? void 0 : _e.selectMonth) !== null && _f !== void 0 ? _f : "Vybrat měsíc",
|
|
70
|
+
}, nextButtonProps: {
|
|
64
71
|
isDisabled: !canGoToNextMonth,
|
|
65
72
|
onClick: canGoToNextMonth ? handleGoToNextMonth : undefined,
|
|
66
|
-
title: "Nadcházející měsíc",
|
|
73
|
+
title: (_h = (_g = props.customButtonTitles) === null || _g === void 0 ? void 0 : _g.nextMonth) !== null && _h !== void 0 ? _h : "Nadcházející měsíc",
|
|
67
74
|
}, prevButtonProps: {
|
|
68
75
|
isDisabled: !canGoToPrevMonth,
|
|
69
76
|
onClick: canGoToPrevMonth ? handleGoToPrevMonth : undefined,
|
|
70
|
-
title: "Předchozí měsíc",
|
|
71
|
-
},
|
|
72
|
-
children:
|
|
73
|
-
onClick:
|
|
74
|
-
title: "Vybrat
|
|
77
|
+
title: (_k = (_j = props.customButtonTitles) === null || _j === void 0 ? void 0 : _j.prevMonth) !== null && _k !== void 0 ? _k : "Předchozí měsíc",
|
|
78
|
+
}, yearButtonProps: {
|
|
79
|
+
children: currentYear,
|
|
80
|
+
onClick: handleSetYearViewModeClick,
|
|
81
|
+
title: (_m = (_l = props.customButtonTitles) === null || _l === void 0 ? void 0 : _l.selectYear) !== null && _m !== void 0 ? _m : "Vybrat rok",
|
|
75
82
|
} }),
|
|
76
83
|
react_1.default.createElement(calendar_1.Calendar, { datePickerProps: datePickerProps })));
|
|
77
84
|
});
|
|
@@ -30,19 +30,28 @@ exports.DatePickerYear = void 0;
|
|
|
30
30
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
31
31
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
32
|
const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-context");
|
|
33
|
+
const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
33
34
|
const use_year_1 = require("@uxf/datepicker/hooks/use-year");
|
|
34
35
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
35
36
|
const react_1 = __importStar(require("react"));
|
|
36
37
|
const calendar_1 = require("../calendar");
|
|
37
38
|
exports.DatePickerYear = (0, react_1.memo)((props) => {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
const { canGoToNextYear, canGoToPrevYear, goToNextYear, goToPrevYear, canGoToMonth, activeMonths } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
40
|
-
const
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
40
|
+
const { canGoToNextYear, canGoToPrevYear, goToNextYear, goToPrevYear, canGoToMonth, activeMonths, firstDayOfWeek, selectedDate, } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
41
|
+
const currentMonth = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.month) !== null && _b !== void 0 ? _b : new Date().getMonth();
|
|
42
|
+
const currentYear = (_d = (_c = activeMonths.at(0)) === null || _c === void 0 ? void 0 : _c.year) !== null && _d !== void 0 ? _d : new Date().getFullYear();
|
|
41
43
|
const { months, yearLabel } = (0, use_year_1.useYear)({
|
|
42
44
|
year: currentYear,
|
|
43
45
|
yearLabelFormat: (date) => (0, dayjs_1.default)(date).format("YYYY"),
|
|
44
46
|
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
45
47
|
});
|
|
48
|
+
const { monthLabel } = (0, use_month_1.useMonth)({
|
|
49
|
+
dayLabelFormat: (date) => (0, dayjs_1.default)(date).format("D"),
|
|
50
|
+
firstDayOfWeek,
|
|
51
|
+
month: currentMonth,
|
|
52
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
53
|
+
year: currentYear,
|
|
54
|
+
});
|
|
46
55
|
const handleGoToNextYear = (0, react_1.useCallback)(() => {
|
|
47
56
|
if (canGoToNextYear) {
|
|
48
57
|
goToNextYear(1);
|
|
@@ -62,19 +71,24 @@ exports.DatePickerYear = (0, react_1.memo)((props) => {
|
|
|
62
71
|
}
|
|
63
72
|
}, [canGoToMonth, props]);
|
|
64
73
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
65
|
-
react_1.default.createElement(calendar_1.CalendarNavigation, {
|
|
74
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { monthButtonProps: {
|
|
75
|
+
children: monthLabel,
|
|
76
|
+
isDisabled: true,
|
|
77
|
+
}, nextButtonProps: {
|
|
66
78
|
isDisabled: !canGoToNextYear,
|
|
67
79
|
onClick: canGoToNextYear ? handleGoToNextYear : undefined,
|
|
68
|
-
title: "Nadcházející rok",
|
|
80
|
+
title: (_f = (_e = props.customButtonTitles) === null || _e === void 0 ? void 0 : _e.nextYear) !== null && _f !== void 0 ? _f : "Nadcházející rok",
|
|
69
81
|
}, prevButtonProps: {
|
|
70
82
|
isDisabled: !canGoToPrevYear,
|
|
71
83
|
onClick: canGoToPrevYear ? handleGoToPrevYear : undefined,
|
|
72
|
-
title: "Předchozí rok",
|
|
73
|
-
},
|
|
84
|
+
title: (_h = (_g = props.customButtonTitles) === null || _g === void 0 ? void 0 : _g.prevYear) !== null && _h !== void 0 ? _h : "Předchozí rok",
|
|
85
|
+
}, yearButtonProps: {
|
|
74
86
|
children: yearLabel,
|
|
75
87
|
onClick: handleYearClick,
|
|
76
|
-
title: "Vybrat rok",
|
|
88
|
+
title: (_k = (_j = props.customButtonTitles) === null || _j === void 0 ? void 0 : _j.selectYear) !== null && _k !== void 0 ? _k : "Vybrat rok",
|
|
77
89
|
} }),
|
|
78
|
-
react_1.default.createElement("div", { className: "uxf-calendar__year" }, months.map((month, index) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-month", !canGoToMonth(month.date) && classes_1.CLASSES.IS_DISABLED
|
|
90
|
+
react_1.default.createElement("div", { className: "uxf-calendar__year" }, months.map((month, index) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-month", !canGoToMonth(month.date) && classes_1.CLASSES.IS_DISABLED, (0, dayjs_1.default)(month.date).month() === (0, dayjs_1.default)(selectedDate).month() &&
|
|
91
|
+
(0, dayjs_1.default)(month.date).year() === (0, dayjs_1.default)(selectedDate).year() &&
|
|
92
|
+
"uxf-calendar__cell--selected"), key: month.monthLabel + index, onClick: handleMonthClick(month.date), type: "button" }, month.monthLabel))))));
|
|
79
93
|
});
|
|
80
94
|
exports.DatePickerYear.displayName = "UxfUiDatePickerYear";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { OnDateChangeType } from "@uxf/datepicker/hooks/use-date-picker";
|
|
2
2
|
import { DatesConfig, type MonthType } from "@uxf/datepicker/utils/types";
|
|
3
3
|
import { CSSProperties, FC, ReactNode } from "react";
|
|
4
|
+
import { CustomButtonTitles } from "./types";
|
|
4
5
|
export interface DatePickerProps {
|
|
5
6
|
bottomContent?: ReactNode;
|
|
6
7
|
closePopoverHandler?: () => void;
|
|
8
|
+
customButtonTitles?: CustomButtonTitles;
|
|
7
9
|
datesConfig?: DatesConfig[];
|
|
8
10
|
maxDate?: Date;
|
|
9
11
|
minDate?: Date;
|
|
@@ -25,7 +25,7 @@ const DatePicker = (props) => {
|
|
|
25
25
|
unavailableDates: props.unavailableDates,
|
|
26
26
|
});
|
|
27
27
|
return (react_1.default.createElement(date_picker_context_1.DatePickerContext.Provider, { value: datePickerProps },
|
|
28
|
-
react_1.default.createElement(date_picker_content_1.DatePickerContent, { bottomContent: props.bottomContent, onMonthChange: props.onMonthChange, style: props.style })));
|
|
28
|
+
react_1.default.createElement(date_picker_content_1.DatePickerContent, { bottomContent: props.bottomContent, customButtonTitles: props.customButtonTitles, onMonthChange: props.onMonthChange, style: props.style })));
|
|
29
29
|
};
|
|
30
30
|
exports.DatePicker = DatePicker;
|
|
31
31
|
exports.DatePicker.displayName = "UxfUiDatePicker";
|
package/date-picker/types.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
1
|
export type ViewModeType = "month" | "year" | "decade";
|
|
2
|
+
export type CustomButtonTitles = {
|
|
3
|
+
nextMonth?: string;
|
|
4
|
+
prevMonth?: string;
|
|
5
|
+
nextDecade?: string;
|
|
6
|
+
prevDecade?: string;
|
|
7
|
+
nextYear?: string;
|
|
8
|
+
prevYear?: string;
|
|
9
|
+
selectMonth?: string;
|
|
10
|
+
selectYear?: string;
|
|
11
|
+
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { DatesConfig, type MonthType } from "@uxf/datepicker/utils/types";
|
|
2
2
|
import React, { CSSProperties, ReactNode } from "react";
|
|
3
3
|
import { InputWithPopoverProps } from "../_input-with-popover";
|
|
4
|
+
import { CustomButtonTitles } from "../date-picker/types";
|
|
4
5
|
export declare const ALLOWED_DATE_FORMAT: string[];
|
|
5
6
|
export declare const DISPLAY_DATE_FORMAT = "D. M. YYYY";
|
|
6
7
|
export declare const OUTPUT_DATE_FORMAT = "YYYY-MM-DD";
|
|
7
8
|
export interface DatePickerInputProps extends Omit<InputWithPopoverProps<string | null>, "children" | "placeholder" | "triggerElement"> {
|
|
8
9
|
allowedDateFormats?: string[];
|
|
9
10
|
bottomContent?: ReactNode;
|
|
11
|
+
customButtonTitles?: CustomButtonTitles;
|
|
10
12
|
datesConfig?: DatesConfig[];
|
|
11
13
|
displayDateFormat?: string;
|
|
12
14
|
maxDate?: string;
|
|
@@ -83,6 +83,6 @@ exports.DatePickerInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
83
83
|
const selectedDate = getSelectedDate(props.value);
|
|
84
84
|
const parsedMinDate = getBoundaryDate(props.minDate);
|
|
85
85
|
const parsedMaxDate = getBoundaryDate(props.maxDate);
|
|
86
|
-
return (react_1.default.createElement(_input_with_popover_1._InputWithPopover, { ...props, className: className, onChange: onInputChange, placeholder: (_c = props.placeholder) !== null && _c !== void 0 ? _c : (0, dayjs_1.default)().format(displayDateFormat), ref: ref, triggerElement: (_d = props.triggerElement) !== null && _d !== void 0 ? _d : react_1.default.createElement(icon_1.Icon, { name: "calendar", size: 20 }), value: value }, ({ close }) => (react_1.default.createElement(date_picker_1.DatePicker, { bottomContent: props.bottomContent, closePopoverHandler: close, datesConfig: props.datesConfig, maxDate: parsedMaxDate, minDate: parsedMinDate, onChange: onDatePickerChange, onMonthChange: props.onMonthChange, preventScroll: true, selectedDate: selectedDate, style: props.style, unavailableDates: props.unavailableDates }))));
|
|
86
|
+
return (react_1.default.createElement(_input_with_popover_1._InputWithPopover, { ...props, className: className, onChange: onInputChange, placeholder: (_c = props.placeholder) !== null && _c !== void 0 ? _c : (0, dayjs_1.default)().format(displayDateFormat), ref: ref, triggerElement: (_d = props.triggerElement) !== null && _d !== void 0 ? _d : react_1.default.createElement(icon_1.Icon, { name: "calendar", size: 20 }), value: value }, ({ close }) => (react_1.default.createElement(date_picker_1.DatePicker, { bottomContent: props.bottomContent, closePopoverHandler: close, customButtonTitles: props.customButtonTitles, datesConfig: props.datesConfig, maxDate: parsedMaxDate, minDate: parsedMinDate, onChange: onDatePickerChange, onMonthChange: props.onMonthChange, preventScroll: true, selectedDate: selectedDate, style: props.style, unavailableDates: props.unavailableDates }))));
|
|
87
87
|
});
|
|
88
88
|
exports.DatePickerInput.displayName = "UxfUiDatePickerInput";
|
|
@@ -32,7 +32,16 @@ function Default() {
|
|
|
32
32
|
const [date, setDate] = (0, react_1.useState)(null);
|
|
33
33
|
const onChange = (0, action_1.action)("onChange", setDate);
|
|
34
34
|
const testDatePickers = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
35
|
-
react_1.default.createElement(date_picker_input_1.DatePickerInput, {
|
|
35
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { customButtonTitles: {
|
|
36
|
+
selectMonth: "Select month",
|
|
37
|
+
selectYear: "Select year",
|
|
38
|
+
nextMonth: "Next month",
|
|
39
|
+
prevMonth: "Previous month",
|
|
40
|
+
nextDecade: "Next decade",
|
|
41
|
+
prevDecade: "Previous decade",
|
|
42
|
+
nextYear: "Next year",
|
|
43
|
+
prevYear: "Previous year",
|
|
44
|
+
}, id: "date-test", isClearable: true, label: "Datum \u010Dehokoliv, vlastn\u00ED titly", name: "date", onChange: onChange, placeholder: "Zadejte datum...", value: date }),
|
|
36
45
|
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test", isClearable: true, label: "Datum \u010Dehokoliv vlastn\u00ED ikona", name: "date", onChange: onChange, triggerElement: react_1.default.createElement(icon_1.Icon, { name: "camera", size: 20 }), value: date }),
|
|
37
46
|
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-disabled", isDisabled: true, label: "Datum disabled", name: "date-disabled", onChange: onChange, value: date }),
|
|
38
47
|
react_1.default.createElement(date_picker_input_1.DatePickerInput, { id: "date-test-readonly", isReadOnly: true, label: "Datum readonly", name: "date-readonly", onChange: onChange, value: date }),
|
|
@@ -45,7 +45,7 @@ const DateRangePickerContent = (props) => {
|
|
|
45
45
|
const datePickerComponents = (0, react_1.useMemo)(() => ({
|
|
46
46
|
month: (react_1.default.createElement("div", { className: "uxf-date-range-picker__months" }, activeMonths.map((activeMonth) => (react_1.default.createElement(date_range_picker_month_1.DateRangePickerMonth, { key: `${activeMonth.year}-${activeMonth.month}`, month: activeMonth.month, setViewMode: setViewMode, year: activeMonth.year }))))),
|
|
47
47
|
year: react_1.default.createElement(date_range_picker_year_1.DateRangePickerYear, { onMonthSelect: (date) => onMonthSelect(date), onYearSelect: onYearSelect }),
|
|
48
|
-
decade: react_1.default.createElement(date_range_picker_decade_1.DateRangePickerDecade, { onYearSelect: (date) => onDecadeYearSelect(date) }),
|
|
48
|
+
decade: (react_1.default.createElement(date_range_picker_decade_1.DateRangePickerDecade, { onYearSelect: (date) => onDecadeYearSelect(date), setViewMode: setViewMode })),
|
|
49
49
|
}), [activeMonths, onYearSelect, onMonthSelect, onDecadeYearSelect]);
|
|
50
50
|
return (react_1.default.createElement("div", { className: `uxf-date-range-picker ${activeMonths.length > 1 ? "uxf-date-range-picker--multi-month" : ""}`, style: props.style },
|
|
51
51
|
props.children,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import { CustomButtonTitles, ViewModeType } from "../date-picker/types";
|
|
2
3
|
interface DatePickerDecadeProps {
|
|
4
|
+
customButtonTitles?: CustomButtonTitles;
|
|
3
5
|
onYearSelect: (date: Date) => void;
|
|
6
|
+
setViewMode: Dispatch<SetStateAction<ViewModeType>>;
|
|
4
7
|
}
|
|
5
8
|
export declare const DateRangePickerDecade: React.NamedExoticComponent<DatePickerDecadeProps>;
|
|
6
9
|
export {};
|
|
@@ -31,14 +31,28 @@ const classes_1 = require("@uxf/core/constants/classes");
|
|
|
31
31
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
32
|
const date_range_picker_context_1 = require("@uxf/datepicker/contexts/date-range-picker-context");
|
|
33
33
|
const use_decade_1 = require("@uxf/datepicker/hooks/use-decade");
|
|
34
|
+
const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
35
|
+
const use_year_1 = require("@uxf/datepicker/hooks/use-year");
|
|
34
36
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
35
37
|
const react_1 = __importStar(require("react"));
|
|
36
38
|
const calendar_1 = require("../calendar");
|
|
37
39
|
exports.DateRangePickerDecade = (0, react_1.memo)((props) => {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
const { canGoToYear, goToNextYear, goToPrevYear, activeMonths } = (0, react_1.useContext)(date_range_picker_context_1.DateRangePickerContext);
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
41
|
+
const { canGoToYear, goToNextYear, goToPrevYear, activeMonths, firstDayOfWeek } = (0, react_1.useContext)(date_range_picker_context_1.DateRangePickerContext);
|
|
40
42
|
const currentYear = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.year) !== null && _b !== void 0 ? _b : new Date().getFullYear();
|
|
41
|
-
const
|
|
43
|
+
const currentMonth = (_d = (_c = activeMonths.at(0)) === null || _c === void 0 ? void 0 : _c.month) !== null && _d !== void 0 ? _d : new Date().getMonth();
|
|
44
|
+
const { years } = (0, use_decade_1.useDecade)({
|
|
45
|
+
year: currentYear,
|
|
46
|
+
});
|
|
47
|
+
const { yearLabel } = (0, use_year_1.useYear)({
|
|
48
|
+
year: currentYear,
|
|
49
|
+
yearLabelFormat: (date) => (0, dayjs_1.default)(date).format("YYYY"),
|
|
50
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
51
|
+
});
|
|
52
|
+
const { monthLabel } = (0, use_month_1.useMonth)({
|
|
53
|
+
firstDayOfWeek,
|
|
54
|
+
month: currentMonth,
|
|
55
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
42
56
|
year: currentYear,
|
|
43
57
|
});
|
|
44
58
|
const canGoToPrevDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).subtract(5, "years").toDate());
|
|
@@ -58,15 +72,21 @@ exports.DateRangePickerDecade = (0, react_1.memo)((props) => {
|
|
|
58
72
|
props.onYearSelect(date);
|
|
59
73
|
}
|
|
60
74
|
}, [canGoToYear, props]);
|
|
75
|
+
const handleSetMonthViewMode = (0, react_1.useCallback)(() => props.setViewMode("year"), [props]);
|
|
61
76
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
62
|
-
react_1.default.createElement(calendar_1.CalendarNavigation, {
|
|
77
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { monthButtonProps: {
|
|
78
|
+
children: monthLabel,
|
|
79
|
+
onClick: handleSetMonthViewMode,
|
|
80
|
+
title: (_f = (_e = props.customButtonTitles) === null || _e === void 0 ? void 0 : _e.selectMonth) !== null && _f !== void 0 ? _f : "Vybrat měsíc",
|
|
81
|
+
}, nextButtonProps: {
|
|
63
82
|
onClick: handleGoToNextDecadeClick,
|
|
64
|
-
title: "Vpřed",
|
|
83
|
+
title: (_h = (_g = props.customButtonTitles) === null || _g === void 0 ? void 0 : _g.nextDecade) !== null && _h !== void 0 ? _h : "Vpřed",
|
|
65
84
|
}, prevButtonProps: {
|
|
66
85
|
onClick: handleGoToPrevDecadeClick,
|
|
67
|
-
title: "Zpět",
|
|
68
|
-
},
|
|
69
|
-
children:
|
|
86
|
+
title: (_k = (_j = props.customButtonTitles) === null || _j === void 0 ? void 0 : _j.prevDecade) !== null && _k !== void 0 ? _k : "Zpět",
|
|
87
|
+
}, yearButtonProps: {
|
|
88
|
+
children: yearLabel,
|
|
89
|
+
isDisabled: true,
|
|
70
90
|
} }),
|
|
71
91
|
react_1.default.createElement("div", { className: "uxf-calendar__decade" }, years.map((year) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-year", !canGoToYear(year.date) && classes_1.CLASSES.IS_DISABLED, (0, dayjs_1.default)(year.date).year() === currentYear && "uxf-calendar__cell-year--current"), key: year.yearLabel, onClick: handleSelectYear(year.date), type: "button" }, year.yearLabel))))));
|
|
72
92
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { UseMonthProps } from "@uxf/datepicker/hooks/use-month";
|
|
2
2
|
import React, { Dispatch, SetStateAction } from "react";
|
|
3
|
+
import { CustomButtonTitles } from "../date-picker/types";
|
|
3
4
|
import { ViewModeType } from "./types";
|
|
4
5
|
interface DatePickerMonthProps extends UseMonthProps {
|
|
6
|
+
customButtonTitles?: CustomButtonTitles;
|
|
5
7
|
setViewMode: Dispatch<SetStateAction<ViewModeType>>;
|
|
6
8
|
}
|
|
7
9
|
export declare const DateRangePickerMonth: React.NamedExoticComponent<DatePickerMonthProps>;
|
|
@@ -29,20 +29,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.DateRangePickerMonth = void 0;
|
|
30
30
|
const date_range_picker_context_1 = require("@uxf/datepicker/contexts/date-range-picker-context");
|
|
31
31
|
const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
32
|
+
const use_year_1 = require("@uxf/datepicker/hooks/use-year");
|
|
32
33
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
33
34
|
const react_1 = __importStar(require("react"));
|
|
34
35
|
const calendar_1 = require("../calendar");
|
|
35
36
|
exports.DateRangePickerMonth = (0, react_1.memo)((props) => {
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
36
38
|
const dateRangePickerProps = (0, react_1.useContext)(date_range_picker_context_1.DateRangePickerContext);
|
|
37
39
|
const { canGoToNextMonth, canGoToPrevMonth, firstDayOfWeek, goToNextMonthsByOneMonth, goToPrevMonthsByOneMonth } = dateRangePickerProps;
|
|
38
40
|
const { monthLabel } = (0, use_month_1.useMonth)({
|
|
39
41
|
dayLabelFormat: (date) => (0, dayjs_1.default)(date).format("D"),
|
|
40
42
|
firstDayOfWeek,
|
|
41
43
|
month: props.month,
|
|
42
|
-
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM
|
|
44
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
43
45
|
weekdayLabelFormat: (date) => (0, dayjs_1.default)(date).format("dd"),
|
|
44
46
|
year: props.year,
|
|
45
47
|
});
|
|
48
|
+
const { yearLabel } = (0, use_year_1.useYear)({
|
|
49
|
+
year: props.year,
|
|
50
|
+
yearLabelFormat: (date) => (0, dayjs_1.default)(date).format("YYYY"),
|
|
51
|
+
});
|
|
46
52
|
const handleGoToPrevMonth = (0, react_1.useCallback)(() => {
|
|
47
53
|
goToPrevMonthsByOneMonth();
|
|
48
54
|
}, [goToPrevMonthsByOneMonth]);
|
|
@@ -50,19 +56,26 @@ exports.DateRangePickerMonth = (0, react_1.memo)((props) => {
|
|
|
50
56
|
const handleMonthClick = (0, react_1.useCallback)(() => {
|
|
51
57
|
props.setViewMode("year");
|
|
52
58
|
}, [props]);
|
|
59
|
+
const handleSetYearViewModeClick = (0, react_1.useCallback)(() => {
|
|
60
|
+
props.setViewMode("decade");
|
|
61
|
+
}, [props]);
|
|
53
62
|
return (react_1.default.createElement("div", { className: "uxf-date-range-picker__month" },
|
|
54
|
-
react_1.default.createElement(calendar_1.CalendarNavigation, {
|
|
63
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { monthButtonProps: {
|
|
64
|
+
children: monthLabel,
|
|
65
|
+
onClick: handleMonthClick,
|
|
66
|
+
title: (_b = (_a = props.customButtonTitles) === null || _a === void 0 ? void 0 : _a.selectMonth) !== null && _b !== void 0 ? _b : "Vybrat měsíc",
|
|
67
|
+
}, nextButtonProps: {
|
|
55
68
|
isDisabled: !canGoToNextMonth,
|
|
56
69
|
onClick: canGoToNextMonth ? handleGoToNextMonth : undefined,
|
|
57
|
-
title: "Nadcházející měsíc",
|
|
70
|
+
title: (_d = (_c = props.customButtonTitles) === null || _c === void 0 ? void 0 : _c.nextMonth) !== null && _d !== void 0 ? _d : "Nadcházející měsíc",
|
|
58
71
|
}, prevButtonProps: {
|
|
59
72
|
isDisabled: !canGoToPrevMonth,
|
|
60
73
|
onClick: canGoToPrevMonth ? handleGoToPrevMonth : undefined,
|
|
61
|
-
title: "Předchozí měsíc",
|
|
62
|
-
},
|
|
63
|
-
children:
|
|
64
|
-
onClick:
|
|
65
|
-
title: "Vybrat
|
|
74
|
+
title: (_f = (_e = props.customButtonTitles) === null || _e === void 0 ? void 0 : _e.prevMonth) !== null && _f !== void 0 ? _f : "Předchozí měsíc",
|
|
75
|
+
}, yearButtonProps: {
|
|
76
|
+
children: yearLabel,
|
|
77
|
+
onClick: handleSetYearViewModeClick,
|
|
78
|
+
title: (_h = (_g = props.customButtonTitles) === null || _g === void 0 ? void 0 : _g.selectYear) !== null && _h !== void 0 ? _h : "Vybrat rok",
|
|
66
79
|
} }),
|
|
67
80
|
react_1.default.createElement(calendar_1.Calendar, { datePickerProps: dateRangePickerProps, month: props.month, year: props.year })));
|
|
68
81
|
});
|
|
@@ -30,13 +30,14 @@ exports.DateRangePickerYear = void 0;
|
|
|
30
30
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
31
31
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
32
|
const date_range_picker_context_1 = require("@uxf/datepicker/contexts/date-range-picker-context");
|
|
33
|
+
const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
33
34
|
const use_year_1 = require("@uxf/datepicker/hooks/use-year");
|
|
34
35
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
35
36
|
const react_1 = __importStar(require("react"));
|
|
36
37
|
const calendar_1 = require("../calendar");
|
|
37
38
|
exports.DateRangePickerYear = (0, react_1.memo)((props) => {
|
|
38
|
-
var _a, _b, _c, _d;
|
|
39
|
-
const { canGoToNextYear, canGoToPrevYear, goToNextYear, goToPrevYear, canGoToMonth, activeMonths } = (0, react_1.useContext)(date_range_picker_context_1.DateRangePickerContext);
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
40
|
+
const { canGoToNextYear, canGoToPrevYear, goToNextYear, goToPrevYear, canGoToMonth, activeMonths, firstDayOfWeek } = (0, react_1.useContext)(date_range_picker_context_1.DateRangePickerContext);
|
|
40
41
|
const currentMonth = (_b = (_a = activeMonths.at(0)) === null || _a === void 0 ? void 0 : _a.month) !== null && _b !== void 0 ? _b : new Date().getMonth();
|
|
41
42
|
const currentYear = (_d = (_c = activeMonths.at(0)) === null || _c === void 0 ? void 0 : _c.year) !== null && _d !== void 0 ? _d : new Date().getFullYear();
|
|
42
43
|
const { months, yearLabel } = (0, use_year_1.useYear)({
|
|
@@ -44,6 +45,12 @@ exports.DateRangePickerYear = (0, react_1.memo)((props) => {
|
|
|
44
45
|
yearLabelFormat: (date) => (0, dayjs_1.default)(date).format("YYYY"),
|
|
45
46
|
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
46
47
|
});
|
|
48
|
+
const { monthLabel } = (0, use_month_1.useMonth)({
|
|
49
|
+
firstDayOfWeek,
|
|
50
|
+
month: currentMonth,
|
|
51
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM"),
|
|
52
|
+
year: currentYear,
|
|
53
|
+
});
|
|
47
54
|
const handleGoToNextYear = (0, react_1.useCallback)(() => {
|
|
48
55
|
if (canGoToNextYear) {
|
|
49
56
|
goToNextYear(1);
|
|
@@ -63,18 +70,21 @@ exports.DateRangePickerYear = (0, react_1.memo)((props) => {
|
|
|
63
70
|
}
|
|
64
71
|
}, [canGoToMonth, props]);
|
|
65
72
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
66
|
-
react_1.default.createElement(calendar_1.CalendarNavigation, {
|
|
73
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { monthButtonProps: {
|
|
74
|
+
children: monthLabel,
|
|
75
|
+
isDisabled: true,
|
|
76
|
+
}, nextButtonProps: {
|
|
67
77
|
isDisabled: !canGoToNextYear,
|
|
68
78
|
onClick: canGoToNextYear ? handleGoToNextYear : undefined,
|
|
69
|
-
title: "Nadcházející rok",
|
|
79
|
+
title: (_f = (_e = props.customButtonTitles) === null || _e === void 0 ? void 0 : _e.nextYear) !== null && _f !== void 0 ? _f : "Nadcházející rok",
|
|
70
80
|
}, prevButtonProps: {
|
|
71
81
|
isDisabled: !canGoToPrevYear,
|
|
72
82
|
onClick: canGoToPrevYear ? handleGoToPrevYear : undefined,
|
|
73
|
-
title: "Předchozí rok",
|
|
74
|
-
},
|
|
83
|
+
title: (_h = (_g = props.customButtonTitles) === null || _g === void 0 ? void 0 : _g.prevYear) !== null && _h !== void 0 ? _h : "Předchozí rok",
|
|
84
|
+
}, yearButtonProps: {
|
|
75
85
|
children: yearLabel,
|
|
76
86
|
onClick: handleYearClick,
|
|
77
|
-
title: "Vybrat rok",
|
|
87
|
+
title: (_k = (_j = props.customButtonTitles) === null || _j === void 0 ? void 0 : _j.selectYear) !== null && _k !== void 0 ? _k : "Vybrat rok",
|
|
78
88
|
} }),
|
|
79
89
|
react_1.default.createElement("div", { className: "uxf-calendar__year" }, months.map((month, index) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-month", !canGoToMonth(month.date) && classes_1.CLASSES.IS_DISABLED, (0, dayjs_1.default)(month.date).month() === currentMonth && "uxf-calendar__cell-month--current"), key: month.monthLabel + index, onClick: handleMonthClick(month.date), type: "button" }, month.monthLabel))))));
|
|
80
90
|
});
|
|
@@ -33,7 +33,7 @@ function Default() {
|
|
|
33
33
|
const onChange = (0, action_1.action)("onChange", setRange);
|
|
34
34
|
const testDatePickers = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
35
35
|
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { id: "date-test", isClearable: true, label: "Datum \u010Dehokoliv", name: "date", onChange: onChange, value: range }),
|
|
36
|
-
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { id: "date-test", label: "Datum \u010Dehokoliv", name: "date", onChange: onChange, value: range }),
|
|
36
|
+
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { id: "date-test", label: "Datum \u010Dehokoliv - 2 m\u011Bs\u00EDce", name: "date", numberOfMonths: 2, onChange: onChange, value: range }),
|
|
37
37
|
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { id: "date-test-disabled", isDisabled: true, label: "Datum disabled", name: "date-disabled", onChange: onChange, value: range }),
|
|
38
38
|
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { id: "date-test-readonly", isReadOnly: true, label: "Datum readonly", name: "date-readonly", onChange: onChange, value: range }),
|
|
39
39
|
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { id: "date-test-invalid", isClearable: true, isInvalid: true, label: "Datum invalid", name: "date-invalid", onChange: onChange, value: range }),
|
package/icons-config.js
CHANGED
|
@@ -5,6 +5,11 @@ module.exports = {
|
|
|
5
5
|
height: 512,
|
|
6
6
|
data: `<path fill="currentColor" d="M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"/>`,
|
|
7
7
|
},
|
|
8
|
+
"angle-right": {
|
|
9
|
+
width: 320,
|
|
10
|
+
height: 512,
|
|
11
|
+
data: `<path fill="currentColor" d="M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z"/>`,
|
|
12
|
+
},
|
|
8
13
|
"arrow-left": {
|
|
9
14
|
width: 448,
|
|
10
15
|
height: 512,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/ui",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.61.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@headlessui/react": "1.7.19",
|
|
26
26
|
"@uxf/core": "11.60.1",
|
|
27
27
|
"@uxf/core-react": "11.60.1",
|
|
28
|
-
"@uxf/datepicker": "11.
|
|
28
|
+
"@uxf/datepicker": "11.61.0",
|
|
29
29
|
"@uxf/styles": "11.60.1",
|
|
30
30
|
"color2k": "2.0.3",
|
|
31
31
|
"dayjs": "1.11.13",
|