@alaarab/ogrid-mcp 2.4.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.
Files changed (52) hide show
  1. package/README.md +68 -0
  2. package/bundled-docs/api/README.md +94 -0
  3. package/bundled-docs/api/column-def.mdx +379 -0
  4. package/bundled-docs/api/components-column-chooser.mdx +310 -0
  5. package/bundled-docs/api/components-column-header-filter.mdx +363 -0
  6. package/bundled-docs/api/components-datagrid-table.mdx +316 -0
  7. package/bundled-docs/api/components-pagination-controls.mdx +344 -0
  8. package/bundled-docs/api/components-sidebar.mdx +427 -0
  9. package/bundled-docs/api/components-status-bar.mdx +309 -0
  10. package/bundled-docs/api/grid-api.mdx +299 -0
  11. package/bundled-docs/api/js-api.mdx +198 -0
  12. package/bundled-docs/api/ogrid-props.mdx +244 -0
  13. package/bundled-docs/api/types.mdx +640 -0
  14. package/bundled-docs/features/cell-references.mdx +225 -0
  15. package/bundled-docs/features/column-chooser.mdx +279 -0
  16. package/bundled-docs/features/column-groups.mdx +290 -0
  17. package/bundled-docs/features/column-pinning.mdx +282 -0
  18. package/bundled-docs/features/column-reordering.mdx +359 -0
  19. package/bundled-docs/features/column-types.mdx +181 -0
  20. package/bundled-docs/features/context-menu.mdx +216 -0
  21. package/bundled-docs/features/csv-export.mdx +227 -0
  22. package/bundled-docs/features/editing.mdx +377 -0
  23. package/bundled-docs/features/filtering.mdx +330 -0
  24. package/bundled-docs/features/formulas.mdx +381 -0
  25. package/bundled-docs/features/grid-api.mdx +311 -0
  26. package/bundled-docs/features/keyboard-navigation.mdx +236 -0
  27. package/bundled-docs/features/pagination.mdx +245 -0
  28. package/bundled-docs/features/performance.mdx +433 -0
  29. package/bundled-docs/features/row-selection.mdx +256 -0
  30. package/bundled-docs/features/server-side-data.mdx +291 -0
  31. package/bundled-docs/features/sidebar.mdx +234 -0
  32. package/bundled-docs/features/sorting.mdx +241 -0
  33. package/bundled-docs/features/spreadsheet-selection.mdx +201 -0
  34. package/bundled-docs/features/status-bar.mdx +205 -0
  35. package/bundled-docs/features/toolbar.mdx +284 -0
  36. package/bundled-docs/features/virtual-scrolling.mdx +624 -0
  37. package/bundled-docs/getting-started/installation.mdx +216 -0
  38. package/bundled-docs/getting-started/overview.mdx +151 -0
  39. package/bundled-docs/getting-started/quick-start.mdx +425 -0
  40. package/bundled-docs/getting-started/vanilla-js.mdx +191 -0
  41. package/bundled-docs/guides/accessibility.mdx +550 -0
  42. package/bundled-docs/guides/controlled-vs-uncontrolled.mdx +153 -0
  43. package/bundled-docs/guides/custom-cell-editors.mdx +201 -0
  44. package/bundled-docs/guides/framework-showcase.mdx +200 -0
  45. package/bundled-docs/guides/mcp-live-testing.mdx +291 -0
  46. package/bundled-docs/guides/mcp.mdx +172 -0
  47. package/bundled-docs/guides/migration-from-ag-grid.mdx +223 -0
  48. package/bundled-docs/guides/theming.mdx +211 -0
  49. package/dist/esm/bridge-client.d.ts +87 -0
  50. package/dist/esm/bridge-client.js +162 -0
  51. package/dist/esm/index.js +1060 -0
  52. package/package.json +43 -0
@@ -0,0 +1,198 @@
1
+ ---
2
+ sidebar_position: 5
3
+ title: Vanilla JS API
4
+ description: Full API reference for @alaarab/ogrid-js
5
+ ---
6
+
7
+ # Vanilla JS API
8
+
9
+ Complete reference for `@alaarab/ogrid-js` — the framework-free data grid.
10
+
11
+ ## OGrid Class
12
+
13
+ ```js
14
+
15
+ const grid = new OGrid(container, options);
16
+ ```
17
+
18
+ ### Constructor
19
+
20
+ | Parameter | Type | Description |
21
+ |-----------|------|-------------|
22
+ | `container` | `HTMLElement` | DOM element to render into. OGrid fills this container. |
23
+ | `options` | `OGridOptions<T>` | Configuration object (see below). |
24
+
25
+ ### Instance Methods
26
+
27
+ | Method | Description |
28
+ |--------|-------------|
29
+ | `grid.api` | The imperative API object (see [API Methods](#api-methods) below). |
30
+ | `grid.on(event, handler)` | Subscribe to a grid event. Returns `void`. |
31
+ | `grid.off(event, handler)` | Unsubscribe from a grid event. |
32
+ | `grid.destroy()` | Tear down the grid — removes DOM, listeners, and ResizeObservers. |
33
+
34
+ ---
35
+
36
+ ## OGridOptions\<T\>
37
+
38
+ All configuration is passed to the constructor.
39
+
40
+ ### Data
41
+
42
+ | Option | Type | Default | Description |
43
+ |--------|------|---------|-------------|
44
+ | `columns` | `(IColumnDef<T> \| IColumnGroupDef<T>)[]` | **required** | Column definitions. |
45
+ | `getRowId` | `(item: T) => RowId` | **required** | Returns a unique `string \| number` per row. |
46
+ | `data` | `T[]` | — | Client-side data. Mutually exclusive with `dataSource`. |
47
+ | `dataSource` | `IDataSource<T>` | — | Server-side data source. Mutually exclusive with `data`. |
48
+
49
+ ### Pagination & Sorting
50
+
51
+ | Option | Type | Default | Description |
52
+ |--------|------|---------|-------------|
53
+ | `page` | `number` | `1` | Initial page (1-based). |
54
+ | `pageSize` | `number` | `20` | Rows per page. |
55
+ | `sort` | `{ field: string; direction: 'asc' \| 'desc' }` | — | Initial sort state. |
56
+ | `filters` | `IFilters` | — | Initial filter state. |
57
+
58
+ ### Interaction
59
+
60
+ | Option | Type | Default | Description |
61
+ |--------|------|---------|-------------|
62
+ | `editable` | `boolean` | `false` | Enable inline cell editing. |
63
+ | `cellSelection` | `boolean` | `false` | Enable spreadsheet-style cell/range selection. |
64
+ | `rowSelection` | `'single' \| 'multiple'` | — | Row checkbox selection mode. |
65
+ | `selectedRows` | `Set<RowId>` | — | Controlled selected row IDs. |
66
+ | `pinnedColumns` | `Record<string, 'left' \| 'right'>` | — | Pin columns to left/right edges. |
67
+ | `visibleColumns` | `Set<string>` | all | Initially visible column IDs. |
68
+
69
+ ### Layout
70
+
71
+ | Option | Type | Default | Description |
72
+ |--------|------|---------|-------------|
73
+ | `layoutMode` | `'fill' \| 'content'` | `'fill'` | `'fill'` stretches to container; `'content'` sizes to data. |
74
+ | `suppressHorizontalScroll` | `boolean` | `false` | Prevent horizontal scrollbar. |
75
+ | `sideBar` | `boolean \| ISideBarDef` | — | Show sidebar with columns/filters panels. |
76
+ | `emptyMessage` | `string` | `'No data'` | Custom empty state text. |
77
+ | `aria-label` | `string` | — | Accessible label for the grid. |
78
+
79
+ ### Callbacks
80
+
81
+ | Option | Type | Description |
82
+ |--------|------|-------------|
83
+ | `onCellValueChanged` | `(event: ICellValueChangedEvent<T>) => void` | Fired when a cell edit is committed. |
84
+ | `onSelectionChange` | `(event: IRowSelectionChangeEvent<T>) => void` | Fired when row selection changes. |
85
+ | `onError` | `(error: unknown) => void` | Fired on server-side data source failures. |
86
+ | `onFirstDataRendered` | `() => void` | Fired once when the first data render completes. |
87
+
88
+ ---
89
+
90
+ ## API Methods
91
+
92
+ Access via `grid.api`:
93
+
94
+ ### Data
95
+
96
+ | Method | Signature | Description |
97
+ |--------|-----------|-------------|
98
+ | `setRowData` | `(data: T[]) => void` | Replace the entire dataset (client-side only; no-op with `dataSource`). |
99
+ | `setLoading` | `(loading: boolean) => void` | Show or hide the loading overlay. |
100
+ | `getDisplayedRows` | `() => T[]` | Get the currently visible (filtered, sorted, paginated) rows. |
101
+ | `refreshData` | `() => void` | Re-fetch from `dataSource` (server-side only). |
102
+
103
+ ### Sorting & Filtering
104
+
105
+ | Method | Signature | Description |
106
+ |--------|-----------|-------------|
107
+ | `setFilterModel` | `(filters: IFilters) => void` | Set the full filter model. Pass `{}` to clear all filters. |
108
+ | `clearFilters` | `() => void` | Clear all active filters. Shorthand for `setFilterModel({})`. |
109
+ | `clearSort` | `() => void` | Reset the sort to no active sort. |
110
+ | `resetGridState` | `(options?: { keepSelection?: boolean }) => void` | Reset all grid state (filters, sort, and optionally selection). |
111
+
112
+ ### Columns
113
+
114
+ | Method | Signature | Description |
115
+ |--------|-----------|-------------|
116
+ | `getColumnState` | `() => IGridColumnState` | Get current column state (visibility, sort, order, widths, filters). |
117
+ | `applyColumnState` | `(state: Partial<IGridColumnState>) => void` | Bulk-restore any combination of column state fields. |
118
+ | `getColumnOrder` | `() => string[]` | Get the current column display order (array of column IDs). |
119
+ | `setColumnOrder` | `(order: string[]) => void` | Set the column display order programmatically. |
120
+
121
+ ### Selection
122
+
123
+ | Method | Signature | Description |
124
+ |--------|-----------|-------------|
125
+ | `selectAll` | `() => void` | Select all rows (requires `rowSelection: 'multiple'`). |
126
+ | `deselectAll` | `() => void` | Deselect all rows. |
127
+ | `getSelectedRows` | `() => RowId[]` | Get the IDs of currently selected rows. |
128
+ | `setSelectedRows` | `(rowIds: RowId[]) => void` | Set which rows are selected by their IDs. |
129
+
130
+ ### Export
131
+
132
+ | Method | Signature | Description |
133
+ |--------|-----------|-------------|
134
+ | `exportToCsv` | `(filename?: string) => void` | Export displayed rows to CSV and trigger a browser download. |
135
+
136
+ ### Virtual Scrolling
137
+
138
+ | Method | Signature | Description |
139
+ |--------|-----------|-------------|
140
+ | `scrollToRow` | `(index: number, options?: { align?: 'start' \| 'center' \| 'end' }) => void` | Scroll to a specific row by index. Only effective when virtual scrolling is enabled. |
141
+
142
+ ---
143
+
144
+ ## Events
145
+
146
+ Subscribe with `grid.on(eventName, handler)`.
147
+
148
+ | Event | Payload Type | Fired When |
149
+ |-------|-------------|------------|
150
+ | `cellValueChanged` | `ICellValueChangedEvent<T>` | A cell edit is committed |
151
+ | `selectionChange` | `IRowSelectionChangeEvent<T>` | Row selection changes |
152
+ | `sortChange` | `{ field: string; direction: 'asc' \| 'desc' }` | Sort state changes |
153
+ | `filterChange` | `{ filters: IFilters }` | Filter state changes |
154
+ | `pageChange` | `{ page: number }` | Current page changes |
155
+
156
+ ### ICellValueChangedEvent\<T\>
157
+
158
+ ```ts
159
+ {
160
+ item: T; // The row data object
161
+ columnId: string; // Which column was edited
162
+ oldValue: unknown; // Previous cell value
163
+ newValue: unknown; // New cell value
164
+ rowIndex: number; // Row index of the edited cell
165
+ }
166
+ ```
167
+
168
+ ---
169
+
170
+ ## IColumnDef\<T\> (JS-specific)
171
+
172
+ The JS package extends the core `IColumnDef<T>` with DOM-aware fields:
173
+
174
+ | Field | Type | Description |
175
+ |-------|------|-------------|
176
+ | `renderCell` | `(cell: HTMLTableCellElement, item: T, value: unknown) => void` | Custom cell renderer — mutate the `<td>` DOM directly. |
177
+ | `cellStyle` | `Partial<CSSStyleDeclaration>` | Inline styles applied to each cell. |
178
+ | `cellEditor` | `string \| (container: HTMLElement, params: object) => { getValue: () => unknown; destroy: () => void }` | Built-in editor name (`'text'`, `'select'`, `'richSelect'`, `'checkbox'`, `'date'`) or a factory function for custom editors. |
179
+
180
+ All other `IColumnDef` fields (`columnId`, `name`, `sortable`, `filterable`, `type`, `editable`, `valueFormatter`, `valueGetter`, `valueParser`, `minWidth`, `defaultWidth`, `idealWidth`, `pinned`, `required`, `defaultVisible`) are identical to the React version — see [Column Definitions](./column-def).
181
+
182
+ ---
183
+
184
+ ## CSS Classes
185
+
186
+ The JS package renders semantic HTML with `ogrid-*` class names. Import the default theme or write your own CSS targeting these selectors:
187
+
188
+ ### Layout
189
+ `ogrid-container`, `ogrid-toolbar`, `ogrid-body-area`, `ogrid-table-container`, `ogrid-sidebar-container`, `ogrid-status-bar-container`, `ogrid-pagination-container`
190
+
191
+ ### Table
192
+ `ogrid-wrapper`, `ogrid-table`, `ogrid-header-cell`, `ogrid-group-header`, `ogrid-sortable`, `ogrid-sort-indicator`, `ogrid-resize-handle`, `ogrid-filter-icon`, `ogrid-row`, `ogrid-cell`, `ogrid-checkbox-header`, `ogrid-checkbox-cell`, `ogrid-fill-handle`, `ogrid-empty-state`
193
+
194
+ ### Data Attributes
195
+ `[data-active-cell]`, `[data-in-range]`, `[data-drag-range]`, `[data-row-selected]`, `[data-pinned="left|right"]`, `[data-column-id]`, `[data-row-index]`, `[data-col-index]`
196
+
197
+ ### CSS Variables
198
+ Override `--ogrid-bg`, `--ogrid-fg`, `--ogrid-border`, `--ogrid-primary`, `--ogrid-selection`, `--ogrid-bg-subtle`, `--ogrid-bg-hover`, `--ogrid-muted`, and more. See [Theming](../guides/theming).
@@ -0,0 +1,244 @@
1
+ ---
2
+ sidebar_position: 1
3
+ title: OGrid Props
4
+ ---
5
+
6
+ # OGrid Props
7
+
8
+ Complete reference for `IOGridProps<T>`, the props accepted by the `OGrid` component in all UI packages (`@alaarab/ogrid-react-radix`, `@alaarab/ogrid-react-fluent`, `@alaarab/ogrid-react-material`).
9
+
10
+ ```typescript
11
+ ```
12
+
13
+ :::caution v1.6.0 Breaking Changes
14
+ - The `title` prop has been removed. Render your own heading outside `<OGrid>`.
15
+ - `IFilters` values are now discriminated unions: `{ type: 'text', value: string }` instead of raw strings. See [Filtering](../features/filtering) for the new format.
16
+ :::
17
+
18
+ ## Data
19
+
20
+ | Name | Type | Default | Description |
21
+ |------|------|---------|-------------|
22
+ | `columns` | `(IColumnDef<T> \| IColumnGroupDef<T>)[]` | **Required** | Array of column definitions and optional column groups. See [Column Definition](./column-def). |
23
+ | `getRowId` | `(item: T) => RowId` | **Required** | Function that returns a unique identifier for each row. Must be stable across re-renders. |
24
+ | `data` | `T[]` | `undefined` | Array of row data for client-side mode. Mutually exclusive with `dataSource`. When provided, sorting, filtering, and pagination are handled in-memory. |
25
+ | `dataSource` | `IDataSource<T>` | `undefined` | Server-side data source. Mutually exclusive with `data`. See [Server-Side Data](../features/server-side-data). |
26
+ | `isLoading` | `boolean` | `false` | Whether the grid is in a loading state. When `true`, the grid displays a loading indicator. |
27
+
28
+ ## Sorting
29
+
30
+ | Name | Type | Default | Description |
31
+ |------|------|---------|-------------|
32
+ | `sort` | `{ field: string; direction: 'asc' \| 'desc' }` | `undefined` | Controlled sort state. When provided, the grid uses this value and calls `onSortChange` when the user clicks a sortable column header. |
33
+ | `onSortChange` | `(sort: { field: string; direction: 'asc' \| 'desc' }) => void` | `undefined` | Callback fired when the user changes the sort. Required for controlled sort mode. |
34
+ | `defaultSortBy` | `string` | `undefined` | Column ID to sort by initially in uncontrolled mode. |
35
+ | `defaultSortDirection` | `'asc' \| 'desc'` | `undefined` | Initial sort direction in uncontrolled mode. Used together with `defaultSortBy`. |
36
+
37
+ ## Filtering
38
+
39
+ | Name | Type | Default | Description |
40
+ |------|------|---------|-------------|
41
+ | `filters` | `IFilters` | `undefined` | Controlled filter state. A record mapping field names to filter values. See [Types](./types) for `IFilters`. |
42
+ | `onFiltersChange` | `(filters: IFilters) => void` | `undefined` | Callback fired when the user applies or clears a filter. Required for controlled filter mode. |
43
+
44
+ ## Pagination
45
+
46
+ | Name | Type | Default | Description |
47
+ |------|------|---------|-------------|
48
+ | `page` | `number` | `undefined` | Controlled current page (1-based). |
49
+ | `pageSize` | `number` | `undefined` | Controlled page size. |
50
+ | `onPageChange` | `(page: number) => void` | `undefined` | Callback fired when the user navigates to a different page. |
51
+ | `onPageSizeChange` | `(size: number) => void` | `undefined` | Callback fired when the user changes the page size. |
52
+ | `defaultPageSize` | `number` | `25` | Initial page size in uncontrolled mode. |
53
+ | `pageSizeOptions` | `number[]` | `[10, 25, 50, 100]` | Options shown in the page size dropdown. The active page size is auto-inserted if missing. |
54
+
55
+ ## Column Visibility and Order
56
+
57
+ | Name | Type | Default | Description |
58
+ |------|------|---------|-------------|
59
+ | `visibleColumns` | `Set<string>` | `undefined` | Controlled set of visible column IDs. When provided, only these columns are displayed. |
60
+ | `onVisibleColumnsChange` | `(cols: Set<string>) => void` | `undefined` | Callback fired when column visibility changes (e.g., via the column chooser). |
61
+ | `columnOrder` | `string[]` | `undefined` | Controlled column order as an array of column IDs. |
62
+ | `onColumnOrderChange` | `(order: string[]) => void` | `undefined` | Callback fired when the user reorders columns. |
63
+ | `onColumnResized` | `(columnId: string, width: number) => void` | `undefined` | Callback fired when the user finishes resizing a column. |
64
+
65
+ ## Editing
66
+
67
+ | Name | Type | Default | Description |
68
+ |------|------|---------|-------------|
69
+ | `editable` | `boolean` | `false` | Whether inline cell editing is enabled globally. Individual columns can override this via `IColumnDef.editable`. |
70
+ | `onCellValueChanged` | `(event: ICellValueChangedEvent<T>) => void` | `undefined` | Callback fired after a cell value is committed. The event contains `item`, `columnId`, `oldValue`, `newValue`, and `rowIndex`. |
71
+ | `onUndo` | `() => void` | `undefined` | Callback fired when the user triggers undo (Ctrl+Z or context menu). |
72
+ | `onRedo` | `() => void` | `undefined` | Callback fired when the user triggers redo (Ctrl+Y or context menu). |
73
+ | `canUndo` | `boolean` | `false` | Whether undo is available. Controls the enabled state of the undo context menu item. |
74
+ | `canRedo` | `boolean` | `false` | Whether redo is available. Controls the enabled state of the redo context menu item. |
75
+
76
+ ## Cell Selection
77
+
78
+ | Name | Type | Default | Description |
79
+ |------|------|---------|-------------|
80
+ | `cellSelection` | `boolean` | `true` | Whether cell selection (active cell, range selection, drag selection) is enabled. When `false`, clicking cells does not highlight them. |
81
+
82
+ ## Row Selection
83
+
84
+ | Name | Type | Default | Description |
85
+ |------|------|---------|-------------|
86
+ | `rowSelection` | `RowSelectionMode` | `'none'` | Row selection mode: `'none'`, `'single'`, or `'multiple'`. When enabled, a checkbox column is added. |
87
+ | `selectedRows` | `Set<RowId>` | `undefined` | Controlled set of selected row IDs. |
88
+ | `onSelectionChange` | `(event: IRowSelectionChangeEvent<T>) => void` | `undefined` | Callback fired when row selection changes. The event contains `selectedRowIds` and `selectedItems`. |
89
+
90
+ ## Status Bar
91
+
92
+ | Name | Type | Default | Description |
93
+ |------|------|---------|-------------|
94
+ | `statusBar` | `boolean \| IStatusBarProps` | `false` | Controls the status bar at the bottom of the grid. Pass `true` to show a default status bar with item counts, or pass an `IStatusBarProps` object for full control. See [Types](./types) for `IStatusBarProps`. |
95
+
96
+ ## Side Bar
97
+
98
+ | Name | Type | Default | Description |
99
+ |------|------|---------|-------------|
100
+ | `sideBar` | `boolean \| ISideBarDef` | `undefined` | Controls the side bar panel. Pass `true` for default side bar, or an `ISideBarDef` object to configure panels and position. See [Types](./types) for `ISideBarDef`. |
101
+
102
+ ## Column Chooser
103
+
104
+ | Name | Type | Default | Description |
105
+ |------|------|---------|-------------|
106
+ | `columnChooser` | `boolean \| 'toolbar' \| 'sidebar'` | `true` | Where to render the column chooser. `true`/`'toolbar'` shows it in the toolbar. `'sidebar'` moves it to the sidebar columns panel. `false` hides it entirely. |
107
+
108
+ ## Column Reordering
109
+
110
+ | Name | Type | Default | Description |
111
+ |------|------|---------|-------------|
112
+ | `columnReorder` | `boolean` | `false` | Enable drag-and-drop column reordering via header cells. See [Column Reordering](../features/column-reordering). |
113
+
114
+ ## Virtual Scrolling
115
+
116
+ | Name | Type | Default | Description |
117
+ |------|------|---------|-------------|
118
+ | `virtualScroll` | `IVirtualScrollConfig` | `undefined` | Virtual scrolling configuration. See [Virtual Scrolling](../features/virtual-scrolling) and [Types](./types) for `IVirtualScrollConfig`. |
119
+
120
+ ## Layout
121
+
122
+ | Name | Type | Default | Description |
123
+ |------|------|---------|-------------|
124
+ | `layoutMode` | `'content' \| 'fill'` | `'fill'` | How the grid sizes itself. `'content'` sizes to fit content. `'fill'` expands to fill its container. |
125
+ | `suppressHorizontalScroll` | `boolean` | `false` | When `true`, disables horizontal scrolling by setting `overflow-x: hidden` on the grid wrapper. |
126
+ | `stickyHeader` | `boolean` | `true` | When `true`, column headers stick to the top of the scroll container during vertical scrolling. Set to `false` to let headers scroll with data. |
127
+ | `fullScreen` | `boolean` | `false` | When `true`, renders a fullscreen toggle button in the toolbar. Clicking it expands the grid to fill the entire viewport. Press **Escape** or click the button again to exit. |
128
+ | `rowHeight` | `number` | `36` | Fixed row height in pixels. Affects layout and virtual scrolling row height calculation. |
129
+ | `density` | `'compact' \| 'normal' \| 'comfortable'` | `'normal'` | Cell spacing preset. Controls cell padding throughout the grid. |
130
+ | `showRowNumbers` | `boolean` | `false` | Show Excel-style row number column (1, 2, 3...) at the start of the grid. |
131
+ | `className` | `string` | `undefined` | Additional CSS class name applied to the root grid element. |
132
+ | `toolbar` | `ReactNode` | `undefined` | Custom toolbar content rendered in the left side of the primary toolbar strip. |
133
+ | `toolbarBelow` | `ReactNode` | `undefined` | Secondary toolbar row rendered below the primary toolbar. Use for active filter chips, breadcrumbs, or other contextual controls. |
134
+ | `entityLabelPlural` | `string` | `undefined` | Plural label for the entity type (e.g., `"projects"`, `"users"`). Used in status bar text and empty state messages. |
135
+ | `emptyState` | `{ message?: ReactNode; render?: () => ReactNode }` | `undefined` | Custom empty state configuration. Provide `message` for a simple text override, or `render` for a fully custom empty state component. |
136
+
137
+ ## Callbacks
138
+
139
+ | Name | Type | Default | Description |
140
+ |------|------|---------|-------------|
141
+ | `onFirstDataRendered` | `() => void` | `undefined` | Fired once when the grid first renders with data. Useful for restoring column state. |
142
+ | `onColumnPinned` | `(columnId: string, pinned: 'left' \| 'right' \| null) => void` | `undefined` | Fired when a column is pinned or unpinned. |
143
+
144
+ ## Error Handling
145
+
146
+ | Name | Type | Default | Description |
147
+ |------|------|---------|-------------|
148
+ | `onError` | `(error: unknown) => void` | `undefined` | Callback fired when the grid encounters an error (e.g., a failed server-side fetch). |
149
+ | `onCellError` | `(error: Error, errorInfo: React.ErrorInfo) => void` | `undefined` | Callback fired when a cell renderer or custom editor throws an error. |
150
+
151
+ ## Accessibility
152
+
153
+ | Name | Type | Default | Description |
154
+ |------|------|---------|-------------|
155
+ | `aria-label` | `string` | `undefined` | Accessible label for the grid. Use this or `aria-labelledby`, not both. |
156
+ | `aria-labelledby` | `string` | `undefined` | ID of an element that labels the grid. Use this or `aria-label`, not both. |
157
+
158
+ ## Ref
159
+
160
+ The `OGrid` component accepts a `ref` prop that exposes the `IOGridApi<T>` imperative API. See [Grid API](./grid-api) for full details.
161
+
162
+ ```typescript
163
+
164
+ function MyGrid() {
165
+ const apiRef = useRef<IOGridApi<MyRow>>(null);
166
+
167
+ return (
168
+ <OGrid
169
+ ref={apiRef}
170
+ columns={columns}
171
+ data={data}
172
+ getRowId={(row) => row.id}
173
+ />
174
+ );
175
+ }
176
+ ```
177
+
178
+ ## Minimal Example
179
+
180
+ ```typescript
181
+
182
+ interface Person {
183
+ id: number;
184
+ name: string;
185
+ age: number;
186
+ }
187
+
188
+ const columns = [
189
+ { columnId: 'name', name: 'Name' },
190
+ { columnId: 'age', name: 'Age', type: 'numeric' as const },
191
+ ];
192
+
193
+ const data: Person[] = [
194
+ { id: 1, name: 'Alice', age: 30 },
195
+ { id: 2, name: 'Bob', age: 25 },
196
+ ];
197
+
198
+ function App() {
199
+ return (
200
+ <OGrid<Person>
201
+ columns={columns}
202
+ data={data}
203
+ getRowId={(row) => row.id}
204
+ />
205
+ );
206
+ }
207
+ ```
208
+
209
+ ## Controlled vs Uncontrolled
210
+
211
+ OGrid supports both controlled and uncontrolled modes for pagination, sorting, filtering, column visibility, column order, and row selection.
212
+
213
+ **Uncontrolled** (default): The grid manages state internally. Use `default*` props to set initial values.
214
+
215
+ ```typescript
216
+ <OGrid
217
+ columns={columns}
218
+ data={data}
219
+ getRowId={(row) => row.id}
220
+ defaultPageSize={25}
221
+ defaultSortBy="name"
222
+ defaultSortDirection="asc"
223
+ />
224
+ ```
225
+
226
+ **Controlled**: You own the state and pass values + callbacks. The grid never updates these values on its own.
227
+
228
+ ```typescript
229
+ const [page, setPage] = useState(1);
230
+ const [pageSize, setPageSize] = useState(25);
231
+ const [sort, setSort] = useState({ field: 'name', direction: 'asc' as const });
232
+
233
+ <OGrid
234
+ columns={columns}
235
+ data={data}
236
+ getRowId={(row) => row.id}
237
+ page={page}
238
+ pageSize={pageSize}
239
+ sort={sort}
240
+ onPageChange={setPage}
241
+ onPageSizeChange={setPageSize}
242
+ onSortChange={setSort}
243
+ />
244
+ ```