Skip to content

Commit 29cc42e

Browse files
author
Asif Ansari
committed
docs: complete GridColDef reference and expand hooks documentation
- README: add full GridColDef property table (35 properties) including flex, editable, minWidth, maxWidth, align, headerAlign, renderHeader, renderEditCell, cellClassName, disableColumnMenu, valueOptions, etc. - docs/API_REFERENCE.md: split GridColDef into subsections (Sizing, Data & Type, Rendering, Editing, Spanning, Styling, Feature Flags) - docs/API_REFERENCE.md: replace hook stubs with full reference entries for usePivot (was missing entirely), useGridStateStorage (full options + return table), useAggregation (params/return tables), useGridApiRef - Bump version to 1.0.2
1 parent f76b93c commit 29cc42e

6 files changed

Lines changed: 269 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
---
77

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+
816
## [1.0.1] — July 30, 2026 📚
917

1018
### Fixed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,42 @@ This means that **Cursor**, **GitHub Copilot**, **Windsurf**, and other AI agent
118118
| `className` | `string` || Custom CSS class on the grid container. |
119119
| `style` | `React.CSSProperties` || Custom inline styles on the grid container. |
120120

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+
121157
### Selection
122158

123159
| Prop | Type | Description |

demo/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export default function App() {
135135
<img src={`${import.meta.env.BASE_URL}logo.png`} alt="OpenGridX Logo" className="app-logo" />
136136
<h2 className="app-title">
137137
OpenGridX
138-
<span className="app-version">v1.0.1</span>
138+
<span className="app-version">v1.0.2</span>
139139
</h2>
140140
</div>
141141

demo/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default function Home(_props: HomeProps) {
6868
<div className="home-logo-hero">
6969
<img src={`${import.meta.env.BASE_URL}banner.png`} alt="OpenGridX Logo" className="home-banner-image" />
7070
</div>
71-
<span className="home-badge">OpenGridX v1.0.1</span>
71+
<span className="home-badge">OpenGridX v1.0.2</span>
7272
<p className="home-subtitle">
7373
The elite, high-performance DataGrid for modern React.
7474
Built to handle massive data with a premium developer experience.

docs/API_REFERENCE.md

Lines changed: 222 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,71 @@ Used in Tree Data and Row Grouping hierarchies.
9191
### `GridColDef`
9292
Defines the behavior and appearance of a single column.
9393

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+
94147
| Property | Type | Default | Description |
95148
| :--- | :--- | :--- | :--- |
96-
| `field` | `string` || Unique identifier (matches row property). |
97-
| `headerName` | `string` || Text displayed in the header. |
98-
| `width` | `number \| string` | `100` | Width in pixels or percentage string. |
99-
| `type` | `'string' \| 'number' \| 'date' \| 'boolean' \| 'singleSelect' \| 'image'` | `'string'` | Data type for formatting and filtering. |
100-
| `sortable` | `boolean` | `true` | Enable sorting for this column. |
101-
| `filterable` | `boolean` | `true` | Enable filtering for this column. |
102-
| `resizable` | `boolean` | `true` | Allow user to drag resize. |
103-
| `hideable` | `boolean` | `true` | Allow user to hide the column. |
104-
| `pinnable` | `boolean` | `true` | Allow column to be pinned via the UI. |
105-
| `exportable` | `boolean` | `true` | If `false`, column is excluded from all exports. |
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']`). |
109159

110160
---
111161

@@ -136,17 +186,169 @@ Context provider for overriding the grid's visual system.
136186
## 🛠️ Hooks
137187

138188
### `useGridApiRef()`
139-
Returns a ref to interact with the grid programmatically.
140-
- `state`: Access full internal state.
141-
- `getVisibleRows()`: Returns filtered/sorted rows.
142-
- `getVisibleColumns()`: Returns currently visible columns.
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+
---
143208

144209
### `useAggregation(params)`
145-
Compute summary values for datasets.
146-
- **Built-in Functions**: `sum`, `avg`, `min`, `max`, `count`, `unique`.
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+
---
147306

148307
### `useGridStateStorage(options)`
149-
Persist and restore grid configurations to LocalStorage or a backend.
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. |
150352

151353
---
152354

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opencorestack/opengridx",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"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.",
55
"type": "module",
66
"main": "./dist/opengridx.umd.js",

0 commit comments

Comments
 (0)