@object-ui/layout 11.4.0 → 11.5.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 +13 -0
- package/dist/NavigationRenderer.d.ts +8 -0
- package/dist/index.js +242 -171
- package/dist/index.umd.cjs +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @object-ui/layout
|
|
2
2
|
|
|
3
|
+
## 11.5.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [6fffd3d]
|
|
8
|
+
- Updated dependencies [9255686]
|
|
9
|
+
- Updated dependencies [fae75e2]
|
|
10
|
+
- Updated dependencies [1072701]
|
|
11
|
+
- @object-ui/react@11.5.0
|
|
12
|
+
- @object-ui/components@11.5.0
|
|
13
|
+
- @object-ui/types@11.5.0
|
|
14
|
+
- @object-ui/core@11.5.0
|
|
15
|
+
|
|
3
16
|
## 11.4.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -170,6 +170,14 @@ export declare function resolveHref(item: NavigationItem, basePath: string, temp
|
|
|
170
170
|
href: string;
|
|
171
171
|
external: boolean;
|
|
172
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* Resolve the SINGLE active navigation item for the current location — the
|
|
175
|
+
* inverse of {@link resolveHref}. Surfaces that need "which menu am I in"
|
|
176
|
+
* (sidebar highlight, breadcrumbs, recents, designer deep-links) MUST use
|
|
177
|
+
* this instead of comparing URL strings ad-hoc; the two functions are
|
|
178
|
+
* round-trip tested together.
|
|
179
|
+
*/
|
|
180
|
+
export declare function resolveActiveNavItem(items: NavigationItem[], pathname: string, search: string, basePath: string, templateContext?: NavTemplateContext): NavigationItem | null;
|
|
173
181
|
/**
|
|
174
182
|
* Recursively filter navigation items by search query (case-insensitive label match).
|
|
175
183
|
* Groups are kept if any child matches, with non-matching children pruned.
|
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, useIsMobile as M } from "@object-ui/components";
|
|
4
|
-
import { ArrowLeft as N, ChevronRight as
|
|
5
|
-
import { SchemaRenderer as
|
|
6
|
-
import { Fragment as
|
|
4
|
+
import { ArrowLeft as N, ChevronRight as P, FileText as F, GripVertical as ee, Layers as te, Pin as ne, PinOff as re, Search as ie, Star as I } from "lucide-react";
|
|
5
|
+
import { SchemaRenderer as L, useRecordContext as ae } from "@object-ui/react";
|
|
6
|
+
import { Fragment as oe, jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
7
7
|
import { Link as se, NavLink as B, useLocation as V } from "react-router-dom";
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { SortableContext as
|
|
10
|
-
import { CSS as
|
|
11
|
-
import { menuItemToNavigationItem as
|
|
8
|
+
import { DndContext as ce, KeyboardSensor as H, PointerSensor as le, closestCenter as ue, useSensor as U, useSensors as W } from "@dnd-kit/core";
|
|
9
|
+
import { SortableContext as de, arrayMove as fe, useSortable as pe, verticalListSortingStrategy as me } from "@dnd-kit/sortable";
|
|
10
|
+
import { CSS as he } from "@dnd-kit/utilities";
|
|
11
|
+
import { menuItemToNavigationItem as ge } from "@object-ui/types";
|
|
12
12
|
//#region src/PageHeader.tsx
|
|
13
|
-
var
|
|
13
|
+
var _e = (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
|
+
}, ve = (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" ? _e(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 G({ 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 = ve(e, m?.data) || (h ? "" : e), _ = n ?? r, v = typeof _ == "string" && /\{[a-zA-Z0-9_.]+\}/.test(_), y = ve(_, 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__ */ R(
|
|
29
|
+
}, []), w = Array.isArray(l?.children) ? l.children.filter(Boolean).map((e, t) => /* @__PURE__ */ R(L, { 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(L, { schema: {
|
|
30
30
|
type: "record:quick_actions",
|
|
31
31
|
properties: {
|
|
32
32
|
actions: T,
|
|
@@ -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 ye(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;
|
|
@@ -101,17 +101,17 @@ function _e(e) {
|
|
|
101
101
|
l: l * 100
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
let t =
|
|
104
|
+
function be(e) {
|
|
105
|
+
let t = ye(e);
|
|
106
106
|
return t ? `${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%` : null;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
let t =
|
|
108
|
+
function xe(e) {
|
|
109
|
+
let t = ye(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)}%`;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function Se(e) {
|
|
115
115
|
let t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
|
|
116
116
|
if (!t) return "0 0% 100%";
|
|
117
117
|
let n = (e) => {
|
|
@@ -120,16 +120,16 @@ function be(e) {
|
|
|
120
120
|
}, r = n(parseInt(t[1], 16)), i = n(parseInt(t[2], 16)), a = n(parseInt(t[3], 16));
|
|
121
121
|
return .2126 * r + .7152 * i + .0722 * a > .6 ? "222 47% 11%" : "0 0% 100%";
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function Ce(e, t) {
|
|
124
124
|
n(() => {
|
|
125
125
|
let n = document.documentElement, r = () => n.classList.contains("dark"), i = () => {
|
|
126
126
|
if (e?.primaryColor) {
|
|
127
|
-
let t =
|
|
128
|
-
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%" :
|
|
127
|
+
let t = be(e.primaryColor), i = xe(e.primaryColor), a = r() && i || t;
|
|
128
|
+
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%" : Se(e.primaryColor)), n.style.setProperty("--ring", a), n.style.setProperty("--sidebar-primary", a), n.style.setProperty("--sidebar-ring", a));
|
|
129
129
|
} 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");
|
|
130
130
|
if (e?.accentColor) {
|
|
131
|
-
let t =
|
|
132
|
-
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%" :
|
|
131
|
+
let t = be(e.accentColor), i = xe(e.accentColor), a = r() && i || t;
|
|
132
|
+
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%" : Se(e.accentColor)));
|
|
133
133
|
} else n.style.removeProperty("--brand-accent"), n.style.removeProperty("--brand-accent-hsl"), n.style.removeProperty("--accent"), n.style.removeProperty("--accent-foreground");
|
|
134
134
|
};
|
|
135
135
|
i();
|
|
@@ -156,8 +156,8 @@ function xe(e, t) {
|
|
|
156
156
|
t
|
|
157
157
|
]);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
159
|
+
function K({ sidebar: e, navbar: t, children: n, className: r, defaultOpen: i = !0, branding: a }) {
|
|
160
|
+
return Ce(a, a?.title), /* @__PURE__ */ z(k, {
|
|
161
161
|
defaultOpen: i,
|
|
162
162
|
className: "!flex-col h-svh overflow-hidden",
|
|
163
163
|
children: [/* @__PURE__ */ R("header", {
|
|
@@ -177,7 +177,7 @@ function J({ sidebar: e, navbar: t, children: n, className: r, defaultOpen: i =
|
|
|
177
177
|
}
|
|
178
178
|
//#endregion
|
|
179
179
|
//#region src/PageCard.tsx
|
|
180
|
-
function
|
|
180
|
+
function we({ className: e, children: t, ...n }) {
|
|
181
181
|
return /* @__PURE__ */ R("div", {
|
|
182
182
|
className: A("rounded-xl border bg-card text-card-foreground shadow", e),
|
|
183
183
|
...n,
|
|
@@ -189,7 +189,7 @@ function Se({ className: e, children: t, ...n }) {
|
|
|
189
189
|
}
|
|
190
190
|
//#endregion
|
|
191
191
|
//#region src/ResponsiveGrid.tsx
|
|
192
|
-
var
|
|
192
|
+
var Te = {
|
|
193
193
|
xs: {
|
|
194
194
|
1: "grid-cols-1",
|
|
195
195
|
2: "grid-cols-2",
|
|
@@ -239,11 +239,11 @@ var Ce = {
|
|
|
239
239
|
12: "2xl:grid-cols-12"
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
|
-
function
|
|
242
|
+
function Ee(e) {
|
|
243
243
|
if (!e) return "grid-cols-1";
|
|
244
244
|
let t = [];
|
|
245
245
|
for (let [n, r] of Object.entries(e)) {
|
|
246
|
-
let e =
|
|
246
|
+
let e = Te[n];
|
|
247
247
|
if (e && r) {
|
|
248
248
|
let n = Object.keys(e).map(Number).reduce((e, t) => Math.abs(t - r) < Math.abs(e - r) ? t : e);
|
|
249
249
|
t.push(e[n]);
|
|
@@ -251,7 +251,7 @@ function we(e) {
|
|
|
251
251
|
}
|
|
252
252
|
return t.join(" ") || "grid-cols-1";
|
|
253
253
|
}
|
|
254
|
-
var
|
|
254
|
+
var De = {
|
|
255
255
|
0: "gap-0",
|
|
256
256
|
1: "gap-1",
|
|
257
257
|
2: "gap-2",
|
|
@@ -260,16 +260,16 @@ var Te = {
|
|
|
260
260
|
5: "gap-5",
|
|
261
261
|
6: "gap-6",
|
|
262
262
|
8: "gap-8"
|
|
263
|
-
},
|
|
264
|
-
className: A("grid",
|
|
263
|
+
}, Oe = ({ columns: e, gap: t = 4, className: n, children: r }) => /* @__PURE__ */ R("div", {
|
|
264
|
+
className: A("grid", Ee(e), typeof t == "number" ? De[t] || `gap-${t}` : "", n),
|
|
265
265
|
children: r
|
|
266
266
|
});
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region src/NavigationRenderer.tsx
|
|
269
|
-
function
|
|
270
|
-
return e ? j(e) :
|
|
269
|
+
function q(e) {
|
|
270
|
+
return e ? j(e) : F;
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function J(e, t) {
|
|
273
273
|
if (typeof e == "string") return e;
|
|
274
274
|
if (t) {
|
|
275
275
|
let n = t(e.key, {
|
|
@@ -280,30 +280,40 @@ function X(e, t) {
|
|
|
280
280
|
}
|
|
281
281
|
return e.defaultValue || e.key;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
let s =
|
|
283
|
+
function ke(e, t, n, r, i, a, o) {
|
|
284
|
+
let s = J(e.label, n);
|
|
285
285
|
if (typeof e.label != "string") return s;
|
|
286
|
+
let c = (e) => !!e && s.trim().toLowerCase() !== e.trim().toLowerCase();
|
|
286
287
|
if (e.type === "object" && e.objectName) {
|
|
287
|
-
if (e.viewName) return a ? a(e.objectName, e.viewName, s) : s;
|
|
288
|
+
if (e.viewName) return c(e.viewName) ? s : a ? a(e.objectName, e.viewName, s) : s;
|
|
289
|
+
if (c(e.objectName)) return s;
|
|
288
290
|
if (t) return t(e.objectName, s);
|
|
289
291
|
}
|
|
290
|
-
|
|
292
|
+
if (e.type === "dashboard" && e.dashboardName) {
|
|
293
|
+
if (c(e.dashboardName)) return s;
|
|
294
|
+
if (r) return r(e.dashboardName, s);
|
|
295
|
+
}
|
|
296
|
+
if (e.type === "group" && e.id) {
|
|
297
|
+
if (c(e.id)) return s;
|
|
298
|
+
if (i) return i(e.id, s);
|
|
299
|
+
}
|
|
300
|
+
return o && e.id && !c(e.id) ? o(e.id, s) : s;
|
|
291
301
|
}
|
|
292
|
-
var
|
|
293
|
-
function
|
|
302
|
+
var Ae = (e) => !(e === !1 || e === "false"), je = () => !0, Me = () => !0, Ne = /\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;
|
|
303
|
+
function Y(e, t) {
|
|
294
304
|
if (!e.includes("{")) return e;
|
|
295
|
-
let n = !1, r = e.replace(
|
|
305
|
+
let n = !1, r = e.replace(Ne, (e, r) => {
|
|
296
306
|
let i;
|
|
297
307
|
return i = r === "current_user_id" ? t?.currentUserId : r === "current_org_id" ? t?.currentOrgId : t?.contextValues?.[r], i || (n = !0, "");
|
|
298
308
|
});
|
|
299
309
|
return n ? null : r;
|
|
300
310
|
}
|
|
301
|
-
function
|
|
311
|
+
function X(e, t, n) {
|
|
302
312
|
switch (e.type) {
|
|
303
313
|
case "object": {
|
|
304
314
|
let r = `${t}/${e.objectName ?? ""}`, i = e.recordId;
|
|
305
315
|
if (i) {
|
|
306
|
-
let t =
|
|
316
|
+
let t = Y(i, n);
|
|
307
317
|
if (t) {
|
|
308
318
|
let n = `${r}/record/${encodeURIComponent(t)}`;
|
|
309
319
|
return {
|
|
@@ -312,6 +322,20 @@ function Me(e, t, n) {
|
|
|
312
322
|
};
|
|
313
323
|
}
|
|
314
324
|
}
|
|
325
|
+
let a = e.filters;
|
|
326
|
+
if (a && typeof a == "object" && !Array.isArray(a)) {
|
|
327
|
+
let e = new URLSearchParams();
|
|
328
|
+
for (let [t, r] of Object.entries(a)) {
|
|
329
|
+
if (r == null || t === "") continue;
|
|
330
|
+
let i = Y(String(r), n);
|
|
331
|
+
i !== null && e.set(`filter[${t}]`, i);
|
|
332
|
+
}
|
|
333
|
+
let t = e.toString();
|
|
334
|
+
return {
|
|
335
|
+
href: t ? `${r}/data?${t}` : `${r}/data`,
|
|
336
|
+
external: !1
|
|
337
|
+
};
|
|
338
|
+
}
|
|
315
339
|
return {
|
|
316
340
|
href: e.viewName ? `${r}/view/${e.viewName}` : r,
|
|
317
341
|
external: !1
|
|
@@ -330,7 +354,7 @@ function Me(e, t, n) {
|
|
|
330
354
|
if (r && typeof r == "object") {
|
|
331
355
|
let e = new URLSearchParams();
|
|
332
356
|
for (let [t, i] of Object.entries(r)) if (i != null) if (typeof i == "string") {
|
|
333
|
-
let r =
|
|
357
|
+
let r = Y(i, n);
|
|
334
358
|
r !== null && e.set(t, r);
|
|
335
359
|
} else e.set(t, JSON.stringify(i));
|
|
336
360
|
let t = e.toString();
|
|
@@ -366,7 +390,7 @@ function Me(e, t, n) {
|
|
|
366
390
|
if (a && typeof a == "object") {
|
|
367
391
|
let e = new URLSearchParams();
|
|
368
392
|
for (let [t, r] of Object.entries(a)) if (!(t === "type" || t === "name") && r != null) if (typeof r == "string") {
|
|
369
|
-
let i =
|
|
393
|
+
let i = Y(r, n);
|
|
370
394
|
i && e.set(t, i);
|
|
371
395
|
} else e.set(t, JSON.stringify(r));
|
|
372
396
|
let t = e.toString();
|
|
@@ -401,37 +425,87 @@ function Me(e, t, n) {
|
|
|
401
425
|
};
|
|
402
426
|
}
|
|
403
427
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
428
|
+
var Pe = 50, Fe = 40, Ie = 30, Le = 25, Re = 10, ze = 5;
|
|
429
|
+
function Be(e) {
|
|
430
|
+
let t = /* @__PURE__ */ new Map();
|
|
431
|
+
return new URLSearchParams(e).forEach((e, n) => {
|
|
432
|
+
let r = /^filter\[(.+)\]$/.exec(n);
|
|
433
|
+
r && r[1] && e !== "" && t.set(r[1], e);
|
|
434
|
+
}), t;
|
|
435
|
+
}
|
|
436
|
+
function Ve(e, t) {
|
|
437
|
+
return t.startsWith(`${e}.`) ? t.slice(e.length + 1) : t;
|
|
409
438
|
}
|
|
410
|
-
function
|
|
439
|
+
function He(e, t, n, r, i) {
|
|
440
|
+
let { href: a, external: o } = X(e, r, i);
|
|
441
|
+
if (o || a === "#") return 0;
|
|
442
|
+
if (e.type === "object" && e.objectName) {
|
|
443
|
+
let a = `${r}/${e.objectName}`;
|
|
444
|
+
if (t !== a && !t.startsWith(`${a}/`)) return 0;
|
|
445
|
+
let o = t === a ? [] : t.slice(a.length + 1).split("/"), s = e.recordId;
|
|
446
|
+
if (s) {
|
|
447
|
+
let e = Y(s, i);
|
|
448
|
+
if (e) return o[0] === "record" && decodeURIComponent(o[1] ?? "") === e ? Pe : 0;
|
|
449
|
+
}
|
|
450
|
+
let c = e.filters;
|
|
451
|
+
if (c && typeof c == "object" && !Array.isArray(c)) {
|
|
452
|
+
if (o[0] !== "data") return 0;
|
|
453
|
+
let e = /* @__PURE__ */ new Map();
|
|
454
|
+
for (let [t, n] of Object.entries(c)) {
|
|
455
|
+
if (n == null || t === "") continue;
|
|
456
|
+
let r = Y(String(n), i);
|
|
457
|
+
r !== null && e.set(t, r);
|
|
458
|
+
}
|
|
459
|
+
if (e.size !== n.size) return 0;
|
|
460
|
+
for (let [t, r] of e) if (n.get(t) !== r) return 0;
|
|
461
|
+
return Fe;
|
|
462
|
+
}
|
|
463
|
+
return e.viewName ? o[0] !== "view" || !o[1] ? 0 : Ve(e.objectName, decodeURIComponent(o[1])) === Ve(e.objectName, e.viewName) ? Ie : 0 : o.length === 0 ? Le : Re;
|
|
464
|
+
}
|
|
465
|
+
let s = a.split("?")[0];
|
|
466
|
+
if (t === s) return Le;
|
|
467
|
+
let c = e.componentRef;
|
|
468
|
+
return c && c.split(":")[1] === "directory" ? 0 : t.startsWith(`${s}/`) ? ze : 0;
|
|
469
|
+
}
|
|
470
|
+
function Ue(e, t, n, r, i) {
|
|
471
|
+
let a = Be(n), o = null, s = 0, c = (e) => {
|
|
472
|
+
if (e) for (let n of e) {
|
|
473
|
+
if (n.type === "group") {
|
|
474
|
+
c(n.children);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
let e = He(n, t, a, r, i);
|
|
478
|
+
e > s && (o = n, s = e);
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
return c(e), o;
|
|
482
|
+
}
|
|
483
|
+
var Z = t.createContext(null);
|
|
484
|
+
function We(e, t) {
|
|
411
485
|
if (!t.trim()) return e;
|
|
412
486
|
let n = t.toLowerCase().trim();
|
|
413
487
|
return e.reduce((e, r) => {
|
|
414
488
|
if (r.type === "separator") return e;
|
|
415
489
|
if (r.type === "group" && r.children?.length) {
|
|
416
|
-
let n =
|
|
490
|
+
let n = We(r.children, t);
|
|
417
491
|
return n.length > 0 && e.push({
|
|
418
492
|
...r,
|
|
419
493
|
children: n
|
|
420
494
|
}), e;
|
|
421
495
|
}
|
|
422
|
-
return
|
|
496
|
+
return J(r.label).toLowerCase().includes(n) && e.push(r), e;
|
|
423
497
|
}, []);
|
|
424
498
|
}
|
|
425
|
-
var
|
|
426
|
-
function
|
|
427
|
-
let { attributes: g, listeners: _, setNodeRef: v, transform: y, transition: b, isDragging: x } =
|
|
499
|
+
var Ge = 5;
|
|
500
|
+
function Ke({ 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, templateContext: h }) {
|
|
501
|
+
let { attributes: g, listeners: _, setNodeRef: v, transform: y, transition: b, isDragging: x } = pe({
|
|
428
502
|
id: e.id,
|
|
429
503
|
disabled: !c
|
|
430
504
|
});
|
|
431
505
|
return /* @__PURE__ */ R("div", {
|
|
432
506
|
ref: v,
|
|
433
507
|
style: {
|
|
434
|
-
transform:
|
|
508
|
+
transform: he.Transform.toString(y),
|
|
435
509
|
transition: b,
|
|
436
510
|
opacity: x ? .5 : void 0,
|
|
437
511
|
zIndex: x ? 10 : void 0
|
|
@@ -458,44 +532,29 @@ function Ie({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, onAct
|
|
|
458
532
|
});
|
|
459
533
|
}
|
|
460
534
|
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, templateContext: k }) {
|
|
461
|
-
let j =
|
|
535
|
+
let j = M(), N = j ? "min-h-[44px] text-[15px] gap-3 rounded-xl" : void 0, F = A("shrink-0", j ? "h-5 w-5" : "h-4 w-4"), te = (() => {
|
|
462
536
|
let t = e.expanded;
|
|
463
537
|
if (typeof t == "boolean") return t;
|
|
464
538
|
if (typeof e.defaultOpen == "boolean") return e.defaultOpen;
|
|
465
|
-
})(),
|
|
466
|
-
if (e.type !== "group") return !1;
|
|
467
|
-
let t = (e) =>
|
|
468
|
-
if (!e) return !1;
|
|
469
|
-
for (let r of e) {
|
|
470
|
-
if (r.type === "group") {
|
|
471
|
-
if (t(r.children)) return !0;
|
|
472
|
-
continue;
|
|
473
|
-
}
|
|
474
|
-
let { href: e } = Me(r, n, k);
|
|
475
|
-
if (Ne(r, e, j.pathname)) return !0;
|
|
476
|
-
}
|
|
477
|
-
return !1;
|
|
478
|
-
};
|
|
539
|
+
})(), ie = e.type === "group" ? e.children?.length ?? 0 : 0, I = t.useContext(Z), [L, ae] = i(t.useMemo(() => {
|
|
540
|
+
if (e.type !== "group" || !I) return !1;
|
|
541
|
+
let t = (e) => !!e?.some((e) => e.id === I || e.type === "group" && t(e.children));
|
|
479
542
|
return t(e.children);
|
|
480
|
-
}, [
|
|
481
|
-
e,
|
|
482
|
-
n,
|
|
483
|
-
j.pathname
|
|
484
|
-
]) ? !0 : ie ?? !(ae >= 8));
|
|
543
|
+
}, [e, I]) ? !0 : te ?? !(ie >= 8));
|
|
485
544
|
if (!r(e.visible) || e.requiredPermissions?.length && !o(e.requiredPermissions)) return null;
|
|
486
|
-
let B = e.requiresObject,
|
|
487
|
-
if (B && !u("object", B) ||
|
|
545
|
+
let B = e.requiresObject, V = e.requiresService;
|
|
546
|
+
if (B && !u("object", B) || V && !u("service", V)) return null;
|
|
488
547
|
if (e.type === "separator") return /* @__PURE__ */ R(f, { className: "my-2" });
|
|
489
548
|
if (e.type === "group") {
|
|
490
|
-
let t = (e.children ?? []).slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), i =
|
|
549
|
+
let t = (e.children ?? []).slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), i = ke(e, y, O, b, x, E, D);
|
|
491
550
|
return /* @__PURE__ */ R(s, {
|
|
492
|
-
open:
|
|
493
|
-
onOpenChange:
|
|
551
|
+
open: L,
|
|
552
|
+
onOpenChange: ae,
|
|
494
553
|
children: /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ R(v, {
|
|
495
554
|
asChild: !0,
|
|
496
555
|
children: /* @__PURE__ */ z(l, {
|
|
497
|
-
className: A("flex w-full items-center justify-between",
|
|
498
|
-
children: [i, /* @__PURE__ */ R(
|
|
556
|
+
className: A("flex w-full items-center justify-between", j && "min-h-[44px] text-[15px] rounded-xl"),
|
|
557
|
+
children: [i, /* @__PURE__ */ R(P, { className: A("ml-auto transition-transform", j ? "h-5 w-5" : "h-4 w-4", L && "rotate-90") })]
|
|
499
558
|
})
|
|
500
559
|
}), /* @__PURE__ */ R(c, { children: /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: t.map((e) => /* @__PURE__ */ R(Q, {
|
|
501
560
|
item: e,
|
|
@@ -517,18 +576,18 @@ function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onActi
|
|
|
517
576
|
});
|
|
518
577
|
}
|
|
519
578
|
if (e.type === "action") {
|
|
520
|
-
let t =
|
|
579
|
+
let t = q(e.icon), r = J(e.label, O);
|
|
521
580
|
return /* @__PURE__ */ z(T, { children: [
|
|
522
581
|
h && /* @__PURE__ */ R("span", {
|
|
523
582
|
className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
|
|
524
583
|
"aria-label": O ? O("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
|
|
525
584
|
...h,
|
|
526
|
-
children: /* @__PURE__ */ R(
|
|
585
|
+
children: /* @__PURE__ */ R(ee, { className: "h-3.5 w-3.5" })
|
|
527
586
|
}),
|
|
528
587
|
/* @__PURE__ */ z(w, {
|
|
529
588
|
tooltip: r,
|
|
530
589
|
onClick: () => d?.(e),
|
|
531
|
-
className:
|
|
590
|
+
className: N,
|
|
532
591
|
children: [
|
|
533
592
|
/* @__PURE__ */ R(t, { className: F }),
|
|
534
593
|
/* @__PURE__ */ R("span", { children: r }),
|
|
@@ -550,9 +609,9 @@ function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onActi
|
|
|
550
609
|
})
|
|
551
610
|
] });
|
|
552
611
|
}
|
|
553
|
-
let ce =
|
|
612
|
+
let ce = q(e.icon), { href: H, external: le } = X(e, n, k), ue = I !== null && e.id === I, U = ke(e, y, O, b, x, E, D), W = /* @__PURE__ */ z(oe, { children: [
|
|
554
613
|
/* @__PURE__ */ R(ce, { className: F }),
|
|
555
|
-
/* @__PURE__ */ R("span", { children:
|
|
614
|
+
/* @__PURE__ */ R("span", { children: U }),
|
|
556
615
|
e.badge != null && /* @__PURE__ */ R(a, {
|
|
557
616
|
variant: e.badgeVariant ?? "default",
|
|
558
617
|
className: "ml-auto text-[10px] px-1.5 py-0",
|
|
@@ -564,44 +623,50 @@ function Q({ item: e, basePath: n, evalVis: r, checkPerm: o, checkCap: u, onActi
|
|
|
564
623
|
className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
|
|
565
624
|
"aria-label": O ? O("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
|
|
566
625
|
...h,
|
|
567
|
-
children: /* @__PURE__ */ R(
|
|
626
|
+
children: /* @__PURE__ */ R(ee, { className: "h-3.5 w-3.5" })
|
|
568
627
|
}),
|
|
569
628
|
/* @__PURE__ */ R(w, {
|
|
570
629
|
asChild: !0,
|
|
571
|
-
isActive:
|
|
572
|
-
tooltip:
|
|
573
|
-
className:
|
|
630
|
+
isActive: ue,
|
|
631
|
+
tooltip: U,
|
|
632
|
+
className: N,
|
|
574
633
|
children: le ? /* @__PURE__ */ R("a", {
|
|
575
|
-
href:
|
|
634
|
+
href: H,
|
|
576
635
|
target: "_blank",
|
|
577
636
|
rel: "noopener noreferrer",
|
|
578
|
-
children:
|
|
637
|
+
children: W
|
|
579
638
|
}) : /* @__PURE__ */ R(se, {
|
|
580
|
-
to:
|
|
581
|
-
children:
|
|
639
|
+
to: H,
|
|
640
|
+
children: W
|
|
582
641
|
})
|
|
583
642
|
}),
|
|
584
643
|
p && m && /* @__PURE__ */ R(C, {
|
|
585
644
|
showOnHover: !0,
|
|
586
645
|
onClick: () => m(e.id, !e.pinned, e, n),
|
|
587
646
|
"aria-label": O ? O(e.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
|
|
588
|
-
defaultValue: e.pinned ? `Unpin ${
|
|
589
|
-
name:
|
|
590
|
-
}) : e.pinned ? `Unpin ${
|
|
647
|
+
defaultValue: e.pinned ? `Unpin ${U}` : `Pin ${U}`,
|
|
648
|
+
name: U
|
|
649
|
+
}) : e.pinned ? `Unpin ${U}` : `Pin ${U}`,
|
|
591
650
|
children: e.pinned ? /* @__PURE__ */ R(re, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ R(ne, { className: "h-3.5 w-3.5" })
|
|
592
651
|
})
|
|
593
652
|
] });
|
|
594
653
|
}
|
|
595
|
-
function $({ items: e, basePath: t = "", evaluateVisibility: n =
|
|
596
|
-
let C =
|
|
654
|
+
function $({ items: e, basePath: t = "", evaluateVisibility: n = Ae, checkPermission: i = je, checkCapability: a = Me, onAction: o, searchQuery: s, enablePinning: c, onPinToggle: l, enableReorder: u, onReorder: d, resolveObjectLabel: f, resolveDashboardLabel: p, resolveGroupLabel: m, resolveViewLabel: h, resolveItemLabel: y, t: b, templateContext: x }) {
|
|
655
|
+
let C = V(), w = r(() => Ue(e, C.pathname, C.search, t, x)?.id ?? null, [
|
|
656
|
+
e,
|
|
657
|
+
C.pathname,
|
|
658
|
+
C.search,
|
|
659
|
+
t,
|
|
660
|
+
x
|
|
661
|
+
]), T = r(() => s ? We(e, s) : e, [e, s]), E = r(() => qe(T), [T]), D = T.slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), O = W(U(le, { activationConstraint: { distance: Ge } }), U(H)), k = (e) => {
|
|
597
662
|
let { active: t, over: n } = e;
|
|
598
663
|
if (!n || t.id === n.id || !d) return;
|
|
599
|
-
let r =
|
|
600
|
-
r === -1 || i === -1 || d(
|
|
664
|
+
let r = D.findIndex((e) => e.id === t.id), i = D.findIndex((e) => e.id === n.id);
|
|
665
|
+
r === -1 || i === -1 || d(fe(D, r, i).map((e, t) => ({
|
|
601
666
|
...e,
|
|
602
667
|
order: t
|
|
603
668
|
})));
|
|
604
|
-
},
|
|
669
|
+
}, A = {
|
|
605
670
|
basePath: t,
|
|
606
671
|
evalVis: n,
|
|
607
672
|
checkPerm: i,
|
|
@@ -616,71 +681,77 @@ function $({ items: e, basePath: t = "", evaluateVisibility: n = Oe, checkPermis
|
|
|
616
681
|
resolveItemLabel: y,
|
|
617
682
|
t: b,
|
|
618
683
|
templateContext: x
|
|
619
|
-
},
|
|
684
|
+
}, j = D.some((e) => e.type === "group"), M = E.length > 0 && c ? /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ z(v, {
|
|
620
685
|
className: "flex items-center gap-1.5",
|
|
621
|
-
children: [/* @__PURE__ */ R(
|
|
622
|
-
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children:
|
|
686
|
+
children: [/* @__PURE__ */ R(I, { className: "h-3.5 w-3.5" }), b ? b("console.nav.favorites", { defaultValue: "Favorites" }) : "Favorites"]
|
|
687
|
+
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: E.map((e) => /* @__PURE__ */ R(Q, {
|
|
623
688
|
item: e,
|
|
624
|
-
...
|
|
689
|
+
...A
|
|
625
690
|
}, `fav-${e.id}`)) }) })] }) : null;
|
|
626
|
-
if (!
|
|
627
|
-
let e =
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
children: /* @__PURE__ */ R(K, {
|
|
691
|
+
if (!j) {
|
|
692
|
+
let e = D.filter((e) => e.type !== "group").map((e) => e.id), t = u ? /* @__PURE__ */ R(ce, {
|
|
693
|
+
sensors: O,
|
|
694
|
+
collisionDetection: ue,
|
|
695
|
+
onDragEnd: k,
|
|
696
|
+
children: /* @__PURE__ */ R(de, {
|
|
633
697
|
items: e,
|
|
634
|
-
strategy:
|
|
635
|
-
children: /* @__PURE__ */ R(S, { children:
|
|
698
|
+
strategy: me,
|
|
699
|
+
children: /* @__PURE__ */ R(S, { children: D.map((e) => /* @__PURE__ */ R(Ke, {
|
|
636
700
|
item: e,
|
|
637
701
|
enableReorder: u,
|
|
638
|
-
...
|
|
702
|
+
...A
|
|
639
703
|
}, e.id)) })
|
|
640
704
|
})
|
|
641
|
-
}) : /* @__PURE__ */ R(S, { children:
|
|
705
|
+
}) : /* @__PURE__ */ R(S, { children: D.map((e) => /* @__PURE__ */ R(Q, {
|
|
642
706
|
item: e,
|
|
643
|
-
...
|
|
644
|
-
}, e.id)) })
|
|
707
|
+
...A
|
|
708
|
+
}, e.id)) });
|
|
709
|
+
return /* @__PURE__ */ z(Z.Provider, {
|
|
710
|
+
value: w,
|
|
711
|
+
children: [M, /* @__PURE__ */ R(g, { children: /* @__PURE__ */ R(_, { children: t }) })]
|
|
712
|
+
});
|
|
645
713
|
}
|
|
646
|
-
let
|
|
647
|
-
if (
|
|
648
|
-
let t =
|
|
649
|
-
|
|
714
|
+
let N = [], P = [], F = (e) => {
|
|
715
|
+
if (P.length === 0) return;
|
|
716
|
+
let t = P;
|
|
717
|
+
P = [], N.push(/* @__PURE__ */ R(g, { children: /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: t.map((e) => /* @__PURE__ */ R(Q, {
|
|
650
718
|
item: e,
|
|
651
|
-
...
|
|
719
|
+
...A
|
|
652
720
|
}, e.id)) }) }) }, e));
|
|
653
721
|
};
|
|
654
|
-
return
|
|
655
|
-
e.type === "group" ? (
|
|
722
|
+
return D.forEach((e, t) => {
|
|
723
|
+
e.type === "group" ? (F(`leaf-${t}`), N.push(/* @__PURE__ */ R(Q, {
|
|
656
724
|
item: e,
|
|
657
|
-
...
|
|
658
|
-
}, e.id))) :
|
|
659
|
-
}),
|
|
725
|
+
...A
|
|
726
|
+
}, e.id))) : P.push(e);
|
|
727
|
+
}), F("leaf-end"), /* @__PURE__ */ z(Z.Provider, {
|
|
728
|
+
value: w,
|
|
729
|
+
children: [M, N]
|
|
730
|
+
});
|
|
660
731
|
}
|
|
661
|
-
function
|
|
732
|
+
function qe(e) {
|
|
662
733
|
let t = [];
|
|
663
|
-
for (let n of e) n.pinned && n.type !== "group" && n.type !== "separator" && t.push(n), n.children?.length && t.push(...
|
|
734
|
+
for (let n of e) n.pinned && n.type !== "group" && n.type !== "separator" && t.push(n), n.children?.length && t.push(...qe(n.children));
|
|
664
735
|
return t;
|
|
665
736
|
}
|
|
666
737
|
//#endregion
|
|
667
738
|
//#region src/AppSchemaRenderer.tsx
|
|
668
|
-
function
|
|
739
|
+
function Je({ areas: e, activeAreaId: t, onAreaChange: n, evalVis: r, checkPerm: i }) {
|
|
669
740
|
let a = e.filter((e) => !(!r(e.visible) || e.requiredPermissions?.length && !i(e.requiredPermissions)));
|
|
670
741
|
return a.length <= 1 ? null : /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ z(v, {
|
|
671
742
|
className: "flex items-center gap-1.5",
|
|
672
|
-
children: [/* @__PURE__ */ R(
|
|
743
|
+
children: [/* @__PURE__ */ R(te, { className: "h-3.5 w-3.5" }), "Area"]
|
|
673
744
|
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: a.map((e) => {
|
|
674
|
-
let r =
|
|
745
|
+
let r = q(e.icon);
|
|
675
746
|
return /* @__PURE__ */ R(T, { children: /* @__PURE__ */ z(w, {
|
|
676
747
|
isActive: e.id === t,
|
|
677
|
-
tooltip:
|
|
748
|
+
tooltip: J(e.label),
|
|
678
749
|
onClick: () => n(e.id),
|
|
679
|
-
children: [/* @__PURE__ */ R(r, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", { children:
|
|
750
|
+
children: [/* @__PURE__ */ R(r, { className: "h-4 w-4" }), /* @__PURE__ */ R("span", { children: J(e.label) })]
|
|
680
751
|
}) }, e.id);
|
|
681
752
|
}) }) })] });
|
|
682
753
|
}
|
|
683
|
-
function
|
|
754
|
+
function Ye({ items: e, basePath: t }) {
|
|
684
755
|
let n = V(), r = (e) => {
|
|
685
756
|
let t = [];
|
|
686
757
|
for (let n of e) n.type !== "separator" && (n.type === "group" ? t.push(...r(n.children || [])) : t.push(n));
|
|
@@ -691,7 +762,7 @@ function ze({ items: e, basePath: t }) {
|
|
|
691
762
|
role: "navigation",
|
|
692
763
|
"aria-label": "Mobile navigation",
|
|
693
764
|
children: i.map((e) => {
|
|
694
|
-
let r =
|
|
765
|
+
let r = q(e.icon), i = "#";
|
|
695
766
|
if (e.type === "object") i = `${t}/${e.objectName}`, e.viewName && (i += `/view/${e.viewName}`);
|
|
696
767
|
else if (e.type === "dashboard") i = e.dashboardName ? `${t}/dashboard/${e.dashboardName}` : "#";
|
|
697
768
|
else if (e.type === "page") i = e.pageName ? `${t}/page/${e.pageName}` : "#";
|
|
@@ -716,14 +787,14 @@ function ze({ items: e, basePath: t }) {
|
|
|
716
787
|
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"}`,
|
|
717
788
|
children: [/* @__PURE__ */ R(r, { className: "h-5 w-5" }), /* @__PURE__ */ R("span", {
|
|
718
789
|
className: "text-[10px] truncate max-w-[60px]",
|
|
719
|
-
children:
|
|
790
|
+
children: J(e.label)
|
|
720
791
|
})]
|
|
721
792
|
}, e.id);
|
|
722
793
|
})
|
|
723
794
|
});
|
|
724
795
|
}
|
|
725
|
-
function
|
|
726
|
-
let E =
|
|
796
|
+
function Xe({ 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 }) {
|
|
797
|
+
let E = q(e.logo), D = e.areas ?? [], [O, k] = i("");
|
|
727
798
|
return /* @__PURE__ */ z(p, {
|
|
728
799
|
collapsible: "icon",
|
|
729
800
|
children: [
|
|
@@ -754,7 +825,7 @@ function Be({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onA
|
|
|
754
825
|
"aria-label": "Search navigation"
|
|
755
826
|
})] }),
|
|
756
827
|
/* @__PURE__ */ z(m, { children: [
|
|
757
|
-
D.length > 1 && u && /* @__PURE__ */ R(
|
|
828
|
+
D.length > 1 && u && /* @__PURE__ */ R(Je, {
|
|
758
829
|
areas: D,
|
|
759
830
|
activeAreaId: u,
|
|
760
831
|
onAreaChange: d,
|
|
@@ -780,8 +851,8 @@ function Be({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onA
|
|
|
780
851
|
]
|
|
781
852
|
});
|
|
782
853
|
}
|
|
783
|
-
function
|
|
784
|
-
let S = o ?? ((e) => !(e === !1 || e === "false")), C = s ?? (() => !0), w = c ?? (() => !0), T = r(() => (e.menu ?? []).map((e, t) =>
|
|
854
|
+
function Ze({ 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 }) {
|
|
855
|
+
let S = o ?? ((e) => !(e === !1 || e === "false")), C = s ?? (() => !0), w = c ?? (() => !0), T = r(() => (e.menu ?? []).map((e, t) => ge(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(",");
|
|
785
856
|
n(() => {
|
|
786
857
|
D.length > 0 ? k((e) => D.some((t) => t.id === e) ? e : D[0].id) : k(null);
|
|
787
858
|
}, [e.name, A]);
|
|
@@ -790,8 +861,8 @@ function Ve({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluate
|
|
|
790
861
|
favicon: e.favicon,
|
|
791
862
|
logo: e.logo
|
|
792
863
|
};
|
|
793
|
-
return /* @__PURE__ */ z(
|
|
794
|
-
sidebar: /* @__PURE__ */ R(
|
|
864
|
+
return /* @__PURE__ */ z(oe, { children: [/* @__PURE__ */ R(K, {
|
|
865
|
+
sidebar: /* @__PURE__ */ R(Xe, {
|
|
795
866
|
schema: e,
|
|
796
867
|
basePath: t,
|
|
797
868
|
evalVis: S,
|
|
@@ -815,26 +886,26 @@ function Ve({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluate
|
|
|
815
886
|
defaultOpen: g,
|
|
816
887
|
branding: M,
|
|
817
888
|
children: m
|
|
818
|
-
}), a === "bottom_nav" && /* @__PURE__ */ R(
|
|
889
|
+
}), a === "bottom_nav" && /* @__PURE__ */ R(Ye, {
|
|
819
890
|
items: j,
|
|
820
891
|
basePath: t
|
|
821
892
|
})] });
|
|
822
893
|
}
|
|
823
894
|
//#endregion
|
|
824
895
|
//#region src/Page.tsx
|
|
825
|
-
var
|
|
826
|
-
function
|
|
827
|
-
let a =
|
|
896
|
+
var Qe = (e) => e ? Array.isArray(e) ? e : [e] : [];
|
|
897
|
+
function $e({ schema: e, className: t, style: n, id: r, ...i }) {
|
|
898
|
+
let a = Qe(e.children);
|
|
828
899
|
return /* @__PURE__ */ z("div", {
|
|
829
900
|
id: r || e.id,
|
|
830
901
|
className: A("flex flex-col h-full space-y-4", t),
|
|
831
902
|
style: n,
|
|
832
|
-
children: [/* @__PURE__ */ R(
|
|
903
|
+
children: [/* @__PURE__ */ R(G, {
|
|
833
904
|
title: e.title,
|
|
834
905
|
description: e.description
|
|
835
906
|
}), /* @__PURE__ */ R("div", {
|
|
836
907
|
className: "flex-1 overflow-auto",
|
|
837
|
-
children: a.map((e, t) => /* @__PURE__ */ R(
|
|
908
|
+
children: a.map((e, t) => /* @__PURE__ */ R(L, {
|
|
838
909
|
schema: e,
|
|
839
910
|
...i
|
|
840
911
|
}, e?.id || t))
|
|
@@ -843,10 +914,10 @@ function Ue({ schema: e, className: t, style: n, id: r, ...i }) {
|
|
|
843
914
|
}
|
|
844
915
|
//#endregion
|
|
845
916
|
//#region src/SidebarNav.tsx
|
|
846
|
-
function
|
|
917
|
+
function et(e) {
|
|
847
918
|
return "items" in e && !("href" in e);
|
|
848
919
|
}
|
|
849
|
-
function
|
|
920
|
+
function tt({ item: e, pathname: t }) {
|
|
850
921
|
return e.children && e.children.length > 0 ? /* @__PURE__ */ R(s, {
|
|
851
922
|
asChild: !0,
|
|
852
923
|
defaultOpen: !0,
|
|
@@ -864,7 +935,7 @@ function Ge({ item: e, pathname: t }) {
|
|
|
864
935
|
className: "ml-auto mr-1 h-5 min-w-5 px-1 text-xs",
|
|
865
936
|
children: e.badge
|
|
866
937
|
}),
|
|
867
|
-
/* @__PURE__ */ R(
|
|
938
|
+
/* @__PURE__ */ R(P, { className: "ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
|
|
868
939
|
]
|
|
869
940
|
})
|
|
870
941
|
}), /* @__PURE__ */ R(c, {
|
|
@@ -906,8 +977,8 @@ function Ge({ item: e, pathname: t }) {
|
|
|
906
977
|
})
|
|
907
978
|
}) });
|
|
908
979
|
}
|
|
909
|
-
function
|
|
910
|
-
let s = V(), [c, l] = t.useState(""), d = t.useMemo(() => e.length === 0 ? [] :
|
|
980
|
+
function nt({ items: e, title: n = "Application", className: r, collapsible: i = "icon", searchEnabled: a = !1, searchPlaceholder: o = "Search…" }) {
|
|
981
|
+
let s = V(), [c, l] = t.useState(""), d = t.useMemo(() => e.length === 0 ? [] : et(e[0]) ? e.map((e) => ({
|
|
911
982
|
groupLabel: e.label,
|
|
912
983
|
items: e.items
|
|
913
984
|
})) : [{ items: e }], [e]), f = t.useMemo(() => {
|
|
@@ -942,7 +1013,7 @@ function Ke({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
942
1013
|
className: "text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60",
|
|
943
1014
|
children: e.groupLabel || n
|
|
944
1015
|
}),
|
|
945
|
-
/* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: e.items.map((e) => /* @__PURE__ */ R(
|
|
1016
|
+
/* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: e.items.map((e) => /* @__PURE__ */ R(tt, {
|
|
946
1017
|
item: e,
|
|
947
1018
|
pathname: s.pathname
|
|
948
1019
|
}, e.href)) }) })
|
|
@@ -951,8 +1022,8 @@ function Ke({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
951
1022
|
}
|
|
952
1023
|
//#endregion
|
|
953
1024
|
//#region src/index.ts
|
|
954
|
-
function
|
|
955
|
-
e.register("page-header",
|
|
1025
|
+
function rt() {
|
|
1026
|
+
e.register("page-header", G, {
|
|
956
1027
|
namespace: "layout",
|
|
957
1028
|
label: "Page Header",
|
|
958
1029
|
category: "Layout",
|
|
@@ -963,17 +1034,17 @@ function qe() {
|
|
|
963
1034
|
name: "description",
|
|
964
1035
|
type: "string"
|
|
965
1036
|
}]
|
|
966
|
-
}), e.register("page:card",
|
|
1037
|
+
}), e.register("page:card", we, {
|
|
967
1038
|
namespace: "layout",
|
|
968
1039
|
skipFallback: !0,
|
|
969
1040
|
label: "Page Card",
|
|
970
1041
|
category: "Layout",
|
|
971
1042
|
isContainer: !0
|
|
972
|
-
}), e.register("app-shell",
|
|
1043
|
+
}), e.register("app-shell", K, {
|
|
973
1044
|
namespace: "layout",
|
|
974
1045
|
label: "App Shell",
|
|
975
1046
|
category: "Layout"
|
|
976
|
-
}), e.register("responsive-grid",
|
|
1047
|
+
}), e.register("responsive-grid", Oe, {
|
|
977
1048
|
namespace: "layout",
|
|
978
1049
|
label: "Responsive Grid",
|
|
979
1050
|
category: "Layout",
|
|
@@ -996,7 +1067,7 @@ function qe() {
|
|
|
996
1067
|
name: "basePath",
|
|
997
1068
|
type: "string"
|
|
998
1069
|
}]
|
|
999
|
-
}), e.register("app-schema-renderer",
|
|
1070
|
+
}), e.register("app-schema-renderer", Ze, {
|
|
1000
1071
|
namespace: "layout",
|
|
1001
1072
|
label: "App Schema Renderer",
|
|
1002
1073
|
category: "Layout",
|
|
@@ -1018,7 +1089,7 @@ function qe() {
|
|
|
1018
1089
|
});
|
|
1019
1090
|
}
|
|
1020
1091
|
try {
|
|
1021
|
-
|
|
1092
|
+
rt();
|
|
1022
1093
|
} catch {}
|
|
1023
1094
|
//#endregion
|
|
1024
|
-
export {
|
|
1095
|
+
export { Ze as AppSchemaRenderer, K as AppShell, $ as NavigationRenderer, $e as Page, we as PageCard, G as PageHeader, Oe as ResponsiveGrid, nt as SidebarNav, We as filterNavigationItems, rt as registerLayout, Ue as resolveActiveNavItem, X as resolveHref, q as resolveIcon, J as resolveLabel, Ce 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,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,z=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function B(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(z,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function V(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=B(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=B(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,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 r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=B(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;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&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function H(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function U(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=U(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 W=5;function G({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:_,templateContext:v}){let{attributes:y,listeners:b,setNodeRef:x,transform:S,transition:C,isDragging:w}=(0,l.useSortable)({id:e.id,disabled:!d});return(0,o.jsx)(`div`,{ref:x,style:{transform:u.CSS.Transform.toString(S),transition:C,opacity:w?.5:void 0,zIndex:w?10:void 0},...y,children:(0,o.jsx)(K,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?b:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v})})}function K({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,templateContext:b}){let x=(0,s.useLocation)(),S=(0,r.useIsMobile)(),C=S?`min-h-[44px] text-[15px] gap-3 rounded-xl`:void 0,w=(0,r.cn)(`shrink-0`,S?`h-5 w-5`:`h-4 w-4`),T=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),E=e.type===`group`?e.children?.length??0:0,[D,O]=(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}=V(r,t,b);if(H(r,e,x.pathname))return!0}return!1};return n(e.children)},[e,t,x.pathname])?!0:T??!(E>=8));if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let k=e.requiresObject,A=e.requiresService;if(k&&!l(`object`,k)||A&&!l(`service`,A))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)),s=F(e,m,y,h,g,_,v);return(0,o.jsx)(r.Collapsible,{open:D,onOpenChange:O,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:(0,r.cn)(`flex w-full items-center justify-between`,S&&`min-h-[44px] text-[15px] rounded-xl`),children:[s,(0,o.jsx)(i.ChevronRight,{className:(0,r.cn)(`ml-auto transition-transform`,S?`h-5 w-5`:`h-4 w-4`,D&&`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)(K,{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,templateContext:b},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),className:C,children:[(0,o.jsx)(n,{className:w}),(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 j=N(e.icon),{href:M,external:I}=V(e,t,b),L=H(e,M,x.pathname),R=F(e,m,y,h,g,_,v),z=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(j,{className:w}),(0,o.jsx)(`span`,{children:R}),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:L,tooltip:R,className:C,children:I?(0,o.jsx)(`a`,{href:M,target:`_blank`,rel:`noopener noreferrer`,children:z}):(0,o.jsx)(s.Link,{to:M,children:z})}),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 ${R}`:`Pin ${R}`,name:R}):e.pinned?`Unpin ${R}`:`Pin ${R}`,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 q({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,templateContext:C}){let w=(0,n.useMemo)(()=>f?U(e,f):e,[e,f]),T=(0,n.useMemo)(()=>J(w),[w]),E=w.slice().sort((e,t)=>(e.order??0)-(t.order??0)),D=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:W}}),(0,c.useSensor)(c.KeyboardSensor)),O=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!g)return;let r=E.findIndex(e=>e.id===t.id),i=E.findIndex(e=>e.id===n.id);r===-1||i===-1||g((0,l.arrayMove)(E,r,i).map((e,t)=>({...e,order:t})))},k={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,templateContext:C},A=E.some(e=>e.type===`group`),j=T.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:T.map(e=>(0,o.jsx)(K,{item:e,...k},`fav-${e.id}`))})})]}):null;if(!A){let e=E.filter(e=>e.type!==`group`).map(e=>e.id);return(0,o.jsxs)(o.Fragment,{children:[j,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:h?(0,o.jsx)(c.DndContext,{sensors:D,collisionDetection:c.closestCenter,onDragEnd:O,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:E.map(e=>(0,o.jsx)(G,{item:e,enableReorder:h,...k},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:E.map(e=>(0,o.jsx)(K,{item:e,...k},e.id))})})})]})}let M=[],N=[],P=e=>{if(N.length===0)return;let t=N;N=[],M.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)(K,{item:e,...k},e.id))})})},e))};return E.forEach((e,t)=>{e.type===`group`?(P(`leaf-${t}`),M.push((0,o.jsx)(K,{item:e,...k},e.id))):N.push(e)}),P(`leaf-end`),(0,o.jsxs)(o.Fragment,{children:[j,M]})}function J(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...J(n.children));return t}function Y({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 X({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 Z({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)(Y,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:i,checkPerm:a}),(0,o.jsx)(q,{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 Q({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)(Z,{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)(X,{items:M,basePath:t})]})}var ee=e=>e?Array.isArray(e)?e:[e]:[];function te({schema:e,className:t,style:n,id:i,...s}){let c=ee(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 ne(e){return`items`in e&&!(`href`in e)}function re({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 ie({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?[]:ne(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)(re,{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`,skipFallback:!0,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`,q,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`object`},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,Q,{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=Q,e.AppShell=D,e.NavigationRenderer=q,e.Page=te,e.PageCard=O,e.PageHeader=x,e.ResponsiveGrid=M,e.SidebarNav=ie,e.filterNavigationItems=U,e.registerLayout=$,e.resolveHref=V,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;let c=e=>!!e&&s.trim().toLowerCase()!==e.trim().toLowerCase();if(e.type===`object`&&e.objectName){if(e.viewName)return c(e.viewName)?s:a?a(e.objectName,e.viewName,s):s;if(c(e.objectName))return s;if(t)return t(e.objectName,s)}if(e.type===`dashboard`&&e.dashboardName){if(c(e.dashboardName))return s;if(r)return r(e.dashboardName,s)}if(e.type===`group`&&e.id){if(c(e.id))return s;if(i)return i(e.id,s)}return o&&e.id&&!c(e.id)?o(e.id,s):s}var I=e=>!(e===!1||e===`false`),L=()=>!0,R=()=>!0,z=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function B(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(z,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function V(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=B(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}let a=e.filters;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=new URLSearchParams;for(let[t,r]of Object.entries(a)){if(r==null||t===``)continue;let i=B(String(r),n);i!==null&&e.set(`filter[${t}]`,i)}let t=e.toString();return{href:t?`${r}/data?${t}`:`${r}/data`,external:!1}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=B(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,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 r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=B(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;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&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}var ee=50,te=40,ne=30,H=25,U=10,W=5;function re(e){let t=new Map;return new URLSearchParams(e).forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.set(r[1],e)}),t}function G(e,t){return t.startsWith(`${e}.`)?t.slice(e.length+1):t}function ie(e,t,n,r,i){let{href:a,external:o}=V(e,r,i);if(o||a===`#`)return 0;if(e.type===`object`&&e.objectName){let a=`${r}/${e.objectName}`;if(t!==a&&!t.startsWith(`${a}/`))return 0;let o=t===a?[]:t.slice(a.length+1).split(`/`),s=e.recordId;if(s){let e=B(s,i);if(e)return o[0]===`record`&&decodeURIComponent(o[1]??``)===e?ee:0}let c=e.filters;if(c&&typeof c==`object`&&!Array.isArray(c)){if(o[0]!==`data`)return 0;let e=new Map;for(let[t,n]of Object.entries(c)){if(n==null||t===``)continue;let r=B(String(n),i);r!==null&&e.set(t,r)}if(e.size!==n.size)return 0;for(let[t,r]of e)if(n.get(t)!==r)return 0;return te}return e.viewName?o[0]!==`view`||!o[1]?0:G(e.objectName,decodeURIComponent(o[1]))===G(e.objectName,e.viewName)?ne:0:o.length===0?H:U}let s=a.split(`?`)[0];if(t===s)return H;let c=e.componentRef;return c&&c.split(`:`)[1]===`directory`?0:t.startsWith(`${s}/`)?W:0}function K(e,t,n,r,i){let a=re(n),o=null,s=0,c=e=>{if(e)for(let n of e){if(n.type===`group`){c(n.children);continue}let e=ie(n,t,a,r,i);e>s&&(o=n,s=e)}};return c(e),o}var q=n.default.createContext(null);function J(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=J(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 ae=5;function oe({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:_,templateContext:v}){let{attributes:y,listeners:b,setNodeRef:x,transform:S,transition:C,isDragging:w}=(0,l.useSortable)({id:e.id,disabled:!d});return(0,o.jsx)(`div`,{ref:x,style:{transform:u.CSS.Transform.toString(S),transition:C,opacity:w?.5:void 0,zIndex:w?10:void 0},...y,children:(0,o.jsx)(Y,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?b:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v})})}function Y({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,templateContext:b}){let x=(0,r.useIsMobile)(),S=x?`min-h-[44px] text-[15px] gap-3 rounded-xl`:void 0,C=(0,r.cn)(`shrink-0`,x?`h-5 w-5`:`h-4 w-4`),w=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),T=e.type===`group`?e.children?.length??0:0,E=n.default.useContext(q),[D,O]=(0,n.useState)(n.default.useMemo(()=>{if(e.type!==`group`||!E)return!1;let t=e=>!!e?.some(e=>e.id===E||e.type===`group`&&t(e.children));return t(e.children)},[e,E])?!0:w??!(T>=8));if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let k=e.requiresObject,A=e.requiresService;if(k&&!l(`object`,k)||A&&!l(`service`,A))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)),s=F(e,m,y,h,g,_,v);return(0,o.jsx)(r.Collapsible,{open:D,onOpenChange:O,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:(0,r.cn)(`flex w-full items-center justify-between`,x&&`min-h-[44px] text-[15px] rounded-xl`),children:[s,(0,o.jsx)(i.ChevronRight,{className:(0,r.cn)(`ml-auto transition-transform`,x?`h-5 w-5`:`h-4 w-4`,D&&`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)(Y,{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,templateContext:b},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),className:S,children:[(0,o.jsx)(n,{className:C}),(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 j=N(e.icon),{href:M,external:I}=V(e,t,b),L=E!==null&&e.id===E,R=F(e,m,y,h,g,_,v),z=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(j,{className:C}),(0,o.jsx)(`span`,{children:R}),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:L,tooltip:R,className:S,children:I?(0,o.jsx)(`a`,{href:M,target:`_blank`,rel:`noopener noreferrer`,children:z}):(0,o.jsx)(s.Link,{to:M,children:z})}),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 ${R}`:`Pin ${R}`,name:R}):e.pinned?`Unpin ${R}`:`Pin ${R}`,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 X({items:e,basePath:t=``,evaluateVisibility:a=I,checkPermission:u=L,checkCapability:d=R,onAction:f,searchQuery:p,enablePinning:m,onPinToggle:h,enableReorder:g,onReorder:_,resolveObjectLabel:v,resolveDashboardLabel:y,resolveGroupLabel:b,resolveViewLabel:x,resolveItemLabel:S,t:C,templateContext:w}){let T=(0,s.useLocation)(),E=(0,n.useMemo)(()=>K(e,T.pathname,T.search,t,w)?.id??null,[e,T.pathname,T.search,t,w]),D=(0,n.useMemo)(()=>p?J(e,p):e,[e,p]),O=(0,n.useMemo)(()=>Z(D),[D]),k=D.slice().sort((e,t)=>(e.order??0)-(t.order??0)),A=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:ae}}),(0,c.useSensor)(c.KeyboardSensor)),j=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!_)return;let r=k.findIndex(e=>e.id===t.id),i=k.findIndex(e=>e.id===n.id);r===-1||i===-1||_((0,l.arrayMove)(k,r,i).map((e,t)=>({...e,order:t})))},M={basePath:t,evalVis:a,checkPerm:u,checkCap:d,onAction:f,enablePinning:m,onPinToggle:h,resolveObjectLabel:v,resolveDashboardLabel:y,resolveGroupLabel:b,resolveViewLabel:x,resolveItemLabel:S,t:C,templateContext:w},N=k.some(e=>e.type===`group`),P=O.length>0&&m?(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`}),C?C(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:O.map(e=>(0,o.jsx)(Y,{item:e,...M},`fav-${e.id}`))})})]}):null;if(!N){let e=k.filter(e=>e.type!==`group`).map(e=>e.id),t=g?(0,o.jsx)(c.DndContext,{sensors:A,collisionDetection:c.closestCenter,onDragEnd:j,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:k.map(e=>(0,o.jsx)(oe,{item:e,enableReorder:g,...M},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:k.map(e=>(0,o.jsx)(Y,{item:e,...M},e.id))});return(0,o.jsxs)(q.Provider,{value:E,children:[P,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:t})})]})}let F=[],z=[],B=e=>{if(z.length===0)return;let t=z;z=[],F.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)(Y,{item:e,...M},e.id))})})},e))};return k.forEach((e,t)=>{e.type===`group`?(B(`leaf-${t}`),F.push((0,o.jsx)(Y,{item:e,...M},e.id))):z.push(e)}),B(`leaf-end`),(0,o.jsxs)(q.Provider,{value:E,children:[P,F]})}function Z(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...Z(n.children));return t}function se({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 ce({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 le({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)(se,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:i,checkPerm:a}),(0,o.jsx)(X,{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 Q({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)(le,{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)(ce,{items:M,basePath:t})]})}var ue=e=>e?Array.isArray(e)?e:[e]:[];function de({schema:e,className:t,style:n,id:i,...s}){let c=ue(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 fe(e){return`items`in e&&!(`href`in e)}function pe({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 me({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?[]:fe(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)(pe,{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`,skipFallback:!0,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`,X,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`object`},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,Q,{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=Q,e.AppShell=D,e.NavigationRenderer=X,e.Page=de,e.PageCard=O,e.PageHeader=x,e.ResponsiveGrid=M,e.SidebarNav=me,e.filterNavigationItems=J,e.registerLayout=$,e.resolveActiveNavItem=K,e.resolveHref=V,e.resolveIcon=N,e.resolveLabel=P,e.useAppShellBranding=E});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/layout",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.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.7",
|
|
23
23
|
"react-dom": "19.2.7",
|
|
24
24
|
"tailwind-merge": "^3.6.0",
|
|
25
|
-
"@object-ui/components": "11.
|
|
26
|
-
"@object-ui/core": "11.
|
|
27
|
-
"@object-ui/react": "11.
|
|
28
|
-
"@object-ui/types": "11.
|
|
25
|
+
"@object-ui/components": "11.5.0",
|
|
26
|
+
"@object-ui/core": "11.5.0",
|
|
27
|
+
"@object-ui/react": "11.5.0",
|
|
28
|
+
"@object-ui/types": "11.5.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|