@object-ui/plugin-report 5.2.1 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @object-ui/plugin-report
|
|
2
2
|
|
|
3
|
+
## 5.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @object-ui/types@5.3.1
|
|
8
|
+
- @object-ui/core@5.3.1
|
|
9
|
+
- @object-ui/i18n@5.3.1
|
|
10
|
+
- @object-ui/react@5.3.1
|
|
11
|
+
- @object-ui/components@5.3.1
|
|
12
|
+
- @object-ui/fields@5.3.1
|
|
13
|
+
- @object-ui/plugin-grid@5.3.1
|
|
14
|
+
|
|
15
|
+
## 5.3.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @object-ui/types@5.3.0
|
|
20
|
+
- @object-ui/core@5.3.0
|
|
21
|
+
- @object-ui/i18n@5.3.0
|
|
22
|
+
- @object-ui/react@5.3.0
|
|
23
|
+
- @object-ui/components@5.3.0
|
|
24
|
+
- @object-ui/fields@5.3.0
|
|
25
|
+
- @object-ui/plugin-grid@5.3.0
|
|
26
|
+
|
|
3
27
|
## 5.2.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -34,9 +34,9 @@ var ge = ({ schema: t }) => {
|
|
|
34
34
|
})(), i && i.length > 0 && /* @__PURE__ */ F("div", {
|
|
35
35
|
className: "border rounded-lg",
|
|
36
36
|
children: (() => {
|
|
37
|
-
let t = e.get("
|
|
37
|
+
let t = e.get("grid") || e.get("table");
|
|
38
38
|
return t ? /* @__PURE__ */ F(t, { schema: {
|
|
39
|
-
type: "
|
|
39
|
+
type: "grid",
|
|
40
40
|
rowData: i,
|
|
41
41
|
columnDefs: a,
|
|
42
42
|
domLayout: "autoHeight"
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/types`),require(`@object-ui/components`),require(`react/jsx-runtime`),require(`react-i18next`),require(`@object-ui/plugin-grid`),require(`@object-ui/i18n`),require(`@object-ui/react`),require(`lucide-react`),require(`@object-ui/fields`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/types`,`@object-ui/components`,`react/jsx-runtime`,`react-i18next`,`@object-ui/plugin-grid`,`@object-ui/i18n`,`@object-ui/react`,`lucide-react`,`@object-ui/fields`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginReport={},e.ObjectUICore,e.React,e.ObjectUITypes,e.ObjectUIComponents,e.react_jsx_runtime,e.react_i18next,e._object_ui_plugin_grid,e._object_ui_i18n,e.ObjectUIReact,e.lucide_react,e._object_ui_fields))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var y=({schema:e})=>{let{title:n,description:r,data:o,columns:s}=e;e.chart?.type;let c=!!e.chart;return(0,a.jsxs)(i.Card,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,a.jsxs)(i.CardHeader,{children:[n&&(0,a.jsx)(i.CardTitle,{children:n}),r&&(0,a.jsx)(i.CardDescription,{children:r})]}),(0,a.jsxs)(i.CardContent,{className:`flex-1 overflow-auto space-y-4`,children:[c&&(()=>{let n=e.chart?.type,r=n?t.ComponentRegistry.get(n):null;return r||=t.ComponentRegistry.get(`chart`),r?(0,a.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,a.jsx)(r,{schema:{...e.chart,data:e.chart.data||o}})}):(0,a.jsxs)(`div`,{className:`min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center`,children:[`Unknown component type: `,n||`chart`]})})(),o&&o.length>0&&(0,a.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=t.ComponentRegistry.get(`aggrid`)||t.ComponentRegistry.get(`table`);return e?(0,a.jsx)(e,{schema:{type:`aggrid`,rowData:o,columnDefs:s,domLayout:`autoHeight`}}):(0,a.jsx)(`div`,{className:`overflow-x-auto`,children:(0,a.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,a.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,a.jsx)(`tr`,{children:s?.map(e=>(0,a.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,a.jsx)(`tbody`,{children:o.map((e,t)=>(0,a.jsx)(`tr`,{className:`bg-background border-b`,children:s?.map(t=>(0,a.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function b(e){return e.aggregate?`${e.field}__${e.aggregate}`:e.field}function x(e,t){if(e==null)return null;let n=e instanceof Date?e:new Date(String(e));if(Number.isNaN(n.getTime()))return null;let r=n.getUTCFullYear(),i=n.getUTCMonth(),a=n.getUTCDate();switch(t){case`year`:return String(r);case`quarter`:return`${r}-Q${Math.floor(i/3)+1}`;case`month`:return`${r}-${String(i+1).padStart(2,`0`)}`;case`week`:{let e=new Date(Date.UTC(r,i,a)),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1)),o=Math.ceil(((e.getTime()-n.getTime())/864e5+1)/7);return`${e.getUTCFullYear()}-W${String(o).padStart(2,`0`)}`}case`day`:return`${r}-${String(i+1).padStart(2,`0`)}-${String(a).padStart(2,`0`)}`;default:return String(e)}}function S(e,t){let n=e[t.field];return t.dateGranularity?x(n,t.dateGranularity)??`(empty)`:n==null||n===``?`(empty)`:String(n)}function C(e,t){let n={};for(let r of t){if(!r.aggregate){let t=e.find(e=>e[r.field]!=null);n[b(r)]=t?t[r.field]:null;continue}let t=e.map(e=>e[r.field]);switch(r.aggregate){case`count`:n[b(r)]=t.length;break;case`unique`:{let e=new Set;for(let n of t)n!=null&&e.add(n);n[b(r)]=e.size;break}case`sum`:{let e=0;for(let n of t)e+=Number(n)||0;n[b(r)]=e;break}case`avg`:{let e=0,i=0;for(let n of t){if(n==null||n===``)continue;let t=Number(n);Number.isNaN(t)||(e+=t,i+=1)}n[b(r)]=i===0?null:e/i;break}case`min`:{let e=null;for(let n of t){if(n==null)continue;let t=Number(n);Number.isNaN(t)||(e===null||t<e)&&(e=t)}n[b(r)]=e;break}case`max`:{let e=null;for(let n of t){if(n==null)continue;let t=Number(n);Number.isNaN(t)||(e===null||t>e)&&(e=t)}n[b(r)]=e;break}default:n[b(r)]=null}}return n}function w(e,t,n,r={},i=[]){if(t.length===0)return[];let[a,...o]=t,s=new Map;for(let t of e){let e=S(t,a),n=s.get(e);n||(n=[],s.set(e,n)),n.push(t)}let c=[];for(let[e,t]of s){let s={...r,[a.field]:e},l=[...i,e],u=C(t,n),d=o.length>0?w(t,o,n,s,l):void 0;c.push({groupKey:s,groupPath:l,values:u,count:t.length,children:d})}let l=a.sort===`desc`?-1:1;return c.sort((e,t)=>{let n=String(e.groupPath[e.groupPath.length-1]),r=String(t.groupPath[t.groupPath.length-1]);return n.localeCompare(r)*l}),typeof a.limit==`number`&&a.limit>0?c.slice(0,a.limit):c}function T(e,t,n,r){let i=E(e,n),a=E(e,r),o={},s={},c={};for(let c of i){o[c.id]={};let i=D(e,c.key,n);s[c.id]=C(i,t);for(let e of a){let n=D(i,e.key,r);n.length!==0&&(o[c.id][e.id]=C(n,t))}}for(let n of a){let i=D(e,n.key,r);c[n.id]=C(i,t)}return{rowHeaders:i,colHeaders:a,cells:o,rowTotals:s,colTotals:c,grandTotal:C(e,t),columns:t,downGroupings:n,acrossGroupings:r}}function E(e,t){if(t.length===0)return[{key:{},path:[],id:``}];let n=new Map;for(let r of e){let e=[],i={};for(let n of t){let t=S(r,n);e.push(t),i[n.field]=t}let a=e.join(``);n.has(a)||n.set(a,{key:i,path:e,id:a})}let r=Array.from(n.values());r.sort((e,n)=>{for(let r=0;r<t.length;r++){let i=t[r].sort===`desc`?-1:1,a=e.path[r].localeCompare(n.path[r])*i;if(a!==0)return a}return 0});let i=t[0].limit;if(typeof i==`number`&&i>0){let e=new Set;for(let t of r)e.size>=i&&!e.has(t.path[0])||e.add(t.path[0]);return r.filter(t=>e.has(t.path[0]))}return r}function D(e,t,n){let r=Object.entries(t);if(r.length===0)return e;let i=new Map;for(let e of n)i.set(e.field,e);return e.filter(e=>{for(let[t,n]of r){let r=i.get(t);if((r?S(e,r):e[t]==null?`(null)`:String(e[t]))!==String(n))return!1}return!0})}function O(e,t){let n={};for(let r of t){if(!r.aggregate)continue;let t=b(r),i=0,a=0,o=null,s=null;for(let n of e){let e=n[t];typeof e==`number`&&(i+=e,a+=1,(o==null||e<o)&&(o=e),(s==null||e>s)&&(s=e))}r.aggregate===`min`?n[t]=o:r.aggregate===`max`?n[t]=s:r.aggregate===`avg`?n[t]=a===0?null:i/a:n[t]=i}return n}function k(e,t,n,r){let i=A(e,n),a=A(e,r),o={},s={},c={};for(let n of i){o[n.id]={};let r=e.filter(e=>j(e,n.key));s[n.id]=O(r,t);for(let e of a){let i=r.filter(t=>j(t,e.key));if(i.length===0)continue;let a={};for(let e of t){if(!e.aggregate)continue;let t=b(e);a[t]=i[0][t]}o[n.id][e.id]=a}}for(let n of a){let r=e.filter(e=>j(e,n.key));c[n.id]=O(r,t)}return{rowHeaders:i,colHeaders:a,cells:o,rowTotals:s,colTotals:c,grandTotal:O(e,t),columns:t,downGroupings:n,acrossGroupings:r}}function A(e,t){if(t.length===0)return[{key:{},path:[],id:``}];let n=new Map;for(let r of e){let e=[],i={};for(let n of t){let t=r[n.field],a=t==null?`(null)`:String(t);e.push(a),i[n.field]=a}let a=e.join(``);n.has(a)||n.set(a,{key:i,path:e,id:a})}let r=Array.from(n.values());return r.sort((e,n)=>{for(let r=0;r<t.length;r++){let i=t[r].sort===`desc`?-1:1,a=e.path[r].localeCompare(n.path[r])*i;if(a!==0)return a}return 0}),r}function j(e,t){for(let[n,r]of Object.entries(t))if((e[n]==null?`(null)`:String(e[n]))!==String(r))return!1;return!0}function M(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(n&&r)return{$and:[e,t]};if(n)return e;if(r)return t}function N(e){let t=new Set;for(let n of e.groupingsDown??[])t.add(n.field);for(let n of e.groupingsAcross??[])t.add(n.field);for(let n of e.columns??[])t.add(n.field);for(let n of e.sort??[])t.add(n.field);return Array.from(t)}function P(e,t,n){let r=[...e.groupingsDown??[],...e.groupingsAcross??[]],i=(e.columns??[]).filter(e=>!!e.aggregate);if(r.length===0&&i.length===0)return null;let a=r.map(e=>e.dateGranularity?{field:e.field,dateGranularity:e.dateGranularity}:e.field),o=i.map(e=>({function:e.aggregate===`unique`?`count_distinct`:e.aggregate,field:e.field,alias:b(e)})),s=M(e.filter,t),c={object:e.objectName,limit:n};return a.length>0&&(c.groupBy=a),o.length>0&&(c.aggregations=o),s&&(c.where=s),c}function F(e,t,n){for(let[r,i]of Object.entries(t)){let t=n.find(e=>e.field===r);if((t?S(e,t):String(e[r]??`(empty)`))!==String(i))return!1}return!0}var I=[];function L(e,t={}){let{dataSource:r,runtimeFilter:i,maxRows:a=5e3,enabled:o=!0,rows:s,preferServerAggregation:c=!0}=t,[l,u]=(0,n.useState)(s??I),[d,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(()=>s?!1:!!(e&&o&&r)),[h,g]=(0,n.useState)(null),_=(0,n.useRef)(0),v=(0,n.useCallback)(async()=>{if(!e||!o)return;if(s){u(s),f(!1);return}if(!r){u(I);return}let t=++_.current;m(!0),g(null);try{let n=c?P(e,i,a):null;if(n&&typeof r.aggregate==`function`)try{let i=R(await r.aggregate(e.objectName,n));if(t!==_.current)return;u(i),f(!0);return}catch(e){typeof console<`u`&&console.warn&&console.warn(`[useReportData] dataSource.aggregate() failed, falling back to find():`,e)}if(typeof r.find!=`function`){u(I),f(!1);return}let o=M(e.filter,i),s=N(e),l={$top:a};o&&(l.$filter=o),s.length>0&&(l.$select=s),e.sort&&e.sort.length>0&&(l.$orderBy=e.sort.map(e=>`${e.field} ${e.direction??`asc`}`).join(`,`));let d=R(await r.find(e.objectName,l));if(t!==_.current)return;u(d),f(!1)}catch(e){if(t!==_.current)return;g(e instanceof Error?e:Error(String(e))),u(I),f(!1)}finally{t===_.current&&m(!1)}},[e,o,s,r,i,a,c]);(0,n.useEffect)(()=>{v()},[v]);let{rows:y,totals:b,pivot:x}=(0,n.useMemo)(()=>{if(!e)return{rows:[],totals:{},pivot:null};let t=e.groupingsDown??[],n=e.groupingsAcross??[],r=e.columns??[],i=n.length>0;if(d){let e=[...t,...n],a=l.map(t=>{let n={},r=[];for(let i of e){let e=t[i.field];n[i.field]=e,r.push(e==null?`(null)`:String(e))}let i={...t};for(let t of e)delete i[t.field];return{groupKey:n,groupPath:r,values:i,count:1}}),o=O(l,r),s=i?k(l,r,t,n):null;return{rows:i&&s?s.rowHeaders.map(e=>({groupKey:e.key,groupPath:e.path,values:s.rowTotals[e.id]??{},count:1})):a,totals:o,pivot:s}}let a=i?t:[...t,...n];return{rows:a.length>0?w(l,a,r):l.map(e=>({groupKey:{},groupPath:[],values:r.length>0?C([e],r):{...e},count:1})),totals:C(l,r),pivot:i?T(l,r,t,n):null}},[e,l,d]);return{rows:y,rawRows:l,totals:b,pivot:x,serverAggregated:d,loading:p,error:h,refetch:v,drillDown:(0,n.useCallback)(t=>{if(!e)return[];let n=[...e.groupingsDown??[],...e.groupingsAcross??[]];return l.filter(e=>F(e,t,n))},[e,l])}}function R(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;if(Array.isArray(t.data))return t.data;if(Array.isArray(t.records))return t.records;if(Array.isArray(t.results))return t.results;if(Array.isArray(t.value))return t.value}return I}function ee(e){return e.aggregate?`${e.field}__${e.aggregate}`:e.field}function te(e){let t=[],n=e=>{e.children&&e.children.length>0?e.children.forEach(n):t.push(e)};return e.forEach(n),t}function ne({report:e,rows:t,labels:n}){let r=e.chart;if(!r||!r.type)return{schema:null};let i=e.groupingsDown??[],a=r.xAxis||(i.length>0?i[0]?.field:void 0);if(!a)return{schema:null,diagnostic:`chart.xAxis missing and no groupingsDown[0] to default to.`};let o=e.columns??[],s=r.yAxis,c=`count`,l=`Count`,u=!0;if(s){let e=o.find(e=>e.field===s&&e.aggregate);e?(c=ee(e),l=n?.resolveColumnLabel?.(e)??(typeof e.label==`string`?e.label:`${e.aggregate}(${e.field})`),u=!1):(c=`count`,l=n?.resolveCountLabel?.(s)??`Count of ${s}`)}let d=te(t),f=new Map;for(let e of d){let t=e.groupKey[a];if(t===void 0)continue;let n=String(t??``),r=u?e.count:Number(e.values[c]??0),i=f.get(n);i?i.measure+=Number.isFinite(r)?r:0:f.set(n,{x:t,measure:Number.isFinite(r)?r:0})}let p=Array.from(f.values()).map(e=>{let t=n?.resolveAxisValue?.(a,e.x)??e.x??`(null)`;return{[a]:t,[c]:e.measure}});return(r.type===`pie`||r.type===`donut`||r.type===`funnel`)&&(p=[...p].sort((e,t)=>Number(t[c]??0)-Number(e[c]??0))),{schema:{type:`chart`,chartType:r.type,data:p,xAxisKey:a,series:[{dataKey:c,label:l}],title:r.title,showLegend:r.showLegend??!0,showDataLabels:r.showDataLabels??!1,className:`w-full h-[320px]`}}}function z(e,t,n={}){let r=M(M(e.filter,n.runtimeFilter),Object.keys(t).length>0?t:void 0);return{type:`drill`,name:`drill-${e.name}`,objectName:e.objectName,...r?{filter:r}:{},view:n.view??`list`,...n.recordId===void 0?{}:{recordId:n.recordId},openIn:n.openIn??`current`}}function re(e){return!!e&&e.type===`drill`}function ie(e){return async t=>{if(!re(t))return{success:!1,error:`drill handler invoked with non-drill action`};try{return await e.navigate({objectName:t.objectName,filter:t.filter,view:t.view,recordId:t.recordId,openIn:t.openIn}),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}}function ae(e,t){return e.registerHandler(`drill`,ie(t)),()=>e.unregisterHandler(`drill`)}function oe(e){return e?e===`unique`?`count_distinct`:e:null}function se(e){if(!(!e||e.length===0))return{fields:e.map(e=>({field:e.field,order:e.sort??`asc`,collapsed:!1}))}}function ce(e){return(e.columns??[]).map(e=>{let t={field:e.field};return e.label&&(t.label=typeof e.label==`string`?e.label:String(e.label)),e.format&&(t.format=e.format),e.width&&(t.width=e.width),t})}var le={padding:`12px 16px`,border:`1px dashed rgb(203 213 225)`,borderRadius:8,color:`rgb(100 116 139)`,fontSize:14},B=({report:e,dataSource:t,rows:r,runtimeFilter:i,onDrillDown:u,actionRunner:d,drillView:f,drillOpenIn:p,className:m})=>{let h=e.type??`tabular`,{t:g}=(0,o.useTranslation)(),{fieldLabel:_,translateOptions:v}=(0,c.useSafeFieldLabel)(),[y,x]=n.useState(null);n.useEffect(()=>{let n=t;if(!n||typeof n.getObjectSchema!=`function`||!e.objectName)return;let r=!1;return n.getObjectSchema(e.objectName).then(e=>{r||x(e??null)}).catch(()=>{}),()=>{r=!0}},[t,e.objectName]);let S=n.useCallback(t=>{if(t.label)return String(t.label);let n=y?.fields?.[t.field]?.label??t.field,r=_(e.objectName,t.field,n);return t.aggregate?`${r} · ${g(`report.aggregate.${t.aggregate}`,t.aggregate)}`:r},[y,e.objectName,_,g]),C=n.useCallback((t,n)=>{if(n==null)return;let r=y?.fields?.[t];if(!r||!(r.type===`select`||r.type===`status`)||!Array.isArray(r.options)||r.options.length===0)return;let i=v(e.objectName,t,r.options),a=String(n);for(let e of i)if(e&&e.value!==void 0&&e.value!==null&&String(e.value)===a)return e.label==null?a:String(e.label)},[y,e.objectName,v]),{rawRows:w,rows:T,totals:E,serverAggregated:D,loading:O,error:k,drillDown:A}=L(e,{dataSource:t,rows:r,runtimeFilter:i});if(h===`matrix`||h===`joined`)return(0,a.jsxs)(`div`,{className:m,style:le,children:[`Report type `,(0,a.jsx)(`code`,{children:h}),` is not yet supported by SpecReportGrid. It will be rendered by a dedicated component in M2 (matrix) / M3 (joined).`]});let j=n.useMemo(()=>{if(D){let t=(e.groupingsDown??[]).map(e=>({field:e.field,label:e.field.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})),n=(e.columns??[]).filter(e=>e.aggregate).map(e=>({field:b(e),label:`${(typeof e.label==`string`?e.label:null)??e.field} (${e.aggregate})`,...e.format?{format:e.format}:{}}));return{type:`object-grid`,objectName:e.objectName,columns:[...t,...n]}}let t=h===`summary`?se(e.groupingsDown):void 0,n=(e.columns??[]).map(e=>{let t=oe(e.aggregate);return t?{field:e.field,type:t}:null}).filter(e=>e!==null);return{type:`object-grid`,objectName:e.objectName,columns:ce(e),grouping:t,aggregations:n.length>0?n:void 0}},[e,h,D]),M=w,N=n.useCallback(t=>{let n=e.groupingsDown??[],r={};for(let e of n)r[e.field]=t[e.field];if(d){let t=z(e,r,{runtimeFilter:i,view:f,openIn:p});d.execute(t)}u&&u(r,A(r))},[d,A,p,f,u,e,i]),P=!!u||!!d,F=(e.columns??[]).filter(e=>e.aggregate),I=F.length>0&&E&&Object.keys(E).length>0,R=n.useMemo(()=>h!==`summary`||!e.chart||!e.chart.type?null:ne({report:e,rows:T,labels:{resolveColumnLabel:S,resolveCountLabel:t=>{let n=y?.fields?.[t]?.label??t;return`${_(e.objectName,t,n)} · ${g(`report.aggregate.count`,`Count`)}`},resolveAxisValue:C}}).schema,[e,T,h,S,C,y,_,g]);return(0,a.jsxs)(`div`,{className:m,"data-testid":`spec-report-grid`,"aria-busy":O||void 0,children:[k?(0,a.jsx)(`div`,{role:`alert`,style:{...le,color:`rgb(190 18 60)`},children:k.message}):null,I?(0,a.jsxs)(`div`,{"data-testid":`spec-report-totals`,className:`mb-3 flex flex-wrap items-baseline gap-x-6 gap-y-1 rounded-md border bg-muted/40 px-3 py-2 text-sm`,children:[(0,a.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:g(`report.totals`,`Totals`)}),F.map(e=>{let t=b(e),n=E[t],r=S(e),i=typeof n==`number`?n.toLocaleString(void 0,{maximumFractionDigits:2}):String(n??`—`);return(0,a.jsxs)(`span`,{"data-testid":`spec-report-total-${t}`,className:`inline-flex items-baseline gap-1.5`,children:[(0,a.jsxs)(`span`,{className:`text-muted-foreground`,children:[r,`:`]}),(0,a.jsx)(`span`,{className:`font-mono font-medium tabular-nums`,children:i})]},t)})]}):null,R?(0,a.jsx)(`div`,{className:`mb-4`,"data-testid":`spec-report-chart`,children:(0,a.jsx)(l.SchemaRenderer,{schema:R})}):null,(0,a.jsx)(s.ObjectGrid,{schema:j,data:M,dataSource:t,onRowClick:P?N:void 0})]})};B.displayName=`SpecReportGrid`;var V=`—`;function ue(e){return e==null?V:typeof e==`number`?e.toLocaleString():String(e)}function de(e,t,n){if(e==null||e===``||e===`(null)`)return n;let r=t?.options;if(r){let t=r.get(e);if(t!==void 0&&t!==``)return t}return e}function fe({header:e,groupings:t,metaByField:n,fallback:r,emptyLabel:i}){return e.path.length===0?(0,a.jsx)(a.Fragment,{children:r}):(0,a.jsx)(a.Fragment,{children:e.path.map((e,r)=>{let a=t[r]?.field;return de(e,a?n.get(a):void 0,i)}).join(` / `)})}var pe=({report:e,dataSource:t,rows:r,runtimeFilter:s,onCellClick:l,actionRunner:u,drillView:d,drillOpenIn:f,className:p,emptyCellText:m=V})=>{let{pivot:h,loading:g,error:_}=L(e,{dataSource:t,rows:r,runtimeFilter:s}),v=e.columns??[],y=v.length>1,{fieldLabel:x,translateOptions:S}=(0,c.useSafeFieldLabel)(),{t:C}=(0,o.useTranslation)(),w=C(`report.emptyLabel`,`(Empty)`),T=C(`report.allLabel`,`(All)`),[E,D]=n.useState(null);n.useEffect(()=>{let n=t;if(!n||typeof n.getObjectSchema!=`function`||!e.objectName)return;let r=!1;return n.getObjectSchema(e.objectName).then(e=>{r||D(e??null)}).catch(()=>{}),()=>{r=!0}},[t,e.objectName]);let O=e.groupingsDown??[],k=e.groupingsAcross??[],A=n.useMemo(()=>{let t=new Map,n=E?.fields??{},r=[...O,...k];for(let i of r){let r=n[i.field],a=r?.label??i.field,o=x(e.objectName,i.field,a),s=r?.type===`select`||r?.type===`status`,c;if(s&&Array.isArray(r?.options)&&r.options.length>0){let t=S(e.objectName,i.field,r.options);c=new Map;for(let e of t)e&&e.value!==void 0&&e.value!==null&&c.set(String(e.value),e.label==null?String(e.value):String(e.label))}t.set(i.field,{fieldLabel:o,options:c})}return t},[E,O,k,e.objectName,x,S]),j=n.useMemo(()=>{let t=new Map,n=E?.fields??{};for(let r of v){let i=b(r);if(r.label){t.set(i,String(r.label));continue}let a=n[r.field]?.label??r.field,o=x(e.objectName,r.field,a);if(r.aggregate){let e=C(`report.aggregate.${r.aggregate}`,r.aggregate);t.set(i,`${o} · ${e}`)}else t.set(i,o)}return t},[v,E,e.objectName,x,C]),M=n.useCallback((t,n,r)=>{let i={...t.key,...n.key};if(u){let t=z(e,i,{runtimeFilter:s,view:d,openIn:f});u.execute(t)}l&&l({rowKey:t.key,colKey:n.key,combinedKey:i,values:r})},[u,f,d,l,e,s]);if(_)return(0,a.jsx)(`div`,{className:(0,i.cn)(`rounded-md border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive`,p),role:`alert`,"data-testid":`matrix-error`,children:C(`report.failedToLoad`,`Failed to load matrix: {{message}}`,{message:_.message})});if(!h)return(0,a.jsx)(`div`,{className:(0,i.cn)(`rounded-md border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-sm text-muted-foreground`,p),"aria-busy":g||void 0,"data-testid":`matrix-empty`,children:g?C(`report.loading`,`Loading…`):C(`report.needsAcross`,"Matrix report requires at least one `groupingsAcross` field.")});let N=!!l||!!u,P=O.map(e=>A.get(e.field)?.fieldLabel??e.field).join(` / `)||C(`report.rowsLabel`,`Row`),F=k.map(e=>A.get(e.field)?.fieldLabel??e.field).join(` / `)||C(`report.columnsLabel`,`Column`),I=v.length>0?b(v[0]):null,R=0;if(I)for(let e of h.rowHeaders)for(let t of h.colHeaders){let n=h.cells[e.id]?.[t.id]?.[I];typeof n==`number`&&n>R&&(R=n)}let ee=e=>{if(!I||R<=0||!e)return 0;let t=e[I];return typeof t!=`number`||t<=0?0:Math.min(1,t/R)};return(0,a.jsx)(`div`,{className:(0,i.cn)(`overflow-auto rounded-lg border border-border bg-card shadow-sm`,p),"data-testid":`matrix-renderer`,"aria-busy":g||void 0,children:(0,a.jsxs)(`table`,{role:`table`,className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsxs)(`tr`,{children:[(0,a.jsxs)(`th`,{scope:`col`,className:(0,i.cn)(`sticky left-0 top-0 z-30 border-b border-r border-border bg-muted/60`,`px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-muted-foreground`),"aria-label":`${P} \u2192 ${F}`,children:[(0,a.jsx)(`span`,{className:`text-muted-foreground/70`,children:P}),(0,a.jsx)(`span`,{className:`mx-1 text-muted-foreground/40`,children:`\\`}),(0,a.jsx)(`span`,{className:`text-foreground/80`,children:F})]}),h.colHeaders.map(e=>(0,a.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-20 whitespace-nowrap border-b border-border bg-muted/60 px-3 py-2 text-right text-xs font-semibold text-foreground`,children:(0,a.jsx)(fe,{header:e,groupings:k,metaByField:A,fallback:T,emptyLabel:w})},`col-${e.id}`)),(0,a.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-20 whitespace-nowrap border-b border-l border-border bg-muted px-3 py-2 text-right text-xs font-semibold uppercase tracking-wide text-foreground`,children:C(`report.rowTotal`,`Row Total`)})]})}),(0,a.jsx)(`tbody`,{children:h.rowHeaders.map((e,t)=>(0,a.jsxs)(`tr`,{className:`group`,children:[(0,a.jsx)(`th`,{scope:`row`,className:(0,i.cn)(`sticky left-0 z-10 whitespace-nowrap border-b border-r border-border bg-card px-3 py-2 text-left text-sm font-medium text-foreground`,`group-hover:bg-muted/50`,t===0&&`border-t-0`),children:(0,a.jsx)(fe,{header:e,groupings:O,metaByField:A,fallback:T,emptyLabel:w})}),h.colHeaders.map(t=>{let n=h.cells[e.id]?.[t.id],r=!n,o=ee(n);return(0,a.jsx)(`td`,{className:(0,i.cn)(`border-b border-border px-3 py-2 text-right tabular-nums transition-colors`,r?`text-muted-foreground/40`:`text-foreground`,N&&!r&&`cursor-pointer hover:outline hover:outline-2 hover:-outline-offset-2 hover:outline-primary/50`,`group-hover:bg-muted/30`),style:o>0?{backgroundColor:`rgba(59, 130, 246, ${.06+o*.28})`}:void 0,onClick:N&&!r?()=>M(e,t,n):void 0,"data-row":e.id,"data-col":t.id,children:r?m:H(v,n,y,j)},`cell-${e.id}-${t.id}`)}),(0,a.jsx)(`td`,{className:(0,i.cn)(`border-b border-l border-border bg-muted/40 px-3 py-2 text-right text-sm font-semibold tabular-nums text-foreground`,`group-hover:bg-muted/60`),children:H(v,h.rowTotals[e.id]??{},y,j)})]},`row-${e.id}`))}),(0,a.jsx)(`tfoot`,{children:(0,a.jsxs)(`tr`,{children:[(0,a.jsx)(`th`,{scope:`row`,className:`sticky left-0 z-10 whitespace-nowrap border-t-2 border-r border-border bg-muted px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-foreground`,children:C(`report.columnTotal`,`Column Total`)}),h.colHeaders.map(e=>(0,a.jsx)(`td`,{className:`border-t-2 border-border bg-muted/40 px-3 py-2 text-right text-sm font-semibold tabular-nums text-foreground`,children:H(v,h.colTotals[e.id]??{},y,j)},`coltotal-${e.id}`)),(0,a.jsx)(`td`,{className:`border-l border-t-2 border-border bg-primary/10 px-3 py-2 text-right text-sm font-bold tabular-nums text-foreground`,children:H(v,h.grandTotal,y,j)})]})})]})})};function H(e,t,n,r){return e.length?n?(0,a.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>{let n=b(e);return(0,a.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r?.get(n)??e.label??n}),(0,a.jsx)(`span`,{className:`tabular-nums`,children:ue(t[n])})]},n)})}):ue(t[b(e[0])]):V}function me(e,t){return e?typeof e==`string`?e:typeof e==`object`&&typeof e.default==`string`?e.default:t:t}function he(e,t){if(!t||Object.keys(t).length===0)return e;let n=M(t,e.filter);return{...e,filter:n}}var ge=({report:e,dataSource:t,runtimeFilter:n,actionRunner:i,drillView:o,drillOpenIn:s,className:c,renderBlock:l})=>{if(!(0,r.isJoinedSpecReport)(e))return(0,a.jsxs)(`div`,{className:c,"data-testid":`joined-report-invalid`,style:{color:`var(--color-destructive, #b91c1c)`,fontSize:13,padding:12},children:[`JoinedReportRenderer requires a report with `,(0,a.jsx)(`code`,{children:`type: 'joined'`}),` and a `,(0,a.jsx)(`code`,{children:`blocks`}),` array.`]});let u=e.blocks??[],d=e.filter,f=e.objectName;return(0,a.jsx)(`div`,{className:c,"data-testid":`joined-report`,"data-report-name":e.name,style:{display:`flex`,flexDirection:`column`,gap:24},children:u.map((e,r)=>{let c=e.objectName??f??``,u=he({...e,objectName:c,type:e.type??`tabular`,columns:e.columns??[]},d),p=me(e.label,e.name),m=e.description?me(e.description,``):``,h=e.name??`block-${r}`,g=(0,a.jsxs)(`section`,{"data-testid":`joined-report-block`,"data-block-id":h,style:{display:`flex`,flexDirection:`column`,gap:8,border:`1px solid var(--color-border, #e4e4e7)`,borderRadius:8,padding:16,background:`var(--color-card, #ffffff)`},children:[(0,a.jsxs)(`header`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,a.jsx)(`h3`,{style:{margin:0,fontSize:16,fontWeight:600},children:p}),m?(0,a.jsx)(`p`,{style:{margin:0,fontSize:13,color:`var(--color-muted-foreground, #71717a)`},children:m}):null]}),(0,a.jsx)(U,{schema:u,dataSource:t,runtimeFilter:n,actionRunner:i,drillView:o,drillOpenIn:s})]},h);return l?l(e,r,g):g})})},_e={border:`1px dashed var(--color-border, #d4d4d8)`,borderRadius:8,padding:16,color:`var(--color-muted-foreground, #71717a)`,background:`var(--color-muted, #f4f4f5)`,fontSize:13},U=e=>{let{dataSource:t,rows:n,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l}=e,u=e.schema;if(u&&typeof u==`object`&&u.type===`spec-report`&&u.report&&typeof u.report==`object`&&(u=u.report),(0,r.isSpecReport)(u)){let e=u.type??`tabular`;return e===`matrix`?(0,a.jsx)(pe,{report:u,dataSource:t,rows:n,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l}):e===`joined`?(0,r.isJoinedSpecReport)(u)?(0,a.jsx)(ge,{report:u,dataSource:t,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l}):(0,a.jsxs)(`div`,{className:l,style:_e,"data-testid":`report-joined-placeholder`,children:[`Joined report (`,(0,a.jsx)(`code`,{children:u.name}),`) is missing a `,(0,a.jsx)(`code`,{children:`blocks`}),` array.`]}):(0,a.jsx)(B,{report:u,dataSource:t,rows:n,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l})}return(0,a.jsx)(y,{schema:u})};function ve(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=Se(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/types`),require(`@object-ui/components`),require(`react/jsx-runtime`),require(`react-i18next`),require(`@object-ui/plugin-grid`),require(`@object-ui/i18n`),require(`@object-ui/react`),require(`lucide-react`),require(`@object-ui/fields`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/types`,`@object-ui/components`,`react/jsx-runtime`,`react-i18next`,`@object-ui/plugin-grid`,`@object-ui/i18n`,`@object-ui/react`,`lucide-react`,`@object-ui/fields`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginReport={},e.ObjectUICore,e.React,e.ObjectUITypes,e.ObjectUIComponents,e.react_jsx_runtime,e.react_i18next,e._object_ui_plugin_grid,e._object_ui_i18n,e.ObjectUIReact,e.lucide_react,e._object_ui_fields))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var f=Object.create,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,g=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=h(t),a=0,o=i.length,s;a<o;a++)s=i[a],!_.call(e,s)&&s!==n&&p(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=m(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:f(g(e)),v(t||!e||!e.__esModule?p(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var y=({schema:e})=>{let{title:n,description:r,data:o,columns:s}=e;e.chart?.type;let c=!!e.chart;return(0,a.jsxs)(i.Card,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,a.jsxs)(i.CardHeader,{children:[n&&(0,a.jsx)(i.CardTitle,{children:n}),r&&(0,a.jsx)(i.CardDescription,{children:r})]}),(0,a.jsxs)(i.CardContent,{className:`flex-1 overflow-auto space-y-4`,children:[c&&(()=>{let n=e.chart?.type,r=n?t.ComponentRegistry.get(n):null;return r||=t.ComponentRegistry.get(`chart`),r?(0,a.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,a.jsx)(r,{schema:{...e.chart,data:e.chart.data||o}})}):(0,a.jsxs)(`div`,{className:`min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center`,children:[`Unknown component type: `,n||`chart`]})})(),o&&o.length>0&&(0,a.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=t.ComponentRegistry.get(`grid`)||t.ComponentRegistry.get(`table`);return e?(0,a.jsx)(e,{schema:{type:`grid`,rowData:o,columnDefs:s,domLayout:`autoHeight`}}):(0,a.jsx)(`div`,{className:`overflow-x-auto`,children:(0,a.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,a.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,a.jsx)(`tr`,{children:s?.map(e=>(0,a.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,a.jsx)(`tbody`,{children:o.map((e,t)=>(0,a.jsx)(`tr`,{className:`bg-background border-b`,children:s?.map(t=>(0,a.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function b(e){return e.aggregate?`${e.field}__${e.aggregate}`:e.field}function x(e,t){if(e==null)return null;let n=e instanceof Date?e:new Date(String(e));if(Number.isNaN(n.getTime()))return null;let r=n.getUTCFullYear(),i=n.getUTCMonth(),a=n.getUTCDate();switch(t){case`year`:return String(r);case`quarter`:return`${r}-Q${Math.floor(i/3)+1}`;case`month`:return`${r}-${String(i+1).padStart(2,`0`)}`;case`week`:{let e=new Date(Date.UTC(r,i,a)),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1)),o=Math.ceil(((e.getTime()-n.getTime())/864e5+1)/7);return`${e.getUTCFullYear()}-W${String(o).padStart(2,`0`)}`}case`day`:return`${r}-${String(i+1).padStart(2,`0`)}-${String(a).padStart(2,`0`)}`;default:return String(e)}}function S(e,t){let n=e[t.field];return t.dateGranularity?x(n,t.dateGranularity)??`(empty)`:n==null||n===``?`(empty)`:String(n)}function C(e,t){let n={};for(let r of t){if(!r.aggregate){let t=e.find(e=>e[r.field]!=null);n[b(r)]=t?t[r.field]:null;continue}let t=e.map(e=>e[r.field]);switch(r.aggregate){case`count`:n[b(r)]=t.length;break;case`unique`:{let e=new Set;for(let n of t)n!=null&&e.add(n);n[b(r)]=e.size;break}case`sum`:{let e=0;for(let n of t)e+=Number(n)||0;n[b(r)]=e;break}case`avg`:{let e=0,i=0;for(let n of t){if(n==null||n===``)continue;let t=Number(n);Number.isNaN(t)||(e+=t,i+=1)}n[b(r)]=i===0?null:e/i;break}case`min`:{let e=null;for(let n of t){if(n==null)continue;let t=Number(n);Number.isNaN(t)||(e===null||t<e)&&(e=t)}n[b(r)]=e;break}case`max`:{let e=null;for(let n of t){if(n==null)continue;let t=Number(n);Number.isNaN(t)||(e===null||t>e)&&(e=t)}n[b(r)]=e;break}default:n[b(r)]=null}}return n}function w(e,t,n,r={},i=[]){if(t.length===0)return[];let[a,...o]=t,s=new Map;for(let t of e){let e=S(t,a),n=s.get(e);n||(n=[],s.set(e,n)),n.push(t)}let c=[];for(let[e,t]of s){let s={...r,[a.field]:e},l=[...i,e],u=C(t,n),d=o.length>0?w(t,o,n,s,l):void 0;c.push({groupKey:s,groupPath:l,values:u,count:t.length,children:d})}let l=a.sort===`desc`?-1:1;return c.sort((e,t)=>{let n=String(e.groupPath[e.groupPath.length-1]),r=String(t.groupPath[t.groupPath.length-1]);return n.localeCompare(r)*l}),typeof a.limit==`number`&&a.limit>0?c.slice(0,a.limit):c}function T(e,t,n,r){let i=E(e,n),a=E(e,r),o={},s={},c={};for(let c of i){o[c.id]={};let i=D(e,c.key,n);s[c.id]=C(i,t);for(let e of a){let n=D(i,e.key,r);n.length!==0&&(o[c.id][e.id]=C(n,t))}}for(let n of a){let i=D(e,n.key,r);c[n.id]=C(i,t)}return{rowHeaders:i,colHeaders:a,cells:o,rowTotals:s,colTotals:c,grandTotal:C(e,t),columns:t,downGroupings:n,acrossGroupings:r}}function E(e,t){if(t.length===0)return[{key:{},path:[],id:``}];let n=new Map;for(let r of e){let e=[],i={};for(let n of t){let t=S(r,n);e.push(t),i[n.field]=t}let a=e.join(``);n.has(a)||n.set(a,{key:i,path:e,id:a})}let r=Array.from(n.values());r.sort((e,n)=>{for(let r=0;r<t.length;r++){let i=t[r].sort===`desc`?-1:1,a=e.path[r].localeCompare(n.path[r])*i;if(a!==0)return a}return 0});let i=t[0].limit;if(typeof i==`number`&&i>0){let e=new Set;for(let t of r)e.size>=i&&!e.has(t.path[0])||e.add(t.path[0]);return r.filter(t=>e.has(t.path[0]))}return r}function D(e,t,n){let r=Object.entries(t);if(r.length===0)return e;let i=new Map;for(let e of n)i.set(e.field,e);return e.filter(e=>{for(let[t,n]of r){let r=i.get(t);if((r?S(e,r):e[t]==null?`(null)`:String(e[t]))!==String(n))return!1}return!0})}function O(e,t){let n={};for(let r of t){if(!r.aggregate)continue;let t=b(r),i=0,a=0,o=null,s=null;for(let n of e){let e=n[t];typeof e==`number`&&(i+=e,a+=1,(o==null||e<o)&&(o=e),(s==null||e>s)&&(s=e))}r.aggregate===`min`?n[t]=o:r.aggregate===`max`?n[t]=s:r.aggregate===`avg`?n[t]=a===0?null:i/a:n[t]=i}return n}function k(e,t,n,r){let i=A(e,n),a=A(e,r),o={},s={},c={};for(let n of i){o[n.id]={};let r=e.filter(e=>j(e,n.key));s[n.id]=O(r,t);for(let e of a){let i=r.filter(t=>j(t,e.key));if(i.length===0)continue;let a={};for(let e of t){if(!e.aggregate)continue;let t=b(e);a[t]=i[0][t]}o[n.id][e.id]=a}}for(let n of a){let r=e.filter(e=>j(e,n.key));c[n.id]=O(r,t)}return{rowHeaders:i,colHeaders:a,cells:o,rowTotals:s,colTotals:c,grandTotal:O(e,t),columns:t,downGroupings:n,acrossGroupings:r}}function A(e,t){if(t.length===0)return[{key:{},path:[],id:``}];let n=new Map;for(let r of e){let e=[],i={};for(let n of t){let t=r[n.field],a=t==null?`(null)`:String(t);e.push(a),i[n.field]=a}let a=e.join(``);n.has(a)||n.set(a,{key:i,path:e,id:a})}let r=Array.from(n.values());return r.sort((e,n)=>{for(let r=0;r<t.length;r++){let i=t[r].sort===`desc`?-1:1,a=e.path[r].localeCompare(n.path[r])*i;if(a!==0)return a}return 0}),r}function j(e,t){for(let[n,r]of Object.entries(t))if((e[n]==null?`(null)`:String(e[n]))!==String(r))return!1;return!0}function M(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(n&&r)return{$and:[e,t]};if(n)return e;if(r)return t}function N(e){let t=new Set;for(let n of e.groupingsDown??[])t.add(n.field);for(let n of e.groupingsAcross??[])t.add(n.field);for(let n of e.columns??[])t.add(n.field);for(let n of e.sort??[])t.add(n.field);return Array.from(t)}function P(e,t,n){let r=[...e.groupingsDown??[],...e.groupingsAcross??[]],i=(e.columns??[]).filter(e=>!!e.aggregate);if(r.length===0&&i.length===0)return null;let a=r.map(e=>e.dateGranularity?{field:e.field,dateGranularity:e.dateGranularity}:e.field),o=i.map(e=>({function:e.aggregate===`unique`?`count_distinct`:e.aggregate,field:e.field,alias:b(e)})),s=M(e.filter,t),c={object:e.objectName,limit:n};return a.length>0&&(c.groupBy=a),o.length>0&&(c.aggregations=o),s&&(c.where=s),c}function F(e,t,n){for(let[r,i]of Object.entries(t)){let t=n.find(e=>e.field===r);if((t?S(e,t):String(e[r]??`(empty)`))!==String(i))return!1}return!0}var I=[];function L(e,t={}){let{dataSource:r,runtimeFilter:i,maxRows:a=5e3,enabled:o=!0,rows:s,preferServerAggregation:c=!0}=t,[l,u]=(0,n.useState)(s??I),[d,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(()=>s?!1:!!(e&&o&&r)),[h,g]=(0,n.useState)(null),_=(0,n.useRef)(0),v=(0,n.useCallback)(async()=>{if(!e||!o)return;if(s){u(s),f(!1);return}if(!r){u(I);return}let t=++_.current;m(!0),g(null);try{let n=c?P(e,i,a):null;if(n&&typeof r.aggregate==`function`)try{let i=R(await r.aggregate(e.objectName,n));if(t!==_.current)return;u(i),f(!0);return}catch(e){typeof console<`u`&&console.warn&&console.warn(`[useReportData] dataSource.aggregate() failed, falling back to find():`,e)}if(typeof r.find!=`function`){u(I),f(!1);return}let o=M(e.filter,i),s=N(e),l={$top:a};o&&(l.$filter=o),s.length>0&&(l.$select=s),e.sort&&e.sort.length>0&&(l.$orderBy=e.sort.map(e=>`${e.field} ${e.direction??`asc`}`).join(`,`));let d=R(await r.find(e.objectName,l));if(t!==_.current)return;u(d),f(!1)}catch(e){if(t!==_.current)return;g(e instanceof Error?e:Error(String(e))),u(I),f(!1)}finally{t===_.current&&m(!1)}},[e,o,s,r,i,a,c]);(0,n.useEffect)(()=>{v()},[v]);let{rows:y,totals:b,pivot:x}=(0,n.useMemo)(()=>{if(!e)return{rows:[],totals:{},pivot:null};let t=e.groupingsDown??[],n=e.groupingsAcross??[],r=e.columns??[],i=n.length>0;if(d){let e=[...t,...n],a=l.map(t=>{let n={},r=[];for(let i of e){let e=t[i.field];n[i.field]=e,r.push(e==null?`(null)`:String(e))}let i={...t};for(let t of e)delete i[t.field];return{groupKey:n,groupPath:r,values:i,count:1}}),o=O(l,r),s=i?k(l,r,t,n):null;return{rows:i&&s?s.rowHeaders.map(e=>({groupKey:e.key,groupPath:e.path,values:s.rowTotals[e.id]??{},count:1})):a,totals:o,pivot:s}}let a=i?t:[...t,...n];return{rows:a.length>0?w(l,a,r):l.map(e=>({groupKey:{},groupPath:[],values:r.length>0?C([e],r):{...e},count:1})),totals:C(l,r),pivot:i?T(l,r,t,n):null}},[e,l,d]);return{rows:y,rawRows:l,totals:b,pivot:x,serverAggregated:d,loading:p,error:h,refetch:v,drillDown:(0,n.useCallback)(t=>{if(!e)return[];let n=[...e.groupingsDown??[],...e.groupingsAcross??[]];return l.filter(e=>F(e,t,n))},[e,l])}}function R(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;if(Array.isArray(t.data))return t.data;if(Array.isArray(t.records))return t.records;if(Array.isArray(t.results))return t.results;if(Array.isArray(t.value))return t.value}return I}function ee(e){return e.aggregate?`${e.field}__${e.aggregate}`:e.field}function te(e){let t=[],n=e=>{e.children&&e.children.length>0?e.children.forEach(n):t.push(e)};return e.forEach(n),t}function ne({report:e,rows:t,labels:n}){let r=e.chart;if(!r||!r.type)return{schema:null};let i=e.groupingsDown??[],a=r.xAxis||(i.length>0?i[0]?.field:void 0);if(!a)return{schema:null,diagnostic:`chart.xAxis missing and no groupingsDown[0] to default to.`};let o=e.columns??[],s=r.yAxis,c=`count`,l=`Count`,u=!0;if(s){let e=o.find(e=>e.field===s&&e.aggregate);e?(c=ee(e),l=n?.resolveColumnLabel?.(e)??(typeof e.label==`string`?e.label:`${e.aggregate}(${e.field})`),u=!1):(c=`count`,l=n?.resolveCountLabel?.(s)??`Count of ${s}`)}let d=te(t),f=new Map;for(let e of d){let t=e.groupKey[a];if(t===void 0)continue;let n=String(t??``),r=u?e.count:Number(e.values[c]??0),i=f.get(n);i?i.measure+=Number.isFinite(r)?r:0:f.set(n,{x:t,measure:Number.isFinite(r)?r:0})}let p=Array.from(f.values()).map(e=>{let t=n?.resolveAxisValue?.(a,e.x)??e.x??`(null)`;return{[a]:t,[c]:e.measure}});return(r.type===`pie`||r.type===`donut`||r.type===`funnel`)&&(p=[...p].sort((e,t)=>Number(t[c]??0)-Number(e[c]??0))),{schema:{type:`chart`,chartType:r.type,data:p,xAxisKey:a,series:[{dataKey:c,label:l}],title:r.title,showLegend:r.showLegend??!0,showDataLabels:r.showDataLabels??!1,className:`w-full h-[320px]`}}}function z(e,t,n={}){let r=M(M(e.filter,n.runtimeFilter),Object.keys(t).length>0?t:void 0);return{type:`drill`,name:`drill-${e.name}`,objectName:e.objectName,...r?{filter:r}:{},view:n.view??`list`,...n.recordId===void 0?{}:{recordId:n.recordId},openIn:n.openIn??`current`}}function re(e){return!!e&&e.type===`drill`}function ie(e){return async t=>{if(!re(t))return{success:!1,error:`drill handler invoked with non-drill action`};try{return await e.navigate({objectName:t.objectName,filter:t.filter,view:t.view,recordId:t.recordId,openIn:t.openIn}),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}}function ae(e,t){return e.registerHandler(`drill`,ie(t)),()=>e.unregisterHandler(`drill`)}function oe(e){return e?e===`unique`?`count_distinct`:e:null}function se(e){if(!(!e||e.length===0))return{fields:e.map(e=>({field:e.field,order:e.sort??`asc`,collapsed:!1}))}}function ce(e){return(e.columns??[]).map(e=>{let t={field:e.field};return e.label&&(t.label=typeof e.label==`string`?e.label:String(e.label)),e.format&&(t.format=e.format),e.width&&(t.width=e.width),t})}var le={padding:`12px 16px`,border:`1px dashed rgb(203 213 225)`,borderRadius:8,color:`rgb(100 116 139)`,fontSize:14},B=({report:e,dataSource:t,rows:r,runtimeFilter:i,onDrillDown:u,actionRunner:d,drillView:f,drillOpenIn:p,className:m})=>{let h=e.type??`tabular`,{t:g}=(0,o.useTranslation)(),{fieldLabel:_,translateOptions:v}=(0,c.useSafeFieldLabel)(),[y,x]=n.useState(null);n.useEffect(()=>{let n=t;if(!n||typeof n.getObjectSchema!=`function`||!e.objectName)return;let r=!1;return n.getObjectSchema(e.objectName).then(e=>{r||x(e??null)}).catch(()=>{}),()=>{r=!0}},[t,e.objectName]);let S=n.useCallback(t=>{if(t.label)return String(t.label);let n=y?.fields?.[t.field]?.label??t.field,r=_(e.objectName,t.field,n);return t.aggregate?`${r} · ${g(`report.aggregate.${t.aggregate}`,t.aggregate)}`:r},[y,e.objectName,_,g]),C=n.useCallback((t,n)=>{if(n==null)return;let r=y?.fields?.[t];if(!r||!(r.type===`select`||r.type===`status`)||!Array.isArray(r.options)||r.options.length===0)return;let i=v(e.objectName,t,r.options),a=String(n);for(let e of i)if(e&&e.value!==void 0&&e.value!==null&&String(e.value)===a)return e.label==null?a:String(e.label)},[y,e.objectName,v]),{rawRows:w,rows:T,totals:E,serverAggregated:D,loading:O,error:k,drillDown:A}=L(e,{dataSource:t,rows:r,runtimeFilter:i});if(h===`matrix`||h===`joined`)return(0,a.jsxs)(`div`,{className:m,style:le,children:[`Report type `,(0,a.jsx)(`code`,{children:h}),` is not yet supported by SpecReportGrid. It will be rendered by a dedicated component in M2 (matrix) / M3 (joined).`]});let j=n.useMemo(()=>{if(D){let t=(e.groupingsDown??[]).map(e=>({field:e.field,label:e.field.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})),n=(e.columns??[]).filter(e=>e.aggregate).map(e=>({field:b(e),label:`${(typeof e.label==`string`?e.label:null)??e.field} (${e.aggregate})`,...e.format?{format:e.format}:{}}));return{type:`object-grid`,objectName:e.objectName,columns:[...t,...n]}}let t=h===`summary`?se(e.groupingsDown):void 0,n=(e.columns??[]).map(e=>{let t=oe(e.aggregate);return t?{field:e.field,type:t}:null}).filter(e=>e!==null);return{type:`object-grid`,objectName:e.objectName,columns:ce(e),grouping:t,aggregations:n.length>0?n:void 0}},[e,h,D]),M=w,N=n.useCallback(t=>{let n=e.groupingsDown??[],r={};for(let e of n)r[e.field]=t[e.field];if(d){let t=z(e,r,{runtimeFilter:i,view:f,openIn:p});d.execute(t)}u&&u(r,A(r))},[d,A,p,f,u,e,i]),P=!!u||!!d,F=(e.columns??[]).filter(e=>e.aggregate),I=F.length>0&&E&&Object.keys(E).length>0,R=n.useMemo(()=>h!==`summary`||!e.chart||!e.chart.type?null:ne({report:e,rows:T,labels:{resolveColumnLabel:S,resolveCountLabel:t=>{let n=y?.fields?.[t]?.label??t;return`${_(e.objectName,t,n)} · ${g(`report.aggregate.count`,`Count`)}`},resolveAxisValue:C}}).schema,[e,T,h,S,C,y,_,g]);return(0,a.jsxs)(`div`,{className:m,"data-testid":`spec-report-grid`,"aria-busy":O||void 0,children:[k?(0,a.jsx)(`div`,{role:`alert`,style:{...le,color:`rgb(190 18 60)`},children:k.message}):null,I?(0,a.jsxs)(`div`,{"data-testid":`spec-report-totals`,className:`mb-3 flex flex-wrap items-baseline gap-x-6 gap-y-1 rounded-md border bg-muted/40 px-3 py-2 text-sm`,children:[(0,a.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:g(`report.totals`,`Totals`)}),F.map(e=>{let t=b(e),n=E[t],r=S(e),i=typeof n==`number`?n.toLocaleString(void 0,{maximumFractionDigits:2}):String(n??`—`);return(0,a.jsxs)(`span`,{"data-testid":`spec-report-total-${t}`,className:`inline-flex items-baseline gap-1.5`,children:[(0,a.jsxs)(`span`,{className:`text-muted-foreground`,children:[r,`:`]}),(0,a.jsx)(`span`,{className:`font-mono font-medium tabular-nums`,children:i})]},t)})]}):null,R?(0,a.jsx)(`div`,{className:`mb-4`,"data-testid":`spec-report-chart`,children:(0,a.jsx)(l.SchemaRenderer,{schema:R})}):null,(0,a.jsx)(s.ObjectGrid,{schema:j,data:M,dataSource:t,onRowClick:P?N:void 0})]})};B.displayName=`SpecReportGrid`;var V=`—`;function ue(e){return e==null?V:typeof e==`number`?e.toLocaleString():String(e)}function de(e,t,n){if(e==null||e===``||e===`(null)`)return n;let r=t?.options;if(r){let t=r.get(e);if(t!==void 0&&t!==``)return t}return e}function fe({header:e,groupings:t,metaByField:n,fallback:r,emptyLabel:i}){return e.path.length===0?(0,a.jsx)(a.Fragment,{children:r}):(0,a.jsx)(a.Fragment,{children:e.path.map((e,r)=>{let a=t[r]?.field;return de(e,a?n.get(a):void 0,i)}).join(` / `)})}var pe=({report:e,dataSource:t,rows:r,runtimeFilter:s,onCellClick:l,actionRunner:u,drillView:d,drillOpenIn:f,className:p,emptyCellText:m=V})=>{let{pivot:h,loading:g,error:_}=L(e,{dataSource:t,rows:r,runtimeFilter:s}),v=e.columns??[],y=v.length>1,{fieldLabel:x,translateOptions:S}=(0,c.useSafeFieldLabel)(),{t:C}=(0,o.useTranslation)(),w=C(`report.emptyLabel`,`(Empty)`),T=C(`report.allLabel`,`(All)`),[E,D]=n.useState(null);n.useEffect(()=>{let n=t;if(!n||typeof n.getObjectSchema!=`function`||!e.objectName)return;let r=!1;return n.getObjectSchema(e.objectName).then(e=>{r||D(e??null)}).catch(()=>{}),()=>{r=!0}},[t,e.objectName]);let O=e.groupingsDown??[],k=e.groupingsAcross??[],A=n.useMemo(()=>{let t=new Map,n=E?.fields??{},r=[...O,...k];for(let i of r){let r=n[i.field],a=r?.label??i.field,o=x(e.objectName,i.field,a),s=r?.type===`select`||r?.type===`status`,c;if(s&&Array.isArray(r?.options)&&r.options.length>0){let t=S(e.objectName,i.field,r.options);c=new Map;for(let e of t)e&&e.value!==void 0&&e.value!==null&&c.set(String(e.value),e.label==null?String(e.value):String(e.label))}t.set(i.field,{fieldLabel:o,options:c})}return t},[E,O,k,e.objectName,x,S]),j=n.useMemo(()=>{let t=new Map,n=E?.fields??{};for(let r of v){let i=b(r);if(r.label){t.set(i,String(r.label));continue}let a=n[r.field]?.label??r.field,o=x(e.objectName,r.field,a);if(r.aggregate){let e=C(`report.aggregate.${r.aggregate}`,r.aggregate);t.set(i,`${o} · ${e}`)}else t.set(i,o)}return t},[v,E,e.objectName,x,C]),M=n.useCallback((t,n,r)=>{let i={...t.key,...n.key};if(u){let t=z(e,i,{runtimeFilter:s,view:d,openIn:f});u.execute(t)}l&&l({rowKey:t.key,colKey:n.key,combinedKey:i,values:r})},[u,f,d,l,e,s]);if(_)return(0,a.jsx)(`div`,{className:(0,i.cn)(`rounded-md border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive`,p),role:`alert`,"data-testid":`matrix-error`,children:C(`report.failedToLoad`,`Failed to load matrix: {{message}}`,{message:_.message})});if(!h)return(0,a.jsx)(`div`,{className:(0,i.cn)(`rounded-md border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-sm text-muted-foreground`,p),"aria-busy":g||void 0,"data-testid":`matrix-empty`,children:g?C(`report.loading`,`Loading…`):C(`report.needsAcross`,"Matrix report requires at least one `groupingsAcross` field.")});let N=!!l||!!u,P=O.map(e=>A.get(e.field)?.fieldLabel??e.field).join(` / `)||C(`report.rowsLabel`,`Row`),F=k.map(e=>A.get(e.field)?.fieldLabel??e.field).join(` / `)||C(`report.columnsLabel`,`Column`),I=v.length>0?b(v[0]):null,R=0;if(I)for(let e of h.rowHeaders)for(let t of h.colHeaders){let n=h.cells[e.id]?.[t.id]?.[I];typeof n==`number`&&n>R&&(R=n)}let ee=e=>{if(!I||R<=0||!e)return 0;let t=e[I];return typeof t!=`number`||t<=0?0:Math.min(1,t/R)};return(0,a.jsx)(`div`,{className:(0,i.cn)(`overflow-auto rounded-lg border border-border bg-card shadow-sm`,p),"data-testid":`matrix-renderer`,"aria-busy":g||void 0,children:(0,a.jsxs)(`table`,{role:`table`,className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,a.jsx)(`thead`,{children:(0,a.jsxs)(`tr`,{children:[(0,a.jsxs)(`th`,{scope:`col`,className:(0,i.cn)(`sticky left-0 top-0 z-30 border-b border-r border-border bg-muted/60`,`px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-muted-foreground`),"aria-label":`${P} \u2192 ${F}`,children:[(0,a.jsx)(`span`,{className:`text-muted-foreground/70`,children:P}),(0,a.jsx)(`span`,{className:`mx-1 text-muted-foreground/40`,children:`\\`}),(0,a.jsx)(`span`,{className:`text-foreground/80`,children:F})]}),h.colHeaders.map(e=>(0,a.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-20 whitespace-nowrap border-b border-border bg-muted/60 px-3 py-2 text-right text-xs font-semibold text-foreground`,children:(0,a.jsx)(fe,{header:e,groupings:k,metaByField:A,fallback:T,emptyLabel:w})},`col-${e.id}`)),(0,a.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-20 whitespace-nowrap border-b border-l border-border bg-muted px-3 py-2 text-right text-xs font-semibold uppercase tracking-wide text-foreground`,children:C(`report.rowTotal`,`Row Total`)})]})}),(0,a.jsx)(`tbody`,{children:h.rowHeaders.map((e,t)=>(0,a.jsxs)(`tr`,{className:`group`,children:[(0,a.jsx)(`th`,{scope:`row`,className:(0,i.cn)(`sticky left-0 z-10 whitespace-nowrap border-b border-r border-border bg-card px-3 py-2 text-left text-sm font-medium text-foreground`,`group-hover:bg-muted/50`,t===0&&`border-t-0`),children:(0,a.jsx)(fe,{header:e,groupings:O,metaByField:A,fallback:T,emptyLabel:w})}),h.colHeaders.map(t=>{let n=h.cells[e.id]?.[t.id],r=!n,o=ee(n);return(0,a.jsx)(`td`,{className:(0,i.cn)(`border-b border-border px-3 py-2 text-right tabular-nums transition-colors`,r?`text-muted-foreground/40`:`text-foreground`,N&&!r&&`cursor-pointer hover:outline hover:outline-2 hover:-outline-offset-2 hover:outline-primary/50`,`group-hover:bg-muted/30`),style:o>0?{backgroundColor:`rgba(59, 130, 246, ${.06+o*.28})`}:void 0,onClick:N&&!r?()=>M(e,t,n):void 0,"data-row":e.id,"data-col":t.id,children:r?m:H(v,n,y,j)},`cell-${e.id}-${t.id}`)}),(0,a.jsx)(`td`,{className:(0,i.cn)(`border-b border-l border-border bg-muted/40 px-3 py-2 text-right text-sm font-semibold tabular-nums text-foreground`,`group-hover:bg-muted/60`),children:H(v,h.rowTotals[e.id]??{},y,j)})]},`row-${e.id}`))}),(0,a.jsx)(`tfoot`,{children:(0,a.jsxs)(`tr`,{children:[(0,a.jsx)(`th`,{scope:`row`,className:`sticky left-0 z-10 whitespace-nowrap border-t-2 border-r border-border bg-muted px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-foreground`,children:C(`report.columnTotal`,`Column Total`)}),h.colHeaders.map(e=>(0,a.jsx)(`td`,{className:`border-t-2 border-border bg-muted/40 px-3 py-2 text-right text-sm font-semibold tabular-nums text-foreground`,children:H(v,h.colTotals[e.id]??{},y,j)},`coltotal-${e.id}`)),(0,a.jsx)(`td`,{className:`border-l border-t-2 border-border bg-primary/10 px-3 py-2 text-right text-sm font-bold tabular-nums text-foreground`,children:H(v,h.grandTotal,y,j)})]})})]})})};function H(e,t,n,r){return e.length?n?(0,a.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>{let n=b(e);return(0,a.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r?.get(n)??e.label??n}),(0,a.jsx)(`span`,{className:`tabular-nums`,children:ue(t[n])})]},n)})}):ue(t[b(e[0])]):V}function me(e,t){return e?typeof e==`string`?e:typeof e==`object`&&typeof e.default==`string`?e.default:t:t}function he(e,t){if(!t||Object.keys(t).length===0)return e;let n=M(t,e.filter);return{...e,filter:n}}var ge=({report:e,dataSource:t,runtimeFilter:n,actionRunner:i,drillView:o,drillOpenIn:s,className:c,renderBlock:l})=>{if(!(0,r.isJoinedSpecReport)(e))return(0,a.jsxs)(`div`,{className:c,"data-testid":`joined-report-invalid`,style:{color:`var(--color-destructive, #b91c1c)`,fontSize:13,padding:12},children:[`JoinedReportRenderer requires a report with `,(0,a.jsx)(`code`,{children:`type: 'joined'`}),` and a `,(0,a.jsx)(`code`,{children:`blocks`}),` array.`]});let u=e.blocks??[],d=e.filter,f=e.objectName;return(0,a.jsx)(`div`,{className:c,"data-testid":`joined-report`,"data-report-name":e.name,style:{display:`flex`,flexDirection:`column`,gap:24},children:u.map((e,r)=>{let c=e.objectName??f??``,u=he({...e,objectName:c,type:e.type??`tabular`,columns:e.columns??[]},d),p=me(e.label,e.name),m=e.description?me(e.description,``):``,h=e.name??`block-${r}`,g=(0,a.jsxs)(`section`,{"data-testid":`joined-report-block`,"data-block-id":h,style:{display:`flex`,flexDirection:`column`,gap:8,border:`1px solid var(--color-border, #e4e4e7)`,borderRadius:8,padding:16,background:`var(--color-card, #ffffff)`},children:[(0,a.jsxs)(`header`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,a.jsx)(`h3`,{style:{margin:0,fontSize:16,fontWeight:600},children:p}),m?(0,a.jsx)(`p`,{style:{margin:0,fontSize:13,color:`var(--color-muted-foreground, #71717a)`},children:m}):null]}),(0,a.jsx)(U,{schema:u,dataSource:t,runtimeFilter:n,actionRunner:i,drillView:o,drillOpenIn:s})]},h);return l?l(e,r,g):g})})},_e={border:`1px dashed var(--color-border, #d4d4d8)`,borderRadius:8,padding:16,color:`var(--color-muted-foreground, #71717a)`,background:`var(--color-muted, #f4f4f5)`,fontSize:13},U=e=>{let{dataSource:t,rows:n,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l}=e,u=e.schema;if(u&&typeof u==`object`&&u.type===`spec-report`&&u.report&&typeof u.report==`object`&&(u=u.report),(0,r.isSpecReport)(u)){let e=u.type??`tabular`;return e===`matrix`?(0,a.jsx)(pe,{report:u,dataSource:t,rows:n,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l}):e===`joined`?(0,r.isJoinedSpecReport)(u)?(0,a.jsx)(ge,{report:u,dataSource:t,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l}):(0,a.jsxs)(`div`,{className:l,style:_e,"data-testid":`report-joined-placeholder`,children:[`Joined report (`,(0,a.jsx)(`code`,{children:u.name}),`) is missing a `,(0,a.jsx)(`code`,{children:`blocks`}),` array.`]}):(0,a.jsx)(B,{report:u,dataSource:t,rows:n,runtimeFilter:i,actionRunner:o,drillView:s,drillOpenIn:c,className:l})}return(0,a.jsx)(y,{schema:u})};function ve(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=Se(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
2
2
|
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));q([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
3
3
|
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function ye(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};q(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function W(e,t,n){let r=e.fields||[],i=we(n?.orientation),a=Ce(n?.pageSize);q(`<!DOCTYPE html>
|
|
4
4
|
<html>
|
|
@@ -20,7 +20,7 @@ import { DrillOpenIn, DrillView } from './drill';
|
|
|
20
20
|
* a {@link buildDrillAction} carrying both keys merged.
|
|
21
21
|
*
|
|
22
22
|
* We intentionally don't use ObjectGrid here — its tree model is single-axis
|
|
23
|
-
* and bolting a 2D matrix onto
|
|
23
|
+
* and bolting a 2D matrix onto grid header groups would be heavier than a
|
|
24
24
|
* direct table. The pivot dataset is already small (rows × cols are
|
|
25
25
|
* dimensions, not raw records).
|
|
26
26
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-report",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.umd.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"lucide-react": "^1.16.0",
|
|
24
24
|
"react-i18next": "^17.0.7",
|
|
25
25
|
"tailwind-merge": "^3.6.0",
|
|
26
|
-
"@object-ui/components": "5.
|
|
27
|
-
"@object-ui/core": "5.
|
|
28
|
-
"@object-ui/fields": "5.
|
|
29
|
-
"@object-ui/i18n": "5.
|
|
30
|
-
"@object-ui/plugin-grid": "5.
|
|
31
|
-
"@object-ui/react": "5.
|
|
32
|
-
"@object-ui/types": "5.
|
|
26
|
+
"@object-ui/components": "5.3.1",
|
|
27
|
+
"@object-ui/core": "5.3.1",
|
|
28
|
+
"@object-ui/fields": "5.3.1",
|
|
29
|
+
"@object-ui/i18n": "5.3.1",
|
|
30
|
+
"@object-ui/plugin-grid": "5.3.1",
|
|
31
|
+
"@object-ui/react": "5.3.1",
|
|
32
|
+
"@object-ui/types": "5.3.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0",
|