@object-ui/layout 17.3.0 → 17.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +691 -0
- package/README.md +148 -32
- package/dist/AppSchemaRenderer.d.ts +23 -5
- package/dist/AppShell.d.ts +0 -2
- package/dist/NavigationRenderer.d.ts +32 -25
- package/dist/PageHeader.d.ts +12 -5
- package/dist/ResponsiveGrid.d.ts +19 -22
- package/dist/index.d.ts +7 -7
- package/dist/index.js +369 -350
- package/dist/index.umd.cjs +1 -1
- package/package.json +16 -10
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||!_.call(e,`default`)?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}}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,rightRail:c}){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})}),c]})]})}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})=>{let a=A(e),s=typeof t==`number`?j[t]||`gap-${t}`:``;return(0,o.jsx)(`div`,{className:(0,r.cn)(`grid`,a,s,n),children:i})};function N(e){return e?(0,r.getLazyIcon)(e):i.FileText}function P(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function F(e,t,n,r,i,a,o){let s=P(e.label,n);if(typeof e.label!=`string`)return s;let c=e=>!!e&&s.trim().toLowerCase()!==e.trim().toLowerCase();if(e.type===`object`&&e.objectName){if(e.viewName)return c(e.viewName)?s:a?a(e.objectName,e.viewName,s):s;if(c(e.objectName))return s;if(t)return t(e.objectName,s)}if(e.type===`dashboard`&&e.dashboardName){if(c(e.dashboardName))return s;if(r)return r(e.dashboardName,s)}if(e.type===`group`&&e.id){if(c(e.id))return s;if(i)return i(e.id,s)}return o&&e.id&&!c(e.id)?o(e.id,s):s}var I=e=>e!==!1&&e!==`false`,L=()=>!0,R=()=>!0;function z(e,t={}){let{evaluateVisibility:n=I,checkPermission:r=L,checkCapability:i=R,hasActionHandler:a=!1}=t;for(let o of e)if(n(o.visible)&&!(o.requiredPermissions?.length&&!r(o.requiredPermissions))&&!(o.requiresObject&&!i(`object`,o.requiresObject))&&!(o.requiresService&&!i(`service`,o.requiresService))&&o.type!==`separator`){if(o.type===`group`){if(z(o.children??[],t))return!0;continue}if(!(o.type===`action`&&!a))return!0}return!1}var B=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function V(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(B,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function H(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=V(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}let a=e.filters;if(a&&typeof a==`object`&&!Array.isArray(a)){let e=new URLSearchParams;for(let[t,r]of Object.entries(a)){if(r==null||t===``)continue;let i=V(String(r),n);i!==null&&e.set(`filter[${t}]`,i)}let t=e.toString();return{href:t?`${r}/data?${t}`:`${r}/data`,external:!1}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=V(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(t!==`type`&&t!==`name`&&r!=null)if(typeof r==`string`){let i=V(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}var ee=50,te=40,ne=30,U=25,re=10,ie=5;function ae(e){let t=new Map;return new URLSearchParams(e).forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.set(r[1],e)}),t}function W(e,t){return t.startsWith(`${e}.`)?t.slice(e.length+1):t}function oe(e,t,n,r,i){let{href:a,external:o}=H(e,r,i);if(o||a===`#`)return 0;if(e.type===`object`&&e.objectName){let a=`${r}/${e.objectName}`;if(t!==a&&!t.startsWith(`${a}/`))return 0;let o=t===a?[]:t.slice(a.length+1).split(`/`),s=e.recordId;if(s){let e=V(s,i);if(e)return o[0]===`record`&&decodeURIComponent(o[1]??``)===e?ee:0}let c=e.filters;if(c&&typeof c==`object`&&!Array.isArray(c)){if(o[0]!==`data`)return 0;let e=new Map;for(let[t,n]of Object.entries(c)){if(n==null||t===``)continue;let r=V(String(n),i);r!==null&&e.set(t,r)}if(e.size!==n.size)return 0;for(let[t,r]of e)if(n.get(t)!==r)return 0;return te}return e.viewName?o[0]!==`view`||!o[1]?0:W(e.objectName,decodeURIComponent(o[1]))===W(e.objectName,e.viewName)?ne:0:o.length===0?U:re}let s=a.split(`?`)[0];if(t===s)return U;let c=e.componentRef;return c&&c.split(`:`)[1]===`directory`?0:t.startsWith(`${s}/`)?ie:0}function G(e,t,n,r,i){let a=ae(n),o=null,s=0,c=e=>{if(e)for(let n of e){if(n.type===`group`){c(n.children);continue}let e=oe(n,t,a,r,i);e>s&&(o=n,s=e)}};return c(e),o}var K=n.default.createContext(null);function q(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=q(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 se=5;function ce({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v}){let{attributes:y,listeners:b,setNodeRef:x,transform:S,transition:C,isDragging:w}=(0,l.useSortable)({id:e.id,disabled:!d}),T={transform:u.CSS.Transform.toString(S),transition:C,opacity:w?.5:void 0,zIndex:w?10:void 0};return(0,o.jsx)(`div`,{ref:x,style:T,...y,children:(0,o.jsx)(J,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,dragListeners:d?b:void 0,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:_,templateContext:v})})}function J({item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,resolveItemLabel:v,t:y,templateContext:b}){let x=(0,r.useIsMobile)(),S=x?`min-h-[44px] text-[15px] gap-3 rounded-xl`:void 0,C=(0,r.cn)(`shrink-0`,x?`h-5 w-5`:`h-4 w-4`),w=(()=>{if(typeof e.expanded==`boolean`)return e.expanded;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),T=e.type===`group`?e.children?.length??0:0,E=n.default.useContext(K),D=n.default.useMemo(()=>{if(e.type!==`group`||!E)return!1;let t=e=>!!e?.some(e=>e.id===E||e.type===`group`&&t(e.children));return t(e.children)},[e,E])?!0:w??!(T>=8),[O,k]=(0,n.useState)(D);if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let A=e.requiresObject,j=e.requiresService;if(A&&!l(`object`,A)||j&&!l(`service`,j))return null;if(e.type===`separator`)return(0,o.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0)),s=F(e,m,y,h,g,_,v);return(0,o.jsx)(r.Collapsible,{open:O,onOpenChange:k,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:(0,r.cn)(`flex w-full items-center justify-between`,x&&`min-h-[44px] text-[15px] rounded-xl`),children:[s,(0,o.jsx)(i.ChevronRight,{className:(0,r.cn)(`ml-auto transition-transform`,x?`h-5 w-5`:`h-4 w-4`,O&&`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)(J,{item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,resolveObjectLabel:m,resolveDashboardLabel:h,resolveGroupLabel:g,resolveViewLabel:_,resolveItemLabel:v,t:y,templateContext:b},e.id))})})})]})})}if(e.type===`action`){if(!u)return null;let n=N(e.icon),a=P(e.label,y);return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":y?y(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsxs)(r.SidebarMenuButton,{tooltip:a,onClick:()=>u?.(e),className:S,children:[(0,o.jsx)(n,{className:C}),(0,o.jsx)(`span`,{children:a}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":y?y(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${a}`:`Pin ${a}`,name:a}):e.pinned?`Unpin ${a}`:`Pin ${a}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}let M=N(e.icon),{href:I,external:L}=H(e,t,b),R=E!==null&&e.id===E,z=F(e,m,y,h,g,_,v),B=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(M,{className:C}),(0,o.jsx)(`span`,{children:z}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,o.jsxs)(r.SidebarMenuItem,{children:[p&&(0,o.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":y?y(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...p,children:(0,o.jsx)(i.GripVertical,{className:`h-3.5 w-3.5`})}),(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:R,tooltip:z,className:S,children:L?(0,o.jsx)(`a`,{href:I,target:`_blank`,rel:`noopener noreferrer`,children:B}):(0,o.jsx)(s.Link,{to:I,children:B})}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":y?y(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${z}`:`Pin ${z}`,name:z}):e.pinned?`Unpin ${z}`:`Pin ${z}`,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 Y({items:e,basePath:t=``,evaluateVisibility:a=I,checkPermission:u=L,checkCapability:d=R,onAction:f,searchQuery:p,enablePinning:m,onPinToggle:h,enableReorder:g,onReorder:_,resolveObjectLabel:v,resolveDashboardLabel:y,resolveGroupLabel:b,resolveViewLabel:x,resolveItemLabel:S,t:C,templateContext:w}){let T=(0,s.useLocation)(),E=(0,n.useMemo)(()=>G(e,T.pathname,T.search,t,w)?.id??null,[e,T.pathname,T.search,t,w]),D=(0,n.useMemo)(()=>p?q(e,p):e,[e,p]),O=(0,n.useMemo)(()=>X(D),[D]),k=D.slice().sort((e,t)=>(e.order??0)-(t.order??0)),A=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:se}}),(0,c.useSensor)(c.KeyboardSensor)),j=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!_)return;let r=k.findIndex(e=>e.id===t.id),i=k.findIndex(e=>e.id===n.id);r!==-1&&i!==-1&&_((0,l.arrayMove)(k,r,i).map((e,t)=>({...e,order:t})))},M={basePath:t,evalVis:a,checkPerm:u,checkCap:d,onAction:f,enablePinning:m,onPinToggle:h,resolveObjectLabel:v,resolveDashboardLabel:y,resolveGroupLabel:b,resolveViewLabel:x,resolveItemLabel:S,t:C,templateContext:w},N=k.some(e=>e.type===`group`),P=O.length>0&&m?(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Star,{className:`h-3.5 w-3.5`}),C?C(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:O.map(e=>(0,o.jsx)(J,{item:e,...M},`fav-${e.id}`))})})]}):null;if(!N){let e=k.filter(e=>e.type!==`group`).map(e=>e.id),t=g?(0,o.jsx)(c.DndContext,{sensors:A,collisionDetection:c.closestCenter,onDragEnd:j,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:k.map(e=>(0,o.jsx)(ce,{item:e,enableReorder:g,...M},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:k.map(e=>(0,o.jsx)(J,{item:e,...M},e.id))});return(0,o.jsxs)(K.Provider,{value:E,children:[P,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:t})})]})}let F=[],z=[],B=e=>{if(z.length===0)return;let t=z;z=[],F.push((0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:t.map(e=>(0,o.jsx)(J,{item:e,...M},e.id))})})},e))};return k.forEach((e,t)=>{e.type===`group`?(B(`leaf-${t}`),F.push((0,o.jsx)(J,{item:e,...M},e.id))):z.push(e)}),B(`leaf-end`),(0,o.jsxs)(K.Provider,{value:E,children:[P,F]})}function X(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...X(n.children));return t}function le({areas:e,activeAreaId:t,onAreaChange:n}){return e.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:e.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 ue({items:e,basePath:t}){let n=(0,s.useLocation)(),r=e=>{let t=[];for(let n of e)n.type!==`separator`&&(n.type===`group`?t.push(...r(n.children||[])):t.push(n));return t},i=r(e).slice(0,5);return i.length===0?null:(0,o.jsx)(`div`,{className:`fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom`,role:`navigation`,"aria-label":`Mobile navigation`,children:i.map(e=>{let r=N(e.icon),i=`#`;if(e.type===`object`)i=`${t}/${e.objectName}`,e.viewName&&(i+=`/view/${e.viewName}`);else if(e.type===`dashboard`)i=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`;else if(e.type===`page`)i=e.pageName?`${t}/page/${e.pageName}`:`#`;else if(e.type===`report`)i=e.reportName?`${t}/report/${e.reportName}`:`#`;else if(e.type===`url`)i=e.url??`#`;else if(e.type===`component`){let n=e.componentRef;if(n){i=`${t}/component/${n.split(`:`).filter(Boolean).join(`/`)}`;let r=e.params;if(r){let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(i+=`?${t}`)}}}let a=i!==`#`&&n.pathname.startsWith(i);return(0,o.jsxs)(s.Link,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,o.jsx)(r,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:P(e.label)})]},e.id)})})}function Z({schema:e,basePath:t,evalVis:i,checkPerm:a,checkCap:s,onAction:c,sidebarHeader:l,sidebarFooter:u,sidebarExtra:d,visibleAreas:f,activeAreaId:p,setActiveAreaId:m,resolvedNavigation:h,enableSearch:g,enablePinning:_,onPinToggle:v,enableReorder:y,onReorder:b}){let x=N(e.logo),[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)(x,{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})]})]})})}),g&&(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:[f.length>1&&p&&(0,o.jsx)(le,{areas:f,activeAreaId:p,onAreaChange:m}),(0,o.jsx)(Y,{items:h,basePath:t,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,searchQuery:S,enablePinning:_,onPinToggle:v,enableReorder:y,onReorder:b}),d]}),u&&(0,o.jsx)(r.SidebarFooter,{children:u})]})}function Q({schema:e,basePath:t=``,mobileNavMode:r=`drawer`,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,navbar:l,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,children:m,className:h,defaultOpen:g=!0,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x}){let S=i??(e=>e!==!1&&e!==`false`),C=a??(()=>!0),w=s??(()=>!0),T=(0,n.useMemo)(()=>(e.menu??[]).map((e,t)=>(0,d.menuItemToNavigationItem)(e,t)),[e.menu]),E=e.navigation??T,O=(e.areas??[]).filter(e=>z(e.navigation,{evaluateVisibility:S,checkPermission:C,checkCapability:w,hasActionHandler:!!c})),[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)??O[0],N=M?.navigation??E,P={title:e.title,favicon:e.favicon,logo:e.logo},F=(0,o.jsx)(Z,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,visibleAreas:O,activeAreaId:M?.id??null,setActiveAreaId:A,resolvedNavigation:N,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(D,{sidebar:F,navbar:l,className:h,defaultOpen:g,branding:P,children:m}),r===`bottom_nav`&&(0,o.jsx)(ue,{items:N,basePath:t})]})}function de(e){return`items`in e&&!(`href`in e)}function fe({item:e,pathname:t}){return e.children&&e.children.length>0?(0,o.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,o.jsxs)(r.SidebarMenuItem,{children:[(0,o.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,o.jsxs)(r.SidebarMenuButton,{tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto mr-1 h-5 min-w-5 px-1 text-xs`,children:e.badge}),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,o.jsx)(r.CollapsibleContent,{className:`motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150`,children:(0,o.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,o.jsx)(r.SidebarMenuSubItem,{children:(0,o.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})},e.href))})})]})}):(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function pe({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?[]:de(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)(fe,{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`,label:`Title`},{name:`subtitle`,type:`string`,label:`Subtitle`}]}),t.ComponentRegistry.register(`page:card`,O,{namespace:`layout`,skipFallback:!0,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`app-shell`,D,{namespace:`layout`,label:`App Shell`,category:`Layout`}),t.ComponentRegistry.register(`responsive-grid`,M,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,Y,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`object`},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,Q,{namespace:`layout`,label:`App Schema Renderer`,category:`Layout`,isContainer:!0,inputs:[{name:`schema`,type:`object`},{name:`basePath`,type:`string`},{name:`mobileNavMode`,type:`string`}]})}try{$()}catch{}e.AppSchemaRenderer=Q,e.AppShell=D,e.NavigationRenderer=Y,e.PageCard=O,e.PageHeader=x,e.ResponsiveGrid=M,e.SidebarNav=pe,e.filterNavigationItems=q,e.hasVisibleNavigationItems=z,e.registerLayout=$,e.resolveActiveNavItem=G,e.resolveHref=H,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"),require("@objectstack/spec/ui")):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`,`@objectstack/spec/ui`],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,e._objectstack_spec_ui))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var p=Object.create,m=Object.defineProperty,h=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,_=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty,y=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=g(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&m(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=h(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:p(_(e)),y(t||!e||!e.__esModule||!v.call(e,`default`)?m(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var b=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)},x=(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`?b(r)??``:String(r)}).replace(/\s*[-–—|/·,:]\s*(?=\s*[-–—|/·,:]|$)/g,``).replace(/^\s*[-–—|/·,:]\s*/,``).replace(/\s+/g,` `).trim():e;function S({title:e,subtitle:t,icon:s,action:c,actions:l,showBack:u,schema:d,className:f,children:p,...m}){let h=(0,a.useRecordContext)(),g=typeof e==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(e),_=x(e,h?.data)||(g?``:e),v=t,y=typeof v==`string`&&/\{[a-zA-Z0-9_.]+\}/.test(v),b=x(v,h?.data)||(y?``:v),S=!!h?.recordId,C=!!h?.embedded,w=u??(S&&!C),T=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`)))},[]),E=Array.isArray(d?.children)?d.children.filter(Boolean).map((e,t)=>(0,o.jsx)(a.SchemaRenderer,{schema:e},e?.id||`pgh-child-${t}`)):null,D=Array.isArray(l)&&l.length>0&&l||Array.isArray(d?.actions)&&d.actions.length>0&&d.actions||Array.isArray(d?.properties?.actions)&&d.properties.actions.length>0&&d.properties.actions||null,O=c||p||(D?(0,o.jsx)(a.SchemaRenderer,{schema:{type:`record:quick_actions`,properties:{actions:D,location:`record_header`,align:`end`,inline:!0}}}):null)||E;return(0,o.jsx)(`div`,{className:(0,r.cn)(`flex flex-col gap-3 pb-4 border-b`,f),...m,children:(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[w&&(0,o.jsx)(r.Button,{type:`button`,variant:`ghost`,size:`icon`,onClick:T,"aria-label":`Back to list`,className:`flex-shrink-0 -ml-2`,children:(0,o.jsx)(i.ArrowLeft,{className:`size-4`})}),s&&(_||b)&&(0,o.jsx)(`div`,{className:`flex-shrink-0 grid place-items-center size-10 rounded-md bg-primary/10 text-primary`,children:typeof s==`string`?(0,o.jsx)(r.LazyIcon,{name:s,className:`size-5`}):s}),(0,o.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[_?(0,o.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight md:text-3xl truncate`,children:_}):null,b&&(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:b})]}),O&&(0,o.jsx)(`div`,{className:`flex items-center gap-2 ml-auto`,children:O})]})})}function C({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 w={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 T(e){if(!e)return`grid-cols-1`;let t=[];for(let[n,r]of Object.entries(e)){let e=w[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 E={0:`gap-0`,1:`gap-1`,2:`gap-2`,3:`gap-3`,4:`gap-4`,5:`gap-5`,6:`gap-6`,8:`gap-8`},D=({columns:e,gap:t=4,className:n,children:i})=>{let a=T(e),s=typeof t==`number`?E[t]||`gap-${t}`:``;return(0,o.jsx)(`div`,{className:(0,r.cn)(`grid`,a,s,n),children:i})};function O(e){return e?(0,r.getLazyIcon)(e):i.FileText}function k(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 A(e,t,n,r,i){let a=k(e.label,n);if(typeof e.label!=`string`)return a;let o=e=>!!e&&a.trim().toLowerCase()!==e.trim().toLowerCase();if(e.type===`object`&&e.objectName){if(e.viewName)return o(e.viewName)?a:i?i(e.objectName,e.viewName,a):a;if(o(e.objectName))return a;if(t)return t(e.objectName,a)}if(e.type===`dashboard`&&e.dashboardName){if(o(e.dashboardName))return a;if(r)return r(e.dashboardName,a)}return a}var j=e=>e!==!1&&e!==`false`,M=()=>!0,N=()=>!0;function P(e,t={}){let{evaluateVisibility:n=j,checkPermission:r=M,checkCapability:i=N,hasActionHandler:a=!1}=t;for(let o of e)if(n(o.visible)&&!(o.requiredPermissions?.length&&!r(o.requiredPermissions))&&!(o.requiresObject&&!i(`object`,o.requiresObject))&&!(o.requiresService&&!i(`service`,o.requiresService))&&o.type!==`separator`){if(o.type===`group`){if(P(o.children??[],t))return!0;continue}if(!(o.type===`action`&&!a))return!0}return!1}var F=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function I(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(F,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}var L=`runAction`;function R(e,t){let n=t.runAction;return typeof n!=`string`||n===``?e:`${e}${e.includes(`?`)?`&`:`?`}${L}=${encodeURIComponent(n)}`}function z(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=I(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}let a=e.filters;if(a&&typeof a==`object`&&!Array.isArray(a)){let t=new URLSearchParams;for(let[e,r]of Object.entries(a)){if(r==null||e===``)continue;let i=I(String(r),n);i!==null&&t.set(`filter[${e}]`,i)}let i=t.toString();return{href:R(i?`${r}/data?${i}`:`${r}/data`,e),external:!1}}return{href:R(e.viewName?`${r}/view/${e.viewName}`:r,e),external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null){if(typeof i==`string`){let r=I(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i))}let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(t!==`type`&&t!==`name`&&r!=null){if(typeof r==`string`){let i=I(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r))}let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}var ee=50,te=40,ne=30,B=25,re=10,ie=5;function ae(e){let t=new Map;return new URLSearchParams(e).forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.set(r[1],e)}),t}function V(e,t){return t.startsWith(`${e}.`)?t.slice(e.length+1):t}function oe(e,t,n,r,i){let{href:a,external:o}=z(e,r,i);if(o||a===`#`)return 0;if(e.type===`object`&&e.objectName){let a=`${r}/${e.objectName}`;if(t!==a&&!t.startsWith(`${a}/`))return 0;let o=t===a?[]:t.slice(a.length+1).split(`/`),s=e.recordId;if(s){let e=I(s,i);if(e)return o[0]===`record`&&decodeURIComponent(o[1]??``)===e?ee:0}let c=e.filters;if(c&&typeof c==`object`&&!Array.isArray(c)){if(o[0]!==`data`)return 0;let e=new Map;for(let[t,n]of Object.entries(c)){if(n==null||t===``)continue;let r=I(String(n),i);r!==null&&e.set(t,r)}if(e.size!==n.size)return 0;for(let[t,r]of e)if(n.get(t)!==r)return 0;return te}return e.viewName?o[0]!==`view`||!o[1]?0:V(e.objectName,decodeURIComponent(o[1]))===V(e.objectName,e.viewName)?ne:0:o.length===0?B:re}let s=a.split(`?`)[0];if(t===s)return B;let c=e.componentRef;return c&&c.split(`:`)[1]===`directory`?0:t.startsWith(`${s}/`)?ie:0}function H(e,t,n,r,i){let a=ae(n),o=null,s=0,c=e=>{if(e)for(let n of e){if(n.type===`group`){c(n.children);continue}let e=oe(n,t,a,r,i);e>s&&(o=n,s=e)}};return c(e),o}var U=n.default.createContext(null);function W(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=W(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return k(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var se=5;function ce({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,enableReorder:d,resolveObjectLabel:f,resolveDashboardLabel:p,resolveViewLabel:m,t:h,templateContext:g}){let{attributes:_,listeners:v,setNodeRef:y,transform:b,transition:x,isDragging:S}=(0,l.useSortable)({id:e.id,disabled:!d}),C={transform:u.CSS.Transform.toString(b),transition:x,opacity:S?.5:void 0,zIndex:S?10:void 0};return(0,o.jsx)(`div`,{ref:y,style:C,..._,children:(0,o.jsx)(G,{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,resolveViewLabel:m,t:h,templateContext:g})})}function G({item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,dragListeners:p,resolveObjectLabel:m,resolveDashboardLabel:h,resolveViewLabel:g,t:_,templateContext:v}){let y=(0,r.useIsMobile)(),b=y?`min-h-[44px] text-[15px] gap-3 rounded-xl`:void 0,x=(0,r.cn)(`shrink-0`,y?`h-5 w-5`:`h-4 w-4`),S=(()=>{if(typeof e.expanded==`boolean`)return e.expanded;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),C=e.type===`group`?e.children?.length??0:0,w=n.default.useContext(U),T=n.default.useMemo(()=>{if(e.type!==`group`||!w)return!1;let t=e=>!!e?.some(e=>e.id===w||e.type===`group`&&t(e.children));return t(e.children)},[e,w])?!0:S??!(C>=8),[E,D]=(0,n.useState)(T);if(!a(e.visible)||e.requiredPermissions?.length&&!c(e.requiredPermissions))return null;let j=e.requiresObject,M=e.requiresService;if(j&&!l(`object`,j)||M&&!l(`service`,M))return null;if(e.type===`separator`)return(0,o.jsx)(r.Separator,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0)),s=A(e,m,_,h,g);return(0,o.jsx)(r.Collapsible,{open:E,onOpenChange:D,children:(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsx)(r.SidebarGroupLabel,{asChild:!0,children:(0,o.jsxs)(r.CollapsibleTrigger,{className:(0,r.cn)(`flex w-full items-center justify-between`,y&&`min-h-[44px] text-[15px] rounded-xl`),children:[s,(0,o.jsx)(i.ChevronRight,{className:(0,r.cn)(`ml-auto transition-transform`,y?`h-5 w-5`:`h-4 w-4`,E&&`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)(G,{item:e,basePath:t,evalVis:a,checkPerm:c,checkCap:l,onAction:u,enablePinning:d,onPinToggle:f,resolveObjectLabel:m,resolveDashboardLabel:h,resolveViewLabel:g,t:_,templateContext:v},e.id))})})})]})})}if(e.type===`action`){if(!u)return null;let n=O(e.icon),a=k(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:a,onClick:()=>u?.(e),className:b,children:[(0,o.jsx)(n,{className:x}),(0,o.jsx)(`span`,{children:a}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":_?_(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${a}`:`Pin ${a}`,name:a}):e.pinned?`Unpin ${a}`:`Pin ${a}`,children:e.pinned?(0,o.jsx)(i.PinOff,{className:`h-3.5 w-3.5`}):(0,o.jsx)(i.Pin,{className:`h-3.5 w-3.5`})})]})}let N=O(e.icon),{href:P,external:F}=z(e,t,v),I=w!==null&&e.id===w,L=A(e,m,_,h,g),R=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(N,{className:x}),(0,o.jsx)(`span`,{children:L}),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:I,tooltip:L,className:b,children:F?(0,o.jsx)(`a`,{href:P,target:`_blank`,rel:`noopener noreferrer`,children:R}):(0,o.jsx)(s.Link,{to:P,children:R})}),d&&f&&(0,o.jsx)(r.SidebarMenuAction,{showOnHover:!0,onClick:()=>f(e.id,!e.pinned,e,t),"aria-label":_?_(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${L}`:`Pin ${L}`,name:L}):e.pinned?`Unpin ${L}`:`Pin ${L}`,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 K({items:e,basePath:t=``,evaluateVisibility:a=j,checkPermission:u=M,checkCapability:d=N,onAction:f,searchQuery:p,enablePinning:m,onPinToggle:h,enableReorder:g,onReorder:_,resolveObjectLabel:v,resolveDashboardLabel:y,resolveViewLabel:b,t:x,templateContext:S}){let C=(0,s.useLocation)(),w=(0,n.useMemo)(()=>H(e,C.pathname,C.search,t,S)?.id??null,[e,C.pathname,C.search,t,S]),T=(0,n.useMemo)(()=>p?W(e,p):e,[e,p]),E=(0,n.useMemo)(()=>q(T),[T]),D=T.slice().sort((e,t)=>(e.order??0)-(t.order??0)),O=(0,c.useSensors)((0,c.useSensor)(c.PointerSensor,{activationConstraint:{distance:se}}),(0,c.useSensor)(c.KeyboardSensor)),k=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!_)return;let r=D.findIndex(e=>e.id===t.id),i=D.findIndex(e=>e.id===n.id);r!==-1&&i!==-1&&_((0,l.arrayMove)(D,r,i).map((e,t)=>({...e,order:t})))},A={basePath:t,evalVis:a,checkPerm:u,checkCap:d,onAction:f,enablePinning:m,onPinToggle:h,resolveObjectLabel:v,resolveDashboardLabel:y,resolveViewLabel:b,t:x,templateContext:S},P=D.some(e=>e.type===`group`),F=E.length>0&&m?(0,o.jsxs)(r.SidebarGroup,{children:[(0,o.jsxs)(r.SidebarGroupLabel,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(i.Star,{className:`h-3.5 w-3.5`}),x?x(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,o.jsx)(r.SidebarGroupContent,{children:(0,o.jsx)(r.SidebarMenu,{children:E.map(e=>(0,o.jsx)(G,{item:e,...A},`fav-${e.id}`))})})]}):null;if(!P){let e=D.filter(e=>e.type!==`group`).map(e=>e.id),t=g?(0,o.jsx)(c.DndContext,{sensors:O,collisionDetection:c.closestCenter,onDragEnd:k,children:(0,o.jsx)(l.SortableContext,{items:e,strategy:l.verticalListSortingStrategy,children:(0,o.jsx)(r.SidebarMenu,{children:D.map(e=>(0,o.jsx)(ce,{item:e,enableReorder:g,...A},e.id))})})}):(0,o.jsx)(r.SidebarMenu,{children:D.map(e=>(0,o.jsx)(G,{item:e,...A},e.id))});return(0,o.jsxs)(U.Provider,{value:w,children:[F,(0,o.jsx)(r.SidebarGroup,{children:(0,o.jsx)(r.SidebarGroupContent,{children:t})})]})}let I=[],L=[],R=e=>{if(L.length===0)return;let t=L;L=[],I.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)(G,{item:e,...A},e.id))})})},e))};return D.forEach((e,t)=>{e.type===`group`?(R(`leaf-${t}`),I.push((0,o.jsx)(G,{item:e,...A},e.id))):L.push(e)}),R(`leaf-end`),(0,o.jsxs)(U.Provider,{value:w,children:[F,I]})}function q(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...q(n.children));return t}function J(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}}return{h:s*360,s:c*100,l:l*100}}function Y(e){let t=J(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function X(e){let t=J(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 Z(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 Q(e,t){(0,n.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=Y(e.primaryColor),i=X(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%`:Z(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=Y(e.accentColor),i=X(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%`:Z(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 $({sidebar:e,navbar:t,children:n,className:i,defaultOpen:a=!0,branding:s,rightRail:c}){return Q(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})}),c]})]})}function le(e){return(0,f.resolveI18nLabel)(e,void 0)??``}function ue({areas:e,activeAreaId:t,onAreaChange:n}){return e.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:e.map(e=>{let i=O(e.icon),a=le(e.label);return(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsxs)(r.SidebarMenuButton,{isActive:e.id===t,tooltip:a,onClick:()=>n(e.id),children:[(0,o.jsx)(i,{className:`h-4 w-4`}),(0,o.jsx)(`span`,{children:a})]})},e.id)})})})]})}function de({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=O(e.icon),i=`#`;if(e.type===`object`)i=`${t}/${e.objectName}`,e.viewName&&(i+=`/view/${e.viewName}`);else if(e.type===`dashboard`)i=e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`;else if(e.type===`page`)i=e.pageName?`${t}/page/${e.pageName}`:`#`;else if(e.type===`report`)i=e.reportName?`${t}/report/${e.reportName}`:`#`;else if(e.type===`url`)i=e.url??`#`;else if(e.type===`component`){let n=e.componentRef;if(n){i=`${t}/component/${n.split(`:`).filter(Boolean).join(`/`)}`;let r=e.params;if(r){let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(i+=`?${t}`)}}}let a=i!==`#`&&n.pathname.startsWith(i);return(0,o.jsxs)(s.Link,{to:i,className:`flex flex-col items-center gap-0.5 px-2 py-1.5 transition-colors min-w-[44px] min-h-[44px] justify-center ${a?`text-primary`:`text-muted-foreground hover:text-foreground`}`,children:[(0,o.jsx)(r,{className:`h-5 w-5`}),(0,o.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:k(e.label)})]},e.id)})})}function fe({schema:e,basePath:t,evalVis:i,checkPerm:a,checkCap:s,onAction:c,sidebarHeader:l,sidebarFooter:u,sidebarExtra:d,visibleAreas:f,activeAreaId:p,setActiveAreaId:m,resolvedNavigation:h,enableSearch:g,enablePinning:_,onPinToggle:v,enableReorder:y,onReorder:b}){let x=O(e.logo),[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)(x,{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})]})]})})}),g&&(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:[f.length>1&&p&&(0,o.jsx)(ue,{areas:f,activeAreaId:p,onAreaChange:m}),(0,o.jsx)(K,{items:h,basePath:t,evaluateVisibility:i,checkPermission:a,checkCapability:s,onAction:c,searchQuery:S,enablePinning:_,onPinToggle:v,enableReorder:y,onReorder:b}),d]}),u&&(0,o.jsx)(r.SidebarFooter,{children:u})]})}function pe({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,D=(e.areas??[]).filter(e=>P(e.navigation,{evaluateVisibility:S,checkPermission:C,checkCapability:w,hasActionHandler:!!c})),[O,k]=(0,n.useState)(()=>D.length>0?D[0].id:null),A=D.map(e=>e.id).join(`,`);(0,n.useEffect)(()=>{D.length>0?k(e=>D.some(t=>t.id===e)?e:D[0].id):k(null)},[e.name,A]);let j=D.find(e=>e.id===O)??D[0],M=j?.navigation??E,N={title:e.title,favicon:e.favicon},F=(0,o.jsx)(fe,{schema:e,basePath:t,evalVis:S,checkPerm:C,checkCap:w,onAction:c,sidebarHeader:u,sidebarFooter:f,sidebarExtra:p,visibleAreas:D,activeAreaId:j?.id??null,setActiveAreaId:k,resolvedNavigation:M,enableSearch:_,enablePinning:v,onPinToggle:y,enableReorder:b,onReorder:x});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)($,{sidebar:F,navbar:l,className:h,defaultOpen:g,branding:N,children:m}),r===`bottom_nav`&&(0,o.jsx)(de,{items:M,basePath:t})]})}function me(e){return`items`in e&&!(`href`in e)}function he({item:e,pathname:t}){return e.children&&e.children.length>0?(0,o.jsx)(r.Collapsible,{asChild:!0,defaultOpen:!0,className:`group/collapsible`,children:(0,o.jsxs)(r.SidebarMenuItem,{children:[(0,o.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,o.jsxs)(r.SidebarMenuButton,{tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto mr-1 h-5 min-w-5 px-1 text-xs`,children:e.badge}),(0,o.jsx)(i.ChevronRight,{className:`ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90`})]})}),(0,o.jsx)(r.CollapsibleContent,{className:`motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=closed]:slide-out-to-top-1 motion-safe:data-[state=open]:slide-in-from-top-1 motion-safe:duration-150`,children:(0,o.jsx)(r.SidebarMenuSub,{children:e.children.map(e=>(0,o.jsx)(r.SidebarMenuSubItem,{children:(0,o.jsx)(r.SidebarMenuSubButton,{asChild:!0,isActive:t===e.href,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})},e.href))})})]})}):(0,o.jsx)(r.SidebarMenuItem,{children:(0,o.jsx)(r.SidebarMenuButton,{asChild:!0,isActive:t===e.href,tooltip:e.title,className:`motion-safe:transition-colors motion-safe:duration-150`,children:(0,o.jsxs)(s.NavLink,{to:e.href,children:[e.icon&&(0,o.jsx)(e.icon,{}),(0,o.jsx)(`span`,{children:e.title}),e.badge!=null&&(0,o.jsx)(r.Badge,{variant:e.badgeVariant||`default`,className:`ml-auto h-5 min-w-5 px-1 text-xs`,children:e.badge})]})})})}function ge({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?[]:me(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)(he,{item:e,pathname:d.pathname},e.href))})})]},e.groupLabel||n))]})})}function _e(){t.ComponentRegistry.register(`page-header`,S,{namespace:`layout`,label:`Page Header`,category:`Layout`,isContainer:!0,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`subtitle`,type:`string`,label:`Subtitle`},{name:`icon`,type:`string`,label:`Icon`,description:`Lucide icon name`},{name:`actions`,type:`array`,label:`Actions`,description:`ActionDef list (or action ids) rendered through record:quick_actions`}]}),t.ComponentRegistry.register(`page:card`,C,{namespace:`layout`,skipFallback:!0,label:`Page Card`,category:`Layout`,isContainer:!0}),t.ComponentRegistry.register(`responsive-grid`,D,{namespace:`layout`,label:`Responsive Grid`,category:`Layout`,isContainer:!0,inputs:[{name:`columns`,type:`object`},{name:`gap`,type:`number`}]}),t.ComponentRegistry.register(`navigation-renderer`,K,{namespace:`layout`,label:`Navigation Renderer`,category:`Layout`,inputs:[{name:`items`,type:`array`,required:!0},{name:`basePath`,type:`string`}]}),t.ComponentRegistry.register(`app-schema-renderer`,pe,{namespace:`layout`,label:`App Schema Renderer`,category:`Layout`,isContainer:!0,inputs:[{name:`schema`,type:`object`},{name:`basePath`,type:`string`},{name:`mobileNavMode`,type:`enum`,enum:[`drawer`,`bottom_nav`],defaultValue:`drawer`,label:`Mobile Nav Mode`,description:`Mobile navigation mode. "drawer" (default) puts the sidebar in the mobile sheet overlay; "bottom_nav" additionally renders a fixed bottom bar. These are the only two modes the renderer implements.`}]})}try{_e()}catch{}e.AppSchemaRenderer=pe,e.AppShell=$,e.NAV_RUN_ACTION_PARAM=L,e.NavigationRenderer=K,e.PageCard=C,e.PageHeader=S,e.ResponsiveGrid=D,e.SidebarNav=ge,e.filterNavigationItems=W,e.hasVisibleNavigationItems=P,e.registerLayout=_e,e.resolveActiveNavItem=H,e.resolveHref=z,e.resolveIcon=O,e.resolveLabel=k,e.useAppShellBranding=Q});
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/layout",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.6.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"sideEffects":
|
|
5
|
+
"sideEffects": [
|
|
6
|
+
"./dist/index.js",
|
|
7
|
+
"./dist/index.umd.cjs",
|
|
8
|
+
"./src/index.ts"
|
|
9
|
+
],
|
|
6
10
|
"main": "dist/index.umd.cjs",
|
|
7
11
|
"module": "dist/index.js",
|
|
8
12
|
"types": "dist/index.d.ts",
|
|
@@ -17,15 +21,16 @@
|
|
|
17
21
|
"@dnd-kit/core": "^6.3.1",
|
|
18
22
|
"@dnd-kit/sortable": "^10.0.0",
|
|
19
23
|
"@dnd-kit/utilities": "^3.2.2",
|
|
24
|
+
"@objectstack/spec": "^17.0.0",
|
|
20
25
|
"clsx": "^2.1.1",
|
|
21
|
-
"lucide-react": "^1.
|
|
26
|
+
"lucide-react": "^1.31.0",
|
|
22
27
|
"react": "19.2.8",
|
|
23
28
|
"react-dom": "19.2.8",
|
|
24
29
|
"tailwind-merge": "^3.6.0",
|
|
25
|
-
"@object-ui/components": "17.
|
|
26
|
-
"@object-ui/core": "17.
|
|
27
|
-
"@object-ui/react": "17.
|
|
28
|
-
"@object-ui/types": "17.
|
|
30
|
+
"@object-ui/components": "17.6.0",
|
|
31
|
+
"@object-ui/core": "17.6.0",
|
|
32
|
+
"@object-ui/react": "17.6.0",
|
|
33
|
+
"@object-ui/types": "17.6.0"
|
|
29
34
|
},
|
|
30
35
|
"peerDependencies": {
|
|
31
36
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -33,12 +38,13 @@
|
|
|
33
38
|
"react-router-dom": "^6.0.0 || ^7.0.0"
|
|
34
39
|
},
|
|
35
40
|
"devDependencies": {
|
|
36
|
-
"@objectstack/spec": "^17.0.0-rc.2",
|
|
37
41
|
"@vitejs/plugin-react": "^6.0.5",
|
|
38
42
|
"react-router-dom": "^7.18.2",
|
|
39
|
-
"vite": "^8.2.
|
|
43
|
+
"vite": "^8.2.1",
|
|
40
44
|
"vite-plugin-dts": "^5.0.3",
|
|
41
|
-
"vitest": "^4.1.10"
|
|
45
|
+
"vitest": "^4.1.10",
|
|
46
|
+
"@object-ui/sdui-parser": "17.6.0",
|
|
47
|
+
"@object-ui/test-support": "17.4.0"
|
|
42
48
|
},
|
|
43
49
|
"description": "Layout components for Object UI — AppShell, PageHeader, SidebarNav and responsive containers with React Router integration",
|
|
44
50
|
"keywords": [
|