@object-ui/layout 5.0.1 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/index.js +110 -99
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/layout/src/NavigationRenderer.d.ts +14 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @object-ui/layout
|
|
2
2
|
|
|
3
|
+
## 5.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8955b9c]
|
|
8
|
+
- @object-ui/components@5.1.1
|
|
9
|
+
- @object-ui/types@5.1.1
|
|
10
|
+
- @object-ui/core@5.1.1
|
|
11
|
+
- @object-ui/react@5.1.1
|
|
12
|
+
|
|
13
|
+
## 5.1.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [bd8447d]
|
|
18
|
+
- Updated dependencies [fbd5052]
|
|
19
|
+
- Updated dependencies [d51a577]
|
|
20
|
+
- Updated dependencies [d1ec6a2]
|
|
21
|
+
- Updated dependencies [cf30cc2]
|
|
22
|
+
- Updated dependencies [5b80cfd]
|
|
23
|
+
- Updated dependencies [d548d6b]
|
|
24
|
+
- @object-ui/components@5.1.0
|
|
25
|
+
- @object-ui/react@5.1.0
|
|
26
|
+
- @object-ui/types@5.1.0
|
|
27
|
+
- @object-ui/core@5.1.0
|
|
28
|
+
|
|
29
|
+
## 5.0.2
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- @object-ui/components@5.0.2
|
|
34
|
+
- @object-ui/react@5.0.2
|
|
35
|
+
- @object-ui/types@5.0.2
|
|
36
|
+
- @object-ui/core@5.0.2
|
|
37
|
+
|
|
3
38
|
## 5.0.1
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentRegistry as e } from "@object-ui/core";
|
|
2
2
|
import t, { useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
3
|
import { Badge as a, Button as o, Collapsible as s, CollapsibleContent as c, CollapsibleTrigger as l, Input as u, LazyIcon as d, Separator as f, Sidebar as p, SidebarContent as m, SidebarFooter as h, SidebarGroup as g, SidebarGroupContent as _, SidebarGroupLabel as v, SidebarHeader as y, SidebarInput as b, SidebarInset as x, SidebarMenu as S, SidebarMenuAction as C, SidebarMenuButton as w, SidebarMenuItem as T, SidebarMenuSub as E, SidebarMenuSubButton as D, SidebarMenuSubItem as O, SidebarProvider as k, cn as A, getLazyIcon as j } from "@object-ui/components";
|
|
4
|
-
import { ArrowLeft as M, ChevronRight as
|
|
4
|
+
import { ArrowLeft as M, ChevronRight as N, FileText as P, GripVertical as ee, Layers as te, Pin as ne, PinOff as re, Search as ie, Star as F } from "lucide-react";
|
|
5
5
|
import { SchemaRenderer as I, useRecordContext as ae } from "@object-ui/react";
|
|
6
6
|
import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
7
7
|
import { Link as oe, NavLink as se, useLocation as B } from "react-router-dom";
|
|
@@ -267,7 +267,7 @@ var Te = {
|
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region src/NavigationRenderer.tsx
|
|
269
269
|
function J(e) {
|
|
270
|
-
return e ? j(e) :
|
|
270
|
+
return e ? j(e) : P;
|
|
271
271
|
}
|
|
272
272
|
function Y(e, t) {
|
|
273
273
|
if (typeof e == "string") return e;
|
|
@@ -280,9 +280,14 @@ function Y(e, t) {
|
|
|
280
280
|
}
|
|
281
281
|
return e.defaultValue || e.key;
|
|
282
282
|
}
|
|
283
|
-
function X(e, t, n, r, i) {
|
|
284
|
-
let
|
|
285
|
-
|
|
283
|
+
function X(e, t, n, r, i, a) {
|
|
284
|
+
let o = Y(e.label, n);
|
|
285
|
+
if (typeof e.label != "string") return o;
|
|
286
|
+
if (e.type === "object" && e.objectName) {
|
|
287
|
+
if (e.viewName) return a ? a(e.objectName, e.viewName, o) : o;
|
|
288
|
+
if (t) return t(e.objectName, o);
|
|
289
|
+
}
|
|
290
|
+
return r && e.type === "dashboard" && e.dashboardName ? r(e.dashboardName, o) : i && e.type === "group" && e.id ? i(e.id, o) : o;
|
|
286
291
|
}
|
|
287
292
|
var De = (e) => !(e === !1 || e === "false"), Oe = () => !0, ke = () => !0;
|
|
288
293
|
function Ae(e, t) {
|
|
@@ -316,6 +321,9 @@ function Ae(e, t) {
|
|
|
316
321
|
};
|
|
317
322
|
}
|
|
318
323
|
}
|
|
324
|
+
function je(e, t, n) {
|
|
325
|
+
return t === "#" ? !1 : n === t ? !0 : e.type === "object" && e.objectName ? !(e.viewName || !n.startsWith(`${t}/`) || n.slice(t.length + 1).startsWith("view/")) : n.startsWith(`${t}/`);
|
|
326
|
+
}
|
|
319
327
|
function Z(e, t) {
|
|
320
328
|
if (!t.trim()) return e;
|
|
321
329
|
let n = t.toLowerCase().trim();
|
|
@@ -331,21 +339,21 @@ function Z(e, t) {
|
|
|
331
339
|
return Y(r.label).toLowerCase().includes(n) && e.push(r), e;
|
|
332
340
|
}, []);
|
|
333
341
|
}
|
|
334
|
-
var
|
|
335
|
-
function
|
|
336
|
-
let { attributes:
|
|
342
|
+
var Me = 5;
|
|
343
|
+
function Ne({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, onAction: a, enablePinning: o, onPinToggle: s, enableReorder: c, resolveObjectLabel: l, resolveDashboardLabel: u, resolveGroupLabel: d, resolveViewLabel: f, t: p }) {
|
|
344
|
+
let { attributes: m, listeners: h, setNodeRef: g, transform: _, transition: v, isDragging: y } = ge({
|
|
337
345
|
id: e.id,
|
|
338
346
|
disabled: !c
|
|
339
347
|
});
|
|
340
348
|
return /* @__PURE__ */ R("div", {
|
|
341
|
-
ref:
|
|
349
|
+
ref: g,
|
|
342
350
|
style: {
|
|
343
|
-
transform: ve.Transform.toString(
|
|
344
|
-
transition:
|
|
345
|
-
opacity:
|
|
346
|
-
zIndex:
|
|
351
|
+
transform: ve.Transform.toString(_),
|
|
352
|
+
transition: v,
|
|
353
|
+
opacity: y ? .5 : void 0,
|
|
354
|
+
zIndex: y ? 10 : void 0
|
|
347
355
|
},
|
|
348
|
-
...
|
|
356
|
+
...m,
|
|
349
357
|
children: /* @__PURE__ */ R(Q, {
|
|
350
358
|
item: e,
|
|
351
359
|
basePath: t,
|
|
@@ -355,30 +363,31 @@ function Me({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: i, onAct
|
|
|
355
363
|
onAction: a,
|
|
356
364
|
enablePinning: o,
|
|
357
365
|
onPinToggle: s,
|
|
358
|
-
dragListeners: c ?
|
|
366
|
+
dragListeners: c ? h : void 0,
|
|
359
367
|
resolveObjectLabel: l,
|
|
360
368
|
resolveDashboardLabel: u,
|
|
361
369
|
resolveGroupLabel: d,
|
|
362
|
-
|
|
370
|
+
resolveViewLabel: f,
|
|
371
|
+
t: p
|
|
363
372
|
})
|
|
364
373
|
});
|
|
365
374
|
}
|
|
366
|
-
function Q({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: o, onAction: u, enablePinning: d, onPinToggle: p, dragListeners: m, resolveObjectLabel: h, resolveDashboardLabel: y, resolveGroupLabel: b,
|
|
367
|
-
let
|
|
375
|
+
function Q({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: o, onAction: u, enablePinning: d, onPinToggle: p, dragListeners: m, resolveObjectLabel: h, resolveDashboardLabel: y, resolveGroupLabel: b, resolveViewLabel: x, t: E }) {
|
|
376
|
+
let D = B(), [O, k] = i(e.defaultOpen !== !1);
|
|
368
377
|
if (!n(e.visible) || e.requiredPermissions?.length && !r(e.requiredPermissions)) return null;
|
|
369
|
-
let
|
|
370
|
-
if (
|
|
378
|
+
let A = e.requiresObject, j = e.requiresService;
|
|
379
|
+
if (A && !o("object", A) || j && !o("service", j)) return null;
|
|
371
380
|
if (e.type === "separator") return /* @__PURE__ */ R(f, { className: "my-2" });
|
|
372
381
|
if (e.type === "group") {
|
|
373
382
|
let i = (e.children ?? []).slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0));
|
|
374
383
|
return /* @__PURE__ */ R(s, {
|
|
375
|
-
open:
|
|
376
|
-
onOpenChange:
|
|
384
|
+
open: O,
|
|
385
|
+
onOpenChange: k,
|
|
377
386
|
children: /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ R(v, {
|
|
378
387
|
asChild: !0,
|
|
379
388
|
children: /* @__PURE__ */ z(l, {
|
|
380
389
|
className: "flex w-full items-center justify-between",
|
|
381
|
-
children: [X(e, h,
|
|
390
|
+
children: [X(e, h, E, y, b, x), /* @__PURE__ */ R(N, { className: `ml-auto h-4 w-4 transition-transform ${O ? "rotate-90" : ""}` })]
|
|
382
391
|
})
|
|
383
392
|
}), /* @__PURE__ */ R(c, { children: /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: i.map((e) => /* @__PURE__ */ R(Q, {
|
|
384
393
|
item: e,
|
|
@@ -392,18 +401,19 @@ function Q({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: o, onActi
|
|
|
392
401
|
resolveObjectLabel: h,
|
|
393
402
|
resolveDashboardLabel: y,
|
|
394
403
|
resolveGroupLabel: b,
|
|
395
|
-
|
|
404
|
+
resolveViewLabel: x,
|
|
405
|
+
t: E
|
|
396
406
|
}, e.id)) }) }) })] })
|
|
397
407
|
});
|
|
398
408
|
}
|
|
399
409
|
if (e.type === "action") {
|
|
400
|
-
let t = J(e.icon), n = Y(e.label,
|
|
410
|
+
let t = J(e.icon), n = Y(e.label, E);
|
|
401
411
|
return /* @__PURE__ */ z(T, { children: [
|
|
402
412
|
m && /* @__PURE__ */ R("span", {
|
|
403
413
|
className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
|
|
404
|
-
"aria-label":
|
|
414
|
+
"aria-label": E ? E("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
|
|
405
415
|
...m,
|
|
406
|
-
children: /* @__PURE__ */ R(
|
|
416
|
+
children: /* @__PURE__ */ R(ee, { className: "h-3.5 w-3.5" })
|
|
407
417
|
}),
|
|
408
418
|
/* @__PURE__ */ z(w, {
|
|
409
419
|
tooltip: n,
|
|
@@ -421,17 +431,17 @@ function Q({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: o, onActi
|
|
|
421
431
|
d && p && /* @__PURE__ */ R(C, {
|
|
422
432
|
showOnHover: !0,
|
|
423
433
|
onClick: () => p(e.id, !e.pinned),
|
|
424
|
-
"aria-label":
|
|
434
|
+
"aria-label": E ? E(e.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
|
|
425
435
|
defaultValue: e.pinned ? `Unpin ${n}` : `Pin ${n}`,
|
|
426
436
|
name: n
|
|
427
437
|
}) : e.pinned ? `Unpin ${n}` : `Pin ${n}`,
|
|
428
|
-
children: e.pinned ? /* @__PURE__ */ R(
|
|
438
|
+
children: e.pinned ? /* @__PURE__ */ R(re, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ R(ne, { className: "h-3.5 w-3.5" })
|
|
429
439
|
})
|
|
430
440
|
] });
|
|
431
441
|
}
|
|
432
|
-
let
|
|
433
|
-
/* @__PURE__ */ R(
|
|
434
|
-
/* @__PURE__ */ R("span", { children:
|
|
442
|
+
let M = J(e.icon), { href: P, external: te } = Ae(e, t), ie = je(e, P, D.pathname), F = X(e, h, E, y, b, x), I = /* @__PURE__ */ z(L, { children: [
|
|
443
|
+
/* @__PURE__ */ R(M, { className: "h-4 w-4" }),
|
|
444
|
+
/* @__PURE__ */ R("span", { children: F }),
|
|
435
445
|
e.badge != null && /* @__PURE__ */ R(a, {
|
|
436
446
|
variant: e.badgeVariant ?? "default",
|
|
437
447
|
className: "ml-auto text-[10px] px-1.5 py-0",
|
|
@@ -441,45 +451,45 @@ function Q({ item: e, basePath: t, evalVis: n, checkPerm: r, checkCap: o, onActi
|
|
|
441
451
|
return /* @__PURE__ */ z(T, { children: [
|
|
442
452
|
m && /* @__PURE__ */ R("span", {
|
|
443
453
|
className: "absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground",
|
|
444
|
-
"aria-label":
|
|
454
|
+
"aria-label": E ? E("console.nav.dragToReorder", { defaultValue: "Drag to reorder" }) : "Drag to reorder",
|
|
445
455
|
...m,
|
|
446
|
-
children: /* @__PURE__ */ R(
|
|
456
|
+
children: /* @__PURE__ */ R(ee, { className: "h-3.5 w-3.5" })
|
|
447
457
|
}),
|
|
448
458
|
/* @__PURE__ */ R(w, {
|
|
449
459
|
asChild: !0,
|
|
450
|
-
isActive:
|
|
451
|
-
tooltip:
|
|
452
|
-
children:
|
|
453
|
-
href:
|
|
460
|
+
isActive: ie,
|
|
461
|
+
tooltip: F,
|
|
462
|
+
children: te ? /* @__PURE__ */ R("a", {
|
|
463
|
+
href: P,
|
|
454
464
|
target: "_blank",
|
|
455
465
|
rel: "noopener noreferrer",
|
|
456
|
-
children:
|
|
466
|
+
children: I
|
|
457
467
|
}) : /* @__PURE__ */ R(oe, {
|
|
458
|
-
to:
|
|
459
|
-
children:
|
|
468
|
+
to: P,
|
|
469
|
+
children: I
|
|
460
470
|
})
|
|
461
471
|
}),
|
|
462
472
|
d && p && /* @__PURE__ */ R(C, {
|
|
463
473
|
showOnHover: !0,
|
|
464
474
|
onClick: () => p(e.id, !e.pinned),
|
|
465
|
-
"aria-label":
|
|
466
|
-
defaultValue: e.pinned ? `Unpin ${
|
|
467
|
-
name:
|
|
468
|
-
}) : e.pinned ? `Unpin ${
|
|
469
|
-
children: e.pinned ? /* @__PURE__ */ R(
|
|
475
|
+
"aria-label": E ? E(e.pinned ? "console.nav.unpinItem" : "console.nav.pinItem", {
|
|
476
|
+
defaultValue: e.pinned ? `Unpin ${F}` : `Pin ${F}`,
|
|
477
|
+
name: F
|
|
478
|
+
}) : e.pinned ? `Unpin ${F}` : `Pin ${F}`,
|
|
479
|
+
children: e.pinned ? /* @__PURE__ */ R(re, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ R(ne, { className: "h-3.5 w-3.5" })
|
|
470
480
|
})
|
|
471
481
|
] });
|
|
472
482
|
}
|
|
473
|
-
function $({ items: e, basePath: t = "", evaluateVisibility: n = De, checkPermission: i = Oe, checkCapability: a = ke, onAction: o, searchQuery: s, enablePinning: c, onPinToggle: l, enableReorder: u, onReorder: d, resolveObjectLabel: f, resolveDashboardLabel: p, resolveGroupLabel: m,
|
|
474
|
-
let
|
|
483
|
+
function $({ items: e, basePath: t = "", evaluateVisibility: n = De, checkPermission: i = Oe, checkCapability: a = ke, onAction: o, searchQuery: s, enablePinning: c, onPinToggle: l, enableReorder: u, onReorder: d, resolveObjectLabel: f, resolveDashboardLabel: p, resolveGroupLabel: m, resolveViewLabel: h, t: y }) {
|
|
484
|
+
let b = r(() => s ? Z(e, s) : e, [e, s]), x = r(() => Pe(b), [b]), C = b.slice().sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), w = pe(fe(ue, { activationConstraint: { distance: Me } }), fe(le)), T = (e) => {
|
|
475
485
|
let { active: t, over: n } = e;
|
|
476
486
|
if (!n || t.id === n.id || !d) return;
|
|
477
|
-
let r =
|
|
478
|
-
r === -1 || i === -1 || d(he(
|
|
487
|
+
let r = C.findIndex((e) => e.id === t.id), i = C.findIndex((e) => e.id === n.id);
|
|
488
|
+
r === -1 || i === -1 || d(he(C, r, i).map((e, t) => ({
|
|
479
489
|
...e,
|
|
480
490
|
order: t
|
|
481
491
|
})));
|
|
482
|
-
},
|
|
492
|
+
}, E = {
|
|
483
493
|
basePath: t,
|
|
484
494
|
evalVis: n,
|
|
485
495
|
checkPerm: i,
|
|
@@ -490,61 +500,62 @@ function $({ items: e, basePath: t = "", evaluateVisibility: n = De, checkPermis
|
|
|
490
500
|
resolveObjectLabel: f,
|
|
491
501
|
resolveDashboardLabel: p,
|
|
492
502
|
resolveGroupLabel: m,
|
|
493
|
-
|
|
494
|
-
|
|
503
|
+
resolveViewLabel: h,
|
|
504
|
+
t: y
|
|
505
|
+
}, D = C.some((e) => e.type === "group"), O = x.length > 0 && c ? /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ z(v, {
|
|
495
506
|
className: "flex items-center gap-1.5",
|
|
496
|
-
children: [/* @__PURE__ */ R(F, { className: "h-3.5 w-3.5" }),
|
|
497
|
-
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children:
|
|
507
|
+
children: [/* @__PURE__ */ R(F, { className: "h-3.5 w-3.5" }), y ? y("console.nav.favorites", { defaultValue: "Favorites" }) : "Favorites"]
|
|
508
|
+
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: x.map((e) => /* @__PURE__ */ R(Q, {
|
|
498
509
|
item: e,
|
|
499
|
-
...
|
|
510
|
+
...E
|
|
500
511
|
}, `fav-${e.id}`)) }) })] }) : null;
|
|
501
|
-
if (!
|
|
502
|
-
let e =
|
|
503
|
-
return /* @__PURE__ */ z(L, { children: [
|
|
504
|
-
sensors:
|
|
512
|
+
if (!D) {
|
|
513
|
+
let e = C.filter((e) => e.type !== "group").map((e) => e.id);
|
|
514
|
+
return /* @__PURE__ */ z(L, { children: [O, /* @__PURE__ */ R(g, { children: /* @__PURE__ */ R(_, { children: u ? /* @__PURE__ */ R(ce, {
|
|
515
|
+
sensors: w,
|
|
505
516
|
collisionDetection: de,
|
|
506
|
-
onDragEnd:
|
|
517
|
+
onDragEnd: T,
|
|
507
518
|
children: /* @__PURE__ */ R(me, {
|
|
508
519
|
items: e,
|
|
509
520
|
strategy: _e,
|
|
510
|
-
children: /* @__PURE__ */ R(S, { children:
|
|
521
|
+
children: /* @__PURE__ */ R(S, { children: C.map((e) => /* @__PURE__ */ R(Ne, {
|
|
511
522
|
item: e,
|
|
512
523
|
enableReorder: u,
|
|
513
|
-
...
|
|
524
|
+
...E
|
|
514
525
|
}, e.id)) })
|
|
515
526
|
})
|
|
516
|
-
}) : /* @__PURE__ */ R(S, { children:
|
|
527
|
+
}) : /* @__PURE__ */ R(S, { children: C.map((e) => /* @__PURE__ */ R(Q, {
|
|
517
528
|
item: e,
|
|
518
|
-
...
|
|
529
|
+
...E
|
|
519
530
|
}, e.id)) }) }) })] });
|
|
520
531
|
}
|
|
521
|
-
let
|
|
522
|
-
if (
|
|
523
|
-
let t =
|
|
524
|
-
|
|
532
|
+
let k = [], A = [], j = (e) => {
|
|
533
|
+
if (A.length === 0) return;
|
|
534
|
+
let t = A;
|
|
535
|
+
A = [], k.push(/* @__PURE__ */ R(g, { children: /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: t.map((e) => /* @__PURE__ */ R(Q, {
|
|
525
536
|
item: e,
|
|
526
|
-
...
|
|
537
|
+
...E
|
|
527
538
|
}, e.id)) }) }) }, e));
|
|
528
539
|
};
|
|
529
|
-
return
|
|
530
|
-
e.type === "group" ? (
|
|
540
|
+
return C.forEach((e, t) => {
|
|
541
|
+
e.type === "group" ? (j(`leaf-${t}`), k.push(/* @__PURE__ */ R(Q, {
|
|
531
542
|
item: e,
|
|
532
|
-
...
|
|
533
|
-
}, e.id))) :
|
|
534
|
-
}),
|
|
543
|
+
...E
|
|
544
|
+
}, e.id))) : A.push(e);
|
|
545
|
+
}), j("leaf-end"), /* @__PURE__ */ z(L, { children: [O, k] });
|
|
535
546
|
}
|
|
536
|
-
function
|
|
547
|
+
function Pe(e) {
|
|
537
548
|
let t = [];
|
|
538
|
-
for (let n of e) n.pinned && n.type !== "group" && n.type !== "separator" && t.push(n), n.children?.length && t.push(...
|
|
549
|
+
for (let n of e) n.pinned && n.type !== "group" && n.type !== "separator" && t.push(n), n.children?.length && t.push(...Pe(n.children));
|
|
539
550
|
return t;
|
|
540
551
|
}
|
|
541
552
|
//#endregion
|
|
542
553
|
//#region src/AppSchemaRenderer.tsx
|
|
543
|
-
function
|
|
554
|
+
function Fe({ areas: e, activeAreaId: t, onAreaChange: n, evalVis: r, checkPerm: i }) {
|
|
544
555
|
let a = e.filter((e) => !(!r(e.visible) || e.requiredPermissions?.length && !i(e.requiredPermissions)));
|
|
545
556
|
return a.length <= 1 ? null : /* @__PURE__ */ z(g, { children: [/* @__PURE__ */ z(v, {
|
|
546
557
|
className: "flex items-center gap-1.5",
|
|
547
|
-
children: [/* @__PURE__ */ R(
|
|
558
|
+
children: [/* @__PURE__ */ R(te, { className: "h-3.5 w-3.5" }), "Area"]
|
|
548
559
|
}), /* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: a.map((e) => {
|
|
549
560
|
let r = J(e.icon);
|
|
550
561
|
return /* @__PURE__ */ R(T, { children: /* @__PURE__ */ z(w, {
|
|
@@ -555,7 +566,7 @@ function Pe({ areas: e, activeAreaId: t, onAreaChange: n, evalVis: r, checkPerm:
|
|
|
555
566
|
}) }, e.id);
|
|
556
567
|
}) }) })] });
|
|
557
568
|
}
|
|
558
|
-
function
|
|
569
|
+
function Ie({ items: e, basePath: t }) {
|
|
559
570
|
let n = B(), r = (e) => {
|
|
560
571
|
let t = [];
|
|
561
572
|
for (let n of e) n.type !== "separator" && (n.type === "group" ? t.push(...r(n.children || [])) : t.push(n));
|
|
@@ -580,7 +591,7 @@ function Fe({ items: e, basePath: t }) {
|
|
|
580
591
|
})
|
|
581
592
|
});
|
|
582
593
|
}
|
|
583
|
-
function
|
|
594
|
+
function Le({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onAction: o, sidebarHeader: s, sidebarFooter: c, sidebarExtra: l, activeAreaId: u, setActiveAreaId: d, resolvedNavigation: f, enableSearch: g, enablePinning: _, onPinToggle: v, enableReorder: x, onReorder: C }) {
|
|
584
595
|
let E = J(e.logo), D = e.areas ?? [], [O, k] = i("");
|
|
585
596
|
return /* @__PURE__ */ z(p, {
|
|
586
597
|
collapsible: "icon",
|
|
@@ -612,7 +623,7 @@ function Ie({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onA
|
|
|
612
623
|
"aria-label": "Search navigation"
|
|
613
624
|
})] }),
|
|
614
625
|
/* @__PURE__ */ z(m, { children: [
|
|
615
|
-
D.length > 1 && u && /* @__PURE__ */ R(
|
|
626
|
+
D.length > 1 && u && /* @__PURE__ */ R(Fe, {
|
|
616
627
|
areas: D,
|
|
617
628
|
activeAreaId: u,
|
|
618
629
|
onAreaChange: d,
|
|
@@ -638,7 +649,7 @@ function Ie({ schema: e, basePath: t, evalVis: n, checkPerm: r, checkCap: a, onA
|
|
|
638
649
|
]
|
|
639
650
|
});
|
|
640
651
|
}
|
|
641
|
-
function
|
|
652
|
+
function Re({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluateVisibility: o, checkPermission: s, checkCapability: c, onAction: l, navbar: u, sidebarHeader: d, sidebarFooter: f, sidebarExtra: p, children: m, className: h, defaultOpen: g = !0, enableSearch: _, enablePinning: v, onPinToggle: y, enableReorder: b, onReorder: x }) {
|
|
642
653
|
let S = o ?? ((e) => !(e === !1 || e === "false")), C = s ?? (() => !0), w = c ?? (() => !0), T = r(() => (e.menu ?? []).map((e, t) => ye(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(",");
|
|
643
654
|
n(() => {
|
|
644
655
|
D.length > 0 ? k((e) => D.some((t) => t.id === e) ? e : D[0].id) : k(null);
|
|
@@ -649,7 +660,7 @@ function Le({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluate
|
|
|
649
660
|
logo: e.logo
|
|
650
661
|
};
|
|
651
662
|
return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(q, {
|
|
652
|
-
sidebar: /* @__PURE__ */ R(
|
|
663
|
+
sidebar: /* @__PURE__ */ R(Le, {
|
|
653
664
|
schema: e,
|
|
654
665
|
basePath: t,
|
|
655
666
|
evalVis: S,
|
|
@@ -673,16 +684,16 @@ function Le({ schema: e, basePath: t = "", mobileNavMode: a = "drawer", evaluate
|
|
|
673
684
|
defaultOpen: g,
|
|
674
685
|
branding: M,
|
|
675
686
|
children: m
|
|
676
|
-
}), a === "bottom_nav" && /* @__PURE__ */ R(
|
|
687
|
+
}), a === "bottom_nav" && /* @__PURE__ */ R(Ie, {
|
|
677
688
|
items: j,
|
|
678
689
|
basePath: t
|
|
679
690
|
})] });
|
|
680
691
|
}
|
|
681
692
|
//#endregion
|
|
682
693
|
//#region src/Page.tsx
|
|
683
|
-
var
|
|
684
|
-
function
|
|
685
|
-
let a =
|
|
694
|
+
var ze = (e) => e ? Array.isArray(e) ? e : [e] : [];
|
|
695
|
+
function Be({ schema: e, className: t, style: n, id: r, ...i }) {
|
|
696
|
+
let a = ze(e.children);
|
|
686
697
|
return /* @__PURE__ */ z("div", {
|
|
687
698
|
id: r || e.id,
|
|
688
699
|
className: A("flex flex-col h-full space-y-4", t),
|
|
@@ -701,10 +712,10 @@ function ze({ schema: e, className: t, style: n, id: r, ...i }) {
|
|
|
701
712
|
}
|
|
702
713
|
//#endregion
|
|
703
714
|
//#region src/SidebarNav.tsx
|
|
704
|
-
function
|
|
715
|
+
function Ve(e) {
|
|
705
716
|
return "items" in e && !("href" in e);
|
|
706
717
|
}
|
|
707
|
-
function
|
|
718
|
+
function He({ item: e, pathname: t }) {
|
|
708
719
|
return e.children && e.children.length > 0 ? /* @__PURE__ */ R(s, {
|
|
709
720
|
asChild: !0,
|
|
710
721
|
defaultOpen: !0,
|
|
@@ -721,7 +732,7 @@ function Ve({ item: e, pathname: t }) {
|
|
|
721
732
|
className: "ml-auto mr-1 h-5 min-w-5 px-1 text-xs",
|
|
722
733
|
children: e.badge
|
|
723
734
|
}),
|
|
724
|
-
/* @__PURE__ */ R(
|
|
735
|
+
/* @__PURE__ */ R(N, { className: "ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
|
|
725
736
|
]
|
|
726
737
|
})
|
|
727
738
|
}), /* @__PURE__ */ R(c, { children: /* @__PURE__ */ R(E, { children: e.children.map((e) => /* @__PURE__ */ R(O, { children: /* @__PURE__ */ R(D, {
|
|
@@ -758,8 +769,8 @@ function Ve({ item: e, pathname: t }) {
|
|
|
758
769
|
})
|
|
759
770
|
}) });
|
|
760
771
|
}
|
|
761
|
-
function
|
|
762
|
-
let s = B(), [c, l] = t.useState(""), d = t.useMemo(() => e.length === 0 ? [] :
|
|
772
|
+
function Ue({ items: e, title: n = "Application", className: r, collapsible: i = "icon", searchEnabled: a = !1, searchPlaceholder: o = "Search…" }) {
|
|
773
|
+
let s = B(), [c, l] = t.useState(""), d = t.useMemo(() => e.length === 0 ? [] : Ve(e[0]) ? e.map((e) => ({
|
|
763
774
|
groupLabel: e.label,
|
|
764
775
|
items: e.items
|
|
765
776
|
})) : [{ items: e }], [e]), f = t.useMemo(() => {
|
|
@@ -777,7 +788,7 @@ function He({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
777
788
|
className: "px-3 py-2",
|
|
778
789
|
children: /* @__PURE__ */ z("div", {
|
|
779
790
|
className: "relative",
|
|
780
|
-
children: [/* @__PURE__ */ R(
|
|
791
|
+
children: [/* @__PURE__ */ R(ie, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" }), /* @__PURE__ */ R(u, {
|
|
781
792
|
type: "search",
|
|
782
793
|
placeholder: o,
|
|
783
794
|
value: c,
|
|
@@ -794,7 +805,7 @@ function He({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
794
805
|
className: "text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60",
|
|
795
806
|
children: e.groupLabel || n
|
|
796
807
|
}),
|
|
797
|
-
/* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: e.items.map((e) => /* @__PURE__ */ R(
|
|
808
|
+
/* @__PURE__ */ R(_, { children: /* @__PURE__ */ R(S, { children: e.items.map((e) => /* @__PURE__ */ R(He, {
|
|
798
809
|
item: e,
|
|
799
810
|
pathname: s.pathname
|
|
800
811
|
}, e.href)) }) })
|
|
@@ -803,7 +814,7 @@ function He({ items: e, title: n = "Application", className: r, collapsible: i =
|
|
|
803
814
|
}
|
|
804
815
|
//#endregion
|
|
805
816
|
//#region src/index.ts
|
|
806
|
-
function
|
|
817
|
+
function We() {
|
|
807
818
|
e.register("page-header", H, {
|
|
808
819
|
namespace: "layout",
|
|
809
820
|
label: "Page Header",
|
|
@@ -847,7 +858,7 @@ function Ue() {
|
|
|
847
858
|
name: "basePath",
|
|
848
859
|
type: "string"
|
|
849
860
|
}]
|
|
850
|
-
}), e.register("app-schema-renderer",
|
|
861
|
+
}), e.register("app-schema-renderer", Re, {
|
|
851
862
|
namespace: "layout",
|
|
852
863
|
label: "App Schema Renderer",
|
|
853
864
|
category: "Layout",
|
|
@@ -869,7 +880,7 @@ function Ue() {
|
|
|
869
880
|
});
|
|
870
881
|
}
|
|
871
882
|
try {
|
|
872
|
-
|
|
883
|
+
We();
|
|
873
884
|
} catch {}
|
|
874
885
|
//#endregion
|
|
875
|
-
export {
|
|
886
|
+
export { Re as AppSchemaRenderer, q as AppShell, $ as NavigationRenderer, Be as Page, Se as PageCard, H as PageHeader, Ee as ResponsiveGrid, Ue as SidebarNav, Z as filterNavigationItems, We as registerLayout, J as resolveIcon, Y as resolveLabel, xe 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){let a=P(e.label,n);return typeof e.label==`string`?t&&e.type===`object`&&e.objectName?t(e.objectName,a):r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,a):i&&e.type===`group`&&e.id?i(e.id,a):a:a}var I=e=>!(e===!1||e===`false`),L=()=>!0,R=()=>!0;function z(e,t){switch(e.type){case`object`:{let n=`${t}/${e.objectName??``}`;return{href:e.viewName?`${n}/view/${e.viewName}`:n,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:return{href:e.pageName?`${t}/page/${e.pageName}`:`#`,external:!1};case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};default:return{href:`#`,external:!1}}}function B(e,t){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=B(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 V=5;function H({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,t:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=(0,l.useSortable)({id:e.id,disabled:!d});return(0,o.jsx)(`div`,{ref:v,style:{transform:u.CSS.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,o.jsx)(U,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?_:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,t:h})})}function U({item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,t:_}){let v=(0,s.useLocation)(),[y,b]=(0,n.useState)(e.defaultOpen!==!1);if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let x=e.requiresObject,S=e.requiresService;if(x&&!l(`object`,x)||S&&!l(`service`,S))return null;if(e.type===`separator`)return(0,o.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,o.jsx)(r.Collapsible,{open:y,onOpenChange:b,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:`flex w-full items-center justify-between`,children:[F(e,m,_,h,g),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform ${y?`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)(U,{item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,t:_},e.id))})})})]})})}if(e.type===`action`){let t=N(e.icon),n=P(e.label,_);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":_?_(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsxs)(r.SidebarMenuButton,{tooltip:n,onClick:()=>u?.(e),children:[(0,o.jsx)(t,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:n}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned),"aria-label":_?_(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${n}`:`Pin ${n}`,name:n}):e.pinned?`Unpin ${n}`:`Pin ${n}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}let C=N(e.icon),{href:w,external:T}=z(e,t),E=w!==`#`&&v.pathname.startsWith(w),D=F(e,m,_,h,g),O=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(C,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:D}),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":_?_(`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:E,tooltip:D,children:T?(0,o.jsx)(`a`,{href:w,target:`_blank`,rel:`noopener noreferrer`,children:O}):(0,o.jsx)(s.Link,{to:w,children:O})}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned),"aria-label":_?_(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${D}`:`Pin ${D}`,name:D}):e.pinned?`Unpin ${D}`:`Pin ${D}`,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 W({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,t:b}){let x=(0,n.useMemo)(()=>f?B(e,f):e,[e,f]),S=(0,n.useMemo)(()=>G(x),[x]),C=x.slice().sort((e,t)=>(e.order??0)-(t.order??0)),w=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:V}}),(0,c.useSensor)(c.KeyboardSensor)),T=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!g)return;let r=C.findIndex(e=>e.id===t.id),i=C.findIndex(e=>e.id===n.id);r===-1||i===-1||g((0,l.arrayMove)(C,r,i).map((e,t)=>({...e,order:t})))},E={basePath:t,evalVis:a,checkPerm:s,checkCap:u,onAction:d,enablePinning:p,onPinToggle:m,resolveObjectLabel:_,resolveDashboardLabel:v,resolveGroupLabel:y,t:b},D=C.some(e=>e.type===`group`),O=S.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`}),b?b(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:S.map(e=>(0,o.jsx)(U,{item:e,...E},`fav-${e.id}`))})})]}):null;if(!D){let e=C.filter(e=>e.type!==`group`).map(e=>e.id);return(0,o.jsxs)(o.Fragment,{children:[O,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:h?(0,o.jsx)(c.DndContext,{sensors:w,collisionDetection:c.closestCenter,onDragEnd:T,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:C.map(e=>(0,o.jsx)(H,{item:e,enableReorder:h,...E},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:C.map(e=>(0,o.jsx)(U,{item:e,...E},e.id))})})})]})}let k=[],A=[],j=e=>{if(A.length===0)return;let t=A;A=[],k.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)(U,{item:e,...E},e.id))})})},e))};return C.forEach((e,t)=>{e.type===`group`?(j(`leaf-${t}`),k.push((0,o.jsx)(U,{item:e,...E},e.id))):A.push(e)}),j(`leaf-end`),(0,o.jsxs)(o.Fragment,{children:[O,k]})}function G(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...G(n.children));return t}function K({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 q({items:e,basePath:t}){let n=(0,s.useLocation)(),r=e=>{let t=[];for(let n of e)n.type!==`separator`&&(n.type===`group`?t.push(...r(n.children||[])):t.push(n));return t},i=r(e).slice(0,5);return i.length===0?null:(0,o.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,role:`navigation`,"aria-label":`Mobile navigation`,children:i.map(e=>{let r=N(e.icon),i=`#`;e.type===`object`?(i=`${t}/${e.objectName}`,e.viewName&&(i+=`/view/${e.viewName}`)):e.type===`dashboard`?i=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`:e.type===`page`?i=e.pageName?`${t}/page/${e.pageName}`:`#`:e.type===`report`?i=e.reportName?`${t}/report/${e.reportName}`:`#`:e.type===`url`&&(i=e.url??`#`);let a=i!==`#`&&n.pathname.startsWith(i);return(0,o.jsxs)(s.Link,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,o.jsx)(r,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:P(e.label)})]},e.id)})})}function J({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)(K,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:i,checkPerm:a}),(0,o.jsx)(W,{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 Y({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)(J,{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)(q,{items:M,basePath:t})]})}var X=e=>e?Array.isArray(e)?e:[e]:[];function Z({schema:e,className:t,style:n,id:i,...s}){let c=X(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 Q(e){return`items`in e&&!(`href`in e)}function ee({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,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,{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,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,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 te({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?[]:Q(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)(ee,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function $(){t.ComponentRegistry.register(`page-header`,x,{namespace:`layout`,label:`Page Header`,category:`Layout`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`}]}),t.ComponentRegistry.register(`page:card`,O,{namespace:`layout`,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,D,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,M,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,W,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`object`},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,Y,{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=Y,e.AppShell=D,e.NavigationRenderer=W,e.Page=Z,e.PageCard=O,e.PageHeader=x,e.ResponsiveGrid=M,e.SidebarNav=te,e.filterNavigationItems=B,e.registerLayout=$,e.resolveIcon=N,e.resolveLabel=P,e.useAppShellBranding=E});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`@object-ui/react`),require(`react/jsx-runtime`),require(`react-router-dom`),require(`@dnd-kit/core`),require(`@dnd-kit/sortable`),require(`@dnd-kit/utilities`),require(`@object-ui/types`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`react/jsx-runtime`,`react-router-dom`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUILayout={},e._object_ui_core,e.react,e._object_ui_components,e.lucide_react,e._object_ui_react,e.react_jsx_runtime,e.react_router_dom,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e._object_ui_types))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var y=e=>{let t=e?.name??e?.full_name??e?.display_name??e?.label??e?.title??e?.subject;return t!=null&&String(t).trim()?String(t):[e?.salutation,e?.first_name,e?.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e?.email==`string`&&e.email.trim()?e.email.trim():null)},b=(e,t)=>!e||typeof e!=`string`?e??``:e.includes(`{`)?e.replace(/\{([a-zA-Z0-9_.]+)\}/g,(e,n)=>{let r=n.split(`.`).reduce((e,t)=>e==null?e:e[t],t);return r==null?``:typeof r==`object`?y(r)??``:String(r)}).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g,``).replace(/^\s*[-–—|/·,:]\s*/,``).replace(/\s+/g,` `).trim():e;function x({title:e,subtitle:t,description:s,icon:c,action:l,actions:u,showBack:d,schema:f,className:p,children:m,...h}){let g=(0,a.useRecordContext)(),_=typeof e==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(e),v=b(e,g?.data)||(_?``:e),y=t??s,x=typeof y==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(y),S=b(y,g?.data)||(x?``:y),C=!!g?.recordId,w=!!g?.embedded,T=d??(C&&!w),E=n.default.useCallback(()=>{if(typeof window>`u`)return;let e=window.location.pathname,t=e.replace(/\/record\/[^/]+\/?$/,``);t===e?window.history.length>1&&window.history.back():(window.history.pushState({},``,t+window.location.search),window.dispatchEvent(new PopStateEvent(`popstate`)))},[]),D=Array.isArray(f?.children)?f.children.filter(Boolean).map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e},e?.id||`pgh-child-${t}`)):null,O=Array.isArray(u)&&u.length>0&&u||Array.isArray(f?.actions)&&f.actions.length>0&&f.actions||Array.isArray(f?.properties?.actions)&&f.properties.actions.length>0&&f.properties.actions||null,k=l||m||(O?(0,o.jsx)(a.SchemaRenderer,{schema:{type:`record:quick_actions`,properties:{actions:O,location:`record_header`,align:`end`,inline:!0}}}):null)||D;return(0,o.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-3 pb-4 border-b`,p),...h,children:(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[T&&(0,o.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:E,"aria-label":`Back to list`,className:`flex-shrink-0 -ml-2`,children:(0,o.jsx)(i.ArrowLeft,{className:`size-4`})}),c&&(v||S)&&(0,o.jsx)(`div`,{className:`flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary`,children:typeof c==`string`?(0,o.jsx)(r.LazyIcon,{name:c,className:`size-5`}):c}),(0,o.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[v?(0,o.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:v}):null,S&&(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:S})]}),k&&(0,o.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:k})]})})}function S(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function C(e){let t=S(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function w(e){let t=S(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function T(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function E(e,t){(0,n.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=C(e.primaryColor),i=w(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:T(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=C(e.accentColor),i=w(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:T(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function D({sidebar:e,navbar:t,children:n,className:i,defaultOpen:a=!0,branding:s}){return E(s,s?.title),(0,o.jsxs)(r.SidebarProvider,{defaultOpen:a,className:`!flex-col h-svh overflow-hidden`,children:[(0,o.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,o.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,o.jsx)(r.SidebarInset,{className:`min-w-0`,children:(0,o.jsx)(`main`,{className:(0,r.cn)(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,i),children:n})})]})]})}function O({className:e,children:t,...n}){return(0,o.jsx)(`div`,{className:(0,r.cn)(`rounded-xl border bg-card text-card-foreground shadow`,e),...n,children:(0,o.jsx)(`div`,{className:`p-6`,children:t})})}var k={xs:{1:`grid-cols-1`,2:`grid-cols-2`,3:`grid-cols-3`,4:`grid-cols-4`,6:`grid-cols-6`,12:`grid-cols-12`},sm:{1:`sm:grid-cols-1`,2:`sm:grid-cols-2`,3:`sm:grid-cols-3`,4:`sm:grid-cols-4`,6:`sm:grid-cols-6`,12:`sm:grid-cols-12`},md:{1:`md:grid-cols-1`,2:`md:grid-cols-2`,3:`md:grid-cols-3`,4:`md:grid-cols-4`,6:`md:grid-cols-6`,12:`md:grid-cols-12`},lg:{1:`lg:grid-cols-1`,2:`lg:grid-cols-2`,3:`lg:grid-cols-3`,4:`lg:grid-cols-4`,6:`lg:grid-cols-6`,12:`lg:grid-cols-12`},xl:{1:`xl:grid-cols-1`,2:`xl:grid-cols-2`,3:`xl:grid-cols-3`,4:`xl:grid-cols-4`,6:`xl:grid-cols-6`,12:`xl:grid-cols-12`},"2xl":{1:`2xl:grid-cols-1`,2:`2xl:grid-cols-2`,3:`2xl:grid-cols-3`,4:`2xl:grid-cols-4`,6:`2xl:grid-cols-6`,12:`2xl:grid-cols-12`}};function A(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=k[n];if(e&&r){let n=Object.keys(e).map(Number).reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e);t.push(e[n])}}return t.join(` `)||`grid-cols-1`}var j={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},M=({columns:e,gap:t=4,className:n,children:i})=>(0,o.jsx)(`div`,{className:(0,r.cn)(`grid`,A(e),typeof t==`number`?j[t]||`gap-${t}`:``,n),children:i});function N(e){return e?(0,r.getLazyIcon)(e):i.FileText}function P(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function F(e,t,n,r,i,a){let o=P(e.label,n);if(typeof e.label!=`string`)return o;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,o):o;if(t)return t(e.objectName,o)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,o):i&&e.type===`group`&&e.id?i(e.id,o):o}var I=e=>!(e===!1||e===`false`),L=()=>!0,R=()=>!0;function z(e,t){switch(e.type){case`object`:{let n=`${t}/${e.objectName??``}`;return{href:e.viewName?`${n}/view/${e.viewName}`:n,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:return{href:e.pageName?`${t}/page/${e.pageName}`:`#`,external:!1};case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};default:return{href:`#`,external:!1}}}function B(e,t,n){return t===`#`?!1:n===t?!0:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function V(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=V(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return P(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var H=5;function U({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,t:g}){let{attributes:_,listeners:v,setNodeRef:y,transform:b,transition:x,isDragging:S}=(0,l.useSortable)({id:e.id,disabled:!d});return(0,o.jsx)(`div`,{ref:y,style:{transform:u.CSS.Transform.toString(b),transition:x,opacity:S?.5:void 0,zIndex:S?10:void 0},..._,children:(0,o.jsx)(W,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?v:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,t:g})})}function W({item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,t:v}){let y=(0,s.useLocation)(),[b,x]=(0,n.useState)(e.defaultOpen!==!1);if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let S=e.requiresObject,C=e.requiresService;if(S&&!l(`object`,S)||C&&!l(`service`,C))return null;if(e.type===`separator`)return(0,o.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,o.jsx)(r.Collapsible,{open:b,onOpenChange:x,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:`flex w-full items-center justify-between`,children:[F(e,m,v,h,g,_),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform ${b?`rotate-90`:``}`})]})}),(0,o.jsx)(r.CollapsibleContent,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:n.map(e=>(0,o.jsx)(W,{item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,t:v},e.id))})})})]})})}if(e.type===`action`){let t=N(e.icon),n=P(e.label,v);return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":v?v(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsxs)(r.SidebarMenuButton,{tooltip:n,onClick:()=>u?.(e),children:[(0,o.jsx)(t,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:n}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned),"aria-label":v?v(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${n}`:`Pin ${n}`,name:n}):e.pinned?`Unpin ${n}`:`Pin ${n}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}let w=N(e.icon),{href:T,external:E}=z(e,t),D=B(e,T,y.pathname),O=F(e,m,v,h,g,_),k=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(w,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:O}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":v?v(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:D,tooltip:O,children:E?(0,o.jsx)(`a`,{href:T,target:`_blank`,rel:`noopener noreferrer`,children:k}):(0,o.jsx)(s.Link,{to:T,children:k})}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned),"aria-label":v?v(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${O}`:`Pin ${O}`,name:O}):e.pinned?`Unpin ${O}`:`Pin ${O}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}function G({items:e,basePath:t=``,evaluateVisibility:a=I,checkPermission:s=L,checkCapability:u=R,onAction:d,searchQuery:f,enablePinning:p,onPinToggle:m,enableReorder:h,onReorder:g,resolveObjectLabel:_,resolveDashboardLabel:v,resolveGroupLabel:y,resolveViewLabel:b,t:x}){let S=(0,n.useMemo)(()=>f?V(e,f):e,[e,f]),C=(0,n.useMemo)(()=>K(S),[S]),w=S.slice().sort((e,t)=>(e.order??0)-(t.order??0)),T=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:H}}),(0,c.useSensor)(c.KeyboardSensor)),E=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!g)return;let r=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||g((0,l.arrayMove)(w,r,i).map((e,t)=>({...e,order:t})))},D={basePath:t,evalVis:a,checkPerm:s,checkCap:u,onAction:d,enablePinning:p,onPinToggle:m,resolveObjectLabel:_,resolveDashboardLabel:v,resolveGroupLabel:y,resolveViewLabel:b,t:x},O=w.some(e=>e.type===`group`),k=C.length>0&&p?(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Star,{className:`h-3.5 w-3.5`}),x?x(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:C.map(e=>(0,o.jsx)(W,{item:e,...D},`fav-${e.id}`))})})]}):null;if(!O){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,o.jsxs)(o.Fragment,{children:[k,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:h?(0,o.jsx)(c.DndContext,{sensors:T,collisionDetection:c.closestCenter,onDragEnd:E,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:w.map(e=>(0,o.jsx)(U,{item:e,enableReorder:h,...D},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:w.map(e=>(0,o.jsx)(W,{item:e,...D},e.id))})})})]})}let A=[],j=[],M=e=>{if(j.length===0)return;let t=j;j=[],A.push((0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:t.map(e=>(0,o.jsx)(W,{item:e,...D},e.id))})})},e))};return w.forEach((e,t)=>{e.type===`group`?(M(`leaf-${t}`),A.push((0,o.jsx)(W,{item:e,...D},e.id))):j.push(e)}),M(`leaf-end`),(0,o.jsxs)(o.Fragment,{children:[k,A]})}function K(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...K(n.children));return t}function q({areas:e,activeAreaId:t,onAreaChange:n,evalVis:a,checkPerm:s}){let c=e.filter(e=>!(!a(e.visible)||e.requiredPermissions?.length&&!s(e.requiredPermissions)));return c.length<=1?null:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Layers,{className:`h-3.5 w-3.5`}),`Area`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:c.map(e=>{let i=N(e.icon);return(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:P(e.label),onClick:()=>n(e.id),children:[(0,o.jsx)(i,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:P(e.label)})]})},e.id)})})})]})}function J({items:e,basePath:t}){let n=(0,s.useLocation)(),r=e=>{let t=[];for(let n of e)n.type!==`separator`&&(n.type===`group`?t.push(...r(n.children||[])):t.push(n));return t},i=r(e).slice(0,5);return i.length===0?null:(0,o.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,role:`navigation`,"aria-label":`Mobile navigation`,children:i.map(e=>{let r=N(e.icon),i=`#`;e.type===`object`?(i=`${t}/${e.objectName}`,e.viewName&&(i+=`/view/${e.viewName}`)):e.type===`dashboard`?i=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`:e.type===`page`?i=e.pageName?`${t}/page/${e.pageName}`:`#`:e.type===`report`?i=e.reportName?`${t}/report/${e.reportName}`:`#`:e.type===`url`&&(i=e.url??`#`);let a=i!==`#`&&n.pathname.startsWith(i);return(0,o.jsxs)(s.Link,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,o.jsx)(r,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:P(e.label)})]},e.id)})})}function Y({schema:e,basePath:t,evalVis:i,checkPerm:a,checkCap:s,onAction:c,sidebarHeader:l,sidebarFooter:u,sidebarExtra:d,activeAreaId:f,setActiveAreaId:p,resolvedNavigation:m,enableSearch:h,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}){let b=N(e.logo),x=e.areas??[],[S,C]=(0,n.useState)(``);return(0,o.jsxs)(r.Sidebar,{collapsible:`icon`,children:[(0,o.jsxs)(r.SidebarHeader,{children:[l??(0,o.jsx)(r.SidebarMenu,{children:(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{size:`lg`,tooltip:e.title??e.name,children:[(0,o.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground`,children:e.logo&&e.logo.startsWith(`http`)?(0,o.jsx)(`img`,{src:e.logo,alt:e.title??``,className:`size-6 object-contain`}):(0,o.jsx)(b,{className:`size-4`})}),(0,o.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,o.jsx)(`span`,{className:`truncate font-semibold`,children:e.title??e.name??`App`}),e.description&&(0,o.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]})]})})}),h&&(0,o.jsx)(r.SidebarInput,{placeholder:`Search navigation…`,value:S,onChange:e=>C(e.target.value),"aria-label":`Search navigation`})]}),(0,o.jsxs)(r.SidebarContent,{children:[x.length>1&&f&&(0,o.jsx)(q,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:i,checkPerm:a}),(0,o.jsx)(G,{items:m,basePath:t,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,searchQuery:S,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}),d]}),u&&(0,o.jsx)(r.SidebarFooter,{children:u})]})}function X({schema:e,basePath:t=``,mobileNavMode:r=`drawer`,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,navbar:l,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,children:m,className:h,defaultOpen:g=!0,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=i??(e=>!(e===!1||e===`false`)),C=a??(()=>!0),w=s??(()=>!0),T=(0,n.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,d.menuItemToNavigationItem)(e,t)),[e.menu]),E=e.navigation??T,O=e.areas??[],[k,A]=(0,n.useState)(()=>O.length>0?O[0].id:null),j=O.map(e=>e.id).join(`,`);(0,n.useEffect)(()=>{O.length>0?A(e=>O.some(t=>t.id===e)?e:O[0].id):A(null)},[e.name,j]);let M=O.find(e=>e.id===k)?.navigation??E,N={title:e.title,favicon:e.favicon,logo:e.logo};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(D,{sidebar:(0,o.jsx)(Y,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,activeAreaId:k,setActiveAreaId:A,resolvedNavigation:M,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}),navbar:l,className:h,defaultOpen:g,branding:N,children:m}),r===`bottom_nav`&&(0,o.jsx)(J,{items:M,basePath:t})]})}var Z=e=>e?Array.isArray(e)?e:[e]:[];function Q({schema:e,className:t,style:n,id:i,...s}){let c=Z(e.children);return(0,o.jsxs)(`div`,{id:i||e.id,className:(0,r.cn)(`flex flex-col h-full space-y-4`,t),style:n,children:[(0,o.jsx)(x,{title:e.title,description:e.description}),(0,o.jsx)(`div`,{className:`flex-1 overflow-auto`,children:c.map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e,...s},e?.id||t))})]})}function ee(e){return`items`in e&&!(`href`in e)}function te({item:e,pathname:t}){return e.children&&e.children.length>0?(0,o.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,o.jsxs)(r.SidebarMenuItem,{children:[(0,o.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,o.jsxs)(r.SidebarMenuButton,{tooltip:e.title,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,{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,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,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function ne({items:e,title:t=`Application`,className:a,collapsible:c=`icon`,searchEnabled:l=!1,searchPlaceholder:u=`Search…`}){let d=(0,s.useLocation)(),[f,p]=n.default.useState(``),m=n.default.useMemo(()=>e.length===0?[]:ee(e[0])?e.map(e=>({groupLabel:e.label,items:e.items})):[{items:e}],[e]),h=n.default.useMemo(()=>{if(!f)return m;let e=f.toLowerCase();return m.map(t=>({...t,items:t.items.filter(t=>t.title.toLowerCase().includes(e)||t.children?.some(t=>t.title.toLowerCase().includes(e)))})).filter(e=>e.items.length>0)},[m,f]);return(0,o.jsx)(r.Sidebar,{className:a,collapsible:c,children:(0,o.jsxs)(r.SidebarContent,{children:[l&&(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(i.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,o.jsx)(r.Input,{type:`search`,placeholder:u,value:f,onChange:e=>p(e.target.value),className:`pl-8 h-9`})]})}),h.map((e,n)=>(0,o.jsxs)(r.SidebarGroup,{children:[n>0&&(0,o.jsx)(`div`,{className:`mx-3 mb-1 h-px bg-sidebar-border/60`,"aria-hidden":!0}),(0,o.jsx)(r.SidebarGroupLabel,{className:`text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60`,children:e.groupLabel||t}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:e.items.map(e=>(0,o.jsx)(te,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function $(){t.ComponentRegistry.register(`page-header`,x,{namespace:`layout`,label:`Page Header`,category:`Layout`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`}]}),t.ComponentRegistry.register(`page:card`,O,{namespace:`layout`,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,D,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,M,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,G,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`object`},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,X,{namespace:`layout`,label:`App Schema Renderer`,category:`Layout`,isContainer:!0,inputs:[{name:`schema`,type:`object`},{name:`basePath`,type:`string`},{name:`mobileNavMode`,type:`string`}]})}try{$()}catch{}e.AppSchemaRenderer=X,e.AppShell=D,e.NavigationRenderer=G,e.Page=Q,e.PageCard=O,e.PageHeader=x,e.ResponsiveGrid=M,e.SidebarNav=ne,e.filterNavigationItems=V,e.registerLayout=$,e.resolveIcon=N,e.resolveLabel=P,e.useAppShellBranding=E});
|
|
@@ -69,6 +69,19 @@ export interface NavigationRendererProps {
|
|
|
69
69
|
* `useObjectLabel().dashboardLabel`.
|
|
70
70
|
*/
|
|
71
71
|
resolveDashboardLabel?: (dashboardName: string, fallbackLabel: string) => string;
|
|
72
|
+
/**
|
|
73
|
+
* Optional label resolver for object-type navigation items that target a
|
|
74
|
+
* specific view (i.e. `viewName` is set). Called with
|
|
75
|
+
* `(objectName, viewName, fallbackLabel)`. Mirrors
|
|
76
|
+
* `useObjectLabel().viewLabel` and resolves
|
|
77
|
+
* `{ns}.objects.{objectName}._views.{viewName}.label`.
|
|
78
|
+
*
|
|
79
|
+
* Without this resolver, an object item with a `viewName` falls back to
|
|
80
|
+
* its schema-provided explicit label (which keeps it distinct from a bare
|
|
81
|
+
* object-list entry under the same group — avoids visual duplicates such
|
|
82
|
+
* as two `商机` rows where one is the list and the other is a Kanban view).
|
|
83
|
+
*/
|
|
84
|
+
resolveViewLabel?: (objectName: string, viewName: string, fallbackLabel: string) => string;
|
|
72
85
|
/**
|
|
73
86
|
* Optional label resolver for navigation group items.
|
|
74
87
|
* Called with `(groupId, fallbackLabel)` for items where
|
|
@@ -134,4 +147,4 @@ export declare function filterNavigationItems(items: NavigationItem[], query: st
|
|
|
134
147
|
* />
|
|
135
148
|
* ```
|
|
136
149
|
*/
|
|
137
|
-
export declare function NavigationRenderer({ items, basePath, evaluateVisibility: evalVis, checkPermission: checkPerm, checkCapability: checkCap, onAction, searchQuery, enablePinning, onPinToggle, enableReorder, onReorder, resolveObjectLabel, resolveDashboardLabel, resolveGroupLabel, t: tProp, }: NavigationRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
150
|
+
export declare function NavigationRenderer({ items, basePath, evaluateVisibility: evalVis, checkPermission: checkPerm, checkCapability: checkCap, onAction, searchQuery, enablePinning, onPinToggle, enableReorder, onReorder, resolveObjectLabel, resolveDashboardLabel, resolveGroupLabel, resolveViewLabel, t: tProp, }: NavigationRendererProps): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/layout",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.umd.cjs",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"react": "19.2.6",
|
|
23
23
|
"react-dom": "19.2.6",
|
|
24
24
|
"tailwind-merge": "^3.6.0",
|
|
25
|
-
"@object-ui/components": "5.
|
|
26
|
-
"@object-ui/core": "5.
|
|
27
|
-
"@object-ui/react": "5.
|
|
28
|
-
"@object-ui/types": "5.
|
|
25
|
+
"@object-ui/components": "5.1.1",
|
|
26
|
+
"@object-ui/core": "5.1.1",
|
|
27
|
+
"@object-ui/react": "5.1.1",
|
|
28
|
+
"@object-ui/types": "5.1.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|