@object-ui/plugin-dashboard 4.0.10 → 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 +23 -0
- package/README.md +44 -0
- package/dist/index.js +730 -610
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-dashboard/src/DashboardConfigPanel.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/DashboardGridLayout.d.ts +17 -1
- package/dist/packages/plugin-dashboard/src/DashboardGridLayout.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/DashboardRenderer.d.ts +15 -1
- package/dist/packages/plugin-dashboard/src/DashboardRenderer.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/MetricWidget.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/ObjectDataTable.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/PivotTable.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/WidgetConfigPanel.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/index.d.ts.map +1 -1
- package/package.json +13 -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(`@object-ui/react`),require(`@object-ui/components`),require(`react`),require(`lucide-react`),require(`react/jsx-runtime`),require(`react-grid-layout`),require(`react-grid-layout/css/styles.css`),require(`@object-ui/i18n`),require(`@object-ui/fields`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`@object-ui/react`,`@object-ui/components`,`react`,`lucide-react`,`react/jsx-runtime`,`react-grid-layout`,`react-grid-layout/css/styles.css`,`@object-ui/i18n`,`@object-ui/fields`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDashboard={},e.ObjectUICore,e.ObjectUIReact,e.ObjectUIComponents,e.React,e.lucide_react,e.react_jsx_runtime,e.ReactGridLayout,e.react_grid_layout_css_styles_css,e.ObjectUII18n,e.ObjectUIFields))})(this,function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e};i=((e,t,n)=>(n=e==null?{}:d(h(e)),_(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e)))(i,1);function v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function y(e){return e?(0,r.getLazyIcon)(e):null}function b(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var x=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],S=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`]);function C(e){return S.has(e)?{enabled:!0}:void 0}var w=(0,i.forwardRef)(({schema:e,className:t,dataSource:s,onRefresh:c,recordCount:l,userActions:u,designMode:d,selectedWidgetId:f,onWidgetClick:p,modalHandler:m,scriptHandlers:h,...g},_)=>{let S=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),w=S,T=e.gap||4,[E,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(!1),A=(0,i.useRef)(null),{executeAction:j,engine:M}=(0,n.useActionEngine)({actions:(0,i.useMemo)(()=>(e.header?.actions??[]).map(e=>({name:e.actionUrl||e.label,type:e.actionType||`url`,target:e.actionUrl,label:e.label})),[e.header?.actions])}),{dashboardLabel:N,dashboardDescription:P,dashboardActionLabel:F,widgetTitle:I,widgetDescription:L,fieldLabel:R}=(0,n.useObjectLabel)(),z=e.name,B=(0,i.useCallback)(e=>z?F(z,e.actionUrl||e.label,e.label):e.label,[z,F]),V=(0,i.useCallback)(e=>{let t=b(e.title);return!z||!e.id||t===void 0?t:I(z,e.id,t)},[z,I]),H=(0,i.useCallback)(e=>{let t=b(e.description);return!z||!e.id?t:L(z,e.id,t)},[z,L]);(0,i.useEffect)(()=>{let e=M.getRunner();if(m&&e.setModalHandler(m),h)for(let[t,n]of Object.entries(h))e.registerScript(t,n)},[M,m,h]),(0,i.useEffect)(()=>{let e=()=>k(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let U=(0,i.useCallback)(()=>{c&&(D(!0),c(),setTimeout(()=>D(!1),600))},[c]);(0,i.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!c))return A.current=setInterval(U,e.refreshInterval*1e3),()=>{A.current&&clearInterval(A.current)}},[e.refreshInterval,c,U]);let W=(0,i.useCallback)((e,t)=>{!d||!p||!t||(e.stopPropagation(),p(t))},[d,p]),G=(0,i.useCallback)((t,n,r)=>{if(!d||!p)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),p(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&p(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&p(e.id)}else t.key===`Escape`&&(t.preventDefault(),p(null))},[d,p,e.widgets]),K=(0,i.useCallback)(e=>{!d||!p||e.target===e.currentTarget&&p(null)},[d,p]),q=(e,t,i)=>{let a=e.layout?{...e.layout,w:Math.min(e.layout.w,w)}:void 0,c=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`metric`&&e.object){let t=n.data,r=v(t)&&t.aggregate?{field:e.valueField||t.aggregate.field,function:e.aggregate||t.aggregate.function,groupBy:e.categoryField??t.aggregate.groupBy??`_all`}:e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object||(v(t)?t.object:void 0),aggregate:r,filter:(v(t)?t.filter:void 0)||e.filter,label:n.label||V(e)||``,fallbackValue:n.value,trend:n.trend,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,drillDown:n.drillDown??{enabled:!0},title:n.label||V(e)||``}}if((t===`gauge`||t===`solid-gauge`)&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object,aggregate:t,filter:e.filter,label:n.label||V(e)||``,fallbackValue:n.fallbackValue??n.value,icon:n.icon,description:n.description}}let r={}[t]||t;if(r===`bar`||r===`horizontal-bar`||r===`line`||r===`area`||r===`pie`||r===`donut`||r===`scatter`||r===`funnel`){let t=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(v(t)){let o=t.aggregate,s=o?{field:e.valueField||o.field,function:e.aggregate||o.function,groupBy:e.categoryField||o.groupBy}:void 0,c=s?.field||a,l=e.object||t.object;return{type:`object-chart`,chartType:r,objectName:l,aggregate:s,xAxisKey:i,series:[{dataKey:c,label:l?R(l,c,c):c}],colors:x,drillDown:n.drillDown??C(r),className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!t&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0,a=e.valueField||`value`;return{type:`object-chart`,chartType:r,objectName:e.object,aggregate:t,xAxisKey:i,series:[{dataKey:a,label:R(e.object,a,a)}],colors:x,drillDown:n.drillDown??C(r),className:`h-[200px] sm:h-[250px] md:h-[300px]`}}return{type:`chart`,chartType:r,data:Array.isArray(t)?t:t?.items||[],xAxisKey:i,series:[{dataKey:a,label:e.object?R(e.object,a,a):a}],colors:x,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data;if(v(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data,r=e,i={rowField:r.rowField??n.rowField,columnField:r.columnField??n.columnField,valueField:r.valueField??n.valueField,aggregation:r.aggregation??n.aggregation??`sum`,showRowTotals:r.showRowTotals??n.showRowTotals,showColumnTotals:r.showColumnTotals??n.showColumnTotals,format:r.format??n.format},a=(v(t)||!t&&e.object)&&n.drillDown===void 0?{...n,drillDown:{enabled:!0}}:n;if(v(t)){let{data:n,...r}=a;return{type:`object-pivot`,...r,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter}}return!t&&e.object?{type:`object-pivot`,...a,...i,objectName:e.object,filter:e.filter}:{type:`pivot`,...n,...i,data:Array.isArray(t)?t:t?.items||[]}}if(t===`list`){let t=e.data||n.data;if(v(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:Array.isArray(t)?t:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}return t===`custom`?{type:`text`,value:"Custom widget — set `component` to a UIComponent schema.",variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:{...e,...n}})(),l=e.type===`metric`,u=V(e),p=H(e),m=e.id||u||`widget-${t}`,h=d&&f===e.id,g=d?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":h,"aria-label":`Widget: ${u||`Widget ${t+1}`}`,onClick:t=>W(t,e.id),onKeyDown:n=>G(n,e.id,t)}:{},_=d?(0,r.cn)(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,h?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0;return l?(0,o.jsxs)(`div`,{className:(0,r.cn)(`h-full w-full`,d&&`relative`,_),style:!O&&a?{gridColumn:`span ${a.w}`,gridRow:`span ${a.h}`}:void 0,...g,children:[(0,o.jsx)(n.SchemaRenderer,{schema:c,className:(0,r.cn)(`h-full w-full`,d&&`pointer-events-none`),dataSource:s}),d&&(0,o.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},m):(0,o.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,i&&`w-full`,d&&`relative`,_),style:!O&&a?{gridColumn:`span ${a.w}`,gridRow:`span ${a.h}`}:void 0,...g,children:[u&&(0,o.jsxs)(r.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,o.jsx)(r.CardTitle,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:u,children:u}),p&&(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:p})]}),(0,o.jsx)(r.CardContent,{className:`p-0`,children:(0,o.jsx)(`div`,{className:(0,r.cn)(`h-full w-full`,`p-3 sm:p-4 md:p-6`,d&&`pointer-events-none`),children:(0,o.jsx)(n.SchemaRenderer,{schema:c,dataSource:s})})}),d&&(0,o.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},m)},J=e.header&&(0,o.jsxs)(`div`,{className:`col-span-full mb-4`,children:[e.header.showTitle!==!1&&e.title&&(0,o.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:z?N({name:z,label:b(e.title)}):b(e.title)}),e.header.showDescription!==!1&&e.description&&(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:z?P({name:z,description:b(e.description)}):b(e.description)}),e.header.actions&&e.header.actions.length>0&&(0,o.jsx)(`div`,{className:`flex gap-2 mt-3`,children:e.header.actions.map((e,t)=>{let n=y(e.icon);return(0,o.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:async()=>{let{actionType:t,actionUrl:n,label:r}=e;if(!t||!n){console.warn(`[DashboardRenderer] Header action missing actionType/actionUrl:`,e);return}if(t===`url`){/^https?:\/\//.test(n)||n.startsWith(`//`)?window.location.assign(n):(window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)));return}if(t===`modal`||t===`script`){let e=await j(n||r);e?.success||console.warn(`[DashboardRenderer] action failed`,e?.error);return}console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`)},children:[n&&(0,o.jsx)(n,{className:`w-4 h-4 mr-1.5`}),B(e)]},t)})})]}),ee=l!==void 0&&(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l.toLocaleString(),` records`]}),Y=u?JSON.stringify(u):void 0,X=c&&(0,o.jsxs)(`div`,{className:(0,r.cn)(`flex items-center justify-end gap-3 mb-2`,!O&&`col-span-full`),children:[ee,(0,o.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:U,disabled:E,"aria-label":`Refresh dashboard`,children:[(0,o.jsx)(a.RefreshCw,{className:(0,r.cn)(`h-4 w-4 mr-2`,E&&`animate-spin`)}),E?`Refreshing…`:`Refresh All`]})]});if(O){let n=e.widgets?.filter(e=>e.type===`metric`)||[],i=e.widgets?.filter(e=>e.type!==`metric`)||[];return(0,o.jsxs)(`div`,{ref:_,className:(0,r.cn)(`flex flex-col gap-4 px-4`,t),"data-user-actions":Y,onClick:K,...g,children:[J,X,n.length>0&&(0,o.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:K,children:n.map((e,t)=>q(e,t))}),i.length>0&&(0,o.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:K,children:i.map((e,t)=>q(e,t,!0))})]})}let Z=e.columns!=null||S!==4;return(0,o.jsxs)(`div`,{ref:_,className:(0,r.cn)(`grid auto-rows-min`,!Z&&`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...Z&&{gridTemplateColumns:`repeat(${w}, minmax(0, 1fr))`},gap:`${T*.25}rem`},"data-user-actions":Y,onClick:K,...g,children:[J,X,e.widgets?.map((e,t)=>q(e,t))]})});function T({editMode:e}){let t=(0,n.useDnd)();return i.useEffect(()=>{if(e)return t.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{t.endDrag()};t.endDrag(`dashboard`)},[e,t]),null}var E=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],D=({schema:e,className:t,onLayoutChange:c,persistLayoutKey:l=`dashboard-layout`,onRefresh:u})=>{let{width:d,containerRef:f,mounted:p}=(0,s.useContainerWidth)(),[m,h]=i.useState(!1),[g,_]=i.useState(!1),y=(0,n.useHasDndProvider)(),b=i.useRef(null),x=i.useCallback(()=>{u&&(_(!0),u(),setTimeout(()=>_(!1),600))},[u]);i.useEffect(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!u))return b.current=setInterval(x,e.refreshInterval*1e3),()=>{b.current&&clearInterval(b.current)}},[e.refreshInterval,u,x]);let[S,C]=i.useState(()=>{if(typeof window<`u`&&l){let e=localStorage.getItem(l);if(e)try{return JSON.parse(e)}catch(e){console.error(`Failed to parse saved layout:`,e)}}return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x||t%4*3,y:e.layout?.y||Math.floor(t/4)*4,w:e.layout?.w||3,h:e.layout?.h||4}))||[]}}),w=i.useCallback((e,t)=>{C(t),c?.(e)},[c]),D=i.useCallback(()=>{typeof window<`u`&&l&&localStorage.setItem(l,JSON.stringify(S)),h(!1)},[S,l]),O=i.useCallback(()=>{C({lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x||t%4*3,y:e.layout?.y||Math.floor(t/4)*4,w:e.layout?.w||3,h:e.layout?.h||4}))||[]}),typeof window<`u`&&l&&localStorage.removeItem(l)},[e.widgets,l]),k=i.useCallback(e=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`horizontal-bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`||t===`funnel`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(v(r)){let n=r.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a;return{type:`object-chart`,chartType:t,objectName:e.object||r.object,aggregate:o,xAxisKey:i,series:[{dataKey:s}],colors:E,className:`h-full`}}if(!r&&e.object){let n=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0;return{type:`object-chart`,chartType:t,objectName:e.object,aggregate:n,xAxisKey:i,series:[{dataKey:e.valueField||`value`}],colors:E,className:`h-full`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:E,className:`h-full`}}if(t===`table`){let t=e.data||n.data;if(v(t)){let{data:r,...i}=n;return{type:`data-table`,...i,objectName:e.object||t.object,dataProvider:t,data:[],searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`data-table`,...n,objectName:e.object,data:[],searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data;if(v(t)){let{data:r,...i}=n;return{type:`pivot`,...i,objectName:e.object||t.object,dataProvider:t,data:[]}}return{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}},[]);return(0,o.jsxs)(`div`,{ref:f,className:(0,r.cn)(`w-full`,t),"data-testid":`grid-layout`,children:[y&&(0,o.jsx)(T,{editMode:m}),(0,o.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,o.jsx)(`h2`,{className:`text-2xl font-bold`,children:e.title||`Dashboard`}),(0,o.jsx)(`div`,{className:`flex gap-2`,children:m?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(r.Button,{onClick:D,size:`sm`,variant:`default`,children:[(0,o.jsx)(a.Save,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,o.jsxs)(r.Button,{onClick:O,size:`sm`,variant:`outline`,children:[(0,o.jsx)(a.X,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,o.jsx)(r.Button,{onClick:()=>h(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,o.jsxs)(o.Fragment,{children:[u&&(0,o.jsxs)(r.Button,{onClick:x,size:`sm`,variant:`outline`,disabled:g,"aria-label":`Refresh dashboard`,children:[(0,o.jsx)(a.RefreshCw,{className:(0,r.cn)(`h-4 w-4 mr-2`,g&&`animate-spin`)}),g?`Refreshing…`:`Refresh All`]}),(0,o.jsxs)(r.Button,{onClick:()=>h(!0),size:`sm`,variant:`outline`,children:[(0,o.jsx)(a.Edit,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),p&&(0,o.jsx)(s.ResponsiveGridLayout,{className:`layout`,width:d,layouts:S,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:m,handle:`.drag-handle`},resizeConfig:{enabled:m},onLayoutChange:w,children:e.widgets?.map((e,t)=>{let i=e.id||`widget-${t}`,s=k(e);return(0,o.jsx)(`div`,{className:`h-full`,children:e.type===`metric`?(0,o.jsxs)(`div`,{className:`h-full w-full relative`,children:[m&&(0,o.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,o.jsx)(a.GripVertical,{className:`h-4 w-4`})}),(0,o.jsx)(n.SchemaRenderer,{schema:s,className:`h-full w-full`})]}):(0,o.jsxs)(r.Card,{className:(0,r.cn)(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,m&&`ring-2 ring-primary/20`),children:[e.title&&(0,o.jsxs)(r.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,o.jsx)(r.CardTitle,{className:`text-base font-medium tracking-tight truncate`,title:e.title,children:e.title}),m&&(0,o.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,o.jsx)(a.GripVertical,{className:`h-4 w-4`})})]}),(0,o.jsx)(r.CardContent,{className:`p-0 h-full`,children:(0,o.jsx)(`div`,{className:(0,r.cn)(`h-full w-full overflow-auto p-4`),children:(0,o.jsx)(n.SchemaRenderer,{schema:s})})})]})},i)})})]})};function O(e,t,n){if(e==null)return``;if(typeof e==`string`){let r=Number(e);return!isFinite(r)||e.trim()===``?e:O(r,t,n)}if(!isFinite(e))return String(e);let r={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`},i=(t||``).trim(),a=!!n||i.length>0&&r[i[0]]!==void 0,o=i.endsWith(`%`),s=i.match(/0\.(0+)/),c=s?s[1].length:0;if(a){let t=n||r[i[0]]||`USD`;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}catch{return`${t} ${e.toFixed(c)}`}}return o?`${(e>1?e:e*100).toFixed(c)}%`:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}function k(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var A={default:`bg-muted text-muted-foreground`,blue:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,teal:`bg-teal-500/10 text-teal-600 dark:text-teal-400`,orange:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,purple:`bg-purple-500/10 text-purple-600 dark:text-purple-400`,success:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},j=({label:e,value:t,trend:n,icon:s,className:c,description:l,loading:u,error:d,colorVariant:f=`default`,format:p,currency:m,prefix:h,suffix:g,onClick:_,...v})=>{let y=A[f]||A.default,b=(0,i.useMemo)(()=>{let e=typeof t==`number`||typeof t==`string`&&t.trim()!==``&&isFinite(Number(t))?O(t,p,m):t??``,n=String(e);return`${h&&n.startsWith(h)?``:h??``}${n}${g&&n.endsWith(g)?``:g??``}`},[t,p,m,h,g]),x=(0,i.useMemo)(()=>{if(typeof s==`string`){let e=(0,r.getLazyIcon)(s);return e?(0,o.jsx)(e,{className:`h-4 w-4`}):null}return s},[s]);return(0,o.jsxs)(r.Card,{className:(0,r.cn)(`h-full overflow-hidden`,_&&`cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,c),onClick:_,role:_?`button`:void 0,tabIndex:_?0:void 0,onKeyDown:_?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}:void 0,...v,children:[(0,o.jsxs)(r.CardHeader,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,o.jsx)(r.CardTitle,{className:`text-sm font-medium truncate`,children:k(e)}),x&&(0,o.jsx)(`div`,{className:(0,r.cn)(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,y),children:x})]}),(0,o.jsx)(r.CardContent,{children:u?(0,o.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,o.jsx)(a.Loader2,{className:`h-4 w-4 animate-spin`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,o.jsx)(a.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,o.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:`text-2xl font-bold truncate`,children:b}),(n||l)&&(0,o.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0`,children:[n&&(0,o.jsxs)(`span`,{className:(0,r.cn)(`flex items-center shrink-0 font-medium`,n.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,n.direction===`down`&&`text-rose-600 dark:text-rose-400`,n.direction===`neutral`&&`text-muted-foreground`),children:[n.direction===`up`&&(0,o.jsx)(a.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),n.direction===`down`&&(0,o.jsx)(a.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),n.direction===`neutral`&&(0,o.jsx)(a.MinusIcon,{className:`h-3 w-3 mr-1`}),n.value,`%`]}),(0,o.jsx)(`span`,{className:`truncate min-w-0`,children:k(l)||k(n?.label)})]})]})})]})};function M(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var N=({title:e,value:t,icon:n,trend:i,trendValue:s,description:c,className:l,loading:u,error:d,...f})=>{let p=n?(0,r.getLazyIcon)(n):null;return(0,o.jsxs)(r.Card,{className:(0,r.cn)(`h-full`,l),...f,children:[(0,o.jsxs)(r.CardHeader,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,o.jsx)(r.CardTitle,{className:`text-sm font-medium`,children:M(e)}),p&&(0,o.jsx)(p,{className:`h-4 w-4 text-muted-foreground`})]}),(0,o.jsx)(r.CardContent,{children:u?(0,o.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,o.jsx)(a.Loader2,{className:`h-4 w-4 animate-spin`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,o.jsx)(a.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,o.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(i||s||c)&&(0,o.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[i&&s&&(0,o.jsxs)(`span`,{className:(0,r.cn)(`flex items-center mr-2`,i===`up`&&`text-green-500`,i===`down`&&`text-red-500`,i===`neutral`&&`text-yellow-500`),children:[i===`up`&&(0,o.jsx)(a.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),i===`down`&&(0,o.jsx)(a.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),i===`neutral`&&(0,o.jsx)(a.MinusIcon,{className:`h-3 w-3 mr-1`}),s]}),M(c)]})]})})]})},P=({objectName:e,aggregate:a,filter:s,label:c,fallbackValue:l,trend:u,icon:d,className:f,description:p,dataSource:m,colorVariant:h,format:g,currency:_,prefix:v,suffix:y,drillDown:b,title:x})=>{let S=(0,i.useContext)(n.SchemaRendererContext),C=m||S?.dataSource,[w,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(null),[O,k]=(0,i.useState)(!1),[A,M]=(0,i.useState)(null),[N,P]=(0,i.useState)(null);(0,i.useEffect)(()=>{let t=!0;if(!(!C||!e||typeof C.getObjectSchema!=`function`))return C.getObjectSchema(e).then(e=>{t&&P(e)}).catch(()=>{}),()=>{t=!1}},[C,e]);let F=(0,i.useMemo)(()=>{let e=a?.field;if(!e||!N?.fields)return null;let t=N.fields;return Array.isArray(t)?t.find(t=>t?.name===e)||null:t[e]||null},[N,a?.field]),I=(0,i.useMemo)(()=>{if(g)return g;if(F){if(F.type===`currency`){let e=F.precision??F.scale??0;return e>0?`0,0.${`0`.repeat(e)}`:`0,0`}if(F.type===`percent`)return`0,0%`;if(F.type===`number`||F.type===`integer`)return`0,0`}},[g,F]),L=(0,i.useMemo)(()=>{if(_)return _;if(F?.type===`currency`)return F.defaultCurrency||F.currency||void 0},[_,F]),R=(0,i.useMemo)(()=>a?JSON.stringify(a):``,[a]),z=(0,i.useMemo)(()=>(0,t.resolveDateMacros)(s),[s]),B=(0,i.useCallback)(async(t,n)=>{if(!(!t||!e)){n.current&&(k(!0),M(null));try{let r;if(a&&typeof t.aggregate==`function`){let n=await t.aggregate(e,{field:a.field,function:a.function,groupBy:a.groupBy||`_all`,filter:z}),i=Array.isArray(n)?n:[];r=i.length===0?0:a.function===`count`?i.reduce((e,t)=>e+(Number(t[a.field])||Number(t.count)||0),0):i[0][a.field]??0}else if(typeof t.find==`function`){let n=await t.find(e,{$filter:z});r=(Array.isArray(n)?n:n?.data||n?.records||[]).length}else return;n.current&&D(r)}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),n.current&&M(e instanceof Error?e.message:`Failed to load metric`)}finally{n.current&&k(!1)}}},[e,R,(0,i.useMemo)(()=>z?JSON.stringify(z):``,[z])]);(0,i.useEffect)(()=>{let t={current:!0};return C&&e?B(C,t):(D(null),M(null)),()=>{t.current=!1}},[C,e,B]);let V=E===null?C?`—`:l??`—`:E,H=(0,t.isDrillEnabled)(b)&&!!e&&!!C,U=(0,i.useMemo)(()=>{let e=typeof c==`string`?c:c?.defaultValue||``;return(0,t.resolveDrillTitle)(b,{},(typeof x==`string`?x:x?.defaultValue||``)||e||`Details`)},[b,c,x]),W=(0,i.useMemo)(()=>{if(!H)return null;let t=b?.target??`drawer`,i=(0,o.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,o.jsx)(n.SchemaRenderer,{schema:{type:`object-data-table`,objectName:e,filter:z,pageSize:25,drillDown:{enabled:!1}}})});return t===`modal`?(0,o.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&T(!1),children:(0,o.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,o.jsx)(r.DialogHeader,{children:(0,o.jsx)(r.DialogTitle,{children:U})}),i]})}):(0,o.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&T(!1),children:(0,o.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,o.jsx)(r.SheetHeader,{children:(0,o.jsx)(r.SheetTitle,{children:U})}),(0,o.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:i})]})})},[H,b,e,z,U]);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(j,{label:c,value:V,trend:u,icon:d,className:f,description:p,loading:O,error:A,colorVariant:h,format:I,currency:L,prefix:v,suffix:y,onClick:H?()=>T(!0):void 0}),w&&W]})};function F(){try{let{t:e}=(0,l.useObjectTranslation)(),t=e(`dashboard.total`);return!t||t===`dashboard.total`?`Total`:t}catch{return`Total`}}function I(e,t){if(!t)return String(e);let n=``,r=``,i=!1,a,o=t,s=o.match(/^([^0-9.,#]*)/);if(s&&s[1]){let e=s[1];n=e.replace(`,`,``),e.includes(`,`)&&(i=!0),o=o.slice(s[1].length)}o.includes(`,`)&&(i=!0,o=o.replace(/,/g,``));let c=o.match(/\.(\d+)f?/);c&&(a=Number(c[1]),o=o.slice(c[0].length)),r=o.replace(/[0-9#.f]/g,``);let l=a===void 0?String(e):e.toFixed(a);if(i){let[e,t]=l.split(`.`),i=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?i:`${i}.${t}`)+r}return n+l+r}var L=`—`;function R(e,t){return e===``?L:t?.[e]??e}function z(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return e.reduce((e,t)=>e+t,0)}}var B=({schema:e,className:n,rowLabels:a,columnLabels:s,rowFieldLabel:c,onDrillDown:l})=>{let{title:u,rowField:d,columnField:f,valueField:p,aggregation:m=`sum`,data:h=[],showRowTotals:g=!1,showColumnTotals:_=!1,format:v,columnColors:y,drillDown:b}=e,x=F(),S=(0,t.isDrillEnabled)(b)&&typeof l==`function`,C=e=>{S&&l({...e,rowLabel:e.rowKey===void 0?e.rowLabel:a?.[e.rowKey]??e.rowKey,colLabel:e.colKey===void 0?e.colLabel:s?.[e.colKey]??e.colKey})},w=e=>t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},T=S?`cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]`:``,E=Array.isArray(h)?h:[],{rowKeys:D,colKeys:O,matrix:k,rowTotals:A,colTotals:j,grandTotal:M}=(0,i.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let r of E){let i=String(r[d]??``),a=String(r[f]??``),o=Number(r[p])||0;e.set(i,!0),t.set(a,!0),n[i]||(n[i]={}),n[i][a]||(n[i][a]=[]),n[i][a].push(o)}let r=Array.from(e.keys()),i=Array.from(t.keys()),a={},o={},s={};for(let e of r){a[e]={};let t=[];for(let r of i){let i=n[e]?.[r]??[],o=z(i,m);a[e][r]=o,t.push(...i),!s[r]&&s[r]}o[e]=z(t,m)}for(let e of i){let t=[];for(let i of r){let r=n[i]?.[e]??[];t.push(...r)}s[e]=z(t,m)}let c=[];for(let e of E)c.push(Number(e[p])||0);return{rowKeys:r,colKeys:i,matrix:a,rowTotals:o,colTotals:s,grandTotal:z(c,m)}},[E,d,f,p,m]),N=e=>I(e,v);return E.length===0?(0,o.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,n),children:[u&&(0,o.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:u}),(0,o.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,"data-testid":`pivot-empty-state`,children:[(0,o.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,o.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,o.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,o.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`}),(0,o.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`})]}),(0,o.jsx)(`p`,{className:`text-xs`,children:`No data available`})]})]}):(0,o.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,n),children:[u&&(0,o.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:u}),(0,o.jsxs)(`table`,{className:`w-full text-sm border-collapse table-auto`,role:`table`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,o.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground whitespace-nowrap`,children:c||d}),O.map(e=>{let t=()=>C({scope:`column`,colKey:e});return(0,o.jsx)(`th`,{className:(0,r.cn)(`text-right p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,y?.[e]??`text-muted-foreground`,T),title:e===``?`${f}: (empty)`:`${f}: ${e}`,role:S?`button`:void 0,tabIndex:S?0:void 0,onClick:S?t:void 0,onKeyDown:S?w(t):void 0,"aria-label":S?`Drill into ${f}: ${e||`(empty)`}`:void 0,children:R(e,s)},e)}),g&&(0,o.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap`,children:x})]})}),(0,o.jsx)(`tbody`,{children:D.map(e=>(0,o.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,o.jsx)(`td`,{className:(0,r.cn)(`p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,T),role:S?`button`:void 0,tabIndex:S?0:void 0,onClick:S?()=>C({scope:`row`,rowKey:e}):void 0,onKeyDown:S?w(()=>C({scope:`row`,rowKey:e})):void 0,"aria-label":S?`Drill into ${d}: ${e||`(empty)`}`:void 0,children:R(e,a)}),O.map(t=>{let n=k[e]?.[t]??0,i=()=>C({scope:`cell`,rowKey:e,colKey:t,value:n});return(0,o.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 tabular-nums`,y?.[t],T),role:S?`button`:void 0,tabIndex:S?0:void 0,onClick:S?i:void 0,onKeyDown:S?w(i):void 0,"aria-label":S?`Drill into ${d}=${e||`(empty)`}, ${f}=${t||`(empty)`}`:void 0,children:N(n)},t)}),g&&(0,o.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 font-semibold tabular-nums bg-muted/20`,T),role:S?`button`:void 0,tabIndex:S?0:void 0,onClick:S?()=>C({scope:`row`,rowKey:e,value:A[e]??0}):void 0,onKeyDown:S?w(()=>C({scope:`row`,rowKey:e,value:A[e]??0})):void 0,children:N(A[e]??0)})]},e))}),_&&(0,o.jsx)(`tfoot`,{children:(0,o.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,o.jsx)(`td`,{className:`p-2`,children:x}),O.map(e=>(0,o.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 tabular-nums`,T),role:S?`button`:void 0,tabIndex:S?0:void 0,onClick:S?()=>C({scope:`column`,colKey:e,value:j[e]??0}):void 0,onKeyDown:S?w(()=>C({scope:`column`,colKey:e,value:j[e]??0})):void 0,children:N(j[e]??0)},e)),g&&(0,o.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 tabular-nums font-bold`,T),role:S?`button`:void 0,tabIndex:S?0:void 0,onClick:S?()=>C({scope:`total`,value:M}):void 0,onKeyDown:S?w(()=>C({scope:`total`,value:M})):void 0,children:N(M)})]})})]})]})};function V(e){return e.map(e=>typeof e==`string`?{header:e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase()),accessorKey:e}:e)}function H(e,t){if(!t?.fields)return[];let n={};if(Array.isArray(t.fields))for(let e of t.fields)e?.name&&(n[e.name]=e);else for(let[e,r]of Object.entries(t.fields))n[e]={name:e,...r};let r=e=>e===`lookup`||e===`reference`||e===`master_detail`||e===`user`||e===`owner`,i=Array.isArray(e.columns)?e.columns:[],a=new Set;if(i.length>0){let e=i.map(e=>typeof e==`string`?e:e.accessorKey||e.name).filter(Boolean);for(let t of e){let e=n[t];e&&r(e.type)&&a.add(t)}}else for(let[e,t]of Object.entries(n))r(t?.type)&&a.add(e);return Array.from(a)}var U=({schema:e,dataSource:a,className:s})=>{let c=(0,i.useContext)(n.SchemaRendererContext),d=a||c?.dataSource,f=(0,n.useDataScope)(e.bind),{fieldLabel:p,fieldOptionLabel:m}=(0,l.useSafeFieldLabel)(),[h,g]=(0,i.useState)([]),[_,v]=(0,i.useState)(null),[y,b]=(0,i.useState)(!1),[x,S]=(0,i.useState)(null);(0,i.useEffect)(()=>{let n=!0;return e.objectName&&!f&&(!e.data||e.data.length===0)&&(async()=>{if(!(!d||!e.objectName)){n&&(b(!0),S(null));try{let r;if(typeof d.find==`function`){let n=H(e,_),i={$filter:(0,t.resolveDateMacros)(e.filter)};n.length&&(i.$expand=n),r=(0,t.extractRecords)(await d.find(e.objectName,i))}else return;n&&g(r)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),n&&S(e instanceof Error?e.message:`Failed to load data`)}finally{n&&b(!1)}}})(),()=>{n=!1}},[e.objectName,d,f,e.data,e.filter,_]),(0,i.useEffect)(()=>{let t=!0;if(!(!d||!e.objectName||typeof d.getObjectSchema!=`function`))return d.getObjectSchema(e.objectName).then(e=>{t&&v(e)}).catch(()=>{}),()=>{t=!1}},[e.objectName,d]);let C=f||e.data||h,w=Array.isArray(C)?C:[],T=(0,i.useMemo)(()=>{let t=e.objectName,n={};if(_?.fields){let e=_.fields;if(Array.isArray(e))for(let t of e)t?.name&&(n[t.name]=t);else for(let[t,r]of Object.entries(e))n[t]={name:t,...r}}let r=e=>{let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`);return t?p(t,e,n):n},i=e=>{let r=n[e.accessorKey],i=e.referenceTo??r?.referenceTo??(typeof r?.reference==`string`?r.reference:r?.reference?.to)??r?.target,a=e.options??r?.options;t&&a&&(r?.type===`select`||r?.type===`picklist`||r?.type===`dropdown`||r?.type===`status`)&&(a=a.map(n=>{if(n==null)return n;let r=typeof n==`object`?n.value:n,i=typeof n==`object`&&n.label||String(r);return{value:r,label:m(t,e.accessorKey,String(r),i),color:typeof n==`object`?n.color:void 0}}));let s={name:e.accessorKey,label:e.header,type:e.type??r?.type,options:a,referenceTo:i,format:e.format??r?.format,currency:e.currency??r?.currency??r?.defaultCurrency,decimals:e.decimals??r?.decimals??r?.precision??r?.scale},c=new Set([`currency`,`money`,`number`,`integer`,`decimal`,`float`,`percent`,`percentage`]),l=e.align??(c.has(s.type)||typeof s.format==`string`&&/^[\$¥€£]|%$|0/.test(s.format)?`right`:void 0);if(typeof e.cell==`function`)return{...e,...s,align:l};let d=e=>{if(e==null||e===``)return``;let t=s.format;if(typeof t==`string`&&/^\$|¥|€|£/.test(t)&&typeof e==`number`){let n={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`}[t[0]];return(0,u.formatCurrency)(e,s.currency||n)}if(typeof t==`string`&&/%/.test(t)&&typeof e==`number`){let n=(t.match(/0\.(0+)%/)||[,``])[1].length;return(0,u.formatPercent)((e>1?e/100:e)*100,n)}return typeof t==`string`&&/[YMDHms]/.test(t)?(0,u.formatDate)(e,t):(0,o.jsx)((0,u.getCellRenderer)((0,u.resolveCellRendererType)(s)),{value:e,field:s})};return{...e,...s,align:l,cell:d}};if(e.columns&&e.columns.length>0){let n=V(e.columns);return(t?n.map(e=>({...e,header:p(t,e.accessorKey,e.header)})):n).map(i)}if(w.length===0)return[];let a=new Set([`id`,`organization_id`,`tenant_id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`deleted_at`,`deleted_by`,`version`,`_id`,`__typename`]),s=(e,t)=>t&&(t.isSystem===!0||t.system===!0)?!0:a.has(e);return(Object.keys(n).length>0?Object.keys(n).filter(e=>!s(e,n[e])):Object.keys(w[0]).filter(e=>!e.startsWith(`_`)&&!s(e))).map(e=>i({header:r(e),accessorKey:e}))},[e.columns,e.objectName,w,_,p,m]);return y&&w.length===0?(0,o.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,s),"data-testid":`table-loading`,children:(0,o.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(r.Skeleton,{className:`h-6 w-1/4`}),(0,o.jsx)(r.Skeleton,{className:`h-6 w-1/4`}),(0,o.jsx)(r.Skeleton,{className:`h-6 w-1/4`}),(0,o.jsx)(r.Skeleton,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(r.Skeleton,{className:`h-5 w-1/4`}),(0,o.jsx)(r.Skeleton,{className:`h-5 w-1/4`}),(0,o.jsx)(r.Skeleton,{className:`h-5 w-1/4`}),(0,o.jsx)(r.Skeleton,{className:`h-5 w-1/4`})]},e))]})}):x?(0,o.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,s),"data-testid":`table-error`,children:(0,o.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,o.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,o.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,o.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,o.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,o.jsx)(`p`,{className:`text-xs`,children:x})]})}):!d&&e.objectName&&w.length===0?(0,o.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,s),children:(0,o.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,o.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})}):w.length===0?(0,o.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,s),"data-testid":`table-empty-state`,children:(0,o.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,o.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,o.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,o.jsx)(`line`,{x1:`3`,y1:`9`,x2:`21`,y2:`9`}),(0,o.jsx)(`line`,{x1:`9`,y1:`21`,x2:`9`,y2:`9`})]}),(0,o.jsx)(`p`,{className:`text-xs`,children:`No data available`})]})}):(0,o.jsx)(n.SchemaRenderer,{schema:{...e,type:`data-table`,data:w,columns:T},className:s})},W=({open:e,onClose:t,title:n,target:i=`drawer`,objectName:a,filter:s,dataSource:c,columns:l,maxRows:u,className:d})=>{let f={type:`object-data-table`,objectName:a,filter:s,columns:l?.map(e=>({accessorKey:e,header:e})),pagination:!0,searchable:!1,pageSize:u},p=(0,o.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,d),"data-testid":`drill-down-body`,children:(0,o.jsx)(U,{schema:f,dataSource:c})});return i===`dialog`?(0,o.jsx)(r.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,o.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,o.jsx)(r.DialogHeader,{children:(0,o.jsx)(r.DialogTitle,{children:n})}),p]})}):(0,o.jsx)(r.Sheet,{open:e,onOpenChange:e=>!e&&t(),children:(0,o.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,o.jsx)(r.SheetHeader,{children:(0,o.jsx)(r.SheetTitle,{children:n})}),(0,o.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:p})]})})},G=({schema:e,dataSource:a,className:s})=>{let c=(0,i.useContext)(n.SchemaRendererContext),u=a||c?.dataSource,d=(0,n.useDataScope)(e.bind),[f,p]=(0,i.useState)([]),[m,h]=(0,i.useState)(!1),[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)({}),[b,x]=(0,i.useState)({}),[S,C]=(0,i.useState)(null),{fieldLabel:w,fieldOptionLabel:T}=(0,l.useSafeFieldLabel)(),E=(0,i.useRef)(w),D=(0,i.useRef)(T);(0,i.useEffect)(()=>{E.current=w,D.current=T},[w,T]),(0,i.useEffect)(()=>{if(!u||!e.objectName)return;let t=u.getObjectSchema;if(typeof t!=`function`)return;let n=!0;return Promise.resolve(t.call(u,e.objectName)).then(t=>{if(!n||!t?.fields)return;let r=e.objectName,i={},a={};for(let[e,n]of Object.entries(t.fields)){let t=n?.label?String(n.label):e;a[e]=E.current(r,e,t);let o=n?.options;if(Array.isArray(o)&&o.length>0){let t={};for(let n of o)if(n&&n.value!==void 0&&n.label!==void 0){let i=String(n.value),a=String(n.label);t[i]=D.current(r,e,i,a)}Object.keys(t).length>0&&(i[e]=t)}}y(i),x(a)}).catch(()=>{}),()=>{n=!1}},[u,e.objectName]),(0,i.useEffect)(()=>{let n=!0;return e.objectName&&!d&&(!e.data||e.data.length===0)&&(async()=>{if(!(!u||!e.objectName)){n&&(h(!0),_(null));try{let r;if(typeof u.find==`function`)r=(0,t.extractRecords)(await u.find(e.objectName,{$filter:(0,t.resolveDateMacros)(e.filter)}));else return;n&&p(r)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),n&&_(e instanceof Error?e.message:`Failed to load data`)}finally{n&&h(!1)}}})(),()=>{n=!1}},[e.objectName,u,d,e.data,e.filter]);let O=d||e.data||f,k=Array.isArray(O)?O:[];if(m&&k.length===0)return(0,o.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,s),"data-testid":`pivot-loading`,children:[e.title&&(0,o.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,o.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(r.Skeleton,{className:`h-6 w-24`}),(0,o.jsx)(r.Skeleton,{className:`h-6 w-20`}),(0,o.jsx)(r.Skeleton,{className:`h-6 w-20`}),(0,o.jsx)(r.Skeleton,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(r.Skeleton,{className:`h-5 w-24`}),(0,o.jsx)(r.Skeleton,{className:`h-5 w-20`}),(0,o.jsx)(r.Skeleton,{className:`h-5 w-20`}),(0,o.jsx)(r.Skeleton,{className:`h-5 w-20`})]},e))]})]});if(g)return(0,o.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,s),"data-testid":`pivot-error`,children:[e.title&&(0,o.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,o.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,o.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,o.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,o.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,o.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,o.jsx)(`p`,{className:`text-xs`,children:g})]})]});if(!u&&e.objectName&&k.length===0)return(0,o.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,s),children:[e.title&&(0,o.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,o.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,o.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]});let A={...e,data:k},j=e.rowField?v[e.rowField]:void 0,M=e.columnField?v[e.columnField]:void 0,N=e.rowField?b[e.rowField]:void 0,P=e.drillDown,F=(0,t.isDrillEnabled)(P)?e=>C(e):void 0;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(B,{schema:A,className:s,rowLabels:j,columnLabels:M,rowFieldLabel:N,onDrillDown:F}),(()=>{if(!S||!e.objectName)return null;let n=(0,t.computeDrillFilter)(P,S,{rowField:e.rowField,columnField:e.columnField}),r={...e.filter||{},...n};return(0,o.jsx)(W,{open:!0,onClose:()=>C(null),title:(0,t.resolveDrillTitle)(P,S,e.title||`Details`),target:P?.target??`drawer`,objectName:e.objectName,filter:r,dataSource:u,columns:P?.columns,maxRows:P?.maxRows})})()]})},K={breadcrumb:[`Dashboard`,`Configuration`],sections:[{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`columns`,label:`Columns`,type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:`Gap`,type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:`Row height (px)`,type:`slider`,defaultValue:120,min:40,max:320,step:10}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`refreshInterval`,label:`Auto refresh`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Off`},{value:`30`,label:`Every 30s`},{value:`60`,label:`Every 1 min`},{value:`300`,label:`Every 5 min`},{value:`900`,label:`Every 15 min`},{value:`1800`,label:`Every 30 min`},{value:`3600`,label:`Every 1 hour`}]}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Dashboard title`},{key:`showDescription`,label:`Show description`,type:`switch`,defaultValue:!0},{key:`theme`,label:`Theme`,type:`select`,defaultValue:`auto`,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`auto`,label:`Auto`}]}]}]};function q({open:e,onClose:t,config:n,onSave:i,onFieldChange:a}){let{draft:s,isDirty:c,updateField:l,discard:u}=(0,r.useConfigDraft)(n,{onUpdate:a});return(0,o.jsx)(r.ConfigPanelRenderer,{open:e,onClose:t,schema:K,draft:s,isDirty:c,onFieldChange:l,onSave:()=>i(s),onDiscard:u})}var J=[{value:`metric`,label:`Metric`},{value:`bar`,label:`Bar Chart`},{value:`horizontal-bar`,label:`Horizontal Bar`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`donut`,label:`Donut Chart`},{value:`area`,label:`Area Chart`},{value:`scatter`,label:`Scatter Plot`},{value:`funnel`,label:`Funnel`},{value:`table`,label:`Table`},{value:`pivot`,label:`Pivot Table`},{value:`list`,label:`List`},{value:`custom`,label:`Custom`}],ee=[{value:`default`,label:`Default`},{value:`blue`,label:`Blue`},{value:`teal`,label:`Teal`},{value:`orange`,label:`Orange`},{value:`purple`,label:`Purple`},{value:`success`,label:`Success`},{value:`warning`,label:`Warning`},{value:`danger`,label:`Danger`}],Y=[{value:`count`,label:`Count`},{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}],X=[`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`],Z=[`bar`,`horizontal-bar`,`line`,`area`,`scatter`],te=[`pie`,`donut`,`funnel`],ne=[`metric`,...X],re=[...X],ie=[`pivot`,`metric`,`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`];function ae(e){return!!e&&X.includes(e)}function oe(e){return!!e&&Z.includes(e)}function se(e){return!!e&&re.includes(e)}function Q(e){return!!e&&ne.includes(e)}function ce(e){return!!e&&ie.includes(e)}var le=[{value:`drawer`,label:`Side drawer`},{value:`dialog`,label:`Center dialog`}],ue=[{value:`group`,label:`Group`},{value:`value`,label:`Value`}],de=[{value:`asc`,label:`↑`},{value:`desc`,label:`↓`}];function $(e,t,n,i){return{key:e,label:t,type:`custom`,render:(a,s,c)=>(0,o.jsx)(r.ConfigRow,{label:t,children:(0,o.jsx)(`div`,{"data-testid":`config-field-${e}`,children:(0,o.jsx)(r.Combobox,{options:i??[],value:a??``,onValueChange:s,placeholder:n,searchPlaceholder:`Search fields…`,emptyText:`No fields found.`,className:`h-7 w-32 text-xs`,disabled:!c.object})})})}}function fe(e,t,n){let i=e&&e.length>0,a=i?{key:`object`,label:`Data source`,type:`custom`,render:(t,n)=>(0,o.jsx)(r.ConfigRow,{label:`Data source`,children:(0,o.jsx)(`div`,{"data-testid":`config-field-object`,children:(0,o.jsx)(r.Combobox,{options:e,value:t??``,onValueChange:n,placeholder:`Select object…`,searchPlaceholder:`Search objects…`,emptyText:`No objects found.`,className:`h-7 w-32 text-xs`})})})}:{key:`object`,label:`Data source`,type:`input`,placeholder:`Object name`},s=i?{...$(`categoryField`,`Category field`,`Select field…`,t),helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>se(e.type)}:{key:`categoryField`,label:`Category field`,type:`input`,placeholder:`e.g. status`,helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>se(e.type)},c=i?{...$(`valueField`,`Value field`,`Select field…`,t),helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>Q(e.type)&&(e.aggregate??`count`)!==`count`}:{key:`valueField`,label:`Value field`,type:`input`,placeholder:`e.g. amount`,helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>Q(e.type)&&(e.aggregate??`count`)!==`count`},l=i?$(`rowField`,`Field`,`Select row field…`,t):{key:`rowField`,label:`Field`,type:`input`,placeholder:`e.g. owner`},u=i?$(`columnField`,`Field`,`Select column field…`,t):{key:`columnField`,label:`Field`,type:`input`,placeholder:`e.g. stage`},d=i?$(`valueField`,`Field`,`Select value field…`,t):{key:`valueField`,label:`Field`,type:`input`,placeholder:`e.g. amount`};return{breadcrumb:[`Dashboard`,{pivot:`Pivot table`,table:`Table`}[n??``]??(ae(n)?`Chart`:`Widget`)],sections:[{key:`general`,title:`General`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Widget title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Widget description`},{key:`type`,label:`Widget type`,type:`select`,options:J,defaultValue:`metric`}]},{key:`data`,title:`Data Binding`,collapsible:!0,visibleWhen:e=>e.type!==`pivot`,fields:[a,s,c,{key:`aggregate`,label:`Aggregation`,type:`select`,options:Y,defaultValue:`count`,helpText:`Count ignores Value field; Sum / Avg / Min / Max require it.`,visibleWhen:e=>Q(e.type)}]},{key:`pivot-data`,title:`Data`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[a]},{key:`pivot-rows`,title:`Rows`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[l,{key:`rowSortBy`,label:`Sort by`,type:`icon-group`,options:ue,defaultValue:`group`},{key:`rowSortOrder`,label:`Sort order`,type:`icon-group`,options:de,defaultValue:`asc`},{key:`showRowLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showRowTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-columns`,title:`Columns`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[u,{key:`columnSortBy`,label:`Sort by`,type:`icon-group`,options:ue,defaultValue:`group`},{key:`columnSortOrder`,label:`Sort order`,type:`icon-group`,options:de,defaultValue:`asc`},{key:`showColumnLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showColumnTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-values`,title:`Values`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[d,{key:`aggregation`,label:`Aggregation`,type:`select`,options:Y,defaultValue:`sum`},{key:`format`,label:`Number format`,type:`input`,placeholder:`e.g. $,.2f`}]},{key:`chart-axis`,title:`Axis & Series`,collapsible:!0,visibleWhen:e=>oe(e.type),fields:[{key:`xAxisLabel`,label:`X-axis label`,type:`input`,placeholder:`e.g. Month`},{key:`yAxisLabel`,label:`Y-axis label`,type:`input`,placeholder:`e.g. Revenue`},{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`chart-legend`,title:`Display`,collapsible:!0,visibleWhen:e=>!!e.type&&te.includes(e.type),fields:[{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`table-options`,title:`Table options`,collapsible:!0,visibleWhen:e=>e.type===`table`,fields:[{key:`searchable`,label:`Searchable`,type:`switch`,defaultValue:!1},{key:`pagination`,label:`Pagination`,type:`switch`,defaultValue:!1}]},{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`layoutW`,label:`Width (columns)`,type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:`Height (rows)`,type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`drill-down`,title:`Drill-down`,collapsible:!0,defaultCollapsed:!0,visibleWhen:e=>ce(e.type),fields:[{key:`drillDownEnabled`,label:`Enable drill-down`,type:`switch`,defaultValue:!1,helpText:`When enabled, clicking a cell / segment opens a filtered list of underlying records.`},{key:`drillDownTarget`,label:`Open in`,type:`select`,options:le,defaultValue:`drawer`,visibleWhen:e=>!!e.drillDownEnabled}]},{key:`behavior`,title:`Behavior`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`actionUrl`,label:`Click-through URL`,type:`input`,placeholder:`https://...`}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:`Color variant`,type:`select`,options:ee,defaultValue:`default`}]}]}}function pe(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.defaultValue||t.key||``}return String(e)}function me(e){let t=e.type,n={...e};return se(t)||delete n.categoryField,Q(t)?(n.aggregate??`count`)===`count`&&delete n.valueField:(delete n.valueField,delete n.aggregate),oe(t)||(delete n.xAxisLabel,delete n.yAxisLabel),t===`pivot`?(delete n.aggregate,delete n.categoryField):(delete n.rowField,delete n.columnField,delete n.aggregation,delete n.rowSortBy,delete n.rowSortOrder,delete n.columnSortBy,delete n.columnSortOrder,delete n.showRowLabels,delete n.showRowTotals,delete n.showColumnLabels,delete n.showColumnTotals,delete n.format),t!==`table`&&(delete n.searchable,delete n.pagination),ce(t)||(delete n.drillDownEnabled,delete n.drillDownTarget),n}function he({open:e,onClose:t,config:n,onSave:a,onFieldChange:s,headerExtra:c,availableObjects:l,availableFields:u}){let{draft:d,isDirty:f,updateField:p,discard:m}=(0,r.useConfigDraft)(i.useMemo(()=>({...n,title:typeof n.title==`object`?pe(n.title):n.title,description:typeof n.description==`object`?pe(n.description):n.description}),[n]),{onUpdate:s});return(0,o.jsx)(r.ConfigPanelRenderer,{open:e,onClose:t,schema:i.useMemo(()=>fe(l,u,d.type),[l,u,d.type]),draft:d,isDirty:f,onFieldChange:p,onSave:()=>a(me(d)),onDiscard:m,headerExtra:c})}function ge({schema:e,config:t,onConfigSave:n,onWidgetSave:s,onRefresh:c,recordCount:l,defaultConfigOpen:u=!1,className:d}){let[f,p]=(0,i.useState)(u),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(e),[v,y]=(0,i.useState)(0);(0,i.useEffect)(()=>{_(e),y(e=>e+1)},[e]);let b=i.useMemo(()=>{if(!m||!g.widgets)return null;let e=g.widgets.find(e=>(e.id||e.title)===m);if(!e)return null;let t=e.options||{};return{...t,id:e.id??``,title:e.title??``,description:e.description??``,type:e.type??``,object:e.object??``,categoryField:e.categoryField??t.categoryField??``,valueField:e.valueField??t.valueField??``,aggregate:e.aggregate??t.aggregate??``,colorVariant:e.colorVariant??t.colorVariant??`default`,actionUrl:e.actionUrl??t.actionUrl??``,drillDownEnabled:t.drillDown?.enabled??!!(e.object&&(e.type===`pivot`||e.type===`metric`||e.type===`bar`||e.type===`horizontal-bar`||e.type===`line`||e.type===`area`||e.type===`pie`||e.type===`donut`||e.type===`funnel`)),drillDownTarget:t.drillDown?.target??`drawer`,layoutW:e.layout?.w??1,layoutH:e.layout?.h??1}},[m,v]),x=(0,i.useCallback)(e=>{h(e),p(!0)},[]),S=(0,i.useCallback)(()=>{h(null)},[]),C=(0,i.useCallback)((e,t)=>{m&&_(n=>n.widgets?{...n,widgets:n.widgets.map(n=>{if((n.id||n.title)!==m)return n;if(e===`layoutW`)return{...n,layout:{...n.layout||{},w:t}};if(e===`layoutH`)return{...n,layout:{...n.layout||{},h:t}};if(e===`drillDownEnabled`||e===`drillDownTarget`){let r=n.options?.drillDown??{},i=e===`drillDownEnabled`?{...r,enabled:!!t}:{...r,target:t};return{...n,options:{...n.options||{},drillDown:i}}}return{...n,[e]:t}})}:n)},[m]),T=(0,i.useCallback)(e=>{if(m&&s){let{drillDownEnabled:t,drillDownTarget:n,...r}=e,i={...r};(t||n)&&(i.options={...r.options||{},drillDown:{...r.options?.drillDown||{},...t===void 0?{}:{enabled:!!t},...n===void 0?{}:{target:n}}}),s(m,i)}h(null),y(e=>e+1)},[m,s]),E=(0,i.useCallback)(()=>{p(e=>!e),h(null)},[]);return(0,o.jsxs)(`div`,{className:(0,r.cn)(`flex h-full w-full`,d),"data-testid":`dashboard-with-config`,children:[(0,o.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-auto relative`,children:[(0,o.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,o.jsxs)(r.Button,{size:`sm`,variant:f?`default`:`outline`,onClick:E,"data-testid":`dashboard-config-toggle`,children:[(0,o.jsx)(a.Settings,{className:`h-3.5 w-3.5 mr-1`}),`Settings`]})}),(0,o.jsx)(w,{schema:g,onRefresh:c,recordCount:l,designMode:f,selectedWidgetId:m,onWidgetClick:x})]}),f&&(0,o.jsx)(`div`,{className:`relative shrink-0`,children:m&&b?(0,o.jsx)(he,{open:!0,onClose:S,config:b,onSave:T,onFieldChange:C}):(0,o.jsx)(q,{open:!0,onClose:()=>p(!1),config:t,onSave:n})})]})}t.ComponentRegistry.register(`dashboard`,w,{namespace:`view`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`columns`,type:`number`,label:`Columns`,defaultValue:3},{name:`gap`,type:`number`,label:`Gap`,defaultValue:4},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:3,widgets:[]}}),t.ComponentRegistry.register(`metric`,j,{namespace:`plugin-dashboard`,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`,label:`Label`},{name:`value`,type:`string`,label:`Value`}]}),t.ComponentRegistry.register(`metric-card`,N,{namespace:`plugin-dashboard`,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`value`,type:`string`,label:`Value`,required:!0},{name:`icon`,type:`string`,label:`Icon (Lucide name)`},{name:`trend`,type:`enum`,label:`Trend`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`,label:`Trend Value (e.g., +12%)`},{name:`description`,type:`string`,label:`Description`}],defaultProps:{title:`Metric`,value:`0`}}),t.ComponentRegistry.register(`object-metric`,P,{namespace:`plugin-dashboard`,label:`Object Metric`,category:`Dashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`label`,type:`string`,label:`Label`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`},{name:`icon`,type:`string`,label:`Icon (Lucide name)`}],defaultProps:{label:`Metric`}}),t.ComponentRegistry.register(`pivot`,B,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}}),t.ComponentRegistry.register(`object-pivot`,G,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`filter`,type:`array`,label:`Filter`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),t.ComponentRegistry.register(`dashboard-grid`,D,{namespace:`plugin-dashboard`,label:`Dashboard Grid (Editable)`,category:`Complex`,icon:`layout-grid`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`persistLayoutKey`,type:`string`,label:`Layout Storage Key`,defaultValue:`dashboard-layout`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{title:`Dashboard`,widgets:[],persistLayoutKey:`dashboard-layout`}}),t.ComponentRegistry.register(`object-data-table`,U,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`searchable`,type:`boolean`,label:`Searchable`},{name:`pagination`,type:`boolean`,label:`Pagination`}],defaultProps:{searchable:!1,pagination:!1}});var _e={DashboardRenderer:w,DashboardGridLayout:D,MetricWidget:j,MetricCard:N,ObjectMetricWidget:P,PivotTable:B,ObjectPivotTable:G,ObjectDataTable:U,DashboardConfigPanel:q,WidgetConfigPanel:he,DashboardWithConfig:ge};e.DashboardConfigPanel=q,e.DashboardGridLayout=D,e.DashboardRenderer=w,e.DashboardWithConfig=ge,e.DrillDownDrawer=W,e.MetricCard=N,e.MetricWidget=j,e.ObjectDataTable=U,e.ObjectMetricWidget=P,e.ObjectPivotTable=G,e.PivotTable=B,e.WidgetConfigPanel=he,e.dashboardComponents=_e});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`@object-ui/react`),require(`@object-ui/components`),require(`react`),require(`lucide-react`),require(`@dnd-kit/core`),require(`@dnd-kit/sortable`),require(`@dnd-kit/utilities`),require(`react/jsx-runtime`),require(`react-grid-layout`),require(`react-grid-layout/css/styles.css`),require(`@object-ui/i18n`),require(`@object-ui/fields`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`@object-ui/react`,`@object-ui/components`,`react`,`lucide-react`,`@dnd-kit/core`,`@dnd-kit/sortable`,`@dnd-kit/utilities`,`react/jsx-runtime`,`react-grid-layout`,`react-grid-layout/css/styles.css`,`@object-ui/i18n`,`@object-ui/fields`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDashboard={},e.ObjectUICore,e.ObjectUIReact,e.ObjectUIComponents,e.React,e.lucide_react,e._dnd_kit_core,e._dnd_kit_sortable,e._dnd_kit_utilities,e.react_jsx_runtime,e.ReactGridLayout,e.react_grid_layout_css_styles_css,e.ObjectUII18n,e.ObjectUIFields))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var m=Object.create,h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,b=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!y.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e};i=((e,t,n)=>(n=e==null?{}:m(v(e)),b(t||!e||!e.__esModule?h(n,`default`,{value:e,enumerable:!0}):n,e)))(i,1);function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function S({id:e,disabled:t,gridSpan:n,className:i,children:a}){let{attributes:o,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m,isOver:h}=(0,s.useSortable)({id:e,disabled:t});return(0,l.jsx)(`div`,{ref:d,style:{transform:c.CSS.Transform.toString(f),transition:p,opacity:m?.4:1,...n?{gridColumn:`span ${n.w}`,gridRow:`span ${n.h}`}:{}},className:(0,r.cn)(`h-full w-full`,i,!t&&`cursor-grab active:cursor-grabbing`,h&&!m&&`ring-2 ring-primary ring-offset-2 rounded-lg`),"data-sortable-widget-id":e,...o,...u,children:a})}function C(e){return e?(0,r.getLazyIcon)(e):null}function w(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var T=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],E=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`]);function D(e){return E.has(e)?{enabled:!0}:void 0}var O=(0,i.forwardRef)(({schema:e,className:t,dataSource:c,onRefresh:u,recordCount:d,userActions:f,designMode:p,selectedWidgetId:m,onWidgetClick:h,onWidgetsReorder:g,modalHandler:_,scriptHandlers:v,hideHeaderText:y,...b},E)=>{let O=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),k=O,A=e.gap||4,[j,M]=(0,i.useState)(!1),[N,P]=(0,i.useState)(!1),F=(0,i.useRef)(null),{executeAction:I,engine:L}=(0,n.useActionEngine)({actions:(0,i.useMemo)(()=>(e.header?.actions??[]).map(e=>({name:e.actionUrl||e.label,type:e.actionType||`url`,target:e.actionUrl,label:e.label})),[e.header?.actions])}),{dashboardLabel:R,dashboardDescription:z,dashboardActionLabel:B,widgetTitle:V,widgetDescription:H,fieldLabel:U}=(0,n.useObjectLabel)(),W=e.name,ee=(0,i.useCallback)(e=>W?B(W,e.actionUrl||e.label,e.label):e.label,[W,B]),G=(0,i.useCallback)(e=>{let t=w(e.title);return!W||!e.id||t===void 0?t:V(W,e.id,t)},[W,V]),te=(0,i.useCallback)(e=>{let t=w(e.description);return!W||!e.id?t:H(W,e.id,t)},[W,H]);(0,i.useEffect)(()=>{let e=L.getRunner();if(_&&e.setModalHandler(_),v)for(let[t,n]of Object.entries(v))e.registerScript(t,n)},[L,_,v]),(0,i.useEffect)(()=>{let e=()=>P(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let K=(0,i.useCallback)(()=>{u&&(M(!0),u(),setTimeout(()=>M(!1),600))},[u]);(0,i.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!u))return F.current=setInterval(K,e.refreshInterval*1e3),()=>{F.current&&clearInterval(F.current)}},[e.refreshInterval,u,K]);let q=(0,i.useCallback)((e,t)=>{!p||!h||!t||(e.stopPropagation(),h(t))},[p,h]),ne=(0,i.useCallback)((t,n,r)=>{if(!p||!h)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),h(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&h(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&h(e.id)}else t.key===`Escape`&&(t.preventDefault(),h(null))},[p,h,e.widgets]),J=(0,i.useCallback)(e=>{!p||!h||e.target===e.currentTarget&&h(null)},[p,h]),Y=!!(p&&g),X=(0,o.useSensors)((0,o.useSensor)(o.PointerSensor,{activationConstraint:{distance:5}})),Z=(0,i.useCallback)(t=>{if(!Y)return;let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.widgets??[],a=i.findIndex(e=>e.id===n.id),o=i.findIndex(e=>e.id===r.id);a<0||o<0||g?.((0,s.arrayMove)(i,a,o))},[Y,e.widgets,g]),re=(e,t,a)=>{let o=e.layout?{...e.layout,w:Math.min(e.layout.w,k)}:void 0,s=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`metric`&&e.object){let t=n.data,r=x(t)&&t.aggregate?{field:e.valueField||t.aggregate.field,function:e.aggregate||t.aggregate.function,groupBy:e.categoryField??t.aggregate.groupBy??`_all`}:e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object||(x(t)?t.object:void 0),aggregate:r,filter:(x(t)?t.filter:void 0)||e.filter,label:n.label||G(e)||``,fallbackValue:n.value,trend:n.trend,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,drillDown:n.drillDown??{enabled:!0},title:n.label||G(e)||``}}if((t===`gauge`||t===`solid-gauge`)&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object,aggregate:t,filter:e.filter,label:n.label||G(e)||``,fallbackValue:n.fallbackValue??n.value,icon:n.icon,description:n.description}}let r={}[t]||t;if(r===`bar`||r===`horizontal-bar`||r===`line`||r===`area`||r===`pie`||r===`donut`||r===`scatter`||r===`funnel`){let t=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(x(t)){let o=t.aggregate,s=o?{field:e.valueField||o.field,function:e.aggregate||o.function,groupBy:e.categoryField||o.groupBy}:void 0,c=s?.field||a,l=e.object||t.object;return{type:`object-chart`,chartType:r,objectName:l,aggregate:s,xAxisKey:i,series:[{dataKey:c,label:l?U(l,c,c):c}],colors:T,drillDown:n.drillDown??D(r),className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!t&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0,a=e.valueField||`value`;return{type:`object-chart`,chartType:r,objectName:e.object,aggregate:t,xAxisKey:i,series:[{dataKey:a,label:U(e.object,a,a)}],colors:T,drillDown:n.drillDown??D(r),className:`h-[200px] sm:h-[250px] md:h-[300px]`}}return{type:`chart`,chartType:r,data:Array.isArray(t)?t:t?.items||[],xAxisKey:i,series:[{dataKey:a,label:e.object?U(e.object,a,a):a}],colors:T,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data;if(x(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data,r=e,i={rowField:r.rowField??n.rowField,columnField:r.columnField??n.columnField,valueField:r.valueField??n.valueField,aggregation:r.aggregation??n.aggregation??`sum`,showRowTotals:r.showRowTotals??n.showRowTotals,showColumnTotals:r.showColumnTotals??n.showColumnTotals,format:r.format??n.format},a=(x(t)||!t&&e.object)&&n.drillDown===void 0?{...n,drillDown:{enabled:!0}}:n;if(x(t)){let{data:n,...r}=a;return{type:`object-pivot`,...r,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter}}return!t&&e.object?{type:`object-pivot`,...a,...i,objectName:e.object,filter:e.filter}:{type:`pivot`,...n,...i,data:Array.isArray(t)?t:t?.items||[]}}if(t===`list`){let t=e.data||n.data;if(x(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:Array.isArray(t)?t:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}return t===`custom`?{type:`text`,value:"Custom widget — set `component` to a UIComponent schema.",variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:{...e,...n}})(),u=e.type===`metric`,d=G(e),f=te(e),h=e.id||d||`widget-${t}`,g=p&&m===e.id,_=p?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":g,"aria-label":`Widget: ${d||`Widget ${t+1}`}`,onClick:t=>q(t,e.id),onKeyDown:n=>ne(n,e.id,t)}:{},v=p?(0,r.cn)(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,g?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0,y=!N&&o&&!Y?{gridColumn:`span ${o.w}`,gridRow:`span ${o.h}`}:void 0,b=u?(0,l.jsxs)(`div`,{className:(0,r.cn)(`h-full w-full`,p&&`relative`,v),style:y,..._,children:[(0,l.jsx)(n.SchemaRenderer,{schema:s,className:(0,r.cn)(`h-full w-full`,p&&`pointer-events-none`),dataSource:c}),p&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]}):(0,l.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,a&&`w-full`,p&&`relative`,v),style:y,..._,children:[d&&(0,l.jsxs)(r.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,l.jsx)(r.CardTitle,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:d,children:d}),f&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:f})]}),(0,l.jsx)(r.CardContent,{className:`p-0`,children:(0,l.jsx)(`div`,{className:(0,r.cn)(`h-full w-full`,`p-3 sm:p-4 md:p-6`,p&&`pointer-events-none`),children:(0,l.jsx)(n.SchemaRenderer,{schema:s,dataSource:c})})}),p&&(0,l.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]});return Y&&e.id?(0,l.jsx)(S,{id:e.id,gridSpan:!N&&o?{w:o.w,h:o.h}:void 0,children:b},h):(0,l.jsx)(i.Fragment,{children:b},h)},Q=e.header&&(0,l.jsxs)(`div`,{className:`col-span-full mb-4`,children:[!y&&e.header.showTitle!==!1&&e.title&&(0,l.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:W?R({name:W,label:w(e.title)}):w(e.title)}),!y&&e.header.showDescription!==!1&&e.description&&(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:W?z({name:W,description:w(e.description)}):w(e.description)}),e.header.actions&&e.header.actions.length>0&&(0,l.jsx)(`div`,{className:`flex gap-2 mt-3`,children:e.header.actions.map((e,t)=>{let n=C(e.icon);return(0,l.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:async()=>{let{actionType:t,actionUrl:n,label:r}=e;if(!t||!n){console.warn(`[DashboardRenderer] Header action missing actionType/actionUrl:`,e);return}if(t===`url`){/^https?:\/\//.test(n)||n.startsWith(`//`)?window.location.assign(n):(window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)));return}if(t===`modal`||t===`script`){let e=await I(n||r);e?.success||console.warn(`[DashboardRenderer] action failed`,e?.error);return}console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`)},children:[n&&(0,l.jsx)(n,{className:`w-4 h-4 mr-1.5`}),ee(e)]},t)})})]}),ie=d!==void 0&&(0,l.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[d.toLocaleString(),` records`]}),ae=f?JSON.stringify(f):void 0,oe=u&&(0,l.jsxs)(`div`,{className:(0,r.cn)(`flex items-center justify-end gap-3 mb-2`,!N&&`col-span-full`),children:[ie,(0,l.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:K,disabled:j,"aria-label":`Refresh dashboard`,children:[(0,l.jsx)(a.RefreshCw,{className:(0,r.cn)(`h-4 w-4 mr-2`,j&&`animate-spin`)}),j?`Refreshing…`:`Refresh All`]})]}),se=(0,i.useMemo)(()=>(e.widgets??[]).map(e=>e.id).filter(e=>!!e),[e.widgets]),ce=(0,i.useMemo)(()=>(e.widgets??[]).filter(e=>e.type===`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]),le=(0,i.useMemo)(()=>(e.widgets??[]).filter(e=>e.type!==`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]);if(N){let n=e.widgets?.filter(e=>e.type===`metric`)||[],i=e.widgets?.filter(e=>e.type!==`metric`)||[],a=(0,l.jsxs)(`div`,{ref:E,className:(0,r.cn)(`flex flex-col gap-4 px-4`,t),"data-user-actions":ae,onClick:J,...b,children:[Q,oe,n.length>0&&(0,l.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:J,children:(0,l.jsx)(s.SortableContext,{items:ce,strategy:s.rectSortingStrategy,disabled:!Y,children:n.map((e,t)=>re(e,t))})}),i.length>0&&(0,l.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:J,children:(0,l.jsx)(s.SortableContext,{items:le,strategy:s.verticalListSortingStrategy,disabled:!Y,children:i.map((e,t)=>re(e,t,!0))})})]});return Y?(0,l.jsx)(o.DndContext,{sensors:X,collisionDetection:o.closestCenter,onDragEnd:Z,children:a}):a}let ue=e.columns!=null||O!==4,de=(0,l.jsxs)(`div`,{ref:E,className:(0,r.cn)(`grid auto-rows-min`,!ue&&`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...ue&&{gridTemplateColumns:`repeat(${k}, minmax(0, 1fr))`},gap:`${A*.25}rem`},"data-user-actions":ae,onClick:J,...b,children:[Q,oe,(0,l.jsx)(s.SortableContext,{items:se,strategy:s.rectSortingStrategy,disabled:!Y,children:e.widgets?.map((e,t)=>re(e,t))})]});return Y?(0,l.jsx)(o.DndContext,{sensors:X,collisionDetection:o.closestCenter,onDragEnd:Z,children:de}):de});function k({editMode:e}){let t=(0,n.useDnd)();return i.useEffect(()=>{if(e)return t.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{t.endDrag()};t.endDrag(`dashboard`)},[e,t]),null}var A=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];function j(e,t){if(!e.widgets?.length)return e;let n=new Map(t.map(e=>[e.i,e])),r=e.widgets.map((e,t)=>{let r=e.id||`widget-${t}`,i=n.get(r);return i?{...e,layout:{x:i.x,y:i.y,w:i.w,h:i.h}}:e});return{...e,widgets:r}}function M(e){return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x??t%4*3,y:e.layout?.y??Math.floor(t/4)*4,w:e.layout?.w??3,h:e.layout?.h??4}))||[]}}var N=({schema:e,className:t,onLayoutChange:o,onSchemaChange:s,onRefresh:c})=>{let{width:d,containerRef:f,mounted:p}=(0,u.useContainerWidth)(),[m,h]=i.useState(!1),[g,_]=i.useState(!1),v=(0,n.useHasDndProvider)(),y=i.useRef(null),b=i.useCallback(()=>{c&&(_(!0),c(),setTimeout(()=>_(!1),600))},[c]);i.useEffect(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!c))return y.current=setInterval(b,e.refreshInterval*1e3),()=>{y.current&&clearInterval(y.current)}},[e.refreshInterval,c,b]);let[S,C]=i.useState(()=>M(e)),w=i.useMemo(()=>JSON.stringify(e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x,y:e.layout?.y,w:e.layout?.w,h:e.layout?.h}))??[]),[e.widgets]);i.useEffect(()=>{C(M(e))},[w]);let T=i.useCallback((e,t)=>{C(t),o?.(e)},[o]),E=i.useCallback(()=>{s?s(j(e,S.lg)):process.env.NODE_ENV!==`production`&&console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."),h(!1)},[s,e,S]),D=i.useCallback(()=>{C(M(e))},[e]),O=i.useCallback(e=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`horizontal-bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`||t===`funnel`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(x(r)){let n=r.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a;return{type:`object-chart`,chartType:t,objectName:e.object||r.object,aggregate:o,xAxisKey:i,series:[{dataKey:s}],colors:A,className:`h-full`}}if(!r&&e.object){let n=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0;return{type:`object-chart`,chartType:t,objectName:e.object,aggregate:n,xAxisKey:i,series:[{dataKey:e.valueField||`value`}],colors:A,className:`h-full`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:A,className:`h-full`}}if(t===`table`){let t=e.data||n.data;if(x(t)){let{data:r,...i}=n;return{type:`data-table`,...i,objectName:e.object||t.object,dataProvider:t,data:[],searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`data-table`,...n,objectName:e.object,data:[],searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data;if(x(t)){let{data:r,...i}=n;return{type:`pivot`,...i,objectName:e.object||t.object,dataProvider:t,data:[]}}return{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}},[]);return(0,l.jsxs)(`div`,{ref:f,className:(0,r.cn)(`w-full`,t),"data-testid":`grid-layout`,children:[v&&(0,l.jsx)(k,{editMode:m}),(0,l.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,l.jsx)(`h2`,{className:`text-2xl font-bold`,children:e.title||`Dashboard`}),(0,l.jsx)(`div`,{className:`flex gap-2`,children:m?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(r.Button,{onClick:E,size:`sm`,variant:`default`,children:[(0,l.jsx)(a.Save,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,l.jsxs)(r.Button,{onClick:D,size:`sm`,variant:`outline`,children:[(0,l.jsx)(a.X,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,l.jsx)(r.Button,{onClick:()=>h(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,l.jsxs)(l.Fragment,{children:[c&&(0,l.jsxs)(r.Button,{onClick:b,size:`sm`,variant:`outline`,disabled:g,"aria-label":`Refresh dashboard`,children:[(0,l.jsx)(a.RefreshCw,{className:(0,r.cn)(`h-4 w-4 mr-2`,g&&`animate-spin`)}),g?`Refreshing…`:`Refresh All`]}),(0,l.jsxs)(r.Button,{onClick:()=>h(!0),size:`sm`,variant:`outline`,children:[(0,l.jsx)(a.Edit,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),p&&(0,l.jsx)(u.ResponsiveGridLayout,{className:`layout`,width:d,layouts:S,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:m,handle:`.drag-handle`},resizeConfig:{enabled:m},onLayoutChange:T,children:e.widgets?.map((e,t)=>{let i=e.id||`widget-${t}`,o=O(e);return(0,l.jsx)(`div`,{className:`h-full`,children:e.type===`metric`?(0,l.jsxs)(`div`,{className:`h-full w-full relative`,children:[m&&(0,l.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,l.jsx)(a.GripVertical,{className:`h-4 w-4`})}),(0,l.jsx)(n.SchemaRenderer,{schema:o,className:`h-full w-full`})]}):(0,l.jsxs)(r.Card,{className:(0,r.cn)(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,m&&`ring-2 ring-primary/20`),children:[e.title&&(0,l.jsxs)(r.CardHeader,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,l.jsx)(r.CardTitle,{className:`text-base font-medium tracking-tight truncate`,title:e.title,children:e.title}),m&&(0,l.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,l.jsx)(a.GripVertical,{className:`h-4 w-4`})})]}),(0,l.jsx)(r.CardContent,{className:`p-0 h-full`,children:(0,l.jsx)(`div`,{className:(0,r.cn)(`h-full w-full overflow-auto p-4`),children:(0,l.jsx)(n.SchemaRenderer,{schema:o})})})]})},i)})})]})},P=(0,f.createSafeTranslation)({"dashboard.trend.vsLastQuarter":`vs last quarter`,"dashboard.trend.vsLastMonth":`vs last month`,"dashboard.trend.vsLastWeek":`vs last week`,"dashboard.trend.vsLastYear":`vs last year`,"dashboard.trend.vsYesterday":`vs yesterday`,"dashboard.trend.vsPreviousPeriod":`vs previous period`},`dashboard.trend.vsLastQuarter`);function F(e){switch(e.trim().toLowerCase().replace(/\s+/g,` `)){case`vs last quarter`:case`vs previous quarter`:return`dashboard.trend.vsLastQuarter`;case`vs last month`:case`vs previous month`:return`dashboard.trend.vsLastMonth`;case`vs last week`:case`vs previous week`:return`dashboard.trend.vsLastWeek`;case`vs last year`:case`vs previous year`:return`dashboard.trend.vsLastYear`;case`vs yesterday`:return`dashboard.trend.vsYesterday`;case`vs previous period`:case`vs prior period`:return`dashboard.trend.vsPreviousPeriod`;default:return}}function I(e,t,n){if(e==null)return``;if(typeof e==`string`){let r=Number(e);return!isFinite(r)||e.trim()===``?e:I(r,t,n)}if(!isFinite(e))return String(e);let r={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`},i=(t||``).trim(),a=!!n||i.length>0&&r[i[0]]!==void 0,o=i.endsWith(`%`),s=i.match(/0\.(0+)/),c=s?s[1].length:0;if(a){let t=n||r[i[0]]||`USD`;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}catch{return`${t} ${e.toFixed(c)}`}}return o?`${(e>1?e:e*100).toFixed(c)}%`:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}function L(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var R={default:`bg-muted text-muted-foreground`,blue:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,teal:`bg-teal-500/10 text-teal-600 dark:text-teal-400`,orange:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,purple:`bg-purple-500/10 text-purple-600 dark:text-purple-400`,success:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},z=({label:e,value:t,trend:n,icon:o,className:s,description:c,loading:u,error:d,colorVariant:f=`default`,format:p,currency:m,prefix:h,suffix:g,onClick:_,...v})=>{let y=R[f]||R.default,{t:b}=P(),x=(0,i.useMemo)(()=>{let e=L(c)||L(n?.label);if(!e)return e;let t=F(e);return t?b(t):e},[c,n?.label,b]),S=(0,i.useMemo)(()=>{let e=typeof t==`number`||typeof t==`string`&&t.trim()!==``&&isFinite(Number(t))?I(t,p,m):t??``,n=String(e);return`${h&&n.startsWith(h)?``:h??``}${n}${g&&n.endsWith(g)?``:g??``}`},[t,p,m,h,g]),C=(0,i.useMemo)(()=>{if(typeof o==`string`){let e=(0,r.getLazyIcon)(o);return e?(0,l.jsx)(e,{className:`h-4 w-4`}):null}return o},[o]);return(0,l.jsxs)(r.Card,{className:(0,r.cn)(`h-full overflow-hidden`,_&&`cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,s),onClick:_,role:_?`button`:void 0,tabIndex:_?0:void 0,onKeyDown:_?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}:void 0,...v,children:[(0,l.jsxs)(r.CardHeader,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,l.jsx)(r.CardTitle,{className:`text-sm font-medium truncate`,children:L(e)}),C&&(0,l.jsx)(`div`,{className:(0,r.cn)(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,y),children:C})]}),(0,l.jsx)(r.CardContent,{children:u?(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,l.jsx)(a.Loader2,{className:`h-4 w-4 animate-spin`}),(0,l.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,l.jsx)(a.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,l.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`text-2xl font-bold truncate`,children:S}),(n||c)&&(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0`,children:[n&&(0,l.jsxs)(`span`,{className:(0,r.cn)(`flex items-center shrink-0 font-medium`,n.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,n.direction===`down`&&`text-rose-600 dark:text-rose-400`,n.direction===`neutral`&&`text-muted-foreground`),children:[n.direction===`up`&&(0,l.jsx)(a.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),n.direction===`down`&&(0,l.jsx)(a.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),n.direction===`neutral`&&(0,l.jsx)(a.MinusIcon,{className:`h-3 w-3 mr-1`}),n.value,`%`]}),(0,l.jsx)(`span`,{className:`truncate min-w-0`,children:x})]})]})})]})};function B(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var V=({title:e,value:t,icon:n,trend:i,trendValue:o,description:s,className:c,loading:u,error:d,...f})=>{let p=n?(0,r.getLazyIcon)(n):null;return(0,l.jsxs)(r.Card,{className:(0,r.cn)(`h-full`,c),...f,children:[(0,l.jsxs)(r.CardHeader,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,l.jsx)(r.CardTitle,{className:`text-sm font-medium`,children:B(e)}),p&&(0,l.jsx)(p,{className:`h-4 w-4 text-muted-foreground`})]}),(0,l.jsx)(r.CardContent,{children:u?(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,l.jsx)(a.Loader2,{className:`h-4 w-4 animate-spin`}),(0,l.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):d?(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,l.jsx)(a.AlertCircle,{className:`h-4 w-4 text-destructive shrink-0`}),(0,l.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:d})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(i||o||s)&&(0,l.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[i&&o&&(0,l.jsxs)(`span`,{className:(0,r.cn)(`flex items-center mr-2`,i===`up`&&`text-green-500`,i===`down`&&`text-red-500`,i===`neutral`&&`text-yellow-500`),children:[i===`up`&&(0,l.jsx)(a.ArrowUpIcon,{className:`h-3 w-3 mr-1`}),i===`down`&&(0,l.jsx)(a.ArrowDownIcon,{className:`h-3 w-3 mr-1`}),i===`neutral`&&(0,l.jsx)(a.MinusIcon,{className:`h-3 w-3 mr-1`}),o]}),B(s)]})]})})]})},H=({objectName:e,aggregate:a,filter:o,label:s,fallbackValue:c,trend:u,icon:d,className:f,description:p,dataSource:m,colorVariant:h,format:g,currency:_,prefix:v,suffix:y,drillDown:b,title:x})=>{let S=(0,i.useContext)(n.SchemaRendererContext),C=m||S?.dataSource,[w,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(null),[O,k]=(0,i.useState)(!1),[A,j]=(0,i.useState)(null),[M,N]=(0,i.useState)(null);(0,i.useEffect)(()=>{let t=!0;if(!(!C||!e||typeof C.getObjectSchema!=`function`))return C.getObjectSchema(e).then(e=>{t&&N(e)}).catch(()=>{}),()=>{t=!1}},[C,e]);let P=(0,i.useMemo)(()=>{let e=a?.field;if(!e||!M?.fields)return null;let t=M.fields;return Array.isArray(t)?t.find(t=>t?.name===e)||null:t[e]||null},[M,a?.field]),F=(0,i.useMemo)(()=>{if(g)return g;if(P){if(P.type===`currency`){let e=P.precision??P.scale??0;return e>0?`0,0.${`0`.repeat(e)}`:`0,0`}if(P.type===`percent`)return`0,0%`;if(P.type===`number`||P.type===`integer`)return`0,0`}},[g,P]),I=(0,i.useMemo)(()=>{if(_)return _;if(P?.type===`currency`)return P.defaultCurrency||P.currency||void 0},[_,P]),L=(0,i.useMemo)(()=>a?JSON.stringify(a):``,[a]),R=(0,i.useMemo)(()=>(0,t.resolveDateMacros)(o),[o]),B=(0,i.useCallback)(async(t,n)=>{if(!(!t||!e)){n.current&&(k(!0),j(null));try{let r;if(a&&typeof t.aggregate==`function`){let n=await t.aggregate(e,{field:a.field,function:a.function,groupBy:a.groupBy||`_all`,filter:R}),i=Array.isArray(n)?n:[];r=i.length===0?0:a.function===`count`?i.reduce((e,t)=>e+(Number(t[a.field])||Number(t.count)||0),0):i[0][a.field]??0}else if(typeof t.find==`function`){let n=await t.find(e,{$filter:R});r=(Array.isArray(n)?n:n?.data||n?.records||[]).length}else return;n.current&&D(r)}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),n.current&&j(e instanceof Error?e.message:`Failed to load metric`)}finally{n.current&&k(!1)}}},[e,L,(0,i.useMemo)(()=>R?JSON.stringify(R):``,[R])]);(0,i.useEffect)(()=>{let t={current:!0};return C&&e?B(C,t):(D(null),j(null)),()=>{t.current=!1}},[C,e,B]);let V=E===null?C?`—`:c??`—`:E,H=(0,t.isDrillEnabled)(b)&&!!e&&!!C,U=(0,i.useMemo)(()=>{let e=typeof s==`string`?s:s?.defaultValue||``;return(0,t.resolveDrillTitle)(b,{},(typeof x==`string`?x:x?.defaultValue||``)||e||`Details`)},[b,s,x]),W=(0,i.useMemo)(()=>{if(!H)return null;let t=b?.target??`drawer`,i=(0,l.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,l.jsx)(n.SchemaRenderer,{schema:{type:`object-data-table`,objectName:e,filter:R,pageSize:25,drillDown:{enabled:!1}}})});return t===`modal`?(0,l.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&T(!1),children:(0,l.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,l.jsx)(r.DialogHeader,{children:(0,l.jsx)(r.DialogTitle,{children:U})}),i]})}):(0,l.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&T(!1),children:(0,l.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,l.jsx)(r.SheetHeader,{children:(0,l.jsx)(r.SheetTitle,{children:U})}),(0,l.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:i})]})})},[H,b,e,R,U]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(z,{label:s,value:V,trend:u,icon:d,className:f,description:p,loading:O,error:A,colorVariant:h,format:F,currency:I,prefix:v,suffix:y,onClick:H?()=>T(!0):void 0}),w&&W]})};function U(){try{let{t:e}=(0,f.useObjectTranslation)(),t=e(`dashboard.total`);return!t||t===`dashboard.total`?`Total`:t}catch{return`Total`}}function W(){try{let{t:e}=(0,f.useObjectTranslation)(),t=e(`dashboard.noDataAvailable`);return!t||t===`dashboard.noDataAvailable`?`No data available`:t}catch{return`No data available`}}function ee(e,t){if(!t)return String(e);let n=``,r=``,i=!1,a,o=t,s=o.match(/^([^0-9.,#]*)/);if(s&&s[1]){let e=s[1];n=e.replace(`,`,``),e.includes(`,`)&&(i=!0),o=o.slice(s[1].length)}o.includes(`,`)&&(i=!0,o=o.replace(/,/g,``));let c=o.match(/\.(\d+)f?/);c&&(a=Number(c[1]),o=o.slice(c[0].length)),r=o.replace(/[0-9#.f]/g,``);let l=a===void 0?String(e):e.toFixed(a);if(i){let[e,t]=l.split(`.`),i=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?i:`${i}.${t}`)+r}return n+l+r}var G=`—`;function te(e,t){return e===``?G:t?.[e]??e}function K(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return e.reduce((e,t)=>e+t,0)}}var q=({schema:e,className:n,rowLabels:a,columnLabels:o,rowFieldLabel:s,onDrillDown:c})=>{let{title:u,rowField:d,columnField:f,valueField:p,aggregation:m=`sum`,data:h=[],showRowTotals:g=!1,showColumnTotals:_=!1,format:v,columnColors:y,drillDown:b}=e,x=U(),S=W(),C=(0,t.isDrillEnabled)(b)&&typeof c==`function`,w=e=>{C&&c({...e,rowLabel:e.rowKey===void 0?e.rowLabel:a?.[e.rowKey]??e.rowKey,colLabel:e.colKey===void 0?e.colLabel:o?.[e.colKey]??e.colKey})},T=e=>t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},E=C?`cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]`:``,D=Array.isArray(h)?h:[],{rowKeys:O,colKeys:k,matrix:A,rowTotals:j,colTotals:M,grandTotal:N}=(0,i.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let r of D){let i=String(r[d]??``),a=String(r[f]??``),o=Number(r[p])||0;e.set(i,!0),t.set(a,!0),n[i]||(n[i]={}),n[i][a]||(n[i][a]=[]),n[i][a].push(o)}let r=Array.from(e.keys()),i=Array.from(t.keys()),a={},o={},s={};for(let e of r){a[e]={};let t=[];for(let r of i){let i=n[e]?.[r]??[],o=K(i,m);a[e][r]=o,t.push(...i),!s[r]&&s[r]}o[e]=K(t,m)}for(let e of i){let t=[];for(let i of r){let r=n[i]?.[e]??[];t.push(...r)}s[e]=K(t,m)}let c=[];for(let e of D)c.push(Number(e[p])||0);return{rowKeys:r,colKeys:i,matrix:a,rowTotals:o,colTotals:s,grandTotal:K(c,m)}},[D,d,f,p,m]),P=e=>ee(e,v);return D.length===0?(0,l.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,n),children:[u&&(0,l.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:u}),(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,"data-testid":`pivot-empty-state`,children:[(0,l.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,l.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,l.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,l.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`}),(0,l.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`})]}),(0,l.jsx)(`p`,{className:`text-xs`,children:S})]})]}):(0,l.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,n),children:[u&&(0,l.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:u}),(0,l.jsxs)(`table`,{className:`w-full text-sm border-collapse table-auto`,role:`table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,l.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground whitespace-nowrap`,children:s||d}),k.map(e=>{let t=()=>w({scope:`column`,colKey:e});return(0,l.jsx)(`th`,{className:(0,r.cn)(`text-right p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,y?.[e]??`text-muted-foreground`,E),title:e===``?`${f}: (empty)`:`${f}: ${e}`,role:C?`button`:void 0,tabIndex:C?0:void 0,onClick:C?t:void 0,onKeyDown:C?T(t):void 0,"aria-label":C?`Drill into ${f}: ${e||`(empty)`}`:void 0,children:te(e,o)},e)}),g&&(0,l.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap`,children:x})]})}),(0,l.jsx)(`tbody`,{children:O.map(e=>(0,l.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,l.jsx)(`td`,{className:(0,r.cn)(`p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,E),role:C?`button`:void 0,tabIndex:C?0:void 0,onClick:C?()=>w({scope:`row`,rowKey:e}):void 0,onKeyDown:C?T(()=>w({scope:`row`,rowKey:e})):void 0,"aria-label":C?`Drill into ${d}: ${e||`(empty)`}`:void 0,children:te(e,a)}),k.map(t=>{let n=A[e]?.[t]??0,i=()=>w({scope:`cell`,rowKey:e,colKey:t,value:n});return(0,l.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 tabular-nums`,y?.[t],E),role:C?`button`:void 0,tabIndex:C?0:void 0,onClick:C?i:void 0,onKeyDown:C?T(i):void 0,"aria-label":C?`Drill into ${d}=${e||`(empty)`}, ${f}=${t||`(empty)`}`:void 0,children:P(n)},t)}),g&&(0,l.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 font-semibold tabular-nums bg-muted/20`,E),role:C?`button`:void 0,tabIndex:C?0:void 0,onClick:C?()=>w({scope:`row`,rowKey:e,value:j[e]??0}):void 0,onKeyDown:C?T(()=>w({scope:`row`,rowKey:e,value:j[e]??0})):void 0,children:P(j[e]??0)})]},e))}),_&&(0,l.jsx)(`tfoot`,{children:(0,l.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,l.jsx)(`td`,{className:`p-2`,children:x}),k.map(e=>(0,l.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 tabular-nums`,E),role:C?`button`:void 0,tabIndex:C?0:void 0,onClick:C?()=>w({scope:`column`,colKey:e,value:M[e]??0}):void 0,onKeyDown:C?T(()=>w({scope:`column`,colKey:e,value:M[e]??0})):void 0,children:P(M[e]??0)},e)),g&&(0,l.jsx)(`td`,{className:(0,r.cn)(`text-right p-2 tabular-nums font-bold`,E),role:C?`button`:void 0,tabIndex:C?0:void 0,onClick:C?()=>w({scope:`total`,value:N}):void 0,onKeyDown:C?T(()=>w({scope:`total`,value:N})):void 0,children:P(N)})]})})]})]})};function ne(e){return e.map(e=>typeof e==`string`?{header:e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase()),accessorKey:e}:e)}function J(e,t){if(!t?.fields)return[];let n={};if(Array.isArray(t.fields))for(let e of t.fields)e?.name&&(n[e.name]=e);else for(let[e,r]of Object.entries(t.fields))n[e]={name:e,...r};let r=e=>e===`lookup`||e===`reference`||e===`master_detail`||e===`user`||e===`owner`,i=Array.isArray(e.columns)?e.columns:[],a=new Set;if(i.length>0){let e=i.map(e=>typeof e==`string`?e:e.accessorKey||e.name).filter(Boolean);for(let t of e){let e=n[t];e&&r(e.type)&&a.add(t)}}else for(let[e,t]of Object.entries(n))r(t?.type)&&a.add(e);return Array.from(a)}var Y=({schema:e,dataSource:a,className:o})=>{let s=(0,i.useContext)(n.SchemaRendererContext),c=a||s?.dataSource,u=(0,n.useDataScope)(e.bind),{fieldLabel:d,fieldOptionLabel:m}=(0,f.useSafeFieldLabel)(),h=`No data available`,g=`No data source available for`;try{let{t:e}=(0,f.useObjectTranslation)(),t=e(`dashboard.noDataAvailable`);t&&t!==`dashboard.noDataAvailable`&&(h=t);let n=e(`dashboard.noDataSourceFor`);n&&n!==`dashboard.noDataSourceFor`&&(g=n)}catch{}let[_,v]=(0,i.useState)([]),[y,b]=(0,i.useState)(null),[x,S]=(0,i.useState)(!1),[C,w]=(0,i.useState)(null);(0,i.useEffect)(()=>{let n=!0;return e.objectName&&!u&&(!e.data||e.data.length===0)&&(async()=>{if(!(!c||!e.objectName)){n&&(S(!0),w(null));try{let r;if(typeof c.find==`function`){let n=J(e,y),i={$filter:(0,t.resolveDateMacros)(e.filter)};n.length&&(i.$expand=n),r=(0,t.extractRecords)(await c.find(e.objectName,i))}else return;n&&v(r)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),n&&w(e instanceof Error?e.message:`Failed to load data`)}finally{n&&S(!1)}}})(),()=>{n=!1}},[e.objectName,c,u,e.data,e.filter,y]),(0,i.useEffect)(()=>{let t=!0;if(!(!c||!e.objectName||typeof c.getObjectSchema!=`function`))return c.getObjectSchema(e.objectName).then(e=>{t&&b(e)}).catch(()=>{}),()=>{t=!1}},[e.objectName,c]);let T=u||e.data||_,E=Array.isArray(T)?T:[],D=(0,i.useMemo)(()=>{let t=e.objectName,n={};if(y?.fields){let e=y.fields;if(Array.isArray(e))for(let t of e)t?.name&&(n[t.name]=t);else for(let[t,r]of Object.entries(e))n[t]={name:t,...r}}let r=e=>{let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`);return t?d(t,e,n):n},i=e=>{let r=n[e.accessorKey],i=e.referenceTo??r?.referenceTo??(typeof r?.reference==`string`?r.reference:r?.reference?.to)??r?.target,a=e.options??r?.options;t&&a&&(r?.type===`select`||r?.type===`picklist`||r?.type===`dropdown`||r?.type===`status`)&&(a=a.map(n=>{if(n==null)return n;let r=typeof n==`object`?n.value:n,i=typeof n==`object`&&n.label||String(r);return{value:r,label:m(t,e.accessorKey,String(r),i),color:typeof n==`object`?n.color:void 0}}));let o={name:e.accessorKey,label:e.header,type:e.type??r?.type,options:a,referenceTo:i,format:e.format??r?.format,currency:e.currency??r?.currency??r?.defaultCurrency,decimals:e.decimals??r?.decimals??r?.precision??r?.scale},s=new Set([`currency`,`money`,`number`,`integer`,`decimal`,`float`,`percent`,`percentage`]),c=e.align??(s.has(o.type)||typeof o.format==`string`&&/^[\$¥€£]|%$|0/.test(o.format)?`right`:void 0);if(typeof e.cell==`function`)return{...e,...o,align:c};let u=e=>{if(e==null||e===``)return``;let t=o.format;if(typeof t==`string`&&/^\$|¥|€|£/.test(t)&&typeof e==`number`){let n={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`}[t[0]];return(0,p.formatCurrency)(e,o.currency||n)}if(typeof t==`string`&&/%/.test(t)&&typeof e==`number`){let n=(t.match(/0\.(0+)%/)||[,``])[1].length;return(0,p.formatPercent)((e>1?e/100:e)*100,n)}return typeof t==`string`&&/[YMDHms]/.test(t)?(0,p.formatDate)(e,t):(0,l.jsx)((0,p.getCellRenderer)((0,p.resolveCellRendererType)(o)),{value:e,field:o})};return{...e,...o,align:c,cell:u}};if(e.columns&&e.columns.length>0){let n=ne(e.columns);return(t?n.map(e=>({...e,header:d(t,e.accessorKey,e.header)})):n).map(i)}if(E.length===0)return[];let a=new Set([`id`,`organization_id`,`tenant_id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`deleted_at`,`deleted_by`,`version`,`_id`,`__typename`]),o=(e,t)=>t&&(t.isSystem===!0||t.system===!0)?!0:a.has(e);return(Object.keys(n).length>0?Object.keys(n).filter(e=>!o(e,n[e])):Object.keys(E[0]).filter(e=>!e.startsWith(`_`)&&!o(e))).map(e=>i({header:r(e),accessorKey:e}))},[e.columns,e.objectName,E,y,d,m]);return x&&E.length===0?(0,l.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,o),"data-testid":`table-loading`,children:(0,l.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(r.Skeleton,{className:`h-6 w-1/4`}),(0,l.jsx)(r.Skeleton,{className:`h-6 w-1/4`}),(0,l.jsx)(r.Skeleton,{className:`h-6 w-1/4`}),(0,l.jsx)(r.Skeleton,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(r.Skeleton,{className:`h-5 w-1/4`}),(0,l.jsx)(r.Skeleton,{className:`h-5 w-1/4`}),(0,l.jsx)(r.Skeleton,{className:`h-5 w-1/4`}),(0,l.jsx)(r.Skeleton,{className:`h-5 w-1/4`})]},e))]})}):C?(0,l.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,o),"data-testid":`table-error`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,l.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,l.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,l.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,l.jsx)(`p`,{className:`text-xs`,children:C})]})}):!c&&e.objectName&&E.length===0?(0,l.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,o),children:(0,l.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,l.jsxs)(`p`,{className:`text-xs`,children:[g,` “`,e.objectName,`”`]})})}):E.length===0?(0,l.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,o),"data-testid":`table-empty-state`,children:(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,l.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,l.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,l.jsx)(`line`,{x1:`3`,y1:`9`,x2:`21`,y2:`9`}),(0,l.jsx)(`line`,{x1:`9`,y1:`21`,x2:`9`,y2:`9`})]}),(0,l.jsx)(`p`,{className:`text-xs`,children:h})]})}):(0,l.jsx)(n.SchemaRenderer,{schema:{...e,type:`data-table`,data:E,columns:D},className:o})},X=({open:e,onClose:t,title:n,target:i=`drawer`,objectName:a,filter:o,dataSource:s,columns:c,maxRows:u,className:d})=>{let f={type:`object-data-table`,objectName:a,filter:o,columns:c?.map(e=>({accessorKey:e,header:e})),pagination:!0,searchable:!1,pageSize:u},p=(0,l.jsx)(`div`,{className:(0,r.cn)(`overflow-auto`,d),"data-testid":`drill-down-body`,children:(0,l.jsx)(Y,{schema:f,dataSource:s})});return i===`dialog`?(0,l.jsx)(r.Dialog,{open:e,onOpenChange:e=>!e&&t(),children:(0,l.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,l.jsx)(r.DialogHeader,{children:(0,l.jsx)(r.DialogTitle,{children:n})}),p]})}):(0,l.jsx)(r.Sheet,{open:e,onOpenChange:e=>!e&&t(),children:(0,l.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,l.jsx)(r.SheetHeader,{children:(0,l.jsx)(r.SheetTitle,{children:n})}),(0,l.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:p})]})})},Z=({schema:e,dataSource:a,className:o})=>{let s=(0,i.useContext)(n.SchemaRendererContext),c=a||s?.dataSource,u=(0,n.useDataScope)(e.bind),[d,p]=(0,i.useState)([]),[m,h]=(0,i.useState)(!1),[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)({}),[b,x]=(0,i.useState)({}),[S,C]=(0,i.useState)(null),{fieldLabel:w,fieldOptionLabel:T}=(0,f.useSafeFieldLabel)(),E=(0,i.useRef)(w),D=(0,i.useRef)(T);(0,i.useEffect)(()=>{E.current=w,D.current=T},[w,T]),(0,i.useEffect)(()=>{if(!c||!e.objectName)return;let t=c.getObjectSchema;if(typeof t!=`function`)return;let n=!0;return Promise.resolve(t.call(c,e.objectName)).then(t=>{if(!n||!t?.fields)return;let r=e.objectName,i={},a={};for(let[e,n]of Object.entries(t.fields)){let t=n?.label?String(n.label):e;a[e]=E.current(r,e,t);let o=n?.options;if(Array.isArray(o)&&o.length>0){let t={};for(let n of o)if(n&&n.value!==void 0&&n.label!==void 0){let i=String(n.value),a=String(n.label);t[i]=D.current(r,e,i,a)}Object.keys(t).length>0&&(i[e]=t)}}y(i),x(a)}).catch(()=>{}),()=>{n=!1}},[c,e.objectName]),(0,i.useEffect)(()=>{let n=!0;return e.objectName&&!u&&(!e.data||e.data.length===0)&&(async()=>{if(!(!c||!e.objectName)){n&&(h(!0),_(null));try{let r;if(typeof c.find==`function`)r=(0,t.extractRecords)(await c.find(e.objectName,{$filter:(0,t.resolveDateMacros)(e.filter)}));else return;n&&p(r)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),n&&_(e instanceof Error?e.message:`Failed to load data`)}finally{n&&h(!1)}}})(),()=>{n=!1}},[e.objectName,c,u,e.data,e.filter]);let O=u||e.data||d,k=Array.isArray(O)?O:[];if(m&&k.length===0)return(0,l.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,o),"data-testid":`pivot-loading`,children:[e.title&&(0,l.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,l.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(r.Skeleton,{className:`h-6 w-24`}),(0,l.jsx)(r.Skeleton,{className:`h-6 w-20`}),(0,l.jsx)(r.Skeleton,{className:`h-6 w-20`}),(0,l.jsx)(r.Skeleton,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(r.Skeleton,{className:`h-5 w-24`}),(0,l.jsx)(r.Skeleton,{className:`h-5 w-20`}),(0,l.jsx)(r.Skeleton,{className:`h-5 w-20`}),(0,l.jsx)(r.Skeleton,{className:`h-5 w-20`})]},e))]})]});if(g)return(0,l.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,o),"data-testid":`pivot-error`,children:[e.title&&(0,l.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,l.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,l.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,l.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,l.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,l.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,l.jsx)(`p`,{className:`text-xs`,children:g})]})]});if(!c&&e.objectName&&k.length===0)return(0,l.jsxs)(`div`,{className:(0,r.cn)(`overflow-auto`,o),children:[e.title&&(0,l.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,l.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,l.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]});let A={...e,data:k},j=e.rowField?v[e.rowField]:void 0,M=e.columnField?v[e.columnField]:void 0,N=e.rowField?b[e.rowField]:void 0,P=e.drillDown,F=(0,t.isDrillEnabled)(P)?e=>C(e):void 0;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(q,{schema:A,className:o,rowLabels:j,columnLabels:M,rowFieldLabel:N,onDrillDown:F}),(()=>{if(!S||!e.objectName)return null;let n=(0,t.computeDrillFilter)(P,S,{rowField:e.rowField,columnField:e.columnField}),r={...e.filter||{},...n};return(0,l.jsx)(X,{open:!0,onClose:()=>C(null),title:(0,t.resolveDrillTitle)(P,S,e.title||`Details`),target:P?.target??`drawer`,objectName:e.objectName,filter:r,dataSource:c,columns:P?.columns,maxRows:P?.maxRows})})()]})},re={breadcrumb:[`Dashboard`,`Configuration`],sections:[{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`columns`,label:`Columns`,type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:`Gap`,type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:`Row height (px)`,type:`slider`,defaultValue:120,min:40,max:320,step:10}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`refreshInterval`,label:`Auto refresh`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Off`},{value:`30`,label:`Every 30s`},{value:`60`,label:`Every 1 min`},{value:`300`,label:`Every 5 min`},{value:`900`,label:`Every 15 min`},{value:`1800`,label:`Every 30 min`},{value:`3600`,label:`Every 1 hour`}]}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Dashboard title`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Short summary shown under the title`},{key:`showDescription`,label:`Show description`,type:`switch`,defaultValue:!0},{key:`theme`,label:`Theme`,type:`select`,defaultValue:`auto`,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`auto`,label:`Auto`}]}]}]};function Q({open:e,onClose:t,config:n,onSave:i,onFieldChange:a}){let{draft:o,isDirty:s,updateField:c,discard:u}=(0,r.useConfigDraft)(n,{onUpdate:a});return(0,l.jsx)(r.ConfigPanelRenderer,{open:e,onClose:t,schema:re,draft:o,isDirty:s,onFieldChange:c,onSave:()=>i(o),onDiscard:u})}var ie=[{value:`metric`,label:`Metric`},{value:`bar`,label:`Bar Chart`},{value:`horizontal-bar`,label:`Horizontal Bar`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`donut`,label:`Donut Chart`},{value:`area`,label:`Area Chart`},{value:`scatter`,label:`Scatter Plot`},{value:`funnel`,label:`Funnel`},{value:`table`,label:`Table`},{value:`pivot`,label:`Pivot Table`}],ae=[{value:`default`,label:`Default`},{value:`blue`,label:`Blue`},{value:`teal`,label:`Teal`},{value:`orange`,label:`Orange`},{value:`purple`,label:`Purple`},{value:`success`,label:`Success`},{value:`warning`,label:`Warning`},{value:`danger`,label:`Danger`}],oe=[{value:`count`,label:`Count`},{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}],se=[`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`],ce=[`bar`,`horizontal-bar`,`line`,`area`,`scatter`],le=[`pie`,`donut`,`funnel`],ue=[`metric`,...se],de=[...se],fe=[`pivot`,`metric`,`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`];function pe(e){return!!e&&se.includes(e)}function me(e){return!!e&&ce.includes(e)}function he(e){return!!e&&de.includes(e)}function ge(e){return!!e&&ue.includes(e)}function _e(e){return!!e&&fe.includes(e)}var ve=[{value:`drawer`,label:`Side drawer`},{value:`dialog`,label:`Center dialog`}],ye=[{value:`group`,label:`Group`},{value:`value`,label:`Value`}],be=[{value:`asc`,label:`↑`},{value:`desc`,label:`↓`}];function $(e,t,n,i){return{key:e,label:t,type:`custom`,render:(a,o,s)=>(0,l.jsx)(r.ConfigRow,{label:t,children:(0,l.jsx)(`div`,{"data-testid":`config-field-${e}`,children:(0,l.jsx)(r.Combobox,{options:i??[],value:a??``,onValueChange:o,placeholder:n,searchPlaceholder:`Search fields…`,emptyText:`No fields found.`,className:`h-7 w-32 text-xs`,disabled:!s.object})})})}}function xe(e,t,n){let i=e&&e.length>0,a=i?{key:`object`,label:`Data source`,type:`custom`,render:(t,n)=>(0,l.jsx)(r.ConfigRow,{label:`Data source`,children:(0,l.jsx)(`div`,{"data-testid":`config-field-object`,children:(0,l.jsx)(r.Combobox,{options:e,value:t??``,onValueChange:n,placeholder:`Select object…`,searchPlaceholder:`Search objects…`,emptyText:`No objects found.`,className:`h-7 w-32 text-xs`})})})}:{key:`object`,label:`Data source`,type:`input`,placeholder:`Object name`},o=i?{...$(`categoryField`,`Category field`,`Select field…`,t),helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>he(e.type)}:{key:`categoryField`,label:`Category field`,type:`input`,placeholder:`e.g. status`,helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>he(e.type)},s=i?{...$(`valueField`,`Value field`,`Select field…`,t),helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>ge(e.type)&&(e.aggregate??`count`)!==`count`}:{key:`valueField`,label:`Value field`,type:`input`,placeholder:`e.g. amount`,helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>ge(e.type)&&(e.aggregate??`count`)!==`count`},c=i?$(`rowField`,`Field`,`Select row field…`,t):{key:`rowField`,label:`Field`,type:`input`,placeholder:`e.g. owner`},u=i?$(`columnField`,`Field`,`Select column field…`,t):{key:`columnField`,label:`Field`,type:`input`,placeholder:`e.g. stage`},d=i?$(`valueField`,`Field`,`Select value field…`,t):{key:`valueField`,label:`Field`,type:`input`,placeholder:`e.g. amount`};return{breadcrumb:[`Dashboard`,{pivot:`Pivot table`,table:`Table`}[n??``]??(pe(n)?`Chart`:`Widget`)],sections:[{key:`general`,title:`General`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Widget title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Widget description`},{key:`type`,label:`Widget type`,type:`select`,options:ie,defaultValue:`metric`}]},{key:`data`,title:`Data Binding`,collapsible:!0,visibleWhen:e=>e.type!==`pivot`,fields:[a,o,s,{key:`aggregate`,label:`Aggregation`,type:`select`,options:oe,defaultValue:`count`,helpText:`Count ignores Value field; Sum / Avg / Min / Max require it.`,visibleWhen:e=>ge(e.type)}]},{key:`pivot-data`,title:`Data`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[a]},{key:`pivot-rows`,title:`Rows`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[c,{key:`rowSortBy`,label:`Sort by`,type:`icon-group`,options:ye,defaultValue:`group`},{key:`rowSortOrder`,label:`Sort order`,type:`icon-group`,options:be,defaultValue:`asc`},{key:`showRowLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showRowTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-columns`,title:`Columns`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[u,{key:`columnSortBy`,label:`Sort by`,type:`icon-group`,options:ye,defaultValue:`group`},{key:`columnSortOrder`,label:`Sort order`,type:`icon-group`,options:be,defaultValue:`asc`},{key:`showColumnLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showColumnTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-values`,title:`Values`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[d,{key:`aggregation`,label:`Aggregation`,type:`select`,options:oe,defaultValue:`sum`},{key:`format`,label:`Number format`,type:`input`,placeholder:`e.g. $,.2f`}]},{key:`chart-axis`,title:`Axis & Series`,collapsible:!0,visibleWhen:e=>me(e.type),fields:[{key:`xAxisLabel`,label:`X-axis label`,type:`input`,placeholder:`e.g. Month`},{key:`yAxisLabel`,label:`Y-axis label`,type:`input`,placeholder:`e.g. Revenue`},{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`chart-legend`,title:`Display`,collapsible:!0,visibleWhen:e=>!!e.type&&le.includes(e.type),fields:[{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`table-options`,title:`Table options`,collapsible:!0,visibleWhen:e=>e.type===`table`,fields:[{key:`searchable`,label:`Searchable`,type:`switch`,defaultValue:!1},{key:`pagination`,label:`Pagination`,type:`switch`,defaultValue:!1}]},{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`layoutW`,label:`Width (columns)`,type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:`Height (rows)`,type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`drill-down`,title:`Drill-down`,collapsible:!0,defaultCollapsed:!0,visibleWhen:e=>_e(e.type),fields:[{key:`drillDownEnabled`,label:`Enable drill-down`,type:`switch`,defaultValue:!1,helpText:`When enabled, clicking a cell / segment opens a filtered list of underlying records.`},{key:`drillDownTarget`,label:`Open in`,type:`select`,options:ve,defaultValue:`drawer`,visibleWhen:e=>!!e.drillDownEnabled}]},{key:`behavior`,title:`Behavior`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`actionUrl`,label:`Click-through URL`,type:`input`,placeholder:`https://...`}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:`Color variant`,type:`select`,options:ae,defaultValue:`default`}]}]}}function Se(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.defaultValue||t.key||``}return String(e)}function Ce(e){let t=e.type,n={...e};return he(t)||delete n.categoryField,ge(t)?(n.aggregate??`count`)===`count`&&delete n.valueField:(delete n.valueField,delete n.aggregate),me(t)||(delete n.xAxisLabel,delete n.yAxisLabel),t===`pivot`?(delete n.aggregate,delete n.categoryField):(delete n.rowField,delete n.columnField,delete n.aggregation,delete n.rowSortBy,delete n.rowSortOrder,delete n.columnSortBy,delete n.columnSortOrder,delete n.showRowLabels,delete n.showRowTotals,delete n.showColumnLabels,delete n.showColumnTotals,delete n.format),t!==`table`&&(delete n.searchable,delete n.pagination),_e(t)||(delete n.drillDownEnabled,delete n.drillDownTarget),n}function we({open:e,onClose:t,config:n,onSave:a,onFieldChange:o,headerExtra:s,availableObjects:c,availableFields:u}){let{draft:d,isDirty:f,updateField:p,discard:m}=(0,r.useConfigDraft)(i.useMemo(()=>({...n,title:typeof n.title==`object`?Se(n.title):n.title,description:typeof n.description==`object`?Se(n.description):n.description}),[n]),{onUpdate:o});return(0,l.jsx)(r.ConfigPanelRenderer,{open:e,onClose:t,schema:i.useMemo(()=>xe(c,u,d.type),[c,u,d.type]),draft:d,isDirty:f,onFieldChange:p,onSave:()=>a(Ce(d)),onDiscard:m,headerExtra:s})}function Te({schema:e,config:t,onConfigSave:n,onWidgetSave:o,onRefresh:s,recordCount:c,defaultConfigOpen:u=!1,className:d}){let[f,p]=(0,i.useState)(u),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(e),[v,y]=(0,i.useState)(0);(0,i.useEffect)(()=>{_(e),y(e=>e+1)},[e]);let b=i.useMemo(()=>{if(!m||!g.widgets)return null;let e=g.widgets.find(e=>(e.id||e.title)===m);if(!e)return null;let t=e.options||{};return{...t,id:e.id??``,title:e.title??``,description:e.description??``,type:e.type??``,object:e.object??``,categoryField:e.categoryField??t.categoryField??``,valueField:e.valueField??t.valueField??``,aggregate:e.aggregate??t.aggregate??``,colorVariant:e.colorVariant??t.colorVariant??`default`,actionUrl:e.actionUrl??t.actionUrl??``,drillDownEnabled:t.drillDown?.enabled??!!(e.object&&(e.type===`pivot`||e.type===`metric`||e.type===`bar`||e.type===`horizontal-bar`||e.type===`line`||e.type===`area`||e.type===`pie`||e.type===`donut`||e.type===`funnel`)),drillDownTarget:t.drillDown?.target??`drawer`,layoutW:e.layout?.w??1,layoutH:e.layout?.h??1}},[m,v]),x=(0,i.useCallback)(e=>{h(e),p(!0)},[]),S=(0,i.useCallback)(()=>{h(null)},[]),C=(0,i.useCallback)((e,t)=>{m&&_(n=>n.widgets?{...n,widgets:n.widgets.map(n=>{if((n.id||n.title)!==m)return n;if(e===`layoutW`)return{...n,layout:{...n.layout||{},w:t}};if(e===`layoutH`)return{...n,layout:{...n.layout||{},h:t}};if(e===`drillDownEnabled`||e===`drillDownTarget`){let r=n.options?.drillDown??{},i=e===`drillDownEnabled`?{...r,enabled:!!t}:{...r,target:t};return{...n,options:{...n.options||{},drillDown:i}}}return{...n,[e]:t}})}:n)},[m]),w=(0,i.useCallback)(e=>{if(m&&o){let{drillDownEnabled:t,drillDownTarget:n,...r}=e,i={...r};(t||n)&&(i.options={...r.options||{},drillDown:{...r.options?.drillDown||{},...t===void 0?{}:{enabled:!!t},...n===void 0?{}:{target:n}}}),o(m,i)}h(null),y(e=>e+1)},[m,o]),T=(0,i.useCallback)(()=>{p(e=>!e),h(null)},[]);return(0,l.jsxs)(`div`,{className:(0,r.cn)(`flex h-full w-full`,d),"data-testid":`dashboard-with-config`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-auto relative`,children:[(0,l.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,l.jsxs)(r.Button,{size:`sm`,variant:f?`default`:`outline`,onClick:T,"data-testid":`dashboard-config-toggle`,children:[(0,l.jsx)(a.Settings,{className:`h-3.5 w-3.5 mr-1`}),`Settings`]})}),(0,l.jsx)(O,{schema:g,onRefresh:s,recordCount:c,designMode:f,selectedWidgetId:m,onWidgetClick:x})]}),f&&(0,l.jsx)(`div`,{className:`relative shrink-0`,children:m&&b?(0,l.jsx)(we,{open:!0,onClose:S,config:b,onSave:w,onFieldChange:C}):(0,l.jsx)(Q,{open:!0,onClose:()=>p(!1),config:t,onSave:n})})]})}t.ComponentRegistry.register(`dashboard`,O,{namespace:`view`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`columns`,type:`number`,label:`Columns`,defaultValue:3},{name:`gap`,type:`number`,label:`Gap`,defaultValue:4},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:3,widgets:[]}}),t.ComponentRegistry.register(`metric`,z,{namespace:`plugin-dashboard`,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`,label:`Label`},{name:`value`,type:`string`,label:`Value`}]}),t.ComponentRegistry.register(`metric-card`,V,{namespace:`plugin-dashboard`,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`value`,type:`string`,label:`Value`,required:!0},{name:`icon`,type:`string`,label:`Icon (Lucide name)`},{name:`trend`,type:`enum`,label:`Trend`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`,label:`Trend Value (e.g., +12%)`},{name:`description`,type:`string`,label:`Description`}],defaultProps:{title:`Metric`,value:`0`}}),t.ComponentRegistry.register(`object-metric`,H,{namespace:`plugin-dashboard`,label:`Object Metric`,category:`Dashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`label`,type:`string`,label:`Label`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`},{name:`icon`,type:`string`,label:`Icon (Lucide name)`}],defaultProps:{label:`Metric`}}),t.ComponentRegistry.register(`pivot`,q,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}}),t.ComponentRegistry.register(`object-pivot`,Z,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`filter`,type:`array`,label:`Filter`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),t.ComponentRegistry.register(`dashboard-grid`,N,{namespace:`plugin-dashboard`,label:`Dashboard Grid (Editable)`,category:`Complex`,icon:`layout-grid`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{title:`Dashboard`,widgets:[]}}),t.ComponentRegistry.register(`object-data-table`,Y,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`searchable`,type:`boolean`,label:`Searchable`},{name:`pagination`,type:`boolean`,label:`Pagination`}],defaultProps:{searchable:!1,pagination:!1}});var Ee={DashboardRenderer:O,DashboardGridLayout:N,MetricWidget:z,MetricCard:V,ObjectMetricWidget:H,PivotTable:q,ObjectPivotTable:Z,ObjectDataTable:Y,DashboardConfigPanel:Q,WidgetConfigPanel:we,DashboardWithConfig:Te};e.DashboardConfigPanel=Q,e.DashboardGridLayout=N,e.DashboardRenderer=O,e.DashboardWithConfig=Te,e.DrillDownDrawer=X,e.MetricCard=V,e.MetricWidget=z,e.ObjectDataTable=Y,e.ObjectMetricWidget=H,e.ObjectPivotTable=Z,e.PivotTable=q,e.WidgetConfigPanel=we,e.dashboardComponents=Ee});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardConfigPanel.d.ts","sourceRoot":"","sources":["../../../../src/DashboardConfigPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"DashboardConfigPanel.d.ts","sourceRoot":"","sources":["../../../../src/DashboardConfigPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoHH,MAAM,WAAW,yBAAyB;IACxC,gCAAgC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,oBAAoB;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,iCAAiC;IACjC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC9C,oCAAoC;IACpC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACrD;AAMD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,OAAO,EACP,MAAM,EACN,MAAM,EACN,aAAa,GACd,EAAE,yBAAyB,2CAiB3B"}
|
|
@@ -4,10 +4,26 @@ import * as React from 'react';
|
|
|
4
4
|
export interface DashboardGridLayoutProps {
|
|
5
5
|
schema: DashboardSchema;
|
|
6
6
|
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Fires on every drag/resize tick with the raw react-grid-layout payload.
|
|
9
|
+
* Useful for live previews; NOT a persistence hook.
|
|
10
|
+
*/
|
|
7
11
|
onLayoutChange?: (layout: RGLLayout[]) => void;
|
|
8
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Canonical persistence hook. When the user clicks "Save Layout", the
|
|
14
|
+
* grid coordinates are merged back into `schema.widgets[].layout` and the
|
|
15
|
+
* resulting `DashboardSchema` is passed to this callback. The parent is
|
|
16
|
+
* expected to forward it to its data adapter (e.g. `client.meta.saveItem`).
|
|
17
|
+
*
|
|
18
|
+
* If omitted, layout edits stay in memory only — the component does not
|
|
19
|
+
* persist to localStorage or anywhere else (per Rule #1 Protocol Agnostic:
|
|
20
|
+
* persistence is the parent's responsibility, not the renderer's).
|
|
21
|
+
*/
|
|
22
|
+
onSchemaChange?: (schema: DashboardSchema) => void;
|
|
9
23
|
/** Callback invoked when dashboard refresh is triggered (manual or auto) */
|
|
10
24
|
onRefresh?: () => void;
|
|
11
25
|
}
|
|
26
|
+
/** Merge react-grid-layout coordinates back into a DashboardSchema's widgets. */
|
|
27
|
+
export declare function mergeLayoutIntoSchema(schema: DashboardSchema, layout: RGLLayout[]): DashboardSchema;
|
|
12
28
|
export declare const DashboardGridLayout: React.FC<DashboardGridLayoutProps>;
|
|
13
29
|
//# sourceMappingURL=DashboardGridLayout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardGridLayout.d.ts","sourceRoot":"","sources":["../../../../src/DashboardGridLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA2C,KAAK,UAAU,IAAI,SAAS,EAAuC,MAAM,mBAAmB,CAAC;AAC/I,OAAO,kCAAkC,CAAC;AAI1C,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,kBAAkB,CAAC;AA2B/E,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC/C,
|
|
1
|
+
{"version":3,"file":"DashboardGridLayout.d.ts","sourceRoot":"","sources":["../../../../src/DashboardGridLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA2C,KAAK,UAAU,IAAI,SAAS,EAAuC,MAAM,mBAAmB,CAAC;AAC/I,OAAO,kCAAkC,CAAC;AAI1C,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,kBAAkB,CAAC;AA2B/E,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC/C;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,SAAS,EAAE,GAClB,eAAe,CAajB;AAcD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA4TlE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DashboardSchema } from '../../types/src';
|
|
1
|
+
import { DashboardSchema, DashboardWidgetSchema } from '../../types/src';
|
|
2
2
|
import { ActionDef, ActionResult, ActionContext, ModalHandler } from '../../core/src';
|
|
3
3
|
export interface DashboardRendererProps {
|
|
4
4
|
schema: DashboardSchema;
|
|
@@ -19,10 +19,24 @@ export interface DashboardRendererProps {
|
|
|
19
19
|
selectedWidgetId?: string | null;
|
|
20
20
|
/** Callback when a widget is clicked in design mode */
|
|
21
21
|
onWidgetClick?: (widgetId: string | null) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback when widgets are reordered via drag-and-drop in design mode.
|
|
24
|
+
* Receives the next widgets array (with positions swapped). The parent
|
|
25
|
+
* is expected to persist via its data adapter. When omitted, drag-and-
|
|
26
|
+
* drop affordances are disabled even in design mode.
|
|
27
|
+
*/
|
|
28
|
+
onWidgetsReorder?: (widgets: DashboardWidgetSchema[]) => void;
|
|
22
29
|
/** Optional handler for actionType="modal" header actions. Receives a schema and ActionContext. */
|
|
23
30
|
modalHandler?: ModalHandler;
|
|
24
31
|
/** Optional named handlers for actionType="script" header actions, keyed by action name (actionUrl). */
|
|
25
32
|
scriptHandlers?: Record<string, (action: ActionDef, context: ActionContext) => Promise<ActionResult> | ActionResult>;
|
|
33
|
+
/**
|
|
34
|
+
* When true, suppress the built-in header title and description blocks.
|
|
35
|
+
* Header actions (if any) are still rendered. Use this when the parent
|
|
36
|
+
* page chrome (e.g. `DashboardView`) already renders the dashboard's
|
|
37
|
+
* title/subtitle so we don't display them twice.
|
|
38
|
+
*/
|
|
39
|
+
hideHeaderText?: boolean;
|
|
26
40
|
[key: string]: any;
|
|
27
41
|
}
|
|
28
42
|
export declare const DashboardRenderer: import('react').ForwardRefExoticComponent<Omit<DashboardRendererProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardRenderer.d.ts","sourceRoot":"","sources":["../../../../src/DashboardRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"DashboardRenderer.d.ts","sourceRoot":"","sources":["../../../../src/DashboardRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAyG5F,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,WAAW,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACrE,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,uDAAuD;IACvD,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAClD;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,EAAE,KAAK,IAAI,CAAC;IAC9D,mGAAmG;IACnG,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,wGAAwG;IACxG,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,CAAC;IACrH;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,iBAAiB,gIAouB7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricWidget.d.ts","sourceRoot":"","sources":["../../../../src/MetricWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MetricWidget.d.ts","sourceRoot":"","sources":["../../../../src/MetricWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAkHvC,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GACjD,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAmBrC,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,GAAG;YAAE,GAAG,CAAC,EAAE,MAAM,CAAC;YAAC,YAAY,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACzD,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;KACvC,CAAC;IACF,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yFAAyF;IACzF,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,sFAAsF;IACtF,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,GAAI,0IAgB1B,iBAAiB,4CAuGnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectDataTable.d.ts","sourceRoot":"","sources":["../../../../src/ObjectDataTable.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAQxE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACrD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,6EAA6E;AAC7E,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,gBAAgB,EAAE,CAiB9F;AAED;;;;;;;;;;;;;;;GAeG;AACH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAChD,YAAY,EAAE,GAAG,GAChB,MAAM,EAAE,CAgCV;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"ObjectDataTable.d.ts","sourceRoot":"","sources":["../../../../src/ObjectDataTable.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAQxE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACrD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,6EAA6E;AAC7E,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,gBAAgB,EAAE,CAiB9F;AAED;;;;;;;;;;;;;;;GAeG;AACH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAChD,YAAY,EAAE,GAAG,GAChB,MAAM,EAAE,CAgCV;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2T1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotTable.d.ts","sourceRoot":"","sources":["../../../../src/PivotTable.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"PivotTable.d.ts","sourceRoot":"","sources":["../../../../src/PivotTable.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAuBlE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAC3C;AA6ED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAsPhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetConfigPanel.d.ts","sourceRoot":"","sources":["../../../../src/WidgetConfigPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"WidgetConfigPanel.d.ts","sourceRoot":"","sources":["../../../../src/WidgetConfigPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuF/B,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEhE;AAuBD,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA4b5D,MAAM,WAAW,sBAAsB;IACrC,gCAAgC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,oBAAoB;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,wCAAwC;IACxC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC9C,oCAAoC;IACpC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACpD,oEAAoE;IACpE,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,YAAY,EAAE,CAAC;IAClC,+EAA+E;IAC/E,eAAe,CAAC,EAAE,YAAY,EAAE,CAAC;CAClC;AAiFD,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,OAAO,EACP,MAAM,EACN,MAAM,EACN,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,EAAE,sBAAsB,2CA8BxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAwM9N,eAAO,MAAM,mBAAmB;;;;;;;;;;;;CAY/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-dashboard",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Dashboard plugin for Object UI",
|
|
@@ -15,17 +15,20 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@dnd-kit/core": "^6.3.1",
|
|
19
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
20
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
18
21
|
"clsx": "^2.1.1",
|
|
19
|
-
"lucide-react": "^1.
|
|
22
|
+
"lucide-react": "^1.16.0",
|
|
20
23
|
"react": "19.2.6",
|
|
21
24
|
"react-dom": "19.2.6",
|
|
22
25
|
"tailwind-merge": "^3.6.0",
|
|
23
|
-
"@object-ui/components": "4.0.
|
|
24
|
-
"@object-ui/core": "4.0.
|
|
25
|
-
"@object-ui/i18n": "4.0.
|
|
26
|
-
"@object-ui/fields": "4.0.
|
|
27
|
-
"@object-ui/react": "4.0.
|
|
28
|
-
"@object-ui/types": "4.0.
|
|
26
|
+
"@object-ui/components": "4.0.12",
|
|
27
|
+
"@object-ui/core": "4.0.12",
|
|
28
|
+
"@object-ui/i18n": "4.0.12",
|
|
29
|
+
"@object-ui/fields": "4.0.12",
|
|
30
|
+
"@object-ui/react": "4.0.12",
|
|
31
|
+
"@object-ui/types": "4.0.12"
|
|
29
32
|
},
|
|
30
33
|
"peerDependencies": {
|
|
31
34
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -34,10 +37,10 @@
|
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
39
|
"@types/react-grid-layout": "^2.1.0",
|
|
37
|
-
"@vitejs/plugin-react": "^6.0.
|
|
40
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
38
41
|
"react-grid-layout": "^2.2.3",
|
|
39
42
|
"typescript": "^6.0.3",
|
|
40
|
-
"vite": "^8.0.
|
|
43
|
+
"vite": "^8.0.13",
|
|
41
44
|
"vite-plugin-dts": "^5.0.0"
|
|
42
45
|
},
|
|
43
46
|
"keywords": [
|