asta-ui 0.9.6 → 0.9.7
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/css/asta.css +1 -1
- package/css/asta.js +1 -1
- package/dist/base/navbar.js +1 -1
- package/dist/base/sidebar.js +1 -1
- package/dist/base.js +2 -2
- package/dist/{chunk-2EBWWZPS.js → chunk-DWPGFNNF.js} +38 -9
- package/dist/{chunk-CACW5LH3.js → chunk-EAHHWF3V.js} +38 -9
- package/dist/chunk-FT66LAUZ.js +388 -0
- package/dist/chunk-SUWA7DM6.js +388 -0
- package/dist/index.js +2 -2
- package/dist/navbar.js +1 -1
- package/dist/sidebar.js +1 -1
- package/dist/types/components/kit/base/navbar.d.ts +4 -1
- package/dist/types/components/kit/base/sidebar.d.ts +29 -7
- package/dist/types/components/kit/navbar.d.ts +4 -1
- package/dist/types/components/kit/sidebar.d.ts +29 -7
- package/dist/types/packages/asta-ui/src/base.d.ts +1 -1
- package/dist/types/packages/asta-ui/src/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-MVE7RJJ6.js +0 -322
- package/dist/chunk-TBMUSER2.js +0 -322
package/dist/chunk-MVE7RJJ6.js
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
Avatar
|
|
4
|
-
} from "./chunk-IVCHYE55.js";
|
|
5
|
-
|
|
6
|
-
// components/kit/base/sidebar.tsx
|
|
7
|
-
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
var cx = (...c) => c.filter(Boolean).join(" ");
|
|
10
|
-
var EASE = "ease-[cubic-bezier(.16,1,.3,1)]";
|
|
11
|
-
var RING = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent)]";
|
|
12
|
-
var Icon = ({ d, className = "" }) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: cx("h-4 w-4", className), fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
|
|
13
|
-
function Tile({ name, on }) {
|
|
14
|
-
return /* @__PURE__ */ jsx(
|
|
15
|
-
"span",
|
|
16
|
-
{
|
|
17
|
-
"aria-hidden": true,
|
|
18
|
-
className: cx(
|
|
19
|
-
"flex h-7 w-7 shrink-0 items-center justify-center rounded-[7px] text-[12.5px] font-semibold tracking-[-0.02em]",
|
|
20
|
-
on ? "bg-ink text-paper" : cx("bg-paper text-ink", RING)
|
|
21
|
-
),
|
|
22
|
-
children: name.charAt(0)
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
function Label({ hidden, children, className }) {
|
|
27
|
-
return /* @__PURE__ */ jsx(
|
|
28
|
-
"span",
|
|
29
|
-
{
|
|
30
|
-
className: cx(
|
|
31
|
-
"min-w-0 flex-1 overflow-hidden whitespace-nowrap text-left transition-[opacity,transform] duration-300",
|
|
32
|
-
EASE,
|
|
33
|
-
hidden ? "pointer-events-none -translate-x-1 opacity-0" : "translate-x-0 opacity-100 delay-75",
|
|
34
|
-
className
|
|
35
|
-
),
|
|
36
|
-
children
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
function Tip({ children }) {
|
|
41
|
-
return /* @__PURE__ */ jsx(
|
|
42
|
-
"span",
|
|
43
|
-
{
|
|
44
|
-
"aria-hidden": true,
|
|
45
|
-
className: cx(
|
|
46
|
-
"pointer-events-none absolute left-[calc(100%+10px)] top-1/2 z-20 -translate-x-1 -translate-y-1/2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[12px] text-paper opacity-0 transition-[opacity,translate] duration-200",
|
|
47
|
-
"group-hover/item:translate-x-0 group-hover/item:opacity-100 group-focus-visible/item:translate-x-0 group-focus-visible/item:opacity-100",
|
|
48
|
-
EASE
|
|
49
|
-
),
|
|
50
|
-
children
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
var itemCls = "group/item relative flex h-9 w-full items-center rounded-lg text-[13.5px] outline-none transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-brand/50";
|
|
55
|
-
function Sidebar({
|
|
56
|
-
workspaces,
|
|
57
|
-
defaultWorkspace,
|
|
58
|
-
onWorkspaceChange,
|
|
59
|
-
groups,
|
|
60
|
-
active: activeProp,
|
|
61
|
-
defaultActive,
|
|
62
|
-
onNavigate,
|
|
63
|
-
collapsed: collapsedProp,
|
|
64
|
-
defaultCollapsed = false,
|
|
65
|
-
onCollapsedChange,
|
|
66
|
-
user,
|
|
67
|
-
className
|
|
68
|
-
}) {
|
|
69
|
-
const [activeState, setActive] = useState(defaultActive ?? groups[0]?.items[0]?.id ?? "");
|
|
70
|
-
const [collapsedState, setCollapsed] = useState(defaultCollapsed);
|
|
71
|
-
const [workspace, setWorkspace] = useState(defaultWorkspace ?? workspaces[0]?.id);
|
|
72
|
-
const [menu, setMenu] = useState(false);
|
|
73
|
-
const active = activeProp ?? activeState;
|
|
74
|
-
const collapsed = collapsedProp ?? collapsedState;
|
|
75
|
-
const current = workspaces.find((w) => w.id === workspace) ?? workspaces[0];
|
|
76
|
-
const nav = useRef(null);
|
|
77
|
-
const indicator = useRef(null);
|
|
78
|
-
const placed = useRef(false);
|
|
79
|
-
const switcher = useRef(null);
|
|
80
|
-
const trigger = useRef(null);
|
|
81
|
-
useLayoutEffect(() => {
|
|
82
|
-
const ind = indicator.current;
|
|
83
|
-
const el = nav.current?.querySelector(`[data-sb-id="${CSS.escape(active)}"]`);
|
|
84
|
-
if (!ind) return;
|
|
85
|
-
if (!el) {
|
|
86
|
-
ind.style.opacity = "0";
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (!placed.current) ind.style.transition = "none";
|
|
90
|
-
ind.style.transform = `translateY(${el.offsetTop}px)`;
|
|
91
|
-
ind.style.opacity = "1";
|
|
92
|
-
if (!placed.current) {
|
|
93
|
-
void ind.offsetHeight;
|
|
94
|
-
ind.style.transition = "";
|
|
95
|
-
placed.current = true;
|
|
96
|
-
}
|
|
97
|
-
}, [active]);
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (!menu) return;
|
|
100
|
-
switcher.current?.querySelector("[role=menuitemradio][aria-checked=true]")?.focus();
|
|
101
|
-
const down = (e) => {
|
|
102
|
-
if (!switcher.current?.contains(e.target)) setMenu(false);
|
|
103
|
-
};
|
|
104
|
-
document.addEventListener("pointerdown", down);
|
|
105
|
-
return () => document.removeEventListener("pointerdown", down);
|
|
106
|
-
}, [menu]);
|
|
107
|
-
const navigate = (id) => {
|
|
108
|
-
setActive(id);
|
|
109
|
-
onNavigate?.(id);
|
|
110
|
-
};
|
|
111
|
-
const toggle = () => {
|
|
112
|
-
setCollapsed(!collapsed);
|
|
113
|
-
onCollapsedChange?.(!collapsed);
|
|
114
|
-
};
|
|
115
|
-
const pick = (id) => {
|
|
116
|
-
setWorkspace(id);
|
|
117
|
-
onWorkspaceChange?.(id);
|
|
118
|
-
setMenu(false);
|
|
119
|
-
trigger.current?.focus();
|
|
120
|
-
};
|
|
121
|
-
const rove = (e, selector, root) => {
|
|
122
|
-
const els = [...root?.querySelectorAll(selector) ?? []];
|
|
123
|
-
const i = els.indexOf(document.activeElement);
|
|
124
|
-
const next = { ArrowDown: i + 1, ArrowUp: i - 1, Home: 0, End: els.length - 1 }[e.key];
|
|
125
|
-
if (next === void 0 || !els.length) return;
|
|
126
|
-
e.preventDefault();
|
|
127
|
-
els[(next + els.length) % els.length]?.focus();
|
|
128
|
-
};
|
|
129
|
-
return /* @__PURE__ */ jsxs(
|
|
130
|
-
"aside",
|
|
131
|
-
{
|
|
132
|
-
"aria-label": "Sidebar",
|
|
133
|
-
"data-collapsed": collapsed || void 0,
|
|
134
|
-
className: cx(
|
|
135
|
-
"relative flex h-full shrink-0 flex-col bg-paper-2 px-3 py-3 transition-[width] duration-500",
|
|
136
|
-
EASE,
|
|
137
|
-
collapsed ? "w-16" : "w-[248px]",
|
|
138
|
-
className
|
|
139
|
-
),
|
|
140
|
-
children: [
|
|
141
|
-
/* @__PURE__ */ jsx("style", { href: "asta-sidebar", precedence: "asta", children: `
|
|
142
|
-
@keyframes kit-sb-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
|
|
143
|
-
@media (prefers-reduced-motion: reduce) { .kit-sb, .kit-sb * { animation: none !important; transition-duration: 0s !important; } }
|
|
144
|
-
` }),
|
|
145
|
-
/* @__PURE__ */ jsxs("div", { className: "kit-sb flex min-h-0 flex-1 flex-col", children: [
|
|
146
|
-
/* @__PURE__ */ jsxs("div", { ref: switcher, className: "relative", children: [
|
|
147
|
-
/* @__PURE__ */ jsxs(
|
|
148
|
-
"button",
|
|
149
|
-
{
|
|
150
|
-
ref: trigger,
|
|
151
|
-
type: "button",
|
|
152
|
-
"aria-haspopup": "menu",
|
|
153
|
-
"aria-expanded": menu,
|
|
154
|
-
"aria-label": collapsed ? `Workspace: ${current?.name}` : void 0,
|
|
155
|
-
onClick: () => setMenu((v) => !v),
|
|
156
|
-
onKeyDown: (e) => {
|
|
157
|
-
if (e.key === "ArrowDown" && !menu) {
|
|
158
|
-
e.preventDefault();
|
|
159
|
-
setMenu(true);
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
className: cx(itemCls, "h-11 hover:bg-[color-mix(in_srgb,var(--ink)_5%,transparent)] aria-expanded:bg-[color-mix(in_srgb,var(--ink)_5%,transparent)]"),
|
|
163
|
-
children: [
|
|
164
|
-
/* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: current && /* @__PURE__ */ jsx(Tile, { name: current.name, on: true }) }),
|
|
165
|
-
/* @__PURE__ */ jsxs(Label, { hidden: collapsed, className: "flex flex-col leading-tight", children: [
|
|
166
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[13.5px] font-medium text-ink", children: current?.name }),
|
|
167
|
-
current?.plan && /* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: current.plan })
|
|
168
|
-
] }),
|
|
169
|
-
/* @__PURE__ */ jsx(
|
|
170
|
-
Icon,
|
|
171
|
-
{
|
|
172
|
-
d: "m5.5 6 2.5-2.5L10.5 6M5.5 10l2.5 2.5 2.5-2.5",
|
|
173
|
-
className: cx("mr-2 shrink-0 text-mute transition-opacity duration-300", collapsed ? "opacity-0" : "opacity-100")
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
collapsed && /* @__PURE__ */ jsx(Tip, { children: current?.name })
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
),
|
|
180
|
-
menu && /* @__PURE__ */ jsxs(
|
|
181
|
-
"div",
|
|
182
|
-
{
|
|
183
|
-
role: "menu",
|
|
184
|
-
"aria-label": "Switch workspace",
|
|
185
|
-
onKeyDown: (e) => {
|
|
186
|
-
if (e.key === "Escape" || e.key === "Tab") {
|
|
187
|
-
if (e.key === "Escape") e.preventDefault();
|
|
188
|
-
setMenu(false);
|
|
189
|
-
trigger.current?.focus();
|
|
190
|
-
} else rove(e, "[role=menuitemradio]", e.currentTarget);
|
|
191
|
-
},
|
|
192
|
-
className: "absolute left-0 top-[calc(100%+6px)] z-30 w-[232px] origin-top-left rounded-xl bg-paper p-1.5 shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent),0_16px_36px_-14px_rgb(0_0_0/0.3)]",
|
|
193
|
-
style: { animation: "kit-sb-pop .32s cubic-bezier(.16,1,.3,1) both" },
|
|
194
|
-
children: [
|
|
195
|
-
/* @__PURE__ */ jsx("p", { className: "px-2 pb-1.5 pt-1 text-[11.5px] text-mute", children: "Workspaces" }),
|
|
196
|
-
workspaces.map((w) => {
|
|
197
|
-
const on = w.id === current?.id;
|
|
198
|
-
return /* @__PURE__ */ jsxs(
|
|
199
|
-
"button",
|
|
200
|
-
{
|
|
201
|
-
type: "button",
|
|
202
|
-
role: "menuitemradio",
|
|
203
|
-
"aria-checked": on,
|
|
204
|
-
onClick: () => pick(w.id),
|
|
205
|
-
className: "flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 text-left outline-none transition-colors hover:bg-paper-2 focus-visible:bg-paper-2",
|
|
206
|
-
children: [
|
|
207
|
-
/* @__PURE__ */ jsx(Tile, { name: w.name, on }),
|
|
208
|
-
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col leading-tight", children: [
|
|
209
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[13.5px] text-ink", children: w.name }),
|
|
210
|
-
w.plan && /* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: w.plan })
|
|
211
|
-
] }),
|
|
212
|
-
on && /* @__PURE__ */ jsx(Icon, { d: "M3.5 8.5l3 3 6-7", className: "shrink-0 text-brand" })
|
|
213
|
-
]
|
|
214
|
-
},
|
|
215
|
-
w.id
|
|
216
|
-
);
|
|
217
|
-
})
|
|
218
|
-
]
|
|
219
|
-
}
|
|
220
|
-
)
|
|
221
|
-
] }),
|
|
222
|
-
/* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "mt-4 min-h-0 flex-1", onKeyDown: (e) => rove(e, "[data-sb-id]", nav.current), children: /* @__PURE__ */ jsxs("div", { ref: nav, className: "relative", children: [
|
|
223
|
-
/* @__PURE__ */ jsx(
|
|
224
|
-
"span",
|
|
225
|
-
{
|
|
226
|
-
ref: indicator,
|
|
227
|
-
"aria-hidden": true,
|
|
228
|
-
className: cx(
|
|
229
|
-
"absolute inset-x-0 top-0 h-9 rounded-lg bg-paper opacity-0 shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_8%,transparent),0_1px_2px_rgb(0_0_0/0.06)] transition-[transform,opacity] duration-500",
|
|
230
|
-
EASE
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
),
|
|
234
|
-
groups.map((g, gi) => /* @__PURE__ */ jsxs("div", { className: cx(gi > 0 && "mt-3"), children: [
|
|
235
|
-
g.label && /* @__PURE__ */ jsxs("div", { className: "relative flex h-7 items-center px-3", "aria-hidden": collapsed || void 0, children: [
|
|
236
|
-
/* @__PURE__ */ jsx("span", { className: cx("text-[11.5px] text-mute transition-opacity duration-300", collapsed ? "opacity-0" : "opacity-100"), children: g.label }),
|
|
237
|
-
/* @__PURE__ */ jsx(
|
|
238
|
-
"span",
|
|
239
|
-
{
|
|
240
|
-
className: cx(
|
|
241
|
-
"absolute left-1/2 h-px w-3 -translate-x-1/2 bg-[color-mix(in_srgb,var(--ink)_14%,transparent)] transition-opacity duration-300",
|
|
242
|
-
collapsed ? "opacity-100" : "opacity-0"
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
)
|
|
246
|
-
] }),
|
|
247
|
-
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-0.5", children: g.items.map((it) => {
|
|
248
|
-
const on = it.id === active;
|
|
249
|
-
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
250
|
-
"button",
|
|
251
|
-
{
|
|
252
|
-
type: "button",
|
|
253
|
-
"data-sb-id": it.id,
|
|
254
|
-
"aria-current": on ? "page" : void 0,
|
|
255
|
-
"aria-label": collapsed ? it.label : void 0,
|
|
256
|
-
onClick: () => navigate(it.id),
|
|
257
|
-
className: cx(itemCls, on ? "text-ink" : "text-ink-2 hover:text-ink hover:bg-[color-mix(in_srgb,var(--ink)_4%,transparent)]"),
|
|
258
|
-
children: [
|
|
259
|
-
/* @__PURE__ */ jsxs("span", { className: cx("relative flex w-10 shrink-0 justify-center transition-colors duration-300", on ? "text-brand" : "text-mute group-hover/item:text-ink"), children: [
|
|
260
|
-
it.icon,
|
|
261
|
-
!!it.badge && /* @__PURE__ */ jsx(
|
|
262
|
-
"span",
|
|
263
|
-
{
|
|
264
|
-
className: cx(
|
|
265
|
-
"absolute right-2 top-0 h-1.5 w-1.5 rounded-full bg-brand shadow-[0_0_0_2px_var(--paper-2)] transition-[opacity,transform] duration-300",
|
|
266
|
-
EASE,
|
|
267
|
-
collapsed ? "scale-100 opacity-100" : "scale-50 opacity-0"
|
|
268
|
-
)
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
] }),
|
|
272
|
-
/* @__PURE__ */ jsx(Label, { hidden: collapsed, className: "relative", children: it.label }),
|
|
273
|
-
!!it.badge && /* @__PURE__ */ jsx(
|
|
274
|
-
"span",
|
|
275
|
-
{
|
|
276
|
-
className: cx(
|
|
277
|
-
"relative mr-2 rounded-md bg-[color-mix(in_srgb,var(--ink)_6%,transparent)] px-1.5 text-[11.5px] tabular-nums leading-5 text-mute transition-opacity duration-300",
|
|
278
|
-
collapsed ? "opacity-0" : "opacity-100"
|
|
279
|
-
),
|
|
280
|
-
children: it.badge
|
|
281
|
-
}
|
|
282
|
-
),
|
|
283
|
-
collapsed && /* @__PURE__ */ jsx(Tip, { children: it.label })
|
|
284
|
-
]
|
|
285
|
-
}
|
|
286
|
-
) }, it.id);
|
|
287
|
-
}) })
|
|
288
|
-
] }, g.label ?? gi))
|
|
289
|
-
] }) }),
|
|
290
|
-
/* @__PURE__ */ jsxs(
|
|
291
|
-
"button",
|
|
292
|
-
{
|
|
293
|
-
type: "button",
|
|
294
|
-
"aria-pressed": collapsed,
|
|
295
|
-
"aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
296
|
-
onClick: toggle,
|
|
297
|
-
className: cx(itemCls, "text-mute hover:bg-[color-mix(in_srgb,var(--ink)_4%,transparent)] hover:text-ink"),
|
|
298
|
-
children: [
|
|
299
|
-
/* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: /* @__PURE__ */ jsx(Icon, { d: "M2.5 3.5h11v9h-11zM6 3.5v9M10.5 6.5 9 8l1.5 1.5", className: cx("transition-transform duration-500", EASE, collapsed && "-scale-x-100") }) }),
|
|
300
|
-
/* @__PURE__ */ jsx(Label, { hidden: collapsed, children: "Collapse" }),
|
|
301
|
-
collapsed && /* @__PURE__ */ jsx(Tip, { children: "Expand" })
|
|
302
|
-
]
|
|
303
|
-
}
|
|
304
|
-
),
|
|
305
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-12 items-center rounded-lg", children: [
|
|
306
|
-
/* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: /* @__PURE__ */ jsx(Avatar, { name: user.name, src: user.src, size: "sm" }) }),
|
|
307
|
-
/* @__PURE__ */ jsxs(Label, { hidden: collapsed, className: "flex flex-col pl-1 leading-tight", children: [
|
|
308
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[13px] font-medium text-ink", children: user.name }),
|
|
309
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: user.email })
|
|
310
|
-
] })
|
|
311
|
-
] })
|
|
312
|
-
] })
|
|
313
|
-
]
|
|
314
|
-
}
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
var sidebar_default = Sidebar;
|
|
318
|
-
|
|
319
|
-
export {
|
|
320
|
-
Sidebar,
|
|
321
|
-
sidebar_default
|
|
322
|
-
};
|
package/dist/chunk-TBMUSER2.js
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
Avatar
|
|
4
|
-
} from "./chunk-6RA7LJ3K.js";
|
|
5
|
-
|
|
6
|
-
// components/kit/sidebar.tsx
|
|
7
|
-
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
var cx = (...c) => c.filter(Boolean).join(" ");
|
|
10
|
-
var EASE = "ease-[cubic-bezier(.16,1,.3,1)]";
|
|
11
|
-
var RING = "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent)]";
|
|
12
|
-
var Icon = ({ d, className = "" }) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: cx("h-4 w-4", className), fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
|
|
13
|
-
function Tile({ name, on }) {
|
|
14
|
-
return /* @__PURE__ */ jsx(
|
|
15
|
-
"span",
|
|
16
|
-
{
|
|
17
|
-
"aria-hidden": true,
|
|
18
|
-
className: cx(
|
|
19
|
-
"flex h-7 w-7 shrink-0 items-center justify-center rounded-[7px] text-[12.5px] font-semibold tracking-[-0.02em]",
|
|
20
|
-
on ? "bg-ink text-paper" : cx("bg-paper text-ink", RING)
|
|
21
|
-
),
|
|
22
|
-
children: name.charAt(0)
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
function Label({ hidden, children, className }) {
|
|
27
|
-
return /* @__PURE__ */ jsx(
|
|
28
|
-
"span",
|
|
29
|
-
{
|
|
30
|
-
className: cx(
|
|
31
|
-
"min-w-0 flex-1 overflow-hidden whitespace-nowrap text-left transition-[opacity,transform] duration-300",
|
|
32
|
-
EASE,
|
|
33
|
-
hidden ? "pointer-events-none -translate-x-1 opacity-0" : "translate-x-0 opacity-100 delay-75",
|
|
34
|
-
className
|
|
35
|
-
),
|
|
36
|
-
children
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
function Tip({ children }) {
|
|
41
|
-
return /* @__PURE__ */ jsx(
|
|
42
|
-
"span",
|
|
43
|
-
{
|
|
44
|
-
"aria-hidden": true,
|
|
45
|
-
className: cx(
|
|
46
|
-
"pointer-events-none absolute left-[calc(100%+10px)] top-1/2 z-20 -translate-x-1 -translate-y-1/2 whitespace-nowrap rounded-md bg-ink px-2 py-1 text-[12px] text-paper opacity-0 transition-[opacity,translate] duration-200",
|
|
47
|
-
"group-hover/item:translate-x-0 group-hover/item:opacity-100 group-focus-visible/item:translate-x-0 group-focus-visible/item:opacity-100",
|
|
48
|
-
EASE
|
|
49
|
-
),
|
|
50
|
-
children
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
var itemCls = "group/item relative flex h-9 w-full items-center rounded-lg text-[13.5px] outline-none transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-brand/50";
|
|
55
|
-
function Sidebar({
|
|
56
|
-
workspaces,
|
|
57
|
-
defaultWorkspace,
|
|
58
|
-
onWorkspaceChange,
|
|
59
|
-
groups,
|
|
60
|
-
active: activeProp,
|
|
61
|
-
defaultActive,
|
|
62
|
-
onNavigate,
|
|
63
|
-
collapsed: collapsedProp,
|
|
64
|
-
defaultCollapsed = false,
|
|
65
|
-
onCollapsedChange,
|
|
66
|
-
user,
|
|
67
|
-
className
|
|
68
|
-
}) {
|
|
69
|
-
const [activeState, setActive] = useState(defaultActive ?? groups[0]?.items[0]?.id ?? "");
|
|
70
|
-
const [collapsedState, setCollapsed] = useState(defaultCollapsed);
|
|
71
|
-
const [workspace, setWorkspace] = useState(defaultWorkspace ?? workspaces[0]?.id);
|
|
72
|
-
const [menu, setMenu] = useState(false);
|
|
73
|
-
const active = activeProp ?? activeState;
|
|
74
|
-
const collapsed = collapsedProp ?? collapsedState;
|
|
75
|
-
const current = workspaces.find((w) => w.id === workspace) ?? workspaces[0];
|
|
76
|
-
const nav = useRef(null);
|
|
77
|
-
const indicator = useRef(null);
|
|
78
|
-
const placed = useRef(false);
|
|
79
|
-
const switcher = useRef(null);
|
|
80
|
-
const trigger = useRef(null);
|
|
81
|
-
useLayoutEffect(() => {
|
|
82
|
-
const ind = indicator.current;
|
|
83
|
-
const el = nav.current?.querySelector(`[data-sb-id="${CSS.escape(active)}"]`);
|
|
84
|
-
if (!ind) return;
|
|
85
|
-
if (!el) {
|
|
86
|
-
ind.style.opacity = "0";
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (!placed.current) ind.style.transition = "none";
|
|
90
|
-
ind.style.transform = `translateY(${el.offsetTop}px)`;
|
|
91
|
-
ind.style.opacity = "1";
|
|
92
|
-
if (!placed.current) {
|
|
93
|
-
void ind.offsetHeight;
|
|
94
|
-
ind.style.transition = "";
|
|
95
|
-
placed.current = true;
|
|
96
|
-
}
|
|
97
|
-
}, [active]);
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (!menu) return;
|
|
100
|
-
switcher.current?.querySelector("[role=menuitemradio][aria-checked=true]")?.focus();
|
|
101
|
-
const down = (e) => {
|
|
102
|
-
if (!switcher.current?.contains(e.target)) setMenu(false);
|
|
103
|
-
};
|
|
104
|
-
document.addEventListener("pointerdown", down);
|
|
105
|
-
return () => document.removeEventListener("pointerdown", down);
|
|
106
|
-
}, [menu]);
|
|
107
|
-
const navigate = (id) => {
|
|
108
|
-
setActive(id);
|
|
109
|
-
onNavigate?.(id);
|
|
110
|
-
};
|
|
111
|
-
const toggle = () => {
|
|
112
|
-
setCollapsed(!collapsed);
|
|
113
|
-
onCollapsedChange?.(!collapsed);
|
|
114
|
-
};
|
|
115
|
-
const pick = (id) => {
|
|
116
|
-
setWorkspace(id);
|
|
117
|
-
onWorkspaceChange?.(id);
|
|
118
|
-
setMenu(false);
|
|
119
|
-
trigger.current?.focus();
|
|
120
|
-
};
|
|
121
|
-
const rove = (e, selector, root) => {
|
|
122
|
-
const els = [...root?.querySelectorAll(selector) ?? []];
|
|
123
|
-
const i = els.indexOf(document.activeElement);
|
|
124
|
-
const next = { ArrowDown: i + 1, ArrowUp: i - 1, Home: 0, End: els.length - 1 }[e.key];
|
|
125
|
-
if (next === void 0 || !els.length) return;
|
|
126
|
-
e.preventDefault();
|
|
127
|
-
els[(next + els.length) % els.length]?.focus();
|
|
128
|
-
};
|
|
129
|
-
return /* @__PURE__ */ jsxs(
|
|
130
|
-
"aside",
|
|
131
|
-
{
|
|
132
|
-
"aria-label": "Sidebar",
|
|
133
|
-
"data-collapsed": collapsed || void 0,
|
|
134
|
-
className: cx(
|
|
135
|
-
"relative flex h-full shrink-0 flex-col bg-paper-2 px-3 py-3 transition-[width] duration-500",
|
|
136
|
-
EASE,
|
|
137
|
-
collapsed ? "w-16" : "w-[248px]",
|
|
138
|
-
className
|
|
139
|
-
),
|
|
140
|
-
children: [
|
|
141
|
-
/* @__PURE__ */ jsx("style", { href: "asta-sidebar", precedence: "asta", children: `
|
|
142
|
-
@keyframes kit-sb-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
|
|
143
|
-
@media (prefers-reduced-motion: reduce) { .kit-sb, .kit-sb * { animation: none !important; transition-duration: 0s !important; } }
|
|
144
|
-
` }),
|
|
145
|
-
/* @__PURE__ */ jsxs("div", { className: "kit-sb flex min-h-0 flex-1 flex-col", children: [
|
|
146
|
-
/* @__PURE__ */ jsxs("div", { ref: switcher, className: "relative", children: [
|
|
147
|
-
/* @__PURE__ */ jsxs(
|
|
148
|
-
"button",
|
|
149
|
-
{
|
|
150
|
-
ref: trigger,
|
|
151
|
-
type: "button",
|
|
152
|
-
"aria-haspopup": "menu",
|
|
153
|
-
"aria-expanded": menu,
|
|
154
|
-
"aria-label": collapsed ? `Workspace: ${current?.name}` : void 0,
|
|
155
|
-
onClick: () => setMenu((v) => !v),
|
|
156
|
-
onKeyDown: (e) => {
|
|
157
|
-
if (e.key === "ArrowDown" && !menu) {
|
|
158
|
-
e.preventDefault();
|
|
159
|
-
setMenu(true);
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
className: cx(itemCls, "h-11 hover:bg-[color-mix(in_srgb,var(--ink)_5%,transparent)] aria-expanded:bg-[color-mix(in_srgb,var(--ink)_5%,transparent)]"),
|
|
163
|
-
children: [
|
|
164
|
-
/* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: current && /* @__PURE__ */ jsx(Tile, { name: current.name, on: true }) }),
|
|
165
|
-
/* @__PURE__ */ jsxs(Label, { hidden: collapsed, className: "flex flex-col leading-tight", children: [
|
|
166
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[13.5px] font-medium text-ink", children: current?.name }),
|
|
167
|
-
current?.plan && /* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: current.plan })
|
|
168
|
-
] }),
|
|
169
|
-
/* @__PURE__ */ jsx(
|
|
170
|
-
Icon,
|
|
171
|
-
{
|
|
172
|
-
d: "m5.5 6 2.5-2.5L10.5 6M5.5 10l2.5 2.5 2.5-2.5",
|
|
173
|
-
className: cx("mr-2 shrink-0 text-mute transition-opacity duration-300", collapsed ? "opacity-0" : "opacity-100")
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
collapsed && /* @__PURE__ */ jsx(Tip, { children: current?.name })
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
),
|
|
180
|
-
menu && /* @__PURE__ */ jsxs(
|
|
181
|
-
"div",
|
|
182
|
-
{
|
|
183
|
-
role: "menu",
|
|
184
|
-
"aria-label": "Switch workspace",
|
|
185
|
-
onKeyDown: (e) => {
|
|
186
|
-
if (e.key === "Escape" || e.key === "Tab") {
|
|
187
|
-
if (e.key === "Escape") e.preventDefault();
|
|
188
|
-
setMenu(false);
|
|
189
|
-
trigger.current?.focus();
|
|
190
|
-
} else rove(e, "[role=menuitemradio]", e.currentTarget);
|
|
191
|
-
},
|
|
192
|
-
className: "absolute left-0 top-[calc(100%+6px)] z-30 w-[232px] origin-top-left rounded-xl bg-paper p-1.5 shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent),0_16px_36px_-14px_rgb(0_0_0/0.3)]",
|
|
193
|
-
style: { animation: "kit-sb-pop .32s cubic-bezier(.16,1,.3,1) both" },
|
|
194
|
-
children: [
|
|
195
|
-
/* @__PURE__ */ jsx("p", { className: "px-2 pb-1.5 pt-1 text-[11.5px] text-mute", children: "Workspaces" }),
|
|
196
|
-
workspaces.map((w) => {
|
|
197
|
-
const on = w.id === current?.id;
|
|
198
|
-
return /* @__PURE__ */ jsxs(
|
|
199
|
-
"button",
|
|
200
|
-
{
|
|
201
|
-
type: "button",
|
|
202
|
-
role: "menuitemradio",
|
|
203
|
-
"aria-checked": on,
|
|
204
|
-
onClick: () => pick(w.id),
|
|
205
|
-
className: "flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 text-left outline-none transition-colors hover:bg-paper-2 focus-visible:bg-paper-2",
|
|
206
|
-
children: [
|
|
207
|
-
/* @__PURE__ */ jsx(Tile, { name: w.name, on }),
|
|
208
|
-
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col leading-tight", children: [
|
|
209
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[13.5px] text-ink", children: w.name }),
|
|
210
|
-
w.plan && /* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: w.plan })
|
|
211
|
-
] }),
|
|
212
|
-
on && /* @__PURE__ */ jsx(Icon, { d: "M3.5 8.5l3 3 6-7", className: "shrink-0 text-brand" })
|
|
213
|
-
]
|
|
214
|
-
},
|
|
215
|
-
w.id
|
|
216
|
-
);
|
|
217
|
-
})
|
|
218
|
-
]
|
|
219
|
-
}
|
|
220
|
-
)
|
|
221
|
-
] }),
|
|
222
|
-
/* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "mt-4 min-h-0 flex-1", onKeyDown: (e) => rove(e, "[data-sb-id]", nav.current), children: /* @__PURE__ */ jsxs("div", { ref: nav, className: "relative", children: [
|
|
223
|
-
/* @__PURE__ */ jsx(
|
|
224
|
-
"span",
|
|
225
|
-
{
|
|
226
|
-
ref: indicator,
|
|
227
|
-
"aria-hidden": true,
|
|
228
|
-
className: cx(
|
|
229
|
-
"absolute inset-x-0 top-0 h-9 rounded-lg bg-paper opacity-0 shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_8%,transparent),0_1px_2px_rgb(0_0_0/0.06)] transition-[transform,opacity] duration-500",
|
|
230
|
-
EASE
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
),
|
|
234
|
-
groups.map((g, gi) => /* @__PURE__ */ jsxs("div", { className: cx(gi > 0 && "mt-3"), children: [
|
|
235
|
-
g.label && /* @__PURE__ */ jsxs("div", { className: "relative flex h-7 items-center px-3", "aria-hidden": collapsed || void 0, children: [
|
|
236
|
-
/* @__PURE__ */ jsx("span", { className: cx("text-[11.5px] text-mute transition-opacity duration-300", collapsed ? "opacity-0" : "opacity-100"), children: g.label }),
|
|
237
|
-
/* @__PURE__ */ jsx(
|
|
238
|
-
"span",
|
|
239
|
-
{
|
|
240
|
-
className: cx(
|
|
241
|
-
"absolute left-1/2 h-px w-3 -translate-x-1/2 bg-[color-mix(in_srgb,var(--ink)_14%,transparent)] transition-opacity duration-300",
|
|
242
|
-
collapsed ? "opacity-100" : "opacity-0"
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
)
|
|
246
|
-
] }),
|
|
247
|
-
/* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-0.5", children: g.items.map((it) => {
|
|
248
|
-
const on = it.id === active;
|
|
249
|
-
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
250
|
-
"button",
|
|
251
|
-
{
|
|
252
|
-
type: "button",
|
|
253
|
-
"data-sb-id": it.id,
|
|
254
|
-
"aria-current": on ? "page" : void 0,
|
|
255
|
-
"aria-label": collapsed ? it.label : void 0,
|
|
256
|
-
onClick: () => navigate(it.id),
|
|
257
|
-
className: cx(itemCls, on ? "text-ink" : "text-ink-2 hover:text-ink hover:bg-[color-mix(in_srgb,var(--ink)_4%,transparent)]"),
|
|
258
|
-
children: [
|
|
259
|
-
/* @__PURE__ */ jsxs("span", { className: cx("relative flex w-10 shrink-0 justify-center transition-colors duration-300", on ? "text-brand" : "text-mute group-hover/item:text-ink"), children: [
|
|
260
|
-
it.icon,
|
|
261
|
-
!!it.badge && /* @__PURE__ */ jsx(
|
|
262
|
-
"span",
|
|
263
|
-
{
|
|
264
|
-
className: cx(
|
|
265
|
-
"absolute right-2 top-0 h-1.5 w-1.5 rounded-full bg-brand shadow-[0_0_0_2px_var(--paper-2)] transition-[opacity,transform] duration-300",
|
|
266
|
-
EASE,
|
|
267
|
-
collapsed ? "scale-100 opacity-100" : "scale-50 opacity-0"
|
|
268
|
-
)
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
] }),
|
|
272
|
-
/* @__PURE__ */ jsx(Label, { hidden: collapsed, className: "relative", children: it.label }),
|
|
273
|
-
!!it.badge && /* @__PURE__ */ jsx(
|
|
274
|
-
"span",
|
|
275
|
-
{
|
|
276
|
-
className: cx(
|
|
277
|
-
"relative mr-2 rounded-md bg-[color-mix(in_srgb,var(--ink)_6%,transparent)] px-1.5 text-[11.5px] tabular-nums leading-5 text-mute transition-opacity duration-300",
|
|
278
|
-
collapsed ? "opacity-0" : "opacity-100"
|
|
279
|
-
),
|
|
280
|
-
children: it.badge
|
|
281
|
-
}
|
|
282
|
-
),
|
|
283
|
-
collapsed && /* @__PURE__ */ jsx(Tip, { children: it.label })
|
|
284
|
-
]
|
|
285
|
-
}
|
|
286
|
-
) }, it.id);
|
|
287
|
-
}) })
|
|
288
|
-
] }, g.label ?? gi))
|
|
289
|
-
] }) }),
|
|
290
|
-
/* @__PURE__ */ jsxs(
|
|
291
|
-
"button",
|
|
292
|
-
{
|
|
293
|
-
type: "button",
|
|
294
|
-
"aria-pressed": collapsed,
|
|
295
|
-
"aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
296
|
-
onClick: toggle,
|
|
297
|
-
className: cx(itemCls, "text-mute hover:bg-[color-mix(in_srgb,var(--ink)_4%,transparent)] hover:text-ink"),
|
|
298
|
-
children: [
|
|
299
|
-
/* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: /* @__PURE__ */ jsx(Icon, { d: "M2.5 3.5h11v9h-11zM6 3.5v9M10.5 6.5 9 8l1.5 1.5", className: cx("transition-transform duration-500", EASE, collapsed && "-scale-x-100") }) }),
|
|
300
|
-
/* @__PURE__ */ jsx(Label, { hidden: collapsed, children: "Collapse" }),
|
|
301
|
-
collapsed && /* @__PURE__ */ jsx(Tip, { children: "Expand" })
|
|
302
|
-
]
|
|
303
|
-
}
|
|
304
|
-
),
|
|
305
|
-
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-12 items-center rounded-lg", children: [
|
|
306
|
-
/* @__PURE__ */ jsx("span", { className: "flex w-10 shrink-0 justify-center", children: /* @__PURE__ */ jsx(Avatar, { name: user.name, src: user.src, size: "sm" }) }),
|
|
307
|
-
/* @__PURE__ */ jsxs(Label, { hidden: collapsed, className: "flex flex-col pl-1 leading-tight", children: [
|
|
308
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[13px] font-medium text-ink", children: user.name }),
|
|
309
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[11.5px] text-mute", children: user.email })
|
|
310
|
-
] })
|
|
311
|
-
] })
|
|
312
|
-
] })
|
|
313
|
-
]
|
|
314
|
-
}
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
var sidebar_default = Sidebar;
|
|
318
|
-
|
|
319
|
-
export {
|
|
320
|
-
Sidebar,
|
|
321
|
-
sidebar_default
|
|
322
|
-
};
|