elysia-rack 0.2.0 → 0.3.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.
@@ -1,172 +0,0 @@
1
- import {
2
- listRacks
3
- } from "./index-zc7rgvmm.js";
4
- import"./index-37x76zdn.js";
5
-
6
- // src/react/page/components/Breadcrumb.tsx
7
- import { jsxDEV } from "react/jsx-dev-runtime";
8
- function Breadcrumb({ trail }) {
9
- return /* @__PURE__ */ jsxDEV("nav", {
10
- "aria-label": "Breadcrumb",
11
- className: "pb-3 text-sm",
12
- children: /* @__PURE__ */ jsxDEV("ol", {
13
- className: "flex flex-wrap items-center gap-1.5",
14
- children: trail.map((item, i) => {
15
- const last = i === trail.length - 1;
16
- return /* @__PURE__ */ jsxDEV("li", {
17
- className: "flex items-center gap-1.5",
18
- children: [
19
- i > 0 ? /* @__PURE__ */ jsxDEV("span", {
20
- "aria-hidden": "true",
21
- className: "text-text-muted",
22
- children: "/"
23
- }, undefined, false, undefined, this) : null,
24
- item.href && !last ? /* @__PURE__ */ jsxDEV("a", {
25
- href: item.href,
26
- className: "text-text-muted hover:text-foreground",
27
- children: item.label
28
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV("span", {
29
- "aria-current": last ? "page" : undefined,
30
- className: last ? "text-foreground font-semibold" : "text-text-muted",
31
- children: item.label
32
- }, undefined, false, undefined, this)
33
- ]
34
- }, `${item.label}-${i}`, true, undefined, this);
35
- })
36
- }, undefined, false, undefined, this)
37
- }, undefined, false, undefined, this);
38
- }
39
-
40
- // src/react/page/components/Sidebar.tsx
41
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
42
- function Sidebar({ title, groups }) {
43
- return /* @__PURE__ */ jsxDEV2("aside", {
44
- className: "bg-sidebar text-sidebar-foreground border-sidebar-border min-h-0 w-64 shrink-0 overflow-y-auto rounded-lg border",
45
- children: [
46
- /* @__PURE__ */ jsxDEV2("div", {
47
- className: "border-sidebar-border border-b px-4 py-3",
48
- children: /* @__PURE__ */ jsxDEV2("p", {
49
- className: "font-koran text-xl font-black tracking-tight",
50
- children: title
51
- }, undefined, false, undefined, this)
52
- }, undefined, false, undefined, this),
53
- /* @__PURE__ */ jsxDEV2("nav", {
54
- className: "flex flex-col gap-4 p-3",
55
- children: groups.map((group) => /* @__PURE__ */ jsxDEV2("section", {
56
- children: /* @__PURE__ */ jsxDEV2("details", {
57
- className: "group",
58
- open: group.items.some((item) => item.active) || undefined,
59
- children: [
60
- /* @__PURE__ */ jsxDEV2("summary", {
61
- className: "font-koran border-sidebar-border flex cursor-pointer list-none items-center justify-between border-b px-2 pb-1 text-base font-bold tracking-tight [&::-webkit-details-marker]:hidden",
62
- children: [
63
- /* @__PURE__ */ jsxDEV2("span", {
64
- children: group.name
65
- }, undefined, false, undefined, this),
66
- /* @__PURE__ */ jsxDEV2("span", {
67
- "aria-hidden": "true",
68
- className: "text-text-muted text-xs transition group-open:rotate-180",
69
- children: "▾"
70
- }, undefined, false, undefined, this)
71
- ]
72
- }, undefined, true, undefined, this),
73
- /* @__PURE__ */ jsxDEV2("ul", {
74
- className: "border-sidebar-border mt-1 ml-2 flex flex-col gap-0.5 border-l py-1 pl-2",
75
- children: group.items.map((item) => /* @__PURE__ */ jsxDEV2("li", {
76
- children: /* @__PURE__ */ jsxDEV2("a", {
77
- href: item.href,
78
- "aria-current": item.active ? "page" : undefined,
79
- className: item.active ? "bg-sidebar-primary text-sidebar-primary-foreground flex items-center gap-2 rounded-md px-2 py-1.5 text-sm font-semibold" : "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground flex items-center gap-2 rounded-md px-2 py-1.5 text-sm",
80
- children: [
81
- item.icon ? /* @__PURE__ */ jsxDEV2("span", {
82
- "aria-hidden": "true",
83
- children: item.icon
84
- }, undefined, false, undefined, this) : null,
85
- /* @__PURE__ */ jsxDEV2("span", {
86
- children: item.label
87
- }, undefined, false, undefined, this)
88
- ]
89
- }, undefined, true, undefined, this)
90
- }, item.id, false, undefined, this))
91
- }, undefined, false, undefined, this)
92
- ]
93
- }, undefined, true, undefined, this)
94
- }, group.name, false, undefined, this))
95
- }, undefined, false, undefined, this)
96
- ]
97
- }, undefined, true, undefined, this);
98
- }
99
-
100
- // src/react/page/Dashboard.tsx
101
- import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
102
- function itemLabel(r) {
103
- return r.metadata.pluralLabel ?? r.metadata.label ?? r.metadata.id;
104
- }
105
- function buildGroups(racks, selectedId) {
106
- const byGroup = new Map;
107
- for (const r of racks) {
108
- if (r.metadata.hidden)
109
- continue;
110
- const name = r.metadata.group ?? "General";
111
- let group = byGroup.get(name);
112
- if (!group) {
113
- group = { name, items: [] };
114
- byGroup.set(name, group);
115
- }
116
- group.items.push({
117
- id: r.metadata.id,
118
- label: itemLabel(r),
119
- icon: r.metadata.icon,
120
- href: `?resource=${encodeURIComponent(r.metadata.id)}`,
121
- active: r.metadata.id === selectedId
122
- });
123
- }
124
- const groups = [...byGroup.values()].sort((a, b) => a.name.localeCompare(b.name));
125
- for (const group of groups) {
126
- const orderOf = (id) => racks.find((r) => r.metadata.id === id)?.metadata.order ?? 0;
127
- group.items.sort((a, b) => orderOf(a.id) - orderOf(b.id) || a.label.localeCompare(b.label));
128
- }
129
- return groups;
130
- }
131
- async function Dashboard(props) {
132
- const racks = (props.racks ?? listRacks()).filter((r) => !r.metadata.hidden);
133
- const selected = racks.find((r) => r.metadata.id === props.resource) ?? racks[0];
134
- const groups = buildGroups(racks, selected?.metadata.id);
135
- const trail = [
136
- { label: "Dashboard", href: "?" },
137
- ...selected?.metadata.group ? [{ label: selected.metadata.group }] : [],
138
- ...selected ? [{ label: itemLabel(selected) }] : []
139
- ];
140
- return /* @__PURE__ */ jsxDEV3("div", {
141
- className: "koran-paper font-koran-body text-foreground flex flex-col min-h-screen",
142
- children: /* @__PURE__ */ jsxDEV3("div", {
143
- className: "flex min-h-0 flex-1 gap-6 p-4 sm:p-6 h-full",
144
- children: [
145
- /* @__PURE__ */ jsxDEV3(Sidebar, {
146
- title: props.name ?? "Panel",
147
- groups
148
- }, undefined, false, undefined, this),
149
- /* @__PURE__ */ jsxDEV3("main", {
150
- className: "flex min-w-0 flex-1 flex-col",
151
- children: [
152
- /* @__PURE__ */ jsxDEV3(Breadcrumb, {
153
- trail
154
- }, undefined, false, undefined, this),
155
- selected ? /* @__PURE__ */ jsxDEV3("iframe", {
156
- src: selected.path,
157
- title: itemLabel(selected),
158
- sandbox: "allow-scripts allow-same-origin allow-forms",
159
- className: "bg-card min-h-0 w-full flex-1 rounded-lg"
160
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("p", {
161
- className: "text-text-muted border-border rounded-lg border px-4 py-10 text-center",
162
- children: "No resources registered. Mount a resource with rack() first."
163
- }, undefined, false, undefined, this)
164
- ]
165
- }, undefined, true, undefined, this)
166
- ]
167
- }, undefined, true, undefined, this)
168
- }, undefined, false, undefined, this);
169
- }
170
- export {
171
- Dashboard as default
172
- };