@robert-stackflow/oneui 0.6.40 → 0.6.42
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/CHANGELOG.md +14 -0
- package/README.md +9 -1
- package/components/AccountItem.module.css +103 -103
- package/components/AppShell.module.css +223 -223
- package/components/Badge.module.css +30 -30
- package/components/BarChart.module.css +35 -35
- package/components/Breadcrumb.module.css +97 -97
- package/components/Button.module.css +120 -120
- package/components/Checkbox.module.css +95 -95
- package/components/Control.module.css +86 -86
- package/components/DataTable.module.css +75 -75
- package/components/Form.d.ts +5 -1
- package/components/Form.js +5 -1
- package/components/FormField.js +1 -0
- package/components/HierarchyPicker.module.css +185 -185
- package/components/Indicator.module.css +83 -83
- package/components/Layout.module.css +82 -82
- package/components/Markdown.module.css +227 -227
- package/components/NativeForm.d.ts +10 -0
- package/components/NativeForm.js +155 -0
- package/components/NavBar.module.css +130 -130
- package/components/Progress.module.css +33 -33
- package/components/RadioGroup.module.css +87 -87
- package/components/RangeSlider.module.css +141 -141
- package/components/ResizablePanel.module.css +101 -101
- package/components/ResourceCard.module.css +98 -98
- package/components/Slider.module.css +19 -19
- package/components/Steps.module.css +176 -176
- package/components/Tab.module.css +148 -148
- package/components/ThemePicker.module.css +178 -178
- package/components/TimeColumns.module.css +47 -47
- package/components/Timeline.module.css +202 -202
- package/components/Toast.d.ts +7 -2
- package/components/Toast.js +146 -98
- package/components/Toast.module.css +182 -85
- package/components/ToastProvider.js +19 -62
- package/components/ToastStack.d.ts +8 -0
- package/components/ToastStack.js +190 -0
- package/components/TreeTable.module.css +57 -57
- package/components/UptimeChart.module.css +15 -15
- package/components/field.d.ts +1 -1
- package/components/field.js +2 -1
- package/components/form-validation.d.ts +4 -0
- package/components/form-validation.js +22 -0
- package/components/index.d.ts +4 -2
- package/components/index.js +9 -3
- package/package.json +1 -1
- package/styles/blue.css +270 -270
|
@@ -4,12 +4,10 @@ import {
|
|
|
4
4
|
createContext,
|
|
5
5
|
useContext,
|
|
6
6
|
useState,
|
|
7
|
-
useRef,
|
|
8
|
-
useEffect,
|
|
9
7
|
useSyncExternalStore
|
|
10
8
|
} from "react";
|
|
11
9
|
import { useUIConfig } from "./UIProvider.js";
|
|
12
|
-
import {
|
|
10
|
+
import { ToastStack } from "./ToastStack.js";
|
|
13
11
|
import {
|
|
14
12
|
createToaster
|
|
15
13
|
} from "./createToaster.js";
|
|
@@ -29,68 +27,27 @@ function ToastProvider({
|
|
|
29
27
|
serverSnapshot
|
|
30
28
|
);
|
|
31
29
|
const messages = Array.isArray(snapshot) ? snapshot : snapshot ? [snapshot] : [];
|
|
32
|
-
const [expanded, setExpanded] = useState([]);
|
|
33
|
-
const [heights, setHeights] = useState({});
|
|
34
|
-
const timers = useRef(/* @__PURE__ */ new Map());
|
|
35
|
-
const hover = (position, inside) => {
|
|
36
|
-
clearTimeout(timers.current.get(position));
|
|
37
|
-
if (inside)
|
|
38
|
-
setExpanded((old) => old.includes(position) ? old : [...old, position]);
|
|
39
|
-
else
|
|
40
|
-
timers.current.set(
|
|
41
|
-
position,
|
|
42
|
-
setTimeout(
|
|
43
|
-
() => setExpanded((old) => old.filter((entry) => entry !== position)),
|
|
44
|
-
140
|
|
45
|
-
)
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
useEffect(() => () => timers.current.forEach(clearTimeout), []);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
setHeights((previous) => {
|
|
51
|
-
const ids = new Set(messages.map((message) => String(message.id)));
|
|
52
|
-
return Object.keys(previous).every((id) => ids.has(id)) ? previous : Object.fromEntries(
|
|
53
|
-
Object.entries(previous).filter(([id]) => ids.has(id))
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
}, [snapshot]);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
setExpanded([]);
|
|
59
|
-
setHeights({});
|
|
60
|
-
}, [source.id]);
|
|
61
30
|
const limit = Number.isFinite(maxVisible) ? Math.max(1, Math.floor(maxVisible)) : 3;
|
|
62
31
|
return /* @__PURE__ */ jsxs(Context, { value: source.notify, children: [
|
|
63
32
|
children,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
stackOffset: offset,
|
|
83
|
-
stackExpanded: isExpanded,
|
|
84
|
-
stackHidden: index >= limit,
|
|
85
|
-
paused: isExpanded,
|
|
86
|
-
onHoverChange: (inside) => hover(position, inside),
|
|
87
|
-
onHeightChange: (height) => setHeights(
|
|
88
|
-
(old) => old[toast.id] === height ? old : { ...old, [toast.id]: height }
|
|
89
|
-
)
|
|
90
|
-
},
|
|
91
|
-
`${source.id}-${toast.id}`
|
|
92
|
-
);
|
|
93
|
-
})
|
|
33
|
+
[
|
|
34
|
+
...new Set(
|
|
35
|
+
messages.map(
|
|
36
|
+
(toast) => toast.options?.position || config.toastPosition
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
].map((position) => /* @__PURE__ */ jsx(
|
|
40
|
+
ToastStack,
|
|
41
|
+
{
|
|
42
|
+
position,
|
|
43
|
+
messages: messages.filter(
|
|
44
|
+
(toast) => (toast.options?.position || config.toastPosition) === position
|
|
45
|
+
).toReversed(),
|
|
46
|
+
maxVisible: limit,
|
|
47
|
+
onDismiss: source.clear
|
|
48
|
+
},
|
|
49
|
+
`${source.id}-${position}`
|
|
50
|
+
))
|
|
94
51
|
] });
|
|
95
52
|
}
|
|
96
53
|
const useToast = () => useContext(Context);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToastMessage, ToastPosition } from "./ToastProvider";
|
|
2
|
+
/** One top-layer viewport contains all animation and scrolling for this position. */
|
|
3
|
+
export declare function ToastStack({ position, messages, maxVisible, onDismiss, }: {
|
|
4
|
+
position: ToastPosition;
|
|
5
|
+
messages: readonly ToastMessage[];
|
|
6
|
+
maxVisible: number;
|
|
7
|
+
onDismiss(id: number): void;
|
|
8
|
+
}): import("react").ReactPortal;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState
|
|
8
|
+
} from "react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
import { Toast } from "./Toast.js";
|
|
11
|
+
import { useUIText } from "./useUIText.js";
|
|
12
|
+
import s from "./Toast.module.css";
|
|
13
|
+
function ToastStack({
|
|
14
|
+
position,
|
|
15
|
+
messages,
|
|
16
|
+
maxVisible,
|
|
17
|
+
onDismiss
|
|
18
|
+
}) {
|
|
19
|
+
const { text } = useUIText();
|
|
20
|
+
const [host] = useState(() => document.createElement("div"));
|
|
21
|
+
const viewport = useRef(null);
|
|
22
|
+
const region = useRef(null);
|
|
23
|
+
const interaction = useRef({
|
|
24
|
+
pointer: false,
|
|
25
|
+
focus: false,
|
|
26
|
+
pinned: false,
|
|
27
|
+
suppressed: false
|
|
28
|
+
});
|
|
29
|
+
const timer = useRef(void 0);
|
|
30
|
+
const [expanded, setExpanded] = useState(false);
|
|
31
|
+
const [heights, setHeights] = useState({});
|
|
32
|
+
const newest = messages[0]?.id;
|
|
33
|
+
const sync = () => {
|
|
34
|
+
const state = interaction.current;
|
|
35
|
+
setExpanded(
|
|
36
|
+
state.pinned || !state.suppressed && (state.pointer || state.focus)
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
const collapse = () => {
|
|
40
|
+
interaction.current.pinned = false;
|
|
41
|
+
interaction.current.suppressed = true;
|
|
42
|
+
setExpanded(false);
|
|
43
|
+
region.current?.querySelector("[data-toast-expand]")?.focus({ preventScroll: true });
|
|
44
|
+
};
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
const node = viewport.current;
|
|
47
|
+
host.dataset.toastLayer = "";
|
|
48
|
+
host.style.display = "contents";
|
|
49
|
+
const relocate = () => {
|
|
50
|
+
let dialogs;
|
|
51
|
+
try {
|
|
52
|
+
dialogs = document.querySelectorAll("dialog:modal");
|
|
53
|
+
} catch {
|
|
54
|
+
dialogs = document.querySelectorAll("dialog[open]");
|
|
55
|
+
}
|
|
56
|
+
const parent = dialogs.item(dialogs.length - 1) || document.body;
|
|
57
|
+
if (host.parentElement === parent) return;
|
|
58
|
+
if (node.matches(":popover-open")) node.hidePopover();
|
|
59
|
+
parent.append(host);
|
|
60
|
+
node.showPopover();
|
|
61
|
+
};
|
|
62
|
+
relocate();
|
|
63
|
+
const observer = new MutationObserver(relocate);
|
|
64
|
+
observer.observe(document.body, {
|
|
65
|
+
childList: true,
|
|
66
|
+
subtree: true,
|
|
67
|
+
attributes: true,
|
|
68
|
+
attributeFilter: ["open"]
|
|
69
|
+
});
|
|
70
|
+
return () => {
|
|
71
|
+
observer.disconnect();
|
|
72
|
+
host.remove();
|
|
73
|
+
};
|
|
74
|
+
}, [host]);
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
const node = viewport.current;
|
|
77
|
+
if (node.matches(":popover-open")) node.hidePopover();
|
|
78
|
+
node.showPopover();
|
|
79
|
+
}, [newest]);
|
|
80
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const ids = new Set(messages.map((message) => String(message.id)));
|
|
83
|
+
setHeights(
|
|
84
|
+
(old) => Object.keys(old).every((id) => ids.has(id)) ? old : Object.fromEntries(Object.entries(old).filter(([id]) => ids.has(id)))
|
|
85
|
+
);
|
|
86
|
+
if (messages.length < 2) {
|
|
87
|
+
interaction.current.pinned = false;
|
|
88
|
+
setExpanded(false);
|
|
89
|
+
}
|
|
90
|
+
}, [messages]);
|
|
91
|
+
let offset = 0;
|
|
92
|
+
const frontHeight = heights[newest] ?? 64;
|
|
93
|
+
const offsets = messages.map((toast) => {
|
|
94
|
+
const value = offset;
|
|
95
|
+
offset += (heights[toast.id] ?? 64) + 10;
|
|
96
|
+
return value;
|
|
97
|
+
});
|
|
98
|
+
const height = expanded ? offset - 10 : frontHeight + Math.min(messages.length - 1, maxVisible - 1) * 9;
|
|
99
|
+
useLayoutEffect(() => {
|
|
100
|
+
if (expanded && position.startsWith("bottom") && region.current) {
|
|
101
|
+
region.current.scrollTop = region.current.scrollHeight;
|
|
102
|
+
}
|
|
103
|
+
}, [expanded, position, height]);
|
|
104
|
+
return createPortal(
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
ref: viewport,
|
|
109
|
+
popover: "manual",
|
|
110
|
+
className: s.viewport,
|
|
111
|
+
"data-toast-viewport": true,
|
|
112
|
+
"data-position": position,
|
|
113
|
+
children: /* @__PURE__ */ jsx(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
ref: region,
|
|
117
|
+
className: s.region,
|
|
118
|
+
"data-position": position,
|
|
119
|
+
"data-expanded": expanded,
|
|
120
|
+
role: "region",
|
|
121
|
+
"aria-label": text("\u901A\u77E5", "Notifications", "\u901A\u77E5"),
|
|
122
|
+
onPointerEnter: (event) => {
|
|
123
|
+
if (event.pointerType === "touch") return;
|
|
124
|
+
clearTimeout(timer.current);
|
|
125
|
+
interaction.current.pointer = true;
|
|
126
|
+
sync();
|
|
127
|
+
},
|
|
128
|
+
onPointerLeave: () => {
|
|
129
|
+
interaction.current.pointer = false;
|
|
130
|
+
timer.current = setTimeout(() => {
|
|
131
|
+
interaction.current.suppressed = false;
|
|
132
|
+
sync();
|
|
133
|
+
}, 140);
|
|
134
|
+
},
|
|
135
|
+
onFocus: (event) => {
|
|
136
|
+
clearTimeout(timer.current);
|
|
137
|
+
if (event.target.matches(":focus-visible")) {
|
|
138
|
+
interaction.current.focus = true;
|
|
139
|
+
sync();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
onBlur: (event) => {
|
|
143
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
144
|
+
interaction.current.focus = false;
|
|
145
|
+
if (!interaction.current.pointer)
|
|
146
|
+
interaction.current.suppressed = false;
|
|
147
|
+
sync();
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
onKeyDown: (event) => {
|
|
151
|
+
if (event.key === "Escape" && expanded) {
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
collapse();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
children: /* @__PURE__ */ jsx("div", { className: s.stack, style: { height }, children: messages.map((toast, index) => /* @__PURE__ */ jsx(
|
|
157
|
+
Toast,
|
|
158
|
+
{
|
|
159
|
+
embedded: true,
|
|
160
|
+
toast,
|
|
161
|
+
position,
|
|
162
|
+
onDismiss,
|
|
163
|
+
stackIndex: index,
|
|
164
|
+
stackOffset: expanded ? offsets[index] : index * 9,
|
|
165
|
+
stackExpanded: expanded && messages.length > 1,
|
|
166
|
+
stackHidden: !expanded && index >= maxVisible,
|
|
167
|
+
stackHeight: !expanded && index > 0 ? frontHeight : void 0,
|
|
168
|
+
stackCount: index === 0 ? messages.length : void 0,
|
|
169
|
+
onStackToggle: () => {
|
|
170
|
+
interaction.current.pinned = !expanded;
|
|
171
|
+
interaction.current.suppressed = expanded;
|
|
172
|
+
setExpanded(!expanded);
|
|
173
|
+
},
|
|
174
|
+
paused: expanded || index > 0,
|
|
175
|
+
onHeightChange: (value) => setHeights(
|
|
176
|
+
(old) => old[toast.id] === value ? old : { ...old, [toast.id]: value }
|
|
177
|
+
)
|
|
178
|
+
},
|
|
179
|
+
toast.id
|
|
180
|
+
)) })
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
host
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
ToastStack
|
|
190
|
+
};
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
--table-radius: var(--card-radius);
|
|
3
|
-
border-radius: var(--card-radius);
|
|
4
|
-
background: var(--surface);
|
|
5
|
-
overflow: hidden;
|
|
6
|
-
box-shadow: var(--card-shadow, none);
|
|
7
|
-
}
|
|
8
|
-
.root table td {
|
|
9
|
-
padding: 0 18px;
|
|
10
|
-
border-bottom: 0;
|
|
11
|
-
}
|
|
12
|
-
.root table th {
|
|
13
|
-
padding: 14px 18px;
|
|
14
|
-
}
|
|
15
|
-
.root[data-density="compact"] .cell {
|
|
16
|
-
min-height: 48px;
|
|
17
|
-
padding-block: 8px;
|
|
18
|
-
}
|
|
19
|
-
.root tr:focus-visible {
|
|
20
|
-
outline: 1px solid var(--accent-ink, var(--accent));
|
|
21
|
-
outline-offset: -1px;
|
|
22
|
-
}
|
|
23
|
-
.root table tr[data-tree-root="true"]:not(:first-child) td {
|
|
24
|
-
border-top: 1px solid var(--line);
|
|
25
|
-
}
|
|
26
|
-
.cell {
|
|
27
|
-
--tree-elbow-gap: 8px;
|
|
28
|
-
position: relative;
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: center;
|
|
31
|
-
gap: 8px;
|
|
32
|
-
min-height: 72px;
|
|
33
|
-
padding-block: 14px;
|
|
34
|
-
min-width: 260px;
|
|
35
|
-
white-space: normal;
|
|
36
|
-
}
|
|
37
|
-
.expander,
|
|
38
|
-
.spacer {
|
|
39
|
-
flex: 0 0 24px;
|
|
40
|
-
width: 24px;
|
|
41
|
-
height: 26px;
|
|
42
|
-
}
|
|
43
|
-
.content {
|
|
44
|
-
position: relative;
|
|
45
|
-
flex: 1;
|
|
46
|
-
min-width: 0;
|
|
47
|
-
}
|
|
48
|
-
.expander svg {
|
|
49
|
-
width: 14px;
|
|
50
|
-
height: 14px;
|
|
51
|
-
}
|
|
52
|
-
.expander[aria-expanded="false"] svg {
|
|
53
|
-
rotate: -90deg;
|
|
54
|
-
}
|
|
55
|
-
.expander[aria-expanded="true"] svg {
|
|
56
|
-
rotate: 0deg;
|
|
57
|
-
}
|
|
1
|
+
.root {
|
|
2
|
+
--table-radius: var(--card-radius);
|
|
3
|
+
border-radius: var(--card-radius);
|
|
4
|
+
background: var(--surface);
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
box-shadow: var(--card-shadow, none);
|
|
7
|
+
}
|
|
8
|
+
.root table td {
|
|
9
|
+
padding: 0 18px;
|
|
10
|
+
border-bottom: 0;
|
|
11
|
+
}
|
|
12
|
+
.root table th {
|
|
13
|
+
padding: 14px 18px;
|
|
14
|
+
}
|
|
15
|
+
.root[data-density="compact"] .cell {
|
|
16
|
+
min-height: 48px;
|
|
17
|
+
padding-block: 8px;
|
|
18
|
+
}
|
|
19
|
+
.root tr:focus-visible {
|
|
20
|
+
outline: 1px solid var(--accent-ink, var(--accent));
|
|
21
|
+
outline-offset: -1px;
|
|
22
|
+
}
|
|
23
|
+
.root table tr[data-tree-root="true"]:not(:first-child) td {
|
|
24
|
+
border-top: 1px solid var(--line);
|
|
25
|
+
}
|
|
26
|
+
.cell {
|
|
27
|
+
--tree-elbow-gap: 8px;
|
|
28
|
+
position: relative;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 8px;
|
|
32
|
+
min-height: 72px;
|
|
33
|
+
padding-block: 14px;
|
|
34
|
+
min-width: 260px;
|
|
35
|
+
white-space: normal;
|
|
36
|
+
}
|
|
37
|
+
.expander,
|
|
38
|
+
.spacer {
|
|
39
|
+
flex: 0 0 24px;
|
|
40
|
+
width: 24px;
|
|
41
|
+
height: 26px;
|
|
42
|
+
}
|
|
43
|
+
.content {
|
|
44
|
+
position: relative;
|
|
45
|
+
flex: 1;
|
|
46
|
+
min-width: 0;
|
|
47
|
+
}
|
|
48
|
+
.expander svg {
|
|
49
|
+
width: 14px;
|
|
50
|
+
height: 14px;
|
|
51
|
+
}
|
|
52
|
+
.expander[aria-expanded="false"] svg {
|
|
53
|
+
rotate: -90deg;
|
|
54
|
+
}
|
|
55
|
+
.expander[aria-expanded="true"] svg {
|
|
56
|
+
rotate: 0deg;
|
|
57
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
.chart { display: flex; align-items: center; gap: 3px; width: 100%; min-width: 0; height: 36px; }
|
|
2
|
-
.cell { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; height: 32px; outline: none; transform-origin: center bottom; animation: enter 520ms var(--ease) both; animation-delay: calc(var(--bar-index) * 9ms); }
|
|
3
|
-
.bar { width: 100%; height: 22px; border-radius: 3px; background: var(--line); color: var(--line); transform-origin: center bottom; transition: transform 170ms var(--ease), opacity 170ms var(--ease), box-shadow 170ms var(--ease); }
|
|
4
|
-
.cell[data-state="empty"] .bar { height: 15px; }
|
|
5
|
-
.cell[data-state="up"] .bar { background: var(--success); color: var(--success); }
|
|
6
|
-
.cell[data-state="partial"] .bar { background: var(--warning); color: var(--warning); }
|
|
7
|
-
.cell[data-state="down"] .bar { background: var(--danger); color: var(--danger); }
|
|
8
|
-
.chart:hover .cell:not(:hover):not(:focus-visible) .bar { opacity: .55; }
|
|
9
|
-
.cell:hover, .cell:focus-visible { z-index: 1; }
|
|
10
|
-
.cell:hover .bar, .cell:focus-visible .bar { transform: translateY(-3px) scale(1.25, 1.12); box-shadow: 0 4px 10px color-mix(in srgb, currentColor 22%, transparent); }
|
|
11
|
-
.cell:focus-visible .bar { outline: 2px solid var(--fg); outline-offset: 2px; }
|
|
12
|
-
@keyframes enter { from { opacity: 0; transform: translateY(7px) scaleY(.35); } 62% { opacity: 1; transform: translateY(-2px) scaleY(1.06); } to { opacity: 1; transform: none; } }
|
|
13
|
-
@media (prefers-reduced-motion: reduce) { .cell { animation: none; } .bar { transition: none; } .cell:hover .bar, .cell:focus-visible .bar { transform: none; } }
|
|
14
|
-
|
|
15
|
-
.chart > span { flex: 1; min-width: 0; }
|
|
1
|
+
.chart { display: flex; align-items: center; gap: 3px; width: 100%; min-width: 0; height: 36px; }
|
|
2
|
+
.cell { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; height: 32px; outline: none; transform-origin: center bottom; animation: enter 520ms var(--ease) both; animation-delay: calc(var(--bar-index) * 9ms); }
|
|
3
|
+
.bar { width: 100%; height: 22px; border-radius: 3px; background: var(--line); color: var(--line); transform-origin: center bottom; transition: transform 170ms var(--ease), opacity 170ms var(--ease), box-shadow 170ms var(--ease); }
|
|
4
|
+
.cell[data-state="empty"] .bar { height: 15px; }
|
|
5
|
+
.cell[data-state="up"] .bar { background: var(--success); color: var(--success); }
|
|
6
|
+
.cell[data-state="partial"] .bar { background: var(--warning); color: var(--warning); }
|
|
7
|
+
.cell[data-state="down"] .bar { background: var(--danger); color: var(--danger); }
|
|
8
|
+
.chart:hover .cell:not(:hover):not(:focus-visible) .bar { opacity: .55; }
|
|
9
|
+
.cell:hover, .cell:focus-visible { z-index: 1; }
|
|
10
|
+
.cell:hover .bar, .cell:focus-visible .bar { transform: translateY(-3px) scale(1.25, 1.12); box-shadow: 0 4px 10px color-mix(in srgb, currentColor 22%, transparent); }
|
|
11
|
+
.cell:focus-visible .bar { outline: 2px solid var(--fg); outline-offset: 2px; }
|
|
12
|
+
@keyframes enter { from { opacity: 0; transform: translateY(7px) scaleY(.35); } 62% { opacity: 1; transform: translateY(-2px) scaleY(1.06); } to { opacity: 1; transform: none; } }
|
|
13
|
+
@media (prefers-reduced-motion: reduce) { .cell { animation: none; } .bar { transition: none; } .cell:hover .bar, .cell:focus-visible .bar { transform: none; } }
|
|
14
|
+
|
|
15
|
+
.chart > span { flex: 1; min-width: 0; }
|
package/components/field.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare function useFieldControl(options: FieldOptions): {
|
|
|
50
50
|
required: boolean;
|
|
51
51
|
disabled: boolean;
|
|
52
52
|
readOnly: boolean;
|
|
53
|
-
error: ReactNode
|
|
53
|
+
error: string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
54
54
|
hint: ReactNode;
|
|
55
55
|
descriptionId: string | undefined;
|
|
56
56
|
invalid: "false" | "grammar" | "spelling" | "true" | boolean;
|
package/components/field.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, useContext, useId } from "react";
|
|
3
|
+
import { FormValidationContext } from "./form-validation.js";
|
|
3
4
|
const FieldContext = createContext(null);
|
|
4
5
|
function fieldInputProps(field) {
|
|
5
6
|
return {
|
|
@@ -29,7 +30,7 @@ const joinIds = (...values) => [
|
|
|
29
30
|
)
|
|
30
31
|
].join(" ") || void 0;
|
|
31
32
|
function useFieldControl(options) {
|
|
32
|
-
const inherited = useContext(FieldContext), generated = useId(), id = options.id || inherited?.id || generated, error = options.error ?? inherited?.error, hint = options.hint ?? inherited?.hint;
|
|
33
|
+
const inherited = useContext(FieldContext), validation = useContext(FormValidationContext), generated = useId(), id = options.id || inherited?.id || generated, error = options.error ?? validation[id] ?? inherited?.error, hint = options.hint ?? inherited?.hint;
|
|
33
34
|
return {
|
|
34
35
|
id,
|
|
35
36
|
name: options.name ?? inherited?.name,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const FormValidationContext: import("react").Context<Record<string, string>>;
|
|
2
|
+
export type ValidatableControl = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
3
|
+
export declare function formControls(form: HTMLFormElement): ValidatableControl[];
|
|
4
|
+
export declare function validateForm(form: HTMLFormElement | null, focus?: boolean): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
const FormValidationContext = createContext({});
|
|
4
|
+
function formControls(form) {
|
|
5
|
+
return Array.from(form.elements).filter(
|
|
6
|
+
(item) => item instanceof HTMLInputElement || item instanceof HTMLSelectElement || item instanceof HTMLTextAreaElement
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function validateForm(form, focus = true) {
|
|
10
|
+
if (!form) return false;
|
|
11
|
+
const valid = form.checkValidity();
|
|
12
|
+
if (!valid && focus)
|
|
13
|
+
requestAnimationFrame(
|
|
14
|
+
() => formControls(form).find((field) => field.willValidate && !field.validity.valid)?.focus()
|
|
15
|
+
);
|
|
16
|
+
return valid;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
FormValidationContext,
|
|
20
|
+
formControls,
|
|
21
|
+
validateForm
|
|
22
|
+
};
|
package/components/index.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export type { ContextMenuItem, MenuAction } from "./menuTypes";
|
|
|
82
82
|
export { MenuItem } from "./MenuItem";
|
|
83
83
|
export type { MenuItemProps } from "./MenuItem";
|
|
84
84
|
export { Form } from "./Form";
|
|
85
|
+
export type { NativeFormProps } from "./Form";
|
|
86
|
+
export { validateForm } from "./form-validation";
|
|
85
87
|
export { AccountItem } from "./AccountItem";
|
|
86
88
|
export type { AccountItemProps, AccountItemMetadata } from "./AccountItem";
|
|
87
89
|
export { PasskeyItem } from "./PasskeyItem";
|
|
@@ -191,5 +193,5 @@ export { EditableHeading } from "./EditableHeading";
|
|
|
191
193
|
export type { EditableHeadingProps } from "./EditableHeading";
|
|
192
194
|
export type { TableOfContentsProps, TableOfContentsItem, } from "./TableOfContents";
|
|
193
195
|
export type { MarkdownCodeTheme } from "./Markdown";
|
|
194
|
-
export { Lightbox, type LightboxProps, type LightboxItem, type LightboxLabels } from "./Lightbox";
|
|
195
|
-
export { FloatingActionBar, type FloatingActionBarProps } from "./FloatingActionBar";
|
|
196
|
+
export { Lightbox, type LightboxProps, type LightboxItem, type LightboxLabels, } from "./Lightbox";
|
|
197
|
+
export { FloatingActionBar, type FloatingActionBarProps, } from "./FloatingActionBar";
|
package/components/index.js
CHANGED
|
@@ -79,6 +79,7 @@ import { ContextMenuPanel } from "./ContextMenuPanel.js";
|
|
|
79
79
|
import { SelectOptionContent } from "./SelectOptionContent.js";
|
|
80
80
|
import { MenuItem } from "./MenuItem.js";
|
|
81
81
|
import { Form } from "./Form.js";
|
|
82
|
+
import { validateForm } from "./form-validation.js";
|
|
82
83
|
import { AccountItem } from "./AccountItem.js";
|
|
83
84
|
import { PasskeyItem } from "./PasskeyItem.js";
|
|
84
85
|
import { SessionItem } from "./SessionItem.js";
|
|
@@ -156,8 +157,12 @@ import { Markdown } from "./Markdown.js";
|
|
|
156
157
|
import { Banner } from "./Banner.js";
|
|
157
158
|
import { TableOfContents } from "./TableOfContents.js";
|
|
158
159
|
import { EditableHeading } from "./EditableHeading.js";
|
|
159
|
-
import {
|
|
160
|
-
|
|
160
|
+
import {
|
|
161
|
+
Lightbox
|
|
162
|
+
} from "./Lightbox.js";
|
|
163
|
+
import {
|
|
164
|
+
FloatingActionBar
|
|
165
|
+
} from "./FloatingActionBar.js";
|
|
161
166
|
export {
|
|
162
167
|
Accordion,
|
|
163
168
|
AccountItem,
|
|
@@ -313,5 +318,6 @@ export {
|
|
|
313
318
|
useFormState,
|
|
314
319
|
useToast,
|
|
315
320
|
useUIConfig,
|
|
316
|
-
validateFiles
|
|
321
|
+
validateFiles,
|
|
322
|
+
validateForm
|
|
317
323
|
};
|