elysia-rack 0.4.0 → 0.5.2

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.
@@ -0,0 +1,157 @@
1
+ import {
2
+ RackIcon
3
+ } from "./index-vq4gh509.js";
4
+
5
+ // src/react/page/components/Sidebar.tsx
6
+ import { jsxDEV } from "react/jsx-dev-runtime";
7
+ function SidebarItemView({ item, depth = 0 }) {
8
+ const hasChildren = item.children && item.children.length > 0;
9
+ return /* @__PURE__ */ jsxDEV("li", {
10
+ children: [
11
+ /* @__PURE__ */ jsxDEV("a", {
12
+ href: item.href,
13
+ "aria-current": item.active ? "page" : undefined,
14
+ className: item.active ? "bg-sidebar-primary text-sidebar-primary-foreground flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm font-medium" : "text-sidebar-foreground hover:bg-sidebar-accent flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm",
15
+ style: depth > 0 ? { paddingLeft: `${10 + depth * 12}px` } : undefined,
16
+ children: [
17
+ item.icon ? /* @__PURE__ */ jsxDEV(RackIcon, {
18
+ name: item.icon,
19
+ size: 16,
20
+ className: "size-4 shrink-0"
21
+ }, undefined, false, undefined, this) : null,
22
+ /* @__PURE__ */ jsxDEV("span", {
23
+ children: item.label
24
+ }, undefined, false, undefined, this)
25
+ ]
26
+ }, undefined, true, undefined, this),
27
+ hasChildren ? /* @__PURE__ */ jsxDEV("ul", {
28
+ className: "border-sidebar-border mt-0.5 ml-2 flex flex-col gap-0.5 border-l py-1 pl-2",
29
+ children: item.children.map((child) => /* @__PURE__ */ jsxDEV(SidebarItemView, {
30
+ item: child,
31
+ depth: depth + 1
32
+ }, child.id, false, undefined, this))
33
+ }, undefined, false, undefined, this) : null
34
+ ]
35
+ }, undefined, true, undefined, this);
36
+ }
37
+ function hasActive(items) {
38
+ for (const it of items) {
39
+ if (it.active)
40
+ return true;
41
+ if (it.children && hasActive(it.children))
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+ function Sidebar({ title, groups }) {
47
+ return /* @__PURE__ */ jsxDEV("aside", {
48
+ className: "border-sidebar-border bg-sidebar shrink-0 border-b lg:sticky lg:top-0 lg:h-screen lg:w-60 lg:overflow-y-auto lg:border-r lg:border-b-0 xl:w-64",
49
+ children: [
50
+ /* @__PURE__ */ jsxDEV("input", {
51
+ type: "checkbox",
52
+ id: "rack-nav-toggle",
53
+ "aria-label": "Toggle navigation",
54
+ className: "peer sr-only"
55
+ }, undefined, false, undefined, this),
56
+ /* @__PURE__ */ jsxDEV("div", {
57
+ className: "border-sidebar-border flex items-center justify-between gap-3 border-b px-4 py-3",
58
+ children: [
59
+ /* @__PURE__ */ jsxDEV("a", {
60
+ href: "/",
61
+ className: "flex items-center gap-2.5",
62
+ children: [
63
+ /* @__PURE__ */ jsxDEV("span", {
64
+ "aria-hidden": "true",
65
+ className: "bg-gold text-gold-foreground flex size-6 shrink-0 items-center justify-center text-[13px] font-semibold",
66
+ children: title.charAt(0).toUpperCase()
67
+ }, undefined, false, undefined, this),
68
+ /* @__PURE__ */ jsxDEV("span", {
69
+ className: "font-display text-[15px] tracking-tight",
70
+ children: title
71
+ }, undefined, false, undefined, this)
72
+ ]
73
+ }, undefined, true, undefined, this),
74
+ /* @__PURE__ */ jsxDEV("label", {
75
+ htmlFor: "rack-nav-toggle",
76
+ className: "border-border text-muted-foreground hover:bg-navigation-hover cursor-pointer rounded-md border px-2.5 py-1 text-xs lg:hidden",
77
+ children: "Menu"
78
+ }, undefined, false, undefined, this)
79
+ ]
80
+ }, undefined, true, undefined, this),
81
+ /* @__PURE__ */ jsxDEV("nav", {
82
+ className: "hidden flex-col gap-4 overflow-y-auto px-3 py-3 peer-checked:flex lg:flex lg:py-4",
83
+ children: groups.map((group) => /* @__PURE__ */ jsxDEV("section", {
84
+ children: /* @__PURE__ */ jsxDEV("details", {
85
+ className: "group",
86
+ open: hasActive(group.items) || undefined,
87
+ children: [
88
+ /* @__PURE__ */ jsxDEV("summary", {
89
+ className: "text-text-muted flex cursor-pointer list-none items-center justify-between px-2.5 pb-1.5 text-xs font-medium [&::-webkit-details-marker]:hidden",
90
+ children: [
91
+ /* @__PURE__ */ jsxDEV("span", {
92
+ children: group.name
93
+ }, undefined, false, undefined, this),
94
+ /* @__PURE__ */ jsxDEV("span", {
95
+ "aria-hidden": "true",
96
+ className: "text-text-subtle transition-transform group-open:rotate-180",
97
+ children: "▾"
98
+ }, undefined, false, undefined, this)
99
+ ]
100
+ }, undefined, true, undefined, this),
101
+ /* @__PURE__ */ jsxDEV("ul", {
102
+ className: "border-sidebar-border mt-1 ml-2 flex flex-col gap-0.5 border-l py-1 pl-2",
103
+ children: group.items.map((item) => /* @__PURE__ */ jsxDEV(SidebarItemView, {
104
+ item
105
+ }, item.id, false, undefined, this))
106
+ }, undefined, false, undefined, this)
107
+ ]
108
+ }, undefined, true, undefined, this)
109
+ }, group.name, false, undefined, this))
110
+ }, undefined, false, undefined, this)
111
+ ]
112
+ }, undefined, true, undefined, this);
113
+ }
114
+
115
+ // src/react/page/components/Masthead.tsx
116
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
117
+ function Masthead({ title, icon, detail, actions }) {
118
+ return /* @__PURE__ */ jsxDEV2("header", {
119
+ className: "flex flex-wrap items-start justify-between gap-3 pb-4",
120
+ children: [
121
+ /* @__PURE__ */ jsxDEV2("div", {
122
+ className: "min-w-0",
123
+ children: [
124
+ /* @__PURE__ */ jsxDEV2("h1", {
125
+ className: "font-display flex items-center gap-2 text-2xl leading-tight tracking-tight",
126
+ children: [
127
+ icon ? /* @__PURE__ */ jsxDEV2(RackIcon, {
128
+ name: icon,
129
+ size: 22,
130
+ className: "size-[22px] shrink-0"
131
+ }, undefined, false, undefined, this) : null,
132
+ title
133
+ ]
134
+ }, undefined, true, undefined, this),
135
+ detail ? /* @__PURE__ */ jsxDEV2("p", {
136
+ className: "text-text-muted mt-1 text-sm",
137
+ children: detail
138
+ }, undefined, false, undefined, this) : null
139
+ ]
140
+ }, undefined, true, undefined, this),
141
+ /* @__PURE__ */ jsxDEV2("div", {
142
+ className: "flex shrink-0 items-center gap-2",
143
+ children: [
144
+ actions,
145
+ /* @__PURE__ */ jsxDEV2("button", {
146
+ id: "koran-theme-toggle",
147
+ type: "button",
148
+ className: "border-border text-muted-foreground hover:bg-navigation-hover hover:text-foreground rounded-md border px-2.5 py-1.5 text-xs",
149
+ children: "◐ Theme"
150
+ }, undefined, false, undefined, this)
151
+ ]
152
+ }, undefined, true, undefined, this)
153
+ ]
154
+ }, undefined, true, undefined, this);
155
+ }
156
+
157
+ export { Sidebar, Masthead };
@@ -0,0 +1,40 @@
1
+ // src/react/page/components/Icon.tsx
2
+ import { icons } from "lucide-react";
3
+ import { jsxDEV } from "react/jsx-dev-runtime";
4
+ function iconKey(name) {
5
+ return name.replace(/[^a-zA-Z0-9]+/g, " ").trim().split(" ").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
6
+ }
7
+ function RackIcon({ name, ...props }) {
8
+ if (!name)
9
+ return null;
10
+ const Icon = icons[iconKey(name)];
11
+ if (!Icon)
12
+ return /* @__PURE__ */ jsxDEV("span", {
13
+ "aria-hidden": "true",
14
+ children: name
15
+ }, undefined, false, undefined, this);
16
+ return /* @__PURE__ */ jsxDEV(Icon, {
17
+ "aria-hidden": "true",
18
+ ...props
19
+ }, undefined, false, undefined, this);
20
+ }
21
+
22
+ // src/react/donate.ts
23
+ var DEFAULT_DONATE_URL = "https://ko-fi.com/notoofly_manu";
24
+ var DEFAULT_DONATE_LABEL = "Donate on Ko-fi";
25
+ var globalDonate = { enabled: true, url: DEFAULT_DONATE_URL, label: DEFAULT_DONATE_LABEL };
26
+ function setGlobalDonate(enabled) {
27
+ globalDonate = { enabled: enabled !== false, url: DEFAULT_DONATE_URL, label: DEFAULT_DONATE_LABEL };
28
+ }
29
+ function getGlobalDonate() {
30
+ return globalDonate;
31
+ }
32
+ function resolveDonateProp(prop) {
33
+ if (prop === false)
34
+ return { enabled: false, url: DEFAULT_DONATE_URL, label: DEFAULT_DONATE_LABEL };
35
+ if (prop === true || prop === undefined)
36
+ return getGlobalDonate();
37
+ return getGlobalDonate();
38
+ }
39
+
40
+ export { RackIcon, setGlobalDonate, resolveDonateProp };