@chayns-ui/core 0.6.0 → 0.8.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/README.md +9 -3
- package/dist/accordion.css +66 -2
- package/dist/avatar.css +5 -11
- package/dist/badge.css +3 -3
- package/dist/banner.css +89 -0
- package/dist/button.css +16 -2
- package/dist/card.css +29 -2
- package/dist/checkbox.css +24 -13
- package/dist/combo-box.css +20 -2
- package/dist/components/accordion/Accordion.d.ts +10 -2
- package/dist/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.js +120 -46
- package/dist/components/accordion/Accordion.js.map +1 -1
- package/dist/components/accordion/Accordion.types.d.ts +24 -1
- package/dist/components/accordion/Accordion.types.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.types.js +6 -0
- package/dist/components/accordion/Accordion.types.js.map +1 -0
- package/dist/components/accordion/AccordionContext.d.ts +9 -0
- package/dist/components/accordion/AccordionContext.d.ts.map +1 -1
- package/dist/components/accordion/AccordionContext.js +8 -2
- package/dist/components/accordion/AccordionContext.js.map +1 -1
- package/dist/components/accordion-group/AccordionGroup.d.ts +1 -1
- package/dist/components/accordion-group/AccordionGroup.d.ts.map +1 -1
- package/dist/components/accordion-group/AccordionGroup.js +3 -3
- package/dist/components/accordion-group/AccordionGroup.js.map +1 -1
- package/dist/components/avatar/Avatar.d.ts +1 -0
- package/dist/components/avatar/Avatar.d.ts.map +1 -1
- package/dist/components/avatar/Avatar.js +11 -8
- package/dist/components/avatar/Avatar.js.map +1 -1
- package/dist/components/avatar-group/AvatarGroup.js +1 -1
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/banner/Banner.d.ts +3 -0
- package/dist/components/banner/Banner.d.ts.map +1 -0
- package/dist/components/banner/Banner.js +46 -0
- package/dist/components/banner/Banner.js.map +1 -0
- package/dist/components/banner/Banner.types.d.ts +24 -0
- package/dist/components/banner/Banner.types.d.ts.map +1 -0
- package/dist/components/banner/Banner.types.js +11 -0
- package/dist/components/banner/Banner.types.js.map +1 -0
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/button/Button.js +8 -3
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/button/Button.types.d.ts +6 -2
- package/dist/components/button/Button.types.d.ts.map +1 -1
- package/dist/components/button/Button.types.js.map +1 -1
- package/dist/components/card/Card.d.ts +4 -2
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/card/Card.js +24 -8
- package/dist/components/card/Card.js.map +1 -1
- package/dist/components/card/Card.types.d.ts +10 -12
- package/dist/components/card/Card.types.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.d.ts +1 -1
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.js +15 -6
- package/dist/components/checkbox/Checkbox.js.map +1 -1
- package/dist/components/checkbox/Checkbox.types.d.ts +2 -0
- package/dist/components/checkbox/Checkbox.types.d.ts.map +1 -1
- package/dist/components/combo-box/ComboBox.d.ts.map +1 -1
- package/dist/components/combo-box/ComboBox.js +20 -3
- package/dist/components/combo-box/ComboBox.js.map +1 -1
- package/dist/components/date-time-picker/DateTimePicker.d.ts +4 -0
- package/dist/components/date-time-picker/DateTimePicker.d.ts.map +1 -0
- package/dist/components/date-time-picker/DateTimePicker.js +339 -0
- package/dist/components/date-time-picker/DateTimePicker.js.map +1 -0
- package/dist/components/date-time-picker/DateTimePicker.types.d.ts +26 -0
- package/dist/components/date-time-picker/DateTimePicker.types.d.ts.map +1 -0
- package/dist/components/date-time-picker/DateTimePicker.types.js +12 -0
- package/dist/components/date-time-picker/DateTimePicker.types.js.map +1 -0
- package/dist/components/icon-button/IconButton.d.ts +7 -2
- package/dist/components/icon-button/IconButton.d.ts.map +1 -1
- package/dist/components/icon-button/IconButton.js +8 -3
- package/dist/components/icon-button/IconButton.js.map +1 -1
- package/dist/components/icon-button/IconButton.types.d.ts +3 -1
- package/dist/components/icon-button/IconButton.types.d.ts.map +1 -1
- package/dist/components/list/List.js +1 -1
- package/dist/components/popup/Popup.js +1 -1
- package/dist/components/popup/PopupList.js +1 -1
- package/dist/components/radio-group/RadioGroup.d.ts.map +1 -1
- package/dist/components/radio-group/RadioGroup.js +17 -8
- package/dist/components/radio-group/RadioGroup.js.map +1 -1
- package/dist/components/radio-group/RadioGroup.types.d.ts +5 -3
- package/dist/components/radio-group/RadioGroup.types.d.ts.map +1 -1
- package/dist/components/segmented-control/SegmentedControl.d.ts.map +1 -1
- package/dist/components/segmented-control/SegmentedControl.js +12 -5
- package/dist/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/components/segmented-control/SegmentedControl.types.d.ts +5 -2
- package/dist/components/segmented-control/SegmentedControl.types.d.ts.map +1 -1
- package/dist/components/skeleton/Skeleton.d.ts +4 -0
- package/dist/components/skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/Skeleton.js +20 -0
- package/dist/components/skeleton/Skeleton.js.map +1 -0
- package/dist/components/skeleton/Skeleton.types.d.ts +11 -0
- package/dist/components/skeleton/Skeleton.types.d.ts.map +1 -0
- package/dist/components/skeleton/Skeleton.types.js +10 -0
- package/dist/components/skeleton/Skeleton.types.js.map +1 -0
- package/dist/components/split-button/SplitButton.d.ts +1 -1
- package/dist/components/split-button/SplitButton.d.ts.map +1 -1
- package/dist/components/split-button/SplitButton.js +9 -17
- package/dist/components/split-button/SplitButton.js.map +1 -1
- package/dist/components/switch/Switch.d.ts +1 -1
- package/dist/components/switch/Switch.d.ts.map +1 -1
- package/dist/components/switch/Switch.js +13 -5
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/switch/Switch.types.d.ts +2 -0
- package/dist/components/switch/Switch.types.d.ts.map +1 -1
- package/dist/components/text-area/TextArea.d.ts +1 -1
- package/dist/components/text-area/TextArea.d.ts.map +1 -1
- package/dist/components/text-area/TextArea.js +5 -4
- package/dist/components/text-area/TextArea.js.map +1 -1
- package/dist/components/text-field/TextField.d.ts +1 -1
- package/dist/components/text-field/TextField.d.ts.map +1 -1
- package/dist/components/text-field/TextField.js +5 -4
- package/dist/components/text-field/TextField.js.map +1 -1
- package/dist/date-time-picker.css +121 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/list.css +4 -4
- package/dist/radio-group.css +13 -1
- package/dist/segmented-control.css +24 -7
- package/dist/skeleton.css +41 -0
- package/dist/split-button.css +1 -1
- package/dist/styles.css +3 -1
- package/dist/switch.css +18 -5
- package/dist/text-area.css +2 -2
- package/dist/text-field.css +1 -1
- package/package.json +4 -2
- package/dist/components/message-box/MessageBox.d.ts +0 -4
- package/dist/components/message-box/MessageBox.d.ts.map +0 -1
- package/dist/components/message-box/MessageBox.js +0 -19
- package/dist/components/message-box/MessageBox.js.map +0 -1
- package/dist/components/message-box/MessageBox.types.d.ts +0 -13
- package/dist/components/message-box/MessageBox.types.d.ts.map +0 -1
- package/dist/message-box.css +0 -26
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { DATE_TIME_PICKER_MINUTE_STEPS } from "./DateTimePicker.types.js";
|
|
2
|
+
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/date-time-picker/DateTimePicker.tsx
|
|
5
|
+
var WHEEL_LOOP_CYCLES = 11;
|
|
6
|
+
var WHEEL_CENTER_CYCLE = Math.floor(WHEEL_LOOP_CYCLES / 2);
|
|
7
|
+
function dateAtMidnight(value) {
|
|
8
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
9
|
+
}
|
|
10
|
+
function clampDate(value, minDate, maxDate) {
|
|
11
|
+
const date = dateAtMidnight(value);
|
|
12
|
+
if (minDate !== void 0 && date < dateAtMidnight(minDate)) return new Date(minDate);
|
|
13
|
+
if (maxDate !== void 0 && date > dateAtMidnight(maxDate)) return new Date(maxDate);
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
function normalizeMinute(value, minuteStep) {
|
|
17
|
+
const normalized = new Date(value);
|
|
18
|
+
normalized.setMinutes(Math.floor(normalized.getMinutes() / minuteStep) * minuteStep);
|
|
19
|
+
return normalized;
|
|
20
|
+
}
|
|
21
|
+
function Wheel({ ariaLabel, onEscape, onSelect, options, selected }) {
|
|
22
|
+
const wheelRef = useRef(null);
|
|
23
|
+
const selectedRef = useRef(null);
|
|
24
|
+
const dragRef = useRef(void 0);
|
|
25
|
+
const ignoreClickRef = useRef(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (typeof selectedRef.current?.scrollIntoView === "function") selectedRef.current.scrollIntoView({ block: "center" });
|
|
28
|
+
}, []);
|
|
29
|
+
function applyPerspective() {
|
|
30
|
+
const wheel = wheelRef.current;
|
|
31
|
+
const itemHeight = selectedRef.current?.offsetHeight;
|
|
32
|
+
if (!wheel || !itemHeight) return;
|
|
33
|
+
const position = wheel.scrollTop / itemHeight;
|
|
34
|
+
for (const option of wheel.querySelectorAll(".chayns-date-time-picker__wheel-option")) {
|
|
35
|
+
const index = Number(option.dataset.wheelIndex);
|
|
36
|
+
const distance = Math.max(-2.5, Math.min(2.5, index - position));
|
|
37
|
+
const progress = Math.min(1, Math.abs(distance) / 2.5);
|
|
38
|
+
option.style.color = progress < .2 ? "var(--text)" : "var(--text-3)";
|
|
39
|
+
option.style.fontWeight = progress < .2 ? "600" : "400";
|
|
40
|
+
option.style.opacity = String(1 - progress * .7);
|
|
41
|
+
option.style.transform = `rotateX(${distance * 22}deg) scale(${1 - progress * .24})`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function selectCenteredValue() {
|
|
45
|
+
const wheel = wheelRef.current;
|
|
46
|
+
const itemHeight = selectedRef.current?.offsetHeight;
|
|
47
|
+
if (!wheel || !itemHeight) return;
|
|
48
|
+
const option = options[(Math.round(wheel.scrollTop / itemHeight) % options.length + options.length) % options.length];
|
|
49
|
+
if (option !== void 0 && option.value !== selected) onSelect(option.value);
|
|
50
|
+
}
|
|
51
|
+
function handleScroll() {
|
|
52
|
+
const wheel = wheelRef.current;
|
|
53
|
+
const itemHeight = selectedRef.current?.offsetHeight;
|
|
54
|
+
if (!wheel || !itemHeight) return;
|
|
55
|
+
const index = Math.round(wheel.scrollTop / itemHeight);
|
|
56
|
+
const normalizedIndex = (index % options.length + options.length) % options.length;
|
|
57
|
+
if (index < options.length * 2 || index >= options.length * 9) wheel.scrollTop = (WHEEL_CENTER_CYCLE * options.length + normalizedIndex) * itemHeight;
|
|
58
|
+
applyPerspective();
|
|
59
|
+
selectCenteredValue();
|
|
60
|
+
}
|
|
61
|
+
function handleKeyDown(event) {
|
|
62
|
+
if (event.key === "Escape") {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
onEscape();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const index = options.findIndex((option) => option.value === selected);
|
|
68
|
+
let nextIndex = index;
|
|
69
|
+
if (event.key === "ArrowDown") nextIndex = Math.min(index + 1, options.length - 1);
|
|
70
|
+
if (event.key === "ArrowUp") nextIndex = Math.max(index - 1, 0);
|
|
71
|
+
if (event.key === "Home") nextIndex = 0;
|
|
72
|
+
if (event.key === "End") nextIndex = options.length - 1;
|
|
73
|
+
const nextOption = options[nextIndex];
|
|
74
|
+
if (nextIndex !== index && nextOption !== void 0) {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
onSelect(nextOption.value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function handlePointerDown(event) {
|
|
80
|
+
if (event.button !== 0) return;
|
|
81
|
+
if (typeof event.currentTarget.setPointerCapture === "function") event.currentTarget.setPointerCapture(event.pointerId);
|
|
82
|
+
dragRef.current = {
|
|
83
|
+
pointerId: event.pointerId,
|
|
84
|
+
scrollTop: event.currentTarget.scrollTop,
|
|
85
|
+
startY: event.clientY
|
|
86
|
+
};
|
|
87
|
+
ignoreClickRef.current = false;
|
|
88
|
+
}
|
|
89
|
+
function handlePointerMove(event) {
|
|
90
|
+
const drag = dragRef.current;
|
|
91
|
+
if (drag?.pointerId !== event.pointerId) return;
|
|
92
|
+
const distance = event.clientY - drag.startY;
|
|
93
|
+
if (Math.abs(distance) > 3) {
|
|
94
|
+
ignoreClickRef.current = true;
|
|
95
|
+
event.currentTarget.scrollTop = drag.scrollTop - distance;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function handlePointerUp(event) {
|
|
99
|
+
if (dragRef.current?.pointerId !== event.pointerId) return;
|
|
100
|
+
dragRef.current = void 0;
|
|
101
|
+
if (typeof event.currentTarget.releasePointerCapture === "function") event.currentTarget.releasePointerCapture(event.pointerId);
|
|
102
|
+
selectCenteredValue();
|
|
103
|
+
}
|
|
104
|
+
return /* @__PURE__ */ jsx("div", {
|
|
105
|
+
"aria-label": ariaLabel,
|
|
106
|
+
className: "chayns-date-time-picker__wheel",
|
|
107
|
+
onKeyDown: handleKeyDown,
|
|
108
|
+
onPointerDown: handlePointerDown,
|
|
109
|
+
onPointerMove: handlePointerMove,
|
|
110
|
+
onPointerUp: handlePointerUp,
|
|
111
|
+
onScroll: handleScroll,
|
|
112
|
+
ref: wheelRef,
|
|
113
|
+
role: "listbox",
|
|
114
|
+
tabIndex: 0,
|
|
115
|
+
children: Array.from({ length: WHEEL_LOOP_CYCLES }, (_, cycle) => options.map((option, optionIndex) => /* @__PURE__ */ jsx("button", {
|
|
116
|
+
"aria-selected": option.value === selected,
|
|
117
|
+
className: "chayns-date-time-picker__wheel-option",
|
|
118
|
+
"data-wheel-index": cycle * options.length + optionIndex,
|
|
119
|
+
onClick: (event) => {
|
|
120
|
+
if (ignoreClickRef.current) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
ignoreClickRef.current = false;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
onSelect(option.value);
|
|
127
|
+
},
|
|
128
|
+
ref: cycle === WHEEL_CENTER_CYCLE && option.value === selected ? selectedRef : void 0,
|
|
129
|
+
role: "option",
|
|
130
|
+
type: "button",
|
|
131
|
+
children: option.label
|
|
132
|
+
}, `${cycle}-${option.value}`)))
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
var DateTimePicker = forwardRef(function DateTimePicker({ className, disabled, id, label, locale, maxDate, minDate, minuteStep = 1, mode = "time", onChange, onClick, onKeyDown, placeholder, value, wheelLabels, ...buttonProps }, ref) {
|
|
136
|
+
if (!DATE_TIME_PICKER_MINUTE_STEPS.includes(minuteStep)) throw new Error("DateTimePicker minuteStep must be one of: 1, 5, 15, 30.");
|
|
137
|
+
if (minDate !== void 0 && maxDate !== void 0 && dateAtMidnight(minDate) > dateAtMidnight(maxDate)) throw new Error("DateTimePicker requires minDate to be earlier than or equal to maxDate.");
|
|
138
|
+
const generatedId = useId();
|
|
139
|
+
const triggerId = id ?? generatedId;
|
|
140
|
+
const popupId = `${triggerId}-popup`;
|
|
141
|
+
const rootRef = useRef(null);
|
|
142
|
+
const triggerRef = useRef(null);
|
|
143
|
+
const [open, setOpen] = useState(false);
|
|
144
|
+
const displayValue = value === null ? null : mode === "date" ? clampDate(value, minDate, maxDate) : normalizeMinute(value, minuteStep);
|
|
145
|
+
const activeValue = displayValue ?? /* @__PURE__ */ new Date();
|
|
146
|
+
const isTwelveHour = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hour12 === true;
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (!open) return void 0;
|
|
149
|
+
function closeOnOutsidePress(event) {
|
|
150
|
+
if (event.target instanceof Node && !rootRef.current?.contains(event.target)) close();
|
|
151
|
+
}
|
|
152
|
+
document.addEventListener("pointerdown", closeOnOutsidePress);
|
|
153
|
+
return () => document.removeEventListener("pointerdown", closeOnOutsidePress);
|
|
154
|
+
});
|
|
155
|
+
const years = useMemo(() => {
|
|
156
|
+
const today = (/* @__PURE__ */ new Date()).getFullYear();
|
|
157
|
+
const first = minDate?.getFullYear() ?? today - 100;
|
|
158
|
+
const last = maxDate?.getFullYear() ?? today + 100;
|
|
159
|
+
return Array.from({ length: last - first + 1 }, (_, index) => first + index);
|
|
160
|
+
}, [maxDate, minDate]);
|
|
161
|
+
function close() {
|
|
162
|
+
setOpen(false);
|
|
163
|
+
triggerRef.current?.focus();
|
|
164
|
+
}
|
|
165
|
+
function emit(nextValue) {
|
|
166
|
+
onChange(mode === "date" ? clampDate(nextValue, minDate, maxDate) : nextValue);
|
|
167
|
+
}
|
|
168
|
+
function updateTime(part, nextValue) {
|
|
169
|
+
const next = new Date(activeValue);
|
|
170
|
+
if (part === "hours") {
|
|
171
|
+
const hour = isTwelveHour ? nextValue % 12 + (next.getHours() >= 12 ? 12 : 0) : nextValue;
|
|
172
|
+
next.setHours(hour);
|
|
173
|
+
} else next.setMinutes(nextValue);
|
|
174
|
+
emit(next);
|
|
175
|
+
}
|
|
176
|
+
function updatePeriod(period) {
|
|
177
|
+
const next = new Date(activeValue);
|
|
178
|
+
next.setHours(next.getHours() % 12 + period * 12);
|
|
179
|
+
emit(next);
|
|
180
|
+
}
|
|
181
|
+
function updateDate(part, nextValue) {
|
|
182
|
+
const next = new Date(activeValue);
|
|
183
|
+
const originalDay = next.getDate();
|
|
184
|
+
next.setDate(1);
|
|
185
|
+
if (part === "fullYear") next.setFullYear(nextValue);
|
|
186
|
+
if (part === "month") next.setMonth(nextValue);
|
|
187
|
+
if (part === "date") next.setDate(nextValue);
|
|
188
|
+
if (part !== "date") next.setDate(Math.min(originalDay, new Date(next.getFullYear(), next.getMonth() + 1, 0).getDate()));
|
|
189
|
+
emit(next);
|
|
190
|
+
}
|
|
191
|
+
const formattedValue = displayValue === null ? placeholder : mode === "time" ? `${new Intl.DateTimeFormat(locale, {
|
|
192
|
+
hour: "numeric",
|
|
193
|
+
minute: "2-digit"
|
|
194
|
+
}).format(displayValue)}${locale.toLowerCase().startsWith("de") ? " Uhr" : ""}` : new Intl.DateTimeFormat(locale, {
|
|
195
|
+
day: "numeric",
|
|
196
|
+
month: "long",
|
|
197
|
+
year: "numeric"
|
|
198
|
+
}).format(displayValue);
|
|
199
|
+
const hours = Array.from({ length: isTwelveHour ? 12 : 24 }, (_, index) => isTwelveHour ? index + 1 : index).map((hour) => ({
|
|
200
|
+
label: String(hour).padStart(2, "0"),
|
|
201
|
+
value: hour
|
|
202
|
+
}));
|
|
203
|
+
const minutes = Array.from({ length: 60 / minuteStep }, (_, index) => {
|
|
204
|
+
const minute = index * minuteStep;
|
|
205
|
+
return {
|
|
206
|
+
label: String(minute).padStart(2, "0"),
|
|
207
|
+
value: minute
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
const months = Array.from({ length: 12 }, (_, month) => ({
|
|
211
|
+
label: new Intl.DateTimeFormat(locale, { month: "long" }).format(new Date(2026, month, 1)),
|
|
212
|
+
value: month
|
|
213
|
+
})).filter((month) => {
|
|
214
|
+
const first = new Date(activeValue.getFullYear(), month.value, 1);
|
|
215
|
+
const last = new Date(activeValue.getFullYear(), month.value + 1, 0);
|
|
216
|
+
return (minDate === void 0 || last >= dateAtMidnight(minDate)) && (maxDate === void 0 || first <= dateAtMidnight(maxDate));
|
|
217
|
+
});
|
|
218
|
+
const days = Array.from({ length: new Date(activeValue.getFullYear(), activeValue.getMonth() + 1, 0).getDate() }, (_, index) => ({
|
|
219
|
+
label: String(index + 1).padStart(2, "0"),
|
|
220
|
+
value: index + 1
|
|
221
|
+
})).filter((day) => {
|
|
222
|
+
const candidate = new Date(activeValue.getFullYear(), activeValue.getMonth(), day.value);
|
|
223
|
+
return (minDate === void 0 || candidate >= dateAtMidnight(minDate)) && (maxDate === void 0 || candidate <= dateAtMidnight(maxDate));
|
|
224
|
+
});
|
|
225
|
+
const datePartOrder = new Intl.DateTimeFormat(locale, {
|
|
226
|
+
day: "numeric",
|
|
227
|
+
month: "numeric",
|
|
228
|
+
year: "numeric"
|
|
229
|
+
}).formatToParts(activeValue).flatMap((part) => {
|
|
230
|
+
if (part.type === "day") return ["date"];
|
|
231
|
+
if (part.type === "month") return ["month"];
|
|
232
|
+
if (part.type === "year") return ["fullYear"];
|
|
233
|
+
return [];
|
|
234
|
+
});
|
|
235
|
+
const yearOptions = years.map((year) => ({
|
|
236
|
+
label: String(year),
|
|
237
|
+
value: year
|
|
238
|
+
}));
|
|
239
|
+
function dateOptions(part) {
|
|
240
|
+
if (part === "date") return days;
|
|
241
|
+
if (part === "month") return months;
|
|
242
|
+
return yearOptions;
|
|
243
|
+
}
|
|
244
|
+
function dateValue(part) {
|
|
245
|
+
if (part === "date") return activeValue.getDate();
|
|
246
|
+
if (part === "month") return activeValue.getMonth();
|
|
247
|
+
return activeValue.getFullYear();
|
|
248
|
+
}
|
|
249
|
+
const dayPeriods = [0, 1].map((period) => ({
|
|
250
|
+
label: new Intl.DateTimeFormat(locale, { hour: "numeric" }).formatToParts(new Date(2026, 0, 1, period === 0 ? 1 : 13)).find((part) => part.type === "dayPeriod")?.value ?? (period === 0 ? "AM" : "PM"),
|
|
251
|
+
value: period
|
|
252
|
+
}));
|
|
253
|
+
const resolvedClassName = [
|
|
254
|
+
"chayns-date-time-picker",
|
|
255
|
+
`chayns-date-time-picker--${mode}`,
|
|
256
|
+
open ? "chayns-date-time-picker--open" : "",
|
|
257
|
+
displayValue !== null ? "chayns-date-time-picker--filled" : ""
|
|
258
|
+
].filter(Boolean).join(" ");
|
|
259
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
260
|
+
className: resolvedClassName,
|
|
261
|
+
ref: rootRef,
|
|
262
|
+
children: [
|
|
263
|
+
/* @__PURE__ */ jsx("button", {
|
|
264
|
+
...buttonProps,
|
|
265
|
+
"aria-controls": open ? popupId : void 0,
|
|
266
|
+
"aria-expanded": open,
|
|
267
|
+
"aria-haspopup": "dialog",
|
|
268
|
+
className: ["chayns-date-time-picker__trigger", className].filter(Boolean).join(" "),
|
|
269
|
+
disabled,
|
|
270
|
+
id: triggerId,
|
|
271
|
+
onClick: (event) => {
|
|
272
|
+
onClick?.(event);
|
|
273
|
+
if (!event.defaultPrevented) setOpen((current) => !current);
|
|
274
|
+
},
|
|
275
|
+
onKeyDown: (event) => {
|
|
276
|
+
onKeyDown?.(event);
|
|
277
|
+
if (event.key === "Escape" && open && !event.defaultPrevented) {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
close();
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
ref: (element) => {
|
|
283
|
+
triggerRef.current = element;
|
|
284
|
+
if (typeof ref === "function") ref(element);
|
|
285
|
+
else if (ref !== null) ref.current = element;
|
|
286
|
+
},
|
|
287
|
+
type: "button",
|
|
288
|
+
children: formattedValue
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ jsx("label", {
|
|
291
|
+
className: "chayns-date-time-picker__label",
|
|
292
|
+
htmlFor: triggerId,
|
|
293
|
+
children: label
|
|
294
|
+
}),
|
|
295
|
+
open && !disabled ? /* @__PURE__ */ jsxs("div", {
|
|
296
|
+
"aria-label": label,
|
|
297
|
+
className: "chayns-date-time-picker__popup",
|
|
298
|
+
id: popupId,
|
|
299
|
+
role: "dialog",
|
|
300
|
+
children: [/* @__PURE__ */ jsx("div", { className: "chayns-date-time-picker__selection" }), /* @__PURE__ */ jsx("div", {
|
|
301
|
+
className: "chayns-date-time-picker__wheels",
|
|
302
|
+
children: mode === "time" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
303
|
+
/* @__PURE__ */ jsx(Wheel, {
|
|
304
|
+
ariaLabel: wheelLabels.hour,
|
|
305
|
+
onEscape: close,
|
|
306
|
+
onSelect: (hour) => updateTime("hours", hour),
|
|
307
|
+
options: hours,
|
|
308
|
+
selected: isTwelveHour ? activeValue.getHours() % 12 || 12 : activeValue.getHours()
|
|
309
|
+
}),
|
|
310
|
+
/* @__PURE__ */ jsx(Wheel, {
|
|
311
|
+
ariaLabel: wheelLabels.minute,
|
|
312
|
+
onEscape: close,
|
|
313
|
+
onSelect: (minute) => updateTime("minutes", minute),
|
|
314
|
+
options: minutes,
|
|
315
|
+
selected: activeValue.getMinutes()
|
|
316
|
+
}),
|
|
317
|
+
isTwelveHour ? /* @__PURE__ */ jsx(Wheel, {
|
|
318
|
+
ariaLabel: wheelLabels.dayPeriod,
|
|
319
|
+
onEscape: close,
|
|
320
|
+
onSelect: updatePeriod,
|
|
321
|
+
options: dayPeriods,
|
|
322
|
+
selected: activeValue.getHours() >= 12 ? 1 : 0
|
|
323
|
+
}) : null
|
|
324
|
+
] }) : datePartOrder.map((part) => /* @__PURE__ */ jsx(Wheel, {
|
|
325
|
+
ariaLabel: part === "date" ? wheelLabels.day : part === "month" ? wheelLabels.month : wheelLabels.year,
|
|
326
|
+
onEscape: close,
|
|
327
|
+
onSelect: (nextValue) => updateDate(part, nextValue),
|
|
328
|
+
options: dateOptions(part),
|
|
329
|
+
selected: dateValue(part)
|
|
330
|
+
}, part))
|
|
331
|
+
})]
|
|
332
|
+
}) : null
|
|
333
|
+
]
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
//#endregion
|
|
337
|
+
export { DateTimePicker as default };
|
|
338
|
+
|
|
339
|
+
//# sourceMappingURL=DateTimePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePicker.js","names":[],"sources":["../../../src/components/date-time-picker/DateTimePicker.tsx"],"sourcesContent":["import { forwardRef, useEffect, useId, useMemo, useRef, useState } from 'react';\nimport type { KeyboardEvent, PointerEvent as ReactPointerEvent } from 'react';\n\nimport { DATE_TIME_PICKER_MINUTE_STEPS, type DateTimePickerProps } from './DateTimePicker.types.js';\n\nconst WHEEL_LOOP_CYCLES = 11;\nconst WHEEL_CENTER_CYCLE = Math.floor(WHEEL_LOOP_CYCLES / 2);\ntype DatePart = 'date' | 'fullYear' | 'month';\n\ninterface WheelOption {\n label: string;\n value: number;\n}\n\ninterface WheelProps {\n ariaLabel: string;\n onEscape: () => void;\n onSelect: (value: number) => void;\n options: readonly WheelOption[];\n selected: number;\n}\n\nfunction dateAtMidnight(value: Date) {\n return new Date(value.getFullYear(), value.getMonth(), value.getDate());\n}\n\nfunction clampDate(value: Date, minDate?: Date, maxDate?: Date) {\n const date = dateAtMidnight(value);\n if (minDate !== undefined && date < dateAtMidnight(minDate)) return new Date(minDate);\n if (maxDate !== undefined && date > dateAtMidnight(maxDate)) return new Date(maxDate);\n return value;\n}\n\nfunction normalizeMinute(value: Date, minuteStep: number) {\n const normalized = new Date(value);\n normalized.setMinutes(Math.floor(normalized.getMinutes() / minuteStep) * minuteStep);\n return normalized;\n}\n\nfunction Wheel({ ariaLabel, onEscape, onSelect, options, selected }: WheelProps) {\n const wheelRef = useRef<HTMLDivElement>(null);\n const selectedRef = useRef<HTMLButtonElement>(null);\n const dragRef = useRef<{ pointerId: number; scrollTop: number; startY: number } | undefined>(\n undefined,\n );\n const ignoreClickRef = useRef(false);\n\n useEffect(() => {\n if (typeof selectedRef.current?.scrollIntoView === 'function') {\n selectedRef.current.scrollIntoView({ block: 'center' });\n }\n }, []);\n\n function applyPerspective() {\n const wheel = wheelRef.current;\n const itemHeight = selectedRef.current?.offsetHeight;\n if (!wheel || !itemHeight) return;\n\n const position = wheel.scrollTop / itemHeight;\n for (const option of wheel.querySelectorAll<HTMLButtonElement>(\n '.chayns-date-time-picker__wheel-option',\n )) {\n const index = Number(option.dataset.wheelIndex);\n const distance = Math.max(-2.5, Math.min(2.5, index - position));\n const progress = Math.min(1, Math.abs(distance) / 2.5);\n\n option.style.color = progress < 0.2 ? 'var(--text)' : 'var(--text-3)';\n option.style.fontWeight = progress < 0.2 ? '600' : '400';\n option.style.opacity = String(1 - progress * 0.7);\n option.style.transform = `rotateX(${distance * 22}deg) scale(${1 - progress * 0.24})`;\n }\n }\n\n function selectCenteredValue() {\n const wheel = wheelRef.current;\n const itemHeight = selectedRef.current?.offsetHeight;\n if (!wheel || !itemHeight) return;\n\n const index = Math.round(wheel.scrollTop / itemHeight);\n const option = options[((index % options.length) + options.length) % options.length];\n if (option !== undefined && option.value !== selected) onSelect(option.value);\n }\n\n function handleScroll() {\n const wheel = wheelRef.current;\n const itemHeight = selectedRef.current?.offsetHeight;\n if (!wheel || !itemHeight) return;\n\n const index = Math.round(wheel.scrollTop / itemHeight);\n const normalizedIndex = ((index % options.length) + options.length) % options.length;\n if (index < options.length * 2 || index >= options.length * (WHEEL_LOOP_CYCLES - 2)) {\n wheel.scrollTop = (WHEEL_CENTER_CYCLE * options.length + normalizedIndex) * itemHeight;\n }\n\n applyPerspective();\n selectCenteredValue();\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n if (event.key === 'Escape') {\n event.preventDefault();\n onEscape();\n return;\n }\n\n const index = options.findIndex((option) => option.value === selected);\n let nextIndex = index;\n if (event.key === 'ArrowDown') nextIndex = Math.min(index + 1, options.length - 1);\n if (event.key === 'ArrowUp') nextIndex = Math.max(index - 1, 0);\n if (event.key === 'Home') nextIndex = 0;\n if (event.key === 'End') nextIndex = options.length - 1;\n const nextOption = options[nextIndex];\n if (nextIndex !== index && nextOption !== undefined) {\n event.preventDefault();\n onSelect(nextOption.value);\n }\n }\n\n function handlePointerDown(event: ReactPointerEvent<HTMLDivElement>) {\n if (event.button !== 0) return;\n if (typeof event.currentTarget.setPointerCapture === 'function') {\n event.currentTarget.setPointerCapture(event.pointerId);\n }\n dragRef.current = {\n pointerId: event.pointerId,\n scrollTop: event.currentTarget.scrollTop,\n startY: event.clientY,\n };\n ignoreClickRef.current = false;\n }\n\n function handlePointerMove(event: ReactPointerEvent<HTMLDivElement>) {\n const drag = dragRef.current;\n if (drag?.pointerId !== event.pointerId) return;\n const distance = event.clientY - drag.startY;\n if (Math.abs(distance) > 3) {\n ignoreClickRef.current = true;\n event.currentTarget.scrollTop = drag.scrollTop - distance;\n }\n }\n\n function handlePointerUp(event: ReactPointerEvent<HTMLDivElement>) {\n if (dragRef.current?.pointerId !== event.pointerId) return;\n dragRef.current = undefined;\n if (typeof event.currentTarget.releasePointerCapture === 'function') {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n selectCenteredValue();\n }\n\n return (\n <div\n aria-label={ariaLabel}\n className=\"chayns-date-time-picker__wheel\"\n onKeyDown={handleKeyDown}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onScroll={handleScroll}\n ref={wheelRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {Array.from({ length: WHEEL_LOOP_CYCLES }, (_, cycle) =>\n options.map((option, optionIndex) => (\n <button\n aria-selected={option.value === selected}\n className=\"chayns-date-time-picker__wheel-option\"\n data-wheel-index={cycle * options.length + optionIndex}\n key={`${cycle}-${option.value}`}\n onClick={(event) => {\n if (ignoreClickRef.current) {\n event.preventDefault();\n event.stopPropagation();\n ignoreClickRef.current = false;\n return;\n }\n onSelect(option.value);\n }}\n ref={\n cycle === WHEEL_CENTER_CYCLE && option.value === selected ? selectedRef : undefined\n }\n role=\"option\"\n type=\"button\"\n >\n {option.label}\n </button>\n )),\n )}\n </div>\n );\n}\n\nconst DateTimePicker = forwardRef<HTMLButtonElement, DateTimePickerProps>(function DateTimePicker(\n {\n className,\n disabled,\n id,\n label,\n locale,\n maxDate,\n minDate,\n minuteStep = 1,\n mode = 'time',\n onChange,\n onClick,\n onKeyDown,\n placeholder,\n value,\n wheelLabels,\n ...buttonProps\n },\n ref,\n) {\n if (!DATE_TIME_PICKER_MINUTE_STEPS.includes(minuteStep)) {\n throw new Error('DateTimePicker minuteStep must be one of: 1, 5, 15, 30.');\n }\n\n if (\n minDate !== undefined &&\n maxDate !== undefined &&\n dateAtMidnight(minDate) > dateAtMidnight(maxDate)\n ) {\n throw new Error('DateTimePicker requires minDate to be earlier than or equal to maxDate.');\n }\n\n const generatedId = useId();\n const triggerId = id ?? generatedId;\n const popupId = `${triggerId}-popup`;\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [open, setOpen] = useState(false);\n const displayValue =\n value === null\n ? null\n : mode === 'date'\n ? clampDate(value, minDate, maxDate)\n : normalizeMinute(value, minuteStep);\n const activeValue = displayValue ?? new Date();\n const isTwelveHour =\n new Intl.DateTimeFormat(locale, { hour: 'numeric' }).resolvedOptions().hour12 === true;\n\n useEffect(() => {\n if (!open) return undefined;\n function closeOnOutsidePress(event: PointerEvent) {\n if (event.target instanceof Node && !rootRef.current?.contains(event.target)) close();\n }\n document.addEventListener('pointerdown', closeOnOutsidePress);\n return () => document.removeEventListener('pointerdown', closeOnOutsidePress);\n });\n\n const years = useMemo(() => {\n const today = new Date().getFullYear();\n const first = minDate?.getFullYear() ?? today - 100;\n const last = maxDate?.getFullYear() ?? today + 100;\n return Array.from({ length: last - first + 1 }, (_, index) => first + index);\n }, [maxDate, minDate]);\n\n function close() {\n setOpen(false);\n triggerRef.current?.focus();\n }\n\n function emit(nextValue: Date) {\n onChange(mode === 'date' ? clampDate(nextValue, minDate, maxDate) : nextValue);\n }\n\n function updateTime(part: 'hours' | 'minutes', nextValue: number) {\n const next = new Date(activeValue);\n if (part === 'hours') {\n const hour = isTwelveHour ? (nextValue % 12) + (next.getHours() >= 12 ? 12 : 0) : nextValue;\n next.setHours(hour);\n } else {\n next.setMinutes(nextValue);\n }\n emit(next);\n }\n\n function updatePeriod(period: number) {\n const next = new Date(activeValue);\n next.setHours((next.getHours() % 12) + period * 12);\n emit(next);\n }\n\n function updateDate(part: DatePart, nextValue: number) {\n const next = new Date(activeValue);\n const originalDay = next.getDate();\n next.setDate(1);\n if (part === 'fullYear') next.setFullYear(nextValue);\n if (part === 'month') next.setMonth(nextValue);\n if (part === 'date') next.setDate(nextValue);\n if (part !== 'date') {\n next.setDate(\n Math.min(originalDay, new Date(next.getFullYear(), next.getMonth() + 1, 0).getDate()),\n );\n }\n emit(next);\n }\n\n const formattedValue =\n displayValue === null\n ? placeholder\n : mode === 'time'\n ? `${new Intl.DateTimeFormat(locale, {\n hour: 'numeric',\n minute: '2-digit',\n }).format(displayValue)}${locale.toLowerCase().startsWith('de') ? ' Uhr' : ''}`\n : new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n }).format(displayValue);\n const hours = Array.from({ length: isTwelveHour ? 12 : 24 }, (_, index) =>\n isTwelveHour ? index + 1 : index,\n ).map((hour) => ({ label: String(hour).padStart(2, '0'), value: hour }));\n const minutes = Array.from({ length: 60 / minuteStep }, (_, index) => {\n const minute = index * minuteStep;\n return { label: String(minute).padStart(2, '0'), value: minute };\n });\n const months = Array.from({ length: 12 }, (_, month) => ({\n label: new Intl.DateTimeFormat(locale, { month: 'long' }).format(new Date(2026, month, 1)),\n value: month,\n })).filter((month) => {\n const first = new Date(activeValue.getFullYear(), month.value, 1);\n const last = new Date(activeValue.getFullYear(), month.value + 1, 0);\n return (\n (minDate === undefined || last >= dateAtMidnight(minDate)) &&\n (maxDate === undefined || first <= dateAtMidnight(maxDate))\n );\n });\n const days = Array.from(\n { length: new Date(activeValue.getFullYear(), activeValue.getMonth() + 1, 0).getDate() },\n (_, index) => ({ label: String(index + 1).padStart(2, '0'), value: index + 1 }),\n ).filter((day) => {\n const candidate = new Date(activeValue.getFullYear(), activeValue.getMonth(), day.value);\n return (\n (minDate === undefined || candidate >= dateAtMidnight(minDate)) &&\n (maxDate === undefined || candidate <= dateAtMidnight(maxDate))\n );\n });\n const datePartOrder = new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'numeric',\n year: 'numeric',\n })\n .formatToParts(activeValue)\n .flatMap<DatePart>((part) => {\n if (part.type === 'day') return ['date'];\n if (part.type === 'month') return ['month'];\n if (part.type === 'year') return ['fullYear'];\n return [];\n });\n const yearOptions = years.map((year) => ({ label: String(year), value: year }));\n\n function dateOptions(part: DatePart) {\n if (part === 'date') return days;\n if (part === 'month') return months;\n return yearOptions;\n }\n\n function dateValue(part: DatePart) {\n if (part === 'date') return activeValue.getDate();\n if (part === 'month') return activeValue.getMonth();\n return activeValue.getFullYear();\n }\n const dayPeriods = [0, 1].map((period) => ({\n label:\n new Intl.DateTimeFormat(locale, { hour: 'numeric' })\n .formatToParts(new Date(2026, 0, 1, period === 0 ? 1 : 13))\n .find((part) => part.type === 'dayPeriod')?.value ?? (period === 0 ? 'AM' : 'PM'),\n value: period,\n }));\n const resolvedClassName = [\n 'chayns-date-time-picker',\n `chayns-date-time-picker--${mode}`,\n open ? 'chayns-date-time-picker--open' : '',\n displayValue !== null ? 'chayns-date-time-picker--filled' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div className={resolvedClassName} ref={rootRef}>\n <button\n {...buttonProps}\n aria-controls={open ? popupId : undefined}\n aria-expanded={open}\n aria-haspopup=\"dialog\"\n className={['chayns-date-time-picker__trigger', className].filter(Boolean).join(' ')}\n disabled={disabled}\n id={triggerId}\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) setOpen((current) => !current);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.key === 'Escape' && open && !event.defaultPrevented) {\n event.preventDefault();\n close();\n }\n }}\n ref={(element) => {\n triggerRef.current = element;\n if (typeof ref === 'function') ref(element);\n else if (ref !== null) ref.current = element;\n }}\n type=\"button\"\n >\n {formattedValue}\n </button>\n <label className=\"chayns-date-time-picker__label\" htmlFor={triggerId}>\n {label}\n </label>\n {open && !disabled ? (\n <div\n aria-label={label}\n className=\"chayns-date-time-picker__popup\"\n id={popupId}\n role=\"dialog\"\n >\n <div className=\"chayns-date-time-picker__selection\" />\n <div className=\"chayns-date-time-picker__wheels\">\n {mode === 'time' ? (\n <>\n <Wheel\n ariaLabel={wheelLabels.hour}\n onEscape={close}\n onSelect={(hour) => updateTime('hours', hour)}\n options={hours}\n selected={\n isTwelveHour ? activeValue.getHours() % 12 || 12 : activeValue.getHours()\n }\n />\n <Wheel\n ariaLabel={wheelLabels.minute}\n onEscape={close}\n onSelect={(minute) => updateTime('minutes', minute)}\n options={minutes}\n selected={activeValue.getMinutes()}\n />\n {isTwelveHour ? (\n <Wheel\n ariaLabel={wheelLabels.dayPeriod}\n onEscape={close}\n onSelect={updatePeriod}\n options={dayPeriods}\n selected={activeValue.getHours() >= 12 ? 1 : 0}\n />\n ) : null}\n </>\n ) : (\n datePartOrder.map((part) => (\n <Wheel\n ariaLabel={\n part === 'date'\n ? wheelLabels.day\n : part === 'month'\n ? wheelLabels.month\n : wheelLabels.year\n }\n key={part}\n onEscape={close}\n onSelect={(nextValue) => updateDate(part, nextValue)}\n options={dateOptions(part)}\n selected={dateValue(part)}\n />\n ))\n )}\n </div>\n </div>\n ) : null}\n </div>\n );\n});\n\nexport default DateTimePicker;\n"],"mappings":";;;;AAKA,IAAM,oBAAoB;AAC1B,IAAM,qBAAqB,KAAK,MAAM,oBAAoB,CAAC;AAgB3D,SAAS,eAAe,OAAa;CACnC,OAAO,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC;AACxE;AAEA,SAAS,UAAU,OAAa,SAAgB,SAAgB;CAC9D,MAAM,OAAO,eAAe,KAAK;CACjC,IAAI,YAAY,KAAA,KAAa,OAAO,eAAe,OAAO,GAAG,OAAO,IAAI,KAAK,OAAO;CACpF,IAAI,YAAY,KAAA,KAAa,OAAO,eAAe,OAAO,GAAG,OAAO,IAAI,KAAK,OAAO;CACpF,OAAO;AACT;AAEA,SAAS,gBAAgB,OAAa,YAAoB;CACxD,MAAM,aAAa,IAAI,KAAK,KAAK;CACjC,WAAW,WAAW,KAAK,MAAM,WAAW,WAAW,IAAI,UAAU,IAAI,UAAU;CACnF,OAAO;AACT;AAEA,SAAS,MAAM,EAAE,WAAW,UAAU,UAAU,SAAS,YAAwB;CAC/E,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,cAAc,OAA0B,IAAI;CAClD,MAAM,UAAU,OACd,KAAA,CACF;CACA,MAAM,iBAAiB,OAAO,KAAK;CAEnC,gBAAgB;EACd,IAAI,OAAO,YAAY,SAAS,mBAAmB,YACjD,YAAY,QAAQ,eAAe,EAAE,OAAO,SAAS,CAAC;CAE1D,GA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;UACrC,IAAI,QAAQ,MAAM,IAAI,UAAU;IACvC;IACA,MAAK;IAEJ,UAAA;GACK,CAAA;GACR,oBAAC,SAAD;IAAO,WAAU;IAAiC,SAAS;IACxD,UAAA;GACI,CAAA;GACN,QAAQ,CAAC,WACR,qBAAC,OAAD;IACE,cAAY;IACZ,WAAU;IACV,IAAI;IACJ,MAAK;IAJP,UAAA,CAME,oBAAC,OAAD,EAAK,WAAU,qCAAsC,CAAA,GACrD,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,SAAS,SACR,qBAAA,YAAA,EAAA,UAAA;MACE,oBAAC,OAAD;OACE,WAAW,YAAY;OACvB,UAAU;OACV,WAAW,SAAS,WAAW,SAAS,IAAI;OAC5C,SAAS;OACT,UACE,eAAe,YAAY,SAAS,IAAI,MAAM,KAAK,YAAY,SAAS;MAE3E,CAAA;MACD,oBAAC,OAAD;OACE,WAAW,YAAY;OACvB,UAAU;OACV,WAAW,WAAW,WAAW,WAAW,MAAM;OAClD,SAAS;OACT,UAAU,YAAY,WAAW;MAClC,CAAA;MACA,eACC,oBAAC,OAAD;OACE,WAAW,YAAY;OACvB,UAAU;OACV,UAAU;OACV,SAAS;OACT,UAAU,YAAY,SAAS,KAAK,KAAK,IAAI;MAC9C,CAAA,IACC;KACJ,EAAA,CAAA,IAEF,cAAc,KAAK,SACjB,oBAAC,OAAD;MACE,WACE,SAAS,SACL,YAAY,MACZ,SAAS,UACP,YAAY,QACZ,YAAY;MAGpB,UAAU;MACV,WAAW,cAAc,WAAW,MAAM,SAAS;MACnD,SAAS,YAAY,IAAI;MACzB,UAAU,UAAU,IAAI;KACzB,GALM,IAKN,CACF;IAEA,CAAA,CACF;GACH,CAAA,IAAA;EACD;;AAET,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
2
|
+
export declare const DATE_TIME_PICKER_MODES: readonly ["date", "time"];
|
|
3
|
+
export declare const DATE_TIME_PICKER_MINUTE_STEPS: readonly [1, 5, 15, 30];
|
|
4
|
+
export type DateTimePickerMode = (typeof DATE_TIME_PICKER_MODES)[number];
|
|
5
|
+
export type DateTimePickerMinuteStep = (typeof DATE_TIME_PICKER_MINUTE_STEPS)[number];
|
|
6
|
+
export interface DateTimePickerWheelLabels {
|
|
7
|
+
day: string;
|
|
8
|
+
dayPeriod: string;
|
|
9
|
+
hour: string;
|
|
10
|
+
minute: string;
|
|
11
|
+
month: string;
|
|
12
|
+
year: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DateTimePickerProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-controls' | 'aria-expanded' | 'aria-haspopup' | 'aria-label' | 'aria-labelledby' | 'children' | 'onChange' | 'type' | 'value'> {
|
|
15
|
+
label: string;
|
|
16
|
+
locale: string;
|
|
17
|
+
minDate?: Date;
|
|
18
|
+
maxDate?: Date;
|
|
19
|
+
minuteStep?: DateTimePickerMinuteStep;
|
|
20
|
+
mode?: DateTimePickerMode;
|
|
21
|
+
onChange: (value: Date) => void;
|
|
22
|
+
placeholder: string;
|
|
23
|
+
value: Date | null;
|
|
24
|
+
wheelLabels: DateTimePickerWheelLabels;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=DateTimePicker.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePicker.types.d.ts","sourceRoot":"","sources":["../../../src/components/date-time-picker/DateTimePicker.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,eAAO,MAAM,sBAAsB,2BAA4B,CAAC;AAChE,eAAO,MAAM,6BAA6B,yBAA0B,CAAC;AAErE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AACzE,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtF,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,qBAAqB,CAAC,QAAQ,CAAC,EAC7B,eAAe,GACf,eAAe,GACf,eAAe,GACf,YAAY,GACZ,iBAAiB,GACjB,UAAU,GACV,UAAU,GACV,MAAM,GACN,OAAO,CACV;IACC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,WAAW,EAAE,yBAAyB,CAAC;CACxC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/components/date-time-picker/DateTimePicker.types.ts
|
|
2
|
+
var DATE_TIME_PICKER_MODES = ["date", "time"];
|
|
3
|
+
var DATE_TIME_PICKER_MINUTE_STEPS = [
|
|
4
|
+
1,
|
|
5
|
+
5,
|
|
6
|
+
15,
|
|
7
|
+
30
|
|
8
|
+
];
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DATE_TIME_PICKER_MINUTE_STEPS, DATE_TIME_PICKER_MODES };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=DateTimePicker.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePicker.types.js","names":[],"sources":["../../../src/components/date-time-picker/DateTimePicker.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react';\n\nexport const DATE_TIME_PICKER_MODES = ['date', 'time'] as const;\nexport const DATE_TIME_PICKER_MINUTE_STEPS = [1, 5, 15, 30] as const;\n\nexport type DateTimePickerMode = (typeof DATE_TIME_PICKER_MODES)[number];\nexport type DateTimePickerMinuteStep = (typeof DATE_TIME_PICKER_MINUTE_STEPS)[number];\n\nexport interface DateTimePickerWheelLabels {\n day: string;\n dayPeriod: string;\n hour: string;\n minute: string;\n month: string;\n year: string;\n}\n\nexport interface DateTimePickerProps extends Omit<\n ComponentPropsWithRef<'button'>,\n | 'aria-controls'\n | 'aria-expanded'\n | 'aria-haspopup'\n | 'aria-label'\n | 'aria-labelledby'\n | 'children'\n | 'onChange'\n | 'type'\n | 'value'\n> {\n label: string;\n locale: string;\n minDate?: Date;\n maxDate?: Date;\n minuteStep?: DateTimePickerMinuteStep;\n mode?: DateTimePickerMode;\n onChange: (value: Date) => void;\n placeholder: string;\n value: Date | null;\n wheelLabels: DateTimePickerWheelLabels;\n}\n"],"mappings":";AAEA,IAAa,yBAAyB,CAAC,QAAQ,MAAM;AACrD,IAAa,gCAAgC;CAAC;CAAG;CAAG;CAAI;AAAE"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const IconButton: import("react").ForwardRefExoticComponent<(Omit<import("./IconButton.types.js").IconButtonBaseProps & {
|
|
2
|
+
'aria-label': string;
|
|
3
|
+
'aria-labelledby'?: never;
|
|
4
|
+
}, "ref"> | Omit<import("./IconButton.types.js").IconButtonBaseProps & {
|
|
5
|
+
'aria-label'?: never;
|
|
6
|
+
'aria-labelledby': string;
|
|
7
|
+
}, "ref">) & import("react").RefAttributes<HTMLButtonElement>>;
|
|
3
8
|
export default IconButton;
|
|
4
9
|
//# sourceMappingURL=IconButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../src/components/icon-button/IconButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../src/components/icon-button/IconButton.tsx"],"names":[],"mappings":"AAKA,QAAA,MAAM,UAAU;;;;;;8DAkCd,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import ButtonIcon from "../button/button-icon/ButtonIcon.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
//#region src/components/icon-button/IconButton.tsx
|
|
4
|
-
function IconButton({ className, icon, type = "button", variant, ...buttonProps }) {
|
|
5
|
+
var IconButton = forwardRef(function IconButton({ "aria-busy": ariaBusy, className, disabled, icon, loading = false, type = "button", variant, ...buttonProps }, ref) {
|
|
5
6
|
const resolvedClassName = [
|
|
6
7
|
"chayns-icon-button",
|
|
7
8
|
`chayns-icon-button--${variant}`,
|
|
9
|
+
loading ? "chayns-icon-button--loading" : "",
|
|
8
10
|
className
|
|
9
11
|
].filter(Boolean).join(" ");
|
|
10
12
|
return /* @__PURE__ */ jsx("button", {
|
|
11
13
|
...buttonProps,
|
|
14
|
+
"aria-busy": loading ? true : ariaBusy,
|
|
12
15
|
className: resolvedClassName,
|
|
16
|
+
disabled: loading || disabled,
|
|
17
|
+
ref,
|
|
13
18
|
type,
|
|
14
|
-
children: /* @__PURE__ */ jsx(ButtonIcon, { icon })
|
|
19
|
+
children: /* @__PURE__ */ jsx(ButtonIcon, { icon: loading ? "fa-spinner" : icon })
|
|
15
20
|
});
|
|
16
|
-
}
|
|
21
|
+
});
|
|
17
22
|
//#endregion
|
|
18
23
|
export { IconButton as default };
|
|
19
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","names":[],"sources":["../../../src/components/icon-button/IconButton.tsx"],"sourcesContent":["import type { IconButtonProps } from './IconButton.types.js';\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\n\
|
|
1
|
+
{"version":3,"file":"IconButton.js","names":[],"sources":["../../../src/components/icon-button/IconButton.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport type { IconButtonProps } from './IconButton.types.js';\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\n\nconst IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n {\n 'aria-busy': ariaBusy,\n className,\n disabled,\n icon,\n loading = false,\n type = 'button',\n variant,\n ...buttonProps\n },\n ref,\n) {\n const resolvedClassName = [\n 'chayns-icon-button',\n `chayns-icon-button--${variant}`,\n loading ? 'chayns-icon-button--loading' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n {...buttonProps}\n aria-busy={loading ? true : ariaBusy}\n className={resolvedClassName}\n disabled={loading || disabled}\n ref={ref}\n type={type}\n >\n <ButtonIcon icon={loading ? 'fa-spinner' : icon} />\n </button>\n );\n});\n\nexport default IconButton;\n"],"mappings":";;;;AAKA,IAAM,aAAa,WAA+C,SAAS,WACzE,EACE,aAAa,UACb,WACA,UACA,MACA,UAAU,OACV,OAAO,UACP,SACA,GAAG,eAEL,KACA;CACA,MAAM,oBAAoB;EACxB;EACA,uBAAuB;EACvB,UAAU,gCAAgC;EAC1C;CACF,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,OACE,oBAAC,UAAD;EACE,GAAI;EACJ,aAAW,UAAU,OAAO;EAC5B,WAAW;EACX,UAAU,WAAW;EAChB;EACC;EAEN,UAAA,oBAAC,YAAD,EAAY,MAAM,UAAU,eAAe,KAAO,CAAA;CAC5C,CAAA;AAEZ,CAAC"}
|
|
@@ -20,7 +20,7 @@ type IconButtonAccessibleName = {
|
|
|
20
20
|
*/
|
|
21
21
|
'aria-labelledby': string;
|
|
22
22
|
};
|
|
23
|
-
interface IconButtonBaseProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-label' | 'aria-labelledby' | 'children'> {
|
|
23
|
+
export interface IconButtonBaseProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-label' | 'aria-labelledby' | 'children'> {
|
|
24
24
|
/**
|
|
25
25
|
* @description Visual emphasis that communicates the action's role within
|
|
26
26
|
* its action scope, using the same four values as `Button`.
|
|
@@ -33,6 +33,8 @@ interface IconButtonBaseProps extends Omit<ComponentPropsWithRef<'button'>, 'ari
|
|
|
33
33
|
* so this is its only visible content.
|
|
34
34
|
*/
|
|
35
35
|
icon: ButtonIcon;
|
|
36
|
+
/** Shows a spinner while preserving the accessible name and disabling the action. */
|
|
37
|
+
loading?: boolean;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* @description Props for a compact, icon-only native action button. Does not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.types.d.ts","sourceRoot":"","sources":["../../../src/components/icon-button/IconButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE3E;;;;GAIG;AACH,KAAK,wBAAwB,GACzB;IACE;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,KAAK,CAAC;CAC3B,GACD;IACE,YAAY,CAAC,EAAE,KAAK,CAAC;IAErB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEN,
|
|
1
|
+
{"version":3,"file":"IconButton.types.d.ts","sourceRoot":"","sources":["../../../src/components/icon-button/IconButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE3E;;;;GAIG;AACH,KAAK,wBAAwB,GACzB;IACE;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,KAAK,CAAC;CAC3B,GACD;IACE,YAAY,CAAC,EAAE,KAAK,CAAC;IAErB;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEN,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,qBAAqB,CAAC,QAAQ,CAAC,EAC/B,YAAY,GAAG,iBAAiB,GAAG,UAAU,CAC9C;IACC;;;OAGG;IACH,OAAO,EAAE,aAAa,CAAC;IAEvB;;;;;OAKG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,wBAAwB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ListContext, ListItemContext, useListContext, useListItemContext } from "./ListContext.js";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { forwardRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/list/List.tsx
|
|
5
5
|
var Item = forwardRef(function Item({ children, className, ...itemProps }, ref) {
|
|
6
6
|
useListContext();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { cloneElement, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useId, useRef, useState } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
//#region src/components/popup/Popup.tsx
|
|
5
5
|
var PopupContext = createContext(null);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ButtonIcon from "../button/button-icon/ButtonIcon.js";
|
|
2
2
|
import Popup_default from "./Popup.js";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
3
|
import { useRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/popup/PopupList.tsx
|
|
6
6
|
var PopupList = ({ className, items, trigger }) => {
|
|
7
7
|
const itemRefs = useRef([]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/components/radio-group/RadioGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/components/radio-group/RadioGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAgFzE,QAAA,MAAM,UAAU;;CAA2C,CAAC;AAE5D,eAAe,UAAU,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RadioGroupContext, useRadioGroupContext } from "./RadioGroupContext.js";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { forwardRef, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/radio-group/RadioGroup.tsx
|
|
5
|
-
var Radio = forwardRef(function Radio({ children, className, disabled, value, ...inputProps }, ref) {
|
|
5
|
+
var Radio = forwardRef(function Radio({ children, className, description, disabled, onChange, value, ...inputProps }, ref) {
|
|
6
6
|
const group = useRadioGroupContext();
|
|
7
7
|
const isDisabled = group.disabled || disabled === true;
|
|
8
8
|
const inputClassName = ["chayns-radio__input", className].filter(Boolean).join(" ");
|
|
@@ -15,7 +15,10 @@ var Radio = forwardRef(function Radio({ children, className, disabled, value, ..
|
|
|
15
15
|
className: inputClassName,
|
|
16
16
|
disabled: isDisabled,
|
|
17
17
|
name: group.name,
|
|
18
|
-
onChange: () =>
|
|
18
|
+
onChange: (event) => {
|
|
19
|
+
onChange?.(event);
|
|
20
|
+
if (!event.defaultPrevented) group.selectValue(value);
|
|
21
|
+
},
|
|
19
22
|
ref,
|
|
20
23
|
type: "radio",
|
|
21
24
|
value
|
|
@@ -24,9 +27,15 @@ var Radio = forwardRef(function Radio({ children, className, disabled, value, ..
|
|
|
24
27
|
"aria-hidden": "true",
|
|
25
28
|
className: "chayns-radio__control"
|
|
26
29
|
}),
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
className: "chayns-
|
|
29
|
-
children
|
|
30
|
+
/* @__PURE__ */ jsxs("span", {
|
|
31
|
+
className: "chayns-radio__content",
|
|
32
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
33
|
+
className: "chayns-radio__label",
|
|
34
|
+
children
|
|
35
|
+
}), description !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: "chayns-radio__description",
|
|
37
|
+
children: description
|
|
38
|
+
}) : null]
|
|
30
39
|
})
|
|
31
40
|
]
|
|
32
41
|
});
|
|
@@ -52,10 +61,10 @@ var RadioGroupRoot = forwardRef(function RadioGroupRoot({ children, className, d
|
|
|
52
61
|
className: resolvedClassName,
|
|
53
62
|
disabled,
|
|
54
63
|
ref,
|
|
55
|
-
children: [/* @__PURE__ */ jsx("legend", {
|
|
64
|
+
children: [label !== void 0 ? /* @__PURE__ */ jsx("legend", {
|
|
56
65
|
className: "chayns-radio-group__legend",
|
|
57
66
|
children: label
|
|
58
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
67
|
+
}) : null, /* @__PURE__ */ jsx("div", {
|
|
59
68
|
className: "chayns-radio-group__options",
|
|
60
69
|
children
|
|
61
70
|
})]
|