@uxf/ui 10.0.0-beta.40 → 10.0.0-beta.46
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/_select-base/_select-base.d.ts +1 -1
- package/_select-base/_select-base.js +2 -2
- package/calendar/calendar-day-cell.d.ts +3 -0
- package/calendar/calendar-day-cell.js +14 -15
- package/{date-picker/date-picker-navigation.d.ts → calendar/calendar-navigation.d.ts} +2 -3
- package/{date-picker/date-picker-navigation.js → calendar/calendar-navigation.js} +6 -6
- package/calendar/calendar-provider.js +1 -1
- package/calendar/calendar.d.ts +5 -0
- package/calendar/calendar.js +5 -8
- package/calendar/index.d.ts +4 -1
- package/calendar/index.js +5 -15
- package/combobox/combobox.d.ts +1 -1
- package/combobox/combobox.stories.js +5 -1
- package/css/calendar.css +60 -3
- package/css/date-picker.css +10 -2
- package/css/date-range-picker.css +21 -0
- package/date-picker/date-picker-decade.js +6 -6
- package/date-picker/date-picker-month.js +6 -6
- package/date-picker/date-picker-year.js +2 -2
- package/date-range-picker/date-range-picker-content.d.ts +2 -0
- package/date-range-picker/date-range-picker-content.js +55 -0
- package/date-range-picker/date-range-picker-decade.d.ts +6 -0
- package/date-range-picker/date-range-picker-decade.js +72 -0
- package/date-range-picker/date-range-picker-month.d.ts +8 -0
- package/date-range-picker/date-range-picker-month.js +69 -0
- package/date-range-picker/date-range-picker-year.d.ts +7 -0
- package/date-range-picker/date-range-picker-year.js +80 -0
- package/date-range-picker/date-range-picker.d.ts +9 -0
- package/date-range-picker/date-range-picker.js +50 -0
- package/date-range-picker/date-range-picker.spec.d.ts +1 -0
- package/date-range-picker/date-range-picker.spec.js +9 -0
- package/date-range-picker/date-range-picker.stories.d.ts +7 -0
- package/date-range-picker/date-range-picker.stories.js +43 -0
- package/date-range-picker/index.d.ts +3 -0
- package/date-range-picker/index.js +5 -0
- package/date-range-picker/types.d.ts +5 -0
- package/date-range-picker/types.js +2 -0
- package/date-range-picker-input/date-range-picker-input.d.ts +15 -0
- package/date-range-picker-input/date-range-picker-input.js +62 -0
- package/date-range-picker-input/date-range-picker-input.spec.d.ts +1 -0
- package/date-range-picker-input/date-range-picker-input.spec.js +9 -0
- package/date-range-picker-input/date-range-picker-input.stories.d.ts +10 -0
- package/date-range-picker-input/date-range-picker-input.stories.js +53 -0
- package/date-range-picker-input/index.d.ts +2 -0
- package/date-range-picker-input/index.js +5 -0
- package/datetime-picker/datetime-picker.js +1 -1
- package/multi-combobox/multi-combobox.stories.js +4 -1
- package/multi-select/_multi-select-base.js +2 -2
- package/multi-select/multi-select.stories.js +4 -1
- package/package.json +2 -2
- package/select/select.d.ts +1 -1
- package/select/select.stories.js +7 -1
|
@@ -28,7 +28,7 @@ export interface SelectBaseProps<Value, Option> extends FormControlProps<Value |
|
|
|
28
28
|
label: ReactNode;
|
|
29
29
|
options?: Option[];
|
|
30
30
|
placeholder?: string;
|
|
31
|
-
renderOption?: (option: Option) => ReactNode;
|
|
31
|
+
renderOption?: (option: Option, isSelected: boolean) => ReactNode;
|
|
32
32
|
size?: keyof InputGroupSizes;
|
|
33
33
|
variant?: keyof InputGroupVariants;
|
|
34
34
|
leftAddon?: ReactNode;
|
|
@@ -54,9 +54,9 @@ const Options = (props) => {
|
|
|
54
54
|
var _a, _b;
|
|
55
55
|
const HUIComponent = props.HUIComponent;
|
|
56
56
|
return (react_2.default.createElement(HUIComponent.Options, { className: (0, cx_1.cx)("uxf-dropdown", `uxf-dropdown--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, `uxf-dropdown--variant-${(_b = props.variant) !== null && _b !== void 0 ? _b : "default"}`, props.placement === "bottom" && "uxf-dropdown--bottom", props.placement === "top" && "uxf-dropdown--top"), ref: props.forwardRef, static: true, style: props.style }, props.options && props.options.length > 0 ? (props.options.map((option) => {
|
|
57
|
-
var _a
|
|
57
|
+
var _a;
|
|
58
58
|
const optionKey = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option);
|
|
59
|
-
return (react_2.default.createElement(HUIComponent.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), key: optionKey !== null && optionKey !== void 0 ? optionKey : option.id, value: option }, (
|
|
59
|
+
return (react_2.default.createElement(HUIComponent.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), key: optionKey !== null && optionKey !== void 0 ? optionKey : option.id, value: option }, (optionState) => { var _a, _b; return (_b = (_a = props.renderOption) === null || _a === void 0 ? void 0 : _a.call(props, option, optionState.selected)) !== null && _b !== void 0 ? _b : option.label; }));
|
|
60
60
|
})) : (react_2.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, props.emptyMessage))));
|
|
61
61
|
};
|
|
62
62
|
Options.displayName = "UxfUiSelectBaseOptions";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CalendarDay } from "@uxf/datepicker/utils/get-days";
|
|
3
|
+
import { UseDatePickerReturnType } from "@uxf/datepicker/hooks/use-date-picker";
|
|
4
|
+
import { UseDateRangePickerReturnType } from "@uxf/datepicker/hooks/use-date-range-picker";
|
|
3
5
|
interface CalendarDayProps {
|
|
4
6
|
day: CalendarDay;
|
|
7
|
+
datePickerProps: UseDatePickerReturnType | UseDateRangePickerReturnType;
|
|
5
8
|
}
|
|
6
9
|
export declare const CalendarDayCell: React.NamedExoticComponent<CalendarDayProps>;
|
|
7
10
|
export {};
|
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.CalendarDayCell = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const use_day_1 = require("@uxf/datepicker/hooks/use-day");
|
|
29
|
-
const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-context");
|
|
30
29
|
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
31
30
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
31
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
@@ -34,30 +33,30 @@ const useOnMount_1 = require("@uxf/core/hooks/useOnMount");
|
|
|
34
33
|
exports.CalendarDayCell = (0, react_1.memo)((props) => {
|
|
35
34
|
const dayCellRef = (0, react_1.useRef)(null);
|
|
36
35
|
const innerRef = (0, react_1.useRef)(null);
|
|
37
|
-
const {
|
|
38
|
-
const { disabledDate, isSelected, onClick, onKeyDown, onMouseEnter, tabIndex, isToday } = (0, use_day_1.useDay)({
|
|
36
|
+
const { disabledDate, isHovered, isSelected, isInsideRange, isToday, isWithinHoverRange, onClick, onKeyDown, onMouseEnter, tabIndex, } = (0, use_day_1.useDay)({
|
|
39
37
|
date: props.day.date,
|
|
40
|
-
focusedDate,
|
|
41
|
-
isDateBlocked,
|
|
42
|
-
isDateFocused,
|
|
43
|
-
isDateHovered,
|
|
44
|
-
isDateSelected,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
focusedDate: props.datePickerProps.focusedDate,
|
|
39
|
+
isDateBlocked: props.datePickerProps.isDateBlocked,
|
|
40
|
+
isDateFocused: props.datePickerProps.isDateFocused,
|
|
41
|
+
isDateHovered: props.datePickerProps.isDateHovered,
|
|
42
|
+
isDateSelected: props.datePickerProps.isDateSelected,
|
|
43
|
+
isDateInsideRange: "isDateInsideRange" in props.datePickerProps ? props.datePickerProps.isDateInsideRange : () => false,
|
|
44
|
+
onDateFocus: props.datePickerProps.onDateFocus,
|
|
45
|
+
onDateHover: props.datePickerProps.onDateHover,
|
|
46
|
+
onDateSelect: props.datePickerProps.onDateSelect,
|
|
48
47
|
dayRef: dayCellRef,
|
|
49
|
-
preventScroll,
|
|
48
|
+
preventScroll: props.datePickerProps.preventScroll,
|
|
50
49
|
});
|
|
51
50
|
(0, useOnMount_1.useOnMount)(() => {
|
|
52
51
|
const node = innerRef.current;
|
|
53
52
|
if (node && (isToday || isSelected)) {
|
|
54
|
-
node.focus({ preventScroll });
|
|
53
|
+
node.focus({ preventScroll: props.datePickerProps.preventScroll });
|
|
55
54
|
}
|
|
56
55
|
});
|
|
57
56
|
if (!props.day.dayLabel) {
|
|
58
57
|
return react_1.default.createElement("div", null);
|
|
59
58
|
}
|
|
60
|
-
return (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-day", disabledDate && classes_1.CLASSES.IS_DISABLED, isToday && "uxf-calendar__cell
|
|
61
|
-
react_1.default.createElement("span", { className: "uxf-
|
|
59
|
+
return (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-day", disabledDate && classes_1.CLASSES.IS_DISABLED, isToday && "uxf-calendar__cell--today", isSelected && "uxf-calendar__cell--selected", isInsideRange && "uxf-calendar__cell--inside-range", isWithinHoverRange && "uxf-calendar__cell--is-within-hover-range", isHovered && "uxf-calendar__cell--is-hovered", !props.day.currentMonth && "uxf-calendar__cell--not-current-month"), ref: disabledDate ? undefined : (0, composeRefs_1.composeRefs)(dayCellRef, innerRef), onClick: onClick, onKeyDown: onKeyDown, onMouseEnter: onMouseEnter, tabIndex: tabIndex, type: "button" },
|
|
60
|
+
react_1.default.createElement("span", { className: "uxf-calendar__cell__inner" }, props.day.dayLabel)));
|
|
62
61
|
});
|
|
63
62
|
exports.CalendarDayCell.displayName = "UxfUiCalendarDayCell";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { ButtonProps } from "../button";
|
|
3
|
-
interface
|
|
3
|
+
export interface CalendarNavigationProps {
|
|
4
4
|
prevButtonProps: ButtonProps;
|
|
5
5
|
selectButtonProps: ButtonProps;
|
|
6
6
|
nextButtonProps: ButtonProps;
|
|
7
7
|
}
|
|
8
|
-
export declare const
|
|
9
|
-
export {};
|
|
8
|
+
export declare const CalendarNavigation: FC<CalendarNavigationProps>;
|
|
@@ -3,17 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.CalendarNavigation = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const button_1 = require("../button");
|
|
9
9
|
const icon_1 = require("../icon");
|
|
10
|
-
const
|
|
11
|
-
return (react_1.default.createElement("div", { className: "uxf-
|
|
10
|
+
const CalendarNavigation = (props) => {
|
|
11
|
+
return (react_1.default.createElement("div", { className: "uxf-calendar-navigation" },
|
|
12
12
|
react_1.default.createElement(button_1.Button, { isIconButton: true, size: "sm", variant: "white", ...props.prevButtonProps },
|
|
13
13
|
react_1.default.createElement(icon_1.Icon, { name: "arrow-left", size: 16 })),
|
|
14
|
-
props.selectButtonProps.onClick ? (react_1.default.createElement(button_1.Button, { variant: "text", size: "sm", color: "default", ...props.selectButtonProps })) : (react_1.default.createElement("p", { className: "uxf-
|
|
14
|
+
props.selectButtonProps.onClick ? (react_1.default.createElement(button_1.Button, { variant: "text", size: "sm", color: "default", ...props.selectButtonProps })) : (react_1.default.createElement("p", { className: "uxf-calendar-navigation__title" }, props.selectButtonProps.children)),
|
|
15
15
|
react_1.default.createElement(button_1.Button, { isIconButton: true, size: "sm", variant: "white", ...props.nextButtonProps },
|
|
16
16
|
react_1.default.createElement(icon_1.Icon, { name: "arrow-right", size: 16 }))));
|
|
17
17
|
};
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
18
|
+
exports.CalendarNavigation = CalendarNavigation;
|
|
19
|
+
exports.CalendarNavigation.displayName = "UxfUiCalendarNavigation";
|
|
@@ -20,7 +20,7 @@ const CalendarProvider = (props) => {
|
|
|
20
20
|
selectedDate: (_a = props.selectedDate) !== null && _a !== void 0 ? _a : null,
|
|
21
21
|
});
|
|
22
22
|
return (react_1.default.createElement(date_picker_context_1.DatePickerContext.Provider, { value: calendarProps },
|
|
23
|
-
react_1.default.createElement(calendar_1.Calendar,
|
|
23
|
+
react_1.default.createElement(calendar_1.Calendar, { datePickerProps: calendarProps })));
|
|
24
24
|
};
|
|
25
25
|
exports.CalendarProvider = CalendarProvider;
|
|
26
26
|
exports.CalendarProvider.displayName = "UxfUiCalendarProvider";
|
package/calendar/calendar.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { UseDatePickerReturnType } from "@uxf/datepicker/hooks/use-date-picker";
|
|
3
|
+
import { UseDateRangePickerReturnType } from "@uxf/datepicker/hooks/use-date-range-picker";
|
|
2
4
|
export interface CalendarProps {
|
|
5
|
+
datePickerProps: UseDatePickerReturnType | UseDateRangePickerReturnType;
|
|
3
6
|
className?: string;
|
|
7
|
+
month?: number;
|
|
4
8
|
onChange?: (data: Date | null) => void;
|
|
5
9
|
selectedDate?: Date | null;
|
|
10
|
+
year?: number;
|
|
6
11
|
}
|
|
7
12
|
export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<HTMLDivElement>>;
|
package/calendar/calendar.js
CHANGED
|
@@ -31,23 +31,20 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
32
|
const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
33
33
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
34
|
-
const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-context");
|
|
35
34
|
const calendar_day_cell_1 = require("./calendar-day-cell");
|
|
36
35
|
exports.Calendar = (0, react_1.forwardRef)((props, ref) => {
|
|
36
|
+
var _a, _b;
|
|
37
37
|
const calendarClassName = (0, cx_1.cx)("uxf-calendar", props.className);
|
|
38
|
-
const { activeMonths, firstDayOfWeek } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
39
|
-
const currentMonth = activeMonths[0].month;
|
|
40
|
-
const currentYear = activeMonths[0].year;
|
|
41
38
|
const { days, weekdayLabels } = (0, use_month_1.useMonth)({
|
|
42
39
|
dayLabelFormat: (date) => (0, dayjs_1.default)(date).format("D"),
|
|
43
|
-
firstDayOfWeek,
|
|
44
|
-
month:
|
|
40
|
+
firstDayOfWeek: props.datePickerProps.firstDayOfWeek,
|
|
41
|
+
month: (_a = props.month) !== null && _a !== void 0 ? _a : props.datePickerProps.activeMonths[0].month,
|
|
45
42
|
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM YYYY"),
|
|
46
43
|
weekdayLabelFormat: (date) => (0, dayjs_1.default)(date).format("dd"),
|
|
47
|
-
year:
|
|
44
|
+
year: (_b = props.year) !== null && _b !== void 0 ? _b : props.datePickerProps.activeMonths[0].year,
|
|
48
45
|
});
|
|
49
46
|
return (react_1.default.createElement("div", { ref: ref, className: calendarClassName },
|
|
50
47
|
react_1.default.createElement("div", { className: "uxf-calendar__weekdays" }, weekdayLabels.map((weekdayLabel, index) => (react_1.default.createElement("span", { key: `${index}`, className: "uxf-calendar__weekday" }, weekdayLabel)))),
|
|
51
|
-
react_1.default.createElement("div", { className: "uxf-calendar__days" }, days.map((day, index) => (react_1.default.createElement(calendar_day_cell_1.CalendarDayCell, { day: day, key: day.dayLabel + index }))))));
|
|
48
|
+
react_1.default.createElement("div", { className: "uxf-calendar__days" }, days.map((day, index) => (react_1.default.createElement(calendar_day_cell_1.CalendarDayCell, { datePickerProps: props.datePickerProps, day: day, key: day.dayLabel + index }))))));
|
|
52
49
|
});
|
|
53
50
|
exports.Calendar.displayName = "UxfUiCalendar";
|
package/calendar/index.d.ts
CHANGED
package/calendar/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
3
|
+
exports.CalendarNavigation = exports.Calendar = void 0;
|
|
4
|
+
var calendar_1 = require("./calendar");
|
|
5
|
+
Object.defineProperty(exports, "Calendar", { enumerable: true, get: function () { return calendar_1.Calendar; } });
|
|
6
|
+
var calendar_navigation_1 = require("./calendar-navigation");
|
|
7
|
+
Object.defineProperty(exports, "CalendarNavigation", { enumerable: true, get: function () { return calendar_navigation_1.CalendarNavigation; } });
|
package/combobox/combobox.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface ComboboxProps<ValueId = SelectBaseValueId, Option = ComboboxOpt
|
|
|
14
14
|
loadOptions?: (query: string) => Promise<Option[]>;
|
|
15
15
|
noQueryMessage?: string;
|
|
16
16
|
notFoundMessage?: string;
|
|
17
|
-
renderOption?: (option: Option) => ReactNode;
|
|
17
|
+
renderOption?: (option: Option, isSelected: boolean) => ReactNode;
|
|
18
18
|
}
|
|
19
19
|
export declare const Combobox: {
|
|
20
20
|
<ValueId = SelectBaseValueId, Option = ComboboxOption<ValueId>, Value = Option>(props: ComboboxProps<ValueId, Option, Value>): React.JSX.Element;
|
|
@@ -52,7 +52,11 @@ function Default() {
|
|
|
52
52
|
react_1.default.createElement(index_1.Combobox, { id: "combobox-1", label: "Combobox", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
|
|
53
53
|
react_1.default.createElement(index_1.Combobox, { helperText: "Start typing to see options...", id: "combobox-1", label: "Combobox with helper text", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
|
|
54
54
|
react_1.default.createElement(index_1.Combobox, { helperText: "Error message", id: "combobox-1", isInvalid: true, isRequired: true, label: "Combobox invalid", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", value: value }),
|
|
55
|
-
react_1.default.createElement(index_1.Combobox, { dropdownPlacement: "top", id: "combobox-1", label: "Combobox with dropdown top", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", isClearable: true, value: value })
|
|
55
|
+
react_1.default.createElement(index_1.Combobox, { dropdownPlacement: "top", id: "combobox-1", label: "Combobox with dropdown top", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", isClearable: true, value: value }),
|
|
56
|
+
react_1.default.createElement(index_1.Combobox, { id: "combobox-render", label: "RenderOption", name: "combobox", onChange: onChange, options: options, placeholder: "Vyberte...", isClearable: true, value: value, renderOption: (option, isSelected) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
57
|
+
"Option: ",
|
|
58
|
+
option.label,
|
|
59
|
+
isSelected && " (selected)")) })));
|
|
56
60
|
return (react_1.default.createElement("div", { className: "flex flex-col lg:flex-row" },
|
|
57
61
|
react_1.default.createElement("div", { className: "light space-y-2 p-20 lg:w-1/2" }, storyComboboxes),
|
|
58
62
|
react_1.default.createElement("div", { className: "dark space-y-2 bg-gray-900 p-20 lg:w-1/2" }, storyComboboxes)));
|
package/css/calendar.css
CHANGED
|
@@ -82,8 +82,28 @@
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
&--inside-range {
|
|
86
|
+
background-color: theme("backgroundColor.primary.100");
|
|
87
|
+
color: theme("colors.lightMedium");
|
|
88
|
+
|
|
89
|
+
:root .dark & {
|
|
90
|
+
background-color: theme("backgroundColor.primary.900");
|
|
91
|
+
color: theme("colors.darkMedium");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&--is-hovered {
|
|
96
|
+
background-color: theme("backgroundColor.primary.100");
|
|
97
|
+
color: theme("colors.lightMedium");
|
|
98
|
+
|
|
99
|
+
:root .dark & {
|
|
100
|
+
background-color: theme("backgroundColor.primary.900");
|
|
101
|
+
color: theme("colors.darkMedium");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
85
105
|
&--today {
|
|
86
|
-
.uxf-
|
|
106
|
+
.uxf-calendar__cell__inner {
|
|
87
107
|
align-items: center;
|
|
88
108
|
border-radius: 999px;
|
|
89
109
|
display: inline-flex;
|
|
@@ -105,13 +125,28 @@
|
|
|
105
125
|
}
|
|
106
126
|
}
|
|
107
127
|
|
|
108
|
-
&.uxf-calendar__cell
|
|
109
|
-
.uxf-
|
|
128
|
+
&.uxf-calendar__cell--selected {
|
|
129
|
+
.uxf-calendar__cell__inner {
|
|
110
130
|
background-color: theme("backgroundColor.transparent");
|
|
111
131
|
color: theme("colors.white");
|
|
112
132
|
border: 2px solid theme("colors.darkMedium");
|
|
113
133
|
}
|
|
114
134
|
}
|
|
135
|
+
|
|
136
|
+
&.uxf-calendar__cell--inside-range {
|
|
137
|
+
.uxf-calendar__cell__inner {
|
|
138
|
+
background-color: theme("backgroundColor.lightHigh");
|
|
139
|
+
border: 2px solid theme("colors.lightHigh");
|
|
140
|
+
border-radius: 999px;
|
|
141
|
+
color: theme("colors.white");
|
|
142
|
+
|
|
143
|
+
:root .dark & {
|
|
144
|
+
background-color: theme("backgroundColor.transparent");
|
|
145
|
+
border: 2px solid theme("colors.darkMedium");
|
|
146
|
+
color: theme("colors.white");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
115
150
|
}
|
|
116
151
|
|
|
117
152
|
&--not-current-month {
|
|
@@ -221,3 +256,25 @@
|
|
|
221
256
|
grid-template-columns: repeat(6, minmax(0, 1fr));
|
|
222
257
|
}
|
|
223
258
|
}
|
|
259
|
+
|
|
260
|
+
.uxf-calendar-navigation {
|
|
261
|
+
align-items: center;
|
|
262
|
+
display: flex;
|
|
263
|
+
justify-content: space-between;
|
|
264
|
+
margin-bottom: theme("spacing.4");
|
|
265
|
+
|
|
266
|
+
&__title {
|
|
267
|
+
font-size: 14px;
|
|
268
|
+
font-weight: theme("fontWeight.medium");
|
|
269
|
+
text-align: center;
|
|
270
|
+
|
|
271
|
+
:root .light & {
|
|
272
|
+
@apply text-lightMedium is-hoverable:text-lightHigh;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
:root .dark & {
|
|
276
|
+
@apply text-darkMedium is-hoverable:text-darkHigh;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
}
|
package/css/date-picker.css
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
.uxf-date-picker {
|
|
2
|
-
|
|
2
|
+
margin: 0 auto;
|
|
3
|
+
width: 296px;
|
|
4
|
+
|
|
5
|
+
@screen sm {
|
|
6
|
+
width: 340px;
|
|
7
|
+
}
|
|
3
8
|
|
|
4
9
|
&__navigation {
|
|
5
|
-
|
|
10
|
+
align-items: center;
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
margin-bottom: theme("spacing.4");
|
|
6
14
|
|
|
7
15
|
&-title {
|
|
8
16
|
font-size: 14px;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.uxf-date-range-picker {
|
|
2
|
+
margin: 0 auto;
|
|
3
|
+
|
|
4
|
+
&__months {
|
|
5
|
+
display: flex;
|
|
6
|
+
gap: theme("spacing.6");
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
|
|
9
|
+
@screen sm {
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&__month {
|
|
15
|
+
width: 296px;
|
|
16
|
+
|
|
17
|
+
@screen sm {
|
|
18
|
+
width: 340px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -33,7 +33,7 @@ const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-cont
|
|
|
33
33
|
const use_decade_1 = require("@uxf/datepicker/hooks/use-decade");
|
|
34
34
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
35
35
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
36
|
-
const
|
|
36
|
+
const calendar_1 = require("../calendar");
|
|
37
37
|
exports.DatePickerDecade = (0, react_1.memo)((props) => {
|
|
38
38
|
const { onYearSelect } = props;
|
|
39
39
|
const { canGoToYear, goToNextYear, goToPrevYear, activeMonths } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
@@ -41,8 +41,8 @@ exports.DatePickerDecade = (0, react_1.memo)((props) => {
|
|
|
41
41
|
const { decadeLabel, years } = (0, use_decade_1.useDecade)({
|
|
42
42
|
year: currentYear,
|
|
43
43
|
});
|
|
44
|
-
const canGoToPrevDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).subtract(
|
|
45
|
-
const canGoToNextDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).add(
|
|
44
|
+
const canGoToPrevDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).subtract(5, "years").toDate());
|
|
45
|
+
const canGoToNextDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).add(5, "years").toDate());
|
|
46
46
|
const handleGoToPrevDecadeClick = (0, react_1.useCallback)(() => {
|
|
47
47
|
if (canGoToPrevDecade) {
|
|
48
48
|
goToPrevYear(9);
|
|
@@ -59,15 +59,15 @@ exports.DatePickerDecade = (0, react_1.memo)((props) => {
|
|
|
59
59
|
}
|
|
60
60
|
}, [canGoToYear, onYearSelect]);
|
|
61
61
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
62
|
-
react_1.default.createElement(
|
|
62
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { prevButtonProps: {
|
|
63
63
|
onClick: handleGoToPrevDecadeClick,
|
|
64
64
|
title: "Zpět",
|
|
65
65
|
}, nextButtonProps: {
|
|
66
66
|
onClick: handleGoToNextDecadeClick,
|
|
67
|
-
title: "
|
|
67
|
+
title: "Vpřed",
|
|
68
68
|
}, selectButtonProps: {
|
|
69
69
|
children: decadeLabel,
|
|
70
70
|
} }),
|
|
71
|
-
react_1.default.createElement("div", { className: "uxf-calendar__decade" }, years.map((year
|
|
71
|
+
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))))));
|
|
72
72
|
});
|
|
73
73
|
exports.DatePickerDecade.displayName = "UxfUiDatePickerDecade";
|
|
@@ -32,10 +32,10 @@ const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
|
32
32
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
33
33
|
const react_1 = __importStar(require("react"));
|
|
34
34
|
const calendar_1 = require("../calendar");
|
|
35
|
-
const date_picker_navigation_1 = require("./date-picker-navigation");
|
|
36
35
|
exports.DatePickerMonth = (0, react_1.memo)((props) => {
|
|
37
36
|
const { setViewMode } = props;
|
|
38
|
-
const
|
|
37
|
+
const datePickerProps = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
38
|
+
const { activeMonths, canGoToNextMonth, canGoToPrevMonth, firstDayOfWeek, goToNextMonthsByOneMonth, goToPrevMonthsByOneMonth, } = datePickerProps;
|
|
39
39
|
const currentMonth = activeMonths[0].month;
|
|
40
40
|
const currentYear = activeMonths[0].year;
|
|
41
41
|
const { monthLabel } = (0, use_month_1.useMonth)({
|
|
@@ -54,19 +54,19 @@ exports.DatePickerMonth = (0, react_1.memo)((props) => {
|
|
|
54
54
|
setViewMode("year");
|
|
55
55
|
}, [setViewMode]);
|
|
56
56
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
57
|
-
react_1.default.createElement(
|
|
57
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { prevButtonProps: {
|
|
58
58
|
disabled: !canGoToPrevMonth,
|
|
59
59
|
onClick: canGoToPrevMonth ? handleGoToPrevMonth : undefined,
|
|
60
|
-
title: "
|
|
60
|
+
title: "Předchozí měsíc",
|
|
61
61
|
}, nextButtonProps: {
|
|
62
62
|
disabled: !canGoToNextMonth,
|
|
63
63
|
onClick: canGoToNextMonth ? handleGoToNextMonth : undefined,
|
|
64
|
-
title: "
|
|
64
|
+
title: "Nadcházející měsíc",
|
|
65
65
|
}, selectButtonProps: {
|
|
66
66
|
children: monthLabel,
|
|
67
67
|
onClick: handleMonthClick,
|
|
68
68
|
title: "Vybrat měsíc",
|
|
69
69
|
} }),
|
|
70
|
-
react_1.default.createElement(calendar_1.Calendar,
|
|
70
|
+
react_1.default.createElement(calendar_1.Calendar, { datePickerProps: datePickerProps })));
|
|
71
71
|
});
|
|
72
72
|
exports.DatePickerMonth.displayName = "UxfUiDatePickerMonth";
|
|
@@ -33,7 +33,7 @@ const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-cont
|
|
|
33
33
|
const use_year_1 = require("@uxf/datepicker/hooks/use-year");
|
|
34
34
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
35
35
|
const react_1 = __importStar(require("react"));
|
|
36
|
-
const
|
|
36
|
+
const calendar_1 = require("../calendar");
|
|
37
37
|
exports.DatePickerYear = (0, react_1.memo)((props) => {
|
|
38
38
|
const { canGoToNextYear, canGoToPrevYear, goToNextYear, goToPrevYear, canGoToMonth, activeMonths } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
39
39
|
const currentYear = activeMonths[0].year;
|
|
@@ -61,7 +61,7 @@ exports.DatePickerYear = (0, react_1.memo)((props) => {
|
|
|
61
61
|
}
|
|
62
62
|
}, [canGoToMonth, props]);
|
|
63
63
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
64
|
-
react_1.default.createElement(
|
|
64
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { prevButtonProps: {
|
|
65
65
|
disabled: !canGoToPrevYear,
|
|
66
66
|
onClick: canGoToPrevYear ? handleGoToPrevYear : undefined,
|
|
67
67
|
title: "Předchozí rok",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DateRangePickerContent = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const date_range_picker_year_1 = require("./date-range-picker-year");
|
|
29
|
+
const date_range_picker_decade_1 = require("./date-range-picker-decade");
|
|
30
|
+
const date_range_picker_month_1 = require("./date-range-picker-month");
|
|
31
|
+
const date_range_picker_context_1 = require("@uxf/datepicker/contexts/date-range-picker-context");
|
|
32
|
+
const DateRangePickerContent = (props) => {
|
|
33
|
+
// eslint-disable-next-line react/destructuring-assignment
|
|
34
|
+
const { goToDate, activeMonths } = (0, react_1.useContext)(date_range_picker_context_1.DateRangePickerContext);
|
|
35
|
+
const [viewMode, setViewMode] = (0, react_1.useState)("month");
|
|
36
|
+
const onYearSelect = (0, react_1.useCallback)(() => setViewMode("decade"), [setViewMode]);
|
|
37
|
+
const onMonthSelect = (0, react_1.useCallback)((date) => {
|
|
38
|
+
goToDate(date);
|
|
39
|
+
setViewMode("month");
|
|
40
|
+
}, [goToDate, setViewMode]);
|
|
41
|
+
const onDecadeYearSelect = (0, react_1.useCallback)((date) => {
|
|
42
|
+
goToDate(date);
|
|
43
|
+
setViewMode("year");
|
|
44
|
+
}, [goToDate, setViewMode]);
|
|
45
|
+
const datePickerComponents = (0, react_1.useMemo)(() => ({
|
|
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
|
+
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) }),
|
|
49
|
+
}), [onMonthSelect, onYearSelect, onDecadeYearSelect, setViewMode, activeMonths]);
|
|
50
|
+
return (react_1.default.createElement("div", { className: `uxf-date-range-picker ${activeMonths.length > 1 ? "uxf-date-range-picker--multi-month" : ""}` },
|
|
51
|
+
props.children,
|
|
52
|
+
datePickerComponents[viewMode]));
|
|
53
|
+
};
|
|
54
|
+
exports.DateRangePickerContent = DateRangePickerContent;
|
|
55
|
+
exports.DateRangePickerContent.displayName = "UxfUiDateRangePickerContent";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DateRangePickerDecade = void 0;
|
|
30
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const use_decade_1 = require("@uxf/datepicker/hooks/use-decade");
|
|
33
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
34
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
35
|
+
const date_range_picker_context_1 = require("@uxf/datepicker/contexts/date-range-picker-context");
|
|
36
|
+
const calendar_1 = require("../calendar");
|
|
37
|
+
exports.DateRangePickerDecade = (0, react_1.memo)((props) => {
|
|
38
|
+
const { canGoToYear, goToNextYear, goToPrevYear, activeMonths } = (0, react_1.useContext)(date_range_picker_context_1.DateRangePickerContext);
|
|
39
|
+
const currentYear = activeMonths[0].year;
|
|
40
|
+
const { decadeLabel, years } = (0, use_decade_1.useDecade)({
|
|
41
|
+
year: currentYear,
|
|
42
|
+
});
|
|
43
|
+
const canGoToPrevDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).subtract(5, "years").toDate());
|
|
44
|
+
const canGoToNextDecade = canGoToYear((0, dayjs_1.default)(new Date(currentYear, 0)).add(5, "years").toDate());
|
|
45
|
+
const handleGoToPrevDecadeClick = (0, react_1.useCallback)(() => {
|
|
46
|
+
if (canGoToPrevDecade) {
|
|
47
|
+
goToPrevYear(9);
|
|
48
|
+
}
|
|
49
|
+
}, [canGoToPrevDecade, goToPrevYear]);
|
|
50
|
+
const handleGoToNextDecadeClick = (0, react_1.useCallback)(() => {
|
|
51
|
+
if (canGoToNextDecade) {
|
|
52
|
+
goToNextYear(9);
|
|
53
|
+
}
|
|
54
|
+
}, [canGoToNextDecade, goToNextYear]);
|
|
55
|
+
const handleSelectYear = (0, react_1.useCallback)((date) => () => {
|
|
56
|
+
if (canGoToYear(date)) {
|
|
57
|
+
props.onYearSelect(date);
|
|
58
|
+
}
|
|
59
|
+
}, [canGoToYear, props]);
|
|
60
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
61
|
+
react_1.default.createElement(calendar_1.CalendarNavigation, { prevButtonProps: {
|
|
62
|
+
onClick: handleGoToPrevDecadeClick,
|
|
63
|
+
title: "Zpět",
|
|
64
|
+
}, nextButtonProps: {
|
|
65
|
+
onClick: handleGoToNextDecadeClick,
|
|
66
|
+
title: "Vpřed",
|
|
67
|
+
}, selectButtonProps: {
|
|
68
|
+
children: decadeLabel,
|
|
69
|
+
} }),
|
|
70
|
+
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))))));
|
|
71
|
+
});
|
|
72
|
+
exports.DateRangePickerDecade.displayName = "UxfUiDatePickerDecade";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseMonthProps } from "@uxf/datepicker/hooks/use-month";
|
|
2
|
+
import React, { Dispatch, SetStateAction } from "react";
|
|
3
|
+
import { ViewModeType } from "./types";
|
|
4
|
+
interface DatePickerMonthProps extends UseMonthProps {
|
|
5
|
+
setViewMode: Dispatch<SetStateAction<ViewModeType>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const DateRangePickerMonth: React.NamedExoticComponent<DatePickerMonthProps>;
|
|
8
|
+
export {};
|