@agility-workbench/react-grid 1.9.0 → 1.10.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var De=Object.create;var S=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var xe=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Oe=(t,e)=>{for(var o in e)S(t,o,{get:e[o],enumerable:!0})},h=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ke(e))!Ge.call(t,r)&&r!==o&&S(t,r,{get:()=>e[r],enumerable:!(a=Ae(e,r))||a.enumerable});return t},w=(t,e,o)=>(h(t,e,"default"),o&&h(o,e,"default")),f=(t,e,o)=>(o=t!=null?De(xe(t)):{},h(e||!t||!t.__esModule?S(o,"default",{value:t,enumerable:!0}):o,t)),He=t=>h(S({},"__esModule",{value:!0}),t);var g={};Oe(g,{Grid:()=>pe});module.exports=He(g);w(g,require("@agility-workbench/grid"),module.exports);var i=f(require("react"),1),we=require("@agility-workbench/grid");var R=f(require("react"),1);var ie=require("react-dom"),re=require("react-dom/client"),k=new Set,x=!1;function Be(){x=!1;let t=Array.from(k);k.clear();for(let e of t)e.unmount()}function Ve(t){k.add(t),!x&&(x=!0,queueMicrotask(Be))}var d=class{root;constructor(e){this.root=(0,re.createRoot)(e)}render(e){this.root?.render(e)}renderSync(e){let o=this.root;o&&(0,ie.flushSync)(()=>o.render(e))}destroy(){let e=this.root;e&&(this.root=null,Ve(e))}};var v=require("@agility-workbench/grid"),se=require("@agility-workbench/grid"),me=require("@agility-workbench/grid");var G=f(require("react"),1);var ae=new WeakMap;function Ne(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function Le(t){return class{el=document.createElement("div");root=null;handle=G.default.createRef();init(o){this.el.style.width="100%",this.el.style.height="100%",this.root=new d(this.el);let a=G.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 O(t){if(t==null)return;if(typeof t=="string"||Ne(t))return t;let e=ae.get(t);if(e)return e;let o=Le(t);return ae.set(t,o),o}var le=new WeakMap,ue=new WeakMap,ce=new WeakMap,de=new WeakMap;function M(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 Ke(t){return class{el=document.createElement("span");root=null;init(o){this.el.style.display="inline-flex",this.el.style.alignItems="center",this.el.style.width="100%",this.el.style.height="100%",this.el.style.overflow="hidden",this.root=new 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(R.default.createElement(t,ze(o)))}}}function P(t){if(!t)return;if(typeof t=="function"&&(0,v.isClassRenderer)(t)||!M(t))return t;let e=le.get(t);if(e)return e;let o=Ke(t);return le.set(t,o),o}function We(t){let e=t.colDef?.tooltipComponentParams;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?.renderSync(R.default.createElement(t,We(o)))}}}function F(t){if(!t)return;if(typeof t=="function"&&(0,se.isClassTooltipComponent)(t)||!M(t))return t;let e=ue.get(t);if(e)return e;let o=je(t);return ue.set(t,o),o}function b(t){if(t)return e=>{let o=t(e);return!o||typeof o.tooltip!="object"||o.tooltip==null?o:{...o,tooltip:{...o.tooltip,component:F(o.tooltip.component)}}}}function Ce(t){return t==null||typeof t=="string"?t:F(t)}function qe(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function Ue(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(R.default.createElement(t,qe(o)))}}}function fe(t){if(!t)return;if(typeof t=="function"&&(0,me.isClassActionFrameComponent)(t)||!M(t))return t;let e=ce.get(t);if(e)return e;let o=Ue(t);return ce.set(t,o),o}function Je(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(R.default.createElement(t,o))}}}function p(t){if(!t)return;if(typeof t=="function"&&(0,v.isClassSetFilterComponent)(t)||!M(t))return t;let e=de.get(t);if(e)return e;let o=Je(t);return de.set(t,o),o}function Re(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:P(t.cellRenderer),cellEditor:O(t.cellEditor),tooltipComponent:F(t.tooltipComponent),headerTooltip:Ce(t.headerTooltip),actionFrameComponent:fe(t.actionFrameComponent),filterParams:Re(t.filterParams),children:t.children?H(t.children)??void 0:void 0}}function H(t){return t==null?t:t.map(e=>Qe(e))}function ge(t){if(t==null)return;let e={...t};return"cellRenderer"in t&&(e.cellRenderer=P(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=O(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=F(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=Ce(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=fe(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=Re(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",b(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=P(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=ge(t.defaultColDef)),t.bodyContextMenu===!1&&(e.bodyContextMenu=!1),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 he=f(require("react"),1);var E=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(he.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 Se=f(require("react"),1);var T=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(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 ve=require("react/jsx-runtime");function m(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function _e(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var pe=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),B=(0,i.useRef)(e.onCellClicked),V=(0,i.useRef)(e.onRowClicked),N=(0,i.useRef)(e.onCellDoubleClicked),L=(0,i.useRef)(e.onRowDoubleClicked),z=(0,i.useRef)(e.onCellValueChanged),K=(0,i.useRef)(e.onSelectionChanged),W=(0,i.useRef)(e.onSortChanged),j=(0,i.useRef)(e.onFilterChanged),q=(0,i.useRef)(e.onQuickFilterFindChanged),U=(0,i.useRef)(e.onHistoryChanged),J=(0,i.useRef)(e.onBeforeCellCommit),Q=(0,i.useRef)(e.fillOperation);s.current=e.onGridReady,y.current=e.getColumnMenuItems,C.current=e.bodyContextMenu,B.current=e.onCellClicked,V.current=e.onRowClicked,N.current=e.onCellDoubleClicked,L.current=e.onRowDoubleClicked,z.current=e.onCellValueChanged,K.current=e.onSelectionChanged,W.current=e.onSortChanged,j.current=e.onFilterChanged,q.current=e.onQuickFilterFindChanged,U.current=e.onHistoryChanged,J.current=e.onBeforeCellCommit,Q.current=e.fillOperation,(0,i.useLayoutEffect)(()=>{let u=a.current;if(!u)return;let c=ye(e);c.onCellClicked=l=>B.current?.(l),c.onRowClicked=l=>V.current?.(l),c.onCellDoubleClicked=l=>N.current?.(l),c.onRowDoubleClicked=l=>L.current?.(l),c.onCellValueChanged=l=>z.current?.(l),c.onSelectionChanged=l=>K.current?.(l),c.onSortChanged=l=>W.current?.(l),c.onFilterChanged=l=>j.current?.(l),c.onQuickFilterFindChanged=l=>q.current?.(l),c.onHistoryChanged=l=>U.current?.(l),c.onBeforeCellCommit=l=>J.current?.(l),c.fillOperation=l=>Q.current?.(l);let D=(0,we.createGrid)(u,{...c,menuAdapter:new T({getColumnMenuItems:l=>y.current?.(l)??l.items}),bodyMenuAdapter:new E({getBodyMenuItems:l=>{let oe=C.current;return typeof oe=="function"?oe(l):l.items}})}),A={api:D,destroyed:!1,appliedServerSideDataSource:c.serverSideDataSource};return r.current=A,m(o,D),m(e.apiRef,D),()=>{r.current===A&&(r.current=null),m(o,null),m(e.apiRef,null),_e(A)}},[]),(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:H(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 I=(0,i.useRef)(null);(0,i.useLayoutEffect)(()=>{let u=r.current;if(!(!u||I.current===u))return I.current=u,s.current?.(u.api),()=>{I.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({pivotColumnMoveMode:e.pivotColumnMoveMode})},[e.pivotColumnMoveMode]);let _=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!_.current){_.current=!0;return}e.pivotMode!=null&&r.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let Me=JSON.stringify(e.pivotColumns??null),Y=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!Y.current){Y.current=!0;return}e.pivotColumns!=null&&r.current?.api.setPivotColumns(e.pivotColumns)},[Me]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let Pe=JSON.stringify(e.rowSelection??null),X=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!X.current){X.current=!0;return}r.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[Pe]),(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:b(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})},[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]),(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 Fe=JSON.stringify(e.paginationControls??null),Z=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!Z.current){Z.current=!0;return}r.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[Fe]);let be=JSON.stringify(e.quickFilter??null),$=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!$.current){$.current=!0;return}r.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[be]);let Ee=JSON.stringify(e.tooltip??null),ee=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!ee.current){ee.current=!0;return}r.current?.api.updateGridOptions({tooltip:e.tooltip})},[Ee]);let Te=JSON.stringify(e.columnPanel??null),te=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!te.current){te.current=!0;return}r.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[Te]);let Ie=JSON.stringify(e.toolbar??null),ne=(0,i.useRef)(!1);return(0,i.useLayoutEffect)(()=>{if(!ne.current){ne.current=!0;return}r.current?.api.updateGridOptions({toolbar:e.toolbar})},[Ie]),(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,ve.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 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")});
|
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 } from '@agility-workbench/grid';
|
|
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';
|
|
2
2
|
export * from '@agility-workbench/grid';
|
|
3
3
|
import React$1 from 'react';
|
|
4
4
|
|
|
@@ -67,7 +67,7 @@ interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
|
|
|
67
67
|
subMenu?: MenuItem[];
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
|
|
70
|
+
interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
|
|
71
71
|
/** Optional className/style for the host div */
|
|
72
72
|
className?: string;
|
|
73
73
|
style?: React.CSSProperties;
|
|
@@ -102,6 +102,21 @@ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "fullWidthCell
|
|
|
102
102
|
ctx: BodyMenuContext;
|
|
103
103
|
items: MenuItem[];
|
|
104
104
|
}) => MenuItem[]);
|
|
105
|
+
/**
|
|
106
|
+
* Customizes the column menu opened for several selected columns at once (see the core
|
|
107
|
+
* `multiColumnMenu`):
|
|
108
|
+
* - omitted (default): the grid's built-in multi-column items.
|
|
109
|
+
* - a function: called with the built-in items and the columns they act on (target first); return
|
|
110
|
+
* the items to show (menu-item slots may be React nodes), or `[]` for no menu. The latest
|
|
111
|
+
* function passed is the one called. `getColumnMenuItems` still runs afterwards.
|
|
112
|
+
* - `false` at mount: no multi-column menu, and `getColumnMenuItems` does not run for one either.
|
|
113
|
+
* Switching to `false` after mount behaves like a function returning `[]`.
|
|
114
|
+
*/
|
|
115
|
+
multiColumnMenu?: false | ((p: {
|
|
116
|
+
ctx: ColumnMenuContext;
|
|
117
|
+
columns: Column[];
|
|
118
|
+
items: MenuItem[];
|
|
119
|
+
}) => MenuItem[]);
|
|
105
120
|
/**
|
|
106
121
|
* Renderer for a full-width row's content (see the core `fullWidthCellRenderer`). May be a plain
|
|
107
122
|
* core CellRenderer or a React component; a React component is adapted like `colDef.cellRenderer`.
|
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 } from '@agility-workbench/grid';
|
|
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';
|
|
2
2
|
export * from '@agility-workbench/grid';
|
|
3
3
|
import React$1 from 'react';
|
|
4
4
|
|
|
@@ -67,7 +67,7 @@ interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
|
|
|
67
67
|
subMenu?: MenuItem[];
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
|
|
70
|
+
interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "multiColumnMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
|
|
71
71
|
/** Optional className/style for the host div */
|
|
72
72
|
className?: string;
|
|
73
73
|
style?: React.CSSProperties;
|
|
@@ -102,6 +102,21 @@ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "fullWidthCell
|
|
|
102
102
|
ctx: BodyMenuContext;
|
|
103
103
|
items: MenuItem[];
|
|
104
104
|
}) => MenuItem[]);
|
|
105
|
+
/**
|
|
106
|
+
* Customizes the column menu opened for several selected columns at once (see the core
|
|
107
|
+
* `multiColumnMenu`):
|
|
108
|
+
* - omitted (default): the grid's built-in multi-column items.
|
|
109
|
+
* - a function: called with the built-in items and the columns they act on (target first); return
|
|
110
|
+
* the items to show (menu-item slots may be React nodes), or `[]` for no menu. The latest
|
|
111
|
+
* function passed is the one called. `getColumnMenuItems` still runs afterwards.
|
|
112
|
+
* - `false` at mount: no multi-column menu, and `getColumnMenuItems` does not run for one either.
|
|
113
|
+
* Switching to `false` after mount behaves like a function returning `[]`.
|
|
114
|
+
*/
|
|
115
|
+
multiColumnMenu?: false | ((p: {
|
|
116
|
+
ctx: ColumnMenuContext;
|
|
117
|
+
columns: Column[];
|
|
118
|
+
items: MenuItem[];
|
|
119
|
+
}) => MenuItem[]);
|
|
105
120
|
/**
|
|
106
121
|
* Renderer for a full-width row's content (see the core `fullWidthCellRenderer`). May be a plain
|
|
107
122
|
* core CellRenderer or a React component; a React component is adapted like `colDef.cellRenderer`.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"@agility-workbench/grid";import He,{useLayoutEffect as l,useRef as c}from"react";import{createGrid as Be}from"@agility-workbench/grid";import y from"react";import{flushSync as ge}from"react-dom";import{createRoot as ye}from"react-dom/client";var E=new Set,T=!1;function he(){T=!1;let t=Array.from(E);E.clear();for(let e of t)e.unmount()}function Se(t){E.add(t),!T&&(T=!0,queueMicrotask(he))}var s=class{root;constructor(e){this.root=ye(e)}render(e){this.root?.render(e)}renderSync(e){let o=this.root;o&&ge(()=>o.render(e))}destroy(){let e=this.root;e&&(this.root=null,Se(e))}};import{isClassRenderer as ve,isClassSetFilterComponent as Me}from"@agility-workbench/grid";import{isClassTooltipComponent as Pe}from"@agility-workbench/grid";import{isClassActionFrameComponent as Fe}from"@agility-workbench/grid";import Z from"react";var $=new WeakMap;function we(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function pe(t){return class{el=document.createElement("div");root=null;handle=Z.createRef();init(o){this.el.style.width="100%",this.el.style.height="100%",this.root=new s(this.el);let r=Z.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 I(t){if(t==null)return;if(typeof t=="string"||we(t))return t;let e=$.get(t);if(e)return e;let o=pe(t);return $.set(t,o),o}var ee=new WeakMap,te=new WeakMap,ne=new WeakMap,oe=new WeakMap;function h(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function be(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function Ee(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,be(o)))}}}function S(t){if(!t)return;if(typeof t=="function"&&ve(t)||!h(t))return t;let e=ee.get(t);if(e)return e;let o=Ee(t);return ee.set(t,o),o}function Te(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function Ie(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,Te(o)))}}}function w(t){if(!t)return;if(typeof t=="function"&&Pe(t)||!h(t))return t;let e=te.get(t);if(e)return e;let o=Ie(t);return te.set(t,o),o}function p(t){if(t)return e=>{let o=t(e);return!o||typeof o.tooltip!="object"||o.tooltip==null?o:{...o,tooltip:{...o.tooltip,component:w(o.tooltip.component)}}}}function ie(t){return t==null||typeof t=="string"?t:w(t)}function De(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function Ae(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,De(o)))}}}function re(t){if(!t)return;if(typeof t=="function"&&Fe(t)||!h(t))return t;let e=ne.get(t);if(e)return e;let o=Ae(t);return ne.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 g(t){if(!t)return;if(typeof t=="function"&&Me(t)||!h(t))return t;let e=oe.get(t);if(e)return e;let o=ke(t);return oe.set(t,o),o}function ae(t){if(t)return{...t,valueComponent:g(t.valueComponent),selectAllComponent:g(t.selectAllComponent),blanksComponent:g(t.blanksComponent),groupComponent:g(t.groupComponent)}}function xe(t){return{...t,cellRenderer:S(t.cellRenderer),cellEditor:I(t.cellEditor),tooltipComponent:w(t.tooltipComponent),headerTooltip:ie(t.headerTooltip),actionFrameComponent:re(t.actionFrameComponent),filterParams:ae(t.filterParams),children:t.children?D(t.children)??void 0:void 0}}function D(t){return t==null?t:t.map(e=>xe(e))}function le(t){if(t==null)return;let e={...t};return"cellRenderer"in t&&(e.cellRenderer=S(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=I(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=w(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=ie(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=re(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=ae(t.filterParams)),e}function n(t,e,o){o!=null&&(t[e]=o)}function ue(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",p(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=S(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=le(t.defaultColDef)),t.bodyContextMenu===!1&&(e.bodyContextMenu=!1),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 Ge from"react";var v=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(Ge.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 Oe from"react";var M=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(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{jsx as Le}from"react/jsx-runtime";function C(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function Ve(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var Ne=He.forwardRef(function(e,o){let r=c(null),i=c(null),m=c(e.onGridReady),R=c(e.getColumnMenuItems),f=c(e.bodyContextMenu),A=c(e.onCellClicked),k=c(e.onRowClicked),x=c(e.onCellDoubleClicked),G=c(e.onRowDoubleClicked),O=c(e.onCellValueChanged),H=c(e.onSelectionChanged),B=c(e.onSortChanged),V=c(e.onFilterChanged),N=c(e.onQuickFilterFindChanged),L=c(e.onHistoryChanged),z=c(e.onBeforeCellCommit),K=c(e.fillOperation);m.current=e.onGridReady,R.current=e.getColumnMenuItems,f.current=e.bodyContextMenu,A.current=e.onCellClicked,k.current=e.onRowClicked,x.current=e.onCellDoubleClicked,G.current=e.onRowDoubleClicked,O.current=e.onCellValueChanged,H.current=e.onSelectionChanged,B.current=e.onSortChanged,V.current=e.onFilterChanged,N.current=e.onQuickFilterFindChanged,L.current=e.onHistoryChanged,z.current=e.onBeforeCellCommit,K.current=e.fillOperation,l(()=>{let u=r.current;if(!u)return;let d=ue(e);d.onCellClicked=a=>A.current?.(a),d.onRowClicked=a=>k.current?.(a),d.onCellDoubleClicked=a=>x.current?.(a),d.onRowDoubleClicked=a=>G.current?.(a),d.onCellValueChanged=a=>O.current?.(a),d.onSelectionChanged=a=>H.current?.(a),d.onSortChanged=a=>B.current?.(a),d.onFilterChanged=a=>V.current?.(a),d.onQuickFilterFindChanged=a=>N.current?.(a),d.onHistoryChanged=a=>L.current?.(a),d.onBeforeCellCommit=a=>z.current?.(a),d.fillOperation=a=>K.current?.(a);let F=Be(u,{...d,menuAdapter:new M({getColumnMenuItems:a=>R.current?.(a)??a.items}),bodyMenuAdapter:new v({getBodyMenuItems:a=>{let X=f.current;return typeof X=="function"?X(a):a.items}})}),b={api:F,destroyed:!1,appliedServerSideDataSource:d.serverSideDataSource};return i.current=b,C(o,F),C(e.apiRef,F),()=>{i.current===b&&(i.current=null),C(o,null),C(e.apiRef,null),Ve(b)}},[]),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:D(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 P=c(null);l(()=>{let u=i.current;if(!(!u||P.current===u))return P.current=u,m.current?.(u.api),()=>{P.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({pivotColumnMoveMode:e.pivotColumnMoveMode})},[e.pivotColumnMoveMode]);let W=c(!1);l(()=>{if(!W.current){W.current=!0;return}e.pivotMode!=null&&i.current?.api.setPivotMode(e.pivotMode)},[e.pivotMode]);let ce=JSON.stringify(e.pivotColumns??null),j=c(!1);l(()=>{if(!j.current){j.current=!0;return}e.pivotColumns!=null&&i.current?.api.setPivotColumns(e.pivotColumns)},[ce]),l(()=>{i.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let de=JSON.stringify(e.rowSelection??null),q=c(!1);l(()=>{if(!q.current){q.current=!0;return}i.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[de]),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:p(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})},[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]),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 se=JSON.stringify(e.paginationControls??null),U=c(!1);l(()=>{if(!U.current){U.current=!0;return}i.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[se]);let me=JSON.stringify(e.quickFilter??null),J=c(!1);l(()=>{if(!J.current){J.current=!0;return}i.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[me]);let Ce=JSON.stringify(e.tooltip??null),Q=c(!1);l(()=>{if(!Q.current){Q.current=!0;return}i.current?.api.updateGridOptions({tooltip:e.tooltip})},[Ce]);let fe=JSON.stringify(e.columnPanel??null),_=c(!1);l(()=>{if(!_.current){_.current=!0;return}i.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[fe]);let Re=JSON.stringify(e.toolbar??null),Y=c(!1);return l(()=>{if(!Y.current){Y.current=!0;return}i.current?.api.updateGridOptions({toolbar:e.toolbar})},[Re]),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]),Le("div",{ref:r,className:e.className,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...e.style}})});export{Ne as Grid};
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agility-workbench/react-grid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.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.10.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"react": ">=18.0.0",
|