@opencorestack/opengridx 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +198 -19
- package/docs/API_REFERENCE.md +236 -24
- package/docs/components/datagrid.md +5 -3
- package/docs/features/editing-reordering.md +11 -7
- package/docs/features/filtering.md +10 -8
- package/docs/features/selection.md +2 -1
- package/docs/features/sorting-pagination.md +3 -1
- package/docs/features/state-persistence.md +1 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [1.0.2] — July 30, 2026 📚
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **`GridColDef` documentation**: Added all previously undocumented column properties — `flex`, `minWidth`, `maxWidth`, `align`, `headerAlign`, `description`, `editable`, `renderHeader`, `renderEditCell`, `cellClassName`, `headerClassName`, `disableColumnMenu`, `groupable`, `aggregable`, `availableAggregationFunctions`, `valueOptions` (for `singleSelect`), `colSpan`, `rowSpan`. Both `README.md` and `docs/API_REFERENCE.md` now carry the complete table.
|
|
12
|
+
- **Hooks documentation**: Expanded the stubs in `docs/API_REFERENCE.md` into full reference entries. `usePivot` (was entirely missing), `useGridStateStorage` (was one sentence — now has a full options + return table and code example), `useAggregation` (now has params/return tables and built-in function list), `useGridApiRef` (corrected description and added usage example).
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## [1.0.1] — July 30, 2026 📚
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- **Bundled documentation accuracy**: All doc files shipped inside the npm package (`docs/`) have been corrected to match the actual v1.0.0 API. Key fixes: removed non-existent `pageSize` standalone prop (correct API is `paginationModel` + `pageSizeOptions`), fixed `height` type to `number | string`, corrected `onColumnOrderChange` params shape, removed non-existent `isRowSelectable` and `reorderable` props, fixed `GridFilterModel.items` type, added missing `GridApi` methods (`getFilterModel`, `getAllColumns`, `setPageSize`, `getAggregationResult`, `getAggregationModel`, `copySelectedRows`), and corrected `GridInitialState` persisted state fields. AI agents (Cursor, Copilot, Windsurf) reading bundled docs will now generate accurate code.
|
|
20
|
+
- **README API reference**: Same prop and type corrections applied — complete `apiRef` method list, new prop tables for Events, Columns, Pinning, Inline Editing, Row Reordering, and updated comparison table.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
8
24
|
## [1.0.0] — July 30, 2026 🚀
|
|
9
25
|
|
|
10
26
|
First stable public release. All 32 demo pages ship with a live source viewer. npm publish workflow is live.
|
package/README.md
CHANGED
|
@@ -40,14 +40,14 @@ const columns: GridColDef[] = [
|
|
|
40
40
|
{ field: 'name', headerName: 'Name', width: 180 },
|
|
41
41
|
{ field: 'role', headerName: 'Role', width: 150 },
|
|
42
42
|
{ field: 'salary', headerName: 'Salary', width: 120, type: 'number',
|
|
43
|
-
valueFormatter: ({ value }) => `$${value.toLocaleString()}` },
|
|
43
|
+
valueFormatter: ({ value }) => `$${(value as number).toLocaleString()}` },
|
|
44
44
|
{ field: 'department', headerName: 'Department', width: 160 },
|
|
45
45
|
];
|
|
46
46
|
|
|
47
47
|
const rows = [
|
|
48
|
-
{ id: 1, name: 'Jon Snow',
|
|
49
|
-
{ id: 2, name: 'Cersei Lannister', role: 'Manager',
|
|
50
|
-
{ id: 3, name: 'Arya Stark',
|
|
48
|
+
{ id: 1, name: 'Jon Snow', role: 'Engineer', salary: 95000, department: 'Defense' },
|
|
49
|
+
{ id: 2, name: 'Cersei Lannister', role: 'Manager', salary: 140000, department: 'Management' },
|
|
50
|
+
{ id: 3, name: 'Arya Stark', role: 'Analyst', salary: 65000, department: 'Special Ops' },
|
|
51
51
|
];
|
|
52
52
|
|
|
53
53
|
export default function App() {
|
|
@@ -77,18 +77,23 @@ export default function App() {
|
|
|
77
77
|
- **Clipboard**: `Ctrl+C` / `Cmd+C` copies selected rows as TSV for Excel/Sheets.
|
|
78
78
|
- **Accessibility**: WCAG 2.1 AA — full ARIA roles and keyboard navigation.
|
|
79
79
|
- **Theming**: CSS variable API with 5 built-in themes + custom theme support.
|
|
80
|
+
- **Column & Row Reordering**: Drag-and-drop column reordering and row reordering.
|
|
81
|
+
- **Inline Cell Editing**: Full inline editing with `processRowUpdate` validation.
|
|
82
|
+
- **State Persistence**: Save and restore grid state (sort, filter, columns) via `useGridStateStorage`.
|
|
80
83
|
- **AI-Native Integration**: Shipped with raw `lib/` source and `docs/` inside the npm package, allowing AI agents (Cursor, Copilot, Windsurf) to flawlessly implement features by "seeing" the internal logic.
|
|
81
84
|
|
|
82
85
|
---
|
|
83
86
|
|
|
84
87
|
## 🤖 AI-Powered Implementation
|
|
85
88
|
|
|
86
|
-
OpenGridX is built for the era of AI-native development. When you install `@opencorestack/opengridx`, we include the full raw source code and markdown documentation in your `node_modules`.
|
|
89
|
+
OpenGridX is built for the era of AI-native development. When you install `@opencorestack/opengridx`, we include the full raw source code and markdown documentation in your `node_modules`.
|
|
87
90
|
|
|
88
91
|
This means that **Cursor**, **GitHub Copilot**, **Windsurf**, and other AI agents can read the actual implementation patterns and docs to accurately help you build complex features like server-side tree data or pivot tables without guessing.
|
|
89
92
|
|
|
90
93
|
> **Tip for Cursor/Copilot users:** If your AI is struggling, tell it to "Read the docs and source in `./node_modules/@opencorestack/opengridx/docs`" for instant context.
|
|
91
94
|
|
|
95
|
+
---
|
|
96
|
+
|
|
92
97
|
## 📐 API Reference
|
|
93
98
|
|
|
94
99
|
### Core Props
|
|
@@ -97,14 +102,57 @@ This means that **Cursor**, **GitHub Copilot**, **Windsurf**, and other AI agent
|
|
|
97
102
|
| :--- | :--- | :--- | :--- |
|
|
98
103
|
| `rows` | `GridRowModel[]` | — | **Required.** Array of data rows. |
|
|
99
104
|
| `columns` | `GridColDef[]` | — | **Required.** Column definitions. |
|
|
100
|
-
| `height` | `number` | `500` | Grid height in pixels. |
|
|
105
|
+
| `height` | `number \| string` | `500` | Grid height in pixels or CSS string (e.g. `'100%'`). |
|
|
106
|
+
| `autoHeight` | `boolean` | `false` | Expands grid height to fit all rows. |
|
|
101
107
|
| `loading` | `boolean` | `false` | Shows skeleton loader when `true`. |
|
|
108
|
+
| `density` | `'compact' \| 'standard' \| 'comfortable'` | `'standard'` | Visual row density. |
|
|
102
109
|
| `checkboxSelection` | `boolean` | `false` | Enables checkbox column for row selection. |
|
|
103
110
|
| `pagination` | `boolean` | `false` | Enables client-side pagination. |
|
|
104
|
-
| `
|
|
111
|
+
| `paginationModel` | `{ page: number; pageSize: number }` | — | Controlled pagination state. |
|
|
112
|
+
| `onPaginationModelChange` | `(model) => void` | — | Fires on page or page size change. |
|
|
113
|
+
| `pageSizeOptions` | `number[]` | `[10, 25, 50]` | Available page size options. |
|
|
105
114
|
| `getRowId` | `(row) => GridRowId` | `row.id` | Custom row ID accessor. |
|
|
106
115
|
| `rowHeight` | `number` | `52` | Row height in pixels. |
|
|
107
116
|
| `headerHeight` | `number` | `56` | Header height in pixels. |
|
|
117
|
+
| `noRowsLabel` | `string` | — | Custom empty-state message. |
|
|
118
|
+
| `className` | `string` | — | Custom CSS class on the grid container. |
|
|
119
|
+
| `style` | `React.CSSProperties` | — | Custom inline styles on the grid container. |
|
|
120
|
+
|
|
121
|
+
### Column Definitions (`GridColDef`)
|
|
122
|
+
|
|
123
|
+
| Property | Type | Default | Description |
|
|
124
|
+
| :--- | :--- | :--- | :--- |
|
|
125
|
+
| `field` | `string` | — | **Required.** Must match the row object key. |
|
|
126
|
+
| `headerName` | `string` | — | Header label text. |
|
|
127
|
+
| `description` | `string` | — | Tooltip on header hover. |
|
|
128
|
+
| `width` | `number \| string` | `100` | Fixed width in px. |
|
|
129
|
+
| `flex` | `number` | — | Flex-grow weight — fills remaining space. Cannot be combined with `width`. |
|
|
130
|
+
| `minWidth` | `number` | — | Minimum width in px, enforced during resize. |
|
|
131
|
+
| `maxWidth` | `number` | — | Maximum width in px, enforced during resize. |
|
|
132
|
+
| `align` | `'left' \| 'center' \| 'right'` | `'left'` | Cell content alignment. |
|
|
133
|
+
| `headerAlign` | `'left' \| 'center' \| 'right'` | `'left'` | Header content alignment. |
|
|
134
|
+
| `type` | `'string' \| 'number' \| 'date' \| 'boolean' \| 'singleSelect' \| 'image'` | `'string'` | Drives filter operators and default formatting. |
|
|
135
|
+
| `valueOptions` | `Array<string \| number \| { value, label }>` | — | Options list for `type: 'singleSelect'`. |
|
|
136
|
+
| `editable` | `boolean` | `false` | Enables inline cell editing. Pair with `processRowUpdate`. |
|
|
137
|
+
| `valueGetter` | `(params) => unknown` | — | Derive a computed cell value from the row. |
|
|
138
|
+
| `valueFormatter` | `(params) => string` | — | Format the display string (does not affect edit or sort). |
|
|
139
|
+
| `renderCell` | `(params) => ReactNode` | — | Fully custom cell renderer. |
|
|
140
|
+
| `renderHeader` | `(params) => ReactNode` | — | Custom header cell renderer. |
|
|
141
|
+
| `renderEditCell` | `(params) => ReactNode` | — | Custom editor rendered in edit mode. |
|
|
142
|
+
| `cellClassName` | `string \| ((params) => string)` | — | CSS class on every cell; use a function for conditional per-row styling. |
|
|
143
|
+
| `headerClassName` | `string` | — | CSS class on the header cell. |
|
|
144
|
+
| `colSpan` | `number \| ((params) => number)` | — | Merge cells horizontally. |
|
|
145
|
+
| `rowSpan` | `number \| ((params) => number)` | — | Merge cells vertically. |
|
|
146
|
+
| `sortable` | `boolean` | `true` | Enable/disable column sorting. |
|
|
147
|
+
| `filterable` | `boolean` | `true` | Enable/disable column filtering. |
|
|
148
|
+
| `resizable` | `boolean` | `true` | Allow drag-resize. |
|
|
149
|
+
| `hideable` | `boolean` | `true` | Allow hiding via the column panel. |
|
|
150
|
+
| `pinnable` | `boolean` | `true` | Allow pinning via the UI. |
|
|
151
|
+
| `disableColumnMenu` | `boolean` | `false` | Hide the column header context menu. |
|
|
152
|
+
| `exportable` | `boolean` | `true` | Set to `false` to exclude from all exports. |
|
|
153
|
+
| `groupable` | `boolean` | `true` | Allow as a row grouping dimension. |
|
|
154
|
+
| `aggregable` | `boolean` | `true` | Allow aggregation on this column. |
|
|
155
|
+
| `availableAggregationFunctions` | `string[]` | all | Restrict which aggregation functions are offered. |
|
|
108
156
|
|
|
109
157
|
### Selection
|
|
110
158
|
|
|
@@ -113,17 +161,37 @@ This means that **Cursor**, **GitHub Copilot**, **Windsurf**, and other AI agent
|
|
|
113
161
|
| `rowSelectionModel` | `GridRowId[]` | Controlled selected row IDs. |
|
|
114
162
|
| `onRowSelectionModelChange` | `(model: GridRowId[]) => void` | Fires on selection change. |
|
|
115
163
|
| `disableRowSelectionOnClick` | `boolean` | Prevent row click from toggling selection. |
|
|
164
|
+
| `disableMultipleRowSelection` | `boolean` | Restrict to single-row selection. |
|
|
165
|
+
| `pinCheckboxColumn` | `boolean` | Keeps the checkbox column visible during horizontal scroll. |
|
|
116
166
|
|
|
117
167
|
### Sorting & Filtering
|
|
118
168
|
|
|
119
169
|
| Prop | Type | Description |
|
|
120
170
|
| :--- | :--- | :--- |
|
|
121
171
|
| `sortModel` | `GridSortItem[]` | Controlled sort model. |
|
|
122
|
-
| `onSortModelChange` | `(model) => void` | Fires on sort change. |
|
|
172
|
+
| `onSortModelChange` | `(model: GridSortItem[]) => void` | Fires on sort change. |
|
|
123
173
|
| `filterModel` | `GridFilterModel` | Controlled filter model. |
|
|
124
|
-
| `onFilterModelChange` | `(model) => void` | Fires on filter change. |
|
|
174
|
+
| `onFilterModelChange` | `(model: GridFilterModel) => void` | Fires on filter change. |
|
|
125
175
|
| `disableColumnFilter` | `boolean` | Disables column-level filtering. |
|
|
126
176
|
|
|
177
|
+
### Columns
|
|
178
|
+
|
|
179
|
+
| Prop | Type | Description |
|
|
180
|
+
| :--- | :--- | :--- |
|
|
181
|
+
| `columnVisibilityModel` | `GridColumnVisibilityModel` | Controlled column visibility. |
|
|
182
|
+
| `onColumnVisibilityModelChange` | `(model) => void` | Fires when column visibility changes. |
|
|
183
|
+
| `columnOrder` | `string[]` | Controlled column field order. |
|
|
184
|
+
| `onColumnOrderChange` | `(params) => void` | Fires when columns are reordered. |
|
|
185
|
+
| `disableColumnReorder` | `boolean` | Disables drag-and-drop column reordering. |
|
|
186
|
+
|
|
187
|
+
### Events
|
|
188
|
+
|
|
189
|
+
| Prop | Type | Description |
|
|
190
|
+
| :--- | :--- | :--- |
|
|
191
|
+
| `onRowClick` | `(params: GridRowParams) => void` | Fires when a row is clicked. |
|
|
192
|
+
| `onCellClick` | `(params: GridCellParams) => void` | Fires when a cell is clicked. |
|
|
193
|
+
| `onRowsScrollEnd` | `(params: GridRowScrollEndParams) => void` | Fires when scrolling reaches the bottom. |
|
|
194
|
+
|
|
127
195
|
### Server-Side
|
|
128
196
|
|
|
129
197
|
| Prop | Type | Description |
|
|
@@ -134,11 +202,60 @@ This means that **Cursor**, **GitHub Copilot**, **Windsurf**, and other AI agent
|
|
|
134
202
|
| `dataSource` | `GridDataSource` | Server-side data adapter. |
|
|
135
203
|
| `rowCount` | `number` | Total rows for server-side pagination. |
|
|
136
204
|
|
|
205
|
+
### Pinning
|
|
206
|
+
|
|
207
|
+
| Prop | Type | Description |
|
|
208
|
+
| :--- | :--- | :--- |
|
|
209
|
+
| `pinnedColumns` | `GridColumnPinning` | Pin columns to `left` or `right`. |
|
|
210
|
+
| `onPinnedColumnsChange` | `(model) => void` | Fires when column pinning changes. |
|
|
211
|
+
| `pinnedRows` | `GridRowPinning` | Pin rows to `top` or `bottom`. |
|
|
212
|
+
| `onPinnedRowsChange` | `(model) => void` | Fires when row pinning changes. |
|
|
213
|
+
|
|
214
|
+
### Inline Editing
|
|
215
|
+
|
|
216
|
+
| Prop | Type | Description |
|
|
217
|
+
| :--- | :--- | :--- |
|
|
218
|
+
| `isCellEditable` | `(params: GridCellParams) => boolean` | Per-cell editability predicate. |
|
|
219
|
+
| `processRowUpdate` | `(newRow, oldRow) => R \| Promise<R>` | Handles row save; supports async validation. |
|
|
220
|
+
| `onProcessRowUpdateError` | `(error: unknown) => void` | Fires if `processRowUpdate` throws. |
|
|
221
|
+
|
|
222
|
+
### Row Reordering
|
|
223
|
+
|
|
224
|
+
| Prop | Type | Description |
|
|
225
|
+
| :--- | :--- | :--- |
|
|
226
|
+
| `rowReordering` | `boolean` | Enables drag-and-drop row reordering. |
|
|
227
|
+
| `onRowOrderChange` | `(params) => void` | Fires when rows are reordered. |
|
|
228
|
+
|
|
229
|
+
### Advanced Features
|
|
230
|
+
|
|
231
|
+
| Prop | Type | Description |
|
|
232
|
+
| :--- | :--- | :--- |
|
|
233
|
+
| `treeData` | `boolean` | Enables hierarchical tree data display. |
|
|
234
|
+
| `getTreeDataPath` | `(row) => string[]` | Returns the path array for each row in tree mode. |
|
|
235
|
+
| `groupingColDef` | `GridColDef` | Overrides the auto-generated grouping column. |
|
|
236
|
+
| `defaultGroupingExpansionDepth` | `number` | Initial expansion depth for tree data. |
|
|
237
|
+
| `rowGroupingModel` | `GridRowGroupingModel` | Controlled row grouping state. |
|
|
238
|
+
| `onRowGroupingModelChange` | `(model) => void` | Fires when grouping changes. |
|
|
239
|
+
| `aggregationModel` | `GridAggregationModel` | Controlled aggregation state (e.g. `{ salary: 'sum' }`). |
|
|
240
|
+
| `onAggregationModelChange` | `(model) => void` | Fires when aggregation changes. |
|
|
241
|
+
| `pivotMode` | `boolean` | Switches the grid to multidimensional pivot mode. |
|
|
242
|
+
| `pivotModel` | `GridPivotModel` | Controlled pivot configuration (rows, columns, values). |
|
|
243
|
+
| `onPivotModelChange` | `(model) => void` | Fires when pivot model changes. |
|
|
244
|
+
|
|
245
|
+
### Master-Detail
|
|
246
|
+
|
|
247
|
+
| Prop | Type | Description |
|
|
248
|
+
| :--- | :--- | :--- |
|
|
249
|
+
| `getDetailPanelContent` | `(params) => ReactNode` | Renders the expandable detail panel. |
|
|
250
|
+
| `getDetailPanelHeight` | `(params) => number \| 'auto'` | Controls detail panel height. |
|
|
251
|
+
| `detailPanelExpandedRowIds` | `Set<GridRowId>` | Controlled expanded rows. |
|
|
252
|
+
| `onDetailPanelExpandedRowIdsChange` | `(ids) => void` | Fires when expanded rows change. |
|
|
253
|
+
|
|
137
254
|
### Customization
|
|
138
255
|
|
|
139
256
|
| Prop | Type | Description |
|
|
140
257
|
| :--- | :--- | :--- |
|
|
141
|
-
| `slots` | `GridSlots` | Replace built-in components (toolbar, pagination, overlays). |
|
|
258
|
+
| `slots` | `GridSlots` | Replace built-in components (toolbar, pagination, overlays, footer). |
|
|
142
259
|
| `slotProps` | `GridSlotProps` | Pass custom props to slot components. |
|
|
143
260
|
| `getRowClassName` | `(params) => string` | Add custom CSS class to rows. |
|
|
144
261
|
| `getCellClassName` | `(params) => string` | Add custom CSS class to cells. |
|
|
@@ -150,14 +267,42 @@ This means that **Cursor**, **GitHub Copilot**, **Windsurf**, and other AI agent
|
|
|
150
267
|
const apiRef = useGridApiRef();
|
|
151
268
|
<DataGrid apiRef={apiRef} ... />
|
|
152
269
|
|
|
153
|
-
//
|
|
270
|
+
// Rows
|
|
271
|
+
apiRef.current.getRow(id) // → GridRowModel | null
|
|
272
|
+
apiRef.current.getAllRows() // → GridRowModel[]
|
|
273
|
+
apiRef.current.getVisibleRows() // → GridRowModel[] (post-filter/sort)
|
|
274
|
+
|
|
275
|
+
// Columns
|
|
276
|
+
apiRef.current.getColumn(field) // → GridColDef | null
|
|
277
|
+
apiRef.current.getAllColumns() // → GridColDef[]
|
|
278
|
+
apiRef.current.getVisibleColumns() // → GridColDef[]
|
|
279
|
+
|
|
280
|
+
// Selection
|
|
281
|
+
apiRef.current.selectRow(id, true)
|
|
282
|
+
apiRef.current.selectRows([id1, id2], true)
|
|
154
283
|
apiRef.current.getSelectedRows() // → GridRowId[]
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
apiRef.current.setFilterModel(model) // programmatic filter
|
|
284
|
+
|
|
285
|
+
// Sorting
|
|
158
286
|
apiRef.current.sortColumn('name', 'asc')
|
|
287
|
+
apiRef.current.getSortModel() // → GridSortItem[]
|
|
288
|
+
|
|
289
|
+
// Filtering
|
|
290
|
+
apiRef.current.setFilterModel(model)
|
|
291
|
+
apiRef.current.getFilterModel() // → GridFilterModel
|
|
292
|
+
|
|
293
|
+
// Pagination
|
|
159
294
|
apiRef.current.setPage(2)
|
|
160
|
-
apiRef.current.
|
|
295
|
+
apiRef.current.setPageSize(50)
|
|
296
|
+
|
|
297
|
+
// Scroll
|
|
298
|
+
apiRef.current.scrollToIndexes({ rowIndex: 100, colIndex: 3 })
|
|
299
|
+
|
|
300
|
+
// Clipboard
|
|
301
|
+
apiRef.current.copySelectedRows() // → Promise<void>
|
|
302
|
+
|
|
303
|
+
// Aggregation
|
|
304
|
+
apiRef.current.getAggregationResult() // → Record<string, unknown> | null
|
|
305
|
+
apiRef.current.getAggregationModel() // → GridAggregationModel | null
|
|
161
306
|
```
|
|
162
307
|
|
|
163
308
|
---
|
|
@@ -186,6 +331,20 @@ Replace any built-in component with your own:
|
|
|
186
331
|
/>
|
|
187
332
|
```
|
|
188
333
|
|
|
334
|
+
### Built-in Toolbar
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
import { DataGrid, GridToolbar } from '@opencorestack/opengridx';
|
|
338
|
+
|
|
339
|
+
<DataGrid
|
|
340
|
+
rows={rows}
|
|
341
|
+
columns={columns}
|
|
342
|
+
slots={{ toolbar: GridToolbar }}
|
|
343
|
+
/>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
`GridToolbar` provides global search, column visibility panel, filter panel, and export controls out of the box.
|
|
347
|
+
|
|
189
348
|
### Export Functionality
|
|
190
349
|
|
|
191
350
|
OpenGridX has **two tiers of Excel export**:
|
|
@@ -214,6 +373,21 @@ printGrid(rows, columns, 'Report Title');
|
|
|
214
373
|
> npm install exceljs
|
|
215
374
|
> ```
|
|
216
375
|
|
|
376
|
+
### State Persistence
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
import { useGridStateStorage } from '@opencorestack/opengridx';
|
|
380
|
+
|
|
381
|
+
const { initialState, onStateChange } = useGridStateStorage('my-grid-key');
|
|
382
|
+
|
|
383
|
+
<DataGrid
|
|
384
|
+
rows={rows}
|
|
385
|
+
columns={columns}
|
|
386
|
+
initialState={initialState}
|
|
387
|
+
onStateChange={onStateChange}
|
|
388
|
+
/>
|
|
389
|
+
```
|
|
390
|
+
|
|
217
391
|
### Theming
|
|
218
392
|
|
|
219
393
|
```tsx
|
|
@@ -232,11 +406,11 @@ Built-in themes: `darkTheme`, `roseTheme`, `emeraldTheme`, `amberTheme`, `compac
|
|
|
232
406
|
|
|
233
407
|
| Artifact | Minified | Gzipped | Notes |
|
|
234
408
|
| :--- | :--- | :--- | :--- |
|
|
235
|
-
| **Core ES Module** (`opengridx.es.js`) |
|
|
236
|
-
| **Core UMD** (`opengridx.umd.js`) |
|
|
237
|
-
| **Styles** (`opengridx.css`) |
|
|
409
|
+
| **Core ES Module** (`opengridx.es.js`) | 242 KB | **58 KB** | Use this — tree-shakeable |
|
|
410
|
+
| **Core UMD** (`opengridx.umd.js`) | 164 KB | **48 KB** | CommonJS / CDN compat |
|
|
411
|
+
| **Styles** (`opengridx.css`) | 62 KB | **10 KB** | Auto-included |
|
|
238
412
|
| **ExcelJS** (optional peer dep) | — | — | `npm install exceljs` |
|
|
239
|
-
| **npm package download** | — | **
|
|
413
|
+
| **npm package download** | — | **613 KB** | Total compressed tarball |
|
|
240
414
|
|
|
241
415
|
- **Tree-shaking Ready**: ES Module build — bundlers (Vite, Webpack) only include what you use.
|
|
242
416
|
- **Zero UI Dependencies**: No MUI, Ant Design, or Radix. Pure React + vanilla CSS.
|
|
@@ -252,6 +426,8 @@ Full documentation at 👉 **[opencorestack.github.io/OpenGridX](https://opencor
|
|
|
252
426
|
### 🏛️ Components
|
|
253
427
|
- **[DataGrid](docs/components/datagrid.md)** — Main component props and slots
|
|
254
428
|
- **[Toolbar & Pagination](docs/components/toolbar.md)** — Supplemental UI components
|
|
429
|
+
- **[Filter Panel](docs/components/filter-panel.md)** — Advanced filter panel component
|
|
430
|
+
- **[Column Visibility](docs/components/column-visibility.md)** — Column show/hide panel
|
|
255
431
|
|
|
256
432
|
### 🚀 Features
|
|
257
433
|
- **[Virtualization](docs/features/virtualization.md)** — 60fps rendering for 100k+ rows
|
|
@@ -264,6 +440,7 @@ Full documentation at 👉 **[opencorestack.github.io/OpenGridX](https://opencor
|
|
|
264
440
|
- **[Infinite Scroll](docs/features/infinite-scroll.md)** — Seamless lazy-loading
|
|
265
441
|
- **[Export Guide](docs/features/export-guide.md)** — Excel, CSV, and Print
|
|
266
442
|
- **[Data Source](docs/features/data-source.md)** — Server-side integration
|
|
443
|
+
- **[Loading States](docs/features/loading-states.md)** — Skeleton and shimmer overlays
|
|
267
444
|
|
|
268
445
|
### 📊 Advanced Data
|
|
269
446
|
- **[Aggregation & Pivot](docs/features/aggregation-pivot.md)** — Summary totals
|
|
@@ -292,6 +469,8 @@ Most React grids gatekeep essential features like **Row Grouping**, **Excel Expo
|
|
|
292
469
|
| Advanced Filtering | ❌ | ✅ | ❌ | ✅ |
|
|
293
470
|
| Aggregation | ❌ | ✅ | ❌ | ✅ |
|
|
294
471
|
| Pivot Mode | ❌ | ✅ | ❌ | ✅ |
|
|
472
|
+
| Inline Cell Editing | ❌ | ✅ | ✅ | ✅ |
|
|
473
|
+
| State Persistence | ❌ | ✅ | ❌ | ✅ |
|
|
295
474
|
| **Price** | Free | **$$$** | Free (limited) | **Free** |
|
|
296
475
|
|
|
297
476
|
---
|
package/docs/API_REFERENCE.md
CHANGED
|
@@ -22,11 +22,15 @@ The main component for displaying and interacting with data.
|
|
|
22
22
|
| `checkboxSelection` | `boolean` | `false` | Enable row selection via checkboxes. |
|
|
23
23
|
| `pagination` | `boolean` | `false` | Enable the bottom pagination bar. |
|
|
24
24
|
| `paginationMode` | `'client' \| 'server' \| 'infinite'` | `'client'` | How to handle paging. |
|
|
25
|
-
| `paginationModel` | `GridPaginationModel` | `{page
|
|
25
|
+
| `paginationModel` | `GridPaginationModel` | — | Controlled pagination state (`{ page, pageSize }`). |
|
|
26
|
+
| `onPaginationModelChange` | `(model: GridPaginationModel) => void` | — | Fired when page or page size changes. |
|
|
27
|
+
| `pageSizeOptions` | `number[]` | `[10, 25, 50]` | Available page size options. |
|
|
26
28
|
| `rowCount` | `number` | — | Total rows (required for server-side paging). |
|
|
29
|
+
| `height` | `number \| string` | `undefined` | Total height of the grid container. |
|
|
30
|
+
| `density` | `'compact' \| 'standard' \| 'comfortable'` | `'standard'` | Visual row density. |
|
|
27
31
|
| `initialState` | `GridInitialState` | `undefined` | Starting state for sorting, filters, etc. |
|
|
28
32
|
| `slots` | `GridSlots` | `{}` | Custom component overrides. |
|
|
29
|
-
| `slotProps` | `Record<string,
|
|
33
|
+
| `slotProps` | `Record<string, unknown>` | `{}` | Props passed to custom slots. |
|
|
30
34
|
| `filterModel` | `GridFilterModel` | `undefined` | Active filters. |
|
|
31
35
|
| `sortModel` | `GridSortItem[]` | `undefined` | Active sorting. |
|
|
32
36
|
| `onRowClick` | `(params: GridRowParams) => void` | — | Fired when a row is clicked. |
|
|
@@ -54,8 +58,14 @@ Access these methods via the `apiRef` prop.
|
|
|
54
58
|
| `sortColumn(field, dir)` | `void` | Programmatically sort a column. |
|
|
55
59
|
| `getSortModel()` | `GridSortItem[]` | Get active sorting state. |
|
|
56
60
|
| `setFilterModel(model)` | `void` | Programmatically set filters. |
|
|
61
|
+
| `getFilterModel()` | `GridFilterModel` | Get the current filter model. |
|
|
57
62
|
| `setPage(page)` | `void` | Change current page (0-indexed). |
|
|
63
|
+
| `setPageSize(pageSize)` | `void` | Change the current page size. |
|
|
58
64
|
| `scrollToIndexes(params)` | `void` | Scroll to specific row/column index. |
|
|
65
|
+
| `getAllColumns()` | `GridColDef[]` | Get all defined columns. |
|
|
66
|
+
| `getAggregationResult()` | `Record<string, unknown> \| null` | Get current aggregation results. |
|
|
67
|
+
| `getAggregationModel()` | `GridAggregationModel \| null` | Get the active aggregation configuration. |
|
|
68
|
+
| `copySelectedRows()` | `Promise<void>` | Copy selected rows to clipboard as TSV. |
|
|
59
69
|
|
|
60
70
|
---
|
|
61
71
|
|
|
@@ -71,7 +81,7 @@ Used in Tree Data and Row Grouping hierarchies.
|
|
|
71
81
|
| `depth` | `number` | Nesting level (0 for root). |
|
|
72
82
|
| `isExpanded` | `boolean` | Current expansion state. |
|
|
73
83
|
| `children` | `GridRowId[]` | IDs of child nodes. |
|
|
74
|
-
| `groupingValue` | `
|
|
84
|
+
| `groupingValue` | `unknown` | The value this node is grouping by. |
|
|
75
85
|
| `aggregatedValues` | `object` | Sums/Avgs computed for this group. |
|
|
76
86
|
|
|
77
87
|
---
|
|
@@ -81,21 +91,71 @@ Used in Tree Data and Row Grouping hierarchies.
|
|
|
81
91
|
### `GridColDef`
|
|
82
92
|
Defines the behavior and appearance of a single column.
|
|
83
93
|
|
|
94
|
+
#### Sizing & Layout
|
|
95
|
+
|
|
96
|
+
| Property | Type | Default | Description |
|
|
97
|
+
| :--- | :--- | :--- | :--- |
|
|
98
|
+
| `field` | `string` | — | **Required.** Unique identifier matching the row object key. |
|
|
99
|
+
| `headerName` | `string` | — | Text shown in the column header cell. |
|
|
100
|
+
| `description` | `string` | — | Tooltip shown on header hover (accessibility label). |
|
|
101
|
+
| `width` | `number \| string` | `100` | Fixed width in pixels or a percentage string. |
|
|
102
|
+
| `minWidth` | `number` | — | Minimum width in pixels (enforced during resize). |
|
|
103
|
+
| `maxWidth` | `number` | — | Maximum width in pixels (enforced during resize). |
|
|
104
|
+
| `flex` | `number` | — | Flex grow factor — distributes remaining space proportionally. Mutually exclusive with a fixed `width`. |
|
|
105
|
+
| `align` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment of cell content. |
|
|
106
|
+
| `headerAlign` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment of the header cell content. |
|
|
107
|
+
|
|
108
|
+
#### Data & Type
|
|
109
|
+
|
|
110
|
+
| Property | Type | Default | Description |
|
|
111
|
+
| :--- | :--- | :--- | :--- |
|
|
112
|
+
| `type` | `'string' \| 'number' \| 'date' \| 'boolean' \| 'singleSelect' \| 'image'` | `'string'` | Data type — determines default filter operators and cell formatting. |
|
|
113
|
+
| `valueOptions` | `Array<string \| number \| { value: unknown; label: string }>` | — | Allowed values for `type: 'singleSelect'` — used in the filter dropdown and edit cell. |
|
|
114
|
+
| `valueGetter` | `(params: GridValueGetterParams) => unknown` | — | Derive a computed value from the row object. Runs before `valueFormatter` and `renderCell`. |
|
|
115
|
+
| `valueFormatter` | `(params: GridValueFormatterParams) => string` | — | Format the value into a display string (e.g. currency, dates). Does not affect editing or sorting. |
|
|
116
|
+
|
|
117
|
+
#### Rendering
|
|
118
|
+
|
|
119
|
+
| Property | Type | Description |
|
|
120
|
+
| :--- | :--- | :--- |
|
|
121
|
+
| `renderCell` | `(params: GridRenderCellParams) => ReactNode` | Fully custom cell renderer. Receives `value`, `row`, `field`, `rowIndex`, `colIndex`. |
|
|
122
|
+
| `renderHeader` | `(params: GridRenderHeaderParams) => ReactNode` | Custom header cell renderer. Use for icons, sort indicators, or rich headers. |
|
|
123
|
+
| `renderEditCell` | `(params: GridRenderCellParams) => ReactNode` | Custom editor rendered when the cell enters edit mode. Requires `editable: true`. |
|
|
124
|
+
|
|
125
|
+
#### Editing
|
|
126
|
+
|
|
127
|
+
| Property | Type | Default | Description |
|
|
128
|
+
| :--- | :--- | :--- | :--- |
|
|
129
|
+
| `editable` | `boolean` | `false` | Enables inline cell editing. Commit is handled by `DataGrid.processRowUpdate`. |
|
|
130
|
+
|
|
131
|
+
#### Spanning
|
|
132
|
+
|
|
133
|
+
| Property | Type | Description |
|
|
134
|
+
| :--- | :--- | :--- |
|
|
135
|
+
| `colSpan` | `number \| ((params: GridRenderCellParams) => number)` | Number of columns this cell merges horizontally. |
|
|
136
|
+
| `rowSpan` | `number \| ((params: GridRenderCellParams) => number)` | Number of rows this cell merges vertically. |
|
|
137
|
+
|
|
138
|
+
#### Styling
|
|
139
|
+
|
|
140
|
+
| Property | Type | Description |
|
|
141
|
+
| :--- | :--- | :--- |
|
|
142
|
+
| `cellClassName` | `string \| ((params: GridRenderCellParams) => string)` | CSS class applied to every cell in this column. Use a function for conditional per-row styling. |
|
|
143
|
+
| `headerClassName` | `string` | CSS class applied to the header cell. |
|
|
144
|
+
|
|
145
|
+
#### Feature Flags
|
|
146
|
+
|
|
84
147
|
| Property | Type | Default | Description |
|
|
85
148
|
| :--- | :--- | :--- | :--- |
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `valueFormatter` | `(params: GridValueFormatterParams) => string` | — | Format value for display. |
|
|
97
|
-
| `valueGetter` | `(params: GridValueGetterParams) => any` | — | Compute value from row data. |
|
|
98
|
-
| `renderCell` | `(params: GridRenderCellParams) => ReactNode` | — | Custom cell renderer. |
|
|
149
|
+
| `sortable` | `boolean` | `true` | Enable/disable sorting for this column. |
|
|
150
|
+
| `filterable` | `boolean` | `true` | Enable/disable filtering for this column. |
|
|
151
|
+
| `resizable` | `boolean` | `true` | Allow the user to drag-resize this column. |
|
|
152
|
+
| `hideable` | `boolean` | `true` | Allow the user to hide this column via the panel. |
|
|
153
|
+
| `pinnable` | `boolean` | `true` | Allow this column to be pinned via the UI. |
|
|
154
|
+
| `disableColumnMenu` | `boolean` | `false` | Hide the column header kebab/context menu. |
|
|
155
|
+
| `exportable` | `boolean` | `true` | Set to `false` to exclude from CSV, Excel, JSON, and Print exports. |
|
|
156
|
+
| `groupable` | `boolean` | `true` | Allow this column to be used as a row grouping dimension. |
|
|
157
|
+
| `aggregable` | `boolean` | `true` | Allow this column to be aggregated. |
|
|
158
|
+
| `availableAggregationFunctions` | `string[]` | all built-ins | Restrict which aggregation functions are available for this column (e.g. `['sum', 'avg']`). |
|
|
99
159
|
|
|
100
160
|
---
|
|
101
161
|
|
|
@@ -126,17 +186,169 @@ Context provider for overriding the grid's visual system.
|
|
|
126
186
|
## 🛠️ Hooks
|
|
127
187
|
|
|
128
188
|
### `useGridApiRef()`
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
189
|
+
|
|
190
|
+
Creates a typed ref to pass to the `apiRef` prop. Gives you imperative access to the grid after mount.
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import { useGridApiRef } from '@opencorestack/opengridx';
|
|
194
|
+
|
|
195
|
+
const apiRef = useGridApiRef();
|
|
196
|
+
|
|
197
|
+
// Pass to the grid
|
|
198
|
+
<DataGrid apiRef={apiRef} rows={rows} columns={columns} />
|
|
199
|
+
|
|
200
|
+
// Then call methods imperiously
|
|
201
|
+
apiRef.current.scrollToIndexes({ rowIndex: 0 });
|
|
202
|
+
apiRef.current.setFilterModel({ items: [] });
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
See the [Imperative API (`GridApi`)](#%EF%B8%8F-imperative-api-gridapi) table above for the full method list.
|
|
206
|
+
|
|
207
|
+
---
|
|
133
208
|
|
|
134
209
|
### `useAggregation(params)`
|
|
135
|
-
|
|
136
|
-
|
|
210
|
+
|
|
211
|
+
Headless hook for computing column summaries outside of the built-in `aggregationModel` prop. Useful when you need aggregation results for a custom footer or external display.
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
import { useAggregation } from '@opencorestack/opengridx';
|
|
215
|
+
|
|
216
|
+
const { aggregationResult, isLoading } = useAggregation({
|
|
217
|
+
rows,
|
|
218
|
+
aggregationModel: { salary: 'sum', age: 'avg' },
|
|
219
|
+
isServerSide: false,
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### Params (`UseAggregationParams`)
|
|
224
|
+
|
|
225
|
+
| Param | Type | Description |
|
|
226
|
+
| :--- | :--- | :--- |
|
|
227
|
+
| `rows` | `GridRowModel[]` | The rows to aggregate. |
|
|
228
|
+
| `aggregationModel` | `GridAggregationModel` | Map of `field → aggFn` (e.g. `{ salary: 'sum' }`). |
|
|
229
|
+
| `isServerSide` | `boolean` | If `true`, skips client computation and uses `serverAggregationResults`. |
|
|
230
|
+
| `filterModel` | `GridFilterModel` | Optional — restricts aggregation to filtered rows. |
|
|
231
|
+
| `sortModel` | `GridSortItem[]` | Optional — used when `dataSource` is provided. |
|
|
232
|
+
| `dataSource` | `GridDataSource` | Optional — server-side data adapter for async aggregation. |
|
|
233
|
+
| `serverAggregationResults` | `GridAggregationResult \| null` | Pre-fetched results when `isServerSide: true`. |
|
|
234
|
+
|
|
235
|
+
#### Return (`UseAggregationReturn`)
|
|
236
|
+
|
|
237
|
+
| Field | Type | Description |
|
|
238
|
+
| :--- | :--- | :--- |
|
|
239
|
+
| `aggregationResult` | `GridAggregationResult` | Map of `field → computed value`. |
|
|
240
|
+
| `isLoading` | `boolean` | `true` while a server-side fetch is in progress. |
|
|
241
|
+
| `error` | `unknown` | Set if the server-side fetch threw. |
|
|
242
|
+
|
|
243
|
+
**Built-in aggregation functions:** `sum`, `avg`, `min`, `max`, `count`, `unique`
|
|
244
|
+
|
|
245
|
+
You can also use `formatAggregationValue(value, fnName)` to produce a display string from a raw result.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### `usePivot(rawRows, rawCols, model, enabled)`
|
|
250
|
+
|
|
251
|
+
Headless hook that transforms a flat dataset into pivot rows and pivot column definitions. Pass the output directly to `<DataGrid rows={} columns={} />` when `pivotMode` is active.
|
|
252
|
+
|
|
253
|
+
```tsx
|
|
254
|
+
import { usePivot } from '@opencorestack/opengridx';
|
|
255
|
+
|
|
256
|
+
const { pivotRows, pivotColumns, isValid } = usePivot(
|
|
257
|
+
rows,
|
|
258
|
+
columns,
|
|
259
|
+
{
|
|
260
|
+
rowFields: ['department'],
|
|
261
|
+
columnFields: ['year'],
|
|
262
|
+
valueFields: [{ field: 'revenue', aggFn: 'sum' }],
|
|
263
|
+
},
|
|
264
|
+
isPivotEnabled,
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
<DataGrid
|
|
268
|
+
rows={isPivotEnabled ? pivotRows : rows}
|
|
269
|
+
columns={isPivotEnabled ? pivotColumns : columns}
|
|
270
|
+
/>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
#### Parameters
|
|
274
|
+
|
|
275
|
+
| Param | Type | Description |
|
|
276
|
+
| :--- | :--- | :--- |
|
|
277
|
+
| `rawRows` | `GridRowModel[]` | Original flat dataset. |
|
|
278
|
+
| `rawCols` | `GridColDef[]` | Original column definitions. |
|
|
279
|
+
| `model` | `GridPivotModel` | Pivot configuration — `rowFields`, `columnFields`, `valueFields`. |
|
|
280
|
+
| `enabled` | `boolean` | When `false`, returns empty arrays immediately (no computation). |
|
|
281
|
+
|
|
282
|
+
#### Return (`UsePivotReturn`)
|
|
283
|
+
|
|
284
|
+
| Field | Type | Description |
|
|
285
|
+
| :--- | :--- | :--- |
|
|
286
|
+
| `pivotRows` | `GridRowModel[]` | Transformed rows ready for the grid. |
|
|
287
|
+
| `pivotColumns` | `GridColDef[]` | Generated column definitions for each pivot key. |
|
|
288
|
+
| `colKeys` | `string[]` | The distinct column pivot values used. |
|
|
289
|
+
| `isValid` | `boolean` | `false` if the model is incomplete (e.g. no `rowFields` or `valueFields`). |
|
|
290
|
+
|
|
291
|
+
#### `GridPivotModel`
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
interface GridPivotModel {
|
|
295
|
+
rowFields: string[]; // fields to group rows by
|
|
296
|
+
columnFields: string[]; // fields to spread as columns
|
|
297
|
+
valueFields: Array<{
|
|
298
|
+
field: string;
|
|
299
|
+
aggFn: 'sum' | 'avg' | 'count' | 'min' | 'max';
|
|
300
|
+
headerName?: string;
|
|
301
|
+
}>;
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
---
|
|
137
306
|
|
|
138
307
|
### `useGridStateStorage(options)`
|
|
139
|
-
|
|
308
|
+
|
|
309
|
+
Persists grid state (sort, filters, pagination, column visibility, etc.) to `localStorage` and restores it on mount. Pass the returned values directly to `DataGrid`.
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
import { useGridStateStorage } from '@opencorestack/opengridx';
|
|
313
|
+
|
|
314
|
+
// Simple — just a storage key
|
|
315
|
+
const { initialState, onStateChange } = useGridStateStorage('my-grid');
|
|
316
|
+
|
|
317
|
+
// Advanced — with options
|
|
318
|
+
const { initialState, onStateChange, clearState } = useGridStateStorage({
|
|
319
|
+
key: 'my-grid',
|
|
320
|
+
debounceMs: 500, // default: 300
|
|
321
|
+
include: ['sorting', 'filter', 'pagination'], // persist only these slices
|
|
322
|
+
storage: sessionStorage, // default: localStorage
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
<DataGrid
|
|
326
|
+
rows={rows}
|
|
327
|
+
columns={columns}
|
|
328
|
+
initialState={initialState}
|
|
329
|
+
onStateChange={onStateChange}
|
|
330
|
+
/>
|
|
331
|
+
|
|
332
|
+
// Clear saved state (e.g. on a "Reset" button)
|
|
333
|
+
<button onClick={clearState}>Reset Grid</button>
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
#### Options (`UseGridStateStorageOptions`)
|
|
337
|
+
|
|
338
|
+
| Option | Type | Default | Description |
|
|
339
|
+
| :--- | :--- | :--- | :--- |
|
|
340
|
+
| `key` | `string` | — | **Required.** Storage key — use a unique value per grid instance. |
|
|
341
|
+
| `debounceMs` | `number` | `300` | Debounce delay in ms before writing to storage. |
|
|
342
|
+
| `include` | `(keyof GridState)[]` | all | Restrict which state slices are persisted. |
|
|
343
|
+
| `storage` | `Storage` | `localStorage` | Any object implementing `getItem`/`setItem`/`removeItem` (e.g. `sessionStorage` or a custom backend adapter). |
|
|
344
|
+
|
|
345
|
+
#### Return (`UseGridStateStorageReturn`)
|
|
346
|
+
|
|
347
|
+
| Field | Type | Description |
|
|
348
|
+
| :--- | :--- | :--- |
|
|
349
|
+
| `initialState` | `GridState \| undefined` | Restored state from storage — pass to `DataGrid.initialState`. |
|
|
350
|
+
| `onStateChange` | `(state: GridState) => void` | Callback to pass to `DataGrid.onStateChange`. |
|
|
351
|
+
| `clearState` | `() => void` | Removes the saved state from storage. |
|
|
140
352
|
|
|
141
353
|
---
|
|
142
354
|
|
|
@@ -153,7 +365,7 @@ interface GridSortItem {
|
|
|
153
365
|
### `GridFilterModel`
|
|
154
366
|
```typescript
|
|
155
367
|
interface GridFilterModel {
|
|
156
|
-
items
|
|
368
|
+
items?: (GridFilterItem | GridFilterGroup)[];
|
|
157
369
|
logicOperator?: 'and' | 'or';
|
|
158
370
|
quickFilterValues?: string[];
|
|
159
371
|
}
|
|
@@ -29,8 +29,9 @@ function MyGrid() {
|
|
|
29
29
|
| `loading` | `boolean` | `false` | Displays a loading skeleton/shimmer. |
|
|
30
30
|
| `checkboxSelection` | `boolean` | `false` | Enable row checkboxes. |
|
|
31
31
|
| `pagination` | `boolean` | `false` | Enable/Disable bottom pagination bar. |
|
|
32
|
-
| `paginationModel` | `GridPaginationModel` | `{page
|
|
33
|
-
| `
|
|
32
|
+
| `paginationModel` | `GridPaginationModel` | — | Controlled pagination state (`{ page, pageSize }`). |
|
|
33
|
+
| `pageSizeOptions` | `number[]` | `[10, 25, 50]` | Available page size options. |
|
|
34
|
+
| `initialState` | `GridInitialState` | `undefined` | Initial configuration (sorting, columns, etc). |
|
|
34
35
|
|
|
35
36
|
## 🖱️ Interaction & Events
|
|
36
37
|
|
|
@@ -38,8 +39,9 @@ function MyGrid() {
|
|
|
38
39
|
| :--- | :--- | :--- |
|
|
39
40
|
| `onRowClick` | `(params) => void` | Fired when clicking a row body. |
|
|
40
41
|
| `onCellClick` | `(params) => void` | Fired when clicking a specific cell. |
|
|
42
|
+
| `onPaginationModelChange` | `(model: GridPaginationModel) => void` | Fired when page or page size changes. |
|
|
41
43
|
| `onStateChange` | `(state) => void` | Fired on any internal state update. |
|
|
42
|
-
| `processRowUpdate` | `(new, old) => R
|
|
44
|
+
| `processRowUpdate` | `(new, old) => R \| Promise<R>` | Fired after a cell edit is committed. |
|
|
43
45
|
|
|
44
46
|
## 📦 Slots
|
|
45
47
|
|
|
@@ -82,18 +82,22 @@ const [colOrder, setColOrder] = useState(['id', 'name', 'status']);
|
|
|
82
82
|
<DataGrid
|
|
83
83
|
columnOrder={colOrder}
|
|
84
84
|
onColumnOrderChange={(params) => {
|
|
85
|
-
// params
|
|
86
|
-
|
|
85
|
+
// params: { column: GridColDef, oldIndex: number, targetIndex: number }
|
|
86
|
+
const newOrder = [...colOrder];
|
|
87
|
+
const [moved] = newOrder.splice(params.oldIndex, 1);
|
|
88
|
+
newOrder.splice(params.targetIndex, 0, moved);
|
|
89
|
+
setColOrder(newOrder);
|
|
87
90
|
}}
|
|
88
91
|
/>
|
|
89
92
|
```
|
|
90
93
|
|
|
91
94
|
### Non-Reorderable Columns
|
|
92
|
-
To prevent
|
|
95
|
+
To prevent all columns from being reordered, use `disableColumnReorder` on the grid. For individual column control, pin the column using `pinnedColumns` at the grid level — pinned columns do not participate in drag-reorder.
|
|
93
96
|
|
|
94
97
|
```tsx
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
// Disable reordering globally
|
|
99
|
+
<DataGrid disableColumnReorder />
|
|
100
|
+
|
|
101
|
+
// Keep a column fixed by pinning it
|
|
102
|
+
<DataGrid pinnedColumns={{ left: ['id'] }} />
|
|
99
103
|
```
|
|
@@ -49,7 +49,7 @@ The `GridFilterModel` describes the current state of filters.
|
|
|
49
49
|
|
|
50
50
|
```typescript
|
|
51
51
|
interface GridFilterModel {
|
|
52
|
-
items
|
|
52
|
+
items?: (GridFilterItem | GridFilterGroup)[]; // Active filter items or groups
|
|
53
53
|
logicOperator?: 'and' | 'or'; // How to combine items
|
|
54
54
|
quickFilterValues?: string[]; // Values for the global search
|
|
55
55
|
}
|
|
@@ -57,27 +57,29 @@ interface GridFilterModel {
|
|
|
57
57
|
interface GridFilterItem {
|
|
58
58
|
field: string; // Column to filter
|
|
59
59
|
operator: GridFilterOperator;
|
|
60
|
-
value?:
|
|
60
|
+
value?: unknown; // Comparison value
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
### Supported Operators
|
|
65
65
|
| Type | Operators |
|
|
66
66
|
| :--- | :--- |
|
|
67
|
-
| **String** | `contains`, `equals`, `startsWith`, `endsWith`, `isEmpty`, `isNotEmpty` |
|
|
68
|
-
| **Number** |
|
|
69
|
-
| **Date** | `is`, `not`, `
|
|
67
|
+
| **String** | `contains`, `equals`, `startsWith`, `endsWith`, `isEmpty`, `isNotEmpty`, `isAnyOf` |
|
|
68
|
+
| **Number** | `equals`, `!=`, `>`, `>=`, `<`, `<=`, `isEmpty`, `isNotEmpty` |
|
|
69
|
+
| **Date** | `is`, `not`, `isEmpty`, `isNotEmpty` |
|
|
70
70
|
| **Boolean** | `is` |
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
-
## 🎨 Customizing
|
|
75
|
-
|
|
74
|
+
## 🎨 Customizing the Toolbar
|
|
75
|
+
The filter panel is accessible through the built-in `GridToolbar`. To use your own toolbar that includes a filter entry point, pass a custom component to the `toolbar` slot:
|
|
76
76
|
|
|
77
77
|
```tsx
|
|
78
78
|
<DataGrid
|
|
79
79
|
slots={{
|
|
80
|
-
|
|
80
|
+
toolbar: MyCustomToolbar
|
|
81
81
|
}}
|
|
82
82
|
/>
|
|
83
83
|
```
|
|
84
|
+
|
|
85
|
+
The `FilterPanel` component is also exported from `@opencorestack/opengridx` if you need to embed it inside a custom layout.
|
|
@@ -47,7 +47,8 @@ const [selection, setSelection] = useState<GridRowId[]>([]);
|
|
|
47
47
|
| `disableRowSelectionOnClick` | `boolean` | `false` | If true, clicking a cell won't select the row. |
|
|
48
48
|
| `disableMultipleRowSelection` | `boolean` | `false` | Restricts selection to a single row. |
|
|
49
49
|
| `rowSelectionModel` | `GridRowId[]` | `[]` | Controlled array of selected IDs. |
|
|
50
|
-
| `
|
|
50
|
+
| `onRowSelectionModelChange` | `(model: GridRowSelectionModel) => void` | — | Fired when the selection changes. |
|
|
51
|
+
| `pinCheckboxColumn` | `boolean` | `false` | Keep the checkbox column visible during horizontal scroll. |
|
|
51
52
|
|
|
52
53
|
---
|
|
53
54
|
|
|
@@ -52,7 +52,9 @@ When using `paginationMode="server"`, you must provide the `rowCount` and handle
|
|
|
52
52
|
| Prop | Type | Default | Description |
|
|
53
53
|
| :--- | :--- | :--- | :--- |
|
|
54
54
|
| `pagination` | `boolean` | `false` | Enable/disable the pagination footer. |
|
|
55
|
-
| `paginationMode` | `'client' \| 'server'` | `'client'` | Location of the pagination logic. |
|
|
55
|
+
| `paginationMode` | `'client' \| 'server' \| 'infinite'` | `'client'` | Location of the pagination logic. |
|
|
56
|
+
| `paginationModel` | `GridPaginationModel` | — | Controlled pagination state (`{ page, pageSize }`). |
|
|
57
|
+
| `onPaginationModelChange` | `(model: GridPaginationModel) => void` | — | Fired when page or page size changes. |
|
|
56
58
|
| `pageSizeOptions` | `number[]` | `[10, 25, 50]` | Options for the rows-per-page selector. |
|
|
57
59
|
|
|
58
60
|
---
|
|
@@ -63,5 +63,4 @@ The following features support state persistence:
|
|
|
63
63
|
- **Filtering**: `filterModel`
|
|
64
64
|
- **Pagination**: `paginationModel`
|
|
65
65
|
- **Columns**: `columnVisibilityModel`, `columnOrder`, `pinnedColumns`, `columnWidths`
|
|
66
|
-
- **
|
|
67
|
-
- **Grouping**: `rowGroupingModel`
|
|
66
|
+
- **Density**: `density`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencorestack/opengridx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OpenGridX: High-performance React data infrastructure. Unlock advanced Row Grouping, Excel Export, and Column Pinning without the usual \"Pro\" gatekeeping. Built for speed, scale, and complete architectural freedom. Fully open, virtualization-ready, and feature-complete.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/opengridx.umd.js",
|