@agility-workbench/react-grid 1.10.1 → 1.11.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 +19 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +28 -4
- package/dist/index.d.ts +28 -4
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -110,6 +110,25 @@ 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
|
+
### React components in the grid
|
|
123
|
+
|
|
124
|
+
`ReactColDef` component slots accept React components: `cellRenderer`, `cellEditor`,
|
|
125
|
+
`tooltipComponent`, `headerTooltip`, `actionFrameComponent`, the set-filter components in
|
|
126
|
+
`filterParams`, and the header components `headerComponent` (header content) and
|
|
127
|
+
`headerCellComponent` (the whole header cell). Header components receive `HeaderComponentParams`
|
|
128
|
+
as props and re-render on sort/filter changes. The same slots are adapted in `defaultColDef`,
|
|
129
|
+
`groupColumnDef`, and `pivotResultColumnDef`. Core class components (and a header function
|
|
130
|
+
returning an `HTMLElement`) pass through unchanged.
|
|
131
|
+
|
|
113
132
|
## Styling
|
|
114
133
|
|
|
115
134
|
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 ze=Object.create;var w=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var _e=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty;var qe=(t,e)=>{for(var n in e)w(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of je(e))!Ue.call(t,r)&&r!==n&&w(t,r,{get:()=>e[r],enumerable:!(a=We(e,r))||a.enumerable});return t},M=(t,e,n)=>(S(t,e,"default"),n&&S(n,e,"default")),h=(t,e,n)=>(n=t!=null?ze(_e(t)):{},S(e||!t||!t.__esModule?w(n,"default",{value:t,enumerable:!0}):n,t)),Je=t=>S(w({},"__esModule",{value:!0}),t);var p={};qe(p,{Grid:()=>Ie});module.exports=Je(p);M(p,require("@agility-workbench/grid"),module.exports);var i=h(require("react"),1),ke=require("@agility-workbench/grid");var m=h(require("react"),1);var le=require("react-dom"),ue=require("react-dom/client"),A=new Set,x=!1;function Qe(){x=!1;let t=Array.from(A);A.clear();for(let e of t)e.unmount()}function Ye(t){A.add(t),!x&&(x=!0,queueMicrotask(Qe))}var s=class{root;constructor(e){this.root=(0,ue.createRoot)(e)}render(e){this.root?.render(e)}renderSync(e){let n=this.root;n&&(0,le.flushSync)(()=>n.render(e))}destroy(){let e=this.root;e&&(this.root=null,Ye(e))}};var E=require("@agility-workbench/grid"),Re=require("@agility-workbench/grid"),ge=require("@agility-workbench/grid"),he=require("@agility-workbench/grid");var G=h(require("react"),1);var de=new WeakMap;function $e(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=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"||$e(t))return t;let e=de.get(t);if(e)return e;let n=Xe(t);return de.set(t,n),n}var ce=new WeakMap,se=new WeakMap,me=new WeakMap,Ce=new WeakMap,fe=new WeakMap;function y(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function Ze(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function et(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,Ze(n)))}}}function b(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=et(t);return ce.set(t,n),n}function tt(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function nt(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,tt(n)))}}}function T(t){if(!t)return;if(typeof t=="function"&&(0,Re.isClassTooltipComponent)(t)||!y(t))return t;let e=se.get(t);if(e)return e;let n=nt(t);return se.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:T(n.tooltip.component)}}}}function ye(t){return t==null||typeof t=="string"?t:T(t)}function ot(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function rt(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,ot(n)))}}}function pe(t){if(!t)return;if(typeof t=="function"&&(0,ge.isClassActionFrameComponent)(t)||!y(t))return t;let e=me.get(t);if(e)return e;let n=rt(t);return me.set(t,n),n}function it({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 at(t){if(!(typeof t=="function"&&!t.prototype?.isReactComponent))return r=>m.default.createElement(t,r);let n=t;function a(r){let d=n(r);return d instanceof HTMLElement?m.default.createElement(it,{node:d}):d}return r=>m.default.createElement(a,r)}function lt(t){let e=at(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,he.isClassHeaderComponent)(t)||!y(t))return t;let e=fe.get(t);if(e)return e;let n=lt(t);return fe.set(t,n),n}function ut(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=Ce.get(t);if(e)return e;let n=ut(t);return Ce.set(t,n),n}function Se(t){if(t)return{...t,valueComponent:v(t.valueComponent),selectAllComponent:v(t.selectAllComponent),blanksComponent:v(t.blanksComponent),groupComponent:v(t.groupComponent)}}function dt(t){return{...t,cellRenderer:b(t.cellRenderer),cellEditor:N(t.cellEditor),tooltipComponent:T(t.tooltipComponent),headerTooltip:ye(t.headerTooltip),actionFrameComponent:pe(t.actionFrameComponent),filterParams:Se(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=>dt(e))}function we(t){let e={...t};return"cellRenderer"in t&&(e.cellRenderer=b(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=N(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=T(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=ye(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=pe(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=Se(t.filterParams)),"headerComponent"in t&&(e.headerComponent=P(t.headerComponent)),"headerCellComponent"in t&&(e.headerCellComponent=P(t.headerCellComponent)),e}function Me(t){if(t!=null)return we(t)}function L(t){if(t!=null)return we(t)}function o(t,e,n){n!=null&&(t[e]=n)}function ve(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,"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,"rowModelType",t.rowModelType),o(e,"getGroupChildCount",t.getGroupChildCount),o(e,"groupChildCount",t.groupChildCount),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,"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=b(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=Me(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 Pe=h(require("react"),1);var D=class{constructor(e){this.opts=e}resolveMenuItems(e,n){let a=[],r=n,d=this.opts.getBodyMenuItems?this.opts.getBodyMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(d,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),d=this.normalizeSlot(a.right,n);return{...a,left:r,right:d,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(Pe.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 Ee=h(require("react"),1);var H=class{constructor(e){this.opts=e}resolveMenuItems(e,n){let a=[],r=n,d=this.opts.getColumnMenuItems?this.opts.getColumnMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(d,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),d=this.normalizeSlot(a.right,n);return{...a,left:r,right:d,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(Ee.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 be=require("@agility-workbench/grid"),ct=new Set(["onCellClicked","onRowClicked","onCellDoubleClicked","onRowDoubleClicked","onCellValueChanged","onSelectionChanged","onSortChanged","onFilterChanged","onQuickFilterFindChanged","onHistoryChanged","onBeforeCellCommit","fillOperation","multiColumnMenu"]),st=be.CREATION_ONLY_OPTION_KEYS.filter(t=>!ct.has(t)),mt=["keyboardNavigationMode","enableKeyboardNavigationModeSwitch"],Te=Symbol("uncomparable");function Fe(t,e){let n=e;if(t==="treeData"&&e!=null&&typeof e=="object"){let a={...e};for(let r of mt)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 Te}}function De(t){let e=new Map;for(let n of st){let a=t[n];e.set(n,{value:a,fingerprint:Fe(n,a)})}return e}function He(){try{return process.env.NODE_ENV!=="production"}catch{return!0}}function Ct(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 Oe(t,e,n){for(let[a,r]of e){if(n.has(a))continue;let d=t[a];if(Object.is(d,r.value))continue;let f=Fe(a,d);f!==Te&&f===r.fingerprint||(n.add(a),console.warn(Ct(a)))}}var Ae=require("react/jsx-runtime");function C(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function ft(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var Ie=i.default.forwardRef(function(e,n){let a=(0,i.useRef)(null),r=(0,i.useRef)(null),d=(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.onFilterChanged),Q=(0,i.useRef)(e.onQuickFilterFindChanged),Y=(0,i.useRef)(e.onHistoryChanged),$=(0,i.useRef)(e.onBeforeCellCommit),X=(0,i.useRef)(e.fillOperation);d.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.onFilterChanged,Q.current=e.onQuickFilterFindChanged,Y.current=e.onHistoryChanged,$.current=e.onBeforeCellCommit,X.current=e.fillOperation,(0,i.useLayoutEffect)(()=>{let u=a.current;if(!u)return;let c=ve(e);c.onCellClicked=l=>K.current?.(l),c.onRowClicked=l=>z.current?.(l),c.onCellDoubleClicked=l=>W.current?.(l),c.onRowDoubleClicked=l=>j.current?.(l),c.onCellValueChanged=l=>_.current?.(l),c.onSelectionChanged=l=>U.current?.(l),c.onSortChanged=l=>q.current?.(l),c.onFilterChanged=l=>J.current?.(l),c.onQuickFilterFindChanged=l=>Q.current?.(l),c.onHistoryChanged=l=>Y.current?.(l),c.onBeforeCellCommit=l=>$.current?.(l),c.fillOperation=l=>X.current?.(l),e.multiColumnMenu!==!1&&(c.multiColumnMenu=l=>{let g=V.current;return g===!1?[]:typeof g!="function"?l.items:g(l)});let k=(0,ke.createGrid)(u,{...c,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}})}),I={api:k,destroyed:!1,appliedServerSideDataSource:c.serverSideDataSource,creationOnly:He()?{snapshot:De(e),warned:new Set}:null};return r.current=I,C(n,k),C(e.apiRef,k),()=>{r.current===I&&(r.current=null),C(n,null),C(e.apiRef,null),ft(I)}},[]),(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,d.current?.(u.api),()=>{O.current=null}},[]),(0,i.useLayoutEffect)(()=>{let u=r.current?.creationOnly;u&&Oe(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({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 Z=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!Z.current){Z.current=!0;return}e.pivotMode!=null&&r.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let xe=JSON.stringify(e.pivotColumns??null),ee=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ee.current){ee.current=!0;return}e.pivotColumns!=null&&r.current?.api.setPivotColumns(e.pivotColumns)},[xe]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let Ge=JSON.stringify(e.rowSelection??null),te=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!te.current){te.current=!0;return}r.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[Ge]),(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 Ne=JSON.stringify(e.paginationControls??null),ne=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ne.current){ne.current=!0;return}r.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[Ne]);let Be=JSON.stringify(e.quickFilter??null),oe=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!oe.current){oe.current=!0;return}r.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[Be]);let Le=JSON.stringify(e.tooltip??null),re=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!re.current){re.current=!0;return}r.current?.api.updateGridOptions({tooltip:e.tooltip})},[Le]);let Ve=JSON.stringify(e.columnPanel??null),ie=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ie.current){ie.current=!0;return}r.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[Ve]);let Ke=JSON.stringify(e.toolbar??null),ae=(0,i.useRef)(!1);return(0,i.useLayoutEffect)(()=>{if(!ae.current){ae.current=!0;return}r.current?.api.updateGridOptions({toolbar:e.toolbar})},[Ke]),(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,Ae.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, 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"> & {
|
|
53
|
+
type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams" | "headerComponent" | "headerCellComponent"> & {
|
|
48
54
|
cellRenderer?: CellRenderer | 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, 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"> & {
|
|
53
|
+
type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams" | "headerComponent" | "headerCellComponent"> & {
|
|
48
54
|
cellRenderer?: CellRenderer | 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 tt,{useLayoutEffect as u,useRef as d}from"react";import{createGrid as nt}from"@agility-workbench/grid";import C from"react";import{flushSync as be}from"react-dom";import{createRoot as Te}from"react-dom/client";var D=new Set,H=!1;function Fe(){H=!1;let t=Array.from(D);D.clear();for(let e of t)e.unmount()}function De(t){D.add(t),!H&&(H=!0,queueMicrotask(Fe))}var m=class{root;constructor(e){this.root=Te(e)}render(e){this.root?.render(e)}renderSync(e){let n=this.root;n&&be(()=>n.render(e))}destroy(){let e=this.root;e&&(this.root=null,De(e))}};import{isClassRenderer as ke,isClassSetFilterComponent as Ie}from"@agility-workbench/grid";import{isClassTooltipComponent as Ae}from"@agility-workbench/grid";import{isClassActionFrameComponent as xe}from"@agility-workbench/grid";import{isClassHeaderComponent as Ge}from"@agility-workbench/grid";import te from"react";var ne=new WeakMap;function He(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function Oe(t){return class{el=document.createElement("div");root=null;handle=te.createRef();init(n){this.el.style.width="100%",this.el.style.height="100%",this.root=new m(this.el);let i=te.createElement(t,{...n,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 n=this.root;this.root=null,n?.destroy()}}}function O(t){if(t==null)return;if(typeof t=="string"||He(t))return t;let e=ne.get(t);if(e)return e;let n=Oe(t);return ne.set(t,n),n}var oe=new WeakMap,re=new WeakMap,ie=new WeakMap,ae=new WeakMap,le=new WeakMap;function y(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function Ne(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function Be(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 m(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(C.createElement(t,Ne(n)))}}}function w(t){if(!t)return;if(typeof t=="function"&&ke(t)||!y(t))return t;let e=oe.get(t);if(e)return e;let n=Be(t);return oe.set(t,n),n}function Le(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function Ve(t){return class{el=document.createElement("div");root=null;init(n){this.root=new m(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(C.createElement(t,Le(n)))}}}function M(t){if(!t)return;if(typeof t=="function"&&Ae(t)||!y(t))return t;let e=re.get(t);if(e)return e;let n=Ve(t);return re.set(t,n),n}function v(t){if(t)return e=>{let n=t(e);return!n||typeof n.tooltip!="object"||n.tooltip==null?n:{...n,tooltip:{...n.tooltip,component:M(n.tooltip.component)}}}}function ue(t){return t==null||typeof t=="string"?t:M(t)}function Ke(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function ze(t){return class{el=document.createElement("div");root=null;init(n){this.root=new m(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(C.createElement(t,Ke(n)))}}}function de(t){if(!t)return;if(typeof t=="function"&&xe(t)||!y(t))return t;let e=ie.get(t);if(e)return e;let n=ze(t);return ie.set(t,n),n}function We({node:t}){let e=C.useRef(null);return C.useLayoutEffect(()=>{let n=e.current;n&&n.firstChild!==t&&n.replaceChildren(t)},[t]),C.createElement("span",{ref:e,style:{display:"contents"}})}function je(t){if(!(typeof t=="function"&&!t.prototype?.isReactComponent))return r=>C.createElement(t,r);let n=t;function i(r){let c=n(r);return c instanceof HTMLElement?C.createElement(We,{node:c}):c}return r=>C.createElement(i,r)}function _e(t){let e=je(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 S(t){if(!t)return;if(typeof t=="function"&&Ge(t)||!y(t))return t;let e=le.get(t);if(e)return e;let n=_e(t);return le.set(t,n),n}function Ue(t){return class{el=document.createElement("span");root=null;init(n){this.root=new m(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(C.createElement(t,n))}}}function p(t){if(!t)return;if(typeof t=="function"&&Ie(t)||!y(t))return t;let e=ae.get(t);if(e)return e;let n=Ue(t);return ae.set(t,n),n}function ce(t){if(t)return{...t,valueComponent:p(t.valueComponent),selectAllComponent:p(t.selectAllComponent),blanksComponent:p(t.blanksComponent),groupComponent:p(t.groupComponent)}}function qe(t){return{...t,cellRenderer:w(t.cellRenderer),cellEditor:O(t.cellEditor),tooltipComponent:M(t.tooltipComponent),headerTooltip:ue(t.headerTooltip),actionFrameComponent:de(t.actionFrameComponent),filterParams:ce(t.filterParams),headerComponent:S(t.headerComponent),headerCellComponent:S(t.headerCellComponent),children:t.children?k(t.children)??void 0:void 0}}function k(t){return t==null?t:t.map(e=>qe(e))}function se(t){let e={...t};return"cellRenderer"in t&&(e.cellRenderer=w(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=O(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=M(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=ue(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=de(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=ce(t.filterParams)),"headerComponent"in t&&(e.headerComponent=S(t.headerComponent)),"headerCellComponent"in t&&(e.headerCellComponent=S(t.headerCellComponent)),e}function me(t){if(t!=null)return se(t)}function I(t){if(t!=null)return se(t)}function o(t,e,n){n!=null&&(t[e]=n)}function Ce(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",v(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,"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,"rowModelType",t.rowModelType),o(e,"getGroupChildCount",t.getGroupChildCount),o(e,"groupChildCount",t.groupChildCount),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,"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=w(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=me(t.defaultColDef)),t.groupColumnDef!=null&&(e.groupColumnDef=I(t.groupColumnDef)),t.pivotResultColumnDef!=null&&(e.pivotResultColumnDef=I(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}import Je from"react";var P=class{constructor(e){this.opts=e}resolveMenuItems(e,n){let i=[],r=n,c=this.opts.getBodyMenuItems?this.opts.getBodyMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(c,i),cleanup:()=>{for(let g of i)g()}}}normalizeItems(e,n){return e.map(i=>{if(i.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(i.left,n),c=this.normalizeSlot(i.right,n);return{...i,left:r,right:c,subMenu:i.subMenu?this.normalizeItems(i.subMenu,n):void 0}})}normalizeSlot(e,n){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(Je.isValidElement(e)){let{el:i,unmount:r}=this.mountReact(e);return n.push(r),i}}}mountReact(e){let n=document.createElement("span");n.style.display="inline-flex",n.style.alignItems="center";let i=new m(n);return i.render(e),{el:n,unmount:()=>i.destroy()}}};import Qe from"react";var E=class{constructor(e){this.opts=e}resolveMenuItems(e,n){let i=[],r=n,c=this.opts.getColumnMenuItems?this.opts.getColumnMenuItems({ctx:e,items:r}):r;return{items:this.normalizeItems(c,i),cleanup:()=>{for(let g of i)g()}}}normalizeItems(e,n){return e.map(i=>{if(i.isSeparator)return{isSeparator:!0};let r=this.normalizeSlot(i.left,n),c=this.normalizeSlot(i.right,n);return{...i,left:r,right:c,subMenu:i.subMenu?this.normalizeItems(i.subMenu,n):void 0}})}normalizeSlot(e,n){if(e){if(typeof e=="string"||e instanceof HTMLElement)return e;if(Qe.isValidElement(e)){let{el:i,unmount:r}=this.mountReact(e);return n.push(r),i}}}mountReact(e){let n=document.createElement("span");n.style.display="inline-flex",n.style.alignItems="center";let i=new m(n);return i.render(e),{el:n,unmount:()=>i.destroy()}}};import{CREATION_ONLY_OPTION_KEYS as Ye}from"@agility-workbench/grid";var $e=new Set(["onCellClicked","onRowClicked","onCellDoubleClicked","onRowDoubleClicked","onCellValueChanged","onSelectionChanged","onSortChanged","onFilterChanged","onQuickFilterFindChanged","onHistoryChanged","onBeforeCellCommit","fillOperation","multiColumnMenu"]),Xe=Ye.filter(t=>!$e.has(t)),Ze=["keyboardNavigationMode","enableKeyboardNavigationModeSwitch"],fe=Symbol("uncomparable");function Re(t,e){let n=e;if(t==="treeData"&&e!=null&&typeof e=="object"){let i={...e};for(let r of Ze)delete i[r];n=i}try{return JSON.stringify(n,(i,r)=>typeof r=="function"?`\u0192 ${String(r)}`:r===void 0?"\u2205undefined":r)??"\u2205undefined"}catch{return fe}}function ge(t){let e=new Map;for(let n of Xe){let i=t[n];e.set(n,{value:i,fingerprint:Re(n,i)})}return e}function he(){try{return process.env.NODE_ENV!=="production"}catch{return!0}}function et(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 ye(t,e,n){for(let[i,r]of e){if(n.has(i))continue;let c=t[i];if(Object.is(c,r.value))continue;let R=Re(i,c);R!==fe&&R===r.fingerprint||(n.add(i),console.warn(et(i)))}}import{jsx as it}from"react/jsx-runtime";function f(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function ot(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var rt=tt.forwardRef(function(e,n){let i=d(null),r=d(null),c=d(e.onGridReady),R=d(e.getColumnMenuItems),g=d(e.bodyContextMenu),A=d(e.multiColumnMenu),x=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.onFilterChanged),W=d(e.onQuickFilterFindChanged),j=d(e.onHistoryChanged),_=d(e.onBeforeCellCommit),U=d(e.fillOperation);c.current=e.onGridReady,R.current=e.getColumnMenuItems,g.current=e.bodyContextMenu,A.current=e.multiColumnMenu,x.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.onFilterChanged,W.current=e.onQuickFilterFindChanged,j.current=e.onHistoryChanged,_.current=e.onBeforeCellCommit,U.current=e.fillOperation,u(()=>{let l=i.current;if(!l)return;let s=Ce(e);s.onCellClicked=a=>x.current?.(a),s.onRowClicked=a=>G.current?.(a),s.onCellDoubleClicked=a=>N.current?.(a),s.onRowDoubleClicked=a=>B.current?.(a),s.onCellValueChanged=a=>L.current?.(a),s.onSelectionChanged=a=>V.current?.(a),s.onSortChanged=a=>K.current?.(a),s.onFilterChanged=a=>z.current?.(a),s.onQuickFilterFindChanged=a=>W.current?.(a),s.onHistoryChanged=a=>j.current?.(a),s.onBeforeCellCommit=a=>_.current?.(a),s.fillOperation=a=>U.current?.(a),e.multiColumnMenu!==!1&&(s.multiColumnMenu=a=>{let h=A.current;return h===!1?[]:typeof h!="function"?a.items:h(a)});let T=nt(l,{...s,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:T,destroyed:!1,appliedServerSideDataSource:s.serverSideDataSource,creationOnly:he()?{snapshot:ge(e),warned:new Set}:null};return r.current=F,f(n,T),f(e.apiRef,T),()=>{r.current===F&&(r.current=null),f(n,null),f(e.apiRef,null),ot(F)}},[]),u(()=>{let l=r.current?.api??null;return f(n,l),f(e.apiRef,l),()=>{f(n,null),f(e.apiRef,null)}},[n,e.apiRef]),u(()=>{let l=r.current?.api;l&&l.updateGridOptions({columnDefs:k(e.columnDefs)})},[e.columnDefs]),u(()=>{let l=r.current?.api;l&&e.rowModelType!=="serverSide"&&l.setRowData(e.rowData??e.data??[])},[e.data,e.rowData,e.rowModelType]);let b=d(null);u(()=>{let l=r.current;if(!(!l||b.current===l))return b.current=l,c.current?.(l.api),()=>{b.current=null}},[]),u(()=>{let l=r.current?.creationOnly;l&&ye(e,l.snapshot,l.warned)}),u(()=>{r.current?.api.updateGridOptions({groupDisplayType:e.groupDisplayType})},[e.groupDisplayType]),u(()=>{r.current?.api.updateGridOptions({groupSortMode:e.groupSortMode})},[e.groupSortMode]),u(()=>{r.current?.api.updateGridOptions({groupRowsSelectable:e.groupRowsSelectable})},[e.groupRowsSelectable]),u(()=>{r.current?.api.updateGridOptions({groupChildCount:e.groupChildCount})},[e.groupChildCount]),u(()=>{r.current?.api.updateGridOptions({headerHeight:e.headerHeight,leafHeaderHeight:e.leafHeaderHeight,parentHeaderHeight:e.parentHeaderHeight})},[e.headerHeight,e.leafHeaderHeight,e.parentHeaderHeight]),u(()=>{r.current?.api.updateGridOptions({pivotColumnMoveMode:e.pivotColumnMoveMode})},[e.pivotColumnMoveMode]);let q=d(!1);u(()=>{if(!q.current){q.current=!0;return}e.pivotMode!=null&&r.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let pe=JSON.stringify(e.pivotColumns??null),J=d(!1);u(()=>{if(!J.current){J.current=!0;return}e.pivotColumns!=null&&r.current?.api.setPivotColumns(e.pivotColumns)},[pe]),u(()=>{r.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let Se=JSON.stringify(e.rowSelection??null),Q=d(!1);u(()=>{if(!Q.current){Q.current=!0;return}r.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[Se]),u(()=>{r.current?.api.setTreeDataKeyboardNavigationOptions({keyboardNavigationMode:e.treeData?.keyboardNavigationMode,enableKeyboardNavigationModeSwitch:e.treeData?.enableKeyboardNavigationModeSwitch??!1})},[e.treeData?.keyboardNavigationMode,e.treeData?.enableKeyboardNavigationModeSwitch]),u(()=>{r.current?.api.updateGridOptions({pinnedTopRowData:e.pinnedTopRowData,pinnedBottomRowData:e.pinnedBottomRowData,isRowPinned:e.isRowPinned,groupRowsSticky:e.groupRowsSticky})},[e.pinnedTopRowData,e.pinnedBottomRowData,e.isRowPinned,e.groupRowsSticky]),u(()=>{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]),u(()=>{let l=r.current;!l||e.rowModelType!=="serverSide"||e.serverSideDataSource&&e.serverSideDataSource!==l.appliedServerSideDataSource&&(l.appliedServerSideDataSource=e.serverSideDataSource,l.api.updateGridOptions({serverSideDataSource:e.serverSideDataSource}))},[e.rowModelType,e.serverSideDataSource]),u(()=>{let l=r.current;!l||e.rowModelType!=="serverSide"||e.serverSideAggregationSource&&l.api.updateGridOptions({serverSideAggregationSource:e.serverSideAggregationSource})},[e.rowModelType,e.serverSideAggregationSource]),u(()=>{let l=r.current?.api;l&&l.dispatch({type:"overlayShow",overlayType:e.loading?"loading":"none"})},[e.loading]),u(()=>{r.current?.api.updateGridOptions({pagination:e.pagination})},[e.pagination]);let we=JSON.stringify(e.paginationControls??null),Y=d(!1);u(()=>{if(!Y.current){Y.current=!0;return}r.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[we]);let Me=JSON.stringify(e.quickFilter??null),$=d(!1);u(()=>{if(!$.current){$.current=!0;return}r.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[Me]);let ve=JSON.stringify(e.tooltip??null),X=d(!1);u(()=>{if(!X.current){X.current=!0;return}r.current?.api.updateGridOptions({tooltip:e.tooltip})},[ve]);let Pe=JSON.stringify(e.columnPanel??null),Z=d(!1);u(()=>{if(!Z.current){Z.current=!0;return}r.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[Pe]);let Ee=JSON.stringify(e.toolbar??null),ee=d(!1);return u(()=>{if(!ee.current){ee.current=!0;return}r.current?.api.updateGridOptions({toolbar:e.toolbar})},[Ee]),u(()=>{r.current?.api.updateGridOptions({savedViews:e.savedViews})},[e.savedViews]),u(()=>{r.current?.api.updateGridOptions({sheets:e.sheets})},[e.sheets]),u(()=>{r.current?.api.updateGridOptions({theme:e.theme,icons:{...e.theme?.getIcons(),...e.icons}})},[e.theme,e.icons]),it("div",{ref:i,className:e.className,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...e.style}})});export{rt as Grid};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agility-workbench/react-grid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.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.
|
|
64
|
+
"@agility-workbench/grid": "^1.11.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"react": ">=18.0.0",
|