@robert-stackflow/oneui 0.6.8 → 0.6.16
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 +58 -0
- package/README.md +255 -188
- package/components/AccountItem.module.css +103 -103
- package/components/Alert.d.ts +2 -9
- package/components/Alert.js +2 -40
- package/components/AppShell.d.ts +7 -7
- package/components/AppShell.js +37 -33
- package/components/AppShell.module.css +223 -271
- package/components/AppearanceSettings.js +25 -32
- package/components/Badge.module.css +30 -30
- package/components/Banner.d.ts +17 -0
- package/components/Banner.js +99 -0
- package/components/Banner.module.css +143 -0
- package/components/BarChart.module.css +35 -34
- package/components/Breadcrumb.module.css +97 -97
- package/components/Button.module.css +120 -120
- package/components/Cascader.js +1 -0
- package/components/CharacterPicker.js +2 -0
- package/components/Checkbox.module.css +95 -95
- package/components/Combobox.js +1 -0
- package/components/Combobox.module.css +6 -1
- package/components/CommandPalette.js +2 -2
- package/components/ContributionCalendar.module.css +121 -121
- package/components/Control.module.css +86 -86
- package/components/DataTable.d.ts +3 -2
- package/components/DataTable.js +92 -66
- package/components/DataTable.module.css +3 -31
- package/components/DatePicker.js +1 -0
- package/components/DateRangePicker.js +1 -0
- package/components/Dialog.d.ts +3 -1
- package/components/Dialog.js +11 -4
- package/components/Dialog.module.css +139 -97
- package/components/DialogVariants.d.ts +2 -1
- package/components/DialogVariants.js +35 -7
- package/components/HierarchyPicker.module.css +185 -181
- package/components/IconPicker.js +2 -0
- package/components/Indicator.module.css +83 -83
- package/components/Layout.module.css +82 -82
- package/components/Markdown.d.ts +13 -0
- package/components/Markdown.js +164 -0
- package/components/Markdown.module.css +227 -0
- package/components/MenuItem.module.css +172 -172
- package/components/MultiSelect.js +1 -0
- package/components/MultiSelect.module.css +2 -0
- package/components/NavBar.d.ts +20 -0
- package/components/NavBar.js +197 -0
- package/components/NavBar.module.css +130 -0
- package/components/NavigationSurface.module.css +27 -0
- package/components/Picker.module.css +7 -0
- package/components/Popover.d.ts +6 -1
- package/components/Popover.js +39 -13
- package/components/Popover.module.css +8 -0
- 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/SelectSettingRow.d.ts +7 -0
- package/components/SelectSettingRow.js +58 -0
- package/components/SettingRow.d.ts +9 -3
- package/components/SettingRow.js +32 -8
- package/components/SettingRow.module.css +17 -0
- package/components/SettingsLayout.d.ts +15 -3
- package/components/SettingsLayout.js +46 -29
- package/components/SideBar.d.ts +9 -0
- package/components/SideBar.js +30 -0
- package/components/SidebarNavigation.d.ts +24 -3
- package/components/SidebarNavigation.js +274 -47
- package/components/SidebarNavigation.module.css +352 -130
- package/components/Slider.module.css +19 -19
- package/components/Steps.module.css +176 -176
- package/components/Switch.d.ts +3 -1
- package/components/Switch.js +5 -1
- package/components/Switch.module.css +59 -59
- package/components/SwitchSettingRow.d.ts +7 -0
- package/components/SwitchSettingRow.js +45 -0
- package/components/Table.d.ts +8 -1
- package/components/Table.js +34 -17
- package/components/Table.module.css +87 -48
- package/components/TableMarkup.d.ts +2 -1
- package/components/TableMarkup.js +18 -1
- package/components/TableOfContents.d.ts +22 -0
- package/components/TableOfContents.js +462 -0
- package/components/TableOfContents.module.css +252 -0
- package/components/TextAreaSettingRow.d.ts +9 -0
- package/components/TextAreaSettingRow.js +47 -0
- package/components/TextSettingRow.d.ts +9 -0
- package/components/TextSettingRow.js +45 -0
- package/components/ThemePicker.module.css +178 -178
- package/components/ThemeProvider.js +2 -0
- package/components/TimeColumns.module.css +47 -47
- package/components/Timeline.module.css +202 -202
- package/components/Toast.d.ts +8 -1
- package/components/Toast.js +49 -17
- package/components/Toast.module.css +25 -0
- package/components/ToastProvider.d.ts +4 -1
- package/components/ToastProvider.js +67 -12
- package/components/TreeSelect.js +1 -0
- package/components/TreeTable.d.ts +3 -3
- package/components/TreeTable.js +12 -2
- package/components/TreeTable.module.css +57 -53
- package/components/createToaster.d.ts +2 -1
- package/components/createToaster.js +28 -14
- package/components/index.d.ts +18 -1
- package/components/index.js +24 -0
- package/components/motion.d.ts +1 -0
- package/components/motion.js +18 -6
- package/components/settingRowControl.d.ts +7 -0
- package/components/settingRowControl.js +15 -0
- package/package.json +57 -3
- package/styles/base.css +206 -206
- package/styles/blue.css +270 -268
- package/styles/minimal.css +1 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import {
|
|
3
3
|
useId,
|
|
4
|
+
useRef,
|
|
5
|
+
useLayoutEffect,
|
|
4
6
|
useState
|
|
5
7
|
} from "react";
|
|
6
8
|
import { ChevronRight } from "lucide-react";
|
|
@@ -27,7 +29,14 @@ function NavigationButton({
|
|
|
27
29
|
);
|
|
28
30
|
}
|
|
29
31
|
function SidebarNavigation({
|
|
30
|
-
items,
|
|
32
|
+
items = [],
|
|
33
|
+
groups,
|
|
34
|
+
collapsibleGroups = true,
|
|
35
|
+
groupHeaderBold = false,
|
|
36
|
+
collapsedGroupIds,
|
|
37
|
+
defaultCollapsedGroupIds = [],
|
|
38
|
+
onCollapsedGroupsChange,
|
|
39
|
+
mode = "links",
|
|
31
40
|
active,
|
|
32
41
|
onNavigate,
|
|
33
42
|
basePath = "",
|
|
@@ -38,6 +47,15 @@ function SidebarNavigation({
|
|
|
38
47
|
}) {
|
|
39
48
|
const [internal, setInternal] = useState(defaultExpandedIds);
|
|
40
49
|
const expanded = expandedIds ?? internal;
|
|
50
|
+
const [internalGroups, setInternalGroups] = useState(
|
|
51
|
+
defaultCollapsedGroupIds
|
|
52
|
+
);
|
|
53
|
+
const collapsedGroups = collapsedGroupIds ?? internalGroups;
|
|
54
|
+
const toggleGroup = (id) => {
|
|
55
|
+
const next = collapsedGroups.includes(id) ? collapsedGroups.filter((value) => value !== id) : [...collapsedGroups, id];
|
|
56
|
+
if (collapsedGroupIds === void 0) setInternalGroups(next);
|
|
57
|
+
onCollapsedGroupsChange?.(next);
|
|
58
|
+
};
|
|
41
59
|
const toggle = (id) => {
|
|
42
60
|
const next = expanded.includes(id) ? expanded.filter((value) => value !== id) : [...expanded, id];
|
|
43
61
|
if (expandedIds === void 0) setInternal(next);
|
|
@@ -51,7 +69,40 @@ function SidebarNavigation({
|
|
|
51
69
|
event.preventDefault();
|
|
52
70
|
onNavigate(path);
|
|
53
71
|
};
|
|
54
|
-
|
|
72
|
+
const root = useRef(null);
|
|
73
|
+
useLayoutEffect(() => {
|
|
74
|
+
const node = root.current;
|
|
75
|
+
const measure = () => {
|
|
76
|
+
const selected = node.querySelector(
|
|
77
|
+
'[data-navigation-item][aria-current="page"]'
|
|
78
|
+
);
|
|
79
|
+
let visible = Boolean(selected && !selected.closest("[inert]"));
|
|
80
|
+
const target = selected?.closest("[data-navigation-row]") ?? selected;
|
|
81
|
+
const rect = target?.getBoundingClientRect();
|
|
82
|
+
for (let parent = selected?.parentElement; parent && parent !== node; parent = parent.parentElement) {
|
|
83
|
+
if (parent.hasAttribute("data-navigation-collapse") && rect) {
|
|
84
|
+
const clip = parent.getBoundingClientRect();
|
|
85
|
+
if (rect.top < clip.top - 1 || rect.bottom > clip.bottom + 1)
|
|
86
|
+
visible = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
node.style.setProperty("--nav-track-opacity", visible ? "1" : "0");
|
|
90
|
+
if (!visible || !rect) return;
|
|
91
|
+
const bounds = node.getBoundingClientRect();
|
|
92
|
+
node.style.setProperty("--nav-track-y", `${rect.top - bounds.top}px`);
|
|
93
|
+
node.style.setProperty("--nav-track-height", `${rect.height}px`);
|
|
94
|
+
if (!node.dataset.ready) {
|
|
95
|
+
node.getBoundingClientRect();
|
|
96
|
+
node.dataset.ready = "true";
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
measure();
|
|
100
|
+
const observer = new ResizeObserver(measure);
|
|
101
|
+
observer.observe(node);
|
|
102
|
+
node.querySelectorAll("[data-navigation-collapse], [data-navigation-item]").forEach((entry) => observer.observe(entry));
|
|
103
|
+
return () => observer.disconnect();
|
|
104
|
+
}, [active, items, groups, expanded, collapsedGroups, compact, mode]);
|
|
105
|
+
const renderItems = (entries) => entries.map((item) => /* @__PURE__ */ jsx(
|
|
55
106
|
Branch,
|
|
56
107
|
{
|
|
57
108
|
item,
|
|
@@ -60,10 +111,110 @@ function SidebarNavigation({
|
|
|
60
111
|
toggle,
|
|
61
112
|
compact,
|
|
62
113
|
href,
|
|
63
|
-
navigate
|
|
114
|
+
navigate,
|
|
115
|
+
mode,
|
|
116
|
+
onNavigate
|
|
64
117
|
},
|
|
65
118
|
item.id
|
|
66
|
-
))
|
|
119
|
+
));
|
|
120
|
+
return /* @__PURE__ */ jsxs(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
ref: root,
|
|
124
|
+
className: s.tree,
|
|
125
|
+
"data-compact": compact || void 0,
|
|
126
|
+
onKeyDown: (event) => {
|
|
127
|
+
if (!["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key))
|
|
128
|
+
return;
|
|
129
|
+
const controls = [
|
|
130
|
+
...event.currentTarget.querySelectorAll(
|
|
131
|
+
'a[href]:not([aria-disabled="true"]),button:not(:disabled)'
|
|
132
|
+
)
|
|
133
|
+
].filter(
|
|
134
|
+
(node) => !node.closest("[inert]") && node.getClientRects().length > 0
|
|
135
|
+
);
|
|
136
|
+
const index = controls.indexOf(event.target);
|
|
137
|
+
if (index < 0 || !controls.length) return;
|
|
138
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? controls.length - 1 : (index + (event.key === "ArrowDown" ? 1 : -1) + controls.length) % controls.length;
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
controls[next]?.focus();
|
|
141
|
+
},
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: s.track, "data-sidebar-track": true, "aria-hidden": "true" }),
|
|
144
|
+
groups ? groups.map((group) => /* @__PURE__ */ jsx(
|
|
145
|
+
NavigationSection,
|
|
146
|
+
{
|
|
147
|
+
group,
|
|
148
|
+
compact,
|
|
149
|
+
bold: group.headerBold ?? groupHeaderBold,
|
|
150
|
+
collapsible: group.collapsible ?? collapsibleGroups,
|
|
151
|
+
collapsed: collapsedGroups.includes(group.id),
|
|
152
|
+
active: containsActive(group.items, active),
|
|
153
|
+
onToggle: () => toggleGroup(group.id),
|
|
154
|
+
children: renderItems(group.items)
|
|
155
|
+
},
|
|
156
|
+
group.id
|
|
157
|
+
)) : renderItems(items)
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function containsActive(items, active) {
|
|
163
|
+
return items.some(
|
|
164
|
+
(item) => item.id === active || containsActive(item.children ?? [], active)
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function NavigationSection({
|
|
168
|
+
group,
|
|
169
|
+
bold,
|
|
170
|
+
compact,
|
|
171
|
+
collapsible,
|
|
172
|
+
collapsed,
|
|
173
|
+
active,
|
|
174
|
+
onToggle,
|
|
175
|
+
children
|
|
176
|
+
}) {
|
|
177
|
+
const id = useId();
|
|
178
|
+
const trailing = typeof group.trailing === "function" ? group.trailing({ collapsed: collapsible && collapsed, active }) : group.trailing;
|
|
179
|
+
return /* @__PURE__ */ jsxs(
|
|
180
|
+
"section",
|
|
181
|
+
{
|
|
182
|
+
role: "group",
|
|
183
|
+
className: s.section,
|
|
184
|
+
"aria-label": group.label,
|
|
185
|
+
"data-active-within": active || void 0,
|
|
186
|
+
"data-collapsed": collapsed || void 0,
|
|
187
|
+
"data-header-bold": bold,
|
|
188
|
+
children: [
|
|
189
|
+
group.label && !compact && /* @__PURE__ */ jsxs("div", { className: s.groupHeader, children: [
|
|
190
|
+
collapsible ? /* @__PURE__ */ jsxs(
|
|
191
|
+
"button",
|
|
192
|
+
{
|
|
193
|
+
type: "button",
|
|
194
|
+
className: s.groupToggle,
|
|
195
|
+
"aria-label": group.label,
|
|
196
|
+
"aria-expanded": !collapsed,
|
|
197
|
+
"aria-controls": id,
|
|
198
|
+
onClick: onToggle,
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ jsx("span", { children: group.label }),
|
|
201
|
+
/* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": "true" })
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
) : /* @__PURE__ */ jsx("div", { className: s.groupLabel, children: group.label }),
|
|
205
|
+
trailing != null && /* @__PURE__ */ jsx("span", { className: s.groupTrailing, children: trailing })
|
|
206
|
+
] }),
|
|
207
|
+
/* @__PURE__ */ jsx(
|
|
208
|
+
NavigationDisclosure,
|
|
209
|
+
{
|
|
210
|
+
id,
|
|
211
|
+
open: compact || !collapsible || !collapsed,
|
|
212
|
+
children
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
);
|
|
67
218
|
}
|
|
68
219
|
function Branch({
|
|
69
220
|
item,
|
|
@@ -72,48 +223,99 @@ function Branch({
|
|
|
72
223
|
toggle,
|
|
73
224
|
compact,
|
|
74
225
|
href,
|
|
75
|
-
navigate
|
|
226
|
+
navigate,
|
|
227
|
+
mode,
|
|
228
|
+
onNavigate
|
|
76
229
|
}) {
|
|
77
230
|
const id = useId();
|
|
78
231
|
const hasChildren = item.expandable ?? Boolean(item.children?.length || item.content);
|
|
79
232
|
const open = expanded.includes(item.id) && !compact;
|
|
80
|
-
return /* @__PURE__ */ jsxs(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
233
|
+
return /* @__PURE__ */ jsxs(
|
|
234
|
+
"div",
|
|
235
|
+
{
|
|
236
|
+
className: s.branch,
|
|
237
|
+
"data-active-within": containsActive([item], active) || void 0,
|
|
238
|
+
children: [
|
|
239
|
+
/* @__PURE__ */ jsxs(
|
|
240
|
+
"div",
|
|
241
|
+
{
|
|
242
|
+
className: s.row,
|
|
243
|
+
"data-navigation-row": true,
|
|
244
|
+
onKeyDown: (event) => {
|
|
245
|
+
if (item.disabled || compact) return;
|
|
246
|
+
if (event.key === "ArrowRight" && hasChildren) {
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
if (!open) toggle(item.id);
|
|
249
|
+
else
|
|
250
|
+
event.currentTarget.nextElementSibling?.querySelector(
|
|
251
|
+
'[data-navigation-item]:not(:disabled):not([aria-disabled="true"])'
|
|
252
|
+
)?.focus();
|
|
253
|
+
} else if (event.key === "ArrowLeft") {
|
|
254
|
+
event.preventDefault();
|
|
255
|
+
if (open) toggle(item.id);
|
|
256
|
+
else
|
|
257
|
+
event.currentTarget.closest("[data-navigation-children]")?.previousElementSibling?.querySelector(
|
|
258
|
+
"[data-navigation-item]"
|
|
259
|
+
)?.focus();
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
children: [
|
|
263
|
+
mode === "buttons" ? /* @__PURE__ */ jsxs(
|
|
264
|
+
"button",
|
|
265
|
+
{
|
|
266
|
+
type: "button",
|
|
267
|
+
className: s.item,
|
|
268
|
+
"data-navigation-item": true,
|
|
269
|
+
"data-has-icon": Boolean(item.icon) || void 0,
|
|
270
|
+
title: item.label,
|
|
271
|
+
disabled: item.disabled,
|
|
272
|
+
"aria-current": active === item.id ? "page" : void 0,
|
|
273
|
+
onClick: () => onNavigate(item.path),
|
|
274
|
+
children: [
|
|
275
|
+
item.icon,
|
|
276
|
+
/* @__PURE__ */ jsx("span", { className: s.label, children: item.label })
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
) : /* @__PURE__ */ jsxs(
|
|
280
|
+
"a",
|
|
281
|
+
{
|
|
282
|
+
role: item.disabled ? "link" : void 0,
|
|
283
|
+
className: s.item,
|
|
284
|
+
"data-navigation-item": true,
|
|
285
|
+
href: item.disabled ? void 0 : href(item.path),
|
|
286
|
+
"data-has-icon": Boolean(item.icon) || void 0,
|
|
287
|
+
"aria-disabled": item.disabled || void 0,
|
|
288
|
+
tabIndex: item.disabled ? -1 : void 0,
|
|
289
|
+
"aria-current": active === item.id ? "page" : void 0,
|
|
290
|
+
title: item.label,
|
|
291
|
+
onClick: (event) => {
|
|
292
|
+
if (item.disabled) event.preventDefault();
|
|
293
|
+
else navigate(event, item.path);
|
|
294
|
+
},
|
|
295
|
+
children: [
|
|
296
|
+
item.icon,
|
|
297
|
+
/* @__PURE__ */ jsx("span", { className: s.label, children: item.label })
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
item.trailing != null && !compact && /* @__PURE__ */ jsx("span", { className: s.trailing, children: item.trailing }),
|
|
302
|
+
hasChildren && !compact && /* @__PURE__ */ jsx(
|
|
303
|
+
"button",
|
|
304
|
+
{
|
|
305
|
+
type: "button",
|
|
306
|
+
className: s.disclosure,
|
|
307
|
+
"aria-label": `${open ? "\u6536\u8D77" : "\u5C55\u5F00"}${item.label}`,
|
|
308
|
+
"aria-expanded": open,
|
|
309
|
+
"aria-controls": id,
|
|
310
|
+
disabled: item.disabled,
|
|
311
|
+
onClick: () => toggle(item.id),
|
|
312
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { size: 14, "aria-hidden": "true" })
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
hasChildren && /* @__PURE__ */ jsxs(NavigationDisclosure, { id, open, nested: true, label: item.label, children: [
|
|
117
319
|
item.content,
|
|
118
320
|
item.children?.map((child) => /* @__PURE__ */ jsx(
|
|
119
321
|
Branch,
|
|
@@ -124,14 +326,39 @@ function Branch({
|
|
|
124
326
|
toggle,
|
|
125
327
|
compact,
|
|
126
328
|
href,
|
|
127
|
-
navigate
|
|
329
|
+
navigate,
|
|
330
|
+
mode,
|
|
331
|
+
onNavigate
|
|
128
332
|
},
|
|
129
333
|
child.id
|
|
130
334
|
))
|
|
131
|
-
]
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
335
|
+
] })
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
function NavigationDisclosure({
|
|
341
|
+
id,
|
|
342
|
+
open,
|
|
343
|
+
nested = false,
|
|
344
|
+
label,
|
|
345
|
+
children
|
|
346
|
+
}) {
|
|
347
|
+
return /* @__PURE__ */ jsx(
|
|
348
|
+
"div",
|
|
349
|
+
{
|
|
350
|
+
id,
|
|
351
|
+
className: s.collapse,
|
|
352
|
+
"data-navigation-collapse": true,
|
|
353
|
+
"data-open": open,
|
|
354
|
+
"data-navigation-children": nested || void 0,
|
|
355
|
+
role: nested ? "group" : void 0,
|
|
356
|
+
"aria-label": label,
|
|
357
|
+
"aria-hidden": !open,
|
|
358
|
+
inert: !open,
|
|
359
|
+
children: /* @__PURE__ */ jsx("div", { className: s.clip, children: /* @__PURE__ */ jsx("div", { className: nested ? s.children : s.groupItems, children }) })
|
|
360
|
+
}
|
|
361
|
+
);
|
|
135
362
|
}
|
|
136
363
|
export {
|
|
137
364
|
NavigationButton,
|