@uxf/ui 1.0.0-beta.152 → 1.0.0-beta.154
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.js +1 -1
- package/calendar/calendar-day-cell.d.ts +7 -0
- package/calendar/calendar-day-cell.js +64 -0
- package/calendar/calendar-provider.d.ts +6 -0
- package/calendar/calendar-provider.js +26 -0
- package/calendar/calendar.d.ts +7 -0
- package/calendar/calendar.js +53 -0
- package/calendar/calendar.stories.d.ts +10 -0
- package/calendar/calendar.stories.js +49 -0
- package/calendar/index.d.ts +1 -0
- package/calendar/index.js +17 -0
- package/color-radio/color-radio.js +8 -2
- package/css/button.css +30 -25
- package/css/calendar.css +151 -0
- package/css/date-picker.css +8 -14
- package/date-picker-input/date-picker-day.js +1 -1
- package/date-picker-input/date-picker-decade.js +11 -9
- package/date-picker-input/date-picker-month.js +20 -14
- package/date-picker-input/date-picker-navigation.d.ts +9 -0
- package/date-picker-input/date-picker-navigation.js +19 -0
- package/date-picker-input/date-picker-year.js +15 -9
- package/package.json +1 -1
- package/select/select.js +1 -1
|
@@ -65,7 +65,7 @@ const _SelectBase = (props) => {
|
|
|
65
65
|
props.children,
|
|
66
66
|
react_1.default.createElement(input_1.Input.RightElement, null,
|
|
67
67
|
props.value && !props.isDisabled && !props.isReadOnly && props.isClearable && (react_1.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
|
|
68
|
-
react_1.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-sb__button-icon", renderProps.open && classes_1.CLASSES.IS_OPEN), name: iconName })),
|
|
68
|
+
react_1.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-sb__button-icon z-[1]", renderProps.open && classes_1.CLASSES.IS_OPEN), name: iconName })),
|
|
69
69
|
props.rightAddon && react_1.default.createElement(input_1.Input.RightAddon, null, props.rightAddon)),
|
|
70
70
|
react_1.default.createElement(Options, { component: Component, emptyMessage: props.emptyMessage, forwardRef: dropdown.floating, keyExtractor: props.keyExtractor, options: props.options, placement: dropdown.placement, renderOption: props.renderOption }),
|
|
71
71
|
props.helperText && (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: errorId }, props.helperText)))))));
|
|
@@ -0,0 +1,64 @@
|
|
|
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.CalendarDayCell = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
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
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
31
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
33
|
+
const useOnMount_1 = require("@uxf/core/hooks/useOnMount");
|
|
34
|
+
exports.CalendarDayCell = (0, react_1.memo)((props) => {
|
|
35
|
+
const { day } = props;
|
|
36
|
+
const dayCellRef = (0, react_1.useRef)(null);
|
|
37
|
+
const innerRef = (0, react_1.useRef)(null);
|
|
38
|
+
const { focusedDate, isDateBlocked, isDateFocused, isDateHovered, isDateSelected, onDateFocus, onDateHover, onDateSelect, } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
39
|
+
const { disabledDate, isSelected, onClick, onKeyDown, onMouseEnter, tabIndex, isToday } = (0, use_day_1.useDay)({
|
|
40
|
+
date: day.date,
|
|
41
|
+
focusedDate,
|
|
42
|
+
isDateBlocked,
|
|
43
|
+
isDateFocused,
|
|
44
|
+
isDateHovered,
|
|
45
|
+
isDateSelected,
|
|
46
|
+
onDateFocus,
|
|
47
|
+
onDateHover,
|
|
48
|
+
onDateSelect,
|
|
49
|
+
dayRef: dayCellRef,
|
|
50
|
+
});
|
|
51
|
+
const isDisabled = disabledDate || !day.currentMonth;
|
|
52
|
+
(0, useOnMount_1.useOnMount)(() => {
|
|
53
|
+
const node = innerRef.current;
|
|
54
|
+
if (node && (isToday || isSelected)) {
|
|
55
|
+
node.focus();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (!day.dayLabel) {
|
|
59
|
+
return react_1.default.createElement("div", null);
|
|
60
|
+
}
|
|
61
|
+
return (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-calendar__cell uxf-calendar__cell-day", isDisabled && classes_1.CLASSES.IS_DISABLED, isToday && "uxf-calendar__cell-day--today", isSelected && "uxf-calendar__cell-day--selected", !props.day.currentMonth && "uxf-calendar__cell-day--not-current-month"), ref: isDisabled ? undefined : (0, composeRefs_1.composeRefs)(dayCellRef, innerRef), onClick: onClick, onKeyDown: onKeyDown, onMouseEnter: onMouseEnter, tabIndex: tabIndex, type: "button" },
|
|
62
|
+
react_1.default.createElement("span", { className: "uxf-calendar__cell-day__inner" }, day.dayLabel)));
|
|
63
|
+
});
|
|
64
|
+
exports.CalendarDayCell.displayName = "UxfUiCalendarDayCell";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CalendarProvider = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-context");
|
|
9
|
+
const use_date_picker_1 = require("@uxf/datepicker/hooks/use-date-picker");
|
|
10
|
+
const calendar_1 = require("./calendar");
|
|
11
|
+
const CalendarProvider = (props) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const calendarProps = (0, use_date_picker_1.useDatePicker)({
|
|
14
|
+
firstDayOfWeek: 1,
|
|
15
|
+
onDateChange: (data) => {
|
|
16
|
+
if (data && props.onChange) {
|
|
17
|
+
props.onChange(data);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
selectedDate: (_a = props.selectedDate) !== null && _a !== void 0 ? _a : null,
|
|
21
|
+
});
|
|
22
|
+
return (react_1.default.createElement(date_picker_context_1.DatePickerContext.Provider, { value: calendarProps },
|
|
23
|
+
react_1.default.createElement(calendar_1.Calendar, null)));
|
|
24
|
+
};
|
|
25
|
+
exports.CalendarProvider = CalendarProvider;
|
|
26
|
+
exports.CalendarProvider.displayName = "UxfUiCalendarProvider";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface CalendarProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
onChange?: (data: Date | null) => void;
|
|
5
|
+
selectedDate?: Date | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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.Calendar = void 0;
|
|
30
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const use_month_1 = require("@uxf/datepicker/hooks/use-month");
|
|
33
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
34
|
+
const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-context");
|
|
35
|
+
const calendar_day_cell_1 = require("./calendar-day-cell");
|
|
36
|
+
exports.Calendar = (0, react_1.forwardRef)((props, ref) => {
|
|
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
|
+
const { days, weekdayLabels } = (0, use_month_1.useMonth)({
|
|
42
|
+
dayLabelFormat: (date) => (0, dayjs_1.default)(date).format("D"),
|
|
43
|
+
firstDayOfWeek,
|
|
44
|
+
month: currentMonth,
|
|
45
|
+
monthLabelFormat: (date) => (0, dayjs_1.default)(date).format("MMMM YYYY"),
|
|
46
|
+
weekdayLabelFormat: (date) => (0, dayjs_1.default)(date).format("dd"),
|
|
47
|
+
year: currentYear,
|
|
48
|
+
});
|
|
49
|
+
return (react_1.default.createElement("div", { ref: ref, className: calendarClassName },
|
|
50
|
+
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 }))))));
|
|
52
|
+
});
|
|
53
|
+
exports.Calendar.displayName = "UxfUiCalendar";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.ForwardRefExoticComponent<import("./calendar").CalendarProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
parameters: {
|
|
6
|
+
docs: {};
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
10
|
+
export declare function Default(): JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
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.Default = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const action_1 = require("../utils/action");
|
|
29
|
+
const calendar_provider_1 = require("./calendar-provider");
|
|
30
|
+
const calendar_1 = require("./calendar");
|
|
31
|
+
exports.default = {
|
|
32
|
+
title: "UI/Calendar",
|
|
33
|
+
component: calendar_1.Calendar,
|
|
34
|
+
parameters: {
|
|
35
|
+
docs: {
|
|
36
|
+
// page: Docs,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
function Default() {
|
|
41
|
+
const [date, setDate] = (0, react_1.useState)(null);
|
|
42
|
+
const onChange = (0, action_1.action)("onChange", setDate);
|
|
43
|
+
const testCalendars = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
44
|
+
react_1.default.createElement(calendar_provider_1.CalendarProvider, { selectedDate: date, onChange: onChange })));
|
|
45
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
|
+
react_1.default.createElement("div", { className: "light max-w-[640px] space-y-4 rounded bg-white p-8" }, testCalendars),
|
|
47
|
+
react_1.default.createElement("div", { className: "dark max-w-[640px] space-y-4 rounded bg-gray-900 p-8 text-white" }, testCalendars)));
|
|
48
|
+
}
|
|
49
|
+
exports.Default = Default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./calendar";
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./calendar"), exports);
|
|
@@ -26,10 +26,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.ColorRadio = void 0;
|
|
27
27
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
28
28
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
29
|
-
const color2k_1 = require("color2k");
|
|
30
29
|
const react_1 = __importStar(require("react"));
|
|
31
30
|
const useClickableProps_1 = require("@uxf/core/hooks/useClickableProps");
|
|
32
31
|
const icon_1 = require("../icon");
|
|
32
|
+
function readableColorIsBlack(bgColor) {
|
|
33
|
+
const color = bgColor.substring(1, 7);
|
|
34
|
+
const r = parseInt(color.substring(0, 2), 16); // hexToR
|
|
35
|
+
const g = parseInt(color.substring(2, 4), 16); // hexToG
|
|
36
|
+
const b = parseInt(color.substring(4, 6), 16); // hexToB
|
|
37
|
+
return r * 0.299 + g * 0.587 + b * 0.114 > 146;
|
|
38
|
+
}
|
|
33
39
|
exports.ColorRadio = (0, react_1.forwardRef)((props, ref) => {
|
|
34
40
|
var _a, _b, _c;
|
|
35
41
|
const colorRadioStyle = {
|
|
@@ -52,7 +58,7 @@ exports.ColorRadio = (0, react_1.forwardRef)((props, ref) => {
|
|
|
52
58
|
style: colorRadioStyle,
|
|
53
59
|
tabIndex: props.isReadOnly ? -1 : undefined,
|
|
54
60
|
});
|
|
55
|
-
const innerClassName = `uxf-color-radio__inner ${
|
|
61
|
+
const innerClassName = `uxf-color-radio__inner ${readableColorIsBlack(props.color) ? "uxf-color-radio__inner--dark" : ""}`;
|
|
56
62
|
return (react_1.default.createElement("div", { ...clickableProps, ref: ref },
|
|
57
63
|
react_1.default.createElement("span", { className: "uxf-color-radio__color-label" }, props.colorLabel), (_c = (_b = props.renderContent) === null || _b === void 0 ? void 0 : _b.call(props, innerClassName, props.checked, props.colorLabel, props.value)) !== null && _c !== void 0 ? _c : (react_1.default.createElement(icon_1.Icon, { className: innerClassName, name: "check" }))));
|
|
58
64
|
});
|
package/css/button.css
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.uxf-button {
|
|
8
|
-
@apply inline-flex items-center justify-center rounded-md font-medium shadow-sm transition-colors
|
|
8
|
+
@apply inline-flex items-center justify-center rounded-md font-medium shadow-sm transition-colors
|
|
9
|
+
focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2;
|
|
9
10
|
|
|
10
11
|
.uxf-icon {
|
|
11
12
|
@apply h-6;
|
|
@@ -142,32 +143,38 @@
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
&.uxf-button--color-default {
|
|
146
|
+
@apply focus-visible:ring-primary;
|
|
147
|
+
|
|
145
148
|
:root .light & {
|
|
146
|
-
@apply text-primary border-primary
|
|
149
|
+
@apply text-primary border-primary is-hoverable:border-primary-700 is-hoverable:text-primary-700;
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
:root .dark & {
|
|
150
|
-
@apply text-primary border-primary
|
|
153
|
+
@apply text-primary border-primary is-hoverable:border-primary-300 is-hoverable:text-primary-300;
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
&.uxf-button--color-success {
|
|
158
|
+
@apply focus-visible:ring-success;
|
|
159
|
+
|
|
155
160
|
:root .light & {
|
|
156
|
-
@apply text-success border-success
|
|
161
|
+
@apply text-success border-success is-hoverable:border-success-700 is-hoverable:text-success-700;
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
:root .dark & {
|
|
160
|
-
@apply text-success border-success
|
|
165
|
+
@apply text-success border-success is-hoverable:border-success-300 is-hoverable:text-success-300;
|
|
161
166
|
}
|
|
162
167
|
}
|
|
163
168
|
|
|
164
169
|
&.uxf-button--color-error {
|
|
170
|
+
@apply focus-visible:ring-error;
|
|
171
|
+
|
|
165
172
|
:root .light & {
|
|
166
|
-
@apply text-error border-error
|
|
173
|
+
@apply text-error border-error is-hoverable:border-error-700 is-hoverable:text-error-700;
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
:root .dark & {
|
|
170
|
-
@apply text-error border-error
|
|
177
|
+
@apply text-error border-error is-hoverable:border-error-300 is-hoverable:text-error-300;
|
|
171
178
|
}
|
|
172
179
|
}
|
|
173
180
|
|
|
@@ -183,7 +190,7 @@
|
|
|
183
190
|
}
|
|
184
191
|
|
|
185
192
|
&--variant-default {
|
|
186
|
-
@apply text-white
|
|
193
|
+
@apply text-white;
|
|
187
194
|
|
|
188
195
|
:root .dark & {
|
|
189
196
|
@apply focus-visible:ring-offset-gray-900;
|
|
@@ -193,11 +200,11 @@
|
|
|
193
200
|
@apply focus-visible:ring-primary;
|
|
194
201
|
|
|
195
202
|
:root .light & {
|
|
196
|
-
@apply bg-primary
|
|
203
|
+
@apply bg-primary is-hoverable:bg-primary-700;
|
|
197
204
|
}
|
|
198
205
|
|
|
199
206
|
:root .dark & {
|
|
200
|
-
@apply bg-primary
|
|
207
|
+
@apply bg-primary is-hoverable:bg-primary-400;
|
|
201
208
|
}
|
|
202
209
|
|
|
203
210
|
&.is-disabled {
|
|
@@ -215,11 +222,11 @@
|
|
|
215
222
|
@apply focus-visible:ring-success;
|
|
216
223
|
|
|
217
224
|
:root .light & {
|
|
218
|
-
@apply bg-success
|
|
225
|
+
@apply bg-success is-hoverable:bg-success-700;
|
|
219
226
|
}
|
|
220
227
|
|
|
221
228
|
:root .dark & {
|
|
222
|
-
@apply bg-success
|
|
229
|
+
@apply bg-success is-hoverable:bg-success-400;
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
&.is-disabled {
|
|
@@ -237,11 +244,11 @@
|
|
|
237
244
|
@apply focus-visible:ring-error;
|
|
238
245
|
|
|
239
246
|
:root .light & {
|
|
240
|
-
@apply bg-error
|
|
247
|
+
@apply bg-error is-hoverable:bg-error-700;
|
|
241
248
|
}
|
|
242
249
|
|
|
243
250
|
:root .dark & {
|
|
244
|
-
@apply bg-error
|
|
251
|
+
@apply bg-error is-hoverable:bg-error-400;
|
|
245
252
|
}
|
|
246
253
|
|
|
247
254
|
&.is-disabled {
|
|
@@ -257,14 +264,14 @@
|
|
|
257
264
|
}
|
|
258
265
|
|
|
259
266
|
&--variant-white {
|
|
260
|
-
@apply border;
|
|
267
|
+
@apply border focus-visible:ring-primary;
|
|
261
268
|
|
|
262
269
|
:root .light & {
|
|
263
|
-
@apply border-lightBorder bg-white
|
|
270
|
+
@apply border-lightBorder bg-white is-hoverable:bg-gray-100 text-lightMedium;
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
:root .dark & {
|
|
267
|
-
@apply border-darkBorder text-darkMedium bg-lightHigh
|
|
274
|
+
@apply border-darkBorder text-darkMedium bg-lightHigh is-hoverable:bg-gray-800 is-hoverable:text-darkHigh;
|
|
268
275
|
}
|
|
269
276
|
|
|
270
277
|
&.is-disabled {
|
|
@@ -282,14 +289,12 @@
|
|
|
282
289
|
@apply shadow-none;
|
|
283
290
|
|
|
284
291
|
&.uxf-button--color-default {
|
|
285
|
-
@apply text-primary;
|
|
286
|
-
|
|
287
292
|
:root .light & {
|
|
288
|
-
@apply
|
|
293
|
+
@apply text-lightMedium is-hoverable:text-lightHigh;
|
|
289
294
|
}
|
|
290
295
|
|
|
291
296
|
:root .dark & {
|
|
292
|
-
@apply
|
|
297
|
+
@apply text-darkMedium is-hoverable:text-darkHigh;
|
|
293
298
|
}
|
|
294
299
|
}
|
|
295
300
|
|
|
@@ -297,11 +302,11 @@
|
|
|
297
302
|
@apply text-success;
|
|
298
303
|
|
|
299
304
|
:root .light & {
|
|
300
|
-
@apply
|
|
305
|
+
@apply is-hoverable:text-success-700;
|
|
301
306
|
}
|
|
302
307
|
|
|
303
308
|
:root .dark & {
|
|
304
|
-
@apply
|
|
309
|
+
@apply is-hoverable:text-success-300;
|
|
305
310
|
}
|
|
306
311
|
}
|
|
307
312
|
|
|
@@ -309,11 +314,11 @@
|
|
|
309
314
|
@apply text-error;
|
|
310
315
|
|
|
311
316
|
:root .light & {
|
|
312
|
-
@apply
|
|
317
|
+
@apply is-hoverable:text-error-700;
|
|
313
318
|
}
|
|
314
319
|
|
|
315
320
|
:root .dark & {
|
|
316
|
-
@apply
|
|
321
|
+
@apply is-hoverable:text-error-300;
|
|
317
322
|
}
|
|
318
323
|
}
|
|
319
324
|
|
package/css/calendar.css
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
.uxf-calendar {
|
|
2
|
+
&__cell-day {
|
|
3
|
+
align-items: center;
|
|
4
|
+
background-color: theme("backgroundColor.white");
|
|
5
|
+
color: theme("colors.lightMedium");
|
|
6
|
+
display: flex;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
font-weight: theme("fontWeight.medium");
|
|
9
|
+
height: 40px;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
line-height: 1;
|
|
12
|
+
outline: none;
|
|
13
|
+
position: relative;
|
|
14
|
+
text-align: center;
|
|
15
|
+
|
|
16
|
+
--compensated-radii: calc(theme("borderRadius.md") - theme("spacing.px"));
|
|
17
|
+
|
|
18
|
+
:root .dark & {
|
|
19
|
+
background-color: theme("backgroundColor.gray.900");
|
|
20
|
+
color: theme("colors.darkMedium");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
background-color: theme("backgroundColor.gray.50");
|
|
25
|
+
|
|
26
|
+
:root .dark & {
|
|
27
|
+
background-color: theme("backgroundColor.gray.950");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:focus-visible {
|
|
32
|
+
&::before {
|
|
33
|
+
border: 2px solid theme("colors.primary.500");
|
|
34
|
+
border-radius: 2px;
|
|
35
|
+
content: "";
|
|
36
|
+
inset: 0;
|
|
37
|
+
position: absolute;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&:first-child {
|
|
42
|
+
border-top-left-radius: var(--compensated-radii);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:nth-child(7) {
|
|
46
|
+
border-top-right-radius: var(--compensated-radii);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:nth-last-child(7) {
|
|
50
|
+
border-bottom-left-radius: var(--compensated-radii);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:last-child {
|
|
54
|
+
border-bottom-right-radius: var(--compensated-radii);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&--not-current-month {
|
|
58
|
+
background-color: theme("backgroundColor.gray.100");
|
|
59
|
+
color: theme("colors.lightLow");
|
|
60
|
+
|
|
61
|
+
:root .dark & {
|
|
62
|
+
background-color: theme("backgroundColor.gray.800");
|
|
63
|
+
color: theme("colors.darkLow");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&--selected {
|
|
68
|
+
background-color: theme("backgroundColor.primary.500");
|
|
69
|
+
color: theme("colors.white");
|
|
70
|
+
|
|
71
|
+
:root .dark & {
|
|
72
|
+
background-color: theme("backgroundColor.primary.500");
|
|
73
|
+
color: theme("colors.white");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&:hover {
|
|
77
|
+
background-color: theme("backgroundColor.primary.500");
|
|
78
|
+
|
|
79
|
+
:root .dark & {
|
|
80
|
+
background-color: theme("backgroundColor.primary.500");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&--today {
|
|
86
|
+
.uxf-calendar__cell-day__inner {
|
|
87
|
+
align-items: center;
|
|
88
|
+
background-color: theme("backgroundColor.lightHigh");
|
|
89
|
+
border-radius: 999px;
|
|
90
|
+
color: theme("colors.white");
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
height: 32px;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
position: relative;
|
|
95
|
+
width: 32px;
|
|
96
|
+
|
|
97
|
+
:root .dark & {
|
|
98
|
+
background-color: theme("backgroundColor.transparent");
|
|
99
|
+
border: 2px solid theme("colors.darkMedium");
|
|
100
|
+
color: theme("colors.white");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&.uxf-calendar__cell-day--selected {
|
|
105
|
+
.uxf-calendar__cell-day__inner {
|
|
106
|
+
background-color: theme("backgroundColor.transparent");
|
|
107
|
+
color: theme("colors.white");
|
|
108
|
+
border: 2px solid theme("colors.darkMedium");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&__weekdays {
|
|
115
|
+
color: theme("colors.lightLow");
|
|
116
|
+
column-gap: 1px;
|
|
117
|
+
display: grid;
|
|
118
|
+
font-size: 10px;
|
|
119
|
+
font-weight: theme("fontWeight.semibold");
|
|
120
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
121
|
+
padding: 0 1px;
|
|
122
|
+
text-align: center;
|
|
123
|
+
text-transform: uppercase;
|
|
124
|
+
|
|
125
|
+
:root .dark & {
|
|
126
|
+
color: theme("colors.darkLow");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&__weekday {
|
|
131
|
+
align-items: center;
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
height: 32px;
|
|
135
|
+
justify-content: center;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&__days {
|
|
139
|
+
background-color: theme("backgroundColor.lightBorder");
|
|
140
|
+
border-radius: 6px;
|
|
141
|
+
display: grid;
|
|
142
|
+
gap: 1px;
|
|
143
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
144
|
+
padding: 1px;
|
|
145
|
+
text-align: center;
|
|
146
|
+
|
|
147
|
+
:root .dark & {
|
|
148
|
+
background-color: theme("backgroundColor.darkBorder");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
package/css/date-picker.css
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
.uxf-date-picker {
|
|
2
|
-
&
|
|
3
|
-
&__year-select,
|
|
4
|
-
&__decade-select {
|
|
2
|
+
&__navigation {
|
|
5
3
|
@apply flex items-center justify-between px-4 w-[320px] sm:w-[360px];
|
|
6
4
|
}
|
|
7
5
|
|
|
@@ -35,11 +33,7 @@
|
|
|
35
33
|
@apply p-1 transition relative rounded-full outline-none before:absolute before:pointer-events-none
|
|
36
34
|
before:rounded-full before:-inset-1 focus-visible:before:border-2;
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
@apply w-9 h-9;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&__month {
|
|
36
|
+
&-month {
|
|
43
37
|
@apply w-full;
|
|
44
38
|
}
|
|
45
39
|
|
|
@@ -55,15 +49,15 @@
|
|
|
55
49
|
@apply hover:bg-gray-200 focus-visible:before:border-primary;
|
|
56
50
|
}
|
|
57
51
|
|
|
58
|
-
.uxf-date-
|
|
52
|
+
.uxf-date-picker__cell-day--today {
|
|
59
53
|
@apply bg-primary-200 hover:bg-primary-300;
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
.uxf-date-
|
|
56
|
+
.uxf-date-picker__cell-day--selected {
|
|
63
57
|
@apply bg-primary text-white hover:bg-primary;
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
.uxf-date-
|
|
60
|
+
.uxf-date-picker__cell-day--not-current-month {
|
|
67
61
|
@apply text-gray-400;
|
|
68
62
|
}
|
|
69
63
|
}
|
|
@@ -75,15 +69,15 @@
|
|
|
75
69
|
@apply hover:bg-gray-700 focus-visible:before:border-primary;
|
|
76
70
|
}
|
|
77
71
|
|
|
78
|
-
.uxf-date-
|
|
72
|
+
.uxf-date-picker__cell-day--today {
|
|
79
73
|
@apply bg-primary-400/50 hover:bg-primary-400/60;
|
|
80
74
|
}
|
|
81
75
|
|
|
82
|
-
.uxf-date-
|
|
76
|
+
.uxf-date-picker__cell-day--selected {
|
|
83
77
|
@apply bg-primary text-white hover:bg-primary;
|
|
84
78
|
}
|
|
85
79
|
|
|
86
|
-
.uxf-date-
|
|
80
|
+
.uxf-date-picker__cell-day--not-current-month {
|
|
87
81
|
@apply text-gray-600;
|
|
88
82
|
}
|
|
89
83
|
}
|
|
@@ -58,6 +58,6 @@ exports.DatePickerDay = (0, react_1.memo)((props) => {
|
|
|
58
58
|
if (!day.dayLabel) {
|
|
59
59
|
return react_1.default.createElement("div", null);
|
|
60
60
|
}
|
|
61
|
-
return (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-date-picker__cell uxf-date-
|
|
61
|
+
return (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-date-picker__cell uxf-date-picker__cell-day", isDisabled && classes_1.CLASSES.IS_DISABLED, isToday && "uxf-date-picker__cell-day--today", isSelected && "uxf-date-picker__cell-day--selected", !props.currentMonth && "uxf-date-picker__cell-day--not-current-month"), ref: isDisabled ? undefined : (0, composeRefs_1.composeRefs)(dayCellRef, innerRef), onClick: onClick, onKeyDown: onKeyDown, onMouseEnter: onMouseEnter, tabIndex: tabIndex, type: "button" }, day.dayLabel));
|
|
62
62
|
});
|
|
63
63
|
exports.DatePickerDay.displayName = "UxfUiDatePickerDay";
|
|
@@ -31,10 +31,9 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
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 button_1 = require("../button");
|
|
35
|
-
const icon_1 = require("../icon");
|
|
36
34
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
37
35
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
36
|
+
const date_picker_navigation_1 = require("./date-picker-navigation");
|
|
38
37
|
exports.DatePickerDecade = (0, react_1.memo)((props) => {
|
|
39
38
|
const { onYearSelect } = props;
|
|
40
39
|
const { canGoToYear, goToNextYear, goToPrevYear, activeMonths } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
@@ -60,12 +59,15 @@ exports.DatePickerDecade = (0, react_1.memo)((props) => {
|
|
|
60
59
|
}
|
|
61
60
|
}, [canGoToYear, onYearSelect]);
|
|
62
61
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
63
|
-
react_1.default.createElement(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
react_1.default.createElement(date_picker_navigation_1.DatePickerNavigation, { prevButtonProps: {
|
|
63
|
+
onClick: handleGoToPrevDecadeClick,
|
|
64
|
+
title: "Zpět",
|
|
65
|
+
}, nextButtonProps: {
|
|
66
|
+
onClick: handleGoToNextDecadeClick,
|
|
67
|
+
title: "Nadcházející rok",
|
|
68
|
+
}, selectButtonProps: {
|
|
69
|
+
children: decadeLabel,
|
|
70
|
+
} }),
|
|
71
|
+
react_1.default.createElement("div", { className: "uxf-date-picker__decade-calendar" }, years.map((year, index) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-date-picker__cell uxf-date-picker__cell-year", !canGoToYear(year.date) && classes_1.CLASSES.IS_DISABLED, (0, dayjs_1.default)(year.date).year() === currentYear && "uxf-date-picker__cell-year--current"), key: year.yearLabel + index, onClick: handleSelectYear(year.date), type: "button" }, year.yearLabel))))));
|
|
70
72
|
});
|
|
71
73
|
exports.DatePickerDecade.displayName = "UxfUiDatePickerDecade";
|
|
@@ -31,15 +31,14 @@ const date_picker_context_1 = require("@uxf/datepicker/contexts/date-picker-cont
|
|
|
31
31
|
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
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const date_picker_day_1 = require("./date-picker-day");
|
|
34
|
+
const calendar_1 = require("../calendar");
|
|
35
|
+
const date_picker_navigation_1 = require("./date-picker-navigation");
|
|
37
36
|
exports.DatePickerMonth = (0, react_1.memo)((props) => {
|
|
38
37
|
const { setViewMode } = props;
|
|
39
38
|
const { activeMonths, canGoToNextMonth, canGoToPrevMonth, firstDayOfWeek, goToNextMonthsByOneMonth, goToPrevMonthsByOneMonth, } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
40
39
|
const currentMonth = activeMonths[0].month;
|
|
41
40
|
const currentYear = activeMonths[0].year;
|
|
42
|
-
const {
|
|
41
|
+
const { monthLabel } = (0, use_month_1.useMonth)({
|
|
43
42
|
dayLabelFormat: (date) => (0, dayjs_1.default)(date).format("D"),
|
|
44
43
|
firstDayOfWeek,
|
|
45
44
|
month: currentMonth,
|
|
@@ -47,20 +46,27 @@ exports.DatePickerMonth = (0, react_1.memo)((props) => {
|
|
|
47
46
|
weekdayLabelFormat: (date) => (0, dayjs_1.default)(date).format("dd"),
|
|
48
47
|
year: currentYear,
|
|
49
48
|
});
|
|
50
|
-
const handleGoToPrevMonth = (0, react_1.useCallback)(() =>
|
|
49
|
+
const handleGoToPrevMonth = (0, react_1.useCallback)(() => {
|
|
50
|
+
goToPrevMonthsByOneMonth();
|
|
51
|
+
}, [goToPrevMonthsByOneMonth]);
|
|
51
52
|
const handleGoToNextMonth = (0, react_1.useCallback)(() => goToNextMonthsByOneMonth(), [goToNextMonthsByOneMonth]);
|
|
52
53
|
const handleMonthClick = (0, react_1.useCallback)(() => {
|
|
53
54
|
setViewMode("year");
|
|
54
55
|
}, [setViewMode]);
|
|
55
56
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
56
|
-
react_1.default.createElement(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
react_1.default.createElement(date_picker_navigation_1.DatePickerNavigation, { prevButtonProps: {
|
|
58
|
+
disabled: !canGoToPrevMonth,
|
|
59
|
+
onClick: canGoToPrevMonth ? handleGoToPrevMonth : undefined,
|
|
60
|
+
title: "Zpět",
|
|
61
|
+
}, nextButtonProps: {
|
|
62
|
+
disabled: !canGoToNextMonth,
|
|
63
|
+
onClick: canGoToNextMonth ? handleGoToNextMonth : undefined,
|
|
64
|
+
title: "Vpřed",
|
|
65
|
+
}, selectButtonProps: {
|
|
66
|
+
children: monthLabel,
|
|
67
|
+
onClick: handleMonthClick,
|
|
68
|
+
title: "Vybrat měsíc",
|
|
69
|
+
} }),
|
|
70
|
+
react_1.default.createElement(calendar_1.Calendar, null)));
|
|
65
71
|
});
|
|
66
72
|
exports.DatePickerMonth.displayName = "UxfUiDatePickerMonth";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DatePickerNavigation = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const button_1 = require("../button");
|
|
9
|
+
const icon_1 = require("../icon");
|
|
10
|
+
const DatePickerNavigation = (props) => {
|
|
11
|
+
return (react_1.default.createElement("div", { className: "uxf-date-picker__navigation" },
|
|
12
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", ...props.prevButtonProps },
|
|
13
|
+
react_1.default.createElement(icon_1.Icon, { name: "chevronLeft", size: 16 })),
|
|
14
|
+
props.selectButtonProps.onClick ? (react_1.default.createElement(button_1.Button, { variant: "text", color: "default", ...props.selectButtonProps })) : (react_1.default.createElement("p", { className: "uxf-date-picker__navigation-title" }, props.selectButtonProps.children)),
|
|
15
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", ...props.nextButtonProps },
|
|
16
|
+
react_1.default.createElement(icon_1.Icon, { name: "chevronRight", size: 16 }))));
|
|
17
|
+
};
|
|
18
|
+
exports.DatePickerNavigation = DatePickerNavigation;
|
|
19
|
+
exports.DatePickerNavigation.displayName = "UxfUiDatePickerArrowsViewMode";
|
|
@@ -33,8 +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
|
|
37
|
-
const icon_1 = require("../icon");
|
|
36
|
+
const date_picker_navigation_1 = require("./date-picker-navigation");
|
|
38
37
|
exports.DatePickerYear = (0, react_1.memo)((props) => {
|
|
39
38
|
const { canGoToNextYear, canGoToPrevYear, goToNextYear, goToPrevYear, canGoToMonth, activeMonths } = (0, react_1.useContext)(date_picker_context_1.DatePickerContext);
|
|
40
39
|
const currentMonth = activeMonths[0].month;
|
|
@@ -63,12 +62,19 @@ exports.DatePickerYear = (0, react_1.memo)((props) => {
|
|
|
63
62
|
}
|
|
64
63
|
}, [canGoToMonth, props]);
|
|
65
64
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
66
|
-
react_1.default.createElement(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
react_1.default.createElement(date_picker_navigation_1.DatePickerNavigation, { prevButtonProps: {
|
|
66
|
+
disabled: !canGoToPrevYear,
|
|
67
|
+
onClick: canGoToPrevYear ? handleGoToPrevYear : undefined,
|
|
68
|
+
title: "Předchozí rok",
|
|
69
|
+
}, nextButtonProps: {
|
|
70
|
+
disabled: !canGoToNextYear,
|
|
71
|
+
onClick: canGoToNextYear ? handleGoToNextYear : undefined,
|
|
72
|
+
title: "Nadcházející rok",
|
|
73
|
+
}, selectButtonProps: {
|
|
74
|
+
children: yearLabel,
|
|
75
|
+
onClick: handleYearClick,
|
|
76
|
+
title: "Vybrat rok",
|
|
77
|
+
} }),
|
|
78
|
+
react_1.default.createElement("div", { className: "uxf-date-picker__year-calendar" }, months.map((month, index) => (react_1.default.createElement("button", { className: (0, cx_1.cx)("uxf-date-picker__cell uxf-date-picker__cell-month", !canGoToMonth(month.date) && classes_1.CLASSES.IS_DISABLED, (0, dayjs_1.default)(month.date).month() === currentMonth && "uxf-date-picker__cell-month--current"), key: month.monthLabel + index, onClick: handleMonthClick(month.date), type: "button" }, month.monthLabel))))));
|
|
73
79
|
});
|
|
74
80
|
exports.DatePickerYear.displayName = "UxfUiDatePickerYear";
|
package/package.json
CHANGED
package/select/select.js
CHANGED
|
@@ -35,7 +35,7 @@ SelectedOption.displayName = "UxfUiSelectSelectedOption";
|
|
|
35
35
|
const Select = (props) => {
|
|
36
36
|
var _a, _b, _c;
|
|
37
37
|
const selectedOption = props.options.find((option) => option.id === props.value);
|
|
38
|
-
const onChange = (v) => props.onChange(v.id);
|
|
38
|
+
const onChange = (v) => props.onChange(v === null || v === void 0 ? void 0 : v.id);
|
|
39
39
|
return (react_2.default.createElement(_select_base_1._SelectBase, { HUIComponent: react_1.Listbox, className: `uxf-select ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, customInputElementDisplayName: SelectedOption.displayName, dropdownPlacement: props.dropdownPlacement, emptyMessage: "", forwardRef: props.forwardRef, helperText: props.helperText, hiddenLabel: props.hiddenLabel, iconName: props.iconName, id: props.id, isClearable: props.isClearable, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, keyExtractor: props.keyExtractor, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: props.name, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, renderOption: props.renderOption, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, value: props.value, variant: props.variant },
|
|
40
40
|
react_2.default.createElement(SelectedOption, { isEmpty: !(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) }, selectedOption
|
|
41
41
|
? (_c = (_b = props.renderSelectedOption) === null || _b === void 0 ? void 0 : _b.call(props, selectedOption)) !== null && _c !== void 0 ? _c : selectedOption.label
|