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