@agility-workbench/react-grid 1.10.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -110,6 +110,36 @@ activeSheetId, onChange, onActiveSheetChange }}` renders the footer tab strip wi
110
110
  app-owned persistence contract as `savedViews`. See the core README for what pivot mode and
111
111
  sheets do.
112
112
 
113
+ ### Live and creation-only props
114
+
115
+ Most props are live. The ones the grid reads only at creation (`rowHeight`, `getRowId`,
116
+ `rowIdKey`, `rowModelType`, `defaultColDef`, `groupColumnDef`, `pivotResultColumnDef`,
117
+ `initialSort`, … — the core's `CREATION_ONLY_OPTION_KEYS`, minus the bridged callbacks) ignore
118
+ later changes; in development builds the grid logs one `console.warn` naming the prop when that
119
+ happens. Remount the grid (change its React `key`) to apply such a change. The React page of the
120
+ documentation site has the full live-vs-creation table.
121
+
122
+ ### Event props
123
+
124
+ Each core event with a declarative callback is a prop, and the latest one passed is always the
125
+ one called: `onCellClicked`, `onRowClicked`, `onCellDoubleClicked`, `onRowDoubleClicked`,
126
+ `onCellValueChanged`, `onSelectionChanged`, `onSortChanged`, `onFilterChanged`,
127
+ `onQuickFilterFindChanged`, `onHistoryChanged`, `onColumnsChanged`, `onPaginationChanged` and
128
+ `onError`. `onColumnsChanged` (and `onSortChanged`) carry `source: "user" | "api"` — persist
129
+ column state on `"user"` so restoring it never echoes back. `onError` reports failed row-model
130
+ requests; the grid handles them the same way with or without it. Anything else:
131
+ `api.on(eventName, handler)`.
132
+
133
+ ### React components in the grid
134
+
135
+ `ReactColDef` component slots accept React components: `cellRenderer`, `cellEditor`,
136
+ `tooltipComponent`, `headerTooltip`, `actionFrameComponent`, the set-filter components in
137
+ `filterParams`, and the header components `headerComponent` (header content) and
138
+ `headerCellComponent` (the whole header cell). Header components receive `HeaderComponentParams`
139
+ as props and re-render on sort/filter changes. The same slots are adapted in `defaultColDef`,
140
+ `groupColumnDef`, and `pivotResultColumnDef`. Core class components (and a header function
141
+ returning an `HTMLElement`) pass through unchanged.
142
+
113
143
  ## Styling
114
144
 
115
145
  Nothing to do — the grid delivers its own stylesheet when it attaches, once per
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Ae=Object.create;var w=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var He=(t,e)=>{for(var o in e)w(t,o,{get:e[o],enumerable:!0})},S=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ke(e))!Oe.call(t,r)&&r!==o&&w(t,r,{get:()=>e[r],enumerable:!(a=Ge(e,r))||a.enumerable});return t},M=(t,e,o)=>(S(t,e,"default"),o&&S(o,e,"default")),R=(t,e,o)=>(o=t!=null?Ae(xe(t)):{},S(e||!t||!t.__esModule?w(o,"default",{value:t,enumerable:!0}):o,t)),Be=t=>S(w({},"__esModule",{value:!0}),t);var h={};He(h,{Grid:()=>ve});module.exports=Be(h);M(h,require("@agility-workbench/grid"),module.exports);var i=R(require("react"),1),Me=require("@agility-workbench/grid");var g=R(require("react"),1);var re=require("react-dom"),ae=require("react-dom/client"),k=new Set,x=!1;function Ve(){x=!1;let t=Array.from(k);k.clear();for(let e of t)e.unmount()}function Ne(t){k.add(t),!x&&(x=!0,queueMicrotask(Ve))}var d=class{root;constructor(e){this.root=(0,ae.createRoot)(e)}render(e){this.root?.render(e)}renderSync(e){let o=this.root;o&&(0,re.flushSync)(()=>o.render(e))}destroy(){let e=this.root;e&&(this.root=null,Ne(e))}};var p=require("@agility-workbench/grid"),me=require("@agility-workbench/grid"),Ce=require("@agility-workbench/grid");var O=R(require("react"),1);var le=new WeakMap;function Le(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function ze(t){return class{el=document.createElement("div");root=null;handle=O.default.createRef();init(o){this.el.style.width="100%",this.el.style.height="100%",this.root=new d(this.el);let a=O.default.createElement(t,{...o,ref:this.handle});this.root.renderSync(a)}getGui(){return this.el}getValue(){return this.handle.current?.getValue()}isParsed(){return this.handle.current?.isParsed?.()??!1}focus(){this.handle.current?.focus?.()}isCancelBeforeStart(){return this.handle.current?.isCancelBeforeStart?.()??!1}destroy(){let o=this.root;this.root=null,o?.destroy()}}}function H(t){if(t==null)return;if(typeof t=="string"||Le(t))return t;let e=le.get(t);if(e)return e;let o=ze(t);return le.set(t,o),o}var ue=new WeakMap,ce=new WeakMap,de=new WeakMap,se=new WeakMap;function P(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function Ke(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function We(t){return class{el=document.createElement("span");root=null;init(o){this.el.style.display="inline-flex",this.el.style.alignItems="center",this.el.style.width="100%",this.el.style.height="100%",this.el.style.overflow="hidden",this.root=new d(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(g.default.createElement(t,Ke(o)))}}}function F(t){if(!t)return;if(typeof t=="function"&&(0,p.isClassRenderer)(t)||!P(t))return t;let e=ue.get(t);if(e)return e;let o=We(t);return ue.set(t,o),o}function je(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function qe(t){return class{el=document.createElement("div");root=null;init(o){this.root=new d(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.renderSync(g.default.createElement(t,je(o)))}}}function b(t){if(!t)return;if(typeof t=="function"&&(0,me.isClassTooltipComponent)(t)||!P(t))return t;let e=ce.get(t);if(e)return e;let o=qe(t);return ce.set(t,o),o}function E(t){if(t)return e=>{let o=t(e);return!o||typeof o.tooltip!="object"||o.tooltip==null?o:{...o,tooltip:{...o.tooltip,component:b(o.tooltip.component)}}}}function fe(t){return t==null||typeof t=="string"?t:b(t)}function Ue(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function Je(t){return class{el=document.createElement("div");root=null;init(o){this.root=new d(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(g.default.createElement(t,Ue(o)))}}}function Re(t){if(!t)return;if(typeof t=="function"&&(0,Ce.isClassActionFrameComponent)(t)||!P(t))return t;let e=de.get(t);if(e)return e;let o=Je(t);return de.set(t,o),o}function Qe(t){return class{el=document.createElement("span");root=null;init(o){this.root=new d(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(g.default.createElement(t,o))}}}function v(t){if(!t)return;if(typeof t=="function"&&(0,p.isClassSetFilterComponent)(t)||!P(t))return t;let e=se.get(t);if(e)return e;let o=Qe(t);return se.set(t,o),o}function ge(t){if(t)return{...t,valueComponent:v(t.valueComponent),selectAllComponent:v(t.selectAllComponent),blanksComponent:v(t.blanksComponent),groupComponent:v(t.groupComponent)}}function _e(t){return{...t,cellRenderer:F(t.cellRenderer),cellEditor:H(t.cellEditor),tooltipComponent:b(t.tooltipComponent),headerTooltip:fe(t.headerTooltip),actionFrameComponent:Re(t.actionFrameComponent),filterParams:ge(t.filterParams),children:t.children?B(t.children)??void 0:void 0}}function B(t){return t==null?t:t.map(e=>_e(e))}function he(t){if(t==null)return;let e={...t};return"cellRenderer"in t&&(e.cellRenderer=F(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=H(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=b(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=fe(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=Re(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=ge(t.filterParams)),e}function n(t,e,o){o!=null&&(t[e]=o)}function ye(t){let e={};return n(e,"headerHeight",t.headerHeight),n(e,"leafHeaderHeight",t.leafHeaderHeight),n(e,"parentHeaderHeight",t.parentHeaderHeight),n(e,"rowHeight",t.rowHeight),n(e,"pinnedTopRowData",t.pinnedTopRowData),n(e,"pinnedBottomRowData",t.pinnedBottomRowData),n(e,"getRowId",t.getRowId),n(e,"rowIdKey",t.rowIdKey),n(e,"rowDataMode",t.rowDataMode),n(e,"asyncTransactionWaitMs",t.asyncTransactionWaitMs),n(e,"overscanRowCount",t.overscanRowCount),n(e,"minResizeWidth",t.minResizeWidth),n(e,"maxColumnWidth",t.maxColumnWidth),n(e,"pivotMode",t.pivotMode),n(e,"pivotColumns",t.pivotColumns),n(e,"pivotResultColumnDef",t.pivotResultColumnDef),n(e,"maxPivotColumns",t.maxPivotColumns),n(e,"pivotColumnMoveMode",t.pivotColumnMoveMode),n(e,"autosizeColumnsOnDataChange",t.autosizeColumnsOnDataChange),n(e,"allowExportAsCSV",t.allowExportAsCSV),n(e,"allowExportAsExcel",t.allowExportAsExcel),n(e,"pagination",t.pagination),n(e,"paginationControls",t.paginationControls),n(e,"rowNumbers",t.rowNumbers),n(e,"rowHover",t.rowHover),n(e,"columnHover",t.columnHover),n(e,"zebraRows",t.zebraRows),n(e,"getRowClass",t.getRowClass),n(e,"getRowStyle",t.getRowStyle),n(e,"getRowPresentation",E(t.getRowPresentation)),n(e,"onCellClicked",t.onCellClicked),n(e,"onRowClicked",t.onRowClicked),n(e,"onCellDoubleClicked",t.onCellDoubleClicked),n(e,"onRowDoubleClicked",t.onRowDoubleClicked),n(e,"onCellValueChanged",t.onCellValueChanged),n(e,"onSelectionChanged",t.onSelectionChanged),n(e,"onSortChanged",t.onSortChanged),n(e,"onFilterChanged",t.onFilterChanged),n(e,"onQuickFilterFindChanged",t.onQuickFilterFindChanged),n(e,"onHistoryChanged",t.onHistoryChanged),n(e,"ariaLabel",t.ariaLabel),n(e,"ariaLabelledBy",t.ariaLabelledBy),n(e,"highlightActiveCell",t.highlightActiveCell),n(e,"rowSelection",t.rowSelection),n(e,"cellSelection",t.cellSelection),n(e,"rangeSelection",t.rangeSelection),n(e,"fillHandle",t.fillHandle),n(e,"columnSelection",t.columnSelection),n(e,"headerKeyboardNavigation",t.headerKeyboardNavigation),n(e,"showColumnButtonsOnHover",t.showColumnButtonsOnHover),n(e,"selectAllRowsOnHeaderClick",t.selectAllRowsOnHeaderClick),n(e,"selectAllScope",t.selectAllScope),n(e,"selectionPersistence",t.selectionPersistence),n(e,"clearSelectionOnBodyClick",t.clearSelectionOnBodyClick),n(e,"resetPageOn",t.resetPageOn),n(e,"pageSize",t.pageSize),n(e,"pageSizes",t.pageSizes),n(e,"serverSideBlockSize",t.serverSideBlockSize),n(e,"rowModelType",t.rowModelType),n(e,"getGroupChildCount",t.getGroupChildCount),n(e,"groupChildCount",t.groupChildCount),n(e,"paginationUnknownTotalTooltip",t.paginationUnknownTotalTooltip),n(e,"undoLimit",t.undoLimit),n(e,"editTrigger",t.editTrigger),n(e,"readOnlyEdit",t.readOnlyEdit),n(e,"initialSort",t.initialSort),n(e,"showSortPriority",t.showSortPriority),n(e,"pinnedRowsEditable",t.pinnedRowsEditable),n(e,"rowPinningMenu",t.rowPinningMenu),n(e,"rowInsertionMenu",t.rowInsertionMenu),n(e,"suppressKeyboardEdit",t.suppressKeyboardEdit),n(e,"suppressTypeToEdit",t.suppressTypeToEdit),n(e,"moveAfterEdit",t.moveAfterEdit),n(e,"commitOnBlur",t.commitOnBlur),n(e,"reevaluateOnEdit",t.reevaluateOnEdit),n(e,"groupDisplayType",t.groupDisplayType),n(e,"groupColumnDef",t.groupColumnDef),n(e,"groupDefaultExpanded",t.groupDefaultExpanded),n(e,"groupSortMode",t.groupSortMode),n(e,"treeData",t.treeData),n(e,"groupRowsSelectable",t.groupRowsSelectable),n(e,"isRowSelectable",t.isRowSelectable),n(e,"isRowPinned",t.isRowPinned),n(e,"groupRowsSticky",t.groupRowsSticky),n(e,"isFullWidthRow",t.isFullWidthRow),n(e,"tooltip",t.tooltip),n(e,"quickFilter",t.quickFilter),n(e,"columnPanel",t.columnPanel),n(e,"toolbar",t.toolbar),n(e,"savedViews",t.savedViews),n(e,"sheets",t.sheets),n(e,"loadingMessage",t.loadingMessage),n(e,"noRowsMessage",t.noRowsMessage),n(e,"pivotNoValuesMessage",t.pivotNoValuesMessage),n(e,"pivotEmptyMessage",t.pivotEmptyMessage),n(e,"filterDebounceMs",t.filterDebounceMs),n(e,"cellFlashDuration",t.cellFlashDuration),n(e,"cellFadeDuration",t.cellFadeDuration),n(e,"icons",t.icons),n(e,"theme",t.theme),t.fullWidthCellRenderer!=null&&(e.fullWidthCellRenderer=F(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=he(t.defaultColDef)),t.bodyContextMenu===!1&&(e.bodyContextMenu=!1),t.multiColumnMenu!=null&&(e.multiColumnMenu=t.multiColumnMenu),t.rowModelType==="serverSide"&&(n(e,"serverSideDataSource",t.serverSideDataSource),n(e,"serverSideAggregationSource",t.serverSideAggregationSource)),n(e,"suppressStyleInjection",t.suppressStyleInjection),n(e,"styleNonce",t.styleNonce),e}var Se=R(require("react"),1);var T=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let a=[],r=o,s=this.opts.getBodyMenuItems?this.opts.getBodyMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(s,a),cleanup:()=>{for(let C of a)C()}}}normalizeItems(e,o){return e.map(a=>{if(a.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(a.left,o),s=this.normalizeSlot(a.right,o);return{...a,left:r,right:s,subMenu:a.subMenu?this.normalizeItems(a.subMenu,o):void 0}})}normalizeSlot(e,o){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(Se.default.isValidElement(e)){let{el:a,unmount:r}=this.mountReact(e);return o.push(r),a}}}mountReact(e){let o=document.createElement("span");o.style.display="inline-flex",o.style.alignItems="center";let a=new d(o);return a.render(e),{el:o,unmount:()=>a.destroy()}}};var we=R(require("react"),1);var I=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let a=[],r=o,s=this.opts.getColumnMenuItems?this.opts.getColumnMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(s,a),cleanup:()=>{for(let C of a)C()}}}normalizeItems(e,o){return e.map(a=>{if(a.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(a.left,o),s=this.normalizeSlot(a.right,o);return{...a,left:r,right:s,subMenu:a.subMenu?this.normalizeItems(a.subMenu,o):void 0}})}normalizeSlot(e,o){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(we.default.isValidElement(e)){let{el:a,unmount:r}=this.mountReact(e);return o.push(r),a}}}mountReact(e){let o=document.createElement("span");o.style.display="inline-flex",o.style.alignItems="center";let a=new d(o);return a.render(e),{el:o,unmount:()=>a.destroy()}}};var pe=require("react/jsx-runtime");function m(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function Ye(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var ve=i.default.forwardRef(function(e,o){let a=(0,i.useRef)(null),r=(0,i.useRef)(null),s=(0,i.useRef)(e.onGridReady),y=(0,i.useRef)(e.getColumnMenuItems),C=(0,i.useRef)(e.bodyContextMenu),V=(0,i.useRef)(e.multiColumnMenu),N=(0,i.useRef)(e.onCellClicked),L=(0,i.useRef)(e.onRowClicked),z=(0,i.useRef)(e.onCellDoubleClicked),K=(0,i.useRef)(e.onRowDoubleClicked),W=(0,i.useRef)(e.onCellValueChanged),j=(0,i.useRef)(e.onSelectionChanged),q=(0,i.useRef)(e.onSortChanged),U=(0,i.useRef)(e.onFilterChanged),J=(0,i.useRef)(e.onQuickFilterFindChanged),Q=(0,i.useRef)(e.onHistoryChanged),_=(0,i.useRef)(e.onBeforeCellCommit),Y=(0,i.useRef)(e.fillOperation);s.current=e.onGridReady,y.current=e.getColumnMenuItems,C.current=e.bodyContextMenu,V.current=e.multiColumnMenu,N.current=e.onCellClicked,L.current=e.onRowClicked,z.current=e.onCellDoubleClicked,K.current=e.onRowDoubleClicked,W.current=e.onCellValueChanged,j.current=e.onSelectionChanged,q.current=e.onSortChanged,U.current=e.onFilterChanged,J.current=e.onQuickFilterFindChanged,Q.current=e.onHistoryChanged,_.current=e.onBeforeCellCommit,Y.current=e.fillOperation,(0,i.useLayoutEffect)(()=>{let u=a.current;if(!u)return;let c=ye(e);c.onCellClicked=l=>N.current?.(l),c.onRowClicked=l=>L.current?.(l),c.onCellDoubleClicked=l=>z.current?.(l),c.onRowDoubleClicked=l=>K.current?.(l),c.onCellValueChanged=l=>W.current?.(l),c.onSelectionChanged=l=>j.current?.(l),c.onSortChanged=l=>q.current?.(l),c.onFilterChanged=l=>U.current?.(l),c.onQuickFilterFindChanged=l=>J.current?.(l),c.onHistoryChanged=l=>Q.current?.(l),c.onBeforeCellCommit=l=>_.current?.(l),c.fillOperation=l=>Y.current?.(l),e.multiColumnMenu!==!1&&(c.multiColumnMenu=l=>{let f=V.current;return f===!1?[]:typeof f!="function"?l.items:f(l)});let A=(0,Me.createGrid)(u,{...c,menuAdapter:new I({getColumnMenuItems:l=>y.current?.(l)??l.items}),bodyMenuAdapter:new T({getBodyMenuItems:l=>{let f=C.current;return typeof f=="function"?f(l):l.items}})}),G={api:A,destroyed:!1,appliedServerSideDataSource:c.serverSideDataSource};return r.current=G,m(o,A),m(e.apiRef,A),()=>{r.current===G&&(r.current=null),m(o,null),m(e.apiRef,null),Ye(G)}},[]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api??null;return m(o,u),m(e.apiRef,u),()=>{m(o,null),m(e.apiRef,null)}},[o,e.apiRef]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api;u&&u.updateGridOptions({columnDefs:B(e.columnDefs)})},[e.columnDefs]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api;u&&e.rowModelType!=="serverSide"&&u.setRowData(e.rowData??e.data??[])},[e.data,e.rowData,e.rowModelType]);let D=(0,i.useRef)(null);(0,i.useLayoutEffect)(()=>{let u=r.current;if(!(!u||D.current===u))return D.current=u,s.current?.(u.api),()=>{D.current=null}},[]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupDisplayType:e.groupDisplayType})},[e.groupDisplayType]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupSortMode:e.groupSortMode})},[e.groupSortMode]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupRowsSelectable:e.groupRowsSelectable})},[e.groupRowsSelectable]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupChildCount:e.groupChildCount})},[e.groupChildCount]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({headerHeight:e.headerHeight,leafHeaderHeight:e.leafHeaderHeight,parentHeaderHeight:e.parentHeaderHeight})},[e.headerHeight,e.leafHeaderHeight,e.parentHeaderHeight]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({pivotColumnMoveMode:e.pivotColumnMoveMode})},[e.pivotColumnMoveMode]);let X=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!X.current){X.current=!0;return}e.pivotMode!=null&&r.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let Pe=JSON.stringify(e.pivotColumns??null),Z=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!Z.current){Z.current=!0;return}e.pivotColumns!=null&&r.current?.api.setPivotColumns(e.pivotColumns)},[Pe]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let Fe=JSON.stringify(e.rowSelection??null),$=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!$.current){$.current=!0;return}r.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[Fe]),(0,i.useLayoutEffect)(()=>{r.current?.api.setTreeDataKeyboardNavigationOptions({keyboardNavigationMode:e.treeData?.keyboardNavigationMode,enableKeyboardNavigationModeSwitch:e.treeData?.enableKeyboardNavigationModeSwitch??!1})},[e.treeData?.keyboardNavigationMode,e.treeData?.enableKeyboardNavigationModeSwitch]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({pinnedTopRowData:e.pinnedTopRowData,pinnedBottomRowData:e.pinnedBottomRowData,isRowPinned:e.isRowPinned,groupRowsSticky:e.groupRowsSticky})},[e.pinnedTopRowData,e.pinnedBottomRowData,e.isRowPinned,e.groupRowsSticky]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({rowHover:e.rowHover??!0,columnHover:e.columnHover??!1,zebraRows:e.zebraRows??!1,getRowClass:e.getRowClass,getRowStyle:e.getRowStyle,getRowPresentation:E(e.getRowPresentation),ariaLabel:e.ariaLabel,ariaLabelledBy:e.ariaLabelledBy,highlightActiveCell:e.highlightActiveCell??!1,cellSelection:e.cellSelection??!0,rangeSelection:e.rangeSelection??!0,fillHandle:e.fillHandle??!0,columnSelection:e.columnSelection??!0,headerKeyboardNavigation:e.headerKeyboardNavigation??!0,showColumnButtonsOnHover:e.showColumnButtonsOnHover??!1,bodyContextMenu:e.bodyContextMenu!==!1,editTrigger:e.editTrigger??"doubleClick",readOnlyEdit:e.readOnlyEdit??!1,pinnedRowsEditable:e.pinnedRowsEditable??!1,rowPinningMenu:e.rowPinningMenu??!1,rowInsertionMenu:e.rowInsertionMenu,suppressKeyboardEdit:e.suppressKeyboardEdit??!1,suppressTypeToEdit:e.suppressTypeToEdit??!1,moveAfterEdit:e.moveAfterEdit??!0,commitOnBlur:e.commitOnBlur??!0,asyncTransactionWaitMs:e.asyncTransactionWaitMs??16,loadingMessage:e.loadingMessage,noRowsMessage:e.noRowsMessage})},[e.rowHover,e.columnHover,e.zebraRows,e.getRowClass,e.getRowStyle,e.getRowPresentation,e.ariaLabel,e.ariaLabelledBy,e.highlightActiveCell,e.cellSelection,e.rangeSelection,e.fillHandle,e.columnSelection,e.headerKeyboardNavigation,e.showColumnButtonsOnHover,e.bodyContextMenu,e.editTrigger,e.readOnlyEdit,e.pinnedRowsEditable,e.rowPinningMenu,e.rowInsertionMenu,e.suppressKeyboardEdit,e.suppressTypeToEdit,e.moveAfterEdit,e.commitOnBlur,e.asyncTransactionWaitMs,e.loadingMessage,e.noRowsMessage]),(0,i.useLayoutEffect)(()=>{let u=r.current;!u||e.rowModelType!=="serverSide"||e.serverSideDataSource&&e.serverSideDataSource!==u.appliedServerSideDataSource&&(u.appliedServerSideDataSource=e.serverSideDataSource,u.api.updateGridOptions({serverSideDataSource:e.serverSideDataSource}))},[e.rowModelType,e.serverSideDataSource]),(0,i.useLayoutEffect)(()=>{let u=r.current;!u||e.rowModelType!=="serverSide"||e.serverSideAggregationSource&&u.api.updateGridOptions({serverSideAggregationSource:e.serverSideAggregationSource})},[e.rowModelType,e.serverSideAggregationSource]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api;u&&u.dispatch({type:"overlayShow",overlayType:e.loading?"loading":"none"})},[e.loading]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({pagination:e.pagination})},[e.pagination]);let be=JSON.stringify(e.paginationControls??null),ee=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ee.current){ee.current=!0;return}r.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[be]);let Ee=JSON.stringify(e.quickFilter??null),te=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!te.current){te.current=!0;return}r.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[Ee]);let Te=JSON.stringify(e.tooltip??null),ne=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ne.current){ne.current=!0;return}r.current?.api.updateGridOptions({tooltip:e.tooltip})},[Te]);let Ie=JSON.stringify(e.columnPanel??null),oe=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!oe.current){oe.current=!0;return}r.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[Ie]);let De=JSON.stringify(e.toolbar??null),ie=(0,i.useRef)(!1);return(0,i.useLayoutEffect)(()=>{if(!ie.current){ie.current=!0;return}r.current?.api.updateGridOptions({toolbar:e.toolbar})},[De]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({savedViews:e.savedViews})},[e.savedViews]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({sheets:e.sheets})},[e.sheets]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({theme:e.theme,icons:{...e.theme?.getIcons(),...e.icons}})},[e.theme,e.icons]),(0,pe.jsx)("div",{ref:a,className:e.className,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...e.style}})});0&&(module.exports={Grid,...require("@agility-workbench/grid")});
1
+ "use strict";var _e=Object.create;var S=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var Ye=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},w=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of qe(e))!Qe.call(t,r)&&r!==n&&S(t,r,{get:()=>e[r],enumerable:!(a=Ue(e,r))||a.enumerable});return t},M=(t,e,n)=>(w(t,e,"default"),n&&w(n,e,"default")),h=(t,e,n)=>(n=t!=null?_e(Je(t)):{},w(e||!t||!t.__esModule?S(n,"default",{value:t,enumerable:!0}):n,t)),$e=t=>w(S({},"__esModule",{value:!0}),t);var p={};Ye(p,{Grid:()=>Ge});module.exports=$e(p);M(p,require("@agility-workbench/grid"),module.exports);var i=h(require("react"),1),Ie=require("@agility-workbench/grid");var m=h(require("react"),1);var ce=require("react-dom"),se=require("react-dom/client"),x=new Set,I=!1;function Xe(){I=!1;let t=Array.from(x);x.clear();for(let e of t)e.unmount()}function Ze(t){x.add(t),!I&&(I=!0,queueMicrotask(Xe))}var s=class{root;constructor(e){this.root=(0,se.createRoot)(e)}render(e){this.root?.render(e)}renderSync(e){let n=this.root;n&&(0,ce.flushSync)(()=>n.render(e))}destroy(){let e=this.root;e&&(this.root=null,Ze(e))}};var E=require("@agility-workbench/grid"),ye=require("@agility-workbench/grid"),pe=require("@agility-workbench/grid"),we=require("@agility-workbench/grid");var G=h(require("react"),1);var me=new WeakMap;function et(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function tt(t){return class{el=document.createElement("div");root=null;handle=G.default.createRef();init(n){this.el.style.width="100%",this.el.style.height="100%",this.root=new s(this.el);let a=G.default.createElement(t,{...n,ref:this.handle});this.root.renderSync(a)}getGui(){return this.el}getValue(){return this.handle.current?.getValue()}isParsed(){return this.handle.current?.isParsed?.()??!1}focus(){this.handle.current?.focus?.()}isCancelBeforeStart(){return this.handle.current?.isCancelBeforeStart?.()??!1}destroy(){let n=this.root;this.root=null,n?.destroy()}}}function N(t){if(t==null)return;if(typeof t=="string"||et(t))return t;let e=me.get(t);if(e)return e;let n=tt(t);return me.set(t,n),n}var Ce=new WeakMap,fe=new WeakMap,Re=new WeakMap,ge=new WeakMap,he=new WeakMap;function y(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function nt(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function ot(t){return class{el=document.createElement("span");root=null;init(n){this.el.style.display="inline-flex",this.el.style.alignItems="center",this.el.style.width="100%",this.el.style.height="100%",this.el.style.overflow="hidden",this.root=new s(this.el),this.render(n)}getGui(){return this.el}refresh(n){return this.render(n),!0}destroy(){this.root?.destroy(),this.root=null}render(n){this.root?.render(m.default.createElement(t,nt(n)))}}}function T(t){if(!t)return;if(typeof t=="function"&&(0,E.isClassRenderer)(t)||!y(t))return t;let e=Ce.get(t);if(e)return e;let n=ot(t);return Ce.set(t,n),n}function rt(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function it(t){return class{el=document.createElement("div");root=null;init(n){this.root=new s(this.el),this.render(n)}getGui(){return this.el}refresh(n){return this.render(n),!0}destroy(){this.root?.destroy(),this.root=null}render(n){this.root?.renderSync(m.default.createElement(t,rt(n)))}}}function b(t){if(!t)return;if(typeof t=="function"&&(0,ye.isClassTooltipComponent)(t)||!y(t))return t;let e=fe.get(t);if(e)return e;let n=it(t);return fe.set(t,n),n}function F(t){if(t)return e=>{let n=t(e);return!n||typeof n.tooltip!="object"||n.tooltip==null?n:{...n,tooltip:{...n.tooltip,component:b(n.tooltip.component)}}}}function Se(t){return t==null||typeof t=="string"?t:b(t)}function at(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function lt(t){return class{el=document.createElement("div");root=null;init(n){this.root=new s(this.el),this.render(n)}getGui(){return this.el}refresh(n){return this.render(n),!0}destroy(){this.root?.destroy(),this.root=null}render(n){this.root?.render(m.default.createElement(t,at(n)))}}}function Me(t){if(!t)return;if(typeof t=="function"&&(0,pe.isClassActionFrameComponent)(t)||!y(t))return t;let e=Re.get(t);if(e)return e;let n=lt(t);return Re.set(t,n),n}function ut({node:t}){let e=m.default.useRef(null);return m.default.useLayoutEffect(()=>{let n=e.current;n&&n.firstChild!==t&&n.replaceChildren(t)},[t]),m.default.createElement("span",{ref:e,style:{display:"contents"}})}function dt(t){if(!(typeof t=="function"&&!t.prototype?.isReactComponent))return r=>m.default.createElement(t,r);let n=t;function a(r){let c=n(r);return c instanceof HTMLElement?m.default.createElement(ut,{node:c}):c}return r=>m.default.createElement(a,r)}function ct(t){let e=dt(t);return class{el=document.createElement("div");root=null;init(a){this.el.className="pte-hcell-custom-root",this.el.style.display="flex",this.el.style.alignItems="center",this.el.style.width="100%",this.el.style.height="100%",this.el.style.overflow="hidden",this.root=new s(this.el),this.render(a)}getGui(){return this.el}refresh(a){return this.render(a),!0}destroy(){this.root?.destroy(),this.root=null}render(a){this.root?.render(e(a))}}}function P(t){if(!t)return;if(typeof t=="function"&&(0,we.isClassHeaderComponent)(t)||!y(t))return t;let e=he.get(t);if(e)return e;let n=ct(t);return he.set(t,n),n}function st(t){return class{el=document.createElement("span");root=null;init(n){this.root=new s(this.el),this.render(n)}getGui(){return this.el}refresh(n){return this.render(n),!0}destroy(){this.root?.destroy(),this.root=null}render(n){this.root?.render(m.default.createElement(t,n))}}}function v(t){if(!t)return;if(typeof t=="function"&&(0,E.isClassSetFilterComponent)(t)||!y(t))return t;let e=ge.get(t);if(e)return e;let n=st(t);return ge.set(t,n),n}function ve(t){if(t)return{...t,valueComponent:v(t.valueComponent),selectAllComponent:v(t.selectAllComponent),blanksComponent:v(t.blanksComponent),groupComponent:v(t.groupComponent)}}function mt(t){return{...t,cellRenderer:T(t.cellRenderer),cellEditor:N(t.cellEditor),tooltipComponent:b(t.tooltipComponent),headerTooltip:Se(t.headerTooltip),actionFrameComponent:Me(t.actionFrameComponent),filterParams:ve(t.filterParams),headerComponent:P(t.headerComponent),headerCellComponent:P(t.headerCellComponent),children:t.children?B(t.children)??void 0:void 0}}function B(t){return t==null?t:t.map(e=>mt(e))}function Pe(t){let e={...t};return"cellRenderer"in t&&(e.cellRenderer=T(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=N(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=b(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=Se(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=Me(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=ve(t.filterParams)),"headerComponent"in t&&(e.headerComponent=P(t.headerComponent)),"headerCellComponent"in t&&(e.headerCellComponent=P(t.headerCellComponent)),e}function Ee(t){if(t!=null)return Pe(t)}function L(t){if(t!=null)return Pe(t)}function o(t,e,n){n!=null&&(t[e]=n)}function Te(t){let e={};return o(e,"headerHeight",t.headerHeight),o(e,"leafHeaderHeight",t.leafHeaderHeight),o(e,"parentHeaderHeight",t.parentHeaderHeight),o(e,"rowHeight",t.rowHeight),o(e,"pinnedTopRowData",t.pinnedTopRowData),o(e,"pinnedBottomRowData",t.pinnedBottomRowData),o(e,"getRowId",t.getRowId),o(e,"rowIdKey",t.rowIdKey),o(e,"rowDataMode",t.rowDataMode),o(e,"asyncTransactionWaitMs",t.asyncTransactionWaitMs),o(e,"overscanRowCount",t.overscanRowCount),o(e,"minResizeWidth",t.minResizeWidth),o(e,"maxColumnWidth",t.maxColumnWidth),o(e,"pivotMode",t.pivotMode),o(e,"pivotColumns",t.pivotColumns),o(e,"maxPivotColumns",t.maxPivotColumns),o(e,"pivotColumnMoveMode",t.pivotColumnMoveMode),o(e,"autosizeColumnsOnDataChange",t.autosizeColumnsOnDataChange),o(e,"allowExportAsCSV",t.allowExportAsCSV),o(e,"allowExportAsExcel",t.allowExportAsExcel),o(e,"pagination",t.pagination),o(e,"paginationControls",t.paginationControls),o(e,"rowNumbers",t.rowNumbers),o(e,"rowHover",t.rowHover),o(e,"columnHover",t.columnHover),o(e,"zebraRows",t.zebraRows),o(e,"getRowClass",t.getRowClass),o(e,"getRowStyle",t.getRowStyle),o(e,"getRowPresentation",F(t.getRowPresentation)),o(e,"onCellClicked",t.onCellClicked),o(e,"onRowClicked",t.onRowClicked),o(e,"onCellDoubleClicked",t.onCellDoubleClicked),o(e,"onRowDoubleClicked",t.onRowDoubleClicked),o(e,"onCellValueChanged",t.onCellValueChanged),o(e,"onSelectionChanged",t.onSelectionChanged),o(e,"onSortChanged",t.onSortChanged),o(e,"onColumnsChanged",t.onColumnsChanged),o(e,"onPaginationChanged",t.onPaginationChanged),o(e,"onError",t.onError),o(e,"onFilterChanged",t.onFilterChanged),o(e,"onQuickFilterFindChanged",t.onQuickFilterFindChanged),o(e,"onHistoryChanged",t.onHistoryChanged),o(e,"ariaLabel",t.ariaLabel),o(e,"ariaLabelledBy",t.ariaLabelledBy),o(e,"highlightActiveCell",t.highlightActiveCell),o(e,"rowSelection",t.rowSelection),o(e,"cellSelection",t.cellSelection),o(e,"rangeSelection",t.rangeSelection),o(e,"fillHandle",t.fillHandle),o(e,"columnSelection",t.columnSelection),o(e,"headerKeyboardNavigation",t.headerKeyboardNavigation),o(e,"showColumnButtonsOnHover",t.showColumnButtonsOnHover),o(e,"selectAllRowsOnHeaderClick",t.selectAllRowsOnHeaderClick),o(e,"selectAllScope",t.selectAllScope),o(e,"selectionPersistence",t.selectionPersistence),o(e,"clearSelectionOnBodyClick",t.clearSelectionOnBodyClick),o(e,"resetPageOn",t.resetPageOn),o(e,"pageSize",t.pageSize),o(e,"pageSizes",t.pageSizes),o(e,"serverSideBlockSize",t.serverSideBlockSize),o(e,"serverSideMaxBlocks",t.serverSideMaxBlocks),o(e,"rowModelType",t.rowModelType),o(e,"getGroupChildCount",t.getGroupChildCount),o(e,"groupChildCount",t.groupChildCount),o(e,"groupTotalRow",t.groupTotalRow),o(e,"grandTotalRow",t.grandTotalRow),o(e,"groupTotalRowLabel",t.groupTotalRowLabel),o(e,"paginationUnknownTotalTooltip",t.paginationUnknownTotalTooltip),o(e,"undoLimit",t.undoLimit),o(e,"editTrigger",t.editTrigger),o(e,"readOnlyEdit",t.readOnlyEdit),o(e,"initialSort",t.initialSort),o(e,"showSortPriority",t.showSortPriority),o(e,"pinnedRowsEditable",t.pinnedRowsEditable),o(e,"rowPinningMenu",t.rowPinningMenu),o(e,"rowInsertionMenu",t.rowInsertionMenu),o(e,"suppressKeyboardEdit",t.suppressKeyboardEdit),o(e,"suppressTypeToEdit",t.suppressTypeToEdit),o(e,"moveAfterEdit",t.moveAfterEdit),o(e,"commitOnBlur",t.commitOnBlur),o(e,"reevaluateOnEdit",t.reevaluateOnEdit),o(e,"groupDisplayType",t.groupDisplayType),o(e,"groupDefaultExpanded",t.groupDefaultExpanded),o(e,"groupSortMode",t.groupSortMode),o(e,"treeData",t.treeData),o(e,"groupRowsSelectable",t.groupRowsSelectable),o(e,"groupSelectsChildren",t.groupSelectsChildren),o(e,"aggFuncs",t.aggFuncs),o(e,"isRowSelectable",t.isRowSelectable),o(e,"isRowPinned",t.isRowPinned),o(e,"groupRowsSticky",t.groupRowsSticky),o(e,"isFullWidthRow",t.isFullWidthRow),o(e,"tooltip",t.tooltip),o(e,"quickFilter",t.quickFilter),o(e,"columnPanel",t.columnPanel),o(e,"toolbar",t.toolbar),o(e,"savedViews",t.savedViews),o(e,"sheets",t.sheets),o(e,"loadingMessage",t.loadingMessage),o(e,"noRowsMessage",t.noRowsMessage),o(e,"pivotNoValuesMessage",t.pivotNoValuesMessage),o(e,"pivotEmptyMessage",t.pivotEmptyMessage),o(e,"filterDebounceMs",t.filterDebounceMs),o(e,"cellFlashDuration",t.cellFlashDuration),o(e,"cellFadeDuration",t.cellFadeDuration),o(e,"icons",t.icons),o(e,"theme",t.theme),t.fullWidthCellRenderer!=null&&(e.fullWidthCellRenderer=T(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=Ee(t.defaultColDef)),t.groupColumnDef!=null&&(e.groupColumnDef=L(t.groupColumnDef)),t.pivotResultColumnDef!=null&&(e.pivotResultColumnDef=L(t.pivotResultColumnDef)),t.bodyContextMenu===!1&&(e.bodyContextMenu=!1),t.multiColumnMenu!=null&&(e.multiColumnMenu=t.multiColumnMenu),t.rowModelType==="serverSide"&&(o(e,"serverSideDataSource",t.serverSideDataSource),o(e,"serverSideAggregationSource",t.serverSideAggregationSource)),o(e,"suppressStyleInjection",t.suppressStyleInjection),o(e,"styleNonce",t.styleNonce),e}var be=h(require("react"),1);var D=class{constructor(e){this.opts=e}resolveMenuItems(e,n){let a=[],r=n,c=this.opts.getBodyMenuItems?this.opts.getBodyMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(c,a),cleanup:()=>{for(let R of a)R()}}}normalizeItems(e,n){return e.map(a=>{if(a.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(a.left,n),c=this.normalizeSlot(a.right,n);return{...a,left:r,right:c,subMenu:a.subMenu?this.normalizeItems(a.subMenu,n):void 0}})}normalizeSlot(e,n){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(be.default.isValidElement(e)){let{el:a,unmount:r}=this.mountReact(e);return n.push(r),a}}}mountReact(e){let n=document.createElement("span");n.style.display="inline-flex",n.style.alignItems="center";let a=new s(n);return a.render(e),{el:n,unmount:()=>a.destroy()}}};var Fe=h(require("react"),1);var H=class{constructor(e){this.opts=e}resolveMenuItems(e,n){let a=[],r=n,c=this.opts.getColumnMenuItems?this.opts.getColumnMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(c,a),cleanup:()=>{for(let R of a)R()}}}normalizeItems(e,n){return e.map(a=>{if(a.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(a.left,n),c=this.normalizeSlot(a.right,n);return{...a,left:r,right:c,subMenu:a.subMenu?this.normalizeItems(a.subMenu,n):void 0}})}normalizeSlot(e,n){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(Fe.default.isValidElement(e)){let{el:a,unmount:r}=this.mountReact(e);return n.push(r),a}}}mountReact(e){let n=document.createElement("span");n.style.display="inline-flex",n.style.alignItems="center";let a=new s(n);return a.render(e),{el:n,unmount:()=>a.destroy()}}};var De=require("@agility-workbench/grid"),Ct=new Set(["onCellClicked","onRowClicked","onCellDoubleClicked","onRowDoubleClicked","onCellValueChanged","onSelectionChanged","onSortChanged","onColumnsChanged","onPaginationChanged","onError","onFilterChanged","onQuickFilterFindChanged","onHistoryChanged","onBeforeCellCommit","fillOperation","multiColumnMenu"]),ft=De.CREATION_ONLY_OPTION_KEYS.filter(t=>!Ct.has(t)),Rt=["keyboardNavigationMode","enableKeyboardNavigationModeSwitch"],He=Symbol("uncomparable");function Oe(t,e){let n=e;if(t==="treeData"&&e!=null&&typeof e=="object"){let a={...e};for(let r of Rt)delete a[r];n=a}try{return JSON.stringify(n,(a,r)=>typeof r=="function"?`\u0192 ${String(r)}`:r===void 0?"\u2205undefined":r)??"\u2205undefined"}catch{return He}}function ke(t){let e=new Map;for(let n of ft){let a=t[n];e.set(n,{value:a,fingerprint:Oe(n,a)})}return e}function Ae(){try{return process.env.NODE_ENV!=="production"}catch{return!0}}function gt(t){return`[agility-workbench] <Grid> prop "${t}" changed after the grid was created. It is read only at creation, so the change is ignored. Remount the grid to apply it (for example, change the <Grid>'s React key).`}function xe(t,e,n){for(let[a,r]of e){if(n.has(a))continue;let c=t[a];if(Object.is(c,r.value))continue;let f=Oe(a,c);f!==He&&f===r.fingerprint||(n.add(a),console.warn(gt(a)))}}var Ne=require("react/jsx-runtime");function C(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function ht(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var Ge=i.default.forwardRef(function(e,n){let a=(0,i.useRef)(null),r=(0,i.useRef)(null),c=(0,i.useRef)(e.onGridReady),f=(0,i.useRef)(e.getColumnMenuItems),R=(0,i.useRef)(e.bodyContextMenu),V=(0,i.useRef)(e.multiColumnMenu),K=(0,i.useRef)(e.onCellClicked),z=(0,i.useRef)(e.onRowClicked),W=(0,i.useRef)(e.onCellDoubleClicked),j=(0,i.useRef)(e.onRowDoubleClicked),_=(0,i.useRef)(e.onCellValueChanged),U=(0,i.useRef)(e.onSelectionChanged),q=(0,i.useRef)(e.onSortChanged),J=(0,i.useRef)(e.onColumnsChanged),Q=(0,i.useRef)(e.onPaginationChanged),Y=(0,i.useRef)(e.onError),$=(0,i.useRef)(e.onFilterChanged),X=(0,i.useRef)(e.onQuickFilterFindChanged),Z=(0,i.useRef)(e.onHistoryChanged),ee=(0,i.useRef)(e.onBeforeCellCommit),te=(0,i.useRef)(e.fillOperation);c.current=e.onGridReady,f.current=e.getColumnMenuItems,R.current=e.bodyContextMenu,V.current=e.multiColumnMenu,K.current=e.onCellClicked,z.current=e.onRowClicked,W.current=e.onCellDoubleClicked,j.current=e.onRowDoubleClicked,_.current=e.onCellValueChanged,U.current=e.onSelectionChanged,q.current=e.onSortChanged,J.current=e.onColumnsChanged,Q.current=e.onPaginationChanged,Y.current=e.onError,$.current=e.onFilterChanged,X.current=e.onQuickFilterFindChanged,Z.current=e.onHistoryChanged,ee.current=e.onBeforeCellCommit,te.current=e.fillOperation,(0,i.useLayoutEffect)(()=>{let u=a.current;if(!u)return;let d=Te(e);d.onCellClicked=l=>K.current?.(l),d.onRowClicked=l=>z.current?.(l),d.onCellDoubleClicked=l=>W.current?.(l),d.onRowDoubleClicked=l=>j.current?.(l),d.onCellValueChanged=l=>_.current?.(l),d.onSelectionChanged=l=>U.current?.(l),d.onSortChanged=l=>q.current?.(l),d.onColumnsChanged=l=>J.current?.(l),d.onPaginationChanged=l=>Q.current?.(l),d.onError=l=>Y.current?.(l),d.onFilterChanged=l=>$.current?.(l),d.onQuickFilterFindChanged=l=>X.current?.(l),d.onHistoryChanged=l=>Z.current?.(l),d.onBeforeCellCommit=l=>ee.current?.(l),d.fillOperation=l=>te.current?.(l),e.multiColumnMenu!==!1&&(d.multiColumnMenu=l=>{let g=V.current;return g===!1?[]:typeof g!="function"?l.items:g(l)});let k=(0,Ie.createGrid)(u,{...d,menuAdapter:new H({getColumnMenuItems:l=>f.current?.(l)??l.items}),bodyMenuAdapter:new D({getBodyMenuItems:l=>{let g=R.current;return typeof g=="function"?g(l):l.items}})}),A={api:k,destroyed:!1,appliedServerSideDataSource:d.serverSideDataSource,creationOnly:Ae()?{snapshot:ke(e),warned:new Set}:null};return r.current=A,C(n,k),C(e.apiRef,k),()=>{r.current===A&&(r.current=null),C(n,null),C(e.apiRef,null),ht(A)}},[]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api??null;return C(n,u),C(e.apiRef,u),()=>{C(n,null),C(e.apiRef,null)}},[n,e.apiRef]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api;u&&u.updateGridOptions({columnDefs:B(e.columnDefs)})},[e.columnDefs]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api;u&&e.rowModelType!=="serverSide"&&u.setRowData(e.rowData??e.data??[])},[e.data,e.rowData,e.rowModelType]);let O=(0,i.useRef)(null);(0,i.useLayoutEffect)(()=>{let u=r.current;if(!(!u||O.current===u))return O.current=u,c.current?.(u.api),()=>{O.current=null}},[]),(0,i.useLayoutEffect)(()=>{let u=r.current?.creationOnly;u&&xe(e,u.snapshot,u.warned)}),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupDisplayType:e.groupDisplayType})},[e.groupDisplayType]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupSortMode:e.groupSortMode})},[e.groupSortMode]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupRowsSelectable:e.groupRowsSelectable})},[e.groupRowsSelectable]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupChildCount:e.groupChildCount})},[e.groupChildCount]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupTotalRow:e.groupTotalRow,grandTotalRow:e.grandTotalRow})},[e.groupTotalRow,e.grandTotalRow]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({groupTotalRowLabel:e.groupTotalRowLabel})},[e.groupTotalRowLabel]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({headerHeight:e.headerHeight,leafHeaderHeight:e.leafHeaderHeight,parentHeaderHeight:e.parentHeaderHeight})},[e.headerHeight,e.leafHeaderHeight,e.parentHeaderHeight]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({pivotColumnMoveMode:e.pivotColumnMoveMode})},[e.pivotColumnMoveMode]);let ne=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ne.current){ne.current=!0;return}e.pivotMode!=null&&r.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let Be=JSON.stringify(e.pivotColumns??null),oe=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!oe.current){oe.current=!0;return}e.pivotColumns!=null&&r.current?.api.setPivotColumns(e.pivotColumns)},[Be]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let Le=JSON.stringify(e.rowSelection??null),re=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!re.current){re.current=!0;return}r.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[Le]),(0,i.useLayoutEffect)(()=>{r.current?.api.setTreeDataKeyboardNavigationOptions({keyboardNavigationMode:e.treeData?.keyboardNavigationMode,enableKeyboardNavigationModeSwitch:e.treeData?.enableKeyboardNavigationModeSwitch??!1})},[e.treeData?.keyboardNavigationMode,e.treeData?.enableKeyboardNavigationModeSwitch]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({pinnedTopRowData:e.pinnedTopRowData,pinnedBottomRowData:e.pinnedBottomRowData,isRowPinned:e.isRowPinned,groupRowsSticky:e.groupRowsSticky})},[e.pinnedTopRowData,e.pinnedBottomRowData,e.isRowPinned,e.groupRowsSticky]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({rowHover:e.rowHover??!0,columnHover:e.columnHover??!1,zebraRows:e.zebraRows??!1,getRowClass:e.getRowClass,getRowStyle:e.getRowStyle,getRowPresentation:F(e.getRowPresentation),ariaLabel:e.ariaLabel,ariaLabelledBy:e.ariaLabelledBy,highlightActiveCell:e.highlightActiveCell??!1,cellSelection:e.cellSelection??!0,rangeSelection:e.rangeSelection??!0,fillHandle:e.fillHandle??!0,columnSelection:e.columnSelection??!0,headerKeyboardNavigation:e.headerKeyboardNavigation??!0,showColumnButtonsOnHover:e.showColumnButtonsOnHover??!1,bodyContextMenu:e.bodyContextMenu!==!1,editTrigger:e.editTrigger??"doubleClick",readOnlyEdit:e.readOnlyEdit??!1,pinnedRowsEditable:e.pinnedRowsEditable??!1,rowPinningMenu:e.rowPinningMenu??!1,rowInsertionMenu:e.rowInsertionMenu,suppressKeyboardEdit:e.suppressKeyboardEdit??!1,suppressTypeToEdit:e.suppressTypeToEdit??!1,moveAfterEdit:e.moveAfterEdit??!0,commitOnBlur:e.commitOnBlur??!0,asyncTransactionWaitMs:e.asyncTransactionWaitMs??16,loadingMessage:e.loadingMessage,noRowsMessage:e.noRowsMessage})},[e.rowHover,e.columnHover,e.zebraRows,e.getRowClass,e.getRowStyle,e.getRowPresentation,e.ariaLabel,e.ariaLabelledBy,e.highlightActiveCell,e.cellSelection,e.rangeSelection,e.fillHandle,e.columnSelection,e.headerKeyboardNavigation,e.showColumnButtonsOnHover,e.bodyContextMenu,e.editTrigger,e.readOnlyEdit,e.pinnedRowsEditable,e.rowPinningMenu,e.rowInsertionMenu,e.suppressKeyboardEdit,e.suppressTypeToEdit,e.moveAfterEdit,e.commitOnBlur,e.asyncTransactionWaitMs,e.loadingMessage,e.noRowsMessage]),(0,i.useLayoutEffect)(()=>{let u=r.current;!u||e.rowModelType!=="serverSide"||e.serverSideDataSource&&e.serverSideDataSource!==u.appliedServerSideDataSource&&(u.appliedServerSideDataSource=e.serverSideDataSource,u.api.updateGridOptions({serverSideDataSource:e.serverSideDataSource}))},[e.rowModelType,e.serverSideDataSource]),(0,i.useLayoutEffect)(()=>{let u=r.current;!u||e.rowModelType!=="serverSide"||e.serverSideAggregationSource&&u.api.updateGridOptions({serverSideAggregationSource:e.serverSideAggregationSource})},[e.rowModelType,e.serverSideAggregationSource]),(0,i.useLayoutEffect)(()=>{let u=r.current?.api;u&&u.dispatch({type:"overlayShow",overlayType:e.loading?"loading":"none"})},[e.loading]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({pagination:e.pagination})},[e.pagination]);let Ve=JSON.stringify(e.paginationControls??null),ie=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ie.current){ie.current=!0;return}r.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[Ve]);let Ke=JSON.stringify(e.quickFilter??null),ae=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ae.current){ae.current=!0;return}r.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[Ke]);let ze=JSON.stringify(e.tooltip??null),le=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!le.current){le.current=!0;return}r.current?.api.updateGridOptions({tooltip:e.tooltip})},[ze]);let We=JSON.stringify(e.columnPanel??null),ue=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ue.current){ue.current=!0;return}r.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[We]);let je=JSON.stringify(e.toolbar??null),de=(0,i.useRef)(!1);return(0,i.useLayoutEffect)(()=>{if(!de.current){de.current=!0;return}r.current?.api.updateGridOptions({toolbar:e.toolbar})},[je]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({savedViews:e.savedViews})},[e.savedViews]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({sheets:e.sheets})},[e.sheets]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({theme:e.theme,icons:{...e.theme?.getIcons(),...e.icons}})},[e.theme,e.icons]),(0,Ne.jsx)("div",{ref:a,className:e.className,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...e.style}})});0&&(module.exports={Grid,...require("@agility-workbench/grid")});
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICellEditorParams, ColDef, CellRenderer, CellRendererParams, CellEditor, TooltipComponent, TooltipComponentParams, ActionFrameComponent, ActionFrameComponentParams, FilterParams, SetFilterValueComponent, SetFilterValueComponentParams, SetFilterSpecialValueComponent, SetFilterSpecialValueComponentParams, SetFilterGroupComponent, SetFilterGroupComponentParams, NON_DEFAULTABLE_COLDEF_KEYS, RowPresentationParams, RowPresentation, RowTooltipPresentation, MenuItem as MenuItem$1, GridOptions, IGridAPI, ColumnMenuContext, BodyMenuContext, Column } from '@agility-workbench/grid';
1
+ import { ICellEditorParams, ColDef, CellRenderer, CellRendererAlias, CellRendererParams, CellEditor, TooltipComponent, TooltipComponentParams, ActionFrameComponent, ActionFrameComponentParams, FilterParams, SetFilterValueComponent, SetFilterValueComponentParams, SetFilterSpecialValueComponent, SetFilterSpecialValueComponentParams, SetFilterGroupComponent, SetFilterGroupComponentParams, HeaderComponent, HeaderComponentParams, NON_DEFAULTABLE_COLDEF_KEYS, RowPresentationParams, RowPresentation, RowTooltipPresentation, MenuItem as MenuItem$1, GridOptions, IGridAPI, ColumnMenuContext, BodyMenuContext, Column } from '@agility-workbench/grid';
2
2
  export * from '@agility-workbench/grid';
3
3
  import React$1 from 'react';
4
4
 
@@ -35,6 +35,12 @@ type ReactRowPresentation = Omit<RowPresentation, "tooltip"> & {
35
35
  };
36
36
  type ReactGetRowPresentation = (params: RowPresentationParams) => ReactRowPresentation | null | undefined;
37
37
  type ReactActionFrameComponent = React$1.ComponentType<ActionFrameComponentParams> | React$1.ExoticComponent<ActionFrameComponentParams>;
38
+ /**
39
+ * A React component for a column header slot (`headerComponent` = content only, `headerCellComponent`
40
+ * = whole cell). It receives the core {@link HeaderComponentParams} as props and re-renders whenever
41
+ * the grid refreshes the header (sort / filter state changes).
42
+ */
43
+ type ReactHeaderComponent = React$1.ComponentType<HeaderComponentParams> | React$1.ExoticComponent<HeaderComponentParams>;
38
44
  type ReactSetFilterValueComponent = React$1.ComponentType<SetFilterValueComponentParams> | React$1.ExoticComponent<SetFilterValueComponentParams>;
39
45
  type ReactSetFilterSpecialValueComponent = React$1.ComponentType<SetFilterSpecialValueComponentParams> | React$1.ExoticComponent<SetFilterSpecialValueComponentParams>;
40
46
  type ReactSetFilterGroupComponent = React$1.ComponentType<SetFilterGroupComponentParams> | React$1.ExoticComponent<SetFilterGroupComponentParams>;
@@ -44,13 +50,15 @@ type ReactFilterParams = Omit<FilterParams, "valueComponent" | "selectAllCompone
44
50
  blanksComponent?: SetFilterSpecialValueComponent | ReactSetFilterSpecialValueComponent;
45
51
  groupComponent?: SetFilterGroupComponent | ReactSetFilterGroupComponent;
46
52
  };
47
- type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams"> & {
48
- cellRenderer?: CellRenderer | ReactCellRenderer;
53
+ type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams" | "headerComponent" | "headerCellComponent"> & {
54
+ cellRenderer?: CellRenderer | CellRendererAlias | ReactCellRenderer;
49
55
  cellEditor?: CellEditor | ReactCellEditor;
50
56
  tooltipComponent?: TooltipComponent | ReactTooltipComponent;
51
57
  headerTooltip?: string | TooltipComponent | ReactTooltipComponent;
52
58
  actionFrameComponent?: ActionFrameComponent | ReactActionFrameComponent;
53
59
  filterParams?: ReactFilterParams;
60
+ headerComponent?: HeaderComponent | ReactHeaderComponent;
61
+ headerCellComponent?: HeaderComponent | ReactHeaderComponent;
54
62
  children?: ReactColDef[];
55
63
  };
56
64
  /**
@@ -59,6 +67,12 @@ type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "to
59
67
  * `DefaultColDef`, but its component fields may be React components.
60
68
  */
61
69
  type ReactDefaultColDef = Omit<ReactColDef, (typeof NON_DEFAULTABLE_COLDEF_KEYS)[number]>;
70
+ /**
71
+ * React-aware shape of the partial column defs the grid layers over a synthesized column
72
+ * (`groupColumnDef`, `pivotResultColumnDef`): a `Partial<ReactColDef>`, so component fields may be
73
+ * React components.
74
+ */
75
+ type ReactPartialColDef = Partial<Omit<ReactColDef, "children">>;
62
76
 
63
77
  type MenuSlotReact = string | HTMLElement | React.ReactElement | null | false | undefined;
64
78
  interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
@@ -67,7 +81,7 @@ interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
67
81
  subMenu?: MenuItem[];
68
82
  }
69
83
 
70
- interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
84
+ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation" | "groupColumnDef" | "pivotResultColumnDef"> {
71
85
  /** Optional className/style for the host div */
72
86
  className?: string;
73
87
  style?: React.CSSProperties;
@@ -128,10 +142,20 @@ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMe
128
142
  * be React components; they are adapted exactly as they would be on a real column def.
129
143
  */
130
144
  defaultColDef?: ReactDefaultColDef;
145
+ /**
146
+ * The auto-group column's definition (see core `groupColumnDef`), React-aware like `defaultColDef`:
147
+ * component fields (cellRenderer, tooltipComponent, headerComponent, …) may be React components.
148
+ */
149
+ groupColumnDef?: ReactPartialColDef;
150
+ /**
151
+ * Layered over every pivot result column (see core `pivotResultColumnDef`), React-aware like
152
+ * `defaultColDef`.
153
+ */
154
+ pivotResultColumnDef?: ReactPartialColDef;
131
155
  /** React-aware row presentation callback; row tooltip components may be React components. */
132
156
  getRowPresentation?: ReactGetRowPresentation;
133
157
  }
134
158
 
135
159
  declare const Grid: React$1.ForwardRefExoticComponent<GridProps & React$1.RefAttributes<IGridAPI | null>>;
136
160
 
137
- export { Grid, type GridProps, type MenuSlotReact, type ReactActionFrameComponent, type ReactCellEditor, type ReactCellEditorHandle, type ReactCellRenderer, type ReactColDef, type ReactDefaultColDef, type ReactFilterParams, type ReactGetRowPresentation, type MenuItem as ReactMenuItem, type ReactRowPresentation, type ReactRowTooltipPresentation, type ReactSetFilterGroupComponent, type ReactSetFilterSpecialValueComponent, type ReactSetFilterValueComponent, type ReactTooltipComponent };
161
+ export { Grid, type GridProps, type MenuSlotReact, type ReactActionFrameComponent, type ReactCellEditor, type ReactCellEditorHandle, type ReactCellRenderer, type ReactColDef, type ReactDefaultColDef, type ReactFilterParams, type ReactGetRowPresentation, type ReactHeaderComponent, type MenuItem as ReactMenuItem, type ReactPartialColDef, type ReactRowPresentation, type ReactRowTooltipPresentation, type ReactSetFilterGroupComponent, type ReactSetFilterSpecialValueComponent, type ReactSetFilterValueComponent, type ReactTooltipComponent };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICellEditorParams, ColDef, CellRenderer, CellRendererParams, CellEditor, TooltipComponent, TooltipComponentParams, ActionFrameComponent, ActionFrameComponentParams, FilterParams, SetFilterValueComponent, SetFilterValueComponentParams, SetFilterSpecialValueComponent, SetFilterSpecialValueComponentParams, SetFilterGroupComponent, SetFilterGroupComponentParams, NON_DEFAULTABLE_COLDEF_KEYS, RowPresentationParams, RowPresentation, RowTooltipPresentation, MenuItem as MenuItem$1, GridOptions, IGridAPI, ColumnMenuContext, BodyMenuContext, Column } from '@agility-workbench/grid';
1
+ import { ICellEditorParams, ColDef, CellRenderer, CellRendererAlias, CellRendererParams, CellEditor, TooltipComponent, TooltipComponentParams, ActionFrameComponent, ActionFrameComponentParams, FilterParams, SetFilterValueComponent, SetFilterValueComponentParams, SetFilterSpecialValueComponent, SetFilterSpecialValueComponentParams, SetFilterGroupComponent, SetFilterGroupComponentParams, HeaderComponent, HeaderComponentParams, NON_DEFAULTABLE_COLDEF_KEYS, RowPresentationParams, RowPresentation, RowTooltipPresentation, MenuItem as MenuItem$1, GridOptions, IGridAPI, ColumnMenuContext, BodyMenuContext, Column } from '@agility-workbench/grid';
2
2
  export * from '@agility-workbench/grid';
3
3
  import React$1 from 'react';
4
4
 
@@ -35,6 +35,12 @@ type ReactRowPresentation = Omit<RowPresentation, "tooltip"> & {
35
35
  };
36
36
  type ReactGetRowPresentation = (params: RowPresentationParams) => ReactRowPresentation | null | undefined;
37
37
  type ReactActionFrameComponent = React$1.ComponentType<ActionFrameComponentParams> | React$1.ExoticComponent<ActionFrameComponentParams>;
38
+ /**
39
+ * A React component for a column header slot (`headerComponent` = content only, `headerCellComponent`
40
+ * = whole cell). It receives the core {@link HeaderComponentParams} as props and re-renders whenever
41
+ * the grid refreshes the header (sort / filter state changes).
42
+ */
43
+ type ReactHeaderComponent = React$1.ComponentType<HeaderComponentParams> | React$1.ExoticComponent<HeaderComponentParams>;
38
44
  type ReactSetFilterValueComponent = React$1.ComponentType<SetFilterValueComponentParams> | React$1.ExoticComponent<SetFilterValueComponentParams>;
39
45
  type ReactSetFilterSpecialValueComponent = React$1.ComponentType<SetFilterSpecialValueComponentParams> | React$1.ExoticComponent<SetFilterSpecialValueComponentParams>;
40
46
  type ReactSetFilterGroupComponent = React$1.ComponentType<SetFilterGroupComponentParams> | React$1.ExoticComponent<SetFilterGroupComponentParams>;
@@ -44,13 +50,15 @@ type ReactFilterParams = Omit<FilterParams, "valueComponent" | "selectAllCompone
44
50
  blanksComponent?: SetFilterSpecialValueComponent | ReactSetFilterSpecialValueComponent;
45
51
  groupComponent?: SetFilterGroupComponent | ReactSetFilterGroupComponent;
46
52
  };
47
- type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams"> & {
48
- cellRenderer?: CellRenderer | ReactCellRenderer;
53
+ type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams" | "headerComponent" | "headerCellComponent"> & {
54
+ cellRenderer?: CellRenderer | CellRendererAlias | ReactCellRenderer;
49
55
  cellEditor?: CellEditor | ReactCellEditor;
50
56
  tooltipComponent?: TooltipComponent | ReactTooltipComponent;
51
57
  headerTooltip?: string | TooltipComponent | ReactTooltipComponent;
52
58
  actionFrameComponent?: ActionFrameComponent | ReactActionFrameComponent;
53
59
  filterParams?: ReactFilterParams;
60
+ headerComponent?: HeaderComponent | ReactHeaderComponent;
61
+ headerCellComponent?: HeaderComponent | ReactHeaderComponent;
54
62
  children?: ReactColDef[];
55
63
  };
56
64
  /**
@@ -59,6 +67,12 @@ type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "to
59
67
  * `DefaultColDef`, but its component fields may be React components.
60
68
  */
61
69
  type ReactDefaultColDef = Omit<ReactColDef, (typeof NON_DEFAULTABLE_COLDEF_KEYS)[number]>;
70
+ /**
71
+ * React-aware shape of the partial column defs the grid layers over a synthesized column
72
+ * (`groupColumnDef`, `pivotResultColumnDef`): a `Partial<ReactColDef>`, so component fields may be
73
+ * React components.
74
+ */
75
+ type ReactPartialColDef = Partial<Omit<ReactColDef, "children">>;
62
76
 
63
77
  type MenuSlotReact = string | HTMLElement | React.ReactElement | null | false | undefined;
64
78
  interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
@@ -67,7 +81,7 @@ interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
67
81
  subMenu?: MenuItem[];
68
82
  }
69
83
 
70
- interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
84
+ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation" | "groupColumnDef" | "pivotResultColumnDef"> {
71
85
  /** Optional className/style for the host div */
72
86
  className?: string;
73
87
  style?: React.CSSProperties;
@@ -128,10 +142,20 @@ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMe
128
142
  * be React components; they are adapted exactly as they would be on a real column def.
129
143
  */
130
144
  defaultColDef?: ReactDefaultColDef;
145
+ /**
146
+ * The auto-group column's definition (see core `groupColumnDef`), React-aware like `defaultColDef`:
147
+ * component fields (cellRenderer, tooltipComponent, headerComponent, …) may be React components.
148
+ */
149
+ groupColumnDef?: ReactPartialColDef;
150
+ /**
151
+ * Layered over every pivot result column (see core `pivotResultColumnDef`), React-aware like
152
+ * `defaultColDef`.
153
+ */
154
+ pivotResultColumnDef?: ReactPartialColDef;
131
155
  /** React-aware row presentation callback; row tooltip components may be React components. */
132
156
  getRowPresentation?: ReactGetRowPresentation;
133
157
  }
134
158
 
135
159
  declare const Grid: React$1.ForwardRefExoticComponent<GridProps & React$1.RefAttributes<IGridAPI | null>>;
136
160
 
137
- export { Grid, type GridProps, type MenuSlotReact, type ReactActionFrameComponent, type ReactCellEditor, type ReactCellEditorHandle, type ReactCellRenderer, type ReactColDef, type ReactDefaultColDef, type ReactFilterParams, type ReactGetRowPresentation, type MenuItem as ReactMenuItem, type ReactRowPresentation, type ReactRowTooltipPresentation, type ReactSetFilterGroupComponent, type ReactSetFilterSpecialValueComponent, type ReactSetFilterValueComponent, type ReactTooltipComponent };
161
+ export { Grid, type GridProps, type MenuSlotReact, type ReactActionFrameComponent, type ReactCellEditor, type ReactCellEditorHandle, type ReactCellRenderer, type ReactColDef, type ReactDefaultColDef, type ReactFilterParams, type ReactGetRowPresentation, type ReactHeaderComponent, type MenuItem as ReactMenuItem, type ReactPartialColDef, type ReactRowPresentation, type ReactRowTooltipPresentation, type ReactSetFilterGroupComponent, type ReactSetFilterSpecialValueComponent, type ReactSetFilterValueComponent, type ReactTooltipComponent };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"@agility-workbench/grid";import Be,{useLayoutEffect as l,useRef as c}from"react";import{createGrid as Ve}from"@agility-workbench/grid";import y from"react";import{flushSync as he}from"react-dom";import{createRoot as ye}from"react-dom/client";var T=new Set,I=!1;function Se(){I=!1;let t=Array.from(T);T.clear();for(let e of t)e.unmount()}function we(t){T.add(t),!I&&(I=!0,queueMicrotask(Se))}var s=class{root;constructor(e){this.root=ye(e)}render(e){this.root?.render(e)}renderSync(e){let o=this.root;o&&he(()=>o.render(e))}destroy(){let e=this.root;e&&(this.root=null,we(e))}};import{isClassRenderer as pe,isClassSetFilterComponent as Pe}from"@agility-workbench/grid";import{isClassTooltipComponent as Fe}from"@agility-workbench/grid";import{isClassActionFrameComponent as be}from"@agility-workbench/grid";import $ from"react";var ee=new WeakMap;function Me(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function ve(t){return class{el=document.createElement("div");root=null;handle=$.createRef();init(o){this.el.style.width="100%",this.el.style.height="100%",this.root=new s(this.el);let r=$.createElement(t,{...o,ref:this.handle});this.root.renderSync(r)}getGui(){return this.el}getValue(){return this.handle.current?.getValue()}isParsed(){return this.handle.current?.isParsed?.()??!1}focus(){this.handle.current?.focus?.()}isCancelBeforeStart(){return this.handle.current?.isCancelBeforeStart?.()??!1}destroy(){let o=this.root;this.root=null,o?.destroy()}}}function D(t){if(t==null)return;if(typeof t=="string"||Me(t))return t;let e=ee.get(t);if(e)return e;let o=ve(t);return ee.set(t,o),o}var te=new WeakMap,ne=new WeakMap,oe=new WeakMap,ie=new WeakMap;function S(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function Ee(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function Te(t){return class{el=document.createElement("span");root=null;init(o){this.el.style.display="inline-flex",this.el.style.alignItems="center",this.el.style.width="100%",this.el.style.height="100%",this.el.style.overflow="hidden",this.root=new s(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(y.createElement(t,Ee(o)))}}}function w(t){if(!t)return;if(typeof t=="function"&&pe(t)||!S(t))return t;let e=te.get(t);if(e)return e;let o=Te(t);return te.set(t,o),o}function Ie(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function De(t){return class{el=document.createElement("div");root=null;init(o){this.root=new s(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.renderSync(y.createElement(t,Ie(o)))}}}function M(t){if(!t)return;if(typeof t=="function"&&Fe(t)||!S(t))return t;let e=ne.get(t);if(e)return e;let o=De(t);return ne.set(t,o),o}function v(t){if(t)return e=>{let o=t(e);return!o||typeof o.tooltip!="object"||o.tooltip==null?o:{...o,tooltip:{...o.tooltip,component:M(o.tooltip.component)}}}}function re(t){return t==null||typeof t=="string"?t:M(t)}function Ae(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function Ge(t){return class{el=document.createElement("div");root=null;init(o){this.root=new s(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(y.createElement(t,Ae(o)))}}}function ae(t){if(!t)return;if(typeof t=="function"&&be(t)||!S(t))return t;let e=oe.get(t);if(e)return e;let o=Ge(t);return oe.set(t,o),o}function ke(t){return class{el=document.createElement("span");root=null;init(o){this.root=new s(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(y.createElement(t,o))}}}function h(t){if(!t)return;if(typeof t=="function"&&Pe(t)||!S(t))return t;let e=ie.get(t);if(e)return e;let o=ke(t);return ie.set(t,o),o}function le(t){if(t)return{...t,valueComponent:h(t.valueComponent),selectAllComponent:h(t.selectAllComponent),blanksComponent:h(t.blanksComponent),groupComponent:h(t.groupComponent)}}function xe(t){return{...t,cellRenderer:w(t.cellRenderer),cellEditor:D(t.cellEditor),tooltipComponent:M(t.tooltipComponent),headerTooltip:re(t.headerTooltip),actionFrameComponent:ae(t.actionFrameComponent),filterParams:le(t.filterParams),children:t.children?A(t.children)??void 0:void 0}}function A(t){return t==null?t:t.map(e=>xe(e))}function ue(t){if(t==null)return;let e={...t};return"cellRenderer"in t&&(e.cellRenderer=w(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=D(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=M(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=re(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=ae(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=le(t.filterParams)),e}function n(t,e,o){o!=null&&(t[e]=o)}function ce(t){let e={};return n(e,"headerHeight",t.headerHeight),n(e,"leafHeaderHeight",t.leafHeaderHeight),n(e,"parentHeaderHeight",t.parentHeaderHeight),n(e,"rowHeight",t.rowHeight),n(e,"pinnedTopRowData",t.pinnedTopRowData),n(e,"pinnedBottomRowData",t.pinnedBottomRowData),n(e,"getRowId",t.getRowId),n(e,"rowIdKey",t.rowIdKey),n(e,"rowDataMode",t.rowDataMode),n(e,"asyncTransactionWaitMs",t.asyncTransactionWaitMs),n(e,"overscanRowCount",t.overscanRowCount),n(e,"minResizeWidth",t.minResizeWidth),n(e,"maxColumnWidth",t.maxColumnWidth),n(e,"pivotMode",t.pivotMode),n(e,"pivotColumns",t.pivotColumns),n(e,"pivotResultColumnDef",t.pivotResultColumnDef),n(e,"maxPivotColumns",t.maxPivotColumns),n(e,"pivotColumnMoveMode",t.pivotColumnMoveMode),n(e,"autosizeColumnsOnDataChange",t.autosizeColumnsOnDataChange),n(e,"allowExportAsCSV",t.allowExportAsCSV),n(e,"allowExportAsExcel",t.allowExportAsExcel),n(e,"pagination",t.pagination),n(e,"paginationControls",t.paginationControls),n(e,"rowNumbers",t.rowNumbers),n(e,"rowHover",t.rowHover),n(e,"columnHover",t.columnHover),n(e,"zebraRows",t.zebraRows),n(e,"getRowClass",t.getRowClass),n(e,"getRowStyle",t.getRowStyle),n(e,"getRowPresentation",v(t.getRowPresentation)),n(e,"onCellClicked",t.onCellClicked),n(e,"onRowClicked",t.onRowClicked),n(e,"onCellDoubleClicked",t.onCellDoubleClicked),n(e,"onRowDoubleClicked",t.onRowDoubleClicked),n(e,"onCellValueChanged",t.onCellValueChanged),n(e,"onSelectionChanged",t.onSelectionChanged),n(e,"onSortChanged",t.onSortChanged),n(e,"onFilterChanged",t.onFilterChanged),n(e,"onQuickFilterFindChanged",t.onQuickFilterFindChanged),n(e,"onHistoryChanged",t.onHistoryChanged),n(e,"ariaLabel",t.ariaLabel),n(e,"ariaLabelledBy",t.ariaLabelledBy),n(e,"highlightActiveCell",t.highlightActiveCell),n(e,"rowSelection",t.rowSelection),n(e,"cellSelection",t.cellSelection),n(e,"rangeSelection",t.rangeSelection),n(e,"fillHandle",t.fillHandle),n(e,"columnSelection",t.columnSelection),n(e,"headerKeyboardNavigation",t.headerKeyboardNavigation),n(e,"showColumnButtonsOnHover",t.showColumnButtonsOnHover),n(e,"selectAllRowsOnHeaderClick",t.selectAllRowsOnHeaderClick),n(e,"selectAllScope",t.selectAllScope),n(e,"selectionPersistence",t.selectionPersistence),n(e,"clearSelectionOnBodyClick",t.clearSelectionOnBodyClick),n(e,"resetPageOn",t.resetPageOn),n(e,"pageSize",t.pageSize),n(e,"pageSizes",t.pageSizes),n(e,"serverSideBlockSize",t.serverSideBlockSize),n(e,"rowModelType",t.rowModelType),n(e,"getGroupChildCount",t.getGroupChildCount),n(e,"groupChildCount",t.groupChildCount),n(e,"paginationUnknownTotalTooltip",t.paginationUnknownTotalTooltip),n(e,"undoLimit",t.undoLimit),n(e,"editTrigger",t.editTrigger),n(e,"readOnlyEdit",t.readOnlyEdit),n(e,"initialSort",t.initialSort),n(e,"showSortPriority",t.showSortPriority),n(e,"pinnedRowsEditable",t.pinnedRowsEditable),n(e,"rowPinningMenu",t.rowPinningMenu),n(e,"rowInsertionMenu",t.rowInsertionMenu),n(e,"suppressKeyboardEdit",t.suppressKeyboardEdit),n(e,"suppressTypeToEdit",t.suppressTypeToEdit),n(e,"moveAfterEdit",t.moveAfterEdit),n(e,"commitOnBlur",t.commitOnBlur),n(e,"reevaluateOnEdit",t.reevaluateOnEdit),n(e,"groupDisplayType",t.groupDisplayType),n(e,"groupColumnDef",t.groupColumnDef),n(e,"groupDefaultExpanded",t.groupDefaultExpanded),n(e,"groupSortMode",t.groupSortMode),n(e,"treeData",t.treeData),n(e,"groupRowsSelectable",t.groupRowsSelectable),n(e,"isRowSelectable",t.isRowSelectable),n(e,"isRowPinned",t.isRowPinned),n(e,"groupRowsSticky",t.groupRowsSticky),n(e,"isFullWidthRow",t.isFullWidthRow),n(e,"tooltip",t.tooltip),n(e,"quickFilter",t.quickFilter),n(e,"columnPanel",t.columnPanel),n(e,"toolbar",t.toolbar),n(e,"savedViews",t.savedViews),n(e,"sheets",t.sheets),n(e,"loadingMessage",t.loadingMessage),n(e,"noRowsMessage",t.noRowsMessage),n(e,"pivotNoValuesMessage",t.pivotNoValuesMessage),n(e,"pivotEmptyMessage",t.pivotEmptyMessage),n(e,"filterDebounceMs",t.filterDebounceMs),n(e,"cellFlashDuration",t.cellFlashDuration),n(e,"cellFadeDuration",t.cellFadeDuration),n(e,"icons",t.icons),n(e,"theme",t.theme),t.fullWidthCellRenderer!=null&&(e.fullWidthCellRenderer=w(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=ue(t.defaultColDef)),t.bodyContextMenu===!1&&(e.bodyContextMenu=!1),t.multiColumnMenu!=null&&(e.multiColumnMenu=t.multiColumnMenu),t.rowModelType==="serverSide"&&(n(e,"serverSideDataSource",t.serverSideDataSource),n(e,"serverSideAggregationSource",t.serverSideAggregationSource)),n(e,"suppressStyleInjection",t.suppressStyleInjection),n(e,"styleNonce",t.styleNonce),e}import Oe from"react";var p=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let r=[],i=o,m=this.opts.getBodyMenuItems?this.opts.getBodyMenuItems({ctx:e,items:i}):i;return{items:this.normalizeItems(m,r),cleanup:()=>{for(let f of r)f()}}}normalizeItems(e,o){return e.map(r=>{if(r.isSeparator)return{isSeparator:!0};let i=this.normalizeSlot(r.left,o),m=this.normalizeSlot(r.right,o);return{...r,left:i,right:m,subMenu:r.subMenu?this.normalizeItems(r.subMenu,o):void 0}})}normalizeSlot(e,o){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(Oe.isValidElement(e)){let{el:r,unmount:i}=this.mountReact(e);return o.push(i),r}}}mountReact(e){let o=document.createElement("span");o.style.display="inline-flex",o.style.alignItems="center";let r=new s(o);return r.render(e),{el:o,unmount:()=>r.destroy()}}};import He from"react";var P=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let r=[],i=o,m=this.opts.getColumnMenuItems?this.opts.getColumnMenuItems({ctx:e,items:i}):i;return{items:this.normalizeItems(m,r),cleanup:()=>{for(let f of r)f()}}}normalizeItems(e,o){return e.map(r=>{if(r.isSeparator)return{isSeparator:!0};let i=this.normalizeSlot(r.left,o),m=this.normalizeSlot(r.right,o);return{...r,left:i,right:m,subMenu:r.subMenu?this.normalizeItems(r.subMenu,o):void 0}})}normalizeSlot(e,o){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(He.isValidElement(e)){let{el:r,unmount:i}=this.mountReact(e);return o.push(i),r}}}mountReact(e){let o=document.createElement("span");o.style.display="inline-flex",o.style.alignItems="center";let r=new s(o);return r.render(e),{el:o,unmount:()=>r.destroy()}}};import{jsx as ze}from"react/jsx-runtime";function C(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function Ne(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var Le=Be.forwardRef(function(e,o){let r=c(null),i=c(null),m=c(e.onGridReady),g=c(e.getColumnMenuItems),f=c(e.bodyContextMenu),G=c(e.multiColumnMenu),k=c(e.onCellClicked),x=c(e.onRowClicked),O=c(e.onCellDoubleClicked),H=c(e.onRowDoubleClicked),B=c(e.onCellValueChanged),V=c(e.onSelectionChanged),N=c(e.onSortChanged),L=c(e.onFilterChanged),z=c(e.onQuickFilterFindChanged),K=c(e.onHistoryChanged),W=c(e.onBeforeCellCommit),j=c(e.fillOperation);m.current=e.onGridReady,g.current=e.getColumnMenuItems,f.current=e.bodyContextMenu,G.current=e.multiColumnMenu,k.current=e.onCellClicked,x.current=e.onRowClicked,O.current=e.onCellDoubleClicked,H.current=e.onRowDoubleClicked,B.current=e.onCellValueChanged,V.current=e.onSelectionChanged,N.current=e.onSortChanged,L.current=e.onFilterChanged,z.current=e.onQuickFilterFindChanged,K.current=e.onHistoryChanged,W.current=e.onBeforeCellCommit,j.current=e.fillOperation,l(()=>{let u=r.current;if(!u)return;let d=ce(e);d.onCellClicked=a=>k.current?.(a),d.onRowClicked=a=>x.current?.(a),d.onCellDoubleClicked=a=>O.current?.(a),d.onRowDoubleClicked=a=>H.current?.(a),d.onCellValueChanged=a=>B.current?.(a),d.onSelectionChanged=a=>V.current?.(a),d.onSortChanged=a=>N.current?.(a),d.onFilterChanged=a=>L.current?.(a),d.onQuickFilterFindChanged=a=>z.current?.(a),d.onHistoryChanged=a=>K.current?.(a),d.onBeforeCellCommit=a=>W.current?.(a),d.fillOperation=a=>j.current?.(a),e.multiColumnMenu!==!1&&(d.multiColumnMenu=a=>{let R=G.current;return R===!1?[]:typeof R!="function"?a.items:R(a)});let b=Ve(u,{...d,menuAdapter:new P({getColumnMenuItems:a=>g.current?.(a)??a.items}),bodyMenuAdapter:new p({getBodyMenuItems:a=>{let R=f.current;return typeof R=="function"?R(a):a.items}})}),E={api:b,destroyed:!1,appliedServerSideDataSource:d.serverSideDataSource};return i.current=E,C(o,b),C(e.apiRef,b),()=>{i.current===E&&(i.current=null),C(o,null),C(e.apiRef,null),Ne(E)}},[]),l(()=>{let u=i.current?.api??null;return C(o,u),C(e.apiRef,u),()=>{C(o,null),C(e.apiRef,null)}},[o,e.apiRef]),l(()=>{let u=i.current?.api;u&&u.updateGridOptions({columnDefs:A(e.columnDefs)})},[e.columnDefs]),l(()=>{let u=i.current?.api;u&&e.rowModelType!=="serverSide"&&u.setRowData(e.rowData??e.data??[])},[e.data,e.rowData,e.rowModelType]);let F=c(null);l(()=>{let u=i.current;if(!(!u||F.current===u))return F.current=u,m.current?.(u.api),()=>{F.current=null}},[]),l(()=>{i.current?.api.updateGridOptions({groupDisplayType:e.groupDisplayType})},[e.groupDisplayType]),l(()=>{i.current?.api.updateGridOptions({groupSortMode:e.groupSortMode})},[e.groupSortMode]),l(()=>{i.current?.api.updateGridOptions({groupRowsSelectable:e.groupRowsSelectable})},[e.groupRowsSelectable]),l(()=>{i.current?.api.updateGridOptions({groupChildCount:e.groupChildCount})},[e.groupChildCount]),l(()=>{i.current?.api.updateGridOptions({headerHeight:e.headerHeight,leafHeaderHeight:e.leafHeaderHeight,parentHeaderHeight:e.parentHeaderHeight})},[e.headerHeight,e.leafHeaderHeight,e.parentHeaderHeight]),l(()=>{i.current?.api.updateGridOptions({pivotColumnMoveMode:e.pivotColumnMoveMode})},[e.pivotColumnMoveMode]);let q=c(!1);l(()=>{if(!q.current){q.current=!0;return}e.pivotMode!=null&&i.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let de=JSON.stringify(e.pivotColumns??null),U=c(!1);l(()=>{if(!U.current){U.current=!0;return}e.pivotColumns!=null&&i.current?.api.setPivotColumns(e.pivotColumns)},[de]),l(()=>{i.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let se=JSON.stringify(e.rowSelection??null),J=c(!1);l(()=>{if(!J.current){J.current=!0;return}i.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[se]),l(()=>{i.current?.api.setTreeDataKeyboardNavigationOptions({keyboardNavigationMode:e.treeData?.keyboardNavigationMode,enableKeyboardNavigationModeSwitch:e.treeData?.enableKeyboardNavigationModeSwitch??!1})},[e.treeData?.keyboardNavigationMode,e.treeData?.enableKeyboardNavigationModeSwitch]),l(()=>{i.current?.api.updateGridOptions({pinnedTopRowData:e.pinnedTopRowData,pinnedBottomRowData:e.pinnedBottomRowData,isRowPinned:e.isRowPinned,groupRowsSticky:e.groupRowsSticky})},[e.pinnedTopRowData,e.pinnedBottomRowData,e.isRowPinned,e.groupRowsSticky]),l(()=>{i.current?.api.updateGridOptions({rowHover:e.rowHover??!0,columnHover:e.columnHover??!1,zebraRows:e.zebraRows??!1,getRowClass:e.getRowClass,getRowStyle:e.getRowStyle,getRowPresentation:v(e.getRowPresentation),ariaLabel:e.ariaLabel,ariaLabelledBy:e.ariaLabelledBy,highlightActiveCell:e.highlightActiveCell??!1,cellSelection:e.cellSelection??!0,rangeSelection:e.rangeSelection??!0,fillHandle:e.fillHandle??!0,columnSelection:e.columnSelection??!0,headerKeyboardNavigation:e.headerKeyboardNavigation??!0,showColumnButtonsOnHover:e.showColumnButtonsOnHover??!1,bodyContextMenu:e.bodyContextMenu!==!1,editTrigger:e.editTrigger??"doubleClick",readOnlyEdit:e.readOnlyEdit??!1,pinnedRowsEditable:e.pinnedRowsEditable??!1,rowPinningMenu:e.rowPinningMenu??!1,rowInsertionMenu:e.rowInsertionMenu,suppressKeyboardEdit:e.suppressKeyboardEdit??!1,suppressTypeToEdit:e.suppressTypeToEdit??!1,moveAfterEdit:e.moveAfterEdit??!0,commitOnBlur:e.commitOnBlur??!0,asyncTransactionWaitMs:e.asyncTransactionWaitMs??16,loadingMessage:e.loadingMessage,noRowsMessage:e.noRowsMessage})},[e.rowHover,e.columnHover,e.zebraRows,e.getRowClass,e.getRowStyle,e.getRowPresentation,e.ariaLabel,e.ariaLabelledBy,e.highlightActiveCell,e.cellSelection,e.rangeSelection,e.fillHandle,e.columnSelection,e.headerKeyboardNavigation,e.showColumnButtonsOnHover,e.bodyContextMenu,e.editTrigger,e.readOnlyEdit,e.pinnedRowsEditable,e.rowPinningMenu,e.rowInsertionMenu,e.suppressKeyboardEdit,e.suppressTypeToEdit,e.moveAfterEdit,e.commitOnBlur,e.asyncTransactionWaitMs,e.loadingMessage,e.noRowsMessage]),l(()=>{let u=i.current;!u||e.rowModelType!=="serverSide"||e.serverSideDataSource&&e.serverSideDataSource!==u.appliedServerSideDataSource&&(u.appliedServerSideDataSource=e.serverSideDataSource,u.api.updateGridOptions({serverSideDataSource:e.serverSideDataSource}))},[e.rowModelType,e.serverSideDataSource]),l(()=>{let u=i.current;!u||e.rowModelType!=="serverSide"||e.serverSideAggregationSource&&u.api.updateGridOptions({serverSideAggregationSource:e.serverSideAggregationSource})},[e.rowModelType,e.serverSideAggregationSource]),l(()=>{let u=i.current?.api;u&&u.dispatch({type:"overlayShow",overlayType:e.loading?"loading":"none"})},[e.loading]),l(()=>{i.current?.api.updateGridOptions({pagination:e.pagination})},[e.pagination]);let me=JSON.stringify(e.paginationControls??null),Q=c(!1);l(()=>{if(!Q.current){Q.current=!0;return}i.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[me]);let Ce=JSON.stringify(e.quickFilter??null),_=c(!1);l(()=>{if(!_.current){_.current=!0;return}i.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[Ce]);let fe=JSON.stringify(e.tooltip??null),Y=c(!1);l(()=>{if(!Y.current){Y.current=!0;return}i.current?.api.updateGridOptions({tooltip:e.tooltip})},[fe]);let Re=JSON.stringify(e.columnPanel??null),X=c(!1);l(()=>{if(!X.current){X.current=!0;return}i.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[Re]);let ge=JSON.stringify(e.toolbar??null),Z=c(!1);return l(()=>{if(!Z.current){Z.current=!0;return}i.current?.api.updateGridOptions({toolbar:e.toolbar})},[ge]),l(()=>{i.current?.api.updateGridOptions({savedViews:e.savedViews})},[e.savedViews]),l(()=>{i.current?.api.updateGridOptions({sheets:e.sheets})},[e.sheets]),l(()=>{i.current?.api.updateGridOptions({theme:e.theme,icons:{...e.theme?.getIcons(),...e.icons}})},[e.theme,e.icons]),ze("div",{ref:r,className:e.className,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...e.style}})});export{Le as Grid};
1
+ export*from"@agility-workbench/grid";import rt,{useLayoutEffect as l,useRef as d}from"react";import{createGrid as it}from"@agility-workbench/grid";import C from"react";import{flushSync as De}from"react-dom";import{createRoot as He}from"react-dom/client";var D=new Set,H=!1;function Oe(){H=!1;let t=Array.from(D);D.clear();for(let e of t)e.unmount()}function ke(t){D.add(t),!H&&(H=!0,queueMicrotask(Oe))}var m=class{root;constructor(e){this.root=He(e)}render(e){this.root?.render(e)}renderSync(e){let o=this.root;o&&De(()=>o.render(e))}destroy(){let e=this.root;e&&(this.root=null,ke(e))}};import{isClassRenderer as Ie,isClassSetFilterComponent as Ge}from"@agility-workbench/grid";import{isClassTooltipComponent as Ne}from"@agility-workbench/grid";import{isClassActionFrameComponent as Be}from"@agility-workbench/grid";import{isClassHeaderComponent as Le}from"@agility-workbench/grid";import re from"react";var ie=new WeakMap;function Ae(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function xe(t){return class{el=document.createElement("div");root=null;handle=re.createRef();init(o){this.el.style.width="100%",this.el.style.height="100%",this.root=new m(this.el);let i=re.createElement(t,{...o,ref:this.handle});this.root.renderSync(i)}getGui(){return this.el}getValue(){return this.handle.current?.getValue()}isParsed(){return this.handle.current?.isParsed?.()??!1}focus(){this.handle.current?.focus?.()}isCancelBeforeStart(){return this.handle.current?.isCancelBeforeStart?.()??!1}destroy(){let o=this.root;this.root=null,o?.destroy()}}}function O(t){if(t==null)return;if(typeof t=="string"||Ae(t))return t;let e=ie.get(t);if(e)return e;let o=xe(t);return ie.set(t,o),o}var ae=new WeakMap,le=new WeakMap,ue=new WeakMap,de=new WeakMap,ce=new WeakMap;function y(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function Ve(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function Ke(t){return class{el=document.createElement("span");root=null;init(o){this.el.style.display="inline-flex",this.el.style.alignItems="center",this.el.style.width="100%",this.el.style.height="100%",this.el.style.overflow="hidden",this.root=new m(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(C.createElement(t,Ve(o)))}}}function S(t){if(!t)return;if(typeof t=="function"&&Ie(t)||!y(t))return t;let e=ae.get(t);if(e)return e;let o=Ke(t);return ae.set(t,o),o}function ze(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function We(t){return class{el=document.createElement("div");root=null;init(o){this.root=new m(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.renderSync(C.createElement(t,ze(o)))}}}function M(t){if(!t)return;if(typeof t=="function"&&Ne(t)||!y(t))return t;let e=le.get(t);if(e)return e;let o=We(t);return le.set(t,o),o}function v(t){if(t)return e=>{let o=t(e);return!o||typeof o.tooltip!="object"||o.tooltip==null?o:{...o,tooltip:{...o.tooltip,component:M(o.tooltip.component)}}}}function se(t){return t==null||typeof t=="string"?t:M(t)}function je(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function _e(t){return class{el=document.createElement("div");root=null;init(o){this.root=new m(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(C.createElement(t,je(o)))}}}function me(t){if(!t)return;if(typeof t=="function"&&Be(t)||!y(t))return t;let e=ue.get(t);if(e)return e;let o=_e(t);return ue.set(t,o),o}function Ue({node:t}){let e=C.useRef(null);return C.useLayoutEffect(()=>{let o=e.current;o&&o.firstChild!==t&&o.replaceChildren(t)},[t]),C.createElement("span",{ref:e,style:{display:"contents"}})}function qe(t){if(!(typeof t=="function"&&!t.prototype?.isReactComponent))return r=>C.createElement(t,r);let o=t;function i(r){let s=o(r);return s instanceof HTMLElement?C.createElement(Ue,{node:s}):s}return r=>C.createElement(i,r)}function Je(t){let e=qe(t);return class{el=document.createElement("div");root=null;init(i){this.el.className="pte-hcell-custom-root",this.el.style.display="flex",this.el.style.alignItems="center",this.el.style.width="100%",this.el.style.height="100%",this.el.style.overflow="hidden",this.root=new m(this.el),this.render(i)}getGui(){return this.el}refresh(i){return this.render(i),!0}destroy(){this.root?.destroy(),this.root=null}render(i){this.root?.render(e(i))}}}function w(t){if(!t)return;if(typeof t=="function"&&Le(t)||!y(t))return t;let e=ce.get(t);if(e)return e;let o=Je(t);return ce.set(t,o),o}function Qe(t){return class{el=document.createElement("span");root=null;init(o){this.root=new m(this.el),this.render(o)}getGui(){return this.el}refresh(o){return this.render(o),!0}destroy(){this.root?.destroy(),this.root=null}render(o){this.root?.render(C.createElement(t,o))}}}function p(t){if(!t)return;if(typeof t=="function"&&Ge(t)||!y(t))return t;let e=de.get(t);if(e)return e;let o=Qe(t);return de.set(t,o),o}function Ce(t){if(t)return{...t,valueComponent:p(t.valueComponent),selectAllComponent:p(t.selectAllComponent),blanksComponent:p(t.blanksComponent),groupComponent:p(t.groupComponent)}}function Ye(t){return{...t,cellRenderer:S(t.cellRenderer),cellEditor:O(t.cellEditor),tooltipComponent:M(t.tooltipComponent),headerTooltip:se(t.headerTooltip),actionFrameComponent:me(t.actionFrameComponent),filterParams:Ce(t.filterParams),headerComponent:w(t.headerComponent),headerCellComponent:w(t.headerCellComponent),children:t.children?k(t.children)??void 0:void 0}}function k(t){return t==null?t:t.map(e=>Ye(e))}function fe(t){let e={...t};return"cellRenderer"in t&&(e.cellRenderer=S(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=O(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=M(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=se(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=me(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=Ce(t.filterParams)),"headerComponent"in t&&(e.headerComponent=w(t.headerComponent)),"headerCellComponent"in t&&(e.headerCellComponent=w(t.headerCellComponent)),e}function Re(t){if(t!=null)return fe(t)}function A(t){if(t!=null)return fe(t)}function n(t,e,o){o!=null&&(t[e]=o)}function ge(t){let e={};return n(e,"headerHeight",t.headerHeight),n(e,"leafHeaderHeight",t.leafHeaderHeight),n(e,"parentHeaderHeight",t.parentHeaderHeight),n(e,"rowHeight",t.rowHeight),n(e,"pinnedTopRowData",t.pinnedTopRowData),n(e,"pinnedBottomRowData",t.pinnedBottomRowData),n(e,"getRowId",t.getRowId),n(e,"rowIdKey",t.rowIdKey),n(e,"rowDataMode",t.rowDataMode),n(e,"asyncTransactionWaitMs",t.asyncTransactionWaitMs),n(e,"overscanRowCount",t.overscanRowCount),n(e,"minResizeWidth",t.minResizeWidth),n(e,"maxColumnWidth",t.maxColumnWidth),n(e,"pivotMode",t.pivotMode),n(e,"pivotColumns",t.pivotColumns),n(e,"maxPivotColumns",t.maxPivotColumns),n(e,"pivotColumnMoveMode",t.pivotColumnMoveMode),n(e,"autosizeColumnsOnDataChange",t.autosizeColumnsOnDataChange),n(e,"allowExportAsCSV",t.allowExportAsCSV),n(e,"allowExportAsExcel",t.allowExportAsExcel),n(e,"pagination",t.pagination),n(e,"paginationControls",t.paginationControls),n(e,"rowNumbers",t.rowNumbers),n(e,"rowHover",t.rowHover),n(e,"columnHover",t.columnHover),n(e,"zebraRows",t.zebraRows),n(e,"getRowClass",t.getRowClass),n(e,"getRowStyle",t.getRowStyle),n(e,"getRowPresentation",v(t.getRowPresentation)),n(e,"onCellClicked",t.onCellClicked),n(e,"onRowClicked",t.onRowClicked),n(e,"onCellDoubleClicked",t.onCellDoubleClicked),n(e,"onRowDoubleClicked",t.onRowDoubleClicked),n(e,"onCellValueChanged",t.onCellValueChanged),n(e,"onSelectionChanged",t.onSelectionChanged),n(e,"onSortChanged",t.onSortChanged),n(e,"onColumnsChanged",t.onColumnsChanged),n(e,"onPaginationChanged",t.onPaginationChanged),n(e,"onError",t.onError),n(e,"onFilterChanged",t.onFilterChanged),n(e,"onQuickFilterFindChanged",t.onQuickFilterFindChanged),n(e,"onHistoryChanged",t.onHistoryChanged),n(e,"ariaLabel",t.ariaLabel),n(e,"ariaLabelledBy",t.ariaLabelledBy),n(e,"highlightActiveCell",t.highlightActiveCell),n(e,"rowSelection",t.rowSelection),n(e,"cellSelection",t.cellSelection),n(e,"rangeSelection",t.rangeSelection),n(e,"fillHandle",t.fillHandle),n(e,"columnSelection",t.columnSelection),n(e,"headerKeyboardNavigation",t.headerKeyboardNavigation),n(e,"showColumnButtonsOnHover",t.showColumnButtonsOnHover),n(e,"selectAllRowsOnHeaderClick",t.selectAllRowsOnHeaderClick),n(e,"selectAllScope",t.selectAllScope),n(e,"selectionPersistence",t.selectionPersistence),n(e,"clearSelectionOnBodyClick",t.clearSelectionOnBodyClick),n(e,"resetPageOn",t.resetPageOn),n(e,"pageSize",t.pageSize),n(e,"pageSizes",t.pageSizes),n(e,"serverSideBlockSize",t.serverSideBlockSize),n(e,"serverSideMaxBlocks",t.serverSideMaxBlocks),n(e,"rowModelType",t.rowModelType),n(e,"getGroupChildCount",t.getGroupChildCount),n(e,"groupChildCount",t.groupChildCount),n(e,"groupTotalRow",t.groupTotalRow),n(e,"grandTotalRow",t.grandTotalRow),n(e,"groupTotalRowLabel",t.groupTotalRowLabel),n(e,"paginationUnknownTotalTooltip",t.paginationUnknownTotalTooltip),n(e,"undoLimit",t.undoLimit),n(e,"editTrigger",t.editTrigger),n(e,"readOnlyEdit",t.readOnlyEdit),n(e,"initialSort",t.initialSort),n(e,"showSortPriority",t.showSortPriority),n(e,"pinnedRowsEditable",t.pinnedRowsEditable),n(e,"rowPinningMenu",t.rowPinningMenu),n(e,"rowInsertionMenu",t.rowInsertionMenu),n(e,"suppressKeyboardEdit",t.suppressKeyboardEdit),n(e,"suppressTypeToEdit",t.suppressTypeToEdit),n(e,"moveAfterEdit",t.moveAfterEdit),n(e,"commitOnBlur",t.commitOnBlur),n(e,"reevaluateOnEdit",t.reevaluateOnEdit),n(e,"groupDisplayType",t.groupDisplayType),n(e,"groupDefaultExpanded",t.groupDefaultExpanded),n(e,"groupSortMode",t.groupSortMode),n(e,"treeData",t.treeData),n(e,"groupRowsSelectable",t.groupRowsSelectable),n(e,"groupSelectsChildren",t.groupSelectsChildren),n(e,"aggFuncs",t.aggFuncs),n(e,"isRowSelectable",t.isRowSelectable),n(e,"isRowPinned",t.isRowPinned),n(e,"groupRowsSticky",t.groupRowsSticky),n(e,"isFullWidthRow",t.isFullWidthRow),n(e,"tooltip",t.tooltip),n(e,"quickFilter",t.quickFilter),n(e,"columnPanel",t.columnPanel),n(e,"toolbar",t.toolbar),n(e,"savedViews",t.savedViews),n(e,"sheets",t.sheets),n(e,"loadingMessage",t.loadingMessage),n(e,"noRowsMessage",t.noRowsMessage),n(e,"pivotNoValuesMessage",t.pivotNoValuesMessage),n(e,"pivotEmptyMessage",t.pivotEmptyMessage),n(e,"filterDebounceMs",t.filterDebounceMs),n(e,"cellFlashDuration",t.cellFlashDuration),n(e,"cellFadeDuration",t.cellFadeDuration),n(e,"icons",t.icons),n(e,"theme",t.theme),t.fullWidthCellRenderer!=null&&(e.fullWidthCellRenderer=S(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=Re(t.defaultColDef)),t.groupColumnDef!=null&&(e.groupColumnDef=A(t.groupColumnDef)),t.pivotResultColumnDef!=null&&(e.pivotResultColumnDef=A(t.pivotResultColumnDef)),t.bodyContextMenu===!1&&(e.bodyContextMenu=!1),t.multiColumnMenu!=null&&(e.multiColumnMenu=t.multiColumnMenu),t.rowModelType==="serverSide"&&(n(e,"serverSideDataSource",t.serverSideDataSource),n(e,"serverSideAggregationSource",t.serverSideAggregationSource)),n(e,"suppressStyleInjection",t.suppressStyleInjection),n(e,"styleNonce",t.styleNonce),e}import $e from"react";var P=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let i=[],r=o,s=this.opts.getBodyMenuItems?this.opts.getBodyMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(s,i),cleanup:()=>{for(let g of i)g()}}}normalizeItems(e,o){return e.map(i=>{if(i.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(i.left,o),s=this.normalizeSlot(i.right,o);return{...i,left:r,right:s,subMenu:i.subMenu?this.normalizeItems(i.subMenu,o):void 0}})}normalizeSlot(e,o){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if($e.isValidElement(e)){let{el:i,unmount:r}=this.mountReact(e);return o.push(r),i}}}mountReact(e){let o=document.createElement("span");o.style.display="inline-flex",o.style.alignItems="center";let i=new m(o);return i.render(e),{el:o,unmount:()=>i.destroy()}}};import Xe from"react";var E=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let i=[],r=o,s=this.opts.getColumnMenuItems?this.opts.getColumnMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(s,i),cleanup:()=>{for(let g of i)g()}}}normalizeItems(e,o){return e.map(i=>{if(i.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(i.left,o),s=this.normalizeSlot(i.right,o);return{...i,left:r,right:s,subMenu:i.subMenu?this.normalizeItems(i.subMenu,o):void 0}})}normalizeSlot(e,o){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(Xe.isValidElement(e)){let{el:i,unmount:r}=this.mountReact(e);return o.push(r),i}}}mountReact(e){let o=document.createElement("span");o.style.display="inline-flex",o.style.alignItems="center";let i=new m(o);return i.render(e),{el:o,unmount:()=>i.destroy()}}};import{CREATION_ONLY_OPTION_KEYS as Ze}from"@agility-workbench/grid";var et=new Set(["onCellClicked","onRowClicked","onCellDoubleClicked","onRowDoubleClicked","onCellValueChanged","onSelectionChanged","onSortChanged","onColumnsChanged","onPaginationChanged","onError","onFilterChanged","onQuickFilterFindChanged","onHistoryChanged","onBeforeCellCommit","fillOperation","multiColumnMenu"]),tt=Ze.filter(t=>!et.has(t)),nt=["keyboardNavigationMode","enableKeyboardNavigationModeSwitch"],he=Symbol("uncomparable");function ye(t,e){let o=e;if(t==="treeData"&&e!=null&&typeof e=="object"){let i={...e};for(let r of nt)delete i[r];o=i}try{return JSON.stringify(o,(i,r)=>typeof r=="function"?`\u0192 ${String(r)}`:r===void 0?"\u2205undefined":r)??"\u2205undefined"}catch{return he}}function pe(t){let e=new Map;for(let o of tt){let i=t[o];e.set(o,{value:i,fingerprint:ye(o,i)})}return e}function we(){try{return process.env.NODE_ENV!=="production"}catch{return!0}}function ot(t){return`[agility-workbench] <Grid> prop "${t}" changed after the grid was created. It is read only at creation, so the change is ignored. Remount the grid to apply it (for example, change the <Grid>'s React key).`}function Se(t,e,o){for(let[i,r]of e){if(o.has(i))continue;let s=t[i];if(Object.is(s,r.value))continue;let R=ye(i,s);R!==he&&R===r.fingerprint||(o.add(i),console.warn(ot(i)))}}import{jsx as ut}from"react/jsx-runtime";function f(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function at(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var lt=rt.forwardRef(function(e,o){let i=d(null),r=d(null),s=d(e.onGridReady),R=d(e.getColumnMenuItems),g=d(e.bodyContextMenu),x=d(e.multiColumnMenu),I=d(e.onCellClicked),G=d(e.onRowClicked),N=d(e.onCellDoubleClicked),B=d(e.onRowDoubleClicked),L=d(e.onCellValueChanged),V=d(e.onSelectionChanged),K=d(e.onSortChanged),z=d(e.onColumnsChanged),W=d(e.onPaginationChanged),j=d(e.onError),_=d(e.onFilterChanged),U=d(e.onQuickFilterFindChanged),q=d(e.onHistoryChanged),J=d(e.onBeforeCellCommit),Q=d(e.fillOperation);s.current=e.onGridReady,R.current=e.getColumnMenuItems,g.current=e.bodyContextMenu,x.current=e.multiColumnMenu,I.current=e.onCellClicked,G.current=e.onRowClicked,N.current=e.onCellDoubleClicked,B.current=e.onRowDoubleClicked,L.current=e.onCellValueChanged,V.current=e.onSelectionChanged,K.current=e.onSortChanged,z.current=e.onColumnsChanged,W.current=e.onPaginationChanged,j.current=e.onError,_.current=e.onFilterChanged,U.current=e.onQuickFilterFindChanged,q.current=e.onHistoryChanged,J.current=e.onBeforeCellCommit,Q.current=e.fillOperation,l(()=>{let u=i.current;if(!u)return;let c=ge(e);c.onCellClicked=a=>I.current?.(a),c.onRowClicked=a=>G.current?.(a),c.onCellDoubleClicked=a=>N.current?.(a),c.onRowDoubleClicked=a=>B.current?.(a),c.onCellValueChanged=a=>L.current?.(a),c.onSelectionChanged=a=>V.current?.(a),c.onSortChanged=a=>K.current?.(a),c.onColumnsChanged=a=>z.current?.(a),c.onPaginationChanged=a=>W.current?.(a),c.onError=a=>j.current?.(a),c.onFilterChanged=a=>_.current?.(a),c.onQuickFilterFindChanged=a=>U.current?.(a),c.onHistoryChanged=a=>q.current?.(a),c.onBeforeCellCommit=a=>J.current?.(a),c.fillOperation=a=>Q.current?.(a),e.multiColumnMenu!==!1&&(c.multiColumnMenu=a=>{let h=x.current;return h===!1?[]:typeof h!="function"?a.items:h(a)});let b=it(u,{...c,menuAdapter:new E({getColumnMenuItems:a=>R.current?.(a)??a.items}),bodyMenuAdapter:new P({getBodyMenuItems:a=>{let h=g.current;return typeof h=="function"?h(a):a.items}})}),F={api:b,destroyed:!1,appliedServerSideDataSource:c.serverSideDataSource,creationOnly:we()?{snapshot:pe(e),warned:new Set}:null};return r.current=F,f(o,b),f(e.apiRef,b),()=>{r.current===F&&(r.current=null),f(o,null),f(e.apiRef,null),at(F)}},[]),l(()=>{let u=r.current?.api??null;return f(o,u),f(e.apiRef,u),()=>{f(o,null),f(e.apiRef,null)}},[o,e.apiRef]),l(()=>{let u=r.current?.api;u&&u.updateGridOptions({columnDefs:k(e.columnDefs)})},[e.columnDefs]),l(()=>{let u=r.current?.api;u&&e.rowModelType!=="serverSide"&&u.setRowData(e.rowData??e.data??[])},[e.data,e.rowData,e.rowModelType]);let T=d(null);l(()=>{let u=r.current;if(!(!u||T.current===u))return T.current=u,s.current?.(u.api),()=>{T.current=null}},[]),l(()=>{let u=r.current?.creationOnly;u&&Se(e,u.snapshot,u.warned)}),l(()=>{r.current?.api.updateGridOptions({groupDisplayType:e.groupDisplayType})},[e.groupDisplayType]),l(()=>{r.current?.api.updateGridOptions({groupSortMode:e.groupSortMode})},[e.groupSortMode]),l(()=>{r.current?.api.updateGridOptions({groupRowsSelectable:e.groupRowsSelectable})},[e.groupRowsSelectable]),l(()=>{r.current?.api.updateGridOptions({groupChildCount:e.groupChildCount})},[e.groupChildCount]),l(()=>{r.current?.api.updateGridOptions({groupTotalRow:e.groupTotalRow,grandTotalRow:e.grandTotalRow})},[e.groupTotalRow,e.grandTotalRow]),l(()=>{r.current?.api.updateGridOptions({groupTotalRowLabel:e.groupTotalRowLabel})},[e.groupTotalRowLabel]),l(()=>{r.current?.api.updateGridOptions({headerHeight:e.headerHeight,leafHeaderHeight:e.leafHeaderHeight,parentHeaderHeight:e.parentHeaderHeight})},[e.headerHeight,e.leafHeaderHeight,e.parentHeaderHeight]),l(()=>{r.current?.api.updateGridOptions({pivotColumnMoveMode:e.pivotColumnMoveMode})},[e.pivotColumnMoveMode]);let Y=d(!1);l(()=>{if(!Y.current){Y.current=!0;return}e.pivotMode!=null&&r.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let Me=JSON.stringify(e.pivotColumns??null),$=d(!1);l(()=>{if(!$.current){$.current=!0;return}e.pivotColumns!=null&&r.current?.api.setPivotColumns(e.pivotColumns)},[Me]),l(()=>{r.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let ve=JSON.stringify(e.rowSelection??null),X=d(!1);l(()=>{if(!X.current){X.current=!0;return}r.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[ve]),l(()=>{r.current?.api.setTreeDataKeyboardNavigationOptions({keyboardNavigationMode:e.treeData?.keyboardNavigationMode,enableKeyboardNavigationModeSwitch:e.treeData?.enableKeyboardNavigationModeSwitch??!1})},[e.treeData?.keyboardNavigationMode,e.treeData?.enableKeyboardNavigationModeSwitch]),l(()=>{r.current?.api.updateGridOptions({pinnedTopRowData:e.pinnedTopRowData,pinnedBottomRowData:e.pinnedBottomRowData,isRowPinned:e.isRowPinned,groupRowsSticky:e.groupRowsSticky})},[e.pinnedTopRowData,e.pinnedBottomRowData,e.isRowPinned,e.groupRowsSticky]),l(()=>{r.current?.api.updateGridOptions({rowHover:e.rowHover??!0,columnHover:e.columnHover??!1,zebraRows:e.zebraRows??!1,getRowClass:e.getRowClass,getRowStyle:e.getRowStyle,getRowPresentation:v(e.getRowPresentation),ariaLabel:e.ariaLabel,ariaLabelledBy:e.ariaLabelledBy,highlightActiveCell:e.highlightActiveCell??!1,cellSelection:e.cellSelection??!0,rangeSelection:e.rangeSelection??!0,fillHandle:e.fillHandle??!0,columnSelection:e.columnSelection??!0,headerKeyboardNavigation:e.headerKeyboardNavigation??!0,showColumnButtonsOnHover:e.showColumnButtonsOnHover??!1,bodyContextMenu:e.bodyContextMenu!==!1,editTrigger:e.editTrigger??"doubleClick",readOnlyEdit:e.readOnlyEdit??!1,pinnedRowsEditable:e.pinnedRowsEditable??!1,rowPinningMenu:e.rowPinningMenu??!1,rowInsertionMenu:e.rowInsertionMenu,suppressKeyboardEdit:e.suppressKeyboardEdit??!1,suppressTypeToEdit:e.suppressTypeToEdit??!1,moveAfterEdit:e.moveAfterEdit??!0,commitOnBlur:e.commitOnBlur??!0,asyncTransactionWaitMs:e.asyncTransactionWaitMs??16,loadingMessage:e.loadingMessage,noRowsMessage:e.noRowsMessage})},[e.rowHover,e.columnHover,e.zebraRows,e.getRowClass,e.getRowStyle,e.getRowPresentation,e.ariaLabel,e.ariaLabelledBy,e.highlightActiveCell,e.cellSelection,e.rangeSelection,e.fillHandle,e.columnSelection,e.headerKeyboardNavigation,e.showColumnButtonsOnHover,e.bodyContextMenu,e.editTrigger,e.readOnlyEdit,e.pinnedRowsEditable,e.rowPinningMenu,e.rowInsertionMenu,e.suppressKeyboardEdit,e.suppressTypeToEdit,e.moveAfterEdit,e.commitOnBlur,e.asyncTransactionWaitMs,e.loadingMessage,e.noRowsMessage]),l(()=>{let u=r.current;!u||e.rowModelType!=="serverSide"||e.serverSideDataSource&&e.serverSideDataSource!==u.appliedServerSideDataSource&&(u.appliedServerSideDataSource=e.serverSideDataSource,u.api.updateGridOptions({serverSideDataSource:e.serverSideDataSource}))},[e.rowModelType,e.serverSideDataSource]),l(()=>{let u=r.current;!u||e.rowModelType!=="serverSide"||e.serverSideAggregationSource&&u.api.updateGridOptions({serverSideAggregationSource:e.serverSideAggregationSource})},[e.rowModelType,e.serverSideAggregationSource]),l(()=>{let u=r.current?.api;u&&u.dispatch({type:"overlayShow",overlayType:e.loading?"loading":"none"})},[e.loading]),l(()=>{r.current?.api.updateGridOptions({pagination:e.pagination})},[e.pagination]);let Pe=JSON.stringify(e.paginationControls??null),Z=d(!1);l(()=>{if(!Z.current){Z.current=!0;return}r.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[Pe]);let Ee=JSON.stringify(e.quickFilter??null),ee=d(!1);l(()=>{if(!ee.current){ee.current=!0;return}r.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[Ee]);let Te=JSON.stringify(e.tooltip??null),te=d(!1);l(()=>{if(!te.current){te.current=!0;return}r.current?.api.updateGridOptions({tooltip:e.tooltip})},[Te]);let be=JSON.stringify(e.columnPanel??null),ne=d(!1);l(()=>{if(!ne.current){ne.current=!0;return}r.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[be]);let Fe=JSON.stringify(e.toolbar??null),oe=d(!1);return l(()=>{if(!oe.current){oe.current=!0;return}r.current?.api.updateGridOptions({toolbar:e.toolbar})},[Fe]),l(()=>{r.current?.api.updateGridOptions({savedViews:e.savedViews})},[e.savedViews]),l(()=>{r.current?.api.updateGridOptions({sheets:e.sheets})},[e.sheets]),l(()=>{r.current?.api.updateGridOptions({theme:e.theme,icons:{...e.theme?.getIcons(),...e.icons}})},[e.theme,e.icons]),ut("div",{ref:i,className:e.className,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...e.style}})});export{lt as Grid};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility-workbench/react-grid",
3
- "version": "1.10.1",
3
+ "version": "1.12.0",
4
4
  "description": "React bindings for @agility-workbench/grid — a high-performance data grid.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -61,7 +61,7 @@
61
61
  "prepublishOnly": "npm run build"
62
62
  },
63
63
  "dependencies": {
64
- "@agility-workbench/grid": "^1.10.1"
64
+ "@agility-workbench/grid": "^1.12.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": ">=18.0.0",