@agility-workbench/react-grid 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Himanshu M
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # @agility-workbench/react-grid
2
+
3
+ React bindings for [`@agility-workbench/grid`](https://www.npmjs.com/package/@agility-workbench/grid) —
4
+ a high-performance data grid. Provides a `<Grid />` component and re-exports the full
5
+ core API, so you can import everything you need from one place.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @agility-workbench/react-grid react react-dom
11
+ ```
12
+
13
+ `@agility-workbench/grid` is installed automatically as a dependency. `react` and `react-dom`
14
+ are peer dependencies you provide.
15
+
16
+ ## Quick start
17
+
18
+ ```tsx
19
+ import { StrictMode, useState } from "react";
20
+ import {
21
+ ColumnType,
22
+ Grid,
23
+ themeDark,
24
+ type GridEventEditingChangedParams,
25
+ type IGridAPI,
26
+ type ReactColDef,
27
+ } from "@agility-workbench/react-grid";
28
+
29
+ const columnDefs: ReactColDef[] = [
30
+ { key: "name", label: "Name", type: ColumnType.STRING },
31
+ { key: "price", label: "Price", type: ColumnType.NUMBER },
32
+ ];
33
+
34
+ const rowData = [
35
+ { id: "1", name: "Widget", price: 9.99 },
36
+ { id: "2", name: "Gadget", price: 14.5 },
37
+ ];
38
+
39
+ export function Example() {
40
+ const [api, setApi] = useState<IGridAPI | null>(null);
41
+
42
+ return (
43
+ <StrictMode>
44
+ <div style={{ height: 400 }}>
45
+ <Grid
46
+ rowData={rowData}
47
+ columnDefs={columnDefs}
48
+ rowIdKey="id"
49
+ toolbar={{ grouping: true, sorting: true, quickFilter: true, export: true }}
50
+ columnPanel={{ trigger: "toolbar" }}
51
+ theme={themeDark.withParams({ accentColor: "#e11d48", rowHeight: 40 })}
52
+ onGridReady={(readyApi) => {
53
+ setApi(readyApi);
54
+ readyApi.on("editingChanged", (event: GridEventEditingChangedParams) => {
55
+ console.log(event.state);
56
+ });
57
+ }}
58
+ />
59
+ </div>
60
+ </StrictMode>
61
+ );
62
+ }
63
+ ```
64
+
65
+ The React binding creates and attaches the renderer after the host element mounts, so
66
+ `React.StrictMode` effect replay is supported. In development, `onGridReady` may run once
67
+ for each live setup React creates; each callback receives a live API, and refs are cleared
68
+ when a setup is cleaned up.
69
+
70
+ `columnPanel.trigger` accepts `"rail"`, `"header"`, `"menu"`, `"footer"`, or `"toolbar"`. All
71
+ five entry points open the same right-hand column-management drawer.
72
+
73
+ `toolbar` independently enables the `views`, `grouping`, `sorting`, `quickFilter`, and `export`
74
+ sections.
75
+ Every section is off by default; enabling any one shows the toolbar. The quick-filter section reuses
76
+ the existing filter and its behavioral `quickFilter` configuration, but supersedes its floating
77
+ placement and close controls. Changing the object live adds/removes sections without remounting the
78
+ grid. The toolbar-hosted Columns trigger also counts as content, so
79
+ `columnPanel={{ trigger: "toolbar" }}` can display a Columns-only toolbar.
80
+
81
+ Responsive toolbar breakpoints follow the grid container. Labels collapse first, then Export and
82
+ Columns move into a More menu, so embedding the grid in a resizable panel does not require any
83
+ application-level resize handling.
84
+
85
+ `toolbar.views` adds the saved-view picker. Supply `savedViews={{ views, activeViewId, onChange,
86
+ onActiveViewChange }}` to keep persistence controlled by React state, local storage, or a remote
87
+ service. The grid reports complete updated arrays and does not write to storage itself.
88
+
89
+ ## Styling
90
+
91
+ Nothing to do — the grid delivers its own stylesheet when it attaches, once per
92
+ document, and once per shadow root for grids inside one.
93
+
94
+ Under a strict Content Security Policy without `style-src 'unsafe-inline'`, pass
95
+ a nonce via the `styleNonce` prop (page-global, so use the same value for every
96
+ grid). To load the stylesheet yourself instead, import it and opt out with
97
+ `suppressStyleInjection` on each grid, so the two copies do not fight in the
98
+ cascade:
99
+
100
+ ```ts
101
+ import "@agility-workbench/grid/styles.css";
102
+ ```
103
+
104
+ ## Theming, icons, and the full API
105
+
106
+ The React entry re-exports everything from `@agility-workbench/grid` (themes, `ColDef`,
107
+ `injectGridStyles`, all types), so a single import covers your app:
108
+
109
+ ```tsx
110
+ import {
111
+ AggregateType,
112
+ ColumnType,
113
+ FilterType,
114
+ Grid,
115
+ themeLight,
116
+ type ColDef,
117
+ type GridEventEditingChangedParams,
118
+ } from "@agility-workbench/react-grid";
119
+ ```
120
+
121
+ See the [`@agility-workbench/grid` README](https://www.npmjs.com/package/@agility-workbench/grid)
122
+ for the theming API, semantic params, and icon overrides.
123
+
124
+ ## License
125
+
126
+ [MIT](./LICENSE)
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var Me=Object.create;var S=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Ee=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var be=(t,e)=>{for(var n in e)S(t,n,{get:e[n],enumerable:!0})},w=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ve(e))!Te.call(t,r)&&r!==n&&S(t,r,{get:()=>e[r],enumerable:!(a=Pe(e,r))||a.enumerable});return t},p=(t,e,n)=>(w(t,e,"default"),n&&w(n,e,"default")),f=(t,e,n)=>(n=t!=null?Me(Ee(t)):{},w(e||!t||!t.__esModule?S(n,"default",{value:t,enumerable:!0}):n,t)),Fe=t=>w(S({},"__esModule",{value:!0}),t);var g={};be(g,{Grid:()=>fe});module.exports=Fe(g);p(g,require("@agility-workbench/grid"),module.exports);var i=f(require("react"),1),Ce=require("@agility-workbench/grid");var R=f(require("react"),1);var X=require("react-dom"),Z=require("react-dom/client"),A=new Set,x=!1;function Ie(){x=!1;let t=Array.from(A);A.clear();for(let e of t)e.unmount()}function Ae(t){A.add(t),!x&&(x=!0,queueMicrotask(Ie))}var u=class{root;constructor(e){this.root=(0,Z.createRoot)(e)}render(e){this.root?.render(e)}renderSync(e){let n=this.root;n&&(0,X.flushSync)(()=>n.render(e))}destroy(){let e=this.root;e&&(this.root=null,Ae(e))}};var M=require("@agility-workbench/grid"),ie=require("@agility-workbench/grid"),re=require("@agility-workbench/grid");var G=f(require("react"),1);var $=new WeakMap;function xe(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function Ge(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 u(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 O(t){if(t==null)return;if(typeof t=="string"||xe(t))return t;let e=$.get(t);if(e)return e;let n=Ge(t);return $.set(t,n),n}var ee=new WeakMap,te=new WeakMap,ne=new WeakMap,oe=new WeakMap;function P(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function Oe(t){let e=t.colDef.cellRendererParams;return e==null||typeof e!="object"?t:{...t,...e}}function De(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 u(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(R.default.createElement(t,Oe(n)))}}}function v(t){if(!t)return;if(typeof t=="function"&&(0,M.isClassRenderer)(t)||!P(t))return t;let e=ee.get(t);if(e)return e;let n=De(t);return ee.set(t,n),n}function ke(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function He(t){return class{el=document.createElement("div");root=null;init(n){this.root=new u(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(R.default.createElement(t,ke(n)))}}}function E(t){if(!t)return;if(typeof t=="function"&&(0,ie.isClassTooltipComponent)(t)||!P(t))return t;let e=te.get(t);if(e)return e;let n=He(t);return te.set(t,n),n}function T(t){if(t)return e=>{let n=t(e);return!n||typeof n.tooltip!="object"||n.tooltip==null?n:{...n,tooltip:{...n.tooltip,component:E(n.tooltip.component)}}}}function ae(t){return t==null||typeof t=="string"?t:E(t)}function Be(t){let e=t.colDef?.actionFrameComponentParams;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 u(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(R.default.createElement(t,Be(n)))}}}function le(t){if(!t)return;if(typeof t=="function"&&(0,re.isClassActionFrameComponent)(t)||!P(t))return t;let e=ne.get(t);if(e)return e;let n=Ve(t);return ne.set(t,n),n}function Le(t){return class{el=document.createElement("span");root=null;init(n){this.root=new u(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(R.default.createElement(t,n))}}}function D(t){if(!t)return;if(typeof t=="function"&&(0,M.isClassSetFilterComponent)(t)||!P(t))return t;let e=oe.get(t);if(e)return e;let n=Le(t);return oe.set(t,n),n}function ce(t){if(t)return{...t,valueComponent:D(t.valueComponent),selectAllComponent:D(t.selectAllComponent),blanksComponent:D(t.blanksComponent)}}function Ne(t){return{...t,cellRenderer:v(t.cellRenderer),cellEditor:O(t.cellEditor),tooltipComponent:E(t.tooltipComponent),headerTooltip:ae(t.headerTooltip),actionFrameComponent:le(t.actionFrameComponent),filterParams:ce(t.filterParams),children:t.children?k(t.children)??void 0:void 0}}function k(t){return t==null?t:t.map(e=>Ne(e))}function ue(t){if(t==null)return;let e={...t};return"cellRenderer"in t&&(e.cellRenderer=v(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=O(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=E(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=ae(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=le(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=ce(t.filterParams)),e}function o(t,e,n){n!=null&&(t[e]=n)}function de(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,"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",T(t.getRowPresentation)),o(e,"onCellClicked",t.onCellClicked),o(e,"onRowClicked",t.onRowClicked),o(e,"onCellValueChanged",t.onCellValueChanged),o(e,"onSelectionChanged",t.onSelectionChanged),o(e,"onSortChanged",t.onSortChanged),o(e,"onFilterChanged",t.onFilterChanged),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,"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,"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,"groupColumnDef",t.groupColumnDef),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,"loadingMessage",t.loadingMessage),o(e,"noRowsMessage",t.noRowsMessage),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=v(t.fullWidthCellRenderer)),t.defaultColDef!=null&&(e.defaultColDef=ue(t.defaultColDef)),t.bodyContextMenu===!1&&(e.bodyContextMenu=!1),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 se=f(require("react"),1);var b=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 C of a)C()}}}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(se.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 u(n);return a.render(e),{el:n,unmount:()=>a.destroy()}}};var me=f(require("react"),1);var F=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 C of a)C()}}}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(me.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 u(n);return a.render(e),{el:n,unmount:()=>a.destroy()}}};var Re=require("react/jsx-runtime");function m(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function ze(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var fe=i.default.forwardRef(function(e,n){let a=(0,i.useRef)(null),r=(0,i.useRef)(null),d=(0,i.useRef)(e.onGridReady),y=(0,i.useRef)(e.getColumnMenuItems),C=(0,i.useRef)(e.bodyContextMenu),H=(0,i.useRef)(e.onCellClicked),B=(0,i.useRef)(e.onRowClicked),V=(0,i.useRef)(e.onCellValueChanged),L=(0,i.useRef)(e.onSelectionChanged),N=(0,i.useRef)(e.onSortChanged),z=(0,i.useRef)(e.onFilterChanged),K=(0,i.useRef)(e.onHistoryChanged),W=(0,i.useRef)(e.onBeforeCellCommit);d.current=e.onGridReady,y.current=e.getColumnMenuItems,C.current=e.bodyContextMenu,H.current=e.onCellClicked,B.current=e.onRowClicked,V.current=e.onCellValueChanged,L.current=e.onSelectionChanged,N.current=e.onSortChanged,z.current=e.onFilterChanged,K.current=e.onHistoryChanged,W.current=e.onBeforeCellCommit,(0,i.useLayoutEffect)(()=>{let c=a.current;if(!c)return;let s=de(e);s.onCellClicked=l=>H.current?.(l),s.onRowClicked=l=>B.current?.(l),s.onCellValueChanged=l=>V.current?.(l),s.onSelectionChanged=l=>L.current?.(l),s.onSortChanged=l=>N.current?.(l),s.onFilterChanged=l=>z.current?.(l),s.onHistoryChanged=l=>K.current?.(l),s.onBeforeCellCommit=l=>W.current?.(l);let h=(0,Ce.createGrid)(c,{...s,menuAdapter:new F({getColumnMenuItems:l=>y.current?.(l)??l.items}),bodyMenuAdapter:new b({getBodyMenuItems:l=>{let Q=C.current;return typeof Q=="function"?Q(l):l.items}})}),I={api:h,destroyed:!1};return r.current=I,m(n,h),m(e.apiRef,h),d.current?.(h),()=>{r.current===I&&(r.current=null),m(n,null),m(e.apiRef,null),ze(I)}},[]),(0,i.useLayoutEffect)(()=>{let c=r.current?.api??null;return m(n,c),m(e.apiRef,c),()=>{m(n,null),m(e.apiRef,null)}},[n,e.apiRef]),(0,i.useLayoutEffect)(()=>{let c=r.current?.api;c&&c.updateGridOptions({columnDefs:k(e.columnDefs)})},[e.columnDefs]),(0,i.useLayoutEffect)(()=>{let c=r.current?.api;c&&e.rowModelType!=="serverSide"&&c.setRowData(e.rowData??e.data??[])},[e.data,e.rowData,e.rowModelType]),(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({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let ge=JSON.stringify(e.rowSelection??null),j=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!j.current){j.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:T(e.getRowPresentation),ariaLabel:e.ariaLabel,ariaLabelledBy:e.ariaLabelledBy,highlightActiveCell:e.highlightActiveCell??!1,cellSelection:e.cellSelection??!0,rangeSelection:e.rangeSelection??!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.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 c=r.current;!c||e.rowModelType!=="serverSide"||e.serverSideDataSource&&c.api.updateGridOptions({serverSideDataSource:e.serverSideDataSource})},[e.rowModelType,e.serverSideDataSource]),(0,i.useLayoutEffect)(()=>{let c=r.current;!c||e.rowModelType!=="serverSide"||e.serverSideAggregationSource&&c.api.updateGridOptions({serverSideAggregationSource:e.serverSideAggregationSource})},[e.rowModelType,e.serverSideAggregationSource]),(0,i.useLayoutEffect)(()=>{let c=r.current?.api;c&&c.dispatch({type:"overlayShow",overlayType:e.loading?"loading":"none"})},[e.loading]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({pagination:e.pagination})},[e.pagination]);let ye=JSON.stringify(e.paginationControls??null),q=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!q.current){q.current=!0;return}r.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[ye]);let he=JSON.stringify(e.quickFilter??null),U=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!U.current){U.current=!0;return}r.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[he]);let we=JSON.stringify(e.tooltip??null),J=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!J.current){J.current=!0;return}r.current?.api.updateGridOptions({tooltip:e.tooltip})},[we]);let Se=JSON.stringify(e.columnPanel??null),_=(0,i.useRef)(!1);(0,i.useLayoutEffect)(()=>{if(!_.current){_.current=!0;return}r.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[Se]);let pe=JSON.stringify(e.toolbar??null),Y=(0,i.useRef)(!1);return(0,i.useLayoutEffect)(()=>{if(!Y.current){Y.current=!0;return}r.current?.api.updateGridOptions({toolbar:e.toolbar})},[pe]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({savedViews:e.savedViews})},[e.savedViews]),(0,i.useLayoutEffect)(()=>{r.current?.api.updateGridOptions({theme:e.theme,icons:{...e.theme?.getIcons(),...e.icons}})},[e.theme,e.icons]),(0,Re.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")});
@@ -0,0 +1,115 @@
1
+ import { ICellEditorParams, ColDef, CellRenderer, CellRendererParams, CellEditor, TooltipComponent, TooltipComponentParams, ActionFrameComponent, ActionFrameComponentParams, FilterParams, SetFilterValueComponent, SetFilterValueComponentParams, SetFilterSpecialValueComponent, SetFilterSpecialValueComponentParams, NON_DEFAULTABLE_COLDEF_KEYS, RowPresentationParams, RowPresentation, RowTooltipPresentation, MenuItem as MenuItem$1, GridOptions, IGridAPI, ColumnMenuContext, BodyMenuContext } from '@agility-workbench/grid';
2
+ export * from '@agility-workbench/grid';
3
+ import React$1 from 'react';
4
+
5
+ /**
6
+ * The imperative handle a React cell editor exposes via useImperativeHandle. The grid reads
7
+ * `getValue()` on commit and calls the optional lifecycle methods; everything else (mount, focus,
8
+ * teardown) is handled by the adapter.
9
+ */
10
+ interface ReactCellEditorHandle {
11
+ /** The value to commit. */
12
+ getValue: () => unknown;
13
+ /** Whether getValue() is already the final typed value (skip the column's valueParser). */
14
+ isParsed?: () => boolean;
15
+ /** Focus the editor after mount. */
16
+ focus?: () => void;
17
+ /** Return true to abort opening the editor. */
18
+ isCancelBeforeStart?: () => boolean;
19
+ }
20
+ /**
21
+ * A React cell editor: a forwardRef component that receives ICellEditorParams as props and exposes
22
+ * a ReactCellEditorHandle via useImperativeHandle.
23
+ */
24
+ type ReactCellEditor = React$1.ForwardRefExoticComponent<ICellEditorParams & React$1.RefAttributes<ReactCellEditorHandle>> | React$1.ComponentType<ICellEditorParams & {
25
+ ref?: React$1.Ref<ReactCellEditorHandle>;
26
+ }>;
27
+
28
+ type ReactCellRenderer = React$1.ComponentType<CellRendererParams> | React$1.ExoticComponent<CellRendererParams>;
29
+ type ReactTooltipComponent = React$1.ComponentType<TooltipComponentParams> | React$1.ExoticComponent<TooltipComponentParams>;
30
+ type ReactRowTooltipPresentation = Omit<RowTooltipPresentation, "component"> & {
31
+ component?: TooltipComponent | ReactTooltipComponent;
32
+ };
33
+ type ReactRowPresentation = Omit<RowPresentation, "tooltip"> & {
34
+ tooltip?: ReactRowTooltipPresentation | false | null;
35
+ };
36
+ type ReactGetRowPresentation = (params: RowPresentationParams) => ReactRowPresentation | null | undefined;
37
+ type ReactActionFrameComponent = React$1.ComponentType<ActionFrameComponentParams> | React$1.ExoticComponent<ActionFrameComponentParams>;
38
+ type ReactSetFilterValueComponent = React$1.ComponentType<SetFilterValueComponentParams> | React$1.ExoticComponent<SetFilterValueComponentParams>;
39
+ type ReactSetFilterSpecialValueComponent = React$1.ComponentType<SetFilterSpecialValueComponentParams> | React$1.ExoticComponent<SetFilterSpecialValueComponentParams>;
40
+ type ReactFilterParams = Omit<FilterParams, "valueComponent" | "selectAllComponent" | "blanksComponent"> & {
41
+ valueComponent?: SetFilterValueComponent | ReactSetFilterValueComponent;
42
+ selectAllComponent?: SetFilterSpecialValueComponent | ReactSetFilterSpecialValueComponent;
43
+ blanksComponent?: SetFilterSpecialValueComponent | ReactSetFilterSpecialValueComponent;
44
+ };
45
+ type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams"> & {
46
+ cellRenderer?: CellRenderer | ReactCellRenderer;
47
+ cellEditor?: CellEditor | ReactCellEditor;
48
+ tooltipComponent?: TooltipComponent | ReactTooltipComponent;
49
+ headerTooltip?: string | TooltipComponent | ReactTooltipComponent;
50
+ actionFrameComponent?: ActionFrameComponent | ReactActionFrameComponent;
51
+ filterParams?: ReactFilterParams;
52
+ children?: ReactColDef[];
53
+ };
54
+ /**
55
+ * React-aware shape of the grid-level `defaultColDef`: a {@link ReactColDef} minus the per-column
56
+ * identity/structure fields that never inherit (see `NON_DEFAULTABLE_COLDEF_KEYS`). Mirrors core
57
+ * `DefaultColDef`, but its component fields may be React components.
58
+ */
59
+ type ReactDefaultColDef = Omit<ReactColDef, (typeof NON_DEFAULTABLE_COLDEF_KEYS)[number]>;
60
+
61
+ type MenuSlotReact = string | HTMLElement | React.ReactElement | null | false | undefined;
62
+ interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
63
+ left?: MenuSlotReact;
64
+ right?: MenuSlotReact;
65
+ subMenu?: MenuItem[];
66
+ }
67
+
68
+ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
69
+ /** Optional className/style for the host div */
70
+ className?: string;
71
+ style?: React.CSSProperties;
72
+ /** Optional initial data/columns; wrapper will forward after init and on change */
73
+ data?: unknown[];
74
+ /** Public row-data prop. Takes precedence over `data` when both are provided. */
75
+ rowData?: unknown[];
76
+ columnDefs?: ReactColDef[] | ColDef[] | null;
77
+ /** Expose API (AG Grid style) */
78
+ apiRef?: React.Ref<IGridAPI | null>;
79
+ onGridReady?: (api: IGridAPI) => void;
80
+ loading?: boolean;
81
+ /** Hook to customize column menu items */
82
+ getColumnMenuItems?: (p: {
83
+ ctx: ColumnMenuContext;
84
+ items: MenuItem[];
85
+ }) => MenuItem[];
86
+ /**
87
+ * Controls the body (right-click) context menu:
88
+ * - `true` / omitted (default): the grid's default body menu (Copy, Export, …).
89
+ * - `false`: no grid menu — the browser's native context menu appears instead.
90
+ * - a function: called with the menu context and the default items; return the items to show
91
+ * (menu-item slots may be React nodes). Return `[]` to show nothing while still suppressing the
92
+ * native menu. Fires on right-click anywhere in the body, including row-number cells.
93
+ */
94
+ bodyContextMenu?: boolean | ((p: {
95
+ ctx: BodyMenuContext;
96
+ items: MenuItem[];
97
+ }) => MenuItem[]);
98
+ /**
99
+ * Renderer for a full-width row's content (see the core `fullWidthCellRenderer`). May be a plain
100
+ * core CellRenderer or a React component; a React component is adapted like `colDef.cellRenderer`.
101
+ */
102
+ fullWidthCellRenderer?: GridOptions["fullWidthCellRenderer"] | ReactCellRenderer;
103
+ /**
104
+ * Default column definition merged under every column (see core `defaultColDef`). A React-aware
105
+ * `ReactColDef`, so component fields (cellRenderer, tooltipComponent, actionFrameComponent, …) may
106
+ * be React components; they are adapted exactly as they would be on a real column def.
107
+ */
108
+ defaultColDef?: ReactDefaultColDef;
109
+ /** React-aware row presentation callback; row tooltip components may be React components. */
110
+ getRowPresentation?: ReactGetRowPresentation;
111
+ }
112
+
113
+ declare const Grid: React$1.ForwardRefExoticComponent<GridProps & React$1.RefAttributes<IGridAPI | null>>;
114
+
115
+ 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 ReactSetFilterSpecialValueComponent, type ReactSetFilterValueComponent, type ReactTooltipComponent };
@@ -0,0 +1,115 @@
1
+ import { ICellEditorParams, ColDef, CellRenderer, CellRendererParams, CellEditor, TooltipComponent, TooltipComponentParams, ActionFrameComponent, ActionFrameComponentParams, FilterParams, SetFilterValueComponent, SetFilterValueComponentParams, SetFilterSpecialValueComponent, SetFilterSpecialValueComponentParams, NON_DEFAULTABLE_COLDEF_KEYS, RowPresentationParams, RowPresentation, RowTooltipPresentation, MenuItem as MenuItem$1, GridOptions, IGridAPI, ColumnMenuContext, BodyMenuContext } from '@agility-workbench/grid';
2
+ export * from '@agility-workbench/grid';
3
+ import React$1 from 'react';
4
+
5
+ /**
6
+ * The imperative handle a React cell editor exposes via useImperativeHandle. The grid reads
7
+ * `getValue()` on commit and calls the optional lifecycle methods; everything else (mount, focus,
8
+ * teardown) is handled by the adapter.
9
+ */
10
+ interface ReactCellEditorHandle {
11
+ /** The value to commit. */
12
+ getValue: () => unknown;
13
+ /** Whether getValue() is already the final typed value (skip the column's valueParser). */
14
+ isParsed?: () => boolean;
15
+ /** Focus the editor after mount. */
16
+ focus?: () => void;
17
+ /** Return true to abort opening the editor. */
18
+ isCancelBeforeStart?: () => boolean;
19
+ }
20
+ /**
21
+ * A React cell editor: a forwardRef component that receives ICellEditorParams as props and exposes
22
+ * a ReactCellEditorHandle via useImperativeHandle.
23
+ */
24
+ type ReactCellEditor = React$1.ForwardRefExoticComponent<ICellEditorParams & React$1.RefAttributes<ReactCellEditorHandle>> | React$1.ComponentType<ICellEditorParams & {
25
+ ref?: React$1.Ref<ReactCellEditorHandle>;
26
+ }>;
27
+
28
+ type ReactCellRenderer = React$1.ComponentType<CellRendererParams> | React$1.ExoticComponent<CellRendererParams>;
29
+ type ReactTooltipComponent = React$1.ComponentType<TooltipComponentParams> | React$1.ExoticComponent<TooltipComponentParams>;
30
+ type ReactRowTooltipPresentation = Omit<RowTooltipPresentation, "component"> & {
31
+ component?: TooltipComponent | ReactTooltipComponent;
32
+ };
33
+ type ReactRowPresentation = Omit<RowPresentation, "tooltip"> & {
34
+ tooltip?: ReactRowTooltipPresentation | false | null;
35
+ };
36
+ type ReactGetRowPresentation = (params: RowPresentationParams) => ReactRowPresentation | null | undefined;
37
+ type ReactActionFrameComponent = React$1.ComponentType<ActionFrameComponentParams> | React$1.ExoticComponent<ActionFrameComponentParams>;
38
+ type ReactSetFilterValueComponent = React$1.ComponentType<SetFilterValueComponentParams> | React$1.ExoticComponent<SetFilterValueComponentParams>;
39
+ type ReactSetFilterSpecialValueComponent = React$1.ComponentType<SetFilterSpecialValueComponentParams> | React$1.ExoticComponent<SetFilterSpecialValueComponentParams>;
40
+ type ReactFilterParams = Omit<FilterParams, "valueComponent" | "selectAllComponent" | "blanksComponent"> & {
41
+ valueComponent?: SetFilterValueComponent | ReactSetFilterValueComponent;
42
+ selectAllComponent?: SetFilterSpecialValueComponent | ReactSetFilterSpecialValueComponent;
43
+ blanksComponent?: SetFilterSpecialValueComponent | ReactSetFilterSpecialValueComponent;
44
+ };
45
+ type ReactColDef = Omit<ColDef, "cellRenderer" | "cellEditor" | "children" | "tooltipComponent" | "headerTooltip" | "actionFrameComponent" | "filterParams"> & {
46
+ cellRenderer?: CellRenderer | ReactCellRenderer;
47
+ cellEditor?: CellEditor | ReactCellEditor;
48
+ tooltipComponent?: TooltipComponent | ReactTooltipComponent;
49
+ headerTooltip?: string | TooltipComponent | ReactTooltipComponent;
50
+ actionFrameComponent?: ActionFrameComponent | ReactActionFrameComponent;
51
+ filterParams?: ReactFilterParams;
52
+ children?: ReactColDef[];
53
+ };
54
+ /**
55
+ * React-aware shape of the grid-level `defaultColDef`: a {@link ReactColDef} minus the per-column
56
+ * identity/structure fields that never inherit (see `NON_DEFAULTABLE_COLDEF_KEYS`). Mirrors core
57
+ * `DefaultColDef`, but its component fields may be React components.
58
+ */
59
+ type ReactDefaultColDef = Omit<ReactColDef, (typeof NON_DEFAULTABLE_COLDEF_KEYS)[number]>;
60
+
61
+ type MenuSlotReact = string | HTMLElement | React.ReactElement | null | false | undefined;
62
+ interface MenuItem extends Omit<MenuItem$1, "left" | "right" | "subMenu"> {
63
+ left?: MenuSlotReact;
64
+ right?: MenuSlotReact;
65
+ subMenu?: MenuItem[];
66
+ }
67
+
68
+ interface GridProps extends Omit<GridOptions, "bodyContextMenu" | "fullWidthCellRenderer" | "defaultColDef" | "getRowPresentation"> {
69
+ /** Optional className/style for the host div */
70
+ className?: string;
71
+ style?: React.CSSProperties;
72
+ /** Optional initial data/columns; wrapper will forward after init and on change */
73
+ data?: unknown[];
74
+ /** Public row-data prop. Takes precedence over `data` when both are provided. */
75
+ rowData?: unknown[];
76
+ columnDefs?: ReactColDef[] | ColDef[] | null;
77
+ /** Expose API (AG Grid style) */
78
+ apiRef?: React.Ref<IGridAPI | null>;
79
+ onGridReady?: (api: IGridAPI) => void;
80
+ loading?: boolean;
81
+ /** Hook to customize column menu items */
82
+ getColumnMenuItems?: (p: {
83
+ ctx: ColumnMenuContext;
84
+ items: MenuItem[];
85
+ }) => MenuItem[];
86
+ /**
87
+ * Controls the body (right-click) context menu:
88
+ * - `true` / omitted (default): the grid's default body menu (Copy, Export, …).
89
+ * - `false`: no grid menu — the browser's native context menu appears instead.
90
+ * - a function: called with the menu context and the default items; return the items to show
91
+ * (menu-item slots may be React nodes). Return `[]` to show nothing while still suppressing the
92
+ * native menu. Fires on right-click anywhere in the body, including row-number cells.
93
+ */
94
+ bodyContextMenu?: boolean | ((p: {
95
+ ctx: BodyMenuContext;
96
+ items: MenuItem[];
97
+ }) => MenuItem[]);
98
+ /**
99
+ * Renderer for a full-width row's content (see the core `fullWidthCellRenderer`). May be a plain
100
+ * core CellRenderer or a React component; a React component is adapted like `colDef.cellRenderer`.
101
+ */
102
+ fullWidthCellRenderer?: GridOptions["fullWidthCellRenderer"] | ReactCellRenderer;
103
+ /**
104
+ * Default column definition merged under every column (see core `defaultColDef`). A React-aware
105
+ * `ReactColDef`, so component fields (cellRenderer, tooltipComponent, actionFrameComponent, …) may
106
+ * be React components; they are adapted exactly as they would be on a real column def.
107
+ */
108
+ defaultColDef?: ReactDefaultColDef;
109
+ /** React-aware row presentation callback; row tooltip components may be React components. */
110
+ getRowPresentation?: ReactGetRowPresentation;
111
+ }
112
+
113
+ declare const Grid: React$1.ForwardRefExoticComponent<GridProps & React$1.RefAttributes<IGridAPI | null>>;
114
+
115
+ 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 ReactSetFilterSpecialValueComponent, type ReactSetFilterValueComponent, type ReactTooltipComponent };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export*from"@agility-workbench/grid";import Fe,{useLayoutEffect as a,useRef as u}from"react";import{createGrid as Ie}from"@agility-workbench/grid";import y from"react";import{flushSync as ce}from"react-dom";import{createRoot as ue}from"react-dom/client";var E=new Set,T=!1;function de(){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(de))}var d=class{root;constructor(e){this.root=ue(e)}render(e){this.root?.render(e)}renderSync(e){let o=this.root;o&&ce(()=>o.render(e))}destroy(){let e=this.root;e&&(this.root=null,se(e))}};import{isClassRenderer as fe,isClassSetFilterComponent as Re}from"@agility-workbench/grid";import{isClassTooltipComponent as ge}from"@agility-workbench/grid";import{isClassActionFrameComponent as ye}from"@agility-workbench/grid";import q from"react";var U=new WeakMap;function me(t){let e=t?.prototype;return typeof t=="function"&&!!e&&typeof e.init=="function"&&typeof e.getGui=="function"}function Ce(t){return class{el=document.createElement("div");root=null;handle=q.createRef();init(o){this.el.style.width="100%",this.el.style.height="100%",this.root=new d(this.el);let r=q.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 b(t){if(t==null)return;if(typeof t=="string"||me(t))return t;let e=U.get(t);if(e)return e;let o=Ce(t);return U.set(t,o),o}var J=new WeakMap,_=new WeakMap,Y=new WeakMap,Q=new WeakMap;function h(t){return(typeof t=="function"||typeof t=="object")&&t!==null}function he(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(y.createElement(t,he(o)))}}}function w(t){if(!t)return;if(typeof t=="function"&&fe(t)||!h(t))return t;let e=J.get(t);if(e)return e;let o=we(t);return J.set(t,o),o}function Se(t){let e=t.colDef?.tooltipComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function pe(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(y.createElement(t,Se(o)))}}}function S(t){if(!t)return;if(typeof t=="function"&&ge(t)||!h(t))return t;let e=_.get(t);if(e)return e;let o=pe(t);return _.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:S(o.tooltip.component)}}}}function X(t){return t==null||typeof t=="string"?t:S(t)}function Me(t){let e=t.colDef?.actionFrameComponentParams;return e==null||typeof e!="object"?t:{...t,...e}}function Pe(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(y.createElement(t,Me(o)))}}}function Z(t){if(!t)return;if(typeof t=="function"&&ye(t)||!h(t))return t;let e=Y.get(t);if(e)return e;let o=Pe(t);return Y.set(t,o),o}function ve(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(y.createElement(t,o))}}}function F(t){if(!t)return;if(typeof t=="function"&&Re(t)||!h(t))return t;let e=Q.get(t);if(e)return e;let o=ve(t);return Q.set(t,o),o}function $(t){if(t)return{...t,valueComponent:F(t.valueComponent),selectAllComponent:F(t.selectAllComponent),blanksComponent:F(t.blanksComponent)}}function Ee(t){return{...t,cellRenderer:w(t.cellRenderer),cellEditor:b(t.cellEditor),tooltipComponent:S(t.tooltipComponent),headerTooltip:X(t.headerTooltip),actionFrameComponent:Z(t.actionFrameComponent),filterParams:$(t.filterParams),children:t.children?I(t.children)??void 0:void 0}}function I(t){return t==null?t:t.map(e=>Ee(e))}function ee(t){if(t==null)return;let e={...t};return"cellRenderer"in t&&(e.cellRenderer=w(t.cellRenderer)),"cellEditor"in t&&(e.cellEditor=b(t.cellEditor)),"tooltipComponent"in t&&(e.tooltipComponent=S(t.tooltipComponent)),"headerTooltip"in t&&(e.headerTooltip=X(t.headerTooltip)),"actionFrameComponent"in t&&(e.actionFrameComponent=Z(t.actionFrameComponent)),"filterParams"in t&&(e.filterParams=$(t.filterParams)),e}function n(t,e,o){o!=null&&(t[e]=o)}function te(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,"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,"onCellValueChanged",t.onCellValueChanged),n(e,"onSelectionChanged",t.onSelectionChanged),n(e,"onSortChanged",t.onSortChanged),n(e,"onFilterChanged",t.onFilterChanged),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,"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,"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,"loadingMessage",t.loadingMessage),n(e,"noRowsMessage",t.noRowsMessage),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=ee(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 Te from"react";var M=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let r=[],i=o,s=this.opts.getBodyMenuItems?this.opts.getBodyMenuItems({ctx:e,items:i}):i;return{items:this.normalizeItems(s,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),s=this.normalizeSlot(r.right,o);return{...r,left:i,right:s,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(Te.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 d(o);return r.render(e),{el:o,unmount:()=>r.destroy()}}};import be from"react";var P=class{constructor(e){this.opts=e}resolveMenuItems(e,o){let r=[],i=o,s=this.opts.getColumnMenuItems?this.opts.getColumnMenuItems({ctx:e,items:i}):i;return{items:this.normalizeItems(s,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),s=this.normalizeSlot(r.right,o);return{...r,left:i,right:s,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(be.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 d(o);return r.render(e),{el:o,unmount:()=>r.destroy()}}};import{jsx as Ge}from"react/jsx-runtime";function C(t,e){if(t){if(typeof t=="function"){t(e);return}t.current=e}}function Ae(t){if(!t.destroyed){t.destroyed=!0;try{t.api.destroy()}catch{}}}var xe=Fe.forwardRef(function(e,o){let r=u(null),i=u(null),s=u(e.onGridReady),R=u(e.getColumnMenuItems),f=u(e.bodyContextMenu),A=u(e.onCellClicked),x=u(e.onRowClicked),G=u(e.onCellValueChanged),O=u(e.onSelectionChanged),D=u(e.onSortChanged),k=u(e.onFilterChanged),H=u(e.onHistoryChanged),B=u(e.onBeforeCellCommit);s.current=e.onGridReady,R.current=e.getColumnMenuItems,f.current=e.bodyContextMenu,A.current=e.onCellClicked,x.current=e.onRowClicked,G.current=e.onCellValueChanged,O.current=e.onSelectionChanged,D.current=e.onSortChanged,k.current=e.onFilterChanged,H.current=e.onHistoryChanged,B.current=e.onBeforeCellCommit,a(()=>{let c=r.current;if(!c)return;let m=te(e);m.onCellClicked=l=>A.current?.(l),m.onRowClicked=l=>x.current?.(l),m.onCellValueChanged=l=>G.current?.(l),m.onSelectionChanged=l=>O.current?.(l),m.onSortChanged=l=>D.current?.(l),m.onFilterChanged=l=>k.current?.(l),m.onHistoryChanged=l=>H.current?.(l),m.onBeforeCellCommit=l=>B.current?.(l);let g=Ie(c,{...m,menuAdapter:new P({getColumnMenuItems:l=>R.current?.(l)??l.items}),bodyMenuAdapter:new M({getBodyMenuItems:l=>{let j=f.current;return typeof j=="function"?j(l):l.items}})}),v={api:g,destroyed:!1};return i.current=v,C(o,g),C(e.apiRef,g),s.current?.(g),()=>{i.current===v&&(i.current=null),C(o,null),C(e.apiRef,null),Ae(v)}},[]),a(()=>{let c=i.current?.api??null;return C(o,c),C(e.apiRef,c),()=>{C(o,null),C(e.apiRef,null)}},[o,e.apiRef]),a(()=>{let c=i.current?.api;c&&c.updateGridOptions({columnDefs:I(e.columnDefs)})},[e.columnDefs]),a(()=>{let c=i.current?.api;c&&e.rowModelType!=="serverSide"&&c.setRowData(e.rowData??e.data??[])},[e.data,e.rowData,e.rowModelType]),a(()=>{i.current?.api.updateGridOptions({groupDisplayType:e.groupDisplayType})},[e.groupDisplayType]),a(()=>{i.current?.api.updateGridOptions({groupSortMode:e.groupSortMode})},[e.groupSortMode]),a(()=>{i.current?.api.updateGridOptions({groupRowsSelectable:e.groupRowsSelectable})},[e.groupRowsSelectable]),a(()=>{i.current?.api.updateGridOptions({isRowSelectable:e.isRowSelectable})},[e.isRowSelectable]);let ne=JSON.stringify(e.rowSelection??null),V=u(!1);a(()=>{if(!V.current){V.current=!0;return}i.current?.api.updateGridOptions({rowSelection:e.rowSelection})},[ne]),a(()=>{i.current?.api.setTreeDataKeyboardNavigationOptions({keyboardNavigationMode:e.treeData?.keyboardNavigationMode,enableKeyboardNavigationModeSwitch:e.treeData?.enableKeyboardNavigationModeSwitch??!1})},[e.treeData?.keyboardNavigationMode,e.treeData?.enableKeyboardNavigationModeSwitch]),a(()=>{i.current?.api.updateGridOptions({pinnedTopRowData:e.pinnedTopRowData,pinnedBottomRowData:e.pinnedBottomRowData,isRowPinned:e.isRowPinned,groupRowsSticky:e.groupRowsSticky})},[e.pinnedTopRowData,e.pinnedBottomRowData,e.isRowPinned,e.groupRowsSticky]),a(()=>{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,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.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]),a(()=>{let c=i.current;!c||e.rowModelType!=="serverSide"||e.serverSideDataSource&&c.api.updateGridOptions({serverSideDataSource:e.serverSideDataSource})},[e.rowModelType,e.serverSideDataSource]),a(()=>{let c=i.current;!c||e.rowModelType!=="serverSide"||e.serverSideAggregationSource&&c.api.updateGridOptions({serverSideAggregationSource:e.serverSideAggregationSource})},[e.rowModelType,e.serverSideAggregationSource]),a(()=>{let c=i.current?.api;c&&c.dispatch({type:"overlayShow",overlayType:e.loading?"loading":"none"})},[e.loading]),a(()=>{i.current?.api.updateGridOptions({pagination:e.pagination})},[e.pagination]);let oe=JSON.stringify(e.paginationControls??null),L=u(!1);a(()=>{if(!L.current){L.current=!0;return}i.current?.api.updateGridOptions({paginationControls:e.paginationControls})},[oe]);let ie=JSON.stringify(e.quickFilter??null),N=u(!1);a(()=>{if(!N.current){N.current=!0;return}i.current?.api.updateGridOptions({quickFilter:e.quickFilter})},[ie]);let re=JSON.stringify(e.tooltip??null),z=u(!1);a(()=>{if(!z.current){z.current=!0;return}i.current?.api.updateGridOptions({tooltip:e.tooltip})},[re]);let ae=JSON.stringify(e.columnPanel??null),K=u(!1);a(()=>{if(!K.current){K.current=!0;return}i.current?.api.updateGridOptions({columnPanel:e.columnPanel})},[ae]);let le=JSON.stringify(e.toolbar??null),W=u(!1);return a(()=>{if(!W.current){W.current=!0;return}i.current?.api.updateGridOptions({toolbar:e.toolbar})},[le]),a(()=>{i.current?.api.updateGridOptions({savedViews:e.savedViews})},[e.savedViews]),a(()=>{i.current?.api.updateGridOptions({theme:e.theme,icons:{...e.theme?.getIcons(),...e.icons}})},[e.theme,e.icons]),Ge("div",{ref:r,className:e.className,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",...e.style}})});export{xe as Grid};
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@agility-workbench/react-grid",
3
+ "version": "1.0.0",
4
+ "description": "React bindings for @agility-workbench/grid — a high-performance data grid.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Himanshu M",
8
+ "homepage": "https://agilityworkbench.dev",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/agility-workbench/agility-workbench.git",
12
+ "directory": "packages/react-grid"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/agility-workbench/agility-workbench/issues"
16
+ },
17
+ "keywords": [
18
+ "data-grid",
19
+ "datagrid",
20
+ "table",
21
+ "react",
22
+ "react-table",
23
+ "virtualized",
24
+ "typescript",
25
+ "data-table",
26
+ "spreadsheet"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "provenance": true
31
+ },
32
+ "sideEffects": false,
33
+ "main": "./dist/index.cjs",
34
+ "module": "./dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "import": {
39
+ "types": "./dist/index.d.ts",
40
+ "default": "./dist/index.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ }
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
49
+ "files": [
50
+ "dist",
51
+ "README.md",
52
+ "LICENSE"
53
+ ],
54
+ "engines": {
55
+ "node": ">=18"
56
+ },
57
+ "scripts": {
58
+ "build": "npm run clean && tsup",
59
+ "typecheck": "tsc --noEmit",
60
+ "clean": "rm -rf dist",
61
+ "prepublishOnly": "npm run build"
62
+ },
63
+ "dependencies": {
64
+ "@agility-workbench/grid": "^1.0.0"
65
+ },
66
+ "peerDependencies": {
67
+ "react": ">=18.0.0",
68
+ "react-dom": ">=18.0.0"
69
+ },
70
+ "devDependencies": {
71
+ "@types/react": "^19.2.0",
72
+ "@types/react-dom": "^19.2.3"
73
+ }
74
+ }