@object-ui/layout 6.0.4 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @object-ui/layout
|
|
2
2
|
|
|
3
|
+
## 6.2.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @object-ui/react@6.2.0
|
|
8
|
+
- @object-ui/components@6.2.0
|
|
9
|
+
- @object-ui/types@6.2.0
|
|
10
|
+
- @object-ui/core@6.2.0
|
|
11
|
+
|
|
12
|
+
## 6.1.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [991b62d]
|
|
17
|
+
- @object-ui/core@6.1.0
|
|
18
|
+
- @object-ui/types@6.1.0
|
|
19
|
+
- @object-ui/components@6.1.0
|
|
20
|
+
- @object-ui/react@6.1.0
|
|
21
|
+
|
|
3
22
|
## 6.0.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { ComponentRegistry as e } from "@object-ui/core";
|
|
2
2
|
import t, { useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
3
|
import { Badge as a, Button as o, Collapsible as s, CollapsibleContent as c, CollapsibleTrigger as l, Input as u, LazyIcon as d, Separator as f, Sidebar as p, SidebarContent as m, SidebarFooter as h, SidebarGroup as g, SidebarGroupContent as _, SidebarGroupLabel as v, SidebarHeader as y, SidebarInput as b, SidebarInset as x, SidebarMenu as S, SidebarMenuAction as C, SidebarMenuButton as w, SidebarMenuItem as T, SidebarMenuSub as E, SidebarMenuSubButton as D, SidebarMenuSubItem as O, SidebarProvider as k, cn as A, getLazyIcon as j } from "@object-ui/components";
|
|
4
|
-
import { ArrowLeft as M, ChevronRight as
|
|
5
|
-
import { SchemaRenderer as
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { Link as
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { SortableContext as
|
|
10
|
-
import { CSS as
|
|
11
|
-
import { menuItemToNavigationItem as
|
|
4
|
+
import { ArrowLeft as M, ChevronRight as ee, FileText as te, GripVertical as ne, Layers as N, Pin as re, PinOff as P, Search as F, Star as ie } from "lucide-react";
|
|
5
|
+
import { SchemaRenderer as I, useRecordContext as ae } from "@object-ui/react";
|
|
6
|
+
import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
7
|
+
import { Link as B, NavLink as V, useLocation as H } from "react-router-dom";
|
|
8
|
+
import { DndContext as U, KeyboardSensor as W, PointerSensor as oe, closestCenter as se, useSensor as ce, useSensors as le } from "@dnd-kit/core";
|
|
9
|
+
import { SortableContext as ue, arrayMove as de, useSortable as fe, verticalListSortingStrategy as pe } from "@dnd-kit/sortable";
|
|
10
|
+
import { CSS as me } from "@dnd-kit/utilities";
|
|
11
|
+
import { menuItemToNavigationItem as he } from "@object-ui/types";
|
|
12
12
|
//#region src/PageHeader.tsx
|
|
13
|
-
var
|
|
13
|
+
var ge = (e) => {
|
|
14
14
|
let t = e?.name ?? e?.full_name ?? e?.display_name ?? e?.label ?? e?.title ?? e?.subject;
|
|
15
15
|
return t != null && String(t).trim() ? String(t) : [
|
|
16
16
|
e?.salutation,
|
|
17
17
|
e?.first_name,
|
|
18
18
|
e?.last_name
|
|
19
19
|
].filter((e) => typeof e == "string" && e.trim()).map((e) => e.trim()).join(" ") || (typeof e?.email == "string" && e.email.trim() ? e.email.trim() : null);
|
|
20
|
-
},
|
|
20
|
+
}, G = (e, t) => !e || typeof e != "string" ? e ?? "" : e.includes("{") ? e.replace(/\{([a-zA-Z0-9_.]+)\}/g, (e, n) => {
|
|
21
21
|
let r = n.split(".").reduce((e, t) => e == null ? e : e[t], t);
|
|
22
|
-
return r == null ? "" : typeof r == "object" ?
|
|
22
|
+
return r == null ? "" : typeof r == "object" ? ge(r) ?? "" : String(r);
|
|
23
23
|
}).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g, "").replace(/^\s*[-–—|/·,:]\s*/, "").replace(/\s+/g, " ").trim() : e;
|
|
24
|
-
function
|
|
25
|
-
let m =
|
|
24
|
+
function K({ title: e, subtitle: n, description: r, icon: i, action: a, actions: s, showBack: c, schema: l, className: u, children: f, ...p }) {
|
|
25
|
+
let m = ae(), h = typeof e == "string" && /\{[a-zA-Z0-9_.]+\}/.test(e), g = G(e, m?.data) || (h ? "" : e), _ = n ?? r, v = typeof _ == "string" && /\{[a-zA-Z0-9_.]+\}/.test(_), y = G(_, m?.data) || (v ? "" : _), b = !!m?.recordId, x = !!m?.embedded, S = c ?? (b && !x), C = t.useCallback(() => {
|
|
26
26
|
if (typeof window > "u") return;
|
|
27
27
|
let e = window.location.pathname, t = e.replace(/\/record\/[^/]+\/?$/, "");
|
|
28
28
|
t === e ? window.history.length > 1 && window.history.back() : (window.history.pushState({}, "", t + window.location.search), window.dispatchEvent(new PopStateEvent("popstate")));
|
|
29
|
-
}, []), w = Array.isArray(l?.children) ? l.children.filter(Boolean).map((e, t) => /* @__PURE__ */
|
|
29
|
+
}, []), w = Array.isArray(l?.children) ? l.children.filter(Boolean).map((e, t) => /* @__PURE__ */ R(I, { schema: e }, e?.id || `pgh-child-${t}`)) : null, T = Array.isArray(s) && s.length > 0 && s || Array.isArray(l?.actions) && l.actions.length > 0 && l.actions || Array.isArray(l?.properties?.actions) && l.properties.actions.length > 0 && l.properties.actions || null, E = a || f || (T ? /* @__PURE__ */ R(I, { schema: {
|
|
30
30
|
type: "record:quick_actions",
|
|
31
31
|
properties: {
|
|
32
32
|
actions: T,
|
|
@@ -35,39 +35,39 @@ function q({ title: e, subtitle: n, description: r, icon: i, action: a, actions:
|
|
|
35
35
|
inline: !0
|
|
36
36
|
}
|
|
37
37
|
} }) : null) || w;
|
|
38
|
-
return /* @__PURE__ */
|
|
38
|
+
return /* @__PURE__ */ R("div", {
|
|
39
39
|
className: A("flex flex-col gap-3 pb-4 border-b", u),
|
|
40
40
|
...p,
|
|
41
|
-
children: /* @__PURE__ */
|
|
41
|
+
children: /* @__PURE__ */ z("div", {
|
|
42
42
|
className: "flex flex-wrap items-center gap-x-4 gap-y-2",
|
|
43
43
|
children: [
|
|
44
|
-
S && /* @__PURE__ */
|
|
44
|
+
S && /* @__PURE__ */ R(o, {
|
|
45
45
|
type: "button",
|
|
46
46
|
variant: "ghost",
|
|
47
47
|
size: "icon",
|
|
48
48
|
onClick: C,
|
|
49
49
|
"aria-label": "Back to list",
|
|
50
50
|
className: "flex-shrink-0 -ml-2",
|
|
51
|
-
children: /* @__PURE__ */
|
|
51
|
+
children: /* @__PURE__ */ R(M, { className: "size-4" })
|
|
52
52
|
}),
|
|
53
|
-
i && (g || y) && /* @__PURE__ */
|
|
53
|
+
i && (g || y) && /* @__PURE__ */ R("div", {
|
|
54
54
|
className: "flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary",
|
|
55
|
-
children: typeof i == "string" ? /* @__PURE__ */
|
|
55
|
+
children: typeof i == "string" ? /* @__PURE__ */ R(d, {
|
|
56
56
|
name: i,
|
|
57
57
|
className: "size-5"
|
|
58
58
|
}) : i
|
|
59
59
|
}),
|
|
60
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ z("div", {
|
|
61
61
|
className: "flex flex-col min-w-0 flex-1",
|
|
62
|
-
children: [g ? /* @__PURE__ */
|
|
62
|
+
children: [g ? /* @__PURE__ */ R("h1", {
|
|
63
63
|
className: "text-2xl font-bold tracking-tight md:text-3xl truncate",
|
|
64
64
|
children: g
|
|
65
|
-
}) : null, y && /* @__PURE__ */
|
|
65
|
+
}) : null, y && /* @__PURE__ */ R("p", {
|
|
66
66
|
className: "text-sm text-muted-foreground truncate",
|
|
67
67
|
children: y
|
|
68
68
|
})]
|
|
69
69
|
}),
|
|
70
|
-
E && /* @__PURE__ */
|
|
70
|
+
E && /* @__PURE__ */ R("div", {
|
|
71
71
|
className: "flex items-center gap-2 ml-auto",
|
|
72
72
|
children: E
|
|
73
73
|
})
|
|
@@ -77,7 +77,7 @@ function q({ title: e, subtitle: n, description: r, icon: i, action: a, actions:
|
|
|
77
77
|
}
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region src/AppShell.tsx
|
|
80
|
-
function
|
|
80
|
+
function q(e) {
|
|
81
81
|
let t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
|
|
82
82
|
if (!t) return null;
|
|
83
83
|
let n = parseInt(t[1], 16) / 255, r = parseInt(t[2], 16) / 255, i = parseInt(t[3], 16) / 255, a = Math.max(n, r, i), o = Math.min(n, r, i), s = 0, c = 0, l = (a + o) / 2;
|
|
@@ -102,11 +102,11 @@ function ge(e) {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
function _e(e) {
|
|
105
|
-
let t =
|
|
105
|
+
let t = q(e);
|
|
106
106
|
return t ? `${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%` : null;
|
|
107
107
|
}
|
|
108
108
|
function ve(e) {
|
|
109
|
-
let t =
|
|
109
|
+
let t = q(e);
|
|
110
110
|
if (!t) return null;
|
|
111
111
|
let n = Math.max(t.l, 65), r = t.s > 80 ? Math.max(t.s - 10, 70) : t.s;
|
|
112
112
|
return `${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`;
|
|
@@ -157,17 +157,17 @@ function be(e, t) {
|
|
|
157
157
|
]);
|
|
158
158
|
}
|
|
159
159
|
function J({ sidebar: e, navbar: t, children: n, className: r, defaultOpen: i = !0, branding: a }) {
|
|
160
|
-
return be(a, a?.title), /* @__PURE__ */
|
|
160
|
+
return be(a, a?.title), /* @__PURE__ */ z(k, {
|
|
161
161
|
defaultOpen: i,
|
|
162
162
|
className: "!flex-col h-svh overflow-hidden",
|
|
163
|
-
children: [/* @__PURE__ */
|
|
163
|
+
children: [/* @__PURE__ */ R("header", {
|
|
164
164
|
className: "sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4",
|
|
165
165
|
children: t
|
|
166
|
-
}), /* @__PURE__ */
|
|
166
|
+
}), /* @__PURE__ */ z("div", {
|
|
167
167
|
className: "flex flex-1 min-h-0 w-full",
|
|
168
|
-
children: [e, /* @__PURE__ */
|
|
168
|
+
children: [e, /* @__PURE__ */ R(x, {
|
|
169
169
|
className: "min-w-0",
|
|
170
|
-
children: /* @__PURE__ */
|
|
170
|
+
children: /* @__PURE__ */ R("main", {
|
|
171
171
|
className: A("flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6", r),
|
|
172
172
|
children: n
|
|
173
173
|
})
|
|
@@ -178,10 +178,10 @@ function J({ sidebar: e, navbar: t, children: n, className: r, defaultOpen: i =
|
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region src/PageCard.tsx
|
|
180
180
|
function xe({ className: e, children: t, ...n }) {
|
|
181
|
-
return /* @__PURE__ */
|
|
181
|
+
return /* @__PURE__ */ R("div", {
|
|
182
182
|
className: A("rounded-xl border bg-card text-card-foreground shadow", e),
|
|
183
183
|
...n,
|
|
184
|
-
children: /* @__PURE__ */
|
|
184
|
+
children: /* @__PURE__ */ R("div", {
|
|
185
185
|
className: "p-6",
|
|
186
186
|
children: t
|
|
187
187
|
})
|
|
@@ -260,14 +260,14 @@ var we = {
|
|
|
260
260
|
5: "gap-5",
|
|
261
261
|
6: "gap-6",
|
|
262
262
|
8: "gap-8"
|
|
263
|
-
}, Te = ({ columns: e, gap: t = 4, className: n, children: r }) => /* @__PURE__ */
|
|
263
|
+
}, Te = ({ columns: e, gap: t = 4, className: n, children: r }) => /* @__PURE__ */ R("div", {
|
|
264
264
|
className: A("grid", Ce(e), typeof t == "number" ? we[t] || `gap-${t}` : "", n),
|
|
265
265
|
children: r
|
|
266
266
|
});
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region src/NavigationRenderer.tsx
|
|
269
269
|
function Y(e) {
|
|
270
|
-
return e ? j(e) :
|
|
270
|
+
return e ? j(e) : te;
|
|
271
271
|
}
|
|
272
272
|
function X(e, t) {
|
|
273
273
|
if (typeof e == "string") return e;
|
|
@@ -280,14 +280,14 @@ function X(e, t) {
|
|
|
280
280
|
}
|
|
281
281
|
return e.defaultValue || e.key;
|
|
282
282
|
}
|
|
283
|
-
function Ee(e, t, n, r, i, a) {
|
|
284
|
-
let
|
|
285
|
-
if (typeof e.label != "string") return
|
|
283
|
+
function Ee(e, t, n, r, i, a, o) {
|
|
284
|
+
let s = X(e.label, n);
|
|
285
|
+
if (typeof e.label != "string") return s;
|
|
286
286
|
if (e.type === "object" && e.objectName) {
|
|
287
|
-
if (e.viewName) return a ? a(e.objectName, e.viewName,
|
|
288
|
-
if (t) return t(e.objectName,
|
|
287
|
+
if (e.viewName) return a ? a(e.objectName, e.viewName, s) : s;
|
|
288
|
+
if (t) return t(e.objectName, s);
|
|
289
289
|
}
|
|
290
|
-
return r && e.type === "dashboard" && e.dashboardName ? r(e.dashboardName,
|
|
290
|
+
return r && e.type === "dashboard" && e.dashboardName ? r(e.dashboardName, s) : i && e.type === "group" && e.id ? i(e.id, s) : o && e.id ? o(e.id, s) : s;
|
|
291
291
|
}
|
|
292
292
|
var De = (e) => !(e === !1 || e === "false"), Oe = () => !0, ke = () => !0;
|
|
293
293
|
function Ae(e, t) {
|
|
@@ -315,6 +315,29 @@ function Ae(e, t) {
|
|
|
315
315
|
href: e.url ?? "#",
|
|
316
316
|
external: e.target === "_blank"
|
|
317
317
|
};
|
|
318
|
+
case "component": {
|
|
319
|
+
let n = e.componentRef;
|
|
320
|
+
if (!n) return {
|
|
321
|
+
href: "#",
|
|
322
|
+
external: !1
|
|
323
|
+
};
|
|
324
|
+
let r = n.split(":").filter(Boolean);
|
|
325
|
+
if (r.length === 0) return {
|
|
326
|
+
href: "#",
|
|
327
|
+
external: !1
|
|
328
|
+
};
|
|
329
|
+
let i = `${t}/component/${r.join("/")}`, a = e.params;
|
|
330
|
+
if (a && typeof a == "object") {
|
|
331
|
+
let e = new URLSearchParams();
|
|
332
|
+
for (let [t, n] of Object.entries(a)) n != null && e.set(t, typeof n == "string" ? n : JSON.stringify(n));
|
|
333
|
+
let t = e.toString();
|
|
334
|
+
t && (i += `?${t}`);
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
href: i,
|
|
338
|
+
external: !1
|
|
339
|
+
};
|
|
340
|
+
}
|
|
318
341
|
default: return {
|
|
319
342
|
href: "#",
|
|
320
343
|
external: !1
|
|
@@ -340,21 +363,21 @@ function Z(e, t) {
|
|
|
340
363
|
}, []);
|
|
341
364
|
}
|
|
342
365
|
var Me = 5;
|
|
343
|
-
function Ne({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, onAction: a, enablePinning: o, onPinToggle: s, enableReorder: c, resolveObjectLabel: l, resolveDashboardLabel: u, resolveGroupLabel: d, resolveViewLabel: f,
|
|
344
|
-
let { attributes:
|
|
366
|
+
function Ne({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, onAction: a, enablePinning: o, onPinToggle: s, enableReorder: c, resolveObjectLabel: l, resolveDashboardLabel: u, resolveGroupLabel: d, resolveViewLabel: f, resolveItemLabel: p, t: m }) {
|
|
367
|
+
let { attributes: h, listeners: g, setNodeRef: _, transform: v, transition: y, isDragging: b } = fe({
|
|
345
368
|
id: e.id,
|
|
346
369
|
disabled: !c
|
|
347
370
|
});
|
|
348
|
-
return /* @__PURE__ */
|
|
349
|
-
ref:
|
|
371
|
+
return /* @__PURE__ */ R("div", {
|
|
372
|
+
ref: _,
|
|
350
373
|
style: {
|
|
351
|
-
transform:
|
|
352
|
-
transition:
|
|
353
|
-
opacity:
|
|
354
|
-
zIndex:
|
|
374
|
+
transform: me.Transform.toString(v),
|
|
375
|
+
transition: y,
|
|
376
|
+
opacity: b ? .5 : void 0,
|
|
377
|
+
zIndex: b ? 10 : void 0
|
|
355
378
|
},
|
|
356
|
-
...
|
|
357
|
-
children: /* @__PURE__ */
|
|
379
|
+
...h,
|
|
380
|
+
children: /* @__PURE__ */ R(Q, {
|
|
358
381
|
item: e,
|
|
359
382
|
basePath: t,
|
|
360
383
|
evalVis: n,
|
|
@@ -363,21 +386,22 @@ function Ne({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, onAct
|
|
|
363
386
|
onAction: a,
|
|
364
387
|
enablePinning: o,
|
|
365
388
|
onPinToggle: s,
|
|
366
|
-
dragListeners: c ?
|
|
389
|
+
dragListeners: c ? g : void 0,
|
|
367
390
|
resolveObjectLabel: l,
|
|
368
391
|
resolveDashboardLabel: u,
|
|
369
392
|
resolveGroupLabel: d,
|
|
370
393
|
resolveViewLabel: f,
|
|
371
|
-
|
|
394
|
+
resolveItemLabel: p,
|
|
395
|
+
t: m
|
|
372
396
|
})
|
|
373
397
|
});
|
|
374
398
|
}
|
|
375
|
-
function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onAction: d, enablePinning: p, onPinToggle: m, dragListeners: h, resolveObjectLabel: y, resolveDashboardLabel: b, resolveGroupLabel: x, resolveViewLabel: E,
|
|
376
|
-
let
|
|
399
|
+
function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onAction: d, enablePinning: p, onPinToggle: m, dragListeners: h, resolveObjectLabel: y, resolveDashboardLabel: b, resolveGroupLabel: x, resolveViewLabel: E, resolveItemLabel: D, t: O }) {
|
|
400
|
+
let k = H(), A = (() => {
|
|
377
401
|
let t = e.expanded;
|
|
378
402
|
if (typeof t == "boolean") return t;
|
|
379
403
|
if (typeof e.defaultOpen == "boolean") return e.defaultOpen;
|
|
380
|
-
})(),
|
|
404
|
+
})(), j = e.type === "group" ? e.children?.length ?? 0 : 0, [M, te] = i(t.useMemo(() => {
|
|
381
405
|
if (e.type !== "group") return !1;
|
|
382
406
|
let t = (e) => {
|
|
383
407
|
if (!e) return !1;
|
|
@@ -387,7 +411,7 @@ function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onActi
|
|
|
387
411
|
continue;
|
|
388
412
|
}
|
|
389
413
|
let { href: e } = Ae(r, n);
|
|
390
|
-
if (je(r, e,
|
|
414
|
+
if (je(r, e, k.pathname)) return !0;
|
|
391
415
|
}
|
|
392
416
|
return !1;
|
|
393
417
|
};
|
|
@@ -395,24 +419,24 @@ function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onActi
|
|
|
395
419
|
}, [
|
|
396
420
|
e,
|
|
397
421
|
n,
|
|
398
|
-
|
|
399
|
-
]) ? !0 :
|
|
422
|
+
k.pathname
|
|
423
|
+
]) ? !0 : A ?? !(j >= 8));
|
|
400
424
|
if (!r(e.visible) || e.requiredPermissions?.length && !o(e.requiredPermissions)) return null;
|
|
401
|
-
let
|
|
402
|
-
if (
|
|
403
|
-
if (e.type === "separator") return /* @__PURE__ */
|
|
425
|
+
let N = e.requiresObject, F = e.requiresService;
|
|
426
|
+
if (N && !u("object", N) || F && !u("service", F)) return null;
|
|
427
|
+
if (e.type === "separator") return /* @__PURE__ */ R(f, { className: "my-2" });
|
|
404
428
|
if (e.type === "group") {
|
|
405
429
|
let t = (e.children ?? []).slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0));
|
|
406
|
-
return /* @__PURE__ */
|
|
407
|
-
open:
|
|
408
|
-
onOpenChange:
|
|
409
|
-
children: /* @__PURE__ */
|
|
430
|
+
return /* @__PURE__ */ R(s, {
|
|
431
|
+
open: M,
|
|
432
|
+
onOpenChange: te,
|
|
433
|
+
children: /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ R(v, {
|
|
410
434
|
asChild: !0,
|
|
411
|
-
children: /* @__PURE__ */
|
|
435
|
+
children: /* @__PURE__ */ z(l, {
|
|
412
436
|
className: "flex w-full items-center justify-between",
|
|
413
|
-
children: [Ee(e, y,
|
|
437
|
+
children: [Ee(e, y, O, b, x, E, D), /* @__PURE__ */ R(ee, { className: `ml-auto h-4 w-4 transition-transform ${M ? "rotate-90" : ""}` })]
|
|
414
438
|
})
|
|
415
|
-
}), /* @__PURE__ */
|
|
439
|
+
}), /* @__PURE__ */ R(c, { children: /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: t.map((e) => /* @__PURE__ */ R(Q, {
|
|
416
440
|
item: e,
|
|
417
441
|
basePath: n,
|
|
418
442
|
evalVis: r,
|
|
@@ -425,94 +449,95 @@ function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onActi
|
|
|
425
449
|
resolveDashboardLabel: b,
|
|
426
450
|
resolveGroupLabel: x,
|
|
427
451
|
resolveViewLabel: E,
|
|
428
|
-
|
|
452
|
+
resolveItemLabel: D,
|
|
453
|
+
t: O
|
|
429
454
|
}, e.id)) }) }) })] })
|
|
430
455
|
});
|
|
431
456
|
}
|
|
432
457
|
if (e.type === "action") {
|
|
433
|
-
let t = Y(e.icon),
|
|
434
|
-
return /* @__PURE__ */
|
|
435
|
-
h && /* @__PURE__ */
|
|
458
|
+
let t = Y(e.icon), r = X(e.label, O);
|
|
459
|
+
return /* @__PURE__ */ z(T, { children: [
|
|
460
|
+
h && /* @__PURE__ */ R("span", {
|
|
436
461
|
className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
|
|
437
|
-
"aria-label":
|
|
462
|
+
"aria-label": O ? O("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
|
|
438
463
|
...h,
|
|
439
|
-
children: /* @__PURE__ */
|
|
464
|
+
children: /* @__PURE__ */ R(ne, { className: "h-3.5 w-3.5" })
|
|
440
465
|
}),
|
|
441
|
-
/* @__PURE__ */
|
|
442
|
-
tooltip:
|
|
466
|
+
/* @__PURE__ */ z(w, {
|
|
467
|
+
tooltip: r,
|
|
443
468
|
onClick: () => d?.(e),
|
|
444
469
|
children: [
|
|
445
|
-
/* @__PURE__ */
|
|
446
|
-
/* @__PURE__ */
|
|
447
|
-
e.badge != null && /* @__PURE__ */
|
|
470
|
+
/* @__PURE__ */ R(t, { className: "h-4 w-4" }),
|
|
471
|
+
/* @__PURE__ */ R("span", { children: r }),
|
|
472
|
+
e.badge != null && /* @__PURE__ */ R(a, {
|
|
448
473
|
variant: e.badgeVariant ?? "default",
|
|
449
474
|
className: "ml-auto text-[10px] px-1.5 py-0",
|
|
450
475
|
children: e.badge
|
|
451
476
|
})
|
|
452
477
|
]
|
|
453
478
|
}),
|
|
454
|
-
p && m && /* @__PURE__ */
|
|
479
|
+
p && m && /* @__PURE__ */ R(C, {
|
|
455
480
|
showOnHover: !0,
|
|
456
|
-
onClick: () => m(e.id, !e.pinned),
|
|
457
|
-
"aria-label":
|
|
458
|
-
defaultValue: e.pinned ? `Unpin ${
|
|
459
|
-
name:
|
|
460
|
-
}) : e.pinned ? `Unpin ${
|
|
461
|
-
children: e.pinned ? /* @__PURE__ */
|
|
481
|
+
onClick: () => m(e.id, !e.pinned, e, n),
|
|
482
|
+
"aria-label": O ? O(e.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
|
|
483
|
+
defaultValue: e.pinned ? `Unpin ${r}` : `Pin ${r}`,
|
|
484
|
+
name: r
|
|
485
|
+
}) : e.pinned ? `Unpin ${r}` : `Pin ${r}`,
|
|
486
|
+
children: e.pinned ? /* @__PURE__ */ R(P, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ R(re, { className: "h-3.5 w-3.5" })
|
|
462
487
|
})
|
|
463
488
|
] });
|
|
464
489
|
}
|
|
465
|
-
let
|
|
466
|
-
/* @__PURE__ */
|
|
467
|
-
/* @__PURE__ */
|
|
468
|
-
e.badge != null && /* @__PURE__ */
|
|
490
|
+
let ie = Y(e.icon), { href: I, external: ae } = Ae(e, n), V = je(e, I, k.pathname), U = Ee(e, y, O, b, x, E, D), W = /* @__PURE__ */ z(L, { children: [
|
|
491
|
+
/* @__PURE__ */ R(ie, { className: "h-4 w-4" }),
|
|
492
|
+
/* @__PURE__ */ R("span", { children: U }),
|
|
493
|
+
e.badge != null && /* @__PURE__ */ R(a, {
|
|
469
494
|
variant: e.badgeVariant ?? "default",
|
|
470
495
|
className: "ml-auto text-[10px] px-1.5 py-0",
|
|
471
496
|
children: e.badge
|
|
472
497
|
})
|
|
473
498
|
] });
|
|
474
|
-
return /* @__PURE__ */
|
|
475
|
-
h && /* @__PURE__ */
|
|
499
|
+
return /* @__PURE__ */ z(T, { children: [
|
|
500
|
+
h && /* @__PURE__ */ R("span", {
|
|
476
501
|
className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
|
|
477
|
-
"aria-label":
|
|
502
|
+
"aria-label": O ? O("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
|
|
478
503
|
...h,
|
|
479
|
-
children: /* @__PURE__ */
|
|
504
|
+
children: /* @__PURE__ */ R(ne, { className: "h-3.5 w-3.5" })
|
|
480
505
|
}),
|
|
481
|
-
/* @__PURE__ */
|
|
506
|
+
/* @__PURE__ */ R(w, {
|
|
482
507
|
asChild: !0,
|
|
483
|
-
isActive:
|
|
508
|
+
isActive: V,
|
|
484
509
|
tooltip: U,
|
|
485
|
-
children:
|
|
486
|
-
href:
|
|
510
|
+
children: ae ? /* @__PURE__ */ R("a", {
|
|
511
|
+
href: I,
|
|
487
512
|
target: "_blank",
|
|
488
513
|
rel: "noopener noreferrer",
|
|
489
|
-
children:
|
|
490
|
-
}) : /* @__PURE__ */ B
|
|
491
|
-
to:
|
|
492
|
-
children:
|
|
514
|
+
children: W
|
|
515
|
+
}) : /* @__PURE__ */ R(B, {
|
|
516
|
+
to: I,
|
|
517
|
+
children: W
|
|
493
518
|
})
|
|
494
519
|
}),
|
|
495
|
-
p && m && /* @__PURE__ */
|
|
520
|
+
p && m && /* @__PURE__ */ R(C, {
|
|
496
521
|
showOnHover: !0,
|
|
497
|
-
onClick: () => m(e.id, !e.pinned),
|
|
498
|
-
"aria-label":
|
|
522
|
+
onClick: () => m(e.id, !e.pinned, e, n),
|
|
523
|
+
"aria-label": O ? O(e.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
|
|
499
524
|
defaultValue: e.pinned ? `Unpin ${U}` : `Pin ${U}`,
|
|
500
525
|
name: U
|
|
501
526
|
}) : e.pinned ? `Unpin ${U}` : `Pin ${U}`,
|
|
502
|
-
children: e.pinned ? /* @__PURE__ */
|
|
527
|
+
children: e.pinned ? /* @__PURE__ */ R(P, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ R(re, { className: "h-3.5 w-3.5" })
|
|
503
528
|
})
|
|
504
529
|
] });
|
|
505
530
|
}
|
|
506
|
-
function $({ items: e, basePath: t = "", evaluateVisibility: n = De, checkPermission: i = Oe, checkCapability: a = ke, onAction: o, searchQuery: s, enablePinning: c, onPinToggle: l, enableReorder: u, onReorder: d, resolveObjectLabel: f, resolveDashboardLabel: p, resolveGroupLabel: m, resolveViewLabel: h,
|
|
507
|
-
let
|
|
531
|
+
function $({ items: e, basePath: t = "", evaluateVisibility: n = De, checkPermission: i = Oe, checkCapability: a = ke, onAction: o, searchQuery: s, enablePinning: c, onPinToggle: l, enableReorder: u, onReorder: d, resolveObjectLabel: f, resolveDashboardLabel: p, resolveGroupLabel: m, resolveViewLabel: h, resolveItemLabel: y, t: b }) {
|
|
532
|
+
let x = r(() => s ? Z(e, s) : e, [e, s]), C = r(() => Pe(x), [x]), w = x.slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), T = le(ce(oe, { activationConstraint: { distance: Me } }), ce(W)), E = (e) => {
|
|
508
533
|
let { active: t, over: n } = e;
|
|
509
534
|
if (!n || t.id === n.id || !d) return;
|
|
510
|
-
let r =
|
|
511
|
-
r === -1 || i === -1 || d(
|
|
535
|
+
let r = w.findIndex((e) => e.id === t.id), i = w.findIndex((e) => e.id === n.id);
|
|
536
|
+
r === -1 || i === -1 || d(de(w, r, i).map((e, t) => ({
|
|
512
537
|
...e,
|
|
513
538
|
order: t
|
|
514
539
|
})));
|
|
515
|
-
},
|
|
540
|
+
}, D = {
|
|
516
541
|
basePath: t,
|
|
517
542
|
evalVis: n,
|
|
518
543
|
checkPerm: i,
|
|
@@ -524,48 +549,49 @@ function $({ items: e, basePath: t = "", evaluateVisibility: n = De, checkPermis
|
|
|
524
549
|
resolveDashboardLabel: p,
|
|
525
550
|
resolveGroupLabel: m,
|
|
526
551
|
resolveViewLabel: h,
|
|
527
|
-
|
|
528
|
-
|
|
552
|
+
resolveItemLabel: y,
|
|
553
|
+
t: b
|
|
554
|
+
}, O = w.some((e) => e.type === "group"), k = C.length > 0 && c ? /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ z(v, {
|
|
529
555
|
className: "flex items-center gap-1.5",
|
|
530
|
-
children: [/* @__PURE__ */
|
|
531
|
-
}), /* @__PURE__ */
|
|
556
|
+
children: [/* @__PURE__ */ R(ie, { className: "h-3.5 w-3.5" }), b ? b("console.nav.favorites", { defaultValue: "Favorites" }) : "Favorites"]
|
|
557
|
+
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: C.map((e) => /* @__PURE__ */ R(Q, {
|
|
532
558
|
item: e,
|
|
533
|
-
...
|
|
559
|
+
...D
|
|
534
560
|
}, `fav-${e.id}`)) }) })] }) : null;
|
|
535
|
-
if (!
|
|
536
|
-
let e =
|
|
537
|
-
return /* @__PURE__ */
|
|
538
|
-
sensors:
|
|
539
|
-
collisionDetection:
|
|
540
|
-
onDragEnd:
|
|
541
|
-
children: /* @__PURE__ */
|
|
561
|
+
if (!O) {
|
|
562
|
+
let e = w.filter((e) => e.type !== "group").map((e) => e.id);
|
|
563
|
+
return /* @__PURE__ */ z(L, { children: [k, /* @__PURE__ */ R(g, { children: /* @__PURE__ */ R(_, { children: u ? /* @__PURE__ */ R(U, {
|
|
564
|
+
sensors: T,
|
|
565
|
+
collisionDetection: se,
|
|
566
|
+
onDragEnd: E,
|
|
567
|
+
children: /* @__PURE__ */ R(ue, {
|
|
542
568
|
items: e,
|
|
543
|
-
strategy:
|
|
544
|
-
children: /* @__PURE__ */
|
|
569
|
+
strategy: pe,
|
|
570
|
+
children: /* @__PURE__ */ R(S, { children: w.map((e) => /* @__PURE__ */ R(Ne, {
|
|
545
571
|
item: e,
|
|
546
572
|
enableReorder: u,
|
|
547
|
-
...
|
|
573
|
+
...D
|
|
548
574
|
}, e.id)) })
|
|
549
575
|
})
|
|
550
|
-
}) : /* @__PURE__ */
|
|
576
|
+
}) : /* @__PURE__ */ R(S, { children: w.map((e) => /* @__PURE__ */ R(Q, {
|
|
551
577
|
item: e,
|
|
552
|
-
...
|
|
578
|
+
...D
|
|
553
579
|
}, e.id)) }) }) })] });
|
|
554
580
|
}
|
|
555
|
-
let
|
|
556
|
-
if (
|
|
557
|
-
let t =
|
|
558
|
-
|
|
581
|
+
let A = [], j = [], M = (e) => {
|
|
582
|
+
if (j.length === 0) return;
|
|
583
|
+
let t = j;
|
|
584
|
+
j = [], A.push(/* @__PURE__ */ R(g, { children: /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: t.map((e) => /* @__PURE__ */ R(Q, {
|
|
559
585
|
item: e,
|
|
560
|
-
...
|
|
586
|
+
...D
|
|
561
587
|
}, e.id)) }) }) }, e));
|
|
562
588
|
};
|
|
563
|
-
return
|
|
564
|
-
e.type === "group" ? (
|
|
589
|
+
return w.forEach((e, t) => {
|
|
590
|
+
e.type === "group" ? (M(`leaf-${t}`), A.push(/* @__PURE__ */ R(Q, {
|
|
565
591
|
item: e,
|
|
566
|
-
...
|
|
567
|
-
}, e.id))) :
|
|
568
|
-
}),
|
|
592
|
+
...D
|
|
593
|
+
}, e.id))) : j.push(e);
|
|
594
|
+
}), M("leaf-end"), /* @__PURE__ */ z(L, { children: [k, A] });
|
|
569
595
|
}
|
|
570
596
|
function Pe(e) {
|
|
571
597
|
let t = [];
|
|
@@ -576,37 +602,54 @@ function Pe(e) {
|
|
|
576
602
|
//#region src/AppSchemaRenderer.tsx
|
|
577
603
|
function Fe({ areas: e, activeAreaId: t, onAreaChange: n, evalVis: r, checkPerm: i }) {
|
|
578
604
|
let a = e.filter((e) => !(!r(e.visible) || e.requiredPermissions?.length && !i(e.requiredPermissions)));
|
|
579
|
-
return a.length <= 1 ? null : /* @__PURE__ */
|
|
605
|
+
return a.length <= 1 ? null : /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ z(v, {
|
|
580
606
|
className: "flex items-center gap-1.5",
|
|
581
|
-
children: [/* @__PURE__ */
|
|
582
|
-
}), /* @__PURE__ */
|
|
607
|
+
children: [/* @__PURE__ */ R(N, { className: "h-3.5 w-3.5" }), "Area"]
|
|
608
|
+
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: a.map((e) => {
|
|
583
609
|
let r = Y(e.icon);
|
|
584
|
-
return /* @__PURE__ */
|
|
610
|
+
return /* @__PURE__ */ R(T, { children: /* @__PURE__ */ z(w, {
|
|
585
611
|
isActive: e.id === t,
|
|
586
612
|
tooltip: X(e.label),
|
|
587
613
|
onClick: () => n(e.id),
|
|
588
|
-
children: [/* @__PURE__ */
|
|
614
|
+
children: [/* @__PURE__ */ R(r, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", { children: X(e.label) })]
|
|
589
615
|
}) }, e.id);
|
|
590
616
|
}) }) })] });
|
|
591
617
|
}
|
|
592
618
|
function Ie({ items: e, basePath: t }) {
|
|
593
|
-
let n =
|
|
619
|
+
let n = H(), r = (e) => {
|
|
594
620
|
let t = [];
|
|
595
621
|
for (let n of e) n.type !== "separator" && (n.type === "group" ? t.push(...r(n.children || [])) : t.push(n));
|
|
596
622
|
return t;
|
|
597
623
|
}, i = r(e).slice(0, 5);
|
|
598
|
-
return i.length === 0 ? null : /* @__PURE__ */
|
|
624
|
+
return i.length === 0 ? null : /* @__PURE__ */ R("div", {
|
|
599
625
|
className: "fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom",
|
|
600
626
|
role: "navigation",
|
|
601
627
|
"aria-label": "Mobile navigation",
|
|
602
628
|
children: i.map((e) => {
|
|
603
629
|
let r = Y(e.icon), i = "#";
|
|
604
|
-
e.type === "object"
|
|
630
|
+
if (e.type === "object") i = `${t}/${e.objectName}`, e.viewName && (i += `/view/${e.viewName}`);
|
|
631
|
+
else if (e.type === "dashboard") i = e.dashboardName ? `${t}/dashboard/${e.dashboardName}` : "#";
|
|
632
|
+
else if (e.type === "page") i = e.pageName ? `${t}/page/${e.pageName}` : "#";
|
|
633
|
+
else if (e.type === "report") i = e.reportName ? `${t}/report/${e.reportName}` : "#";
|
|
634
|
+
else if (e.type === "url") i = e.url ?? "#";
|
|
635
|
+
else if (e.type === "component") {
|
|
636
|
+
let n = e.componentRef;
|
|
637
|
+
if (n) {
|
|
638
|
+
i = `${t}/component/${n.split(":").filter(Boolean).join("/")}`;
|
|
639
|
+
let r = e.params;
|
|
640
|
+
if (r) {
|
|
641
|
+
let e = new URLSearchParams();
|
|
642
|
+
for (let [t, n] of Object.entries(r)) n != null && e.set(t, typeof n == "string" ? n : JSON.stringify(n));
|
|
643
|
+
let t = e.toString();
|
|
644
|
+
t && (i += `?${t}`);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
605
648
|
let a = i !== "#" && n.pathname.startsWith(i);
|
|
606
|
-
return /* @__PURE__ */
|
|
649
|
+
return /* @__PURE__ */ z(B, {
|
|
607
650
|
to: i,
|
|
608
651
|
className: `flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a ? "text-primary" : "text-muted-foreground hover:text-foreground"}`,
|
|
609
|
-
children: [/* @__PURE__ */
|
|
652
|
+
children: [/* @__PURE__ */ R(r, { className: "h-5 w-5" }), /* @__PURE__ */ R("span", {
|
|
610
653
|
className: "text-[10px] truncate max-w-[60px]",
|
|
611
654
|
children: X(e.label)
|
|
612
655
|
})]
|
|
@@ -616,44 +659,44 @@ function Ie({ items: e, basePath: t }) {
|
|
|
616
659
|
}
|
|
617
660
|
function Le({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onAction: o, sidebarHeader: s, sidebarFooter: c, sidebarExtra: l, activeAreaId: u, setActiveAreaId: d, resolvedNavigation: f, enableSearch: g, enablePinning: _, onPinToggle: v, enableReorder: x, onReorder: C }) {
|
|
618
661
|
let E = Y(e.logo), D = e.areas ?? [], [O, k] = i("");
|
|
619
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ z(p, {
|
|
620
663
|
collapsible: "icon",
|
|
621
664
|
children: [
|
|
622
|
-
/* @__PURE__ */
|
|
665
|
+
/* @__PURE__ */ z(y, { children: [s ?? /* @__PURE__ */ R(S, { children: /* @__PURE__ */ R(T, { children: /* @__PURE__ */ z(w, {
|
|
623
666
|
size: "lg",
|
|
624
667
|
tooltip: e.title ?? e.name,
|
|
625
|
-
children: [/* @__PURE__ */
|
|
668
|
+
children: [/* @__PURE__ */ R("div", {
|
|
626
669
|
className: "flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground",
|
|
627
|
-
children: e.logo && e.logo.startsWith("http") ? /* @__PURE__ */
|
|
670
|
+
children: e.logo && e.logo.startsWith("http") ? /* @__PURE__ */ R("img", {
|
|
628
671
|
src: e.logo,
|
|
629
672
|
alt: e.title ?? "",
|
|
630
673
|
className: "size-6 object-contain"
|
|
631
|
-
}) : /* @__PURE__ */
|
|
632
|
-
}), /* @__PURE__ */
|
|
674
|
+
}) : /* @__PURE__ */ R(E, { className: "size-4" })
|
|
675
|
+
}), /* @__PURE__ */ z("div", {
|
|
633
676
|
className: "grid flex-1 text-left text-sm leading-tight",
|
|
634
|
-
children: [/* @__PURE__ */
|
|
677
|
+
children: [/* @__PURE__ */ R("span", {
|
|
635
678
|
className: "truncate font-semibold",
|
|
636
679
|
children: e.title ?? e.name ?? "App"
|
|
637
|
-
}), e.description && /* @__PURE__ */
|
|
680
|
+
}), e.description && /* @__PURE__ */ R("span", {
|
|
638
681
|
className: "truncate text-xs text-muted-foreground",
|
|
639
682
|
children: e.description
|
|
640
683
|
})]
|
|
641
684
|
})]
|
|
642
|
-
}) }) }), g && /* @__PURE__ */
|
|
685
|
+
}) }) }), g && /* @__PURE__ */ R(b, {
|
|
643
686
|
placeholder: "Search navigation…",
|
|
644
687
|
value: O,
|
|
645
688
|
onChange: (e) => k(e.target.value),
|
|
646
689
|
"aria-label": "Search navigation"
|
|
647
690
|
})] }),
|
|
648
|
-
/* @__PURE__ */
|
|
649
|
-
D.length > 1 && u && /* @__PURE__ */
|
|
691
|
+
/* @__PURE__ */ z(m, { children: [
|
|
692
|
+
D.length > 1 && u && /* @__PURE__ */ R(Fe, {
|
|
650
693
|
areas: D,
|
|
651
694
|
activeAreaId: u,
|
|
652
695
|
onAreaChange: d,
|
|
653
696
|
evalVis: n,
|
|
654
697
|
checkPerm: r
|
|
655
698
|
}),
|
|
656
|
-
/* @__PURE__ */
|
|
699
|
+
/* @__PURE__ */ R($, {
|
|
657
700
|
items: f,
|
|
658
701
|
basePath: t,
|
|
659
702
|
evaluateVisibility: n,
|
|
@@ -668,12 +711,12 @@ function Le({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onA
|
|
|
668
711
|
}),
|
|
669
712
|
l
|
|
670
713
|
] }),
|
|
671
|
-
c && /* @__PURE__ */
|
|
714
|
+
c && /* @__PURE__ */ R(h, { children: c })
|
|
672
715
|
]
|
|
673
716
|
});
|
|
674
717
|
}
|
|
675
718
|
function Re({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluateVisibility: o, checkPermission: s, checkCapability: c, onAction: l, navbar: u, sidebarHeader: d, sidebarFooter: f, sidebarExtra: p, children: m, className: h, defaultOpen: g = !0, enableSearch: _, enablePinning: v, onPinToggle: y, enableReorder: b, onReorder: x }) {
|
|
676
|
-
let S = o ?? ((e) => !(e === !1 || e === "false")), C = s ?? (() => !0), w = c ?? (() => !0), T = r(() => (e.menu ?? []).map((e, t) =>
|
|
719
|
+
let S = o ?? ((e) => !(e === !1 || e === "false")), C = s ?? (() => !0), w = c ?? (() => !0), T = r(() => (e.menu ?? []).map((e, t) => he(e, t)), [e.menu]), E = e.navigation ?? T, D = e.areas ?? [], [O, k] = i(() => D.length > 0 ? D[0].id : null), A = D.map((e) => e.id).join(",");
|
|
677
720
|
n(() => {
|
|
678
721
|
D.length > 0 ? k((e) => D.some((t) => t.id === e) ? e : D[0].id) : k(null);
|
|
679
722
|
}, [e.name, A]);
|
|
@@ -682,8 +725,8 @@ function Re({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluate
|
|
|
682
725
|
favicon: e.favicon,
|
|
683
726
|
logo: e.logo
|
|
684
727
|
};
|
|
685
|
-
return /* @__PURE__ */
|
|
686
|
-
sidebar: /* @__PURE__ */
|
|
728
|
+
return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(J, {
|
|
729
|
+
sidebar: /* @__PURE__ */ R(Le, {
|
|
687
730
|
schema: e,
|
|
688
731
|
basePath: t,
|
|
689
732
|
evalVis: S,
|
|
@@ -707,7 +750,7 @@ function Re({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluate
|
|
|
707
750
|
defaultOpen: g,
|
|
708
751
|
branding: M,
|
|
709
752
|
children: m
|
|
710
|
-
}), a === "bottom_nav" && /* @__PURE__ */
|
|
753
|
+
}), a === "bottom_nav" && /* @__PURE__ */ R(Ie, {
|
|
711
754
|
items: j,
|
|
712
755
|
basePath: t
|
|
713
756
|
})] });
|
|
@@ -717,16 +760,16 @@ function Re({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluate
|
|
|
717
760
|
var ze = (e) => e ? Array.isArray(e) ? e : [e] : [];
|
|
718
761
|
function Be({ schema: e, className: t, style: n, id: r, ...i }) {
|
|
719
762
|
let a = ze(e.children);
|
|
720
|
-
return /* @__PURE__ */
|
|
763
|
+
return /* @__PURE__ */ z("div", {
|
|
721
764
|
id: r || e.id,
|
|
722
765
|
className: A("flex flex-col h-full space-y-4", t),
|
|
723
766
|
style: n,
|
|
724
|
-
children: [/* @__PURE__ */
|
|
767
|
+
children: [/* @__PURE__ */ R(K, {
|
|
725
768
|
title: e.title,
|
|
726
769
|
description: e.description
|
|
727
|
-
}), /* @__PURE__ */
|
|
770
|
+
}), /* @__PURE__ */ R("div", {
|
|
728
771
|
className: "flex-1 overflow-auto",
|
|
729
|
-
children: a.map((e, t) => /* @__PURE__ */
|
|
772
|
+
children: a.map((e, t) => /* @__PURE__ */ R(I, {
|
|
730
773
|
schema: e,
|
|
731
774
|
...i
|
|
732
775
|
}, e?.id || t))
|
|
@@ -739,38 +782,38 @@ function Ve(e) {
|
|
|
739
782
|
return "items" in e && !("href" in e);
|
|
740
783
|
}
|
|
741
784
|
function He({ item: e, pathname: t }) {
|
|
742
|
-
return e.children && e.children.length > 0 ? /* @__PURE__ */
|
|
785
|
+
return e.children && e.children.length > 0 ? /* @__PURE__ */ R(s, {
|
|
743
786
|
asChild: !0,
|
|
744
787
|
defaultOpen: !0,
|
|
745
788
|
className: "group/collapsible",
|
|
746
|
-
children: /* @__PURE__ */
|
|
789
|
+
children: /* @__PURE__ */ z(T, { children: [/* @__PURE__ */ R(l, {
|
|
747
790
|
asChild: !0,
|
|
748
|
-
children: /* @__PURE__ */
|
|
791
|
+
children: /* @__PURE__ */ z(w, {
|
|
749
792
|
tooltip: e.title,
|
|
750
793
|
className: "motion-safe:transition-colors motion-safe:duration-150",
|
|
751
794
|
children: [
|
|
752
|
-
e.icon && /* @__PURE__ */
|
|
753
|
-
/* @__PURE__ */
|
|
754
|
-
e.badge != null && /* @__PURE__ */
|
|
795
|
+
e.icon && /* @__PURE__ */ R(e.icon, {}),
|
|
796
|
+
/* @__PURE__ */ R("span", { children: e.title }),
|
|
797
|
+
e.badge != null && /* @__PURE__ */ R(a, {
|
|
755
798
|
variant: e.badgeVariant || "default",
|
|
756
799
|
className: "ml-auto mr-1 h-5 min-w-5 px-1 text-xs",
|
|
757
800
|
children: e.badge
|
|
758
801
|
}),
|
|
759
|
-
/* @__PURE__ */
|
|
802
|
+
/* @__PURE__ */ R(ee, { className: "ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
|
|
760
803
|
]
|
|
761
804
|
})
|
|
762
|
-
}), /* @__PURE__ */
|
|
805
|
+
}), /* @__PURE__ */ R(c, {
|
|
763
806
|
className: "motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150",
|
|
764
|
-
children: /* @__PURE__ */
|
|
807
|
+
children: /* @__PURE__ */ R(E, { children: e.children.map((e) => /* @__PURE__ */ R(O, { children: /* @__PURE__ */ R(D, {
|
|
765
808
|
asChild: !0,
|
|
766
809
|
isActive: t === e.href,
|
|
767
810
|
className: "motion-safe:transition-colors motion-safe:duration-150",
|
|
768
|
-
children: /* @__PURE__ */ V
|
|
811
|
+
children: /* @__PURE__ */ z(V, {
|
|
769
812
|
to: e.href,
|
|
770
813
|
children: [
|
|
771
|
-
e.icon && /* @__PURE__ */
|
|
772
|
-
/* @__PURE__ */
|
|
773
|
-
e.badge != null && /* @__PURE__ */
|
|
814
|
+
e.icon && /* @__PURE__ */ R(e.icon, {}),
|
|
815
|
+
/* @__PURE__ */ R("span", { children: e.title }),
|
|
816
|
+
e.badge != null && /* @__PURE__ */ R(a, {
|
|
774
817
|
variant: e.badgeVariant || "default",
|
|
775
818
|
className: "ml-auto h-5 min-w-5 px-1 text-xs",
|
|
776
819
|
children: e.badge
|
|
@@ -779,17 +822,17 @@ function He({ item: e, pathname: t }) {
|
|
|
779
822
|
})
|
|
780
823
|
}) }, e.href)) })
|
|
781
824
|
})] })
|
|
782
|
-
}) : /* @__PURE__ */
|
|
825
|
+
}) : /* @__PURE__ */ R(T, { children: /* @__PURE__ */ R(w, {
|
|
783
826
|
asChild: !0,
|
|
784
827
|
isActive: t === e.href,
|
|
785
828
|
tooltip: e.title,
|
|
786
829
|
className: "motion-safe:transition-colors motion-safe:duration-150",
|
|
787
|
-
children: /* @__PURE__ */ V
|
|
830
|
+
children: /* @__PURE__ */ z(V, {
|
|
788
831
|
to: e.href,
|
|
789
832
|
children: [
|
|
790
|
-
e.icon && /* @__PURE__ */
|
|
791
|
-
/* @__PURE__ */
|
|
792
|
-
e.badge != null && /* @__PURE__ */
|
|
833
|
+
e.icon && /* @__PURE__ */ R(e.icon, {}),
|
|
834
|
+
/* @__PURE__ */ R("span", { children: e.title }),
|
|
835
|
+
e.badge != null && /* @__PURE__ */ R(a, {
|
|
793
836
|
variant: e.badgeVariant || "default",
|
|
794
837
|
className: "ml-auto h-5 min-w-5 px-1 text-xs",
|
|
795
838
|
children: e.badge
|
|
@@ -799,7 +842,7 @@ function He({ item: e, pathname: t }) {
|
|
|
799
842
|
}) });
|
|
800
843
|
}
|
|
801
844
|
function Ue({ items: e, title: n = "Application", className: r, collapsible: i = "icon", searchEnabled: a = !1, searchPlaceholder: o = "Search…" }) {
|
|
802
|
-
let s =
|
|
845
|
+
let s = H(), [c, l] = t.useState(""), d = t.useMemo(() => e.length === 0 ? [] : Ve(e[0]) ? e.map((e) => ({
|
|
803
846
|
groupLabel: e.label,
|
|
804
847
|
items: e.items
|
|
805
848
|
})) : [{ items: e }], [e]), f = t.useMemo(() => {
|
|
@@ -810,14 +853,14 @@ function Ue({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
810
853
|
items: t.items.filter((t) => t.title.toLowerCase().includes(e) || t.children?.some((t) => t.title.toLowerCase().includes(e)))
|
|
811
854
|
})).filter((e) => e.items.length > 0);
|
|
812
855
|
}, [d, c]);
|
|
813
|
-
return /* @__PURE__ */
|
|
856
|
+
return /* @__PURE__ */ R(p, {
|
|
814
857
|
className: r,
|
|
815
858
|
collapsible: i,
|
|
816
|
-
children: /* @__PURE__ */
|
|
859
|
+
children: /* @__PURE__ */ z(m, { children: [a && /* @__PURE__ */ R("div", {
|
|
817
860
|
className: "px-3 py-2",
|
|
818
|
-
children: /* @__PURE__ */
|
|
861
|
+
children: /* @__PURE__ */ z("div", {
|
|
819
862
|
className: "relative",
|
|
820
|
-
children: [/* @__PURE__ */
|
|
863
|
+
children: [/* @__PURE__ */ R(F, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" }), /* @__PURE__ */ R(u, {
|
|
821
864
|
type: "search",
|
|
822
865
|
placeholder: o,
|
|
823
866
|
value: c,
|
|
@@ -825,16 +868,16 @@ function Ue({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
825
868
|
className: "pl-8 h-9"
|
|
826
869
|
})]
|
|
827
870
|
})
|
|
828
|
-
}), f.map((e, t) => /* @__PURE__ */
|
|
829
|
-
t > 0 && /* @__PURE__ */
|
|
871
|
+
}), f.map((e, t) => /* @__PURE__ */ z(g, { children: [
|
|
872
|
+
t > 0 && /* @__PURE__ */ R("div", {
|
|
830
873
|
className: "mx-3 mb-1 h-px bg-sidebar-border/60",
|
|
831
874
|
"aria-hidden": !0
|
|
832
875
|
}),
|
|
833
|
-
/* @__PURE__ */
|
|
876
|
+
/* @__PURE__ */ R(v, {
|
|
834
877
|
className: "text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60",
|
|
835
878
|
children: e.groupLabel || n
|
|
836
879
|
}),
|
|
837
|
-
/* @__PURE__ */
|
|
880
|
+
/* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: e.items.map((e) => /* @__PURE__ */ R(He, {
|
|
838
881
|
item: e,
|
|
839
882
|
pathname: s.pathname
|
|
840
883
|
}, e.href)) }) })
|
|
@@ -844,7 +887,7 @@ function Ue({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
844
887
|
//#endregion
|
|
845
888
|
//#region src/index.ts
|
|
846
889
|
function We() {
|
|
847
|
-
e.register("page-header",
|
|
890
|
+
e.register("page-header", K, {
|
|
848
891
|
namespace: "layout",
|
|
849
892
|
label: "Page Header",
|
|
850
893
|
category: "Layout",
|
|
@@ -912,4 +955,4 @@ try {
|
|
|
912
955
|
We();
|
|
913
956
|
} catch {}
|
|
914
957
|
//#endregion
|
|
915
|
-
export { Re as AppSchemaRenderer, J as AppShell, $ as NavigationRenderer, Be as Page, xe as PageCard,
|
|
958
|
+
export { Re as AppSchemaRenderer, J as AppShell, $ as NavigationRenderer, Be as Page, xe as PageCard, K as PageHeader, Te as ResponsiveGrid, Ue as SidebarNav, Z as filterNavigationItems, We as registerLayout, Y as resolveIcon, X as resolveLabel, be as useAppShellBranding };
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("lucide-react"),require("@object-ui/react"),require("react/jsx-runtime"),require("react-router-dom"),require("@dnd-kit/core"),require("@dnd-kit/sortable"),require("@dnd-kit/utilities"),require("@object-ui/types")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`react/jsx-runtime`,`react-router-dom`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUILayout={},e._object_ui_core,e.react,e._object_ui_components,e.lucide_react,e._object_ui_react,e.react_jsx_runtime,e.react_router_dom,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e._object_ui_types))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var y=e=>{let t=e?.name??e?.full_name??e?.display_name??e?.label??e?.title??e?.subject;return t!=null&&String(t).trim()?String(t):[e?.salutation,e?.first_name,e?.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e?.email==`string`&&e.email.trim()?e.email.trim():null)},b=(e,t)=>!e||typeof e!=`string`?e??``:e.includes(`{`)?e.replace(/\{([a-zA-Z0-9_.]+)\}/g,(e,n)=>{let r=n.split(`.`).reduce((e,t)=>e==null?e:e[t],t);return r==null?``:typeof r==`object`?y(r)??``:String(r)}).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g,``).replace(/^\s*[-–—|/·,:]\s*/,``).replace(/\s+/g,` `).trim():e;function x({title:e,subtitle:t,description:s,icon:c,action:l,actions:u,showBack:d,schema:f,className:p,children:m,...h}){let g=(0,a.useRecordContext)(),_=typeof e==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(e),v=b(e,g?.data)||(_?``:e),y=t??s,x=typeof y==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(y),S=b(y,g?.data)||(x?``:y),C=!!g?.recordId,w=!!g?.embedded,T=d??(C&&!w),E=n.default.useCallback(()=>{if(typeof window>`u`)return;let e=window.location.pathname,t=e.replace(/\/record\/[^/]+\/?$/,``);t===e?window.history.length>1&&window.history.back():(window.history.pushState({},``,t+window.location.search),window.dispatchEvent(new PopStateEvent(`popstate`)))},[]),D=Array.isArray(f?.children)?f.children.filter(Boolean).map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e},e?.id||`pgh-child-${t}`)):null,O=Array.isArray(u)&&u.length>0&&u||Array.isArray(f?.actions)&&f.actions.length>0&&f.actions||Array.isArray(f?.properties?.actions)&&f.properties.actions.length>0&&f.properties.actions||null,k=l||m||(O?(0,o.jsx)(a.SchemaRenderer,{schema:{type:`record:quick_actions`,properties:{actions:O,location:`record_header`,align:`end`,inline:!0}}}):null)||D;return(0,o.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-3 pb-4 border-b`,p),...h,children:(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[T&&(0,o.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:E,"aria-label":`Back to list`,className:`flex-shrink-0 -ml-2`,children:(0,o.jsx)(i.ArrowLeft,{className:`size-4`})}),c&&(v||S)&&(0,o.jsx)(`div`,{className:`flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary`,children:typeof c==`string`?(0,o.jsx)(r.LazyIcon,{name:c,className:`size-5`}):c}),(0,o.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[v?(0,o.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:v}):null,S&&(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:S})]}),k&&(0,o.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:k})]})})}function S(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function C(e){let t=S(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function w(e){let t=S(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function T(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function E(e,t){(0,n.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=C(e.primaryColor),i=w(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:T(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=C(e.accentColor),i=w(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:T(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function D({sidebar:e,navbar:t,children:n,className:i,defaultOpen:a=!0,branding:s}){return E(s,s?.title),(0,o.jsxs)(r.SidebarProvider,{defaultOpen:a,className:`!flex-col h-svh overflow-hidden`,children:[(0,o.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,o.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,o.jsx)(r.SidebarInset,{className:`min-w-0`,children:(0,o.jsx)(`main`,{className:(0,r.cn)(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,i),children:n})})]})]})}function O({className:e,children:t,...n}){return(0,o.jsx)(`div`,{className:(0,r.cn)(`rounded-xl border bg-card text-card-foreground shadow`,e),...n,children:(0,o.jsx)(`div`,{className:`p-6`,children:t})})}var k={xs:{1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`,4:`grid-cols-4`,6:`grid-cols-6`,12:`grid-cols-12`},sm:{1:`sm:grid-cols-1`,2:`sm:grid-cols-2`,3:`sm:grid-cols-3`,4:`sm:grid-cols-4`,6:`sm:grid-cols-6`,12:`sm:grid-cols-12`},md:{1:`md:grid-cols-1`,2:`md:grid-cols-2`,3:`md:grid-cols-3`,4:`md:grid-cols-4`,6:`md:grid-cols-6`,12:`md:grid-cols-12`},lg:{1:`lg:grid-cols-1`,2:`lg:grid-cols-2`,3:`lg:grid-cols-3`,4:`lg:grid-cols-4`,6:`lg:grid-cols-6`,12:`lg:grid-cols-12`},xl:{1:`xl:grid-cols-1`,2:`xl:grid-cols-2`,3:`xl:grid-cols-3`,4:`xl:grid-cols-4`,6:`xl:grid-cols-6`,12:`xl:grid-cols-12`},"2xl":{1:`2xl:grid-cols-1`,2:`2xl:grid-cols-2`,3:`2xl:grid-cols-3`,4:`2xl:grid-cols-4`,6:`2xl:grid-cols-6`,12:`2xl:grid-cols-12`}};function A(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=k[n];if(e&&r){let n=Object.keys(e).map(Number).reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e);t.push(e[n])}}return t.join(` `)||`grid-cols-1`}var j={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},M=({columns:e,gap:t=4,className:n,children:i})=>(0,o.jsx)(`div`,{className:(0,r.cn)(`grid`,A(e),typeof t==`number`?j[t]||`gap-${t}`:``,n),children:i});function N(e){return e?(0,r.getLazyIcon)(e):i.FileText}function P(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function F(e,t,n,r,i,a){let o=P(e.label,n);if(typeof e.label!=`string`)return o;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,o):o;if(t)return t(e.objectName,o)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,o):i&&e.type===`group`&&e.id?i(e.id,o):o}var I=e=>!(e===!1||e===`false`),L=()=>!0,R=()=>!0;function z(e,t){switch(e.type){case`object`:{let n=`${t}/${e.objectName??``}`;return{href:e.viewName?`${n}/view/${e.viewName}`:n,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:return{href:e.pageName?`${t}/page/${e.pageName}`:`#`,external:!1};case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};default:return{href:`#`,external:!1}}}function B(e,t,n){return t===`#`?!1:n===t?!0:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function V(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=V(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return P(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var H=5;function U({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,t:g}){let{attributes:_,listeners:v,setNodeRef:y,transform:b,transition:x,isDragging:S}=(0,l.useSortable)({id:e.id,disabled:!d});return(0,o.jsx)(`div`,{ref:y,style:{transform:u.CSS.Transform.toString(b),transition:x,opacity:S?.5:void 0,zIndex:S?10:void 0},..._,children:(0,o.jsx)(W,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?v:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,t:g})})}function W({item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,t:v}){let y=(0,s.useLocation)(),b=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),x=e.type===`group`?e.children?.length??0:0,[S,C]=(0,n.useState)(n.default.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=z(r,t);if(B(r,e,y.pathname))return!0}return!1};return n(e.children)},[e,t,y.pathname])?!0:b??!(x>=8));if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let w=e.requiresObject,T=e.requiresService;if(w&&!l(`object`,w)||T&&!l(`service`,T))return null;if(e.type===`separator`)return(0,o.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,o.jsx)(r.Collapsible,{open:S,onOpenChange:C,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:`flex w-full items-center justify-between`,children:[F(e,m,v,h,g,_),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform ${S?`rotate-90`:``}`})]})}),(0,o.jsx)(r.CollapsibleContent,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:n.map(e=>(0,o.jsx)(W,{item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,t:v},e.id))})})})]})})}if(e.type===`action`){let t=N(e.icon),n=P(e.label,v);return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":v?v(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsxs)(r.SidebarMenuButton,{tooltip:n,onClick:()=>u?.(e),children:[(0,o.jsx)(t,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:n}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned),"aria-label":v?v(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${n}`:`Pin ${n}`,name:n}):e.pinned?`Unpin ${n}`:`Pin ${n}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}let E=N(e.icon),{href:D,external:O}=z(e,t),k=B(e,D,y.pathname),A=F(e,m,v,h,g,_),j=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(E,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:A}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":v?v(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:k,tooltip:A,children:O?(0,o.jsx)(`a`,{href:D,target:`_blank`,rel:`noopener noreferrer`,children:j}):(0,o.jsx)(s.Link,{to:D,children:j})}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned),"aria-label":v?v(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${A}`:`Pin ${A}`,name:A}):e.pinned?`Unpin ${A}`:`Pin ${A}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}function G({items:e,basePath:t=``,evaluateVisibility:a=I,checkPermission:s=L,checkCapability:u=R,onAction:d,searchQuery:f,enablePinning:p,onPinToggle:m,enableReorder:h,onReorder:g,resolveObjectLabel:_,resolveDashboardLabel:v,resolveGroupLabel:y,resolveViewLabel:b,t:x}){let S=(0,n.useMemo)(()=>f?V(e,f):e,[e,f]),C=(0,n.useMemo)(()=>K(S),[S]),w=S.slice().sort((e,t)=>(e.order??0)-(t.order??0)),T=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:H}}),(0,c.useSensor)(c.KeyboardSensor)),E=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!g)return;let r=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||g((0,l.arrayMove)(w,r,i).map((e,t)=>({...e,order:t})))},D={basePath:t,evalVis:a,checkPerm:s,checkCap:u,onAction:d,enablePinning:p,onPinToggle:m,resolveObjectLabel:_,resolveDashboardLabel:v,resolveGroupLabel:y,resolveViewLabel:b,t:x},O=w.some(e=>e.type===`group`),k=C.length>0&&p?(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Star,{className:`h-3.5 w-3.5`}),x?x(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:C.map(e=>(0,o.jsx)(W,{item:e,...D},`fav-${e.id}`))})})]}):null;if(!O){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,o.jsxs)(o.Fragment,{children:[k,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:h?(0,o.jsx)(c.DndContext,{sensors:T,collisionDetection:c.closestCenter,onDragEnd:E,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:w.map(e=>(0,o.jsx)(U,{item:e,enableReorder:h,...D},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:w.map(e=>(0,o.jsx)(W,{item:e,...D},e.id))})})})]})}let A=[],j=[],M=e=>{if(j.length===0)return;let t=j;j=[],A.push((0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:t.map(e=>(0,o.jsx)(W,{item:e,...D},e.id))})})},e))};return w.forEach((e,t)=>{e.type===`group`?(M(`leaf-${t}`),A.push((0,o.jsx)(W,{item:e,...D},e.id))):j.push(e)}),M(`leaf-end`),(0,o.jsxs)(o.Fragment,{children:[k,A]})}function K(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...K(n.children));return t}function q({areas:e,activeAreaId:t,onAreaChange:n,evalVis:a,checkPerm:s}){let c=e.filter(e=>!(!a(e.visible)||e.requiredPermissions?.length&&!s(e.requiredPermissions)));return c.length<=1?null:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Layers,{className:`h-3.5 w-3.5`}),`Area`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:c.map(e=>{let i=N(e.icon);return(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:P(e.label),onClick:()=>n(e.id),children:[(0,o.jsx)(i,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:P(e.label)})]})},e.id)})})})]})}function J({items:e,basePath:t}){let n=(0,s.useLocation)(),r=e=>{let t=[];for(let n of e)n.type!==`separator`&&(n.type===`group`?t.push(...r(n.children||[])):t.push(n));return t},i=r(e).slice(0,5);return i.length===0?null:(0,o.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,role:`navigation`,"aria-label":`Mobile navigation`,children:i.map(e=>{let r=N(e.icon),i=`#`;e.type===`object`?(i=`${t}/${e.objectName}`,e.viewName&&(i+=`/view/${e.viewName}`)):e.type===`dashboard`?i=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`:e.type===`page`?i=e.pageName?`${t}/page/${e.pageName}`:`#`:e.type===`report`?i=e.reportName?`${t}/report/${e.reportName}`:`#`:e.type===`url`&&(i=e.url??`#`);let a=i!==`#`&&n.pathname.startsWith(i);return(0,o.jsxs)(s.Link,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,o.jsx)(r,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:P(e.label)})]},e.id)})})}function Y({schema:e,basePath:t,evalVis:i,checkPerm:a,checkCap:s,onAction:c,sidebarHeader:l,sidebarFooter:u,sidebarExtra:d,activeAreaId:f,setActiveAreaId:p,resolvedNavigation:m,enableSearch:h,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}){let b=N(e.logo),x=e.areas??[],[S,C]=(0,n.useState)(``);return(0,o.jsxs)(r.Sidebar,{collapsible:`icon`,children:[(0,o.jsxs)(r.SidebarHeader,{children:[l??(0,o.jsx)(r.SidebarMenu,{children:(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{size:`lg`,tooltip:e.title??e.name,children:[(0,o.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground`,children:e.logo&&e.logo.startsWith(`http`)?(0,o.jsx)(`img`,{src:e.logo,alt:e.title??``,className:`size-6 object-contain`}):(0,o.jsx)(b,{className:`size-4`})}),(0,o.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,o.jsx)(`span`,{className:`truncate font-semibold`,children:e.title??e.name??`App`}),e.description&&(0,o.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]})]})})}),h&&(0,o.jsx)(r.SidebarInput,{placeholder:`Search navigation…`,value:S,onChange:e=>C(e.target.value),"aria-label":`Search navigation`})]}),(0,o.jsxs)(r.SidebarContent,{children:[x.length>1&&f&&(0,o.jsx)(q,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:i,checkPerm:a}),(0,o.jsx)(G,{items:m,basePath:t,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,searchQuery:S,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}),d]}),u&&(0,o.jsx)(r.SidebarFooter,{children:u})]})}function X({schema:e,basePath:t=``,mobileNavMode:r=`drawer`,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,navbar:l,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,children:m,className:h,defaultOpen:g=!0,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=i??(e=>!(e===!1||e===`false`)),C=a??(()=>!0),w=s??(()=>!0),T=(0,n.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,d.menuItemToNavigationItem)(e,t)),[e.menu]),E=e.navigation??T,O=e.areas??[],[k,A]=(0,n.useState)(()=>O.length>0?O[0].id:null),j=O.map(e=>e.id).join(`,`);(0,n.useEffect)(()=>{O.length>0?A(e=>O.some(t=>t.id===e)?e:O[0].id):A(null)},[e.name,j]);let M=O.find(e=>e.id===k)?.navigation??E,N={title:e.title,favicon:e.favicon,logo:e.logo};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(D,{sidebar:(0,o.jsx)(Y,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,activeAreaId:k,setActiveAreaId:A,resolvedNavigation:M,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}),navbar:l,className:h,defaultOpen:g,branding:N,children:m}),r===`bottom_nav`&&(0,o.jsx)(J,{items:M,basePath:t})]})}var Z=e=>e?Array.isArray(e)?e:[e]:[];function Q({schema:e,className:t,style:n,id:i,...s}){let c=Z(e.children);return(0,o.jsxs)(`div`,{id:i||e.id,className:(0,r.cn)(`flex flex-col h-full space-y-4`,t),style:n,children:[(0,o.jsx)(x,{title:e.title,description:e.description}),(0,o.jsx)(`div`,{className:`flex-1 overflow-auto`,children:c.map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e,...s},e?.id||t))})]})}function ee(e){return`items`in e&&!(`href`in e)}function te({item:e,pathname:t}){return e.children&&e.children.length>0?(0,o.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,o.jsxs)(r.SidebarMenuItem,{children:[(0,o.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,o.jsxs)(r.SidebarMenuButton,{tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto mr-1 h-5 min-w-5 px-1 text-xs`,children:e.badge}),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,o.jsx)(r.CollapsibleContent,{className:`motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150`,children:(0,o.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,o.jsx)(r.SidebarMenuSubItem,{children:(0,o.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})},e.href))})})]})}):(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function ne({items:e,title:t=`Application`,className:a,collapsible:c=`icon`,searchEnabled:l=!1,searchPlaceholder:u=`Search…`}){let d=(0,s.useLocation)(),[f,p]=n.default.useState(``),m=n.default.useMemo(()=>e.length===0?[]:ee(e[0])?e.map(e=>({groupLabel:e.label,items:e.items})):[{items:e}],[e]),h=n.default.useMemo(()=>{if(!f)return m;let e=f.toLowerCase();return m.map(t=>({...t,items:t.items.filter(t=>t.title.toLowerCase().includes(e)||t.children?.some(t=>t.title.toLowerCase().includes(e)))})).filter(e=>e.items.length>0)},[m,f]);return(0,o.jsx)(r.Sidebar,{className:a,collapsible:c,children:(0,o.jsxs)(r.SidebarContent,{children:[l&&(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(i.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,o.jsx)(r.Input,{type:`search`,placeholder:u,value:f,onChange:e=>p(e.target.value),className:`pl-8 h-9`})]})}),h.map((e,n)=>(0,o.jsxs)(r.SidebarGroup,{children:[n>0&&(0,o.jsx)(`div`,{className:`mx-3 mb-1 h-px bg-sidebar-border/60`,"aria-hidden":!0}),(0,o.jsx)(r.SidebarGroupLabel,{className:`text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60`,children:e.groupLabel||t}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:e.items.map(e=>(0,o.jsx)(te,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function $(){t.ComponentRegistry.register(`page-header`,x,{namespace:`layout`,label:`Page Header`,category:`Layout`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`}]}),t.ComponentRegistry.register(`page:card`,O,{namespace:`layout`,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,D,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,M,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,G,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`object`},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,X,{namespace:`layout`,label:`App Schema Renderer`,category:`Layout`,isContainer:!0,inputs:[{name:`schema`,type:`object`},{name:`basePath`,type:`string`},{name:`mobileNavMode`,type:`string`}]})}try{$()}catch{}e.AppSchemaRenderer=X,e.AppShell=D,e.NavigationRenderer=G,e.Page=Q,e.PageCard=O,e.PageHeader=x,e.ResponsiveGrid=M,e.SidebarNav=ne,e.filterNavigationItems=V,e.registerLayout=$,e.resolveIcon=N,e.resolveLabel=P,e.useAppShellBranding=E});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("lucide-react"),require("@object-ui/react"),require("react/jsx-runtime"),require("react-router-dom"),require("@dnd-kit/core"),require("@dnd-kit/sortable"),require("@dnd-kit/utilities"),require("@object-ui/types")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`react/jsx-runtime`,`react-router-dom`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUILayout={},e._object_ui_core,e.react,e._object_ui_components,e.lucide_react,e._object_ui_react,e.react_jsx_runtime,e.react_router_dom,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e._object_ui_types))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var y=e=>{let t=e?.name??e?.full_name??e?.display_name??e?.label??e?.title??e?.subject;return t!=null&&String(t).trim()?String(t):[e?.salutation,e?.first_name,e?.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e?.email==`string`&&e.email.trim()?e.email.trim():null)},b=(e,t)=>!e||typeof e!=`string`?e??``:e.includes(`{`)?e.replace(/\{([a-zA-Z0-9_.]+)\}/g,(e,n)=>{let r=n.split(`.`).reduce((e,t)=>e==null?e:e[t],t);return r==null?``:typeof r==`object`?y(r)??``:String(r)}).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g,``).replace(/^\s*[-–—|/·,:]\s*/,``).replace(/\s+/g,` `).trim():e;function x({title:e,subtitle:t,description:s,icon:c,action:l,actions:u,showBack:d,schema:f,className:p,children:m,...h}){let g=(0,a.useRecordContext)(),_=typeof e==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(e),v=b(e,g?.data)||(_?``:e),y=t??s,x=typeof y==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(y),S=b(y,g?.data)||(x?``:y),C=!!g?.recordId,w=!!g?.embedded,T=d??(C&&!w),E=n.default.useCallback(()=>{if(typeof window>`u`)return;let e=window.location.pathname,t=e.replace(/\/record\/[^/]+\/?$/,``);t===e?window.history.length>1&&window.history.back():(window.history.pushState({},``,t+window.location.search),window.dispatchEvent(new PopStateEvent(`popstate`)))},[]),D=Array.isArray(f?.children)?f.children.filter(Boolean).map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e},e?.id||`pgh-child-${t}`)):null,O=Array.isArray(u)&&u.length>0&&u||Array.isArray(f?.actions)&&f.actions.length>0&&f.actions||Array.isArray(f?.properties?.actions)&&f.properties.actions.length>0&&f.properties.actions||null,k=l||m||(O?(0,o.jsx)(a.SchemaRenderer,{schema:{type:`record:quick_actions`,properties:{actions:O,location:`record_header`,align:`end`,inline:!0}}}):null)||D;return(0,o.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-3 pb-4 border-b`,p),...h,children:(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[T&&(0,o.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:E,"aria-label":`Back to list`,className:`flex-shrink-0 -ml-2`,children:(0,o.jsx)(i.ArrowLeft,{className:`size-4`})}),c&&(v||S)&&(0,o.jsx)(`div`,{className:`flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary`,children:typeof c==`string`?(0,o.jsx)(r.LazyIcon,{name:c,className:`size-5`}):c}),(0,o.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[v?(0,o.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:v}):null,S&&(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:S})]}),k&&(0,o.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:k})]})})}function S(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function C(e){let t=S(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function w(e){let t=S(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function T(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function E(e,t){(0,n.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=C(e.primaryColor),i=w(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:T(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=C(e.accentColor),i=w(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:T(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function D({sidebar:e,navbar:t,children:n,className:i,defaultOpen:a=!0,branding:s}){return E(s,s?.title),(0,o.jsxs)(r.SidebarProvider,{defaultOpen:a,className:`!flex-col h-svh overflow-hidden`,children:[(0,o.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,o.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,o.jsx)(r.SidebarInset,{className:`min-w-0`,children:(0,o.jsx)(`main`,{className:(0,r.cn)(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,i),children:n})})]})]})}function O({className:e,children:t,...n}){return(0,o.jsx)(`div`,{className:(0,r.cn)(`rounded-xl border bg-card text-card-foreground shadow`,e),...n,children:(0,o.jsx)(`div`,{className:`p-6`,children:t})})}var k={xs:{1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`,4:`grid-cols-4`,6:`grid-cols-6`,12:`grid-cols-12`},sm:{1:`sm:grid-cols-1`,2:`sm:grid-cols-2`,3:`sm:grid-cols-3`,4:`sm:grid-cols-4`,6:`sm:grid-cols-6`,12:`sm:grid-cols-12`},md:{1:`md:grid-cols-1`,2:`md:grid-cols-2`,3:`md:grid-cols-3`,4:`md:grid-cols-4`,6:`md:grid-cols-6`,12:`md:grid-cols-12`},lg:{1:`lg:grid-cols-1`,2:`lg:grid-cols-2`,3:`lg:grid-cols-3`,4:`lg:grid-cols-4`,6:`lg:grid-cols-6`,12:`lg:grid-cols-12`},xl:{1:`xl:grid-cols-1`,2:`xl:grid-cols-2`,3:`xl:grid-cols-3`,4:`xl:grid-cols-4`,6:`xl:grid-cols-6`,12:`xl:grid-cols-12`},"2xl":{1:`2xl:grid-cols-1`,2:`2xl:grid-cols-2`,3:`2xl:grid-cols-3`,4:`2xl:grid-cols-4`,6:`2xl:grid-cols-6`,12:`2xl:grid-cols-12`}};function A(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=k[n];if(e&&r){let n=Object.keys(e).map(Number).reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e);t.push(e[n])}}return t.join(` `)||`grid-cols-1`}var j={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},M=({columns:e,gap:t=4,className:n,children:i})=>(0,o.jsx)(`div`,{className:(0,r.cn)(`grid`,A(e),typeof t==`number`?j[t]||`gap-${t}`:``,n),children:i});function N(e){return e?(0,r.getLazyIcon)(e):i.FileText}function P(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function F(e,t,n,r,i,a,o){let s=P(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var I=e=>!(e===!1||e===`false`),L=()=>!0,R=()=>!0;function z(e,t){switch(e.type){case`object`:{let n=`${t}/${e.objectName??``}`;return{href:e.viewName?`${n}/view/${e.viewName}`:n,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:return{href:e.pageName?`${t}/page/${e.pageName}`:`#`,external:!1};case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let n=e.componentRef;if(!n)return{href:`#`,external:!1};let r=n.split(`:`).filter(Boolean);if(r.length===0)return{href:`#`,external:!1};let i=`${t}/component/${r.join(`/`)}`,a=e.params;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}default:return{href:`#`,external:!1}}}function B(e,t,n){return t===`#`?!1:n===t?!0:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function V(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=V(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return P(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var H=5;function U({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_}){let{attributes:v,listeners:y,setNodeRef:b,transform:x,transition:S,isDragging:C}=(0,l.useSortable)({id:e.id,disabled:!d});return(0,o.jsx)(`div`,{ref:b,style:{transform:u.CSS.Transform.toString(x),transition:S,opacity:C?.5:void 0,zIndex:C?10:void 0},...v,children:(0,o.jsx)(W,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?y:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_})})}function W({item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,resolveItemLabel:v,t:y}){let b=(0,s.useLocation)(),x=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),S=e.type===`group`?e.children?.length??0:0,[C,w]=(0,n.useState)(n.default.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=z(r,t);if(B(r,e,b.pathname))return!0}return!1};return n(e.children)},[e,t,b.pathname])?!0:x??!(S>=8));if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let T=e.requiresObject,E=e.requiresService;if(T&&!l(`object`,T)||E&&!l(`service`,E))return null;if(e.type===`separator`)return(0,o.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,o.jsx)(r.Collapsible,{open:C,onOpenChange:w,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:`flex w-full items-center justify-between`,children:[F(e,m,y,h,g,_,v),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform ${C?`rotate-90`:``}`})]})}),(0,o.jsx)(r.CollapsibleContent,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:n.map(e=>(0,o.jsx)(W,{item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,resolveItemLabel:v,t:y},e.id))})})})]})})}if(e.type===`action`){let n=N(e.icon),a=P(e.label,y);return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":y?y(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsxs)(r.SidebarMenuButton,{tooltip:a,onClick:()=>u?.(e),children:[(0,o.jsx)(n,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:a}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":y?y(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${a}`:`Pin ${a}`,name:a}):e.pinned?`Unpin ${a}`:`Pin ${a}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}let D=N(e.icon),{href:O,external:k}=z(e,t),A=B(e,O,b.pathname),j=F(e,m,y,h,g,_,v),M=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(D,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:j}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":y?y(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:A,tooltip:j,children:k?(0,o.jsx)(`a`,{href:O,target:`_blank`,rel:`noopener noreferrer`,children:M}):(0,o.jsx)(s.Link,{to:O,children:M})}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":y?y(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${j}`:`Pin ${j}`,name:j}):e.pinned?`Unpin ${j}`:`Pin ${j}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}function G({items:e,basePath:t=``,evaluateVisibility:a=I,checkPermission:s=L,checkCapability:u=R,onAction:d,searchQuery:f,enablePinning:p,onPinToggle:m,enableReorder:h,onReorder:g,resolveObjectLabel:_,resolveDashboardLabel:v,resolveGroupLabel:y,resolveViewLabel:b,resolveItemLabel:x,t:S}){let C=(0,n.useMemo)(()=>f?V(e,f):e,[e,f]),w=(0,n.useMemo)(()=>K(C),[C]),T=C.slice().sort((e,t)=>(e.order??0)-(t.order??0)),E=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:H}}),(0,c.useSensor)(c.KeyboardSensor)),D=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!g)return;let r=T.findIndex(e=>e.id===t.id),i=T.findIndex(e=>e.id===n.id);r===-1||i===-1||g((0,l.arrayMove)(T,r,i).map((e,t)=>({...e,order:t})))},O={basePath:t,evalVis:a,checkPerm:s,checkCap:u,onAction:d,enablePinning:p,onPinToggle:m,resolveObjectLabel:_,resolveDashboardLabel:v,resolveGroupLabel:y,resolveViewLabel:b,resolveItemLabel:x,t:S},k=T.some(e=>e.type===`group`),A=w.length>0&&p?(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Star,{className:`h-3.5 w-3.5`}),S?S(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:w.map(e=>(0,o.jsx)(W,{item:e,...O},`fav-${e.id}`))})})]}):null;if(!k){let e=T.filter(e=>e.type!==`group`).map(e=>e.id);return(0,o.jsxs)(o.Fragment,{children:[A,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:h?(0,o.jsx)(c.DndContext,{sensors:E,collisionDetection:c.closestCenter,onDragEnd:D,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:T.map(e=>(0,o.jsx)(U,{item:e,enableReorder:h,...O},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:T.map(e=>(0,o.jsx)(W,{item:e,...O},e.id))})})})]})}let j=[],M=[],N=e=>{if(M.length===0)return;let t=M;M=[],j.push((0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:t.map(e=>(0,o.jsx)(W,{item:e,...O},e.id))})})},e))};return T.forEach((e,t)=>{e.type===`group`?(N(`leaf-${t}`),j.push((0,o.jsx)(W,{item:e,...O},e.id))):M.push(e)}),N(`leaf-end`),(0,o.jsxs)(o.Fragment,{children:[A,j]})}function K(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...K(n.children));return t}function q({areas:e,activeAreaId:t,onAreaChange:n,evalVis:a,checkPerm:s}){let c=e.filter(e=>!(!a(e.visible)||e.requiredPermissions?.length&&!s(e.requiredPermissions)));return c.length<=1?null:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Layers,{className:`h-3.5 w-3.5`}),`Area`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:c.map(e=>{let i=N(e.icon);return(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:P(e.label),onClick:()=>n(e.id),children:[(0,o.jsx)(i,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:P(e.label)})]})},e.id)})})})]})}function J({items:e,basePath:t}){let n=(0,s.useLocation)(),r=e=>{let t=[];for(let n of e)n.type!==`separator`&&(n.type===`group`?t.push(...r(n.children||[])):t.push(n));return t},i=r(e).slice(0,5);return i.length===0?null:(0,o.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,role:`navigation`,"aria-label":`Mobile navigation`,children:i.map(e=>{let r=N(e.icon),i=`#`;if(e.type===`object`)i=`${t}/${e.objectName}`,e.viewName&&(i+=`/view/${e.viewName}`);else if(e.type===`dashboard`)i=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`;else if(e.type===`page`)i=e.pageName?`${t}/page/${e.pageName}`:`#`;else if(e.type===`report`)i=e.reportName?`${t}/report/${e.reportName}`:`#`;else if(e.type===`url`)i=e.url??`#`;else if(e.type===`component`){let n=e.componentRef;if(n){i=`${t}/component/${n.split(`:`).filter(Boolean).join(`/`)}`;let r=e.params;if(r){let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(i+=`?${t}`)}}}let a=i!==`#`&&n.pathname.startsWith(i);return(0,o.jsxs)(s.Link,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,o.jsx)(r,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:P(e.label)})]},e.id)})})}function Y({schema:e,basePath:t,evalVis:i,checkPerm:a,checkCap:s,onAction:c,sidebarHeader:l,sidebarFooter:u,sidebarExtra:d,activeAreaId:f,setActiveAreaId:p,resolvedNavigation:m,enableSearch:h,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}){let b=N(e.logo),x=e.areas??[],[S,C]=(0,n.useState)(``);return(0,o.jsxs)(r.Sidebar,{collapsible:`icon`,children:[(0,o.jsxs)(r.SidebarHeader,{children:[l??(0,o.jsx)(r.SidebarMenu,{children:(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{size:`lg`,tooltip:e.title??e.name,children:[(0,o.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground`,children:e.logo&&e.logo.startsWith(`http`)?(0,o.jsx)(`img`,{src:e.logo,alt:e.title??``,className:`size-6 object-contain`}):(0,o.jsx)(b,{className:`size-4`})}),(0,o.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,o.jsx)(`span`,{className:`truncate font-semibold`,children:e.title??e.name??`App`}),e.description&&(0,o.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]})]})})}),h&&(0,o.jsx)(r.SidebarInput,{placeholder:`Search navigation…`,value:S,onChange:e=>C(e.target.value),"aria-label":`Search navigation`})]}),(0,o.jsxs)(r.SidebarContent,{children:[x.length>1&&f&&(0,o.jsx)(q,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:i,checkPerm:a}),(0,o.jsx)(G,{items:m,basePath:t,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,searchQuery:S,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}),d]}),u&&(0,o.jsx)(r.SidebarFooter,{children:u})]})}function X({schema:e,basePath:t=``,mobileNavMode:r=`drawer`,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,navbar:l,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,children:m,className:h,defaultOpen:g=!0,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=i??(e=>!(e===!1||e===`false`)),C=a??(()=>!0),w=s??(()=>!0),T=(0,n.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,d.menuItemToNavigationItem)(e,t)),[e.menu]),E=e.navigation??T,O=e.areas??[],[k,A]=(0,n.useState)(()=>O.length>0?O[0].id:null),j=O.map(e=>e.id).join(`,`);(0,n.useEffect)(()=>{O.length>0?A(e=>O.some(t=>t.id===e)?e:O[0].id):A(null)},[e.name,j]);let M=O.find(e=>e.id===k)?.navigation??E,N={title:e.title,favicon:e.favicon,logo:e.logo};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(D,{sidebar:(0,o.jsx)(Y,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,activeAreaId:k,setActiveAreaId:A,resolvedNavigation:M,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}),navbar:l,className:h,defaultOpen:g,branding:N,children:m}),r===`bottom_nav`&&(0,o.jsx)(J,{items:M,basePath:t})]})}var Z=e=>e?Array.isArray(e)?e:[e]:[];function Q({schema:e,className:t,style:n,id:i,...s}){let c=Z(e.children);return(0,o.jsxs)(`div`,{id:i||e.id,className:(0,r.cn)(`flex flex-col h-full space-y-4`,t),style:n,children:[(0,o.jsx)(x,{title:e.title,description:e.description}),(0,o.jsx)(`div`,{className:`flex-1 overflow-auto`,children:c.map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e,...s},e?.id||t))})]})}function ee(e){return`items`in e&&!(`href`in e)}function te({item:e,pathname:t}){return e.children&&e.children.length>0?(0,o.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,o.jsxs)(r.SidebarMenuItem,{children:[(0,o.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,o.jsxs)(r.SidebarMenuButton,{tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto mr-1 h-5 min-w-5 px-1 text-xs`,children:e.badge}),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,o.jsx)(r.CollapsibleContent,{className:`motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150`,children:(0,o.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,o.jsx)(r.SidebarMenuSubItem,{children:(0,o.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})},e.href))})})]})}):(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function ne({items:e,title:t=`Application`,className:a,collapsible:c=`icon`,searchEnabled:l=!1,searchPlaceholder:u=`Search…`}){let d=(0,s.useLocation)(),[f,p]=n.default.useState(``),m=n.default.useMemo(()=>e.length===0?[]:ee(e[0])?e.map(e=>({groupLabel:e.label,items:e.items})):[{items:e}],[e]),h=n.default.useMemo(()=>{if(!f)return m;let e=f.toLowerCase();return m.map(t=>({...t,items:t.items.filter(t=>t.title.toLowerCase().includes(e)||t.children?.some(t=>t.title.toLowerCase().includes(e)))})).filter(e=>e.items.length>0)},[m,f]);return(0,o.jsx)(r.Sidebar,{className:a,collapsible:c,children:(0,o.jsxs)(r.SidebarContent,{children:[l&&(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(i.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,o.jsx)(r.Input,{type:`search`,placeholder:u,value:f,onChange:e=>p(e.target.value),className:`pl-8 h-9`})]})}),h.map((e,n)=>(0,o.jsxs)(r.SidebarGroup,{children:[n>0&&(0,o.jsx)(`div`,{className:`mx-3 mb-1 h-px bg-sidebar-border/60`,"aria-hidden":!0}),(0,o.jsx)(r.SidebarGroupLabel,{className:`text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60`,children:e.groupLabel||t}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:e.items.map(e=>(0,o.jsx)(te,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function $(){t.ComponentRegistry.register(`page-header`,x,{namespace:`layout`,label:`Page Header`,category:`Layout`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`}]}),t.ComponentRegistry.register(`page:card`,O,{namespace:`layout`,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,D,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,M,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,G,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`object`},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,X,{namespace:`layout`,label:`App Schema Renderer`,category:`Layout`,isContainer:!0,inputs:[{name:`schema`,type:`object`},{name:`basePath`,type:`string`},{name:`mobileNavMode`,type:`string`}]})}try{$()}catch{}e.AppSchemaRenderer=X,e.AppShell=D,e.NavigationRenderer=G,e.Page=Q,e.PageCard=O,e.PageHeader=x,e.ResponsiveGrid=M,e.SidebarNav=ne,e.filterNavigationItems=V,e.registerLayout=$,e.resolveIcon=N,e.resolveLabel=P,e.useAppShellBranding=E});
|
|
@@ -37,7 +37,7 @@ export interface AppSchemaRendererProps {
|
|
|
37
37
|
/** Enable pin/favorite toggle on navigation items */
|
|
38
38
|
enablePinning?: boolean;
|
|
39
39
|
/** Called when a navigation item is pinned or unpinned */
|
|
40
|
-
onPinToggle?: (itemId: string, pinned: boolean) => void;
|
|
40
|
+
onPinToggle?: (itemId: string, pinned: boolean, item?: NavigationItem, basePath?: string) => void;
|
|
41
41
|
/** Enable drag-to-reorder for navigation items */
|
|
42
42
|
enableReorder?: boolean;
|
|
43
43
|
/** Called when navigation items are reordered via drag */
|
|
@@ -47,8 +47,14 @@ export interface NavigationRendererProps {
|
|
|
47
47
|
searchQuery?: string;
|
|
48
48
|
/** Enable pin/favorite toggle on navigation items */
|
|
49
49
|
enablePinning?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Called when a navigation item is pinned or unpinned. The optional
|
|
52
|
+
* `item` and `basePath` arguments are passed so consumers can synthesize
|
|
53
|
+
* a portable favorite record (with a real label/href) instead of storing
|
|
54
|
+
* only the raw nav id. Older consumers that ignore the extra args keep
|
|
55
|
+
* working unchanged.
|
|
56
|
+
*/
|
|
57
|
+
onPinToggle?: (itemId: string, pinned: boolean, item?: NavigationItem, basePath?: string) => void;
|
|
52
58
|
/** Enable drag-to-reorder for navigation items */
|
|
53
59
|
enableReorder?: boolean;
|
|
54
60
|
/** Called when navigation items are reordered via drag */
|
|
@@ -90,6 +96,14 @@ export interface NavigationRendererProps {
|
|
|
90
96
|
* `{ns}.apps.{appName}.navigation.{groupId}.label`.
|
|
91
97
|
*/
|
|
92
98
|
resolveGroupLabel?: (groupId: string, fallbackLabel: string) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Optional label resolver for non-object/non-dashboard/non-group nav
|
|
101
|
+
* items (url, page, report, custom). Called with `(itemId, fallbackLabel)`
|
|
102
|
+
* for items that have a plain-string label and a stable `id`.
|
|
103
|
+
* Convention: `{ns}.apps.{appName}.navigation.{itemId}.label` — same
|
|
104
|
+
* key shape as `resolveGroupLabel` so a single i18n helper covers both.
|
|
105
|
+
*/
|
|
106
|
+
resolveItemLabel?: (itemId: string, fallbackLabel: string) => string;
|
|
93
107
|
/**
|
|
94
108
|
* Optional i18n translation function for resolving I18nLabel objects
|
|
95
109
|
* (`{ key, defaultValue }`). When provided, labels are translated
|
|
@@ -147,4 +161,4 @@ export declare function filterNavigationItems(items: NavigationItem[], query: st
|
|
|
147
161
|
* />
|
|
148
162
|
* ```
|
|
149
163
|
*/
|
|
150
|
-
export declare function NavigationRenderer({ items, basePath, evaluateVisibility: evalVis, checkPermission: checkPerm, checkCapability: checkCap, onAction, searchQuery, enablePinning, onPinToggle, enableReorder, onReorder, resolveObjectLabel, resolveDashboardLabel, resolveGroupLabel, resolveViewLabel, t: tProp, }: NavigationRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
164
|
+
export declare function NavigationRenderer({ items, basePath, evaluateVisibility: evalVis, checkPermission: checkPerm, checkCapability: checkCap, onAction, searchQuery, enablePinning, onPinToggle, enableReorder, onReorder, resolveObjectLabel, resolveDashboardLabel, resolveGroupLabel, resolveViewLabel, resolveItemLabel, t: tProp, }: NavigationRendererProps): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/layout",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.umd.cjs",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"react": "19.2.6",
|
|
23
23
|
"react-dom": "19.2.6",
|
|
24
24
|
"tailwind-merge": "^3.6.0",
|
|
25
|
-
"@object-ui/components": "6.0
|
|
26
|
-
"@object-ui/core": "6.0
|
|
27
|
-
"@object-ui/react": "6.0
|
|
28
|
-
"@object-ui/types": "6.0
|
|
25
|
+
"@object-ui/components": "6.2.0",
|
|
26
|
+
"@object-ui/core": "6.2.0",
|
|
27
|
+
"@object-ui/react": "6.2.0",
|
|
28
|
+
"@object-ui/types": "6.2.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@vitejs/plugin-react": "^6.0.2",
|
|
37
37
|
"react-router-dom": "^7.15.0",
|
|
38
38
|
"vite": "^8.0.14",
|
|
39
|
-
"vite-plugin-dts": "^5.0.
|
|
39
|
+
"vite-plugin-dts": "^5.0.1"
|
|
40
40
|
},
|
|
41
41
|
"description": "Layout components for Object UI — AppShell, Page, SidebarNav and responsive containers with React Router integration",
|
|
42
42
|
"keywords": [
|