@object-ui/layout 4.0.11 → 4.0.12
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 +9 -0
- package/dist/index.js +8 -4
- package/dist/index.umd.cjs +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -125,7 +125,7 @@ function J({ sidebar: e, navbar: t, children: n, className: r, defaultOpen: i =
|
|
|
125
125
|
children: [e, /* @__PURE__ */ j(y, {
|
|
126
126
|
className: "min-w-0",
|
|
127
127
|
children: /* @__PURE__ */ j("main", {
|
|
128
|
-
className: O("flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6", r),
|
|
128
|
+
className: O("flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6", r),
|
|
129
129
|
children: n
|
|
130
130
|
})
|
|
131
131
|
})]
|
|
@@ -513,12 +513,16 @@ function Oe({ areas: e, activeAreaId: t, onAreaChange: n, evalVis: r, checkPerm:
|
|
|
513
513
|
}) }) })] });
|
|
514
514
|
}
|
|
515
515
|
function ke({ items: e, basePath: t }) {
|
|
516
|
-
let n = F(), r =
|
|
517
|
-
|
|
516
|
+
let n = F(), r = (e) => {
|
|
517
|
+
let t = [];
|
|
518
|
+
for (let n of e) n.type !== "separator" && (n.type === "group" ? t.push(...r(n.children || [])) : t.push(n));
|
|
519
|
+
return t;
|
|
520
|
+
}, i = r(e).slice(0, 5);
|
|
521
|
+
return i.length === 0 ? null : /* @__PURE__ */ j("div", {
|
|
518
522
|
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",
|
|
519
523
|
role: "navigation",
|
|
520
524
|
"aria-label": "Mobile navigation",
|
|
521
|
-
children:
|
|
525
|
+
children: i.map((e) => {
|
|
522
526
|
let r = Y(e.icon), i = "#";
|
|
523
527
|
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 ?? "#");
|
|
524
528
|
let a = i !== "#" && n.pathname.startsWith(i);
|
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(`react/jsx-runtime`),require(`react-router-dom`),require(`lucide-react`),require(`@dnd-kit/core`),require(`@dnd-kit/sortable`),require(`@dnd-kit/utilities`),require(`@object-ui/types`),require(`@object-ui/react`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`react/jsx-runtime`,`react-router-dom`,`lucide-react`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`,`@object-ui/react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUILayout={},e._object_ui_core,e.react,e._object_ui_components,e.react_jsx_runtime,e.react_router_dom,e.lucide_react,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e._object_ui_types,e._object_ui_react))})(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);function y({title:e,description:t,action:n,className:a,children:o,...s}){return(0,i.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-4 pb-4 md:pb-8`,a),...s,children:(0,i.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-2`,children:[(0,i.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,i.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:e}),t&&(0,i.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),(n||o)&&(0,i.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto sm:ml-0`,children:[n,o]})]})})}function b(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 x(e){let t=b(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function S(e){let t=b(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 C(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 w(e,t){(0,n.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=x(e.primaryColor),i=S(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%`:C(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=x(e.accentColor),i=S(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%`:C(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 T({sidebar:e,navbar:t,children:n,className:a,defaultOpen:o=!0,branding:s}){return w(s,s?.title),(0,i.jsxs)(r.SidebarProvider,{defaultOpen:o,className:`!flex-col`,children:[(0,i.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,i.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,i.jsx)(r.SidebarInset,{className:`min-w-0`,children:(0,i.jsx)(`main`,{className:(0,r.cn)(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6`,a),children:n})})]})]})}function E({className:e,children:t,...n}){return(0,i.jsx)(`div`,{className:(0,r.cn)(`rounded-xl border bg-card text-card-foreground shadow`,e),...n,children:(0,i.jsx)(`div`,{className:`p-6`,children:t})})}var D={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 O(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=D[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 k={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},A=({columns:e,gap:t=4,className:n,children:a})=>(0,i.jsx)(`div`,{className:(0,r.cn)(`grid`,O(e),typeof t==`number`?k[t]||`gap-${t}`:``,n),children:a});function j(e){return e?(0,r.getLazyIcon)(e):o.FileText}function M(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 N(e,t,n,r,i){let a=M(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 P=e=>!(e===!1||e===`false`),F=()=>!0,I=()=>!0;function L(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 R(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=R(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return M(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var z=5;function B({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:a,onAction:o,enablePinning:s,onPinToggle:u,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,t:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=(0,c.useSortable)({id:e.id,disabled:!d});return(0,i.jsx)(`div`,{ref:v,style:{transform:l.CSS.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,i.jsx)(V,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:a,onAction:o,enablePinning:s,onPinToggle:u,dragListeners:d?_:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,t:h})})}function V({item:e,basePath:t,evalVis:s,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,t:_}){let v=(0,a.useLocation)(),[y,b]=(0,n.useState)(e.defaultOpen!==!1);if(!s(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,i.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,i.jsx)(r.Collapsible,{open:y,onOpenChange:b,children:(0,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,i.jsxs)(r.CollapsibleTrigger,{className:`flex w-full items-center justify-between`,children:[N(e,m,_,h,g),(0,i.jsx)(o.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform ${y?`rotate-90`:``}`})]})}),(0,i.jsx)(r.CollapsibleContent,{children:(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:n.map(e=>(0,i.jsx)(V,{item:e,basePath:t,evalVis:s,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=j(e.icon),n=M(e.label,_);return(0,i.jsxs)(r.SidebarMenuItem,{children:[p&&(0,i.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,i.jsx)(o.GripVertical,{className:`h-3.5 w-3.5`})}),(0,i.jsxs)(r.SidebarMenuButton,{tooltip:n,onClick:()=>u?.(e),children:[(0,i.jsx)(t,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{children:n}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,i.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,i.jsx)(o.PinOff,{className:`h-3.5 w-3.5`}):(0,i.jsx)(o.Pin,{className:`h-3.5 w-3.5`})})]})}let C=j(e.icon),{href:w,external:T}=L(e,t),E=w!==`#`&&v.pathname.startsWith(w),D=N(e,m,_,h,g),O=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(C,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{children:D}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,i.jsxs)(r.SidebarMenuItem,{children:[p&&(0,i.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,i.jsx)(o.GripVertical,{className:`h-3.5 w-3.5`})}),(0,i.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:E,tooltip:D,children:T?(0,i.jsx)(`a`,{href:w,target:`_blank`,rel:`noopener noreferrer`,children:O}):(0,i.jsx)(a.Link,{to:w,children:O})}),d&&f&&(0,i.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,i.jsx)(o.PinOff,{className:`h-3.5 w-3.5`}):(0,i.jsx)(o.Pin,{className:`h-3.5 w-3.5`})})]})}function H({items:e,basePath:t=``,evaluateVisibility:a=P,checkPermission:l=F,checkCapability:u=I,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?R(e,f):e,[e,f]),S=(0,n.useMemo)(()=>U(x),[x]),C=x.slice().sort((e,t)=>(e.order??0)-(t.order??0)),w=(0,s.useSensors)((0,s.useSensor)(s.PointerSensor,{activationConstraint:{distance:z}}),(0,s.useSensor)(s.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,c.arrayMove)(C,r,i).map((e,t)=>({...e,order:t})))},E={basePath:t,evalVis:a,checkPerm:l,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,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(o.Star,{className:`h-3.5 w-3.5`}),b?b(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:S.map(e=>(0,i.jsx)(V,{item:e,...E},`fav-${e.id}`))})})]}):null;if(!D){let e=C.filter(e=>e.type!==`group`).map(e=>e.id);return(0,i.jsxs)(i.Fragment,{children:[O,(0,i.jsx)(r.SidebarGroup,{children:(0,i.jsx)(r.SidebarGroupContent,{children:h?(0,i.jsx)(s.DndContext,{sensors:w,collisionDetection:s.closestCenter,onDragEnd:T,children:(0,i.jsx)(c.SortableContext,{items:e,strategy:c.verticalListSortingStrategy,children:(0,i.jsx)(r.SidebarMenu,{children:C.map(e=>(0,i.jsx)(B,{item:e,enableReorder:h,...E},e.id))})})}):(0,i.jsx)(r.SidebarMenu,{children:C.map(e=>(0,i.jsx)(V,{item:e,...E},e.id))})})})]})}let k=[],A=[],j=e=>{if(A.length===0)return;let t=A;A=[],k.push((0,i.jsx)(r.SidebarGroup,{children:(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:t.map(e=>(0,i.jsx)(V,{item:e,...E},e.id))})})},e))};return C.forEach((e,t)=>{e.type===`group`?(j(`leaf-${t}`),k.push((0,i.jsx)(V,{item:e,...E},e.id))):A.push(e)}),j(`leaf-end`),(0,i.jsxs)(i.Fragment,{children:[O,k]})}function U(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...U(n.children));return t}function W({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,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(o.Layers,{className:`h-3.5 w-3.5`}),`Area`]}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:c.map(e=>{let a=j(e.icon);return(0,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:M(e.label),onClick:()=>n(e.id),children:[(0,i.jsx)(a,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{children:M(e.label)})]})},e.id)})})})]})}function G({items:e,basePath:t}){let n=(0,a.useLocation)(),r=e.filter(e=>e.type!==`group`&&e.type!==`separator`).slice(0,5);return r.length===0?null:(0,i.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:r.map(e=>{let r=j(e.icon),o=`#`;e.type===`object`?(o=`${t}/${e.objectName}`,e.viewName&&(o+=`/view/${e.viewName}`)):e.type===`dashboard`?o=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`:e.type===`page`?o=e.pageName?`${t}/page/${e.pageName}`:`#`:e.type===`report`?o=e.reportName?`${t}/report/${e.reportName}`:`#`:e.type===`url`&&(o=e.url??`#`);let s=o!==`#`&&n.pathname.startsWith(o);return(0,i.jsxs)(a.Link,{to:o,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${s?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,i.jsx)(r,{className:`h-5 w-5`}),(0,i.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:M(e.label)})]},e.id)})})}function K({schema:e,basePath:t,evalVis:a,checkPerm:o,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=j(e.logo),x=e.areas??[],[S,C]=(0,n.useState)(``);return(0,i.jsxs)(r.Sidebar,{collapsible:`icon`,children:[(0,i.jsxs)(r.SidebarHeader,{children:[l??(0,i.jsx)(r.SidebarMenu,{children:(0,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsxs)(r.SidebarMenuButton,{size:`lg`,tooltip:e.title??e.name,children:[(0,i.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,i.jsx)(`img`,{src:e.logo,alt:e.title??``,className:`size-6 object-contain`}):(0,i.jsx)(b,{className:`size-4`})}),(0,i.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,i.jsx)(`span`,{className:`truncate font-semibold`,children:e.title??e.name??`App`}),e.description&&(0,i.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]})]})})}),h&&(0,i.jsx)(r.SidebarInput,{placeholder:`Search navigation…`,value:S,onChange:e=>C(e.target.value),"aria-label":`Search navigation`})]}),(0,i.jsxs)(r.SidebarContent,{children:[x.length>1&&f&&(0,i.jsx)(W,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:a,checkPerm:o}),(0,i.jsx)(H,{items:m,basePath:t,evaluateVisibility:a,checkPermission:o,checkCapability:s,onAction:c,searchQuery:S,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}),d]}),u&&(0,i.jsx)(r.SidebarFooter,{children:u})]})}function q({schema:e,basePath:t=``,mobileNavMode:r=`drawer`,evaluateVisibility:a,checkPermission:o,checkCapability:s,onAction:c,navbar:l,sidebarHeader:d,sidebarFooter:f,sidebarExtra:p,children:m,className:h,defaultOpen:g=!0,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=a??(e=>!(e===!1||e===`false`)),C=o??(()=>!0),w=s??(()=>!0),E=(0,n.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,u.menuItemToNavigationItem)(e,t)),[e.menu]),D=e.navigation??E,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??D,N={title:e.title,favicon:e.favicon,logo:e.logo};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(T,{sidebar:(0,i.jsx)(K,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:d,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,i.jsx)(G,{items:M,basePath:t})]})}var J=e=>e?Array.isArray(e)?e:[e]:[];function Y({schema:e,className:t,style:n,id:a,...o}){let s=J(e.children);return(0,i.jsxs)(`div`,{id:a||e.id,className:(0,r.cn)(`flex flex-col h-full space-y-4`,t),style:n,children:[(0,i.jsx)(y,{title:e.title,description:e.description}),(0,i.jsx)(`div`,{className:`flex-1 overflow-auto`,children:s.map((e,t)=>(0,i.jsx)(d.SchemaRenderer,{schema:e,...o},e?.id||t))})]})}function X(e){return`items`in e&&!(`href`in e)}function Z({item:e,pathname:t}){return e.children&&e.children.length>0?(0,i.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,i.jsxs)(r.SidebarMenuItem,{children:[(0,i.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,i.jsxs)(r.SidebarMenuButton,{tooltip:e.title,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.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,i.jsx)(o.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,i.jsx)(r.CollapsibleContent,{children:(0,i.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,i.jsx)(r.SidebarMenuSubItem,{children:(0,i.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,children:(0,i.jsxs)(a.NavLink,{to:e.href,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.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,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,children:(0,i.jsxs)(a.NavLink,{to:e.href,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function Q({items:e,title:t=`Application`,className:s,collapsible:c=`icon`,searchEnabled:l=!1,searchPlaceholder:u=`Search...`}){let d=(0,a.useLocation)(),[f,p]=n.default.useState(``),m=n.default.useMemo(()=>e.length===0?[]:X(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,i.jsx)(r.Sidebar,{className:s,collapsible:c,children:(0,i.jsxs)(r.SidebarContent,{children:[l&&(0,i.jsx)(`div`,{className:`px-3 py-2`,children:(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(o.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,i.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,i.jsxs)(r.SidebarGroup,{children:[n>0&&(0,i.jsx)(`div`,{className:`mx-3 mb-1 h-px bg-sidebar-border/60`,"aria-hidden":!0}),(0,i.jsx)(r.SidebarGroupLabel,{className:`text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60`,children:e.groupLabel||t}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:e.items.map(e=>(0,i.jsx)(Z,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function $(){t.ComponentRegistry.register(`page-header`,y,{namespace:`layout`,label:`Page Header`,category:`Layout`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`}]}),t.ComponentRegistry.register(`page:header`,y,{namespace:`layout`}),t.ComponentRegistry.register(`page:card`,E,{namespace:`layout`,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,T,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,A,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,H,{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=T,e.NavigationRenderer=H,e.Page=Y,e.PageCard=E,e.PageHeader=y,e.ResponsiveGrid=A,e.SidebarNav=Q,e.filterNavigationItems=R,e.registerLayout=$,e.resolveIcon=j,e.resolveLabel=M,e.useAppShellBranding=w});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`react/jsx-runtime`),require(`react-router-dom`),require(`lucide-react`),require(`@dnd-kit/core`),require(`@dnd-kit/sortable`),require(`@dnd-kit/utilities`),require(`@object-ui/types`),require(`@object-ui/react`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`react/jsx-runtime`,`react-router-dom`,`lucide-react`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`@object-ui/types`,`@object-ui/react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUILayout={},e._object_ui_core,e.react,e._object_ui_components,e.react_jsx_runtime,e.react_router_dom,e.lucide_react,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e._object_ui_types,e._object_ui_react))})(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);function y({title:e,description:t,action:n,className:a,children:o,...s}){return(0,i.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-4 pb-4 md:pb-8`,a),...s,children:(0,i.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-2`,children:[(0,i.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,i.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:e}),t&&(0,i.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),(n||o)&&(0,i.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto sm:ml-0`,children:[n,o]})]})})}function b(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 x(e){let t=b(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function S(e){let t=b(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 C(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 w(e,t){(0,n.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=x(e.primaryColor),i=S(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%`:C(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=x(e.accentColor),i=S(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%`:C(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 T({sidebar:e,navbar:t,children:n,className:a,defaultOpen:o=!0,branding:s}){return w(s,s?.title),(0,i.jsxs)(r.SidebarProvider,{defaultOpen:o,className:`!flex-col`,children:[(0,i.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,i.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,i.jsx)(r.SidebarInset,{className:`min-w-0`,children:(0,i.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`,a),children:n})})]})]})}function E({className:e,children:t,...n}){return(0,i.jsx)(`div`,{className:(0,r.cn)(`rounded-xl border bg-card text-card-foreground shadow`,e),...n,children:(0,i.jsx)(`div`,{className:`p-6`,children:t})})}var D={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 O(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=D[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 k={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},A=({columns:e,gap:t=4,className:n,children:a})=>(0,i.jsx)(`div`,{className:(0,r.cn)(`grid`,O(e),typeof t==`number`?k[t]||`gap-${t}`:``,n),children:a});function j(e){return e?(0,r.getLazyIcon)(e):o.FileText}function M(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 N(e,t,n,r,i){let a=M(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 P=e=>!(e===!1||e===`false`),F=()=>!0,I=()=>!0;function L(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 R(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=R(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return M(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var z=5;function B({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:a,onAction:o,enablePinning:s,onPinToggle:u,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,t:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=(0,c.useSortable)({id:e.id,disabled:!d});return(0,i.jsx)(`div`,{ref:v,style:{transform:l.CSS.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,i.jsx)(V,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:a,onAction:o,enablePinning:s,onPinToggle:u,dragListeners:d?_:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,t:h})})}function V({item:e,basePath:t,evalVis:s,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,t:_}){let v=(0,a.useLocation)(),[y,b]=(0,n.useState)(e.defaultOpen!==!1);if(!s(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,i.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,i.jsx)(r.Collapsible,{open:y,onOpenChange:b,children:(0,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,i.jsxs)(r.CollapsibleTrigger,{className:`flex w-full items-center justify-between`,children:[N(e,m,_,h,g),(0,i.jsx)(o.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform ${y?`rotate-90`:``}`})]})}),(0,i.jsx)(r.CollapsibleContent,{children:(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:n.map(e=>(0,i.jsx)(V,{item:e,basePath:t,evalVis:s,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=j(e.icon),n=M(e.label,_);return(0,i.jsxs)(r.SidebarMenuItem,{children:[p&&(0,i.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,i.jsx)(o.GripVertical,{className:`h-3.5 w-3.5`})}),(0,i.jsxs)(r.SidebarMenuButton,{tooltip:n,onClick:()=>u?.(e),children:[(0,i.jsx)(t,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{children:n}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,i.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,i.jsx)(o.PinOff,{className:`h-3.5 w-3.5`}):(0,i.jsx)(o.Pin,{className:`h-3.5 w-3.5`})})]})}let C=j(e.icon),{href:w,external:T}=L(e,t),E=w!==`#`&&v.pathname.startsWith(w),D=N(e,m,_,h,g),O=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(C,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{children:D}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,i.jsxs)(r.SidebarMenuItem,{children:[p&&(0,i.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,i.jsx)(o.GripVertical,{className:`h-3.5 w-3.5`})}),(0,i.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:E,tooltip:D,children:T?(0,i.jsx)(`a`,{href:w,target:`_blank`,rel:`noopener noreferrer`,children:O}):(0,i.jsx)(a.Link,{to:w,children:O})}),d&&f&&(0,i.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,i.jsx)(o.PinOff,{className:`h-3.5 w-3.5`}):(0,i.jsx)(o.Pin,{className:`h-3.5 w-3.5`})})]})}function H({items:e,basePath:t=``,evaluateVisibility:a=P,checkPermission:l=F,checkCapability:u=I,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?R(e,f):e,[e,f]),S=(0,n.useMemo)(()=>U(x),[x]),C=x.slice().sort((e,t)=>(e.order??0)-(t.order??0)),w=(0,s.useSensors)((0,s.useSensor)(s.PointerSensor,{activationConstraint:{distance:z}}),(0,s.useSensor)(s.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,c.arrayMove)(C,r,i).map((e,t)=>({...e,order:t})))},E={basePath:t,evalVis:a,checkPerm:l,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,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(o.Star,{className:`h-3.5 w-3.5`}),b?b(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:S.map(e=>(0,i.jsx)(V,{item:e,...E},`fav-${e.id}`))})})]}):null;if(!D){let e=C.filter(e=>e.type!==`group`).map(e=>e.id);return(0,i.jsxs)(i.Fragment,{children:[O,(0,i.jsx)(r.SidebarGroup,{children:(0,i.jsx)(r.SidebarGroupContent,{children:h?(0,i.jsx)(s.DndContext,{sensors:w,collisionDetection:s.closestCenter,onDragEnd:T,children:(0,i.jsx)(c.SortableContext,{items:e,strategy:c.verticalListSortingStrategy,children:(0,i.jsx)(r.SidebarMenu,{children:C.map(e=>(0,i.jsx)(B,{item:e,enableReorder:h,...E},e.id))})})}):(0,i.jsx)(r.SidebarMenu,{children:C.map(e=>(0,i.jsx)(V,{item:e,...E},e.id))})})})]})}let k=[],A=[],j=e=>{if(A.length===0)return;let t=A;A=[],k.push((0,i.jsx)(r.SidebarGroup,{children:(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:t.map(e=>(0,i.jsx)(V,{item:e,...E},e.id))})})},e))};return C.forEach((e,t)=>{e.type===`group`?(j(`leaf-${t}`),k.push((0,i.jsx)(V,{item:e,...E},e.id))):A.push(e)}),j(`leaf-end`),(0,i.jsxs)(i.Fragment,{children:[O,k]})}function U(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...U(n.children));return t}function W({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,i.jsxs)(r.SidebarGroup,{children:[(0,i.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,i.jsx)(o.Layers,{className:`h-3.5 w-3.5`}),`Area`]}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:c.map(e=>{let a=j(e.icon);return(0,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:M(e.label),onClick:()=>n(e.id),children:[(0,i.jsx)(a,{className:`h-4 w-4`}),(0,i.jsx)(`span`,{children:M(e.label)})]})},e.id)})})})]})}function G({items:e,basePath:t}){let n=(0,a.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},o=r(e).slice(0,5);return o.length===0?null:(0,i.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:o.map(e=>{let r=j(e.icon),o=`#`;e.type===`object`?(o=`${t}/${e.objectName}`,e.viewName&&(o+=`/view/${e.viewName}`)):e.type===`dashboard`?o=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`:e.type===`page`?o=e.pageName?`${t}/page/${e.pageName}`:`#`:e.type===`report`?o=e.reportName?`${t}/report/${e.reportName}`:`#`:e.type===`url`&&(o=e.url??`#`);let s=o!==`#`&&n.pathname.startsWith(o);return(0,i.jsxs)(a.Link,{to:o,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${s?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,i.jsx)(r,{className:`h-5 w-5`}),(0,i.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:M(e.label)})]},e.id)})})}function K({schema:e,basePath:t,evalVis:a,checkPerm:o,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=j(e.logo),x=e.areas??[],[S,C]=(0,n.useState)(``);return(0,i.jsxs)(r.Sidebar,{collapsible:`icon`,children:[(0,i.jsxs)(r.SidebarHeader,{children:[l??(0,i.jsx)(r.SidebarMenu,{children:(0,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsxs)(r.SidebarMenuButton,{size:`lg`,tooltip:e.title??e.name,children:[(0,i.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,i.jsx)(`img`,{src:e.logo,alt:e.title??``,className:`size-6 object-contain`}):(0,i.jsx)(b,{className:`size-4`})}),(0,i.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,i.jsx)(`span`,{className:`truncate font-semibold`,children:e.title??e.name??`App`}),e.description&&(0,i.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]})]})})}),h&&(0,i.jsx)(r.SidebarInput,{placeholder:`Search navigation…`,value:S,onChange:e=>C(e.target.value),"aria-label":`Search navigation`})]}),(0,i.jsxs)(r.SidebarContent,{children:[x.length>1&&f&&(0,i.jsx)(W,{areas:x,activeAreaId:f,onAreaChange:p,evalVis:a,checkPerm:o}),(0,i.jsx)(H,{items:m,basePath:t,evaluateVisibility:a,checkPermission:o,checkCapability:s,onAction:c,searchQuery:S,enablePinning:g,onPinToggle:_,enableReorder:v,onReorder:y}),d]}),u&&(0,i.jsx)(r.SidebarFooter,{children:u})]})}function q({schema:e,basePath:t=``,mobileNavMode:r=`drawer`,evaluateVisibility:a,checkPermission:o,checkCapability:s,onAction:c,navbar:l,sidebarHeader:d,sidebarFooter:f,sidebarExtra:p,children:m,className:h,defaultOpen:g=!0,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=a??(e=>!(e===!1||e===`false`)),C=o??(()=>!0),w=s??(()=>!0),E=(0,n.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,u.menuItemToNavigationItem)(e,t)),[e.menu]),D=e.navigation??E,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??D,N={title:e.title,favicon:e.favicon,logo:e.logo};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(T,{sidebar:(0,i.jsx)(K,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:d,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,i.jsx)(G,{items:M,basePath:t})]})}var J=e=>e?Array.isArray(e)?e:[e]:[];function Y({schema:e,className:t,style:n,id:a,...o}){let s=J(e.children);return(0,i.jsxs)(`div`,{id:a||e.id,className:(0,r.cn)(`flex flex-col h-full space-y-4`,t),style:n,children:[(0,i.jsx)(y,{title:e.title,description:e.description}),(0,i.jsx)(`div`,{className:`flex-1 overflow-auto`,children:s.map((e,t)=>(0,i.jsx)(d.SchemaRenderer,{schema:e,...o},e?.id||t))})]})}function X(e){return`items`in e&&!(`href`in e)}function Z({item:e,pathname:t}){return e.children&&e.children.length>0?(0,i.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,i.jsxs)(r.SidebarMenuItem,{children:[(0,i.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,i.jsxs)(r.SidebarMenuButton,{tooltip:e.title,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.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,i.jsx)(o.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,i.jsx)(r.CollapsibleContent,{children:(0,i.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,i.jsx)(r.SidebarMenuSubItem,{children:(0,i.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,children:(0,i.jsxs)(a.NavLink,{to:e.href,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.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,i.jsx)(r.SidebarMenuItem,{children:(0,i.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,children:(0,i.jsxs)(a.NavLink,{to:e.href,children:[e.icon&&(0,i.jsx)(e.icon,{}),(0,i.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,i.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function Q({items:e,title:t=`Application`,className:s,collapsible:c=`icon`,searchEnabled:l=!1,searchPlaceholder:u=`Search...`}){let d=(0,a.useLocation)(),[f,p]=n.default.useState(``),m=n.default.useMemo(()=>e.length===0?[]:X(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,i.jsx)(r.Sidebar,{className:s,collapsible:c,children:(0,i.jsxs)(r.SidebarContent,{children:[l&&(0,i.jsx)(`div`,{className:`px-3 py-2`,children:(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(o.Search,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,i.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,i.jsxs)(r.SidebarGroup,{children:[n>0&&(0,i.jsx)(`div`,{className:`mx-3 mb-1 h-px bg-sidebar-border/60`,"aria-hidden":!0}),(0,i.jsx)(r.SidebarGroupLabel,{className:`text-[10px] font-semibold uppercase tracking-wider text-sidebar-foreground/60`,children:e.groupLabel||t}),(0,i.jsx)(r.SidebarGroupContent,{children:(0,i.jsx)(r.SidebarMenu,{children:e.items.map(e=>(0,i.jsx)(Z,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function $(){t.ComponentRegistry.register(`page-header`,y,{namespace:`layout`,label:`Page Header`,category:`Layout`,inputs:[{name:`title`,type:`string`},{name:`description`,type:`string`}]}),t.ComponentRegistry.register(`page:header`,y,{namespace:`layout`}),t.ComponentRegistry.register(`page:card`,E,{namespace:`layout`,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,T,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,A,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,H,{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=T,e.NavigationRenderer=H,e.Page=Y,e.PageCard=E,e.PageHeader=y,e.ResponsiveGrid=A,e.SidebarNav=Q,e.filterNavigationItems=R,e.registerLayout=$,e.resolveIcon=j,e.resolveLabel=M,e.useAppShellBranding=w});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/layout",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.umd.cjs",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"@dnd-kit/sortable": "^10.0.0",
|
|
19
19
|
"@dnd-kit/utilities": "^3.2.2",
|
|
20
20
|
"clsx": "^2.1.1",
|
|
21
|
-
"lucide-react": "^1.
|
|
21
|
+
"lucide-react": "^1.16.0",
|
|
22
22
|
"react": "19.2.6",
|
|
23
23
|
"react-dom": "19.2.6",
|
|
24
24
|
"tailwind-merge": "^3.6.0",
|
|
25
|
-
"@object-ui/components": "4.0.
|
|
26
|
-
"@object-ui/core": "4.0.
|
|
27
|
-
"@object-ui/react": "4.0.
|
|
28
|
-
"@object-ui/types": "4.0.
|
|
25
|
+
"@object-ui/components": "4.0.12",
|
|
26
|
+
"@object-ui/core": "4.0.12",
|
|
27
|
+
"@object-ui/react": "4.0.12",
|
|
28
|
+
"@object-ui/types": "4.0.12"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"react-router-dom": "^6.0.0 || ^7.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@vitejs/plugin-react": "^6.0.
|
|
36
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
37
37
|
"react-router-dom": "^7.15.0",
|
|
38
|
-
"vite": "^8.0.
|
|
38
|
+
"vite": "^8.0.13",
|
|
39
39
|
"vite-plugin-dts": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"description": "Layout components for Object UI — AppShell, Page, SidebarNav and responsive containers with React Router integration",
|