@skiddph/prui 0.6.0 → 0.7.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,969 +0,0 @@
1
- import { jsx as e, jsxs as p, Fragment as Oe } from "react/jsx-runtime";
2
- import * as s from "react";
3
- import { Routes as Ae, Route as ae, Navigate as De, MemoryRouter as ze, BrowserRouter as Fe, useLocation as ce, useNavigate as Le, Outlet as Ie, Link as Be, NavLink as _e } from "react-router-dom";
4
- import { ChevronsRight as re, ChevronsLeft as ne, X as qe, Menu as Ke, Search as Ue, Palette as Ve, ChevronDown as He, Pencil as Je, Trash2 as Ye, Plus as We, Clock as Xe } from "lucide-react";
5
- import { cn as S } from "../core/cn.js";
6
- import { Dropdown as Ge } from "../core/dropdown.js";
7
- import { Button as D } from "../core/button.js";
8
- import { resolveThemeName as Qe, themeMode as Ze, readPersistedTheme as et, applyTheme as le, listThemes as tt, clearAppliedTokens as at } from "../theme.js";
9
- import { Modal as me, confirmModal as rt } from "../core/modal.js";
10
- import { b as nt, D as lt, a as st } from "./data-table-toolbar-BUy2EWPy.js";
11
- import { Textarea as it, Input as W } from "../core/input.js";
12
- import { Label as ot } from "../core/label.js";
13
- import { Select as pe } from "../core/select.js";
14
- import { Switch as fe } from "../core/switch.js";
15
- import { Card as he, CardHeader as be, CardDescription as ve, CardTitle as ge, CardContent as xe } from "../core/card.js";
16
- const dt = [
17
- { path: "/login", name: "login" },
18
- { path: "/register", name: "register" },
19
- { path: "/forgot-password", name: "forgotPassword" },
20
- { path: "/reset-password", name: "resetPassword" },
21
- { path: "/otp", name: "otp" },
22
- { path: "/logout", name: "logout" }
23
- ], ut = [
24
- { path: "/404", name: "notFound" },
25
- { path: "/error", name: "error" },
26
- { path: "/profile", name: "profile" },
27
- { path: "/settings", name: "settings" },
28
- { path: "/admin-setup", name: "adminSetup" }
29
- ];
30
- function ct({ mode: t, config: r, children: n }) {
31
- const a = t === "auth" || t === "auth+utility", l = t === "utility" || t === "auth+utility", m = [
32
- ...a ? dt : [],
33
- ...l ? ut : []
34
- ], [f, g] = s.useState(null);
35
- return s.useEffect(() => {
36
- let x = !1;
37
- return import("../pages.js").then((u) => {
38
- x || g(u.PagesRegistry);
39
- }), () => {
40
- x = !0;
41
- };
42
- }, []), f ? /* @__PURE__ */ p(Ae, { children: [
43
- m.map(({ path: x, name: u }) => {
44
- const w = f[u];
45
- return w ? /* @__PURE__ */ e(ae, { path: x, element: /* @__PURE__ */ e(w, { ...(r == null ? void 0 : r[u]) ?? {} }) }, x) : null;
46
- }),
47
- n,
48
- a ? /* @__PURE__ */ e(ae, { path: "*", element: /* @__PURE__ */ e(De, { to: "/login", replace: !0 }) }) : null
49
- ] }) : /* @__PURE__ */ e("div", { className: "p-8 text-center text-sm text-[var(--prui-dim)]", children: "Loading…" });
50
- }
51
- const mt = s.lazy(
52
- () => Promise.resolve().then(() => Pt).then((t) => ({ default: t.SessionTimeout }))
53
- );
54
- function pt(t) {
55
- const r = t !== !1, n = typeof t == "object" ? t : {}, a = n.persist !== !1, l = Qe(n.default ?? "control"), m = Ze(l), [f, g] = s.useState(() => (a ? et() : null) ?? { theme: l, mode: m }), x = s.useCallback(
56
- (u) => {
57
- g(u), le({ theme: u.theme, mode: u.mode, storageKey: a ? "prui:theme" : null });
58
- },
59
- [a]
60
- );
61
- return s.useEffect(() => {
62
- le({ theme: f.theme, mode: f.mode, storageKey: a ? "prui:theme" : null });
63
- }, [f, a]), { enabled: r, state: f, setTheme: x };
64
- }
65
- function ft({ config: t }) {
66
- const { enabled: r, state: n, setTheme: a } = pt(t);
67
- return r ? /* @__PURE__ */ e(
68
- Ge,
69
- {
70
- align: "end",
71
- trigger: /* @__PURE__ */ e(
72
- "button",
73
- {
74
- type: "button",
75
- "aria-label": "Switch theme",
76
- title: `Theme: ${n.theme}`,
77
- "data-testid": "theme-toggle",
78
- className: "inline-flex h-8 w-8 items-center justify-center rounded-[var(--prui-radius)] text-[var(--prui-dim)] hover:bg-[var(--prui-raise)] hover:text-[var(--prui-fg)] cursor-pointer",
79
- children: /* @__PURE__ */ e(Ve, { className: "h-4 w-4", "aria-hidden": !0 })
80
- }
81
- ),
82
- items: tt().map((l) => ({
83
- label: `${l}${l === n.theme ? " (active)" : ""}`,
84
- onSelect: () => {
85
- at(), a({ theme: l, mode: l === "daylight" ? "light" : "dark" });
86
- }
87
- }))
88
- }
89
- ) : null;
90
- }
91
- function se(t, r) {
92
- return r === "/" ? t === "/" : t === r || t.startsWith(r + "/");
93
- }
94
- function ht({ item: t, onNavigate: r, expandAllOn: n, collapsed: a }) {
95
- const { pathname: l } = ce(), m = (t.items ?? []).some(
96
- (u) => u.href ? se(l, u.href) : (u.items ?? []).some((w) => w.href && se(l, w.href))
97
- ), [f, g] = s.useState(m || n !== void 0 && l === n);
98
- s.useEffect(() => {
99
- m && g(!0);
100
- }, [m]);
101
- const x = t.icon;
102
- return /* @__PURE__ */ p("li", { "data-testid": "nav-group", children: [
103
- /* @__PURE__ */ p(
104
- "button",
105
- {
106
- type: "button",
107
- "aria-expanded": f,
108
- onClick: () => g((u) => !u),
109
- className: S(
110
- "flex w-full items-center gap-2 rounded-[var(--prui-radius)] px-2.5 py-1.5 text-sm cursor-pointer",
111
- m ? "text-[var(--prui-fg)]" : "text-[var(--prui-dim)] hover:text-[var(--prui-fg)]"
112
- ),
113
- children: [
114
- x ? /* @__PURE__ */ e(x, { className: "h-4 w-4 shrink-0", "aria-hidden": !0 }) : /* @__PURE__ */ e("span", { className: S("prui-nav-mono text-[10px] font-semibold"), children: t.label.slice(0, 2).toUpperCase() }),
115
- /* @__PURE__ */ e("span", { className: S("flex-1 text-left truncate", "prui-nav-label"), children: t.label }),
116
- /* @__PURE__ */ e(He, { className: S("prui-nav-chevron h-4 w-4 transition-transform", !f && "-rotate-90"), "aria-hidden": !0 })
117
- ]
118
- }
119
- ),
120
- f ? /* @__PURE__ */ e("ul", { className: "ml-4 mt-0.5 flex flex-col gap-0.5 border-l border-[var(--prui-line)] pl-2", children: (t.items ?? []).map((u) => /* @__PURE__ */ e(ye, { item: u, onNavigate: r, nested: !0, expandAllOn: n, collapsed: a }, u.href ?? u.label)) }) : null
121
- ] });
122
- }
123
- function bt({ label: t }) {
124
- return /* @__PURE__ */ e("li", { className: "px-2.5 pb-1 pt-3 text-[10px] font-semibold uppercase tracking-[0.1em] text-[var(--prui-dim)]", "data-testid": "nav-subgroup", children: t });
125
- }
126
- function ye({ item: t, onNavigate: r, nested: n, expandAllOn: a, collapsed: l }) {
127
- return t.items && t.items.length > 0 ? /* @__PURE__ */ e(ht, { item: t, onNavigate: r, expandAllOn: a, collapsed: l }) : t.heading || !t.href && !t.items ? /* @__PURE__ */ e(bt, { label: t.label }) : t.href ? /* @__PURE__ */ e("li", { children: /* @__PURE__ */ p(
128
- _e,
129
- {
130
- to: t.href,
131
- onClick: r,
132
- className: ({ isActive: m }) => S(
133
- "flex items-center gap-2 rounded-[var(--prui-radius)] px-2.5 py-1.5 text-sm",
134
- n && "pl-2.5",
135
- m ? "bg-[var(--prui-brand)]/15 text-[var(--prui-brand)] font-medium" : "text-[var(--prui-dim)] hover:text-[var(--prui-fg)] hover:bg-[var(--prui-raise)]"
136
- ),
137
- children: [
138
- t.icon && !n ? /* @__PURE__ */ e(t.icon, { className: "h-4 w-4 shrink-0", "aria-hidden": !0 }) : l ? /* @__PURE__ */ e("span", { className: S("prui-nav-mono text-[10px] font-semibold"), children: t.label.slice(0, 2).toUpperCase() }) : null,
139
- /* @__PURE__ */ e("span", { className: S("truncate", l && n && "prui-nav-label", "prui-nav-label"), children: t.label })
140
- ]
141
- }
142
- ) }) : null;
143
- }
144
- function ie({ nav: t, onNavigate: r, expandAllOn: n, collapsed: a }) {
145
- return /* @__PURE__ */ e("nav", { "aria-label": "Main", className: "prui-app-nav", children: /* @__PURE__ */ e("ul", { className: "flex flex-col gap-0.5", children: t.map((l) => /* @__PURE__ */ e(ye, { item: l, onNavigate: r, expandAllOn: n, collapsed: a }, l.href ?? l.label)) }) });
146
- }
147
- function oe({ brand: t }) {
148
- if (!t) return null;
149
- const r = /* @__PURE__ */ p(Oe, { children: [
150
- t.mark ? /* @__PURE__ */ e("img", { src: t.mark, alt: "", className: "h-6 w-6 rounded-[var(--prui-radius-1)] object-cover" }) : null,
151
- /* @__PURE__ */ e("span", { className: "prui-nav-label truncate font-semibold text-[var(--prui-fg)]", children: t.name })
152
- ] }), n = "flex items-center gap-2 px-1 py-1 min-w-0";
153
- return t.href === null ? /* @__PURE__ */ e("div", { className: n, children: r }) : /* @__PURE__ */ e(Be, { to: t.href ?? "/", className: n, "aria-label": t.name, children: r });
154
- }
155
- function vt({
156
- open: t,
157
- onOpenChange: r,
158
- entries: n,
159
- placeholder: a = "Type a command or search...",
160
- onNavigate: l
161
- }) {
162
- const [m, f] = s.useState(""), [g, x] = s.useState(0), u = s.useMemo(() => {
163
- const o = m.trim().toLowerCase();
164
- return o ? n.filter((b) => b.label.toLowerCase().includes(o)) : n;
165
- }, [n, m]);
166
- if (s.useEffect(() => x(0), [m]), !t) return null;
167
- const w = (o) => {
168
- r(!1), o.onSelect ? o.onSelect() : o.href && (l == null || l(o.href));
169
- };
170
- return /* @__PURE__ */ e(
171
- "div",
172
- {
173
- className: "fixed inset-0 z-50 flex items-start justify-center pt-24",
174
- style: { backgroundColor: "rgba(0,0,0,0.55)" },
175
- onMouseDown: (o) => {
176
- o.target === o.currentTarget && r(!1);
177
- },
178
- children: /* @__PURE__ */ p(
179
- "div",
180
- {
181
- role: "dialog",
182
- "aria-modal": "true",
183
- "aria-label": "Command palette",
184
- "data-testid": "command-palette",
185
- className: "w-full max-w-md rounded-[var(--prui-radius)] border border-[var(--prui-line)] bg-[var(--prui-surface)] shadow-xl",
186
- children: [
187
- /* @__PURE__ */ e(
188
- "input",
189
- {
190
- autoFocus: !0,
191
- type: "text",
192
- role: "combobox",
193
- "aria-expanded": "true",
194
- "aria-label": "Command palette search",
195
- "aria-activedescendant": u[g] ? `palette-option-${g}` : void 0,
196
- placeholder: a,
197
- value: m,
198
- onChange: (o) => f(o.target.value),
199
- onKeyDown: (o) => {
200
- if (o.key === "Escape" && r(!1), o.key === "ArrowDown" && (o.preventDefault(), x((b) => Math.min(b + 1, u.length - 1))), o.key === "ArrowUp" && (o.preventDefault(), x((b) => Math.max(b - 1, 0))), o.key === "Enter") {
201
- const b = u[g];
202
- b && (r(!1), b.onSelect ? b.onSelect() : b.href && (l == null || l(b.href)));
203
- }
204
- },
205
- className: "w-full bg-transparent px-4 py-3 text-sm text-[var(--prui-fg)] placeholder:text-[var(--prui-dim)] outline-none border-b border-[var(--prui-line)] rounded-t-[var(--prui-radius)]"
206
- }
207
- ),
208
- /* @__PURE__ */ e("ul", { role: "listbox", className: "max-h-64 overflow-auto p-1", children: u.length === 0 ? /* @__PURE__ */ e("li", { className: "px-3 py-2 text-sm text-[var(--prui-dim)]", children: "No matches." }) : u.map((o, b) => /* @__PURE__ */ p(
209
- "li",
210
- {
211
- id: `palette-option-${b}`,
212
- role: "option",
213
- "aria-selected": b === g,
214
- onMouseEnter: () => x(b),
215
- onClick: () => w(o),
216
- className: S(
217
- "cursor-pointer rounded-[calc(var(--prui-radius)-1px)] px-3 py-2 text-sm text-[var(--prui-fg)]",
218
- b === g && "bg-[var(--prui-raise)]"
219
- ),
220
- children: [
221
- o.group ? /* @__PURE__ */ e("span", { className: "mr-2 text-xs text-[var(--prui-dim)]", children: o.group }) : null,
222
- o.label
223
- ]
224
- },
225
- `${o.label}-${b}`
226
- )) })
227
- ]
228
- }
229
- )
230
- }
231
- );
232
- }
233
- function gt(t) {
234
- const {
235
- brand: r,
236
- nav: n = [],
237
- search: a = !0,
238
- theme: l = !0,
239
- auth: m = !1,
240
- sidebar: f = {},
241
- header: g,
242
- pages: x,
243
- pagesConfig: u,
244
- expandAllOn: w,
245
- layoutType: o = "A",
246
- sidebarHeader: b,
247
- sidebarFooter: z,
248
- children: j
249
- } = t, P = typeof a == "object" ? a : { enabled: a !== !1 }, N = P.enabled !== !1, M = P.hotkey ?? "/", R = f.collapsible !== !1, [C, $] = s.useState(f.defaultOpen === !0), [T, i] = s.useState(!0), [h, v] = s.useState(!1), c = ce(), F = Le(), y = s.useMemo(
250
- () => m === !1 ? null : m === !0 ? {} : m,
251
- [m]
252
- ), K = s.useCallback(() => {
253
- y != null && y.onTimeout ? y.onTimeout() : F((y == null ? void 0 : y.loginPath) ?? "/login");
254
- }, [y, F]), B = s.useMemo(() => {
255
- const E = [];
256
- for (const k of n)
257
- if (k.items)
258
- for (const O of k.items)
259
- O.href && E.push({ label: `${k.label} / ${O.label}`, href: O.href, group: k.label });
260
- else k.href && E.push({ label: k.label, href: k.href });
261
- return E;
262
- }, [n]);
263
- s.useEffect(() => {
264
- if (!N) return;
265
- const E = (k) => {
266
- const O = k.target, V = O && (O.tagName === "INPUT" || O.tagName === "TEXTAREA" || O.isContentEditable);
267
- k.key === M && !V && !k.metaKey && !k.ctrlKey && !k.altKey && (k.preventDefault(), v(!0));
268
- };
269
- return document.addEventListener("keydown", E), () => document.removeEventListener("keydown", E);
270
- }, [M, N]);
271
- const U = s.useRef(c.pathname);
272
- s.useEffect(() => {
273
- U.current !== c.pathname && (U.current = c.pathname, $(!1));
274
- }, [c.pathname]), s.useEffect(() => {
275
- if (!C) return;
276
- const E = document.body.style.overflow;
277
- return document.body.style.overflow = "hidden", () => {
278
- document.body.style.overflow = E;
279
- };
280
- }, [C]);
281
- const _ = f.width ?? 240, A = !T && o !== "D";
282
- return /* @__PURE__ */ p(
283
- "div",
284
- {
285
- className: "prui-app prui-shell min-h-dvh bg-[var(--prui-background)] text-[var(--prui-fg)]",
286
- "data-layout": o,
287
- "data-collapsed": A ? "true" : void 0,
288
- style: { "--prui-shell-sidebar": A ? "var(--prui-rail-width, 64px)" : `${_}px` },
289
- children: [
290
- /* @__PURE__ */ p("aside", { "data-testid": "sidebar", className: "prui-shell-sidebar hidden md:flex md:flex-col md:min-h-0", children: [
291
- /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto p-2 pt-4 scrollbar-thin", children: /* @__PURE__ */ e(ie, { nav: n, expandAllOn: w, collapsed: A }) }),
292
- z ? /* @__PURE__ */ e(
293
- "div",
294
- {
295
- className: S("border-t border-[var(--prui-line)] p-2", A && "flex justify-center px-1"),
296
- "data-testid": "sidebar-footer",
297
- children: z
298
- }
299
- ) : null,
300
- o !== "D" ? /* @__PURE__ */ e("div", { className: "border-t border-[var(--prui-line)] p-2", children: /* @__PURE__ */ e(
301
- D,
302
- {
303
- variant: "ghost",
304
- size: "sm",
305
- className: "w-full justify-center",
306
- "aria-label": A ? "Expand sidebar" : "Collapse sidebar",
307
- "data-testid": "sidebar-toggle",
308
- onClick: () => i((E) => !E),
309
- children: A ? /* @__PURE__ */ e(re, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ e(ne, { className: "h-4 w-4", "aria-hidden": !0 })
310
- }
311
- ) }) : null
312
- ] }),
313
- C ? /* @__PURE__ */ p("div", { className: "md:hidden fixed inset-0 z-40", "data-testid": "mobile-drawer", children: [
314
- /* @__PURE__ */ e(
315
- "div",
316
- {
317
- className: "absolute inset-0",
318
- style: { backgroundColor: "rgba(0,0,0,0.55)" },
319
- onClick: () => $(!1),
320
- "data-testid": "drawer-backdrop"
321
- }
322
- ),
323
- /* @__PURE__ */ p(
324
- "aside",
325
- {
326
- className: "absolute left-0 top-0 h-full w-64 overflow-y-auto border-r border-[var(--prui-line)] bg-[var(--prui-surface)] p-2",
327
- role: "dialog",
328
- "aria-modal": "true",
329
- "aria-label": "Navigation",
330
- children: [
331
- /* @__PURE__ */ e("div", { className: "mb-2 flex h-10 items-center justify-end px-1", children: /* @__PURE__ */ e(
332
- "button",
333
- {
334
- type: "button",
335
- "aria-label": "Close navigation",
336
- onClick: () => $(!1),
337
- className: "rounded-[var(--prui-radius)] p-1 text-[var(--prui-dim)] hover:text-[var(--prui-fg)] cursor-pointer",
338
- children: /* @__PURE__ */ e(qe, { className: "h-4 w-4", "aria-hidden": !0 })
339
- }
340
- ) }),
341
- /* @__PURE__ */ e(ie, { nav: n, onNavigate: () => $(!1), expandAllOn: w, collapsed: !1 })
342
- ]
343
- }
344
- )
345
- ] }) : null,
346
- o === "C" ? /* @__PURE__ */ e(
347
- "div",
348
- {
349
- "data-testid": "sidebar-header",
350
- className: "prui-shell-sidehead hidden h-14 items-center gap-2 border-b border-[var(--prui-line)] bg-[var(--prui-surface)] px-4 md:flex",
351
- children: b ?? /* @__PURE__ */ e(oe, { brand: r })
352
- }
353
- ) : null,
354
- /* @__PURE__ */ p(
355
- "header",
356
- {
357
- "data-testid": "app-header",
358
- className: "prui-shell-header sticky top-0 z-30 grid h-14 grid-cols-[1fr_auto_1fr] items-center gap-4 border-b border-[var(--prui-line)] bg-[var(--prui-surface)] px-4 md:px-6",
359
- children: [
360
- R ? /* @__PURE__ */ e(
361
- D,
362
- {
363
- variant: "ghost",
364
- size: "icon",
365
- "aria-label": "Open navigation",
366
- className: "md:hidden",
367
- onClick: () => $(!0),
368
- "data-testid": "drawer-toggle",
369
- children: /* @__PURE__ */ e(Ke, { className: "h-4 w-4", "aria-hidden": !0 })
370
- }
371
- ) : null,
372
- R && o !== "D" ? /* @__PURE__ */ e(
373
- D,
374
- {
375
- variant: "ghost",
376
- size: "icon",
377
- "aria-label": A ? "Show sidebar rail" : "Hide sidebar rail",
378
- className: "md:hidden",
379
- onClick: () => i((E) => !E),
380
- "data-testid": "rail-toggle-mobile",
381
- children: A ? /* @__PURE__ */ e(re, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ e(ne, { className: "h-4 w-4", "aria-hidden": !0 })
382
- }
383
- ) : null,
384
- /* @__PURE__ */ e("div", { className: "min-w-0 justify-self-start", children: /* @__PURE__ */ e(oe, { brand: r }) }),
385
- N ? /* @__PURE__ */ p(
386
- "button",
387
- {
388
- type: "button",
389
- onClick: () => v(!0),
390
- "data-testid": "search-trigger",
391
- className: "hidden h-8 w-[min(420px,34vw)] items-center gap-2 rounded-[var(--prui-radius)] border border-[var(--prui-line)] bg-[var(--prui-background)] px-3.5 text-sm text-[var(--prui-dim)] hover:border-[var(--prui-dim)] cursor-pointer md:flex",
392
- children: [
393
- /* @__PURE__ */ e(Ue, { className: "h-4 w-4", "aria-hidden": !0 }),
394
- /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: P.placeholder ?? "Search..." }),
395
- /* @__PURE__ */ e("kbd", { className: "ml-auto rounded-[var(--prui-radius-1)] border border-[var(--prui-line)] bg-[var(--prui-raise)] px-1.5 py-0.5 text-xs", children: M })
396
- ]
397
- }
398
- ) : null,
399
- /* @__PURE__ */ p("div", { className: "flex items-center gap-2 justify-self-end", children: [
400
- g,
401
- /* @__PURE__ */ e(ft, { config: l })
402
- ] })
403
- ]
404
- }
405
- ),
406
- /* @__PURE__ */ e("main", { "data-testid": "app-content", className: "prui-shell-content min-h-0 flex-1 p-4 md:p-6", children: x ? /* @__PURE__ */ e(ct, { mode: x, config: u, children: j }) : j ?? /* @__PURE__ */ e(Ie, {}) }),
407
- y ? /* @__PURE__ */ e(s.Suspense, { fallback: null, children: /* @__PURE__ */ e(
408
- mt,
409
- {
410
- timeout: y.sessionTimeout,
411
- warningTime: y.warningTime,
412
- onTimeout: K
413
- }
414
- ) }) : null,
415
- N ? /* @__PURE__ */ e(vt, { open: h, onOpenChange: v, entries: B, placeholder: P.placeholder, onNavigate: F }) : null
416
- ]
417
- }
418
- );
419
- }
420
- function Kt(t) {
421
- const { router: r = "browser", initialEntries: n } = t;
422
- return /* @__PURE__ */ e(r === "memory" ? ze : Fe, { initialEntries: n, children: /* @__PURE__ */ e(gt, { ...t }) });
423
- }
424
- const Ut = {
425
- name: "App",
426
- props: [
427
- { name: "brand", type: "{ name, mark?, href? }", default: "undefined", control: "object" },
428
- { name: "nav", type: "NavItem[]", default: "[]", control: "object" },
429
- { name: "search", type: "boolean | { enabled?, hotkey?, placeholder? }", default: "true", control: "boolean" },
430
- { name: "theme", type: "boolean | { default?: ThemeName | 'dark' | 'light', persist? }", default: "true", control: "boolean" },
431
- { name: "auth", type: "boolean | { sessionTimeout?, warningTime?, onTimeout?, loginPath? }", default: "false", control: "boolean" },
432
- { name: "sidebar", type: "{ width?, collapsible?, defaultOpen? }", default: "{}", control: "object" },
433
- { name: "router", type: "'browser' | 'memory'", default: "'browser'", control: "select", options: ["browser", "memory", "react-router"] },
434
- { name: "initialEntries", type: "string[]", default: "undefined", control: "object" },
435
- { name: "pages", type: "'auth' | 'utility' | 'auth+utility'", default: "undefined", control: "select", options: ["auth", "utility", "auth+utility"] },
436
- { name: "expandAllOn", type: "string (pathname)", default: "undefined", control: "text" },
437
- { name: "layoutType", type: "'A' | 'B' | 'C' | 'D'", default: "'A'", control: "select", options: ["A", "B", "C", "D"] },
438
- { name: "sidebarHeader", type: "ReactNode (layout C sidebar header)", default: "brand", control: "none" },
439
- { name: "sidebarFooter", type: "ReactNode", default: null, control: "none" },
440
- { name: "header", type: "ReactNode", default: null, control: "none" },
441
- { name: "children", type: "ReactNode", default: "Outlet", control: "none" }
442
- ]
443
- };
444
- function xt(t) {
445
- return Array.isArray(t) ? { fields: t } : t;
446
- }
447
- function yt(t) {
448
- if (t)
449
- return t.map((r) => typeof r == "string" || typeof r == "number" ? { label: String(r), value: String(r) } : r);
450
- }
451
- function de(t, r) {
452
- const n = {};
453
- for (const a of t.fields)
454
- r && a.name in r ? n[a.name] = r[a.name] : a.defaultValue !== void 0 ? n[a.name] = a.defaultValue : a.type === "boolean" ? n[a.name] = !1 : n[a.name] = "";
455
- return n;
456
- }
457
- function Nt({
458
- schema: t,
459
- initialValues: r,
460
- defaultValues: n,
461
- onSubmit: a,
462
- onCancel: l,
463
- cancelLabel: m = "Cancel",
464
- submitting: f = !1,
465
- error: g,
466
- className: x
467
- }) {
468
- const u = s.useMemo(() => xt(t), [t]), w = r ?? n, [o, b] = s.useState(() => de(u, w)), [z, j] = s.useState({}), [P, N] = s.useState(null), [M, R] = s.useState(!1);
469
- s.useEffect(() => {
470
- b(de(u, w));
471
- }, [JSON.stringify(u), JSON.stringify(w ?? {})]);
472
- const C = (i, h) => {
473
- b((v) => ({ ...v, [i]: h })), j((v) => {
474
- if (!v[i]) return v;
475
- const c = { ...v };
476
- return delete c[i], c;
477
- });
478
- }, $ = async (i) => {
479
- var v;
480
- i.preventDefault();
481
- const h = {};
482
- for (const c of u.fields) {
483
- if (c.required) {
484
- const y = o[c.name];
485
- (y === "" || y == null || Array.isArray(y) && y.length === 0) && (h[c.name] = c.name === void 0 ? "Required" : `${c.label} is required.`);
486
- }
487
- const F = (v = c.validate) == null ? void 0 : v.call(c, o[c.name], o);
488
- F && (h[c.name] = F);
489
- }
490
- if (j(h), !(Object.keys(h).length > 0)) {
491
- N(null);
492
- try {
493
- const c = a == null ? void 0 : a({ ...o });
494
- c && typeof c.then == "function" && (R(!0), await c);
495
- } catch (c) {
496
- N(c instanceof Error ? c.message : String(c));
497
- } finally {
498
- R(!1);
499
- }
500
- }
501
- }, T = f || M;
502
- return /* @__PURE__ */ p("form", { onSubmit: $, className: S("prui-form flex flex-col gap-4", x), noValidate: !0, children: [
503
- /* @__PURE__ */ e("div", { className: S("grid gap-4", u.columns === 2 && "md:grid-cols-2"), children: u.fields.map((i) => {
504
- const h = z[i.name], v = {
505
- id: `prui-form-${i.name}`,
506
- "aria-invalid": h ? !0 : void 0,
507
- "aria-describedby": h ? `prui-form-${i.name}-error` : void 0
508
- };
509
- return /* @__PURE__ */ p("div", { className: S("flex flex-col gap-1.5", i.colSpan === 2 && "md:col-span-2", i.className), children: [
510
- /* @__PURE__ */ p(ot, { htmlFor: v.id, children: [
511
- i.label,
512
- i.required ? /* @__PURE__ */ e("span", { className: "ml-0.5 text-[var(--prui-danger)]", children: "*" }) : null
513
- ] }),
514
- i.type === "textarea" ? /* @__PURE__ */ e(
515
- it,
516
- {
517
- ...v,
518
- placeholder: i.placeholder,
519
- disabled: i.disabled || T,
520
- value: String(o[i.name] ?? ""),
521
- onChange: (c) => C(i.name, c.target.value)
522
- }
523
- ) : i.type === "select" ? /* @__PURE__ */ e(
524
- pe,
525
- {
526
- ...v,
527
- options: yt(i.options),
528
- placeholder: i.placeholder,
529
- disabled: i.disabled || T,
530
- value: String(o[i.name] ?? ""),
531
- onChange: (c) => C(i.name, c)
532
- }
533
- ) : i.type === "date" ? /* @__PURE__ */ e(
534
- W,
535
- {
536
- ...v,
537
- type: "date",
538
- placeholder: i.placeholder,
539
- disabled: i.disabled || T,
540
- value: String(o[i.name] ?? ""),
541
- onChange: (c) => C(i.name, c.target.value)
542
- }
543
- ) : i.type === "boolean" ? /* @__PURE__ */ e(
544
- fe,
545
- {
546
- ...v,
547
- disabled: i.disabled || T,
548
- checked: !!o[i.name],
549
- onChange: (c) => C(i.name, c)
550
- }
551
- ) : /* @__PURE__ */ e(
552
- W,
553
- {
554
- ...v,
555
- type: i.type ?? "text",
556
- placeholder: i.placeholder,
557
- disabled: i.disabled || T,
558
- value: String(o[i.name] ?? ""),
559
- onChange: (c) => C(i.name, i.type === "number" ? c.target.value === "" ? "" : Number(c.target.value) : c.target.value)
560
- }
561
- ),
562
- h ? /* @__PURE__ */ e("p", { id: `prui-form-${i.name}-error`, role: "alert", className: "text-xs text-[var(--prui-danger)]", children: h }) : null
563
- ] }, i.name);
564
- }) }),
565
- g ?? P ? /* @__PURE__ */ e("p", { role: "alert", "data-testid": "form-error", className: "rounded-[var(--prui-radius)] border border-[var(--prui-danger)]/40 bg-[var(--prui-danger)]/10 px-3 py-2 text-sm text-[var(--prui-danger)]", children: g ?? P }) : null,
566
- /* @__PURE__ */ p("div", { className: "flex items-center justify-end gap-2", children: [
567
- l ? /* @__PURE__ */ e(D, { type: "button", variant: "ghost", onClick: l, disabled: T, children: m }) : null,
568
- /* @__PURE__ */ e(D, { type: "submit", variant: "primary", loading: T, children: u.submitLabel ?? "Submit" })
569
- ] })
570
- ] });
571
- }
572
- const Vt = {
573
- name: "Form",
574
- props: [
575
- { name: "schema", type: "FormSchema", default: null, control: "object" },
576
- { name: "initialValues", type: "Record<string, unknown>", default: "{}", control: "object" },
577
- { name: "onSubmit", type: "(values) => void | Promise<void>", default: null, control: "none" },
578
- { name: "onCancel", type: "() => void", default: null, control: "none" },
579
- { name: "submitting", type: "boolean", default: "false", control: "boolean" },
580
- { name: "error", type: "string | null", default: "null", control: "text" }
581
- ]
582
- };
583
- function Ne(t) {
584
- if (t)
585
- return t.map((r) => typeof r == "string" || typeof r == "number" ? { label: String(r), value: String(r) } : r);
586
- }
587
- function wt(t, r) {
588
- return { fields: t.filter((a) => a.formField !== !1 && !a.hidden).filter((a) => a.key !== "id" && a.key !== "actions").map((a) => {
589
- var l;
590
- return {
591
- name: a.key,
592
- label: typeof a.label == "string" ? a.label : a.key,
593
- type: St(a, r),
594
- options: (l = Ne(a.filterOptions ?? a.options)) == null ? void 0 : l.map((m) => ({ label: m.label, value: m.value })),
595
- required: !1
596
- };
597
- }), submitLabel: r ? "Save" : "Create" };
598
- }
599
- function St(t, r) {
600
- return t.filter === "select" ? "select" : typeof (r == null ? void 0 : r[t.key]) == "number" || t.filter === "number" || t.filter === "numberrange" || t.filter === "price" ? "number" : t.filter === "date" || t.filter === "daterange" ? "date" : "text";
601
- }
602
- function Ht({
603
- name: t,
604
- columns: r,
605
- list: n,
606
- create: a,
607
- update: l,
608
- remove: m,
609
- delete: f,
610
- actions: g,
611
- form: x,
612
- formSchema: u,
613
- rowKey: w,
614
- searchPlaceholder: o,
615
- pageSize: b = 20,
616
- className: z
617
- }) {
618
- const j = m ?? f, P = g ?? ["create", "edit", "delete"], N = (d) => P.includes(d) && (d === "create" ? !!a : d === "edit" ? !!l : !!j), [M, R] = s.useState([]), [C, $] = s.useState(null), [T, i] = s.useState(1), [h, v] = s.useState(b), [c, F] = s.useState([null]), [y, K] = s.useState(""), [B, U] = s.useState({}), [_, A] = s.useState(null), [E, k] = s.useState(!0), [O, V] = s.useState(null), [L, X] = s.useState(null), [we, q] = s.useState(!1), [Se, G] = s.useState(!1), Q = c[T - 1] ?? null, Z = JSON.stringify(B), H = s.useCallback(async () => {
619
- k(!0), V(null);
620
- try {
621
- const d = await n({ search: y, cursor: Q, pageSize: h, sort: _, filters: B });
622
- R(d.rows), $(d.nextCursor ?? d.cursor ?? null);
623
- } catch (d) {
624
- V(d instanceof Error ? d.message : String(d)), R([]), $(null);
625
- } finally {
626
- k(!1);
627
- }
628
- }, [y, Q, h, _, Z, n]);
629
- s.useEffect(() => {
630
- H();
631
- }, [H]), s.useEffect(() => {
632
- i(1), F([null]);
633
- }, [y, h, Z]);
634
- const ke = r.filter((d) => d.filter).map((d) => ({
635
- key: d.key,
636
- label: typeof d.label == "string" ? d.label : d.key,
637
- type: d.filter === "numberrange" ? "number" : d.filter,
638
- options: Ne(d.filterOptions ?? d.options)
639
- })), Ce = (d, J) => {
640
- U((Y) => ({ ...Y, [d]: J }));
641
- }, Te = () => {
642
- X(null), q(!0);
643
- }, Ee = (d) => {
644
- X(d), q(!0);
645
- }, Pe = async (d) => {
646
- if (!(!await rt({
647
- title: `Delete ${I}?`,
648
- message: "This action cannot be undone.",
649
- confirmText: "Delete",
650
- cancelText: "Cancel",
651
- type: "danger"
652
- }) || !j)) {
653
- G(!0);
654
- try {
655
- await j(d), await H();
656
- } finally {
657
- G(!1);
658
- }
659
- }
660
- }, Re = (d, J) => {
661
- if (J === "next") {
662
- const Y = C;
663
- F(($e) => {
664
- const te = [...$e];
665
- return te[d - 1] = Y, te;
666
- });
667
- }
668
- i(d);
669
- }, je = [
670
- ...r.filter((d) => !d.hidden),
671
- ...N("edit") || N("delete") ? [
672
- {
673
- key: "actions",
674
- label: "",
675
- align: "right",
676
- render: (d) => /* @__PURE__ */ p("div", { className: "flex items-center justify-end gap-1", children: [
677
- N("edit") ? /* @__PURE__ */ e(D, { variant: "ghost", size: "icon", "aria-label": "Edit", onClick: () => Ee(d), "data-testid": "resource-edit", children: /* @__PURE__ */ e(Je, { className: "h-3.5 w-3.5", "aria-hidden": !0 }) }) : null,
678
- N("delete") ? /* @__PURE__ */ e(D, { variant: "ghost", size: "icon", "aria-label": "Delete", disabled: Se, onClick: () => void Pe(d), "data-testid": "resource-delete", children: /* @__PURE__ */ e(Ye, { className: "h-3.5 w-3.5 text-[var(--prui-danger)]", "aria-hidden": !0 }) }) : null
679
- ] })
680
- }
681
- ] : []
682
- ], ee = u ?? wt(r, L), Me = L ? Object.fromEntries(
683
- ee.fields.map((d) => [d.name, L[d.name] ?? ""])
684
- ) : void 0, I = t.replace(/s$/, "");
685
- return /* @__PURE__ */ p("div", { className: S("prui-resource flex flex-col gap-2", z), "data-testid": "resource", children: [
686
- /* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ e("h1", { className: "text-xl font-semibold capitalize text-[var(--prui-fg)]", children: t }) }),
687
- /* @__PURE__ */ e(
688
- nt,
689
- {
690
- searchPlaceholder: o ?? `Search ${t}...`,
691
- searchValue: y,
692
- onSearchChange: K,
693
- filters: ke,
694
- filterValues: B,
695
- onFilterChange: Ce,
696
- actions: N("create") ? /* @__PURE__ */ p(D, { variant: "primary", size: "sm", onClick: Te, "data-testid": "resource-create", children: [
697
- /* @__PURE__ */ e(We, { className: "h-4 w-4", "aria-hidden": !0 }),
698
- "New ",
699
- I
700
- ] }) : void 0
701
- }
702
- ),
703
- O ? /* @__PURE__ */ e("div", { role: "alert", "data-testid": "resource-error", className: "rounded-[var(--prui-radius)] border border-[var(--prui-danger)]/40 bg-[var(--prui-danger)]/10 px-3 py-2 text-sm text-[var(--prui-danger)]", children: O }) : null,
704
- /* @__PURE__ */ e(lt, { columns: je, rows: M, rowKey: w, sort: _, onSortChange: A, loading: E }),
705
- /* @__PURE__ */ e(
706
- st,
707
- {
708
- page: T,
709
- pageSize: h,
710
- hasNextPage: C != null,
711
- hasPreviousPage: T > 1,
712
- onPageChange: Re,
713
- onPageSizeChange: (d) => v(d)
714
- }
715
- ),
716
- /* @__PURE__ */ p(me, { open: we, onClose: () => q(!1), size: "sm", ariaLabel: L ? `Edit ${I}` : `New ${I}`, noPadding: !0, children: [
717
- /* @__PURE__ */ e("div", { className: "px-8 pt-8 pb-2", children: /* @__PURE__ */ e("h2", { className: "text-lg font-semibold", style: { color: "var(--prui-fg)" }, children: L ? `Edit ${I}` : `New ${I}` }) }),
718
- /* @__PURE__ */ e("div", { className: "px-8 pb-8", children: x ?? /* @__PURE__ */ e(
719
- Nt,
720
- {
721
- schema: ee,
722
- initialValues: Me,
723
- onCancel: () => q(!1),
724
- onSubmit: async (d) => {
725
- L ? await (l == null ? void 0 : l(L, d)) : await (a == null ? void 0 : a(d)), q(!1), await H();
726
- }
727
- }
728
- ) })
729
- ] })
730
- ] });
731
- }
732
- const Jt = {
733
- name: "Resource",
734
- props: [
735
- { name: "name", type: "string", default: null, control: "text" },
736
- { name: "columns", type: "ResourceColumn<T>[]", default: null, control: "object" },
737
- { name: "list", type: "(query) => Promise<{rows, cursor}>", default: null, control: "none" },
738
- { name: "create", type: "(values) => Promise<void>", default: null, control: "none" },
739
- { name: "update", type: "(row, values) => Promise<void>", default: null, control: "none" },
740
- { name: "remove", type: "(row) => Promise<void>", default: null, control: "none" },
741
- { name: "delete", type: "(row) => Promise<void>", default: "alias of remove", control: "none" },
742
- { name: "actions", type: "('create' | 'edit' | 'delete')[]", default: "all provided", control: "multiselect", options: ["create", "edit", "delete"] },
743
- { name: "form", type: "ReactNode", default: "built-in schema form", control: "none" },
744
- { name: "formSchema", type: "FormSchema", default: "derived from columns", control: "object" },
745
- { name: "pageSize", type: "number", default: "20", control: "number" }
746
- ]
747
- };
748
- function Yt({ items: t, className: r }) {
749
- return /* @__PURE__ */ e("div", { className: S("prui-stat-row grid gap-3 sm:grid-cols-2 lg:grid-cols-4", r), children: t.map((n, a) => {
750
- const l = n.icon;
751
- return /* @__PURE__ */ p(he, { "data-testid": "stat-card", children: [
752
- /* @__PURE__ */ p(be, { className: "pb-2", children: [
753
- /* @__PURE__ */ p(ve, { className: "flex items-center gap-1.5 text-xs", children: [
754
- l ? /* @__PURE__ */ e(l, { className: "h-3.5 w-3.5", "aria-hidden": !0 }) : null,
755
- n.label
756
- ] }),
757
- /* @__PURE__ */ e(ge, { className: "text-2xl", children: n.value })
758
- ] }),
759
- n.delta ? /* @__PURE__ */ e(xe, { className: "pb-3", children: /* @__PURE__ */ e(
760
- "span",
761
- {
762
- className: S(
763
- "text-xs font-medium",
764
- n.trend === "up" && "text-[var(--prui-ok)]",
765
- n.trend === "down" && "text-[var(--prui-danger)]",
766
- (!n.trend || n.trend === "flat") && "text-[var(--prui-dim)]"
767
- ),
768
- children: n.delta
769
- }
770
- ) }) : null
771
- ] }, `${n.label}-${a}`);
772
- }) });
773
- }
774
- const Wt = {
775
- name: "StatRow",
776
- props: [
777
- { name: "items", type: "StatItem[]", default: null, control: "object" },
778
- { name: "className", type: "string", default: "undefined", control: "text" }
779
- ]
780
- };
781
- function kt(t) {
782
- if (t)
783
- return t.map((r) => typeof r == "string" || typeof r == "number" ? { label: String(r), value: String(r) } : r);
784
- }
785
- function Ct({ field: t }) {
786
- const { name: r, type: n, value: a, onChange: l } = t;
787
- if (!n || !r) return null;
788
- const m = `prui-settings-${r}`;
789
- return n === "switch" ? /* @__PURE__ */ e("label", { className: "flex items-center gap-2", htmlFor: m, children: /* @__PURE__ */ e(
790
- fe,
791
- {
792
- id: m,
793
- checked: !!a,
794
- onChange: (f) => l == null ? void 0 : l(f),
795
- "aria-label": t.label
796
- }
797
- ) }) : n === "select" ? /* @__PURE__ */ e(
798
- pe,
799
- {
800
- id: m,
801
- className: "w-56",
802
- options: kt(t.options) ?? [],
803
- value: String(a ?? ""),
804
- onChange: (f) => l == null ? void 0 : l(f),
805
- "aria-label": t.label
806
- }
807
- ) : /* @__PURE__ */ e(
808
- W,
809
- {
810
- id: m,
811
- type: n === "number" ? "number" : "text",
812
- className: "h-8 w-56",
813
- value: String(a ?? ""),
814
- onChange: (f) => l == null ? void 0 : l(n === "number" ? f.target.value === "" ? "" : Number(f.target.value) : f.target.value),
815
- "aria-label": t.label
816
- }
817
- );
818
- }
819
- function Xt({ title: t = "Settings", sections: r, className: n }) {
820
- return /* @__PURE__ */ p("div", { className: S("prui-settings mx-auto flex w-full max-w-4xl flex-col gap-6", n), children: [
821
- /* @__PURE__ */ e("h1", { className: "text-xl font-semibold text-[var(--prui-fg)]", children: t }),
822
- /* @__PURE__ */ p("div", { className: "flex flex-col gap-6 md:flex-row", children: [
823
- /* @__PURE__ */ e("nav", { "aria-label": "Settings sections", className: "md:w-56 md:shrink-0", children: /* @__PURE__ */ e("ul", { className: "flex flex-row flex-wrap gap-1 md:flex-col", children: r.map((a) => /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(
824
- "a",
825
- {
826
- href: `#settings-${a.id}`,
827
- className: "block rounded-[var(--prui-radius)] px-2.5 py-1.5 text-sm text-[var(--prui-dim)] hover:bg-[var(--prui-raise)] hover:text-[var(--prui-fg)]",
828
- children: a.title ?? a.label ?? a.id
829
- }
830
- ) }, a.id)) }) }),
831
- /* @__PURE__ */ e("div", { className: "flex min-w-0 flex-1 flex-col gap-4", children: r.map((a) => /* @__PURE__ */ p(he, { id: `settings-${a.id}`, "data-testid": "settings-section", children: [
832
- /* @__PURE__ */ p(be, { children: [
833
- /* @__PURE__ */ e(ge, { children: a.title ?? a.label ?? a.id }),
834
- a.description ? /* @__PURE__ */ e(ve, { children: a.description }) : null
835
- ] }),
836
- /* @__PURE__ */ e(xe, { children: a.content ?? /* @__PURE__ */ e("dl", { className: "flex flex-col divide-y divide-[var(--prui-line)]", children: (a.fields ?? []).map((l, m) => /* @__PURE__ */ p("div", { className: "flex flex-col gap-2 py-3 first:pt-0 last:pb-0 sm:flex-row sm:items-center sm:justify-between", children: [
837
- /* @__PURE__ */ p("div", { className: "min-w-0", children: [
838
- /* @__PURE__ */ e("dt", { className: "text-sm font-medium text-[var(--prui-fg)]", children: l.label }),
839
- l.description ? /* @__PURE__ */ e("dd", { className: "text-xs text-[var(--prui-dim)]", children: l.description }) : null
840
- ] }),
841
- /* @__PURE__ */ e("div", { className: "shrink-0", children: l.control ?? /* @__PURE__ */ e(Ct, { field: l }) })
842
- ] }, `${l.label}-${m}`)) }) })
843
- ] }, a.id)) })
844
- ] })
845
- ] });
846
- }
847
- const Gt = {
848
- name: "Settings",
849
- props: [
850
- { name: "title", type: "string", default: "'Settings'", control: "text" },
851
- { name: "sections", type: "SettingsSection[]", default: null, control: "object" }
852
- ]
853
- }, ue = ["mousedown", "keydown", "scroll", "touchstart", "click"];
854
- function Tt({
855
- timeout: t = 15,
856
- warningTime: r = 2,
857
- onTimeout: n,
858
- onExtend: a,
859
- title: l = "Session expiring soon",
860
- message: m = "Your session is about to expire due to inactivity."
861
- }) {
862
- const f = Math.max(0, t) * 6e4, g = Math.min(Math.max(0, r) * 6e4, f), [x, u] = s.useState(!1), [w, o] = s.useState(g), b = s.useRef(null), z = s.useRef(null), j = s.useRef(null), P = s.useRef(!1), N = s.useCallback(() => {
863
- for (const h of [b, z, j])
864
- h.current != null && (clearInterval(h.current), clearTimeout(h.current), h.current = null);
865
- }, []), M = s.useCallback(() => {
866
- N(), u(!1), n == null || n();
867
- }, [N, n]), R = s.useCallback(() => {
868
- N(), u(!1), P.current = !1, b.current = window.setTimeout(() => {
869
- P.current = !0, o(g), u(!0), j.current = window.setInterval(() => {
870
- o((h) => h <= 1e3 ? (M(), 0) : h - 1e3);
871
- }, 1e3);
872
- }, f - g), z.current = window.setTimeout(M, f);
873
- }, [N, M, f, g]);
874
- s.useEffect(() => {
875
- const h = () => {
876
- P.current || R();
877
- };
878
- for (const v of ue) document.addEventListener(v, h, { passive: !0 });
879
- return R(), () => {
880
- N();
881
- for (const v of ue) document.removeEventListener(v, h);
882
- };
883
- }, [R, N]);
884
- const C = () => {
885
- a == null || a(), R();
886
- }, $ = Math.floor(w / 6e4), T = Math.floor(w % 6e4 / 1e3), i = `${$}:${String(T).padStart(2, "0")}`;
887
- return /* @__PURE__ */ p(
888
- me,
889
- {
890
- open: x,
891
- onClose: C,
892
- size: "sm",
893
- ariaLabel: l,
894
- children: [
895
- /* @__PURE__ */ p("div", { className: "flex flex-col items-center gap-1 px-8 pb-2 pt-8 text-center", children: [
896
- /* @__PURE__ */ e("div", { className: "mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-[var(--prui-warn)]/15", children: /* @__PURE__ */ e(Xe, { className: "h-6 w-6 text-[var(--prui-warn)]", "aria-hidden": !0 }) }),
897
- /* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-[var(--prui-fg)]", children: l }),
898
- /* @__PURE__ */ e("p", { className: "text-sm text-[var(--prui-dim)]", children: m }),
899
- /* @__PURE__ */ e("div", { className: "py-4 font-mono text-4xl font-bold text-[var(--prui-fg)]", "data-testid": "session-countdown", children: i })
900
- ] }),
901
- /* @__PURE__ */ p("div", { className: "flex flex-col gap-2 px-8 pb-8 sm:flex-row", children: [
902
- /* @__PURE__ */ e(D, { variant: "default", className: "flex-1", onClick: M, "data-testid": "session-logout", children: "Log out now" }),
903
- /* @__PURE__ */ e(D, { variant: "primary", className: "flex-1", onClick: C, "data-testid": "session-extend", children: "Continue session" })
904
- ] })
905
- ]
906
- }
907
- );
908
- }
909
- const Et = {
910
- name: "SessionTimeout",
911
- props: [
912
- { name: "timeout", type: "number", default: "15", control: "number" },
913
- { name: "warningTime", type: "number", default: "2", control: "number" },
914
- { name: "onTimeout", type: "() => void", default: null, control: "none" },
915
- { name: "onExtend", type: "() => void", default: null, control: "none" }
916
- ]
917
- }, Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
918
- __proto__: null,
919
- SessionTimeout: Tt,
920
- sessionTimeoutPropsMeta: Et
921
- }, Symbol.toStringTag, { value: "Module" }));
922
- function Qt({ title: t, description: r, brand: n, width: a = "max-w-sm", footer: l, children: m, className: f }) {
923
- return /* @__PURE__ */ e("div", { className: S("prui-auth-shell flex min-h-[100dvh] items-center justify-center bg-[var(--prui-background)] p-4", f), "data-testid": "auth-shell", children: /* @__PURE__ */ p("div", { className: S("w-full", a), children: [
924
- n ? /* @__PURE__ */ p("div", { className: "mb-6 flex items-center justify-center gap-2", "data-testid": "auth-shell-brand", children: [
925
- n.mark ? /* @__PURE__ */ e("img", { src: n.mark, alt: "", className: "h-8 w-8 rounded-[var(--prui-radius-1)] object-cover" }) : null,
926
- /* @__PURE__ */ e("span", { className: "text-lg font-semibold text-[var(--prui-fg)]", children: n.name })
927
- ] }) : null,
928
- /* @__PURE__ */ p("div", { className: "rounded-[var(--prui-radius)] border border-[var(--prui-line)] bg-[var(--prui-surface)] p-6", children: [
929
- /* @__PURE__ */ p("div", { className: "mb-4 flex flex-col gap-1 text-center", children: [
930
- /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-[var(--prui-fg)]", children: t }),
931
- r ? /* @__PURE__ */ e("p", { className: "text-sm text-[var(--prui-dim)]", children: r }) : null
932
- ] }),
933
- m,
934
- l ? /* @__PURE__ */ e("div", { className: "mt-4 text-center text-sm text-[var(--prui-dim)]", children: l }) : null
935
- ] })
936
- ] }) });
937
- }
938
- const Zt = {
939
- name: "AuthShell",
940
- props: [
941
- { name: "title", type: "string", default: null, control: "text" },
942
- { name: "description", type: "ReactNode", default: null, control: "text" },
943
- { name: "brand", type: "{ name, mark?, href? }", default: "undefined", control: "object" },
944
- { name: "width", type: "string", default: "'max-w-sm'", control: "text" },
945
- { name: "footer", type: "ReactNode", default: null, control: "none" },
946
- { name: "children", type: "ReactNode", default: null, control: "none" }
947
- ]
948
- };
949
- export {
950
- Kt as A,
951
- vt as C,
952
- Nt as F,
953
- Ht as R,
954
- Tt as S,
955
- gt as a,
956
- Qt as b,
957
- ct as c,
958
- Xt as d,
959
- ie as e,
960
- Yt as f,
961
- Ut as g,
962
- Zt as h,
963
- Vt as i,
964
- Gt as j,
965
- Wt as k,
966
- Jt as r,
967
- Et as s,
968
- pt as u
969
- };