@opencorestack/opengridx 1.0.1 → 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 +8 -0
- package/README.md +36 -0
- package/docs/API_REFERENCE.md +222 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
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
|
+
|
|
8
16
|
## [1.0.1] — July 30, 2026 📚
|
|
9
17
|
|
|
10
18
|
### Fixed
|
package/README.md
CHANGED
|
@@ -118,6 +118,42 @@ This means that **Cursor**, **GitHub Copilot**, **Windsurf**, and other AI agent
|
|
|
118
118
|
| `className` | `string` | — | Custom CSS class on the grid container. |
|
|
119
119
|
| `style` | `React.CSSProperties` | — | Custom inline styles on the grid container. |
|
|
120
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. |
|
|
156
|
+
|
|
121
157
|
### Selection
|
|
122
158
|
|
|
123
159
|
| Prop | Type | Description |
|
package/docs/API_REFERENCE.md
CHANGED
|
@@ -91,21 +91,71 @@ Used in Tree Data and Row Grouping hierarchies.
|
|
|
91
91
|
### `GridColDef`
|
|
92
92
|
Defines the behavior and appearance of a single column.
|
|
93
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
|
+
|
|
94
147
|
| Property | Type | Default | Description |
|
|
95
148
|
| :--- | :--- | :--- | :--- |
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `valueFormatter` | `(params: GridValueFormatterParams) => string` | — | Format value for display. |
|
|
107
|
-
| `valueGetter` | `(params: GridValueGetterParams) => any` | — | Compute value from row data. |
|
|
108
|
-
| `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']`). |
|
|
109
159
|
|
|
110
160
|
---
|
|
111
161
|
|
|
@@ -136,17 +186,169 @@ Context provider for overriding the grid's visual system.
|
|
|
136
186
|
## 🛠️ Hooks
|
|
137
187
|
|
|
138
188
|
### `useGridApiRef()`
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
+
---
|
|
143
208
|
|
|
144
209
|
### `useAggregation(params)`
|
|
145
|
-
|
|
146
|
-
|
|
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
|
+
---
|
|
147
306
|
|
|
148
307
|
### `useGridStateStorage(options)`
|
|
149
|
-
|
|
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. |
|
|
150
352
|
|
|
151
353
|
---
|
|
152
354
|
|
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",
|