@skiddph/prui 0.9.1 → 0.10.1

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,22 +1,22 @@
1
- import { jsx as e, jsxs as f, Fragment as Oe } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as f, Fragment as Me } from "react/jsx-runtime";
2
2
  import * as l from "react";
3
- import { createPortal as ut } from "react-dom";
4
- import { Routes as dt, Route as ke, Navigate as mt, MemoryRouter as pt, BrowserRouter as ft, useLocation as De, useNavigate as ze, Outlet as ht, Link as bt, NavLink as vt } from "react-router-dom";
5
- import { ChevronsRight as Se, ChevronsLeft as Te, X as gt, Menu as xt, Search as yt, Palette as wt, ChevronDown as Nt, Pencil as kt, Trash2 as St, Plus as Tt, Clock as Ct } from "lucide-react";
3
+ import { createPortal as ot } from "react-dom";
4
+ import { Routes as ct, Route as ke, Navigate as ut, MemoryRouter as dt, BrowserRouter as mt, useLocation as Pe, useNavigate as Oe, Outlet as pt, Link as ft, NavLink as ht } from "react-router-dom";
5
+ import { ChevronsRight as bt, ChevronsLeft as vt, X as gt, Menu as xt, Search as yt, Palette as wt, ChevronDown as Nt, Pencil as kt, Trash2 as St, Plus as Tt, Clock as Ct } from "lucide-react";
6
6
  import { cn as C } from "../core/cn.js";
7
7
  import { Dropdown as Rt } from "../core/dropdown.js";
8
- import { Button as K } from "../core/button.js";
9
- import { useOverlay as Ae, Portal as $e, useOverlayStack as Et, useEscapeKey as Mt } from "../core/overlay.js";
10
- import { endIndex as jt, homeIndex as Pt, moveIndex as Ce } from "../core/list-nav.js";
11
- import { resolveThemeName as Ot, themeMode as Dt, readPersistedTheme as zt, applyTheme as Re, listThemes as At, clearAppliedTokens as $t } from "../theme.js";
8
+ import { Button as B } from "../core/button.js";
9
+ import { useOverlay as De, Portal as Ae, useOverlayStack as Et, useEscapeKey as jt } from "../core/overlay.js";
10
+ import { endIndex as Mt, homeIndex as Pt, moveIndex as Se } from "../core/list-nav.js";
11
+ import { resolveThemeName as Ot, themeMode as Dt, readPersistedTheme as At, applyTheme as Te, listThemes as zt, clearAppliedTokens as $t } from "../theme.js";
12
12
  import { usePruiI18n as J } from "../i18n.js";
13
- import { Modal as Fe, confirmModal as Ft } from "../core/modal.js";
13
+ import { Modal as ze, confirmModal as Ft } from "../core/modal.js";
14
14
  import { b as It, D as Lt, a as Kt } from "./data-table-toolbar-B-5J2Ozl.js";
15
15
  import { Textarea as Bt, Input as ie } from "../core/input.js";
16
16
  import { Label as Ut } from "../core/label.js";
17
- import { Select as Ie } from "../core/select.js";
18
- import { Switch as Le } from "../core/switch.js";
19
- import { Card as Ke, CardHeader as Be, CardDescription as Ue, CardTitle as Ve, CardContent as _e } from "../core/card.js";
17
+ import { Select as $e } from "../core/select.js";
18
+ import { Switch as Fe } from "../core/switch.js";
19
+ import { Card as Ie, CardHeader as Le, CardDescription as Ke, CardTitle as Be, CardContent as Ue } from "../core/card.js";
20
20
  const Vt = [
21
21
  { path: "/login", name: "login" },
22
22
  { path: "/register", name: "register" },
@@ -32,10 +32,10 @@ const Vt = [
32
32
  { path: "/admin-setup", name: "adminSetup" }
33
33
  ];
34
34
  function qt({ mode: t, config: a, children: n }) {
35
- const r = t === "auth" || t === "auth+utility", o = t === "utility" || t === "auth+utility", d = [
35
+ const r = t === "auth" || t === "auth+utility", o = t === "utility" || t === "auth+utility", m = [
36
36
  ...r ? Vt : [],
37
37
  ...o ? _t : []
38
- ], [m, T] = l.useState(null);
38
+ ], [d, T] = l.useState(null);
39
39
  return l.useEffect(() => {
40
40
  let k = !1;
41
41
  return import("../pages.js").then((x) => {
@@ -43,28 +43,28 @@ function qt({ mode: t, config: a, children: n }) {
43
43
  }), () => {
44
44
  k = !0;
45
45
  };
46
- }, []), m ? /* @__PURE__ */ f(dt, { children: [
47
- d.map(({ path: k, name: x }) => {
48
- const y = m[x];
46
+ }, []), d ? /* @__PURE__ */ f(ct, { children: [
47
+ m.map(({ path: k, name: x }) => {
48
+ const y = d[x];
49
49
  return y ? /* @__PURE__ */ e(ke, { path: k, element: /* @__PURE__ */ e(y, { ...(a == null ? void 0 : a[x]) ?? {} }) }, k) : null;
50
50
  }),
51
51
  n,
52
- r ? /* @__PURE__ */ e(ke, { path: "*", element: /* @__PURE__ */ e(mt, { to: "/login", replace: !0 }) }) : null
52
+ r ? /* @__PURE__ */ e(ke, { path: "*", element: /* @__PURE__ */ e(ut, { to: "/login", replace: !0 }) }) : null
53
53
  ] }) : /* @__PURE__ */ e("div", { className: "p-8 text-center text-sm text-[var(--prui-dim)]", children: "Loading…" });
54
54
  }
55
55
  const Ht = l.lazy(
56
56
  () => Promise.resolve().then(() => or).then((t) => ({ default: t.SessionTimeout }))
57
57
  );
58
58
  function Jt(t) {
59
- const a = t !== !1, n = typeof t == "object" ? t : {}, r = n.persist !== !1, o = Ot(n.default ?? "control"), d = Dt(o), [m, T] = l.useState(() => (r ? zt() : null) ?? { theme: o, mode: d }), k = l.useCallback(
59
+ const a = t !== !1, n = typeof t == "object" ? t : {}, r = n.persist !== !1, o = Ot(n.default ?? "control"), m = Dt(o), [d, T] = l.useState(() => (r ? At() : null) ?? { theme: o, mode: m }), k = l.useCallback(
60
60
  (x) => {
61
- T(x), Re({ theme: x.theme, mode: x.mode, storageKey: r ? "prui:theme" : null });
61
+ T(x), Te({ theme: x.theme, mode: x.mode, storageKey: r ? "prui:theme" : null });
62
62
  },
63
63
  [r]
64
64
  );
65
65
  return l.useEffect(() => {
66
- Re({ theme: m.theme, mode: m.mode, storageKey: r ? "prui:theme" : null });
67
- }, [m, r]), { enabled: a, state: m, setTheme: k };
66
+ Te({ theme: d.theme, mode: d.mode, storageKey: r ? "prui:theme" : null });
67
+ }, [d, r]), { enabled: a, state: d, setTheme: k };
68
68
  }
69
69
  function Yt({ config: t }) {
70
70
  const { enabled: a, state: n, setTheme: r } = Jt(t), { t: o } = J();
@@ -83,10 +83,10 @@ function Yt({ config: t }) {
83
83
  children: /* @__PURE__ */ e(wt, { className: "h-4 w-4", "aria-hidden": !0 })
84
84
  }
85
85
  ),
86
- items: At().map((d) => ({
87
- label: `${d}${d === n.theme ? " (active)" : ""}`,
86
+ items: zt().map((m) => ({
87
+ label: `${m}${m === n.theme ? " (active)" : ""}`,
88
88
  onSelect: () => {
89
- $t(), r({ theme: d, mode: d === "daylight" ? "light" : "dark" });
89
+ $t(), r({ theme: m, mode: m === "daylight" ? "light" : "dark" });
90
90
  }
91
91
  }))
92
92
  }
@@ -97,19 +97,19 @@ function se(t, a) {
97
97
  }
98
98
  function Wt({ item: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
99
99
  var O;
100
- const { pathname: o } = De(), d = ze(), m = (t.items ?? []).some(
100
+ const { pathname: o } = Pe(), m = Oe(), d = (t.items ?? []).some(
101
101
  (v) => v.href ? se(o, v.href) : (v.items ?? []).some((i) => i.href && se(o, i.href))
102
- ), [T, k] = l.useState(m || n !== void 0 && o === n);
102
+ ), [T, k] = l.useState(d || n !== void 0 && o === n);
103
103
  l.useEffect(() => {
104
- m && k(!0);
105
- }, [m]);
106
- const x = t.icon, [y, R] = l.useState(!1), [w, P] = l.useState(null), g = l.useRef(null), u = l.useRef(null), [b, E] = l.useState(-1), M = l.useCallback(() => {
104
+ d && k(!0);
105
+ }, [d]);
106
+ const x = t.icon, [y, M] = l.useState(!1), [w, P] = l.useState(null), g = l.useRef(null), u = l.useRef(null), [b, R] = l.useState(-1), E = l.useCallback(() => {
107
107
  var i, S;
108
- R(!1), E(-1);
108
+ M(!1), R(-1);
109
109
  const v = document.activeElement;
110
110
  v && ((i = u.current) != null && i.contains(v)) && ((S = g.current) == null || S.focus());
111
111
  }, []), { setElement: $, isTop: A } = Et(y);
112
- if (Mt(y, A, () => M()), l.useEffect(() => {
112
+ if (jt(y, A, () => E()), l.useEffect(() => {
113
113
  var v;
114
114
  y && ((v = u.current) == null || v.focus());
115
115
  }, [y]), r) {
@@ -123,16 +123,16 @@ function Wt({ item: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
123
123
  var h;
124
124
  const c = (h = g.current) == null ? void 0 : h.getBoundingClientRect();
125
125
  if (c) {
126
- const B = Math.min(v.length * 32 + 40, 320);
126
+ const K = Math.min(v.length * 32 + 40, 320);
127
127
  P({
128
128
  left: c.right + 8,
129
- top: Math.max(8, Math.min(c.top, window.innerHeight - B - 8))
129
+ top: Math.max(8, Math.min(c.top, window.innerHeight - K - 8))
130
130
  });
131
131
  }
132
- R((B) => !B);
132
+ M((K) => !K);
133
133
  }, N = (c) => {
134
134
  var L, V;
135
- E(c);
135
+ R(c);
136
136
  const h = (L = u.current) == null ? void 0 : L.querySelectorAll("[role='menuitem']");
137
137
  if (!h) return;
138
138
  (V = Array.from(h)[c]) == null || V.focus();
@@ -140,19 +140,19 @@ function Wt({ item: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
140
140
  const h = i.length;
141
141
  switch (c.key) {
142
142
  case "ArrowDown":
143
- c.preventDefault(), N(Ce(b, 1, h));
143
+ c.preventDefault(), N(Se(b, 1, h));
144
144
  break;
145
145
  case "ArrowUp":
146
- c.preventDefault(), N(Ce(b, -1, h));
146
+ c.preventDefault(), N(Se(b, -1, h));
147
147
  break;
148
148
  case "Home":
149
149
  c.preventDefault(), N(Pt(h));
150
150
  break;
151
151
  case "End":
152
- c.preventDefault(), N(jt(h));
152
+ c.preventDefault(), N(Mt(h));
153
153
  break;
154
154
  case "Tab":
155
- M();
155
+ E();
156
156
  break;
157
157
  }
158
158
  };
@@ -172,14 +172,14 @@ function Wt({ item: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
172
172
  "data-testid": "rail-group-trigger",
173
173
  className: C(
174
174
  "flex w-full items-center justify-center rounded-[var(--prui-radius)] px-2.5 py-1.5 text-sm cursor-pointer",
175
- m || y ? "text-[var(--prui-brand)]" : "text-[var(--prui-dim)] hover:text-[var(--prui-fg)]"
175
+ d || y ? "text-[var(--prui-brand)]" : "text-[var(--prui-dim)] hover:text-[var(--prui-fg)]"
176
176
  ),
177
177
  children: x ? /* @__PURE__ */ e(x, { className: "h-4 w-4 shrink-0", "aria-hidden": !0 }) : /* @__PURE__ */ e("span", { className: "prui-nav-mono text-[10px] font-semibold", children: t.label.slice(0, 2).toUpperCase() })
178
178
  }
179
179
  ),
180
- y && w ? ut(
181
- /* @__PURE__ */ f(Oe, { children: [
182
- /* @__PURE__ */ e("div", { className: "fixed inset-0 z-[var(--prui-z-flyout)]", onClick: () => M(), "data-testid": "rail-flyout-backdrop" }),
180
+ y && w ? ot(
181
+ /* @__PURE__ */ f(Me, { children: [
182
+ /* @__PURE__ */ e("div", { className: "fixed inset-0 z-[var(--prui-z-flyout)]", onClick: () => E(), "data-testid": "rail-flyout-backdrop" }),
183
183
  /* @__PURE__ */ f(
184
184
  "div",
185
185
  {
@@ -208,7 +208,7 @@ function Wt({ item: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
208
208
  c.href && se(o, c.href) ? "bg-[var(--prui-brand)]/15 text-[var(--prui-brand)]" : "text-[var(--prui-fg)] hover:bg-[var(--prui-raise)] focus-visible:bg-[var(--prui-raise)] outline-none"
209
209
  ),
210
210
  onClick: () => {
211
- M(), a == null || a(), c.href && d(c.href);
211
+ E(), a == null || a(), c.href && m(c.href);
212
212
  },
213
213
  children: c.label
214
214
  },
@@ -232,7 +232,7 @@ function Wt({ item: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
232
232
  onClick: () => k((v) => !v),
233
233
  className: C(
234
234
  "flex w-full items-center gap-2 rounded-[var(--prui-radius)] px-2.5 py-1.5 text-sm cursor-pointer",
235
- m ? "text-[var(--prui-fg)]" : "text-[var(--prui-dim)] hover:text-[var(--prui-fg)]"
235
+ d ? "text-[var(--prui-fg)]" : "text-[var(--prui-dim)] hover:text-[var(--prui-fg)]"
236
236
  ),
237
237
  children: [
238
238
  x ? /* @__PURE__ */ e(x, { className: "h-4 w-4 shrink-0", "aria-hidden": !0 }) : /* @__PURE__ */ e("span", { className: C("prui-nav-mono text-[10px] font-semibold"), children: t.label.slice(0, 2).toUpperCase() }),
@@ -241,22 +241,22 @@ function Wt({ item: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
241
241
  ]
242
242
  }
243
243
  ),
244
- T ? /* @__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((v) => /* @__PURE__ */ e(qe, { item: v, onNavigate: a, nested: !0, expandAllOn: n, collapsed: r }, v.href ?? v.label)) }) : null
244
+ T ? /* @__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((v) => /* @__PURE__ */ e(Ve, { item: v, onNavigate: a, nested: !0, expandAllOn: n, collapsed: r }, v.href ?? v.label)) }) : null
245
245
  ] });
246
246
  }
247
247
  function Xt({ label: t }) {
248
248
  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 });
249
249
  }
250
- function qe({ item: t, onNavigate: a, nested: n, expandAllOn: r, collapsed: o }) {
250
+ function Ve({ item: t, onNavigate: a, nested: n, expandAllOn: r, collapsed: o }) {
251
251
  return t.items && t.items.length > 0 ? /* @__PURE__ */ e(Wt, { item: t, onNavigate: a, expandAllOn: r, collapsed: o }) : t.heading || !t.href && !t.items ? o ? null : /* @__PURE__ */ e(Xt, { label: t.label }) : t.href ? /* @__PURE__ */ e("li", { children: /* @__PURE__ */ f(
252
- vt,
252
+ ht,
253
253
  {
254
254
  to: t.href,
255
255
  onClick: a,
256
- className: ({ isActive: d }) => C(
256
+ className: ({ isActive: m }) => C(
257
257
  "flex items-center gap-2 rounded-[var(--prui-radius)] px-2.5 py-1.5 text-sm",
258
258
  n && "pl-2.5",
259
- d ? "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)]"
259
+ 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)]"
260
260
  ),
261
261
  children: [
262
262
  t.icon && !n ? /* @__PURE__ */ e(t.icon, { className: "h-4 w-4 shrink-0", "aria-hidden": !0 }) : o ? /* @__PURE__ */ e("span", { className: C("prui-nav-mono text-[10px] font-semibold"), children: t.label.slice(0, 2).toUpperCase() }) : null,
@@ -265,17 +265,17 @@ function qe({ item: t, onNavigate: a, nested: n, expandAllOn: r, collapsed: o })
265
265
  }
266
266
  ) }) : null;
267
267
  }
268
- function Ee({ nav: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
268
+ function Ce({ nav: t, onNavigate: a, expandAllOn: n, collapsed: r }) {
269
269
  const { t: o } = J();
270
- return /* @__PURE__ */ e("nav", { "aria-label": o.mainNavigation, className: "prui-app-nav", children: /* @__PURE__ */ e("ul", { className: "flex flex-col gap-0.5", children: t.map((d) => /* @__PURE__ */ e(qe, { item: d, onNavigate: a, expandAllOn: n, collapsed: r }, d.href ?? d.label)) }) });
270
+ return /* @__PURE__ */ e("nav", { "aria-label": o.mainNavigation, className: "prui-app-nav", children: /* @__PURE__ */ e("ul", { className: "flex flex-col gap-0.5", children: t.map((m) => /* @__PURE__ */ e(Ve, { item: m, onNavigate: a, expandAllOn: n, collapsed: r }, m.href ?? m.label)) }) });
271
271
  }
272
- function Me({ brand: t }) {
272
+ function Re({ brand: t }) {
273
273
  if (!t) return null;
274
- const a = /* @__PURE__ */ f(Oe, { children: [
274
+ const a = /* @__PURE__ */ f(Me, { children: [
275
275
  t.mark ? /* @__PURE__ */ e("img", { src: t.mark, alt: "", className: "h-6 w-6 rounded-[var(--prui-radius-1)] object-cover" }) : null,
276
276
  /* @__PURE__ */ e("span", { className: "prui-nav-label truncate font-semibold text-[var(--prui-fg)]", children: t.name })
277
277
  ] }), n = "flex items-center gap-2 px-1 py-1 min-w-0";
278
- return t.href === null ? /* @__PURE__ */ e("div", { className: n, children: a }) : /* @__PURE__ */ e(bt, { to: t.href ?? "/", className: n, "aria-label": t.name, children: a });
278
+ return t.href === null ? /* @__PURE__ */ e("div", { className: n, children: a }) : /* @__PURE__ */ e(ft, { to: t.href ?? "/", className: n, "aria-label": t.name, children: a });
279
279
  }
280
280
  function Gt({
281
281
  open: t,
@@ -284,19 +284,19 @@ function Gt({
284
284
  placeholder: r,
285
285
  onNavigate: o
286
286
  }) {
287
- const { t: d } = J(), [m, T] = l.useState(""), [k, x] = l.useState(0), y = l.useRef(null), R = r ?? d.commandPlaceholder, w = l.useMemo(() => {
288
- const u = m.trim().toLowerCase();
287
+ const { t: m } = J(), [d, T] = l.useState(""), [k, x] = l.useState(0), y = l.useRef(null), M = r ?? m.commandPlaceholder, w = l.useMemo(() => {
288
+ const u = d.trim().toLowerCase();
289
289
  return u ? n.filter((b) => b.label.toLowerCase().includes(u)) : n;
290
- }, [n, m]);
291
- l.useEffect(() => x(0), [m]);
292
- const { ref: P } = Ae({
290
+ }, [n, d]);
291
+ l.useEffect(() => x(0), [d]);
292
+ const { ref: P } = De({
293
293
  open: t,
294
294
  onEscape: () => a(!1),
295
295
  initialFocus: y
296
296
  }), g = (u) => {
297
297
  a(!1), u.onSelect ? u.onSelect() : u.href && (o == null || o(u.href));
298
298
  };
299
- return t ? /* @__PURE__ */ e($e, { children: /* @__PURE__ */ e("div", { ref: P, children: /* @__PURE__ */ e(
299
+ return t ? /* @__PURE__ */ e(Ae, { children: /* @__PURE__ */ e("div", { ref: P, children: /* @__PURE__ */ e(
300
300
  "div",
301
301
  {
302
302
  className: "prui-dialog-overlay fixed inset-0 z-[var(--prui-z-overlay)] flex items-start justify-center pt-24",
@@ -323,8 +323,8 @@ function Gt({
323
323
  "aria-controls": "prui-palette-listbox",
324
324
  "aria-label": "Command palette search",
325
325
  "aria-activedescendant": w[k] ? `palette-option-${k}` : void 0,
326
- placeholder: R,
327
- value: m,
326
+ placeholder: M,
327
+ value: d,
328
328
  onChange: (u) => T(u.target.value),
329
329
  onKeyDown: (u) => {
330
330
  if (u.key === "ArrowDown" && (u.preventDefault(), x((b) => Math.min(b + 1, w.length - 1))), u.key === "ArrowUp" && (u.preventDefault(), x((b) => Math.max(b - 1, 0))), u.key === "Home" && w.length > 0 && (u.preventDefault(), x(0)), u.key === "End" && w.length > 0 && (u.preventDefault(), x(w.length - 1)), u.key === "Enter") {
@@ -335,7 +335,7 @@ function Gt({
335
335
  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)]"
336
336
  }
337
337
  ),
338
- /* @__PURE__ */ e("ul", { id: "prui-palette-listbox", role: "listbox", "aria-label": "Commands", className: "max-h-64 overflow-auto p-1", children: w.length === 0 ? /* @__PURE__ */ e("li", { className: "px-3 py-2 text-sm text-[var(--prui-dim)]", role: "option", "aria-selected": "false", "aria-disabled": "true", children: d.commandNoMatches }) : w.map((u, b) => /* @__PURE__ */ f(
338
+ /* @__PURE__ */ e("ul", { id: "prui-palette-listbox", role: "listbox", "aria-label": "Commands", className: "max-h-64 overflow-auto p-1", children: w.length === 0 ? /* @__PURE__ */ e("li", { className: "px-3 py-2 text-sm text-[var(--prui-dim)]", role: "option", "aria-selected": "false", "aria-disabled": "true", children: m.commandNoMatches }) : w.map((u, b) => /* @__PURE__ */ f(
339
339
  "li",
340
340
  {
341
341
  id: `palette-option-${b}`,
@@ -366,79 +366,79 @@ function Qt(t) {
366
366
  nav: n = [],
367
367
  search: r = !0,
368
368
  theme: o = !0,
369
- auth: d = !1,
370
- sidebar: m = {},
369
+ auth: m = !1,
370
+ sidebar: d = {},
371
371
  header: T,
372
372
  pages: k,
373
373
  pagesConfig: x,
374
374
  expandAllOn: y,
375
- layoutType: R = "A",
375
+ layoutType: M = "A",
376
376
  sidebarHeader: w,
377
377
  sidebarFooter: P,
378
378
  children: g
379
- } = t, { t: u } = J(), b = typeof r == "object" ? r : { enabled: r !== !1 }, E = b.enabled !== !1, M = b.hotkey ?? "/", $ = m.collapsible !== !1, [A, O] = l.useState(m.defaultOpen === !0), [v, i] = l.useState(!0), [S, N] = l.useState(!1), p = De(), c = ze(), h = l.useMemo(
380
- () => d === !1 ? null : d === !0 ? {} : d,
381
- [d]
382
- ), B = l.useCallback(() => {
379
+ } = t, { t: u } = J(), b = typeof r == "object" ? r : { enabled: r !== !1 }, R = b.enabled !== !1, E = b.hotkey ?? "/", $ = d.collapsible !== !1, [A, O] = l.useState(d.defaultOpen === !0), [v, i] = l.useState(!0), [S, N] = l.useState(!1), p = Pe(), c = Oe(), h = l.useMemo(
380
+ () => m === !1 ? null : m === !0 ? {} : m,
381
+ [m]
382
+ ), K = l.useCallback(() => {
383
383
  h != null && h.onTimeout ? h.onTimeout() : c((h == null ? void 0 : h.loginPath) ?? "/login");
384
384
  }, [h, c]), L = l.useMemo(() => {
385
- const F = [];
385
+ const I = [];
386
386
  for (const j of n)
387
387
  if (j.items)
388
- for (const I of j.items)
389
- I.href && F.push({ label: `${j.label} / ${I.label}`, href: I.href, group: j.label });
390
- else j.href && F.push({ label: j.label, href: j.href });
391
- return F;
388
+ for (const F of j.items)
389
+ F.href && I.push({ label: `${j.label} / ${F.label}`, href: F.href, group: j.label });
390
+ else j.href && I.push({ label: j.label, href: j.href });
391
+ return I;
392
392
  }, [n]);
393
393
  l.useEffect(() => {
394
- if (!E) return;
395
- const F = (j) => {
396
- const I = j.target, q = I && (I.tagName === "INPUT" || I.tagName === "TEXTAREA" || I.isContentEditable);
397
- j.key === M && !q && !j.metaKey && !j.ctrlKey && !j.altKey && (j.preventDefault(), N(!0));
394
+ if (!R) return;
395
+ const I = (j) => {
396
+ const F = j.target, q = F && (F.tagName === "INPUT" || F.tagName === "TEXTAREA" || F.isContentEditable);
397
+ j.key === E && !q && !j.metaKey && !j.ctrlKey && !j.altKey && (j.preventDefault(), N(!0));
398
398
  };
399
- return document.addEventListener("keydown", F), () => document.removeEventListener("keydown", F);
400
- }, [M, E]);
399
+ return document.addEventListener("keydown", I), () => document.removeEventListener("keydown", I);
400
+ }, [E, R]);
401
401
  const V = l.useRef(p.pathname);
402
402
  l.useEffect(() => {
403
403
  V.current !== p.pathname && (V.current = p.pathname, O(!1));
404
404
  }, [p.pathname]);
405
- const Y = l.useRef(null), { ref: re } = Ae({
405
+ const Y = l.useRef(null), { ref: re } = De({
406
406
  open: A,
407
407
  onEscape: () => O(!1),
408
408
  initialFocus: Y
409
- }), ae = m.width ?? 240, D = !v && R !== "D";
409
+ }), ae = d.width ?? 240, z = !v && M !== "D";
410
410
  return /* @__PURE__ */ f(
411
411
  "div",
412
412
  {
413
413
  className: "prui-app prui-shell min-h-dvh bg-[var(--prui-background)] text-[var(--prui-fg)]",
414
- "data-layout": R,
415
- "data-collapsed": D ? "true" : void 0,
416
- style: { "--prui-shell-sidebar": D ? "var(--prui-rail-width, 64px)" : `${ae}px` },
414
+ "data-layout": M,
415
+ "data-collapsed": z ? "true" : void 0,
416
+ style: { "--prui-shell-sidebar": z ? "var(--prui-rail-width, 64px)" : `${ae}px` },
417
417
  children: [
418
418
  /* @__PURE__ */ f("aside", { "data-testid": "sidebar", className: "prui-shell-sidebar hidden md:flex md:flex-col md:min-h-0", children: [
419
- /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto p-2 pt-4 scrollbar-thin", children: /* @__PURE__ */ e(Ee, { nav: n, expandAllOn: y, collapsed: D }) }),
419
+ /* @__PURE__ */ e("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto p-2 pt-4 scrollbar-thin", children: /* @__PURE__ */ e(Ce, { nav: n, expandAllOn: y, collapsed: z }) }),
420
420
  P ? /* @__PURE__ */ e(
421
421
  "div",
422
422
  {
423
- className: C("border-t border-[var(--prui-line)] p-2", D && "flex justify-center px-1"),
423
+ className: C("border-t border-[var(--prui-line)] p-2", z && "flex justify-center px-1"),
424
424
  "data-testid": "sidebar-footer",
425
425
  children: P
426
426
  }
427
427
  ) : null,
428
- R !== "D" ? /* @__PURE__ */ e("div", { className: "border-t border-[var(--prui-line)] p-2", children: /* @__PURE__ */ e(
429
- K,
428
+ M !== "D" ? /* @__PURE__ */ e("div", { className: "border-t border-[var(--prui-line)] p-2", children: /* @__PURE__ */ e(
429
+ B,
430
430
  {
431
431
  variant: "ghost",
432
432
  size: "sm",
433
433
  className: "w-full justify-center",
434
- "aria-label": D ? u.expandSidebar : u.collapseSidebar,
434
+ "aria-label": z ? u.expandSidebar : u.collapseSidebar,
435
435
  "data-testid": "sidebar-toggle",
436
- onClick: () => i((F) => !F),
437
- children: D ? /* @__PURE__ */ e(Se, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ e(Te, { className: "h-4 w-4", "aria-hidden": !0 })
436
+ onClick: () => i((I) => !I),
437
+ children: z ? /* @__PURE__ */ e(bt, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ e(vt, { className: "h-4 w-4", "aria-hidden": !0 })
438
438
  }
439
439
  ) }) : null
440
440
  ] }),
441
- A ? /* @__PURE__ */ e($e, { children: /* @__PURE__ */ f("div", { ref: re, className: "md:hidden fixed inset-0 z-[var(--prui-z-drawer)]", "data-testid": "mobile-drawer", children: [
441
+ A ? /* @__PURE__ */ e(Ae, { children: /* @__PURE__ */ f("div", { ref: re, className: "md:hidden fixed inset-0 z-[var(--prui-z-drawer)]", "data-testid": "mobile-drawer", children: [
442
442
  /* @__PURE__ */ e(
443
443
  "div",
444
444
  {
@@ -467,17 +467,17 @@ function Qt(t) {
467
467
  children: /* @__PURE__ */ e(gt, { className: "h-4 w-4", "aria-hidden": !0 })
468
468
  }
469
469
  ) }),
470
- /* @__PURE__ */ e(Ee, { nav: n, onNavigate: () => O(!1), expandAllOn: y, collapsed: !1 })
470
+ /* @__PURE__ */ e(Ce, { nav: n, onNavigate: () => O(!1), expandAllOn: y, collapsed: !1 })
471
471
  ]
472
472
  }
473
473
  )
474
474
  ] }) }) : null,
475
- R === "C" ? /* @__PURE__ */ e(
475
+ M === "C" ? /* @__PURE__ */ e(
476
476
  "div",
477
477
  {
478
478
  "data-testid": "sidebar-header",
479
479
  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",
480
- children: w ?? /* @__PURE__ */ e(Me, { brand: a })
480
+ children: w ?? /* @__PURE__ */ e(Re, { brand: a })
481
481
  }
482
482
  ) : null,
483
483
  /* @__PURE__ */ f(
@@ -487,7 +487,7 @@ function Qt(t) {
487
487
  className: "prui-shell-header sticky top-0 z-[var(--prui-z-header)] 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",
488
488
  children: [
489
489
  $ ? /* @__PURE__ */ e(
490
- K,
490
+ B,
491
491
  {
492
492
  variant: "ghost",
493
493
  size: "icon",
@@ -498,20 +498,8 @@ function Qt(t) {
498
498
  children: /* @__PURE__ */ e(xt, { className: "h-4 w-4", "aria-hidden": !0 })
499
499
  }
500
500
  ) : null,
501
- $ && R !== "D" ? /* @__PURE__ */ e(
502
- K,
503
- {
504
- variant: "ghost",
505
- size: "icon",
506
- "aria-label": D ? u.expandSidebar : u.collapseSidebar,
507
- className: "md:hidden",
508
- onClick: () => i((F) => !F),
509
- "data-testid": "rail-toggle-mobile",
510
- children: D ? /* @__PURE__ */ e(Se, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ e(Te, { className: "h-4 w-4", "aria-hidden": !0 })
511
- }
512
- ) : null,
513
- /* @__PURE__ */ e("div", { className: "min-w-0 justify-self-start", children: /* @__PURE__ */ e(Me, { brand: a }) }),
514
- E ? /* @__PURE__ */ f(
501
+ /* @__PURE__ */ e("div", { className: "min-w-0 justify-self-start", children: /* @__PURE__ */ e(Re, { brand: a }) }),
502
+ R ? /* @__PURE__ */ f(
515
503
  "button",
516
504
  {
517
505
  type: "button",
@@ -521,7 +509,7 @@ function Qt(t) {
521
509
  children: [
522
510
  /* @__PURE__ */ e(yt, { className: "h-4 w-4", "aria-hidden": !0 }),
523
511
  /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: b.placeholder ?? `${u.search}...` }),
524
- /* @__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 })
512
+ /* @__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: E })
525
513
  ]
526
514
  }
527
515
  ) : null,
@@ -538,7 +526,7 @@ function Qt(t) {
538
526
  "data-testid": "app-content",
539
527
  tabIndex: 0,
540
528
  className: "prui-shell-content min-h-0 flex-1 p-4 outline-none md:p-6",
541
- children: k ? /* @__PURE__ */ e(qt, { mode: k, config: x, children: g }) : g ?? /* @__PURE__ */ e(ht, {})
529
+ children: k ? /* @__PURE__ */ e(qt, { mode: k, config: x, children: g }) : g ?? /* @__PURE__ */ e(pt, {})
542
530
  }
543
531
  ),
544
532
  h ? /* @__PURE__ */ e(l.Suspense, { fallback: null, children: /* @__PURE__ */ e(
@@ -546,17 +534,17 @@ function Qt(t) {
546
534
  {
547
535
  timeout: h.sessionTimeout,
548
536
  warningTime: h.warningTime,
549
- onTimeout: B
537
+ onTimeout: K
550
538
  }
551
539
  ) }) : null,
552
- E ? /* @__PURE__ */ e(Gt, { open: S, onOpenChange: N, entries: L, placeholder: b.placeholder, onNavigate: c }) : null
540
+ R ? /* @__PURE__ */ e(Gt, { open: S, onOpenChange: N, entries: L, placeholder: b.placeholder, onNavigate: c }) : null
553
541
  ]
554
542
  }
555
543
  );
556
544
  }
557
545
  function Rr(t) {
558
546
  const { router: a = "browser", initialEntries: n } = t;
559
- return /* @__PURE__ */ e(a === "memory" ? pt : ft, { initialEntries: n, children: /* @__PURE__ */ e(Qt, { ...t }) });
547
+ return /* @__PURE__ */ e(a === "memory" ? dt : mt, { initialEntries: n, children: /* @__PURE__ */ e(Qt, { ...t }) });
560
548
  }
561
549
  const Er = {
562
550
  name: "App",
@@ -585,7 +573,7 @@ function er(t) {
585
573
  if (t)
586
574
  return t.map((a) => typeof a == "string" || typeof a == "number" ? { label: String(a), value: String(a) } : a);
587
575
  }
588
- function je(t, a) {
576
+ function Ee(t, a) {
589
577
  const n = {};
590
578
  for (const r of t.fields)
591
579
  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] = "";
@@ -597,15 +585,15 @@ function tr({
597
585
  defaultValues: n,
598
586
  onSubmit: r,
599
587
  onCancel: o,
600
- cancelLabel: d,
601
- submitting: m = !1,
588
+ cancelLabel: m,
589
+ submitting: d = !1,
602
590
  error: T,
603
591
  className: k
604
592
  }) {
605
- const { t: x } = J(), y = l.useMemo(() => Zt(t), [t]), R = a ?? n, [w, P] = l.useState(() => je(y, R)), [g, u] = l.useState({}), [b, E] = l.useState(null), [M, $] = l.useState(!1);
593
+ const { t: x } = J(), y = l.useMemo(() => Zt(t), [t]), M = a ?? n, [w, P] = l.useState(() => Ee(y, M)), [g, u] = l.useState({}), [b, R] = l.useState(null), [E, $] = l.useState(!1);
606
594
  l.useEffect(() => {
607
- P(je(y, R));
608
- }, [JSON.stringify(y), JSON.stringify(R ?? {})]);
595
+ P(Ee(y, M));
596
+ }, [JSON.stringify(y), JSON.stringify(M ?? {})]);
609
597
  const A = (i, S) => {
610
598
  P((N) => ({ ...N, [i]: S })), u((N) => {
611
599
  if (!N[i]) return N;
@@ -625,17 +613,17 @@ function tr({
625
613
  c && (S[p.name] = c);
626
614
  }
627
615
  if (u(S), !(Object.keys(S).length > 0)) {
628
- E(null);
616
+ R(null);
629
617
  try {
630
618
  const p = r == null ? void 0 : r({ ...w });
631
619
  p && typeof p.then == "function" && ($(!0), await p);
632
620
  } catch (p) {
633
- E(p instanceof Error ? p.message : String(p));
621
+ R(p instanceof Error ? p.message : String(p));
634
622
  } finally {
635
623
  $(!1);
636
624
  }
637
625
  }
638
- }, v = m || M;
626
+ }, v = d || E;
639
627
  return /* @__PURE__ */ f("form", { onSubmit: O, className: C("prui-form flex flex-col gap-4", k), noValidate: !0, children: [
640
628
  /* @__PURE__ */ e("div", { className: C("grid gap-4", y.columns === 2 && "md:grid-cols-2"), children: y.fields.map((i) => {
641
629
  const S = g[i.name], N = {
@@ -658,7 +646,7 @@ function tr({
658
646
  onChange: (p) => A(i.name, p.target.value)
659
647
  }
660
648
  ) : i.type === "select" ? /* @__PURE__ */ e(
661
- Ie,
649
+ $e,
662
650
  {
663
651
  ...N,
664
652
  options: er(i.options),
@@ -678,7 +666,7 @@ function tr({
678
666
  onChange: (p) => A(i.name, p.target.value)
679
667
  }
680
668
  ) : i.type === "boolean" ? /* @__PURE__ */ e(
681
- Le,
669
+ Fe,
682
670
  {
683
671
  ...N,
684
672
  disabled: i.disabled || v,
@@ -701,12 +689,12 @@ function tr({
701
689
  }) }),
702
690
  T ?? b ? /* @__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: T ?? b }) : null,
703
691
  /* @__PURE__ */ f("div", { className: "flex items-center justify-end gap-2", children: [
704
- o ? /* @__PURE__ */ e(K, { type: "button", variant: "ghost", onClick: o, disabled: v, children: d ?? x.cancel }) : null,
705
- /* @__PURE__ */ e(K, { type: "submit", variant: "primary", loading: v, children: y.submitLabel ?? "Submit" })
692
+ o ? /* @__PURE__ */ e(B, { type: "button", variant: "ghost", onClick: o, disabled: v, children: m ?? x.cancel }) : null,
693
+ /* @__PURE__ */ e(B, { type: "submit", variant: "primary", loading: v, children: y.submitLabel ?? "Submit" })
706
694
  ] })
707
695
  ] });
708
696
  }
709
- const Mr = {
697
+ const jr = {
710
698
  name: "Form",
711
699
  props: [
712
700
  { name: "schema", type: "FormSchema", default: null, control: "object" },
@@ -717,7 +705,7 @@ const Mr = {
717
705
  { name: "error", type: "string | null", default: "null", control: "text" }
718
706
  ]
719
707
  };
720
- function He(t) {
708
+ function _e(t) {
721
709
  if (t)
722
710
  return t.map((a) => typeof a == "string" || typeof a == "number" ? { label: String(a), value: String(a) } : a);
723
711
  }
@@ -728,7 +716,7 @@ function rr(t, a) {
728
716
  name: r.key,
729
717
  label: typeof r.label == "string" ? r.label : r.key,
730
718
  type: ar(r, a),
731
- options: (o = He(r.filterOptions ?? r.options)) == null ? void 0 : o.map((d) => ({ label: d.label, value: d.value })),
719
+ options: (o = _e(r.filterOptions ?? r.options)) == null ? void 0 : o.map((m) => ({ label: m.label, value: m.value })),
732
720
  required: !1
733
721
  };
734
722
  }), submitLabel: a ? "Save" : "Create" };
@@ -736,26 +724,26 @@ function rr(t, a) {
736
724
  function ar(t, a) {
737
725
  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";
738
726
  }
739
- function jr({
727
+ function Mr({
740
728
  name: t,
741
729
  columns: a,
742
730
  list: n,
743
731
  create: r,
744
732
  update: o,
745
- remove: d,
746
- delete: m,
733
+ remove: m,
734
+ delete: d,
747
735
  actions: T,
748
736
  form: k,
749
737
  formSchema: x,
750
738
  rowKey: y,
751
- searchPlaceholder: R,
739
+ searchPlaceholder: M,
752
740
  pageSize: w,
753
741
  state: P,
754
742
  defaultState: g,
755
743
  onStateChange: u,
756
744
  onPageChange: b,
757
- onFilterChange: E,
758
- onSortChange: M,
745
+ onFilterChange: R,
746
+ onSortChange: E,
759
747
  onSearchChange: $,
760
748
  onPageSizeChange: A,
761
749
  onSelectionChange: O,
@@ -765,7 +753,7 @@ function jr({
765
753
  searchDebounce: N = 250,
766
754
  className: p
767
755
  }) {
768
- const { t: c } = J(), h = d ?? m, B = T ?? ["create", "edit", "delete"], L = (s) => B.includes(s) && (s === "create" ? !!r : s === "edit" ? !!o : !!h), V = l.useMemo(
756
+ const { t: c } = J(), h = m ?? d, K = T ?? ["create", "edit", "delete"], L = (s) => K.includes(s) && (s === "create" ? !!r : s === "edit" ? !!o : !!h), V = l.useMemo(
769
757
  () => ({
770
758
  page: 1,
771
759
  pageSize: w ?? (g == null ? void 0 : g.pageSize) ?? 20,
@@ -780,23 +768,23 @@ function jr({
780
768
  ), [Y, re] = l.useState(V), ae = l.useMemo(
781
769
  () => ({ ...Y, ...Object.fromEntries(Object.entries(P ?? {}).filter(([, s]) => s !== void 0)) }),
782
770
  [Y, P]
783
- ), D = l.useCallback(
771
+ ), z = l.useCallback(
784
772
  (s) => {
785
- re((z) => {
786
- const U = { ...z }, X = P;
787
- for (const [G, ct] of Object.entries(s))
788
- X && G in X && X[G] !== void 0 || (U[G] = ct);
773
+ re((D) => {
774
+ const U = { ...D }, X = P;
775
+ for (const [G, it] of Object.entries(s))
776
+ X && G in X && X[G] !== void 0 || (U[G] = it);
789
777
  const te = { ...U, ...Object.fromEntries(Object.entries(P ?? {}).filter(([, G]) => G !== void 0)) };
790
778
  return u == null || u(te), U;
791
779
  });
792
780
  },
793
781
  [P, u]
794
- ), { page: F, pageSize: j, search: I, filters: q, sort: ne, selection: Je, expandedRows: Ye } = ae, [We, oe] = l.useState([]), [ce, ue] = l.useState(null), [Xe, de] = l.useState([null]), [Ge, me] = l.useState(!0), [pe, fe] = l.useState(null), [_, he] = l.useState(null), [Qe, W] = l.useState(!1), [be, ve] = l.useState(!1), [le, Ze] = l.useState(I);
782
+ ), { page: I, pageSize: j, search: F, filters: q, sort: ne, selection: qe, expandedRows: He } = ae, [Je, oe] = l.useState([]), [ce, ue] = l.useState(null), [Ye, de] = l.useState([null]), [We, me] = l.useState(!0), [pe, fe] = l.useState(null), [_, he] = l.useState(null), [Xe, W] = l.useState(!1), [be, ve] = l.useState(!1), [le, Ge] = l.useState(F);
795
783
  l.useEffect(() => {
796
- const s = setTimeout(() => Ze(I), N);
784
+ const s = setTimeout(() => Ge(F), N);
797
785
  return () => clearTimeout(s);
798
- }, [I, N]);
799
- const ge = Xe[F - 1] ?? null, xe = JSON.stringify(q), Q = l.useCallback(async () => {
786
+ }, [F, N]);
787
+ const ge = Ye[I - 1] ?? null, xe = JSON.stringify(q), Q = l.useCallback(async () => {
800
788
  me(!0), fe(null);
801
789
  try {
802
790
  const s = await n({ search: le, cursor: ge, pageSize: j, sort: ne, filters: q });
@@ -810,33 +798,33 @@ function jr({
810
798
  l.useEffect(() => {
811
799
  Q();
812
800
  }, [Q]), l.useEffect(() => {
813
- D({ page: 1 }), de([null]);
801
+ z({ page: 1 }), de([null]);
814
802
  }, [le, j, xe]);
815
- const et = l.useMemo(
803
+ const Qe = l.useMemo(
816
804
  () => a.filter((s) => s.filter).map((s) => ({
817
805
  key: s.key,
818
806
  label: typeof s.label == "string" ? s.label : s.key,
819
807
  type: s.filter === "numberrange" ? "number" : s.filter,
820
- options: He(s.filterOptions ?? s.options)
808
+ options: _e(s.filterOptions ?? s.options)
821
809
  })),
822
810
  [a]
823
- ), tt = (s, z) => {
824
- const U = { ...q, [s]: z };
825
- D({ filters: U }), E == null || E(U);
826
- }, rt = (s) => {
827
- D({ search: s }), $ == null || $(s);
828
- }, at = (s) => {
829
- D({ sort: s }), M == null || M(s);
830
- }, nt = (s, z) => {
831
- if (z === "next") {
811
+ ), Ze = (s, D) => {
812
+ const U = { ...q, [s]: D };
813
+ z({ filters: U }), R == null || R(U);
814
+ }, et = (s) => {
815
+ z({ search: s }), $ == null || $(s);
816
+ }, tt = (s) => {
817
+ z({ sort: s }), E == null || E(s);
818
+ }, rt = (s, D) => {
819
+ if (D === "next") {
832
820
  const U = ce;
833
821
  de((X) => {
834
822
  const te = [...X];
835
823
  return te[s - 1] = U, te;
836
824
  });
837
825
  }
838
- D({ page: s }), b == null || b(s);
839
- }, lt = l.useMemo(
826
+ z({ page: s }), b == null || b(s);
827
+ }, at = l.useMemo(
840
828
  () => [
841
829
  ...a.filter((s) => !s.hidden),
842
830
  ...L("edit") || L("delete") ? [
@@ -845,13 +833,13 @@ function jr({
845
833
  label: "",
846
834
  align: "right",
847
835
  render: (s) => /* @__PURE__ */ f("div", { className: "flex items-center justify-end gap-1", children: [
848
- L("edit") ? /* @__PURE__ */ e(K, { variant: "ghost", size: "icon", "aria-label": "Edit", onClick: () => {
849
- var z;
850
- return (z = Z.current) == null ? void 0 : z.call(Z, s);
836
+ L("edit") ? /* @__PURE__ */ e(B, { variant: "ghost", size: "icon", "aria-label": "Edit", onClick: () => {
837
+ var D;
838
+ return (D = Z.current) == null ? void 0 : D.call(Z, s);
851
839
  }, "data-testid": "resource-edit", children: /* @__PURE__ */ e(kt, { className: "h-3.5 w-3.5", "aria-hidden": !0 }) }) : null,
852
- L("delete") ? /* @__PURE__ */ e(K, { variant: "ghost", size: "icon", "aria-label": "Delete", disabled: be, onClick: () => {
853
- var z;
854
- return void ((z = ee.current) == null ? void 0 : z.call(ee, s));
840
+ L("delete") ? /* @__PURE__ */ e(B, { variant: "ghost", size: "icon", "aria-label": "Delete", disabled: be, onClick: () => {
841
+ var D;
842
+ return void ((D = ee.current) == null ? void 0 : D.call(ee, s));
855
843
  }, "data-testid": "resource-delete", children: /* @__PURE__ */ e(St, { className: "h-3.5 w-3.5 text-[var(--prui-danger)]", "aria-hidden": !0 }) }) : null
856
844
  ] })
857
845
  }
@@ -859,7 +847,7 @@ function jr({
859
847
  ],
860
848
  // eslint-disable-next-line react-hooks/exhaustive-deps -- can() depends only on the action functions
861
849
  [a, r, o, h, be]
862
- ), st = () => {
850
+ ), nt = () => {
863
851
  he(null), W(!0);
864
852
  }, ye = (s) => {
865
853
  he(s), W(!0);
@@ -882,10 +870,10 @@ function jr({
882
870
  Z.current = ye;
883
871
  const ee = l.useRef(we);
884
872
  ee.current = we;
885
- const it = l.useCallback(
886
- (s, z) => String(y ? y(s, z) : s.id ?? z),
873
+ const lt = l.useCallback(
874
+ (s, D) => String(y ? y(s, D) : s.id ?? D),
887
875
  [y]
888
- ), Ne = x ?? rr(a, _), ot = _ ? Object.fromEntries(
876
+ ), Ne = x ?? rr(a, _), st = _ ? Object.fromEntries(
889
877
  Ne.fields.map((s) => [s.name, _[s.name] ?? ""])
890
878
  ) : void 0, H = t.replace(/s$/, "");
891
879
  return /* @__PURE__ */ f("div", { className: C("prui-resource flex flex-col gap-2", p), "data-testid": "resource", children: [
@@ -893,13 +881,13 @@ function jr({
893
881
  /* @__PURE__ */ e(
894
882
  It,
895
883
  {
896
- searchPlaceholder: R ?? c.searchEntity.replace("{name}", t),
897
- searchValue: I,
898
- onSearchChange: rt,
899
- filters: et,
884
+ searchPlaceholder: M ?? c.searchEntity.replace("{name}", t),
885
+ searchValue: F,
886
+ onSearchChange: et,
887
+ filters: Qe,
900
888
  filterValues: q,
901
- onFilterChange: tt,
902
- actions: L("create") ? /* @__PURE__ */ f(K, { variant: "primary", size: "sm", onClick: st, "data-testid": "resource-create", children: [
889
+ onFilterChange: Ze,
890
+ actions: L("create") ? /* @__PURE__ */ f(B, { variant: "primary", size: "sm", onClick: nt, "data-testid": "resource-create", children: [
903
891
  /* @__PURE__ */ e(Tt, { className: "h-4 w-4", "aria-hidden": !0 }),
904
892
  c.newEntity.replace("{name}", H)
905
893
  ] }) : void 0
@@ -909,43 +897,43 @@ function jr({
909
897
  /* @__PURE__ */ e(
910
898
  Lt,
911
899
  {
912
- columns: lt,
913
- rows: We,
914
- rowKey: it,
900
+ columns: at,
901
+ rows: Je,
902
+ rowKey: lt,
915
903
  sort: ne,
916
- onSortChange: at,
917
- loading: Ge,
904
+ onSortChange: tt,
905
+ loading: We,
918
906
  selectable: v,
919
- selectedRowKeys: Je,
920
- onSelectionChange: (s, z) => {
921
- D({ selection: s }), O == null || O(s, z);
907
+ selectedRowKeys: qe,
908
+ onSelectionChange: (s, D) => {
909
+ z({ selection: s }), O == null || O(s, D);
922
910
  },
923
911
  renderExpandedRow: i,
924
- expandedRowKeys: Ye,
925
- onExpandedRowsChange: (s) => D({ expandedRows: s }),
912
+ expandedRowKeys: He,
913
+ onExpandedRowsChange: (s) => z({ expandedRows: s }),
926
914
  virtualized: S
927
915
  }
928
916
  ),
929
917
  /* @__PURE__ */ e(
930
918
  Kt,
931
919
  {
932
- page: F,
920
+ page: I,
933
921
  pageSize: j,
934
922
  hasNextPage: ce != null,
935
- hasPreviousPage: F > 1,
936
- onPageChange: nt,
923
+ hasPreviousPage: I > 1,
924
+ onPageChange: rt,
937
925
  onPageSizeChange: (s) => {
938
- D({ pageSize: s }), A == null || A(s);
926
+ z({ pageSize: s }), A == null || A(s);
939
927
  }
940
928
  }
941
929
  ),
942
- /* @__PURE__ */ f(Fe, { open: Qe, onClose: () => W(!1), size: "sm", ariaLabel: _ ? c.editEntity.replace("{name}", H) : c.newEntity.replace("{name}", H), noPadding: !0, children: [
930
+ /* @__PURE__ */ f(ze, { open: Xe, onClose: () => W(!1), size: "sm", ariaLabel: _ ? c.editEntity.replace("{name}", H) : c.newEntity.replace("{name}", H), noPadding: !0, children: [
943
931
  /* @__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: _ ? c.editEntity.replace("{name}", H) : c.newEntity.replace("{name}", H) }) }),
944
932
  /* @__PURE__ */ e("div", { className: "px-8 pb-8", children: k ?? /* @__PURE__ */ e(
945
933
  tr,
946
934
  {
947
935
  schema: Ne,
948
- initialValues: ot,
936
+ initialValues: st,
949
937
  onCancel: () => W(!1),
950
938
  onSubmit: async (s) => {
951
939
  _ ? await (o == null ? void 0 : o(_, s)) : await (r == null ? void 0 : r(s)), W(!1), await Q();
@@ -987,15 +975,15 @@ const Pr = {
987
975
  function Or({ items: t, className: a }) {
988
976
  return /* @__PURE__ */ e("div", { className: C("prui-stat-row grid gap-3 sm:grid-cols-2 lg:grid-cols-4", a), children: t.map((n, r) => {
989
977
  const o = n.icon;
990
- return /* @__PURE__ */ f(Ke, { "data-testid": "stat-card", children: [
991
- /* @__PURE__ */ f(Be, { className: "pb-2", children: [
992
- /* @__PURE__ */ f(Ue, { className: "flex items-center gap-1.5 text-xs", children: [
978
+ return /* @__PURE__ */ f(Ie, { "data-testid": "stat-card", children: [
979
+ /* @__PURE__ */ f(Le, { className: "pb-2", children: [
980
+ /* @__PURE__ */ f(Ke, { className: "flex items-center gap-1.5 text-xs", children: [
993
981
  o ? /* @__PURE__ */ e(o, { className: "h-3.5 w-3.5", "aria-hidden": !0 }) : null,
994
982
  n.label
995
983
  ] }),
996
- /* @__PURE__ */ e(Ve, { className: "text-2xl", children: n.value })
984
+ /* @__PURE__ */ e(Be, { className: "text-2xl", children: n.value })
997
985
  ] }),
998
- n.delta ? /* @__PURE__ */ e(_e, { className: "pb-3", children: /* @__PURE__ */ e(
986
+ n.delta ? /* @__PURE__ */ e(Ue, { className: "pb-3", children: /* @__PURE__ */ e(
999
987
  "span",
1000
988
  {
1001
989
  className: C(
@@ -1024,38 +1012,38 @@ function nr(t) {
1024
1012
  function lr({ field: t }) {
1025
1013
  const { name: a, type: n, value: r, onChange: o } = t;
1026
1014
  if (!n || !a) return null;
1027
- const d = `prui-settings-${a}`;
1028
- return n === "switch" ? /* @__PURE__ */ e("label", { className: "flex items-center gap-2", htmlFor: d, children: /* @__PURE__ */ e(
1029
- Le,
1015
+ const m = `prui-settings-${a}`;
1016
+ return n === "switch" ? /* @__PURE__ */ e("label", { className: "flex items-center gap-2", htmlFor: m, children: /* @__PURE__ */ e(
1017
+ Fe,
1030
1018
  {
1031
- id: d,
1019
+ id: m,
1032
1020
  checked: !!r,
1033
- onChange: (m) => o == null ? void 0 : o(m),
1021
+ onChange: (d) => o == null ? void 0 : o(d),
1034
1022
  "aria-label": t.label
1035
1023
  }
1036
1024
  ) }) : n === "select" ? /* @__PURE__ */ e(
1037
- Ie,
1025
+ $e,
1038
1026
  {
1039
- id: d,
1027
+ id: m,
1040
1028
  className: "w-56",
1041
1029
  options: nr(t.options) ?? [],
1042
1030
  value: String(r ?? ""),
1043
- onChange: (m) => o == null ? void 0 : o(m),
1031
+ onChange: (d) => o == null ? void 0 : o(Array.isArray(d) ? d.join(",") : d),
1044
1032
  "aria-label": t.label
1045
1033
  }
1046
1034
  ) : /* @__PURE__ */ e(
1047
1035
  ie,
1048
1036
  {
1049
- id: d,
1037
+ id: m,
1050
1038
  type: n === "number" ? "number" : "text",
1051
1039
  className: "h-8 w-56",
1052
1040
  value: String(r ?? ""),
1053
- onChange: (m) => o == null ? void 0 : o(n === "number" ? m.target.value === "" ? "" : Number(m.target.value) : m.target.value),
1041
+ onChange: (d) => o == null ? void 0 : o(n === "number" ? d.target.value === "" ? "" : Number(d.target.value) : d.target.value),
1054
1042
  "aria-label": t.label
1055
1043
  }
1056
1044
  );
1057
1045
  }
1058
- function zr({ title: t = "Settings", sections: a, className: n }) {
1046
+ function Ar({ title: t = "Settings", sections: a, className: n }) {
1059
1047
  return /* @__PURE__ */ f("div", { className: C("prui-settings mx-auto flex w-full max-w-4xl flex-col gap-6", n), children: [
1060
1048
  /* @__PURE__ */ e("h1", { className: "text-xl font-semibold text-[var(--prui-fg)]", children: t }),
1061
1049
  /* @__PURE__ */ f("div", { className: "flex flex-col gap-6 md:flex-row", children: [
@@ -1067,64 +1055,64 @@ function zr({ title: t = "Settings", sections: a, className: n }) {
1067
1055
  children: r.title ?? r.label ?? r.id
1068
1056
  }
1069
1057
  ) }, r.id)) }) }),
1070
- /* @__PURE__ */ e("div", { className: "flex min-w-0 flex-1 flex-col gap-4", children: a.map((r) => /* @__PURE__ */ f(Ke, { id: `settings-${r.id}`, "data-testid": "settings-section", children: [
1071
- /* @__PURE__ */ f(Be, { children: [
1072
- /* @__PURE__ */ e(Ve, { children: r.title ?? r.label ?? r.id }),
1073
- r.description ? /* @__PURE__ */ e(Ue, { children: r.description }) : null
1058
+ /* @__PURE__ */ e("div", { className: "flex min-w-0 flex-1 flex-col gap-4", children: a.map((r) => /* @__PURE__ */ f(Ie, { id: `settings-${r.id}`, "data-testid": "settings-section", children: [
1059
+ /* @__PURE__ */ f(Le, { children: [
1060
+ /* @__PURE__ */ e(Be, { children: r.title ?? r.label ?? r.id }),
1061
+ r.description ? /* @__PURE__ */ e(Ke, { children: r.description }) : null
1074
1062
  ] }),
1075
- /* @__PURE__ */ e(_e, { children: r.content ?? /* @__PURE__ */ e("dl", { className: "flex flex-col divide-y divide-[var(--prui-line)]", children: (r.fields ?? []).map((o, d) => /* @__PURE__ */ f("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: [
1063
+ /* @__PURE__ */ e(Ue, { children: r.content ?? /* @__PURE__ */ e("dl", { className: "flex flex-col divide-y divide-[var(--prui-line)]", children: (r.fields ?? []).map((o, m) => /* @__PURE__ */ f("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: [
1076
1064
  /* @__PURE__ */ f("div", { className: "min-w-0", children: [
1077
1065
  /* @__PURE__ */ e("dt", { className: "text-sm font-medium text-[var(--prui-fg)]", children: o.label }),
1078
1066
  o.description ? /* @__PURE__ */ e("dd", { className: "text-xs text-[var(--prui-dim)]", children: o.description }) : null
1079
1067
  ] }),
1080
1068
  /* @__PURE__ */ e("div", { className: "shrink-0", children: o.control ?? /* @__PURE__ */ e(lr, { field: o }) })
1081
- ] }, `${o.label}-${d}`)) }) })
1069
+ ] }, `${o.label}-${m}`)) }) })
1082
1070
  ] }, r.id)) })
1083
1071
  ] })
1084
1072
  ] });
1085
1073
  }
1086
- const Ar = {
1074
+ const zr = {
1087
1075
  name: "Settings",
1088
1076
  props: [
1089
1077
  { name: "title", type: "string", default: "'Settings'", control: "text" },
1090
1078
  { name: "sections", type: "SettingsSection[]", default: null, control: "object" }
1091
1079
  ]
1092
- }, Pe = ["mousedown", "keydown", "scroll", "touchstart", "click"];
1080
+ }, je = ["mousedown", "keydown", "scroll", "touchstart", "click"];
1093
1081
  function sr({
1094
1082
  timeout: t = 15,
1095
1083
  warningTime: a = 2,
1096
1084
  onTimeout: n,
1097
1085
  onExtend: r,
1098
1086
  title: o = "Session expiring soon",
1099
- message: d = "Your session is about to expire due to inactivity."
1087
+ message: m = "Your session is about to expire due to inactivity."
1100
1088
  }) {
1101
- const m = Math.max(0, t) * 6e4, T = Math.min(Math.max(0, a) * 6e4, m), [k, x] = l.useState(!1), [y, R] = l.useState(T), w = l.useRef(null), P = l.useRef(null), g = l.useRef(null), u = l.useRef(!1), b = l.useCallback(() => {
1089
+ const d = Math.max(0, t) * 6e4, T = Math.min(Math.max(0, a) * 6e4, d), [k, x] = l.useState(!1), [y, M] = l.useState(T), w = l.useRef(null), P = l.useRef(null), g = l.useRef(null), u = l.useRef(!1), b = l.useCallback(() => {
1102
1090
  for (const i of [w, P, g])
1103
1091
  i.current != null && (clearInterval(i.current), clearTimeout(i.current), i.current = null);
1104
- }, []), E = l.useCallback(() => {
1092
+ }, []), R = l.useCallback(() => {
1105
1093
  b(), x(!1), n == null || n();
1106
- }, [b, n]), M = l.useCallback(() => {
1094
+ }, [b, n]), E = l.useCallback(() => {
1107
1095
  b(), x(!1), u.current = !1, w.current = window.setTimeout(() => {
1108
- u.current = !0, R(T), x(!0), g.current = window.setInterval(() => {
1109
- R((i) => i <= 1e3 ? (E(), 0) : i - 1e3);
1096
+ u.current = !0, M(T), x(!0), g.current = window.setInterval(() => {
1097
+ M((i) => i <= 1e3 ? (R(), 0) : i - 1e3);
1110
1098
  }, 1e3);
1111
- }, m - T), P.current = window.setTimeout(E, m);
1112
- }, [b, E, m, T]);
1099
+ }, d - T), P.current = window.setTimeout(R, d);
1100
+ }, [b, R, d, T]);
1113
1101
  l.useEffect(() => {
1114
1102
  const i = () => {
1115
- u.current || M();
1103
+ u.current || E();
1116
1104
  };
1117
- for (const S of Pe) document.addEventListener(S, i, { passive: !0 });
1118
- return M(), () => {
1105
+ for (const S of je) document.addEventListener(S, i, { passive: !0 });
1106
+ return E(), () => {
1119
1107
  b();
1120
- for (const S of Pe) document.removeEventListener(S, i);
1108
+ for (const S of je) document.removeEventListener(S, i);
1121
1109
  };
1122
- }, [M, b]);
1110
+ }, [E, b]);
1123
1111
  const $ = () => {
1124
- r == null || r(), M();
1112
+ r == null || r(), E();
1125
1113
  }, A = Math.floor(y / 6e4), O = Math.floor(y % 6e4 / 1e3), v = `${A}:${String(O).padStart(2, "0")}`;
1126
1114
  return /* @__PURE__ */ f(
1127
- Fe,
1115
+ ze,
1128
1116
  {
1129
1117
  open: k,
1130
1118
  onClose: $,
@@ -1134,12 +1122,12 @@ function sr({
1134
1122
  /* @__PURE__ */ f("div", { className: "flex flex-col items-center gap-1 px-8 pb-2 pt-8 text-center", children: [
1135
1123
  /* @__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(Ct, { className: "h-6 w-6 text-[var(--prui-warn)]", "aria-hidden": !0 }) }),
1136
1124
  /* @__PURE__ */ e("h2", { className: "text-lg font-semibold text-[var(--prui-fg)]", children: o }),
1137
- /* @__PURE__ */ e("p", { className: "text-sm text-[var(--prui-dim)]", children: d }),
1125
+ /* @__PURE__ */ e("p", { className: "text-sm text-[var(--prui-dim)]", children: m }),
1138
1126
  /* @__PURE__ */ e("div", { className: "py-4 font-mono text-4xl font-bold text-[var(--prui-fg)]", "data-testid": "session-countdown", children: v })
1139
1127
  ] }),
1140
1128
  /* @__PURE__ */ f("div", { className: "flex flex-col gap-2 px-8 pb-8 sm:flex-row", children: [
1141
- /* @__PURE__ */ e(K, { variant: "default", className: "flex-1", onClick: E, "data-testid": "session-logout", children: "Log out now" }),
1142
- /* @__PURE__ */ e(K, { variant: "primary", className: "flex-1", onClick: $, "data-testid": "session-extend", children: "Continue session" })
1129
+ /* @__PURE__ */ e(B, { variant: "default", className: "flex-1", onClick: R, "data-testid": "session-logout", children: "Log out now" }),
1130
+ /* @__PURE__ */ e(B, { variant: "primary", className: "flex-1", onClick: $, "data-testid": "session-extend", children: "Continue session" })
1143
1131
  ] })
1144
1132
  ]
1145
1133
  }
@@ -1158,8 +1146,8 @@ const ir = {
1158
1146
  SessionTimeout: sr,
1159
1147
  sessionTimeoutPropsMeta: ir
1160
1148
  }, Symbol.toStringTag, { value: "Module" }));
1161
- function $r({ title: t, description: a, brand: n, width: r = "max-w-sm", footer: o, children: d, className: m }) {
1162
- return /* @__PURE__ */ e("div", { className: C("prui-auth-shell flex min-h-[100dvh] items-center justify-center bg-[var(--prui-background)] p-4", m), "data-testid": "auth-shell", children: /* @__PURE__ */ f("div", { className: C("w-full", r), children: [
1149
+ function $r({ title: t, description: a, brand: n, width: r = "max-w-sm", footer: o, children: m, className: d }) {
1150
+ return /* @__PURE__ */ e("div", { className: C("prui-auth-shell flex min-h-[100dvh] items-center justify-center bg-[var(--prui-background)] p-4", d), "data-testid": "auth-shell", children: /* @__PURE__ */ f("div", { className: C("w-full", r), children: [
1163
1151
  n ? /* @__PURE__ */ f("div", { className: "mb-6 flex items-center justify-center gap-2", "data-testid": "auth-shell-brand", children: [
1164
1152
  n.mark ? /* @__PURE__ */ e("img", { src: n.mark, alt: "", className: "h-8 w-8 rounded-[var(--prui-radius-1)] object-cover" }) : null,
1165
1153
  /* @__PURE__ */ e("span", { className: "text-lg font-semibold text-[var(--prui-fg)]", children: n.name })
@@ -1169,7 +1157,7 @@ function $r({ title: t, description: a, brand: n, width: r = "max-w-sm", footer:
1169
1157
  /* @__PURE__ */ e("h1", { className: "text-lg font-semibold text-[var(--prui-fg)]", children: t }),
1170
1158
  a ? /* @__PURE__ */ e("p", { className: "text-sm text-[var(--prui-dim)]", children: a }) : null
1171
1159
  ] }),
1172
- d,
1160
+ m,
1173
1161
  o ? /* @__PURE__ */ e("div", { className: "mt-4 text-center text-sm text-[var(--prui-dim)]", children: o }) : null
1174
1162
  ] })
1175
1163
  ] }) });
@@ -1189,18 +1177,18 @@ export {
1189
1177
  Rr as A,
1190
1178
  Gt as C,
1191
1179
  tr as F,
1192
- jr as R,
1180
+ Mr as R,
1193
1181
  sr as S,
1194
1182
  Qt as a,
1195
1183
  $r as b,
1196
1184
  qt as c,
1197
- zr as d,
1198
- Ee as e,
1185
+ Ar as d,
1186
+ Ce as e,
1199
1187
  Or as f,
1200
1188
  Er as g,
1201
1189
  Fr as h,
1202
- Mr as i,
1203
- Ar as j,
1190
+ jr as i,
1191
+ zr as j,
1204
1192
  Dr as k,
1205
1193
  Pr as r,
1206
1194
  ir as s,