@epilot/spark-ui 0.28.2 → 0.30.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/dist/calendar-lists-CTby2kR5.d.cts +27 -0
- package/dist/calendar-lists-DoloqsCN.d.ts +27 -0
- package/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/attachment.cjs +1 -1
- package/dist/components/attachment.js +1 -1
- package/dist/components/autocomplete.cjs +1 -0
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.js +1 -0
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.d.cts +1 -1
- package/dist/components/avatar.d.ts +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/banner.cjs +1 -1
- package/dist/components/banner.d.cts +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/box.d.cts +1 -1
- package/dist/components/box.d.ts +1 -1
- package/dist/components/box.js +1 -1
- package/dist/components/breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/bubble.cjs +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.d.cts +1 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.cjs +17 -17
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +3 -3
- package/dist/components/button.d.ts +3 -3
- package/dist/components/button.js +17 -17
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.cjs +23 -4
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.d.cts +11 -2
- package/dist/components/calendar.d.ts +11 -2
- package/dist/components/calendar.js +23 -4
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/card.cjs +1 -1
- package/dist/components/card.d.cts +1 -1
- package/dist/components/card.d.ts +1 -1
- package/dist/components/card.js +2 -2
- package/dist/components/checkbox-group.d.cts +1 -1
- package/dist/components/checkbox-group.d.ts +1 -1
- package/dist/components/checkbox.d.cts +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/combobox.cjs +45 -15
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.d.cts +3 -1
- package/dist/components/combobox.d.ts +3 -1
- package/dist/components/combobox.js +46 -16
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/empty-state.cjs +1 -1
- package/dist/components/empty-state.js +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/field.cjs +58 -17
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +8 -4
- package/dist/components/field.d.ts +8 -4
- package/dist/components/field.js +58 -17
- package/dist/components/field.js.map +1 -1
- package/dist/components/hero-metric.cjs +1 -1
- package/dist/components/hero-metric.js +1 -1
- package/dist/components/info-block.cjs +1 -1
- package/dist/components/info-block.js +1 -1
- package/dist/components/input-date-time.cjs +212 -0
- package/dist/components/input-date-time.cjs.map +1 -0
- package/dist/components/input-date-time.d.cts +38 -0
- package/dist/components/input-date-time.d.ts +38 -0
- package/dist/components/input-date-time.js +205 -0
- package/dist/components/input-date-time.js.map +1 -0
- package/dist/components/input-group.cjs +72 -4
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +6 -1
- package/dist/components/input-group.d.ts +6 -1
- package/dist/components/input-group.js +72 -5
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.cjs +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input.cjs +7 -4
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +8 -5
- package/dist/components/input.js.map +1 -1
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.d.cts +1 -1
- package/dist/components/list.d.ts +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +1 -1
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.js +1 -1
- package/dist/components/pill.d.cts +1 -1
- package/dist/components/pill.d.ts +1 -1
- package/dist/components/popover.cjs +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/radio.d.cts +1 -1
- package/dist/components/radio.d.ts +1 -1
- package/dist/components/segmented-control.d.cts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/select.cjs +4 -2
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +1 -1
- package/dist/components/select.d.ts +1 -1
- package/dist/components/select.js +4 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +15 -18
- package/dist/components/separator.cjs.map +1 -1
- package/dist/components/separator.d.cts +3 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +16 -19
- package/dist/components/separator.js.map +1 -1
- package/dist/components/skeleton.cjs +20 -5
- package/dist/components/skeleton.cjs.map +1 -1
- package/dist/components/skeleton.d.cts +9 -5
- package/dist/components/skeleton.d.ts +9 -5
- package/dist/components/skeleton.js +19 -6
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/spinner.cjs +8 -81
- package/dist/components/spinner.cjs.map +1 -1
- package/dist/components/spinner.js +8 -81
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/switch-group.d.cts +1 -1
- package/dist/components/switch-group.d.ts +1 -1
- package/dist/components/switch.d.cts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/textarea.cjs +7 -4
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.d.cts +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +7 -4
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.d.cts +1 -1
- package/dist/components/theme.d.ts +1 -1
- package/dist/components/theme.js +1 -1
- package/dist/components/toggle-group.d.cts +1 -1
- package/dist/components/toggle-group.d.ts +1 -1
- package/dist/components/toggle.cjs +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.cjs +29 -25
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.d.cts +4 -2
- package/dist/components/tooltip.d.ts +4 -2
- package/dist/components/tooltip.js +29 -25
- package/dist/components/tooltip.js.map +1 -1
- package/dist/lib/accent-theme.cjs +75 -17
- package/dist/lib/accent-theme.cjs.map +1 -1
- package/dist/lib/accent-theme.d.cts +15 -2
- package/dist/lib/accent-theme.d.ts +15 -2
- package/dist/lib/accent-theme.js +74 -18
- package/dist/lib/accent-theme.js.map +1 -1
- package/dist/lib/calendar-lists.cjs +222 -0
- package/dist/lib/calendar-lists.cjs.map +1 -0
- package/dist/lib/calendar-lists.d.cts +4 -0
- package/dist/lib/calendar-lists.d.ts +4 -0
- package/dist/lib/calendar-lists.js +217 -0
- package/dist/lib/calendar-lists.js.map +1 -0
- package/dist/lib/container-chrome.d.cts +1 -1
- package/dist/lib/container-chrome.d.ts +1 -1
- package/dist/lib/control-glyphs.cjs +37 -0
- package/dist/lib/control-glyphs.cjs.map +1 -0
- package/dist/lib/control-glyphs.d.cts +11 -0
- package/dist/lib/control-glyphs.d.ts +11 -0
- package/dist/lib/control-glyphs.js +35 -0
- package/dist/lib/control-glyphs.js.map +1 -0
- package/dist/lib/date-time-mask.cjs +155 -0
- package/dist/lib/date-time-mask.cjs.map +1 -0
- package/dist/lib/date-time-mask.d.cts +56 -0
- package/dist/lib/date-time-mask.d.ts +56 -0
- package/dist/lib/date-time-mask.js +147 -0
- package/dist/lib/date-time-mask.js.map +1 -0
- package/dist/lib/input-box-variants.cjs +11 -0
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +6 -2
- package/dist/lib/input-box-variants.d.ts +6 -2
- package/dist/lib/input-box-variants.js +8 -1
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/input-date-parts.cjs +154 -0
- package/dist/lib/input-date-parts.cjs.map +1 -0
- package/dist/lib/input-date-parts.d.cts +53 -0
- package/dist/lib/input-date-parts.d.ts +53 -0
- package/dist/lib/input-date-parts.js +147 -0
- package/dist/lib/input-date-parts.js.map +1 -0
- package/dist/lib/selection-list.d.cts +1 -1
- package/dist/lib/selection-list.d.ts +1 -1
- package/dist/lib/theme-types.cjs.map +1 -1
- package/dist/lib/theme-types.d.cts +1 -1
- package/dist/lib/theme-types.d.ts +1 -1
- package/dist/lib/theme-types.js.map +1 -1
- package/dist/lib/toggle-group-context.d.cts +1 -1
- package/dist/lib/toggle-group-context.d.ts +1 -1
- package/dist/styles/spark-default.css +369 -25
- package/dist/styles/theme.css +18 -98
- package/dist/{theme-types-Dlge0s3s.d.ts → theme-types-CHl-L2F-.d.cts} +2 -2
- package/dist/{theme-types-Dlge0s3s.d.cts → theme-types-CHl-L2F-.d.ts} +2 -2
- package/package.json +3 -2
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
|
+
const require_lib_date_time_mask = require("./date-time-mask.cjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
react = require_chunk.__toESM(react);
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let ictus_time = require("ictus/time");
|
|
10
|
+
let cn = require("cn");
|
|
11
|
+
//#region src/lib/input-date-parts.tsx
|
|
12
|
+
const MINUTES_PER_DAY = 1440;
|
|
13
|
+
const MIN_STEP = 5;
|
|
14
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
15
|
+
function timesOf(step, extra) {
|
|
16
|
+
const times = [];
|
|
17
|
+
for (let minutes = 0; minutes < MINUTES_PER_DAY; minutes += Math.max(MIN_STEP, step)) times.push((0, ictus_time.formatTime)({
|
|
18
|
+
hours: Math.floor(minutes / 60),
|
|
19
|
+
minutes: minutes % 60,
|
|
20
|
+
seconds: 0
|
|
21
|
+
}));
|
|
22
|
+
if (extra && !times.includes(extra)) {
|
|
23
|
+
const after = times.findIndex((time) => time > extra);
|
|
24
|
+
times.splice(after === -1 ? times.length : after, 0, extra);
|
|
25
|
+
}
|
|
26
|
+
return times;
|
|
27
|
+
}
|
|
28
|
+
function TimeList({ defaultTime, label, onPick, open, selectedTime, times }) {
|
|
29
|
+
const listRef = react.useRef(null);
|
|
30
|
+
react.useEffect(() => {
|
|
31
|
+
if (!open) return;
|
|
32
|
+
const frame = requestAnimationFrame(() => {
|
|
33
|
+
listRef.current?.querySelector("[aria-selected=\"true\"]")?.scrollIntoView?.({ block: "center" });
|
|
34
|
+
});
|
|
35
|
+
return () => cancelAnimationFrame(frame);
|
|
36
|
+
}, [open]);
|
|
37
|
+
const moveFocus = (event) => {
|
|
38
|
+
const options = Array.from(listRef.current?.querySelectorAll("[role=\"option\"]") ?? []);
|
|
39
|
+
const index = options.indexOf(document.activeElement);
|
|
40
|
+
const target = {
|
|
41
|
+
ArrowDown: index + 1,
|
|
42
|
+
ArrowUp: index - 1,
|
|
43
|
+
End: options.length - 1,
|
|
44
|
+
Home: 0
|
|
45
|
+
}[event.key];
|
|
46
|
+
if (target === void 0) return;
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
options[Math.max(0, Math.min(options.length - 1, target))]?.focus();
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
51
|
+
className: "relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l",
|
|
52
|
+
"data-slot": "input-date-times",
|
|
53
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
54
|
+
"aria-label": label,
|
|
55
|
+
className: "absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2",
|
|
56
|
+
onKeyDown: moveFocus,
|
|
57
|
+
ref: listRef,
|
|
58
|
+
role: "listbox",
|
|
59
|
+
tabIndex: -1,
|
|
60
|
+
children: times.map((time) => {
|
|
61
|
+
const isSelected = time === selectedTime;
|
|
62
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
63
|
+
"aria-selected": isSelected,
|
|
64
|
+
className: (0, cn.cn)("shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline", isSelected && "bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))"),
|
|
65
|
+
onClick: () => onPick(time),
|
|
66
|
+
role: "option",
|
|
67
|
+
tabIndex: isSelected || !selectedTime && time === defaultTime ? 0 : -1,
|
|
68
|
+
type: "button",
|
|
69
|
+
children: time
|
|
70
|
+
}, time);
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
76
|
+
function useMaskHandlers({ commit, inputRef, onKeyDown, onOpen, onPaste, onRejectedKey, pickerOnly, separator, withTime }) {
|
|
77
|
+
const placeCaret = (caret) => {
|
|
78
|
+
const input = inputRef.current;
|
|
79
|
+
requestAnimationFrame(() => {
|
|
80
|
+
input?.setSelectionRange(caret, caret);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const handleKeyDown = (event) => {
|
|
84
|
+
onKeyDown?.(event);
|
|
85
|
+
if (event.defaultPrevented) return;
|
|
86
|
+
if (event.key === "ArrowDown") {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
onOpen();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
92
|
+
if (!require_lib_date_time_mask.isDateTimeMaskKey(event.key, withTime)) {
|
|
93
|
+
if (event.key.length === 1) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
onRejectedKey();
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
const next = require_lib_date_time_mask.applyDateTimeMask({
|
|
101
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
102
|
+
key: event.key,
|
|
103
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
104
|
+
separator,
|
|
105
|
+
value: event.currentTarget.value,
|
|
106
|
+
withTime
|
|
107
|
+
});
|
|
108
|
+
commit(next.value);
|
|
109
|
+
placeCaret(next.caret);
|
|
110
|
+
};
|
|
111
|
+
const handlePaste = (event) => {
|
|
112
|
+
onPaste?.(event);
|
|
113
|
+
if (event.defaultPrevented || pickerOnly) return;
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
const next = require_lib_date_time_mask.applyDateTimePaste({
|
|
116
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
117
|
+
pasted: event.clipboardData.getData("text"),
|
|
118
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
119
|
+
separator,
|
|
120
|
+
value: event.currentTarget.value,
|
|
121
|
+
withTime
|
|
122
|
+
});
|
|
123
|
+
commit(next.value);
|
|
124
|
+
placeCaret(next.caret);
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
onKeyDown: handleKeyDown,
|
|
128
|
+
onPaste: handlePaste
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** A polite message that is read again when it repeats. */
|
|
132
|
+
function useAnnouncement() {
|
|
133
|
+
const [message, setMessage] = react.useState({
|
|
134
|
+
text: "",
|
|
135
|
+
count: 0
|
|
136
|
+
});
|
|
137
|
+
const announce = react.useCallback((text) => setMessage((current) => ({
|
|
138
|
+
text,
|
|
139
|
+
count: current.count + 1
|
|
140
|
+
})), []);
|
|
141
|
+
return [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
142
|
+
"aria-live": "polite",
|
|
143
|
+
className: "sr-only",
|
|
144
|
+
"data-slot": "input-date-status",
|
|
145
|
+
children: [message.text, message.count % 2 ? "\xA0" : ""]
|
|
146
|
+
}), announce];
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
exports.TimeList = TimeList;
|
|
150
|
+
exports.timesOf = timesOf;
|
|
151
|
+
exports.useAnnouncement = useAnnouncement;
|
|
152
|
+
exports.useMaskHandlers = useMaskHandlers;
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=input-date-parts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-date-parts.cjs","names":["React","isDateTimeMaskKey","applyDateTimeMask","applyDateTimePaste"],"sources":["../../src/lib/input-date-parts.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport {\n applyDateTimeMask,\n applyDateTimePaste,\n formatTime,\n isDateTimeMaskKey,\n} from './date-time-mask'\n\nconst MINUTES_PER_DAY = 24 * 60\n// a finer step would list hundreds of buttons; a typed off-grid time is still offered\nconst MIN_STEP = 5\n\n/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */\nexport function timesOf(step: number, extra?: string) {\n const times: string[] = []\n for (\n let minutes = 0;\n minutes < MINUTES_PER_DAY;\n minutes += Math.max(MIN_STEP, step)\n ) {\n times.push(\n formatTime({\n hours: Math.floor(minutes / 60),\n minutes: minutes % 60,\n seconds: 0,\n }),\n )\n }\n if (extra && !times.includes(extra)) {\n const after = times.findIndex((time) => time > extra)\n times.splice(after === -1 ? times.length : after, 0, extra)\n }\n return times\n}\n\nexport function TimeList({\n defaultTime,\n label,\n onPick,\n open,\n selectedTime,\n times,\n}: {\n defaultTime: string\n label?: string\n onPick: (time: string) => void\n open: boolean\n selectedTime?: string\n times: string[]\n}) {\n const listRef = React.useRef<HTMLDivElement>(null)\n\n // the picked time scrolls into view when the popup opens; found in the DOM rather than with a ref per option\n React.useEffect(() => {\n if (!open) return\n const frame = requestAnimationFrame(() => {\n listRef.current\n ?.querySelector('[aria-selected=\"true\"]')\n ?.scrollIntoView?.({ block: 'center' })\n })\n return () => cancelAnimationFrame(frame)\n }, [open])\n\n const moveFocus = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const options = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>('[role=\"option\"]') ??\n [],\n )\n const index = options.indexOf(document.activeElement as HTMLButtonElement)\n const target = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n End: options.length - 1,\n Home: 0,\n }[event.key]\n if (target === undefined) return\n event.preventDefault()\n options[Math.max(0, Math.min(options.length - 1, target))]?.focus()\n }\n\n return (\n // the column runs the calendar's full height and the list scrolls inside it\n <div\n className=\"relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l\"\n data-slot=\"input-date-times\"\n >\n <div\n aria-label={label}\n className=\"absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2\"\n onKeyDown={moveFocus}\n ref={listRef}\n role=\"listbox\"\n tabIndex={-1}\n >\n {times.map((time) => {\n const isSelected = time === selectedTime\n return (\n <button\n aria-selected={isSelected}\n className={cn(\n 'shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline',\n isSelected &&\n 'bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))',\n )}\n key={time}\n onClick={() => onPick(time)}\n role=\"option\"\n tabIndex={\n isSelected || (!selectedTime && time === defaultTime) ? 0 : -1\n }\n type=\"button\"\n >\n {time}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n\ntype MaskHandlers = {\n commit: (next: string) => void\n inputRef: React.RefObject<HTMLInputElement | null>\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n onOpen: () => void\n onPaste?: React.ClipboardEventHandler<HTMLInputElement>\n onRejectedKey: () => void\n pickerOnly: boolean\n separator: string\n withTime: boolean\n}\n\n/** Keystrokes and pastes through the date (and time) mask. */\nexport function useMaskHandlers({\n commit,\n inputRef,\n onKeyDown,\n onOpen,\n onPaste,\n onRejectedKey,\n pickerOnly,\n separator,\n withTime,\n}: MaskHandlers) {\n const placeCaret = (caret: number) => {\n const input = inputRef.current\n requestAnimationFrame(() => {\n input?.setSelectionRange(caret, caret)\n })\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n onOpen()\n return\n }\n if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return\n if (!isDateTimeMaskKey(event.key, withTime)) {\n // a printable key the mask ignores: say why nothing appeared\n if (event.key.length === 1) {\n event.preventDefault()\n onRejectedKey()\n }\n return\n }\n event.preventDefault()\n const next = applyDateTimeMask({\n caret: event.currentTarget.selectionStart ?? 0,\n key: event.key,\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event)\n if (event.defaultPrevented || pickerOnly) return\n event.preventDefault()\n const next = applyDateTimePaste({\n caret: event.currentTarget.selectionStart ?? 0,\n pasted: event.clipboardData.getData('text'),\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n return { onKeyDown: handleKeyDown, onPaste: handlePaste }\n}\n\n/** A polite message that is read again when it repeats. */\nexport function useAnnouncement() {\n const [message, setMessage] = React.useState({ text: '', count: 0 })\n const announce = React.useCallback(\n (text: string) =>\n setMessage((current) => ({ text, count: current.count + 1 })),\n [],\n )\n // the trailing no-break space alternates, so a repeated message is new text and read again\n const region = (\n <span aria-live=\"polite\" className=\"sr-only\" data-slot=\"input-date-status\">\n {message.text}\n {message.count % 2 ? ' ' : ''}\n </span>\n )\n return [region, announce] as const\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,kBAAkB;AAExB,MAAM,WAAW;;AAGjB,SAAgB,QAAQ,MAAc,OAAgB;CACpD,MAAM,QAAkB,CAAC;CACzB,KACE,IAAI,UAAU,GACd,UAAU,iBACV,WAAW,KAAK,IAAI,UAAU,IAAI,GAElC,MAAM,MAAA,GAAA,WAAA,YACO;EACT,OAAO,KAAK,MAAM,UAAU,EAAE;EAC9B,SAAS,UAAU;EACnB,SAAS;CACX,CAAC,CACH;CAEF,IAAI,SAAS,CAAC,MAAM,SAAS,KAAK,GAAG;EACnC,MAAM,QAAQ,MAAM,WAAW,SAAS,OAAO,KAAK;EACpD,MAAM,OAAO,UAAU,KAAK,MAAM,SAAS,OAAO,GAAG,KAAK;CAC5D;CACA,OAAO;AACT;AAEA,SAAgB,SAAS,EACvB,aACA,OACA,QACA,MACA,cACA,SAQC;CACD,MAAM,UAAUA,MAAM,OAAuB,IAAI;CAGjD,MAAM,gBAAgB;EACpB,IAAI,CAAC,MAAM;EACX,MAAM,QAAQ,4BAA4B;GACxC,QAAQ,SACJ,cAAc,0BAAwB,GACtC,iBAAiB,EAAE,OAAO,SAAS,CAAC;EAC1C,CAAC;EACD,aAAa,qBAAqB,KAAK;CACzC,GAAG,CAAC,IAAI,CAAC;CAET,MAAM,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|
2
|
+
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/input-date-parts.d.ts
|
|
6
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
7
|
+
declare function timesOf(step: number, extra?: string): string[];
|
|
8
|
+
declare function TimeList({
|
|
9
|
+
defaultTime,
|
|
10
|
+
label,
|
|
11
|
+
onPick,
|
|
12
|
+
open,
|
|
13
|
+
selectedTime,
|
|
14
|
+
times
|
|
15
|
+
}: {
|
|
16
|
+
defaultTime: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
onPick: (time: string) => void;
|
|
19
|
+
open: boolean;
|
|
20
|
+
selectedTime?: string;
|
|
21
|
+
times: string[];
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
type MaskHandlers = {
|
|
24
|
+
commit: (next: string) => void;
|
|
25
|
+
inputRef: React$1.RefObject<HTMLInputElement | null>;
|
|
26
|
+
onKeyDown?: React$1.KeyboardEventHandler<HTMLInputElement>;
|
|
27
|
+
onOpen: () => void;
|
|
28
|
+
onPaste?: React$1.ClipboardEventHandler<HTMLInputElement>;
|
|
29
|
+
onRejectedKey: () => void;
|
|
30
|
+
pickerOnly: boolean;
|
|
31
|
+
separator: string;
|
|
32
|
+
withTime: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
35
|
+
declare function useMaskHandlers({
|
|
36
|
+
commit,
|
|
37
|
+
inputRef,
|
|
38
|
+
onKeyDown,
|
|
39
|
+
onOpen,
|
|
40
|
+
onPaste,
|
|
41
|
+
onRejectedKey,
|
|
42
|
+
pickerOnly,
|
|
43
|
+
separator,
|
|
44
|
+
withTime
|
|
45
|
+
}: MaskHandlers): {
|
|
46
|
+
onKeyDown: (event: React$1.KeyboardEvent<HTMLInputElement>) => void;
|
|
47
|
+
onPaste: (event: React$1.ClipboardEvent<HTMLInputElement>) => void;
|
|
48
|
+
};
|
|
49
|
+
/** A polite message that is read again when it repeats. */
|
|
50
|
+
declare function useAnnouncement(): readonly [import("react/jsx-runtime").JSX.Element, (text: string) => void];
|
|
51
|
+
//#endregion
|
|
52
|
+
export { TimeList, timesOf, useAnnouncement, useMaskHandlers };
|
|
53
|
+
//# sourceMappingURL=input-date-parts.d.cts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/input-date-parts.d.ts
|
|
6
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
7
|
+
declare function timesOf(step: number, extra?: string): string[];
|
|
8
|
+
declare function TimeList({
|
|
9
|
+
defaultTime,
|
|
10
|
+
label,
|
|
11
|
+
onPick,
|
|
12
|
+
open,
|
|
13
|
+
selectedTime,
|
|
14
|
+
times
|
|
15
|
+
}: {
|
|
16
|
+
defaultTime: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
onPick: (time: string) => void;
|
|
19
|
+
open: boolean;
|
|
20
|
+
selectedTime?: string;
|
|
21
|
+
times: string[];
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
type MaskHandlers = {
|
|
24
|
+
commit: (next: string) => void;
|
|
25
|
+
inputRef: React$1.RefObject<HTMLInputElement | null>;
|
|
26
|
+
onKeyDown?: React$1.KeyboardEventHandler<HTMLInputElement>;
|
|
27
|
+
onOpen: () => void;
|
|
28
|
+
onPaste?: React$1.ClipboardEventHandler<HTMLInputElement>;
|
|
29
|
+
onRejectedKey: () => void;
|
|
30
|
+
pickerOnly: boolean;
|
|
31
|
+
separator: string;
|
|
32
|
+
withTime: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
35
|
+
declare function useMaskHandlers({
|
|
36
|
+
commit,
|
|
37
|
+
inputRef,
|
|
38
|
+
onKeyDown,
|
|
39
|
+
onOpen,
|
|
40
|
+
onPaste,
|
|
41
|
+
onRejectedKey,
|
|
42
|
+
pickerOnly,
|
|
43
|
+
separator,
|
|
44
|
+
withTime
|
|
45
|
+
}: MaskHandlers): {
|
|
46
|
+
onKeyDown: (event: React$1.KeyboardEvent<HTMLInputElement>) => void;
|
|
47
|
+
onPaste: (event: React$1.ClipboardEvent<HTMLInputElement>) => void;
|
|
48
|
+
};
|
|
49
|
+
/** A polite message that is read again when it repeats. */
|
|
50
|
+
declare function useAnnouncement(): readonly [import("react/jsx-runtime").JSX.Element, (text: string) => void];
|
|
51
|
+
//#endregion
|
|
52
|
+
export { TimeList, timesOf, useAnnouncement, useMaskHandlers };
|
|
53
|
+
//# sourceMappingURL=input-date-parts.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
|
+
import { applyDateTimeMask, applyDateTimePaste, formatTime, isDateTimeMaskKey } from "./date-time-mask.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/lib/input-date-parts.tsx
|
|
8
|
+
const MINUTES_PER_DAY = 1440;
|
|
9
|
+
const MIN_STEP = 5;
|
|
10
|
+
/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */
|
|
11
|
+
function timesOf(step, extra) {
|
|
12
|
+
const times = [];
|
|
13
|
+
for (let minutes = 0; minutes < MINUTES_PER_DAY; minutes += Math.max(MIN_STEP, step)) times.push(formatTime({
|
|
14
|
+
hours: Math.floor(minutes / 60),
|
|
15
|
+
minutes: minutes % 60,
|
|
16
|
+
seconds: 0
|
|
17
|
+
}));
|
|
18
|
+
if (extra && !times.includes(extra)) {
|
|
19
|
+
const after = times.findIndex((time) => time > extra);
|
|
20
|
+
times.splice(after === -1 ? times.length : after, 0, extra);
|
|
21
|
+
}
|
|
22
|
+
return times;
|
|
23
|
+
}
|
|
24
|
+
function TimeList({ defaultTime, label, onPick, open, selectedTime, times }) {
|
|
25
|
+
const listRef = React$1.useRef(null);
|
|
26
|
+
React$1.useEffect(() => {
|
|
27
|
+
if (!open) return;
|
|
28
|
+
const frame = requestAnimationFrame(() => {
|
|
29
|
+
listRef.current?.querySelector("[aria-selected=\"true\"]")?.scrollIntoView?.({ block: "center" });
|
|
30
|
+
});
|
|
31
|
+
return () => cancelAnimationFrame(frame);
|
|
32
|
+
}, [open]);
|
|
33
|
+
const moveFocus = (event) => {
|
|
34
|
+
const options = Array.from(listRef.current?.querySelectorAll("[role=\"option\"]") ?? []);
|
|
35
|
+
const index = options.indexOf(document.activeElement);
|
|
36
|
+
const target = {
|
|
37
|
+
ArrowDown: index + 1,
|
|
38
|
+
ArrowUp: index - 1,
|
|
39
|
+
End: options.length - 1,
|
|
40
|
+
Home: 0
|
|
41
|
+
}[event.key];
|
|
42
|
+
if (target === void 0) return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
options[Math.max(0, Math.min(options.length - 1, target))]?.focus();
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: "relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l",
|
|
48
|
+
"data-slot": "input-date-times",
|
|
49
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
50
|
+
"aria-label": label,
|
|
51
|
+
className: "absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2",
|
|
52
|
+
onKeyDown: moveFocus,
|
|
53
|
+
ref: listRef,
|
|
54
|
+
role: "listbox",
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
children: times.map((time) => {
|
|
57
|
+
const isSelected = time === selectedTime;
|
|
58
|
+
return /* @__PURE__ */ jsx("button", {
|
|
59
|
+
"aria-selected": isSelected,
|
|
60
|
+
className: cn("shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline", isSelected && "bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))"),
|
|
61
|
+
onClick: () => onPick(time),
|
|
62
|
+
role: "option",
|
|
63
|
+
tabIndex: isSelected || !selectedTime && time === defaultTime ? 0 : -1,
|
|
64
|
+
type: "button",
|
|
65
|
+
children: time
|
|
66
|
+
}, time);
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** Keystrokes and pastes through the date (and time) mask. */
|
|
72
|
+
function useMaskHandlers({ commit, inputRef, onKeyDown, onOpen, onPaste, onRejectedKey, pickerOnly, separator, withTime }) {
|
|
73
|
+
const placeCaret = (caret) => {
|
|
74
|
+
const input = inputRef.current;
|
|
75
|
+
requestAnimationFrame(() => {
|
|
76
|
+
input?.setSelectionRange(caret, caret);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const handleKeyDown = (event) => {
|
|
80
|
+
onKeyDown?.(event);
|
|
81
|
+
if (event.defaultPrevented) return;
|
|
82
|
+
if (event.key === "ArrowDown") {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
onOpen();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
88
|
+
if (!isDateTimeMaskKey(event.key, withTime)) {
|
|
89
|
+
if (event.key.length === 1) {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
onRejectedKey();
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
const next = applyDateTimeMask({
|
|
97
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
98
|
+
key: event.key,
|
|
99
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
100
|
+
separator,
|
|
101
|
+
value: event.currentTarget.value,
|
|
102
|
+
withTime
|
|
103
|
+
});
|
|
104
|
+
commit(next.value);
|
|
105
|
+
placeCaret(next.caret);
|
|
106
|
+
};
|
|
107
|
+
const handlePaste = (event) => {
|
|
108
|
+
onPaste?.(event);
|
|
109
|
+
if (event.defaultPrevented || pickerOnly) return;
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
const next = applyDateTimePaste({
|
|
112
|
+
caret: event.currentTarget.selectionStart ?? 0,
|
|
113
|
+
pasted: event.clipboardData.getData("text"),
|
|
114
|
+
selectionEnd: event.currentTarget.selectionEnd ?? void 0,
|
|
115
|
+
separator,
|
|
116
|
+
value: event.currentTarget.value,
|
|
117
|
+
withTime
|
|
118
|
+
});
|
|
119
|
+
commit(next.value);
|
|
120
|
+
placeCaret(next.caret);
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
onKeyDown: handleKeyDown,
|
|
124
|
+
onPaste: handlePaste
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** A polite message that is read again when it repeats. */
|
|
128
|
+
function useAnnouncement() {
|
|
129
|
+
const [message, setMessage] = React$1.useState({
|
|
130
|
+
text: "",
|
|
131
|
+
count: 0
|
|
132
|
+
});
|
|
133
|
+
const announce = React$1.useCallback((text) => setMessage((current) => ({
|
|
134
|
+
text,
|
|
135
|
+
count: current.count + 1
|
|
136
|
+
})), []);
|
|
137
|
+
return [/* @__PURE__ */ jsxs("span", {
|
|
138
|
+
"aria-live": "polite",
|
|
139
|
+
className: "sr-only",
|
|
140
|
+
"data-slot": "input-date-status",
|
|
141
|
+
children: [message.text, message.count % 2 ? "\xA0" : ""]
|
|
142
|
+
}), announce];
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { TimeList, timesOf, useAnnouncement, useMaskHandlers };
|
|
146
|
+
|
|
147
|
+
//# sourceMappingURL=input-date-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-date-parts.js","names":["React"],"sources":["../../src/lib/input-date-parts.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport {\n applyDateTimeMask,\n applyDateTimePaste,\n formatTime,\n isDateTimeMaskKey,\n} from './date-time-mask'\n\nconst MINUTES_PER_DAY = 24 * 60\n// a finer step would list hundreds of buttons; a typed off-grid time is still offered\nconst MIN_STEP = 5\n\n/** `HH:MM` every `step` minutes (5 at least), plus `extra` when it is off that grid. */\nexport function timesOf(step: number, extra?: string) {\n const times: string[] = []\n for (\n let minutes = 0;\n minutes < MINUTES_PER_DAY;\n minutes += Math.max(MIN_STEP, step)\n ) {\n times.push(\n formatTime({\n hours: Math.floor(minutes / 60),\n minutes: minutes % 60,\n seconds: 0,\n }),\n )\n }\n if (extra && !times.includes(extra)) {\n const after = times.findIndex((time) => time > extra)\n times.splice(after === -1 ? times.length : after, 0, extra)\n }\n return times\n}\n\nexport function TimeList({\n defaultTime,\n label,\n onPick,\n open,\n selectedTime,\n times,\n}: {\n defaultTime: string\n label?: string\n onPick: (time: string) => void\n open: boolean\n selectedTime?: string\n times: string[]\n}) {\n const listRef = React.useRef<HTMLDivElement>(null)\n\n // the picked time scrolls into view when the popup opens; found in the DOM rather than with a ref per option\n React.useEffect(() => {\n if (!open) return\n const frame = requestAnimationFrame(() => {\n listRef.current\n ?.querySelector('[aria-selected=\"true\"]')\n ?.scrollIntoView?.({ block: 'center' })\n })\n return () => cancelAnimationFrame(frame)\n }, [open])\n\n const moveFocus = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const options = Array.from(\n listRef.current?.querySelectorAll<HTMLButtonElement>('[role=\"option\"]') ??\n [],\n )\n const index = options.indexOf(document.activeElement as HTMLButtonElement)\n const target = {\n ArrowDown: index + 1,\n ArrowUp: index - 1,\n End: options.length - 1,\n Home: 0,\n }[event.key]\n if (target === undefined) return\n event.preventDefault()\n options[Math.max(0, Math.min(options.length - 1, target))]?.focus()\n }\n\n return (\n // the column runs the calendar's full height and the list scrolls inside it\n <div\n className=\"relative border-gray-a4 max-sm:h-40 max-sm:border-t sm:w-24 sm:border-l\"\n data-slot=\"input-date-times\"\n >\n <div\n aria-label={label}\n className=\"absolute inset-0 flex flex-col gap-0.5 overflow-y-auto p-2\"\n onKeyDown={moveFocus}\n ref={listRef}\n role=\"listbox\"\n tabIndex={-1}\n >\n {times.map((time) => {\n const isSelected = time === selectedTime\n return (\n <button\n aria-selected={isSelected}\n className={cn(\n 'shrink-0 cursor-pointer rounded-md px-3 py-1.5 text-center text-sm text-gray hover:bg-gray-a3 focus-visible:focus-outline',\n isSelected &&\n 'bg-(--spark-style-bg,var(--color-primary)) text-(--spark-style-fg,var(--color-primary-foreground)) hover:bg-(--spark-style-bg-hover,var(--color-primary-hover))',\n )}\n key={time}\n onClick={() => onPick(time)}\n role=\"option\"\n tabIndex={\n isSelected || (!selectedTime && time === defaultTime) ? 0 : -1\n }\n type=\"button\"\n >\n {time}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n\ntype MaskHandlers = {\n commit: (next: string) => void\n inputRef: React.RefObject<HTMLInputElement | null>\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n onOpen: () => void\n onPaste?: React.ClipboardEventHandler<HTMLInputElement>\n onRejectedKey: () => void\n pickerOnly: boolean\n separator: string\n withTime: boolean\n}\n\n/** Keystrokes and pastes through the date (and time) mask. */\nexport function useMaskHandlers({\n commit,\n inputRef,\n onKeyDown,\n onOpen,\n onPaste,\n onRejectedKey,\n pickerOnly,\n separator,\n withTime,\n}: MaskHandlers) {\n const placeCaret = (caret: number) => {\n const input = inputRef.current\n requestAnimationFrame(() => {\n input?.setSelectionRange(caret, caret)\n })\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n onOpen()\n return\n }\n if (pickerOnly || event.ctrlKey || event.metaKey || event.altKey) return\n if (!isDateTimeMaskKey(event.key, withTime)) {\n // a printable key the mask ignores: say why nothing appeared\n if (event.key.length === 1) {\n event.preventDefault()\n onRejectedKey()\n }\n return\n }\n event.preventDefault()\n const next = applyDateTimeMask({\n caret: event.currentTarget.selectionStart ?? 0,\n key: event.key,\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n onPaste?.(event)\n if (event.defaultPrevented || pickerOnly) return\n event.preventDefault()\n const next = applyDateTimePaste({\n caret: event.currentTarget.selectionStart ?? 0,\n pasted: event.clipboardData.getData('text'),\n selectionEnd: event.currentTarget.selectionEnd ?? undefined,\n separator,\n value: event.currentTarget.value,\n withTime,\n })\n commit(next.value)\n placeCaret(next.caret)\n }\n\n return { onKeyDown: handleKeyDown, onPaste: handlePaste }\n}\n\n/** A polite message that is read again when it repeats. */\nexport function useAnnouncement() {\n const [message, setMessage] = React.useState({ text: '', count: 0 })\n const announce = React.useCallback(\n (text: string) =>\n setMessage((current) => ({ text, count: current.count + 1 })),\n [],\n )\n // the trailing no-break space alternates, so a repeated message is new text and read again\n const region = (\n <span aria-live=\"polite\" className=\"sr-only\" data-slot=\"input-date-status\">\n {message.text}\n {message.count % 2 ? ' ' : ''}\n </span>\n )\n return [region, announce] as const\n}\n"],"mappings":";;;;;;;AAWA,MAAM,kBAAkB;AAExB,MAAM,WAAW;;AAGjB,SAAgB,QAAQ,MAAc,OAAgB;CACpD,MAAM,QAAkB,CAAC;CACzB,KACE,IAAI,UAAU,GACd,UAAU,iBACV,WAAW,KAAK,IAAI,UAAU,IAAI,GAElC,MAAM,KACJ,WAAW;EACT,OAAO,KAAK,MAAM,UAAU,EAAE;EAC9B,SAAS,UAAU;EACnB,SAAS;CACX,CAAC,CACH;CAEF,IAAI,SAAS,CAAC,MAAM,SAAS,KAAK,GAAG;EACnC,MAAM,QAAQ,MAAM,WAAW,SAAS,OAAO,KAAK;EACpD,MAAM,OAAO,UAAU,KAAK,MAAM,SAAS,OAAO,GAAG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;CAAE,EAAE,GAC9D,CAAC,CACH;CAQA,OAAO,CAAC,qBALL,QAAD;EAAM,aAAU;EAAS,WAAU;EAAU,aAAU;YAAvD,CACG,QAAQ,MACR,QAAQ,QAAQ,IAAI,SAAM,EACvB;EAEK,GAAG,QAAQ;AAC1B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { d as SparkInputStyle } from "../theme-types-
|
|
3
|
+
import { d as SparkInputStyle } from "../theme-types-CHl-L2F-.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/selection-list.d.ts
|
|
6
6
|
/** Group chrome per `listStyle`; the group also sets `data-list-style` for its rows. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { d as SparkInputStyle } from "../theme-types-
|
|
3
|
+
import { d as SparkInputStyle } from "../theme-types-CHl-L2F-.js";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/selection-list.d.ts
|
|
6
6
|
/** Group chrome per `listStyle`; the group also sets `data-list-style` for its rows. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-types.cjs","names":[],"sources":["../../src/lib/theme-types.ts"],"sourcesContent":["/** The 6 curated Radix gray families — the only values `getMatchingNeutral` ever returns. */\nexport const SPARK_NEUTRAL_FAMILIES = [\n 'slate',\n 'mauve',\n 'gray',\n 'sage',\n 'olive',\n 'sand',\n] as const\nexport type SparkNeutralFamily = (typeof SPARK_NEUTRAL_FAMILIES)[number]\nexport function isSparkNeutralFamily(\n value: string,\n): value is SparkNeutralFamily {\n return (SPARK_NEUTRAL_FAMILIES as readonly string[]).includes(value)\n}\n\n/**\n * `'auto'` pairs a neutral automatically; one of the 6 curated families picks it by\n * name; any other string is a literal color seed (regenerated against `backgroundColor`\n * exactly like a custom family — see `resolveAutoNeutral`/`generateAccentScale`).\n */\nexport type SparkNeutral = 'auto' | SparkNeutralFamily | (string & {})\nexport type SparkRadius = 'none' | 'small' | 'medium' | 'large' | 'full'\nexport type SparkScaling = '90%' | '95%' | '100%' | '105%' | '110%'\nexport type SparkSpacing = 'dense' | 'default' | 'roomy'\nexport type SparkStyle = 'solid' | 'soft' | 'surface' | 'ghost' | 'outline'\n/**\n * Card chrome variants. `solid` pairs the neutral scale's own background/text\n * extremes (`--neutral-1` fill, `--neutral-12` ink) — the same pairing Radix\n * guarantees stays AA-compliant in both light and dark, so it needs no fixed\n * (non-appearance-tracking) override the way accent's solid ink does.\n */\nexport type SparkCardVariant = SparkStyle\n/**\n * Card container chrome palette. `neutral` (default) paints through the app\n * theme's neutral scale, so a card inherits the configured neutral colour;\n * `accent` tints the card's private mini-scale with the brand accent (chrome\n * only — never the content controls inside). Open union: grows into feedback\n * colours / custom palettes later.\n */\nexport type SparkCardColor = 'neutral' | 'accent'\nexport type SparkLabelPosition = 'outset' | 'inset'\nexport type SparkInputStyle = 'soft' | 'surface' | 'outlined' | 'ghost'\nexport type SparkInputColor = 'brand' | 'gray'\n/** Preferred: `primary` | `neutral` | `destructive`. `accent` / `danger` stay as aliases. */\nexport type SparkButtonColor =\n | 'primary'\n | 'accent'\n | 'neutral'\n | 'destructive'\n | 'danger'\nexport type SparkButtonDesignVariant = 'primary' | 'secondary' | 'tertiary'\nexport type SparkButtonVariant =\n | SparkButtonDesignVariant\n | 'icon'\n | 'danger'\n | 'media'\n | 'link'\n/** A design colour for a button variant; the dark scale is generated from `light` when unset. */\nexport interface SparkButtonDesignColor {\n light: string\n dark?: string\n}\nexport interface SparkButtonRole {\n style?: SparkStyle\n color?: SparkButtonColor | SparkButtonDesignColor\n}\n/** Per-variant `<Button>` look; a nested `<Theme>` replaces only the fields it sets. */\nexport type SparkButtonRoles = Partial<\n Record<SparkButtonDesignVariant, SparkButtonRole>\n>\n"],"mappings":";;;;AACA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,qBACd,OAC6B;CAC7B,OAAQ,uBAA6C,SAAS,KAAK;AACrE"}
|
|
1
|
+
{"version":3,"file":"theme-types.cjs","names":[],"sources":["../../src/lib/theme-types.ts"],"sourcesContent":["/** The 6 curated Radix gray families — the only values `getMatchingNeutral` ever returns. */\nexport const SPARK_NEUTRAL_FAMILIES = [\n 'slate',\n 'mauve',\n 'gray',\n 'sage',\n 'olive',\n 'sand',\n] as const\nexport type SparkNeutralFamily = (typeof SPARK_NEUTRAL_FAMILIES)[number]\nexport function isSparkNeutralFamily(\n value: string,\n): value is SparkNeutralFamily {\n return (SPARK_NEUTRAL_FAMILIES as readonly string[]).includes(value)\n}\n\n/**\n * `'auto'` pairs a neutral automatically; one of the 6 curated families picks it by\n * name; any other string is a literal color seed (regenerated against `backgroundColor`\n * exactly like a custom family — see `resolveAutoNeutral`/`generateAccentScale`).\n */\nexport type SparkNeutral = 'auto' | SparkNeutralFamily | (string & {})\nexport type SparkRadius = 'none' | 'small' | 'medium' | 'large' | 'full'\nexport type SparkScaling = '90%' | '95%' | '100%' | '105%' | '110%'\nexport type SparkSpacing = 'dense' | 'default' | 'roomy'\nexport type SparkStyle = 'solid' | 'soft' | 'surface' | 'ghost' | 'outline'\n/**\n * Card chrome variants. `solid` pairs the neutral scale's own background/text\n * extremes (`--neutral-1` fill, `--neutral-12` ink) — the same pairing Radix\n * guarantees stays AA-compliant in both light and dark, so it needs no fixed\n * (non-appearance-tracking) override the way accent's solid ink does.\n */\nexport type SparkCardVariant = SparkStyle\n/**\n * Card container chrome palette. `neutral` (default) paints through the app\n * theme's neutral scale, so a card inherits the configured neutral colour;\n * `accent` tints the card's private mini-scale with the brand accent (chrome\n * only — never the content controls inside). Open union: grows into feedback\n * colours / custom palettes later.\n */\nexport type SparkCardColor = 'neutral' | 'accent'\nexport type SparkLabelPosition = 'outset' | 'inset' | 'floating'\nexport type SparkInputStyle = 'soft' | 'surface' | 'outlined' | 'ghost'\nexport type SparkInputColor = 'brand' | 'gray'\n/** Preferred: `primary` | `neutral` | `destructive`. `accent` / `danger` stay as aliases. */\nexport type SparkButtonColor =\n | 'primary'\n | 'accent'\n | 'neutral'\n | 'destructive'\n | 'danger'\nexport type SparkButtonDesignVariant = 'primary' | 'secondary' | 'tertiary'\nexport type SparkButtonVariant =\n | SparkButtonDesignVariant\n | 'icon'\n | 'danger'\n | 'media'\n | 'link'\n/** A design colour for a button variant; the dark scale is generated from `light` when unset. */\nexport interface SparkButtonDesignColor {\n light: string\n dark?: string\n}\nexport interface SparkButtonRole {\n style?: SparkStyle\n color?: SparkButtonColor | SparkButtonDesignColor\n}\n/** Per-variant `<Button>` look; a nested `<Theme>` replaces only the fields it sets. */\nexport type SparkButtonRoles = Partial<\n Record<SparkButtonDesignVariant, SparkButtonRole>\n>\n"],"mappings":";;;;AACA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,qBACd,OAC6B;CAC7B,OAAQ,uBAA6C,SAAS,KAAK;AACrE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { _ as SparkSpacing, a as SparkButtonRole, c as SparkCardColor, d as SparkInputStyle, f as SparkLabelPosition, g as SparkScaling, h as SparkRadius, i as SparkButtonDesignVariant, l as SparkCardVariant, m as SparkNeutralFamily, n as SparkButtonColor, o as SparkButtonRoles, p as SparkNeutral, r as SparkButtonDesignColor, s as SparkButtonVariant, t as SPARK_NEUTRAL_FAMILIES, u as SparkInputColor, v as SparkStyle, y as isSparkNeutralFamily } from "../theme-types-
|
|
3
|
+
import { _ as SparkSpacing, a as SparkButtonRole, c as SparkCardColor, d as SparkInputStyle, f as SparkLabelPosition, g as SparkScaling, h as SparkRadius, i as SparkButtonDesignVariant, l as SparkCardVariant, m as SparkNeutralFamily, n as SparkButtonColor, o as SparkButtonRoles, p as SparkNeutral, r as SparkButtonDesignColor, s as SparkButtonVariant, t as SPARK_NEUTRAL_FAMILIES, u as SparkInputColor, v as SparkStyle, y as isSparkNeutralFamily } from "../theme-types-CHl-L2F-.cjs";
|
|
4
4
|
export { SPARK_NEUTRAL_FAMILIES, SparkButtonColor, SparkButtonDesignColor, SparkButtonDesignVariant, SparkButtonRole, SparkButtonRoles, SparkButtonVariant, SparkCardColor, SparkCardVariant, SparkInputColor, SparkInputStyle, SparkLabelPosition, SparkNeutral, SparkNeutralFamily, SparkRadius, SparkScaling, SparkSpacing, SparkStyle, isSparkNeutralFamily };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { _ as SparkSpacing, a as SparkButtonRole, c as SparkCardColor, d as SparkInputStyle, f as SparkLabelPosition, g as SparkScaling, h as SparkRadius, i as SparkButtonDesignVariant, l as SparkCardVariant, m as SparkNeutralFamily, n as SparkButtonColor, o as SparkButtonRoles, p as SparkNeutral, r as SparkButtonDesignColor, s as SparkButtonVariant, t as SPARK_NEUTRAL_FAMILIES, u as SparkInputColor, v as SparkStyle, y as isSparkNeutralFamily } from "../theme-types-
|
|
3
|
+
import { _ as SparkSpacing, a as SparkButtonRole, c as SparkCardColor, d as SparkInputStyle, f as SparkLabelPosition, g as SparkScaling, h as SparkRadius, i as SparkButtonDesignVariant, l as SparkCardVariant, m as SparkNeutralFamily, n as SparkButtonColor, o as SparkButtonRoles, p as SparkNeutral, r as SparkButtonDesignColor, s as SparkButtonVariant, t as SPARK_NEUTRAL_FAMILIES, u as SparkInputColor, v as SparkStyle, y as isSparkNeutralFamily } from "../theme-types-CHl-L2F-.js";
|
|
4
4
|
export { SPARK_NEUTRAL_FAMILIES, SparkButtonColor, SparkButtonDesignColor, SparkButtonDesignVariant, SparkButtonRole, SparkButtonRoles, SparkButtonVariant, SparkCardColor, SparkCardVariant, SparkInputColor, SparkInputStyle, SparkLabelPosition, SparkNeutral, SparkNeutralFamily, SparkRadius, SparkScaling, SparkSpacing, SparkStyle, isSparkNeutralFamily };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-types.js","names":[],"sources":["../../src/lib/theme-types.ts"],"sourcesContent":["/** The 6 curated Radix gray families — the only values `getMatchingNeutral` ever returns. */\nexport const SPARK_NEUTRAL_FAMILIES = [\n 'slate',\n 'mauve',\n 'gray',\n 'sage',\n 'olive',\n 'sand',\n] as const\nexport type SparkNeutralFamily = (typeof SPARK_NEUTRAL_FAMILIES)[number]\nexport function isSparkNeutralFamily(\n value: string,\n): value is SparkNeutralFamily {\n return (SPARK_NEUTRAL_FAMILIES as readonly string[]).includes(value)\n}\n\n/**\n * `'auto'` pairs a neutral automatically; one of the 6 curated families picks it by\n * name; any other string is a literal color seed (regenerated against `backgroundColor`\n * exactly like a custom family — see `resolveAutoNeutral`/`generateAccentScale`).\n */\nexport type SparkNeutral = 'auto' | SparkNeutralFamily | (string & {})\nexport type SparkRadius = 'none' | 'small' | 'medium' | 'large' | 'full'\nexport type SparkScaling = '90%' | '95%' | '100%' | '105%' | '110%'\nexport type SparkSpacing = 'dense' | 'default' | 'roomy'\nexport type SparkStyle = 'solid' | 'soft' | 'surface' | 'ghost' | 'outline'\n/**\n * Card chrome variants. `solid` pairs the neutral scale's own background/text\n * extremes (`--neutral-1` fill, `--neutral-12` ink) — the same pairing Radix\n * guarantees stays AA-compliant in both light and dark, so it needs no fixed\n * (non-appearance-tracking) override the way accent's solid ink does.\n */\nexport type SparkCardVariant = SparkStyle\n/**\n * Card container chrome palette. `neutral` (default) paints through the app\n * theme's neutral scale, so a card inherits the configured neutral colour;\n * `accent` tints the card's private mini-scale with the brand accent (chrome\n * only — never the content controls inside). Open union: grows into feedback\n * colours / custom palettes later.\n */\nexport type SparkCardColor = 'neutral' | 'accent'\nexport type SparkLabelPosition = 'outset' | 'inset'\nexport type SparkInputStyle = 'soft' | 'surface' | 'outlined' | 'ghost'\nexport type SparkInputColor = 'brand' | 'gray'\n/** Preferred: `primary` | `neutral` | `destructive`. `accent` / `danger` stay as aliases. */\nexport type SparkButtonColor =\n | 'primary'\n | 'accent'\n | 'neutral'\n | 'destructive'\n | 'danger'\nexport type SparkButtonDesignVariant = 'primary' | 'secondary' | 'tertiary'\nexport type SparkButtonVariant =\n | SparkButtonDesignVariant\n | 'icon'\n | 'danger'\n | 'media'\n | 'link'\n/** A design colour for a button variant; the dark scale is generated from `light` when unset. */\nexport interface SparkButtonDesignColor {\n light: string\n dark?: string\n}\nexport interface SparkButtonRole {\n style?: SparkStyle\n color?: SparkButtonColor | SparkButtonDesignColor\n}\n/** Per-variant `<Button>` look; a nested `<Theme>` replaces only the fields it sets. */\nexport type SparkButtonRoles = Partial<\n Record<SparkButtonDesignVariant, SparkButtonRole>\n>\n"],"mappings":";;;AACA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,qBACd,OAC6B;CAC7B,OAAQ,uBAA6C,SAAS,KAAK;AACrE"}
|
|
1
|
+
{"version":3,"file":"theme-types.js","names":[],"sources":["../../src/lib/theme-types.ts"],"sourcesContent":["/** The 6 curated Radix gray families — the only values `getMatchingNeutral` ever returns. */\nexport const SPARK_NEUTRAL_FAMILIES = [\n 'slate',\n 'mauve',\n 'gray',\n 'sage',\n 'olive',\n 'sand',\n] as const\nexport type SparkNeutralFamily = (typeof SPARK_NEUTRAL_FAMILIES)[number]\nexport function isSparkNeutralFamily(\n value: string,\n): value is SparkNeutralFamily {\n return (SPARK_NEUTRAL_FAMILIES as readonly string[]).includes(value)\n}\n\n/**\n * `'auto'` pairs a neutral automatically; one of the 6 curated families picks it by\n * name; any other string is a literal color seed (regenerated against `backgroundColor`\n * exactly like a custom family — see `resolveAutoNeutral`/`generateAccentScale`).\n */\nexport type SparkNeutral = 'auto' | SparkNeutralFamily | (string & {})\nexport type SparkRadius = 'none' | 'small' | 'medium' | 'large' | 'full'\nexport type SparkScaling = '90%' | '95%' | '100%' | '105%' | '110%'\nexport type SparkSpacing = 'dense' | 'default' | 'roomy'\nexport type SparkStyle = 'solid' | 'soft' | 'surface' | 'ghost' | 'outline'\n/**\n * Card chrome variants. `solid` pairs the neutral scale's own background/text\n * extremes (`--neutral-1` fill, `--neutral-12` ink) — the same pairing Radix\n * guarantees stays AA-compliant in both light and dark, so it needs no fixed\n * (non-appearance-tracking) override the way accent's solid ink does.\n */\nexport type SparkCardVariant = SparkStyle\n/**\n * Card container chrome palette. `neutral` (default) paints through the app\n * theme's neutral scale, so a card inherits the configured neutral colour;\n * `accent` tints the card's private mini-scale with the brand accent (chrome\n * only — never the content controls inside). Open union: grows into feedback\n * colours / custom palettes later.\n */\nexport type SparkCardColor = 'neutral' | 'accent'\nexport type SparkLabelPosition = 'outset' | 'inset' | 'floating'\nexport type SparkInputStyle = 'soft' | 'surface' | 'outlined' | 'ghost'\nexport type SparkInputColor = 'brand' | 'gray'\n/** Preferred: `primary` | `neutral` | `destructive`. `accent` / `danger` stay as aliases. */\nexport type SparkButtonColor =\n | 'primary'\n | 'accent'\n | 'neutral'\n | 'destructive'\n | 'danger'\nexport type SparkButtonDesignVariant = 'primary' | 'secondary' | 'tertiary'\nexport type SparkButtonVariant =\n | SparkButtonDesignVariant\n | 'icon'\n | 'danger'\n | 'media'\n | 'link'\n/** A design colour for a button variant; the dark scale is generated from `light` when unset. */\nexport interface SparkButtonDesignColor {\n light: string\n dark?: string\n}\nexport interface SparkButtonRole {\n style?: SparkStyle\n color?: SparkButtonColor | SparkButtonDesignColor\n}\n/** Per-variant `<Button>` look; a nested `<Theme>` replaces only the fields it sets. */\nexport type SparkButtonRoles = Partial<\n Record<SparkButtonDesignVariant, SparkButtonRole>\n>\n"],"mappings":";;;AACA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,qBACd,OAC6B;CAC7B,OAAQ,uBAA6C,SAAS,KAAK;AACrE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { n as SparkButtonColor } from "../theme-types-
|
|
3
|
+
import { n as SparkButtonColor } from "../theme-types-CHl-L2F-.cjs";
|
|
4
4
|
import { ButtonProps } from "../components/button.cjs";
|
|
5
5
|
import { ToggleStyle } from "../components/toggle.cjs";
|
|
6
6
|
import * as React$1 from "react";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { n as SparkButtonColor } from "../theme-types-
|
|
3
|
+
import { n as SparkButtonColor } from "../theme-types-CHl-L2F-.js";
|
|
4
4
|
import { ButtonProps } from "../components/button.js";
|
|
5
5
|
import { ToggleStyle } from "../components/toggle.js";
|
|
6
6
|
import * as React$1 from "react";
|