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