@opencorestack/opengridx 2.1.0 → 3.0.1
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 +399 -0
- package/README.md +95 -72
- package/dist/index.d.ts +590 -131
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.es.js +7891 -5631
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +17 -23
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +348 -166
- package/docs/README.md +6 -1
- package/docs/architecture/datagrid-orchestration.md +81 -0
- package/docs/architecture/grid-row-meta.md +102 -0
- package/docs/architecture/use-grid-columns.md +128 -0
- package/docs/architecture/use-grid-controlled-state.md +157 -0
- package/docs/architecture/use-grid-row-pipeline.md +120 -0
- package/docs/architecture/use-grid-scroll-sync.md +111 -0
- package/docs/architecture/use-grid-state-snapshot.md +90 -0
- package/docs/architecture/use-grid-virtualization.md +115 -0
- package/docs/architecture/use-grid-visible-rows.md +85 -0
- package/docs/assets/banner-alt.png +0 -0
- package/docs/assets/banner.png +0 -0
- package/docs/assets/hero.png +0 -0
- package/docs/assets/logo.png +0 -0
- package/docs/components/aggregation-footer.md +15 -10
- package/docs/components/cell.md +16 -6
- package/docs/components/column-group-header.md +55 -28
- package/docs/components/column-resize.md +17 -13
- package/docs/components/column-visibility.md +6 -7
- package/docs/components/datagrid.md +15 -13
- package/docs/components/empty-state.md +2 -1
- package/docs/components/error-overlay.md +12 -7
- package/docs/components/filter-panel.md +28 -8
- package/docs/components/header.md +28 -9
- package/docs/components/pagination.md +14 -8
- package/docs/components/row.md +21 -5
- package/docs/components/toolbar.md +27 -9
- package/docs/components/tooltip.md +16 -7
- package/docs/customization/slots-api.md +90 -38
- package/docs/customization/theming.md +66 -18
- package/docs/features/aggregation-pivot.md +75 -9
- package/docs/features/cell-spanning.md +80 -125
- package/docs/features/clipboard.md +41 -16
- package/docs/features/custom-pagination.md +38 -18
- package/docs/features/data-source.md +36 -13
- package/docs/features/editing-reordering.md +125 -16
- package/docs/features/export-guide.md +126 -39
- package/docs/features/filtering.md +44 -6
- package/docs/features/infinite-scroll.md +54 -46
- package/docs/features/keyboard-navigation.md +83 -0
- package/docs/features/list-view.md +58 -5
- package/docs/features/loading-states.md +18 -20
- package/docs/features/master-detail.md +18 -5
- package/docs/features/pdf-export.md +72 -19
- package/docs/features/pinning.md +24 -5
- package/docs/features/selection.md +50 -10
- package/docs/features/sorting-pagination.md +64 -14
- package/docs/features/state-persistence.md +78 -10
- package/docs/features/toolbar-customization.md +26 -17
- package/docs/features/tree-data-grouping.md +36 -8
- package/docs/features/virtualization.md +37 -14
- package/docs/migration/v1-to-v2.md +115 -0
- package/docs/migration/v2-to-v3.md +1233 -0
- package/docs/performance.md +124 -0
- package/docs/roadmap.md +5 -5
- package/lib/components/Cell/Cell.css +17 -1
- package/lib/components/Cell/Cell.tsx +129 -57
- package/lib/components/Cell/CellErrorBoundary.tsx +12 -6
- package/lib/components/Cell/GridEditInputCell.tsx +114 -41
- package/lib/components/ColumnGroupHeader/ColumnGroupHeader.css +7 -1
- package/lib/components/ColumnResizeHandle/ColumnResizeHandle.css +15 -2
- package/lib/components/ColumnResizeHandle/ColumnResizeHandle.tsx +104 -38
- package/lib/components/ColumnResizeHandle/clampResizeWidth.ts +13 -0
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.css +6 -0
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.tsx +21 -13
- package/lib/components/DataGrid/DataGrid.css +85 -12
- package/lib/components/DataGrid/DataGrid.tsx +582 -876
- package/lib/components/DataGrid/GridAggregationFooter.tsx +53 -17
- package/lib/components/DataGrid/GridErrorOverlay.tsx +15 -12
- package/lib/components/DataGrid/GridListView.tsx +165 -24
- package/lib/components/DataGrid/GridLiveRegion.tsx +31 -0
- package/lib/components/DataGrid/GridLoadingOverlay.tsx +27 -0
- package/lib/components/DataGrid/GridPaginationArea.tsx +44 -0
- package/lib/components/DataGrid/GridPinnedRows.tsx +62 -11
- package/lib/components/DataGrid/GridStandaloneColumnPanel.tsx +40 -38
- package/lib/components/DataGrid/GridToolbarSlot.tsx +51 -0
- package/lib/components/DataGrid/GridVirtualRows.tsx +40 -24
- package/lib/components/DetailPanel/DetailPanel.css +0 -6
- package/lib/components/DetailPanel/DetailPanel.tsx +34 -5
- package/lib/components/DetailPanel/DetailPanelContent.tsx +17 -0
- package/lib/components/FilterPanel/FilterPanel.css +13 -2
- package/lib/components/FilterPanel/FilterPanel.tsx +272 -99
- package/lib/components/Header/ColumnMenu.tsx +91 -39
- package/lib/components/Header/Header.css +6 -3
- package/lib/components/Header/Header.tsx +181 -160
- package/lib/components/ListView/ListView.css +25 -0
- package/lib/components/ListView/ListViewRow.tsx +76 -10
- package/lib/components/Pagination/Pagination.tsx +15 -7
- package/lib/components/Row/Row.tsx +177 -77
- package/lib/components/Toolbar/GlobalSearch.css +6 -3
- package/lib/components/Toolbar/GlobalSearch.tsx +26 -27
- package/lib/components/Toolbar/GridToolbar.css +12 -11
- package/lib/components/Toolbar/GridToolbar.tsx +133 -89
- package/lib/components/Toolbar/PivotPanel.tsx +89 -49
- package/lib/components/Tooltip/Tooltip.css +20 -0
- package/lib/components/Tooltip/Tooltip.tsx +68 -35
- package/lib/components/ui/Button.tsx +3 -0
- package/lib/components/ui/Checkbox.tsx +2 -1
- package/lib/components/ui/ExpandIcon.css +0 -9
- package/lib/components/ui/ExpandIcon.tsx +4 -1
- package/lib/hooks/core/gridApiPlaceholder.ts +34 -0
- package/lib/hooks/core/gridToolbarHostContext.ts +14 -0
- package/lib/hooks/core/useDataGrid.ts +115 -173
- package/lib/hooks/core/useGridAggregationApi.ts +72 -0
- package/lib/hooks/core/useGridApiMethods.ts +115 -0
- package/lib/hooks/core/useGridApiRef.ts +19 -4
- package/lib/hooks/core/useGridApiRefBinding.ts +18 -0
- package/lib/hooks/core/useGridAriaRows.ts +38 -0
- package/lib/hooks/core/useGridClipboardApi.ts +38 -0
- package/lib/hooks/core/useGridColumnLookup.ts +30 -0
- package/lib/hooks/core/useGridColumns.tsx +279 -76
- package/lib/hooks/core/useGridColumnsPanel.ts +77 -0
- package/lib/hooks/core/useGridControlledState.ts +99 -6
- package/lib/hooks/core/useGridDetailPanel.ts +51 -0
- package/lib/hooks/core/useGridDevWarnings.ts +104 -5
- package/lib/hooks/core/useGridFocusHandlers.ts +50 -0
- package/lib/hooks/core/useGridGroupingColumn.ts +62 -0
- package/lib/hooks/core/useGridHeaderHandlers.ts +92 -0
- package/lib/hooks/core/useGridHierarchy.ts +81 -0
- package/lib/hooks/core/useGridKeyboardNavigation.ts +447 -243
- package/lib/hooks/core/useGridLiveRowSelection.ts +67 -0
- package/lib/hooks/core/useGridPageCorrection.ts +55 -0
- package/lib/hooks/core/useGridRowIdOf.ts +32 -0
- package/lib/hooks/core/useGridRowInteractions.ts +81 -0
- package/lib/hooks/core/useGridRowPipeline.ts +69 -39
- package/lib/hooks/core/useGridRowSelection.ts +91 -0
- package/lib/hooks/core/useGridScrollSync.ts +80 -32
- package/lib/hooks/core/useGridScrollToIndexesApi.ts +45 -0
- package/lib/hooks/core/useGridStateSnapshot.ts +40 -5
- package/lib/hooks/core/useGridThemeDimensions.ts +49 -0
- package/lib/hooks/core/useGridToolbarProps.ts +97 -0
- package/lib/hooks/core/useGridViewport.ts +38 -0
- package/lib/hooks/core/useGridViewportSize.ts +26 -0
- package/lib/hooks/core/useGridVisibleRows.ts +17 -5
- package/lib/hooks/core/useLayout.ts +215 -195
- package/lib/hooks/core/useRowsScrollEndLatch.ts +41 -0
- package/lib/hooks/core/useStableColumns.ts +34 -0
- package/lib/hooks/features/useAggregation.ts +82 -51
- package/lib/hooks/features/useColumnGroupReorderGuard.ts +34 -0
- package/lib/hooks/features/useDetailPanelHeights.ts +29 -0
- package/lib/hooks/features/useGridClipboard.ts +133 -73
- package/lib/hooks/features/useGridDataSource.ts +354 -128
- package/lib/hooks/features/useGridEditing.ts +211 -51
- package/lib/hooks/features/useGridPivot.ts +92 -0
- package/lib/hooks/features/useGridSpanRenderWindow.ts +104 -0
- package/lib/hooks/features/useGridSpanning.ts +410 -306
- package/lib/hooks/features/usePivot.ts +0 -0
- package/lib/hooks/features/useServerTreeChildren.ts +50 -0
- package/lib/hooks/useColumnReorder.ts +38 -44
- package/lib/hooks/useRowGrouping.ts +298 -160
- package/lib/hooks/useRowReorder.ts +62 -31
- package/lib/hooks/useTreeData.ts +287 -220
- package/lib/index.ts +28 -2
- package/lib/state/index.ts +1 -0
- package/lib/state/types.ts +7 -1
- package/lib/state/useGridStateStorage.ts +88 -29
- package/lib/theme/DataGridThemeProvider.tsx +143 -38
- package/lib/theme/gridThemeContext.ts +5 -0
- package/lib/theme/index.ts +5 -0
- package/lib/theme/presets.ts +5 -4
- package/lib/theme/types.ts +40 -2
- package/lib/types/index.ts +313 -116
- package/lib/utils/aggregation/index.ts +119 -24
- package/lib/utils/aria/index.ts +40 -0
- package/lib/utils/columnGroups.ts +110 -0
- package/lib/utils/columnLookup.ts +33 -0
- package/lib/utils/columnWidth.ts +22 -0
- package/lib/utils/dataSource/index.ts +46 -0
- package/lib/utils/detailPanel.ts +66 -0
- package/lib/utils/dragData.ts +44 -0
- package/lib/utils/editing/index.ts +30 -0
- package/lib/utils/export/exportShared.ts +197 -0
- package/lib/utils/export/exportToExcelAdvanced.ts +278 -139
- package/lib/utils/export/exportToPdf.ts +143 -92
- package/lib/utils/export/groupLabel.ts +14 -0
- package/lib/utils/export/index.ts +278 -272
- package/lib/utils/export/pdfText.ts +50 -0
- package/lib/utils/filtering/index.ts +277 -148
- package/lib/utils/focus/index.ts +115 -0
- package/lib/utils/gridApiRows.ts +35 -0
- package/lib/utils/gridModes.ts +77 -0
- package/lib/utils/grouping/groupedExportRows.ts +91 -0
- package/lib/utils/pagination/index.ts +56 -0
- package/lib/utils/pinning/index.ts +77 -33
- package/lib/utils/pivot/index.ts +368 -0
- package/lib/utils/scroll/index.ts +55 -5
- package/lib/utils/scroll/scrollEnd.ts +18 -0
- package/lib/utils/sorting/index.ts +154 -30
- package/lib/utils/syntheticRows.ts +12 -0
- package/lib/utils/values.ts +206 -0
- package/lib/utils/viewport.ts +14 -0
- package/llms.txt +261 -164
- package/package.json +13 -5
- package/lib/components/ColumnGroupHeader/ColumnGroupHeader.tsx +0 -220
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.test.tsx +0 -85
- package/lib/components/DataGrid/DataGrid.defects.test.tsx +0 -103
- package/lib/components/DataGrid/DataGrid.regression.test.tsx +0 -132
- package/lib/components/DataGrid/DataGrid.smoke.test.tsx +0 -58
- package/lib/components/DataGrid/DataGrid.v2.test.tsx +0 -127
- package/lib/components/DataGrid/DataGrid.virtualization.browser.test.tsx +0 -183
- package/lib/components/Header/Header.test.tsx +0 -135
- package/lib/components/Pagination/Pagination.test.tsx +0 -64
- package/lib/hooks/core/useDataGrid.regression.test.ts +0 -66
- package/lib/hooks/core/useGridControlledState.test.ts +0 -86
- package/lib/hooks/core/useGridKeyboardNavigation.test.ts +0 -176
- package/lib/hooks/core/useGridRowPipeline.test.ts +0 -117
- package/lib/hooks/features/useAggregation.test.ts +0 -175
- package/lib/hooks/features/usePivot.test.ts +0 -202
- package/lib/hooks/useRowGrouping.test.ts +0 -298
- package/lib/hooks/useTreeData.test.ts +0 -83
- package/lib/utils/aggregation/aggregation.test.ts +0 -16
- package/lib/utils/export/exportToExcelAdvanced.test.ts +0 -109
- package/lib/utils/export/exportToPdf.test.ts +0 -120
- package/lib/utils/export/groupedExport.test.ts +0 -144
- package/lib/utils/filtering/filtering.test.ts +0 -178
- package/lib/utils/sorting/sorting.test.ts +0 -88
package/lib/types/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { GridToolbarProps } from '../components/Toolbar/GridToolbar';
|
|
2
|
+
import type { PaginationProps } from '../components/Pagination/Pagination';
|
|
2
3
|
|
|
3
4
|
/** Unique identifier for a row (string or number). */
|
|
4
5
|
export type GridRowId = string | number;
|
|
@@ -16,24 +17,55 @@ export interface GridRowModel {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* The constraint on the row type `R` of the generic grid types (`DataGridProps<R>`, `GridColDef<R>`,
|
|
21
|
+
* `GridRenderCellParams<R>` …): any object type. Your own interfaces and type aliases can be used as `R`
|
|
22
|
+
* directly; they do not need an index signature or to extend `GridRowModel`. Rows without an `id`
|
|
23
|
+
* field need `getRowId`. `GridRowModel` stays the default `R` (rows with any keys, read as `unknown`).
|
|
24
|
+
* @since v3.0
|
|
25
|
+
*/
|
|
26
|
+
export type GridValidRowModel = object;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A callback that is checked bivariantly in its parameter, like a method. Used for `GridColDef`
|
|
30
|
+
* options that are either a value or a function, so a column typed for your rows (`GridColDef<Row>`)
|
|
31
|
+
* can still be used where an untyped `GridColDef` is expected.
|
|
32
|
+
*/
|
|
33
|
+
type GridColDefCallback<P, T> = { bivarianceHack(params: P): T }['bivarianceHack'];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Hierarchy metadata for a row. Exposed via `params.rowMeta` in `renderCell`.
|
|
20
37
|
* Not present (`undefined`) for flat rows with no active tree-data or row-grouping.
|
|
21
38
|
*
|
|
22
39
|
* @since v1.1 — replaces the `_hasChildren` / `_treeDepth` / `_groupingField` etc.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* compatibility; removal was deferred past v2.0 (still present as of v2.1.0)
|
|
26
|
-
* to a future major version. Do not rely on them being absent yet.
|
|
40
|
+
* fields that were injected onto row objects. Since v3.0 those fields are no longer
|
|
41
|
+
* added at runtime: row objects reach `renderCell` exactly as you passed them.
|
|
27
42
|
*/
|
|
28
43
|
export interface GridRowMeta {
|
|
44
|
+
/** The row has children to show: the expand toggle is rendered for it. */
|
|
29
45
|
hasChildren?: boolean;
|
|
30
46
|
treeDepth?: number;
|
|
31
47
|
groupingField?: string;
|
|
32
48
|
groupingValue?: unknown;
|
|
49
|
+
/** The label the grid shows for a synthetic row: the group label, or the path segment of an auto-created tree parent. */
|
|
33
50
|
groupLabel?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Data rows below this row at any depth that pass the active filter (row-grouping leaves, or
|
|
53
|
+
* tree-data rows; auto-created tree parents are not counted). The "(n)" shown next to group labels.
|
|
54
|
+
*/
|
|
34
55
|
descendantCount?: number;
|
|
35
56
|
isExpanded?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The row is synthetic: a row-grouping group row, a group subtotal row, or a tree-data parent the
|
|
59
|
+
* grid created for a path segment with no row of its own. Synthetic rows are never selected,
|
|
60
|
+
* edited or given a detail panel, and `valueGetter` is not called for them.
|
|
61
|
+
*/
|
|
36
62
|
isGroupRow?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The row is the subtotal row of the group described by `groupingField` / `groupingValue`, shown
|
|
65
|
+
* after the group's children when `getAggregationPosition` returns `'footer'` for it.
|
|
66
|
+
* @since v3.0
|
|
67
|
+
*/
|
|
68
|
+
isGroupFooter?: boolean;
|
|
37
69
|
}
|
|
38
70
|
|
|
39
71
|
export type GridAlignment = 'left' | 'center' | 'right';
|
|
@@ -65,7 +97,7 @@ export interface GridTreeNode {
|
|
|
65
97
|
/** Display label for the group. */
|
|
66
98
|
label?: string;
|
|
67
99
|
|
|
68
|
-
/**
|
|
100
|
+
/** Row grouping: the number of leaf rows in the group that pass the active filter (recursive). */
|
|
69
101
|
descendantCount?: number;
|
|
70
102
|
|
|
71
103
|
/** Count of children on the server (for lazy loading). */
|
|
@@ -78,7 +110,7 @@ export type GridSortDirection = 'asc' | 'desc' | null;
|
|
|
78
110
|
* Metadata for a single column.
|
|
79
111
|
* Governs rendering, sorting, filtering, and data transformation.
|
|
80
112
|
*/
|
|
81
|
-
export interface GridColDef<R extends
|
|
113
|
+
export interface GridColDef<R extends GridValidRowModel = GridRowModel> {
|
|
82
114
|
/** The unique identifier for the column, typically matching a row object key. */
|
|
83
115
|
field: string;
|
|
84
116
|
/** Text displayed in the column header. */
|
|
@@ -129,16 +161,25 @@ export interface GridColDef<R extends GridRowModel = GridRowModel> {
|
|
|
129
161
|
/** Options used for 'singleSelect' type. */
|
|
130
162
|
valueOptions?: Array<string | number | { value: unknown; label: string }>;
|
|
131
163
|
|
|
164
|
+
// The row callbacks below are declared as methods so that `GridColDef<Row>` stays assignable to an
|
|
165
|
+
// untyped `GridColDef` (method parameters are checked bivariantly).
|
|
132
166
|
/** Function to compute a cell value from raw row data. */
|
|
133
|
-
valueGetter
|
|
167
|
+
valueGetter?(params: GridValueGetterParams<R>): unknown;
|
|
168
|
+
/**
|
|
169
|
+
* Maps an edited value back onto the row when an edit is committed; return the updated row.
|
|
170
|
+
* Needed for editable columns with a `valueGetter`, whose value is not stored in `row[field]`.
|
|
171
|
+
* Without it the commit writes `row[field] = value`.
|
|
172
|
+
* @since v3.0
|
|
173
|
+
*/
|
|
174
|
+
valueSetter?(params: GridValueSetterParams<R>): R;
|
|
134
175
|
/** Function to format a value into a human-readable string. */
|
|
135
|
-
valueFormatter
|
|
176
|
+
valueFormatter?(params: GridValueFormatterParams<R>): string;
|
|
136
177
|
/** Custom component or element to render in the cell. */
|
|
137
|
-
renderCell
|
|
178
|
+
renderCell?(params: GridRenderCellParams<R>): React.ReactNode;
|
|
138
179
|
/** Custom component or element to render in the header. */
|
|
139
|
-
renderHeader
|
|
140
|
-
/** Component to render when the cell is in edit mode. */
|
|
141
|
-
renderEditCell
|
|
180
|
+
renderHeader?(params: GridRenderHeaderParams): React.ReactNode;
|
|
181
|
+
/** Component to render when the cell is in edit mode. Receives `onValueChange`, `onCommit` and `onCancel`. */
|
|
182
|
+
renderEditCell?(params: GridRenderEditCellParams<R>): React.ReactNode;
|
|
142
183
|
/** If true, the cell's value can be modified by the user. */
|
|
143
184
|
editable?: boolean;
|
|
144
185
|
/** Optional stacking order (CSS z-index). */
|
|
@@ -146,10 +187,19 @@ export interface GridColDef<R extends GridRowModel = GridRowModel> {
|
|
|
146
187
|
/** If true, the column kebab/hamburger menu is disabled. */
|
|
147
188
|
disableColumnMenu?: boolean;
|
|
148
189
|
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Number of columns this cell should occupy horizontally: the origin plus the next visible columns
|
|
192
|
+
* in render order, clamped to the end of the origin's pinned section. Fractions are floored,
|
|
193
|
+
* `Infinity` means "to the end", and NaN / values below 1 mean no span. `params.value` is the
|
|
194
|
+
* `valueGetter` result. A function that throws is treated as 1.
|
|
195
|
+
*/
|
|
196
|
+
colSpan?: number | GridColDefCallback<GridRenderCellParams<R>, number>;
|
|
197
|
+
/**
|
|
198
|
+
* Number of rows this cell should occupy vertically, clamped to the end of its row section
|
|
199
|
+
* (top-pinned, scrolling or bottom-pinned rows) and to the first row with an expanded detail
|
|
200
|
+
* panel. Normalised like `colSpan`. With both set, the origin covers the whole rectangle.
|
|
201
|
+
*/
|
|
202
|
+
rowSpan?: number | GridColDefCallback<GridRenderCellParams<R>, number>;
|
|
153
203
|
|
|
154
204
|
/**
|
|
155
205
|
* Custom CSS class applied to every cell in this column.
|
|
@@ -159,7 +209,7 @@ export interface GridColDef<R extends GridRowModel = GridRowModel> {
|
|
|
159
209
|
* cellClassName: 'my-class'
|
|
160
210
|
* cellClassName: ({ value }) => value > 100 ? 'cell--high' : 'cell--low'
|
|
161
211
|
*/
|
|
162
|
-
cellClassName?: string |
|
|
212
|
+
cellClassName?: string | GridColDefCallback<GridRenderCellParams<R>, string>;
|
|
163
213
|
|
|
164
214
|
/**
|
|
165
215
|
* Custom CSS class applied to the header cell of this column.
|
|
@@ -177,9 +227,9 @@ export interface GridColDef<R extends GridRowModel = GridRowModel> {
|
|
|
177
227
|
}
|
|
178
228
|
|
|
179
229
|
/** Column definition used exclusively in List View mode. */
|
|
180
|
-
export interface GridListViewColDef<R extends
|
|
230
|
+
export interface GridListViewColDef<R extends GridValidRowModel = GridRowModel> {
|
|
181
231
|
field: string;
|
|
182
|
-
renderCell
|
|
232
|
+
renderCell(params: GridRenderCellParams<R>): React.ReactNode;
|
|
183
233
|
}
|
|
184
234
|
|
|
185
235
|
/**
|
|
@@ -200,7 +250,7 @@ export interface GridColumnGroup {
|
|
|
200
250
|
groupId: string;
|
|
201
251
|
/** Text displayed in the group header cell. */
|
|
202
252
|
headerName: string;
|
|
203
|
-
/**
|
|
253
|
+
/** CSS class(es) added to this group's header cell(s). */
|
|
204
254
|
headerClassName?: string;
|
|
205
255
|
/**
|
|
206
256
|
* Either an array of column field strings (leaf group)
|
|
@@ -213,7 +263,7 @@ export type GridColumnGroupingModel = GridColumnGroup[];
|
|
|
213
263
|
|
|
214
264
|
|
|
215
265
|
/** Parameters passed to the `valueGetter` function. */
|
|
216
|
-
export interface GridValueGetterParams<R extends
|
|
266
|
+
export interface GridValueGetterParams<R extends GridValidRowModel = GridRowModel> {
|
|
217
267
|
/** The row object. */
|
|
218
268
|
row: R;
|
|
219
269
|
/** The field name. */
|
|
@@ -222,8 +272,21 @@ export interface GridValueGetterParams<R extends GridRowModel = GridRowModel> {
|
|
|
222
272
|
value: unknown;
|
|
223
273
|
}
|
|
224
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Parameters passed to the `valueSetter` function.
|
|
277
|
+
* @since v3.0
|
|
278
|
+
*/
|
|
279
|
+
export interface GridValueSetterParams<R extends GridValidRowModel = GridRowModel> {
|
|
280
|
+
/** The committed value from the editor. */
|
|
281
|
+
value: unknown;
|
|
282
|
+
/** The row as it was before the edit. */
|
|
283
|
+
row: R;
|
|
284
|
+
/** The field name. */
|
|
285
|
+
field: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
225
288
|
/** Parameters passed to the `valueFormatter` function. */
|
|
226
|
-
export interface GridValueFormatterParams<R extends
|
|
289
|
+
export interface GridValueFormatterParams<R extends GridValidRowModel = GridRowModel> {
|
|
227
290
|
/** The raw value to format. */
|
|
228
291
|
value: unknown;
|
|
229
292
|
/** The row object. */
|
|
@@ -233,7 +296,7 @@ export interface GridValueFormatterParams<R extends GridRowModel = GridRowModel>
|
|
|
233
296
|
}
|
|
234
297
|
|
|
235
298
|
/** Parameters passed to the `renderCell` function. */
|
|
236
|
-
export interface GridRenderCellParams<R extends
|
|
299
|
+
export interface GridRenderCellParams<R extends GridValidRowModel = GridRowModel> {
|
|
237
300
|
/** The current cell value. */
|
|
238
301
|
value: unknown;
|
|
239
302
|
/**
|
|
@@ -258,6 +321,19 @@ export interface GridRenderCellParams<R extends GridRowModel = GridRowModel> {
|
|
|
258
321
|
rowMeta?: GridRowMeta;
|
|
259
322
|
}
|
|
260
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Parameters passed to `renderEditCell`. `value` is the pending (uncommitted) value.
|
|
326
|
+
* @since v3.0
|
|
327
|
+
*/
|
|
328
|
+
export interface GridRenderEditCellParams<R extends GridValidRowModel = GridRowModel> extends GridRenderCellParams<R> {
|
|
329
|
+
/** Updates the pending value. Call it on every change; nothing is saved until `onCommit`. */
|
|
330
|
+
onValueChange: (value: unknown) => void;
|
|
331
|
+
/** Commits the pending value (runs `processRowUpdate`) and leaves edit mode. */
|
|
332
|
+
onCommit: () => void;
|
|
333
|
+
/** Discards the pending value and leaves edit mode. */
|
|
334
|
+
onCancel: () => void;
|
|
335
|
+
}
|
|
336
|
+
|
|
261
337
|
export interface GridRenderHeaderParams {
|
|
262
338
|
field: string;
|
|
263
339
|
colDef: GridColDef;
|
|
@@ -282,13 +358,18 @@ export type GridFilterOperator =
|
|
|
282
358
|
| 'isEmpty'
|
|
283
359
|
| 'isNotEmpty'
|
|
284
360
|
| 'isAnyOf'
|
|
361
|
+
| '='
|
|
285
362
|
| '>'
|
|
286
363
|
| '>='
|
|
287
364
|
| '<'
|
|
288
365
|
| '<='
|
|
289
366
|
| '!='
|
|
290
367
|
| 'is'
|
|
291
|
-
| 'not'
|
|
368
|
+
| 'not'
|
|
369
|
+
| 'after'
|
|
370
|
+
| 'onOrAfter'
|
|
371
|
+
| 'before'
|
|
372
|
+
| 'onOrBefore';
|
|
292
373
|
|
|
293
374
|
/** Describes a filter condition for a specific column. */
|
|
294
375
|
export interface GridFilterItem {
|
|
@@ -326,7 +407,7 @@ export interface GridFilterModel {
|
|
|
326
407
|
* Configuration options for exporting the DataGrid to PDF format.
|
|
327
408
|
* Requires jspdf and jspdf-autotable peer dependencies.
|
|
328
409
|
*/
|
|
329
|
-
export interface PdfExportOptions {
|
|
410
|
+
export interface PdfExportOptions<R extends GridValidRowModel = GridRowModel> {
|
|
330
411
|
/**
|
|
331
412
|
* Output filename without extension. Default: 'export'
|
|
332
413
|
*/
|
|
@@ -350,10 +431,18 @@ export interface PdfExportOptions {
|
|
|
350
431
|
orientation?: 'portrait' | 'landscape';
|
|
351
432
|
|
|
352
433
|
/**
|
|
353
|
-
* If provided, only rows whose id is in this array are exported.
|
|
434
|
+
* If provided, only rows whose id is in this array are exported. A non-empty selection takes
|
|
435
|
+
* precedence over `groupedRows` (the selected rows are exported flat), and the footer totals
|
|
436
|
+
* are recomputed over the selected rows.
|
|
354
437
|
*/
|
|
355
438
|
selectedRows?: (string | number)[];
|
|
356
439
|
|
|
440
|
+
/**
|
|
441
|
+
* The grid's `getRowId`, when it has one: `selectedRows` holds those ids, and the grid does not
|
|
442
|
+
* copy them onto `row.id` (v3.0+). Defaults to `row.id`.
|
|
443
|
+
*/
|
|
444
|
+
getRowId?: (row: R) => GridRowId;
|
|
445
|
+
|
|
357
446
|
/**
|
|
358
447
|
* Aggregation result from apiRef.current.getAggregationResult().
|
|
359
448
|
* When provided alongside aggregationModel, appends a footer row.
|
|
@@ -390,11 +479,30 @@ export interface PdfExportOptions {
|
|
|
390
479
|
*/
|
|
391
480
|
fontSize?: number;
|
|
392
481
|
|
|
482
|
+
/**
|
|
483
|
+
* A TrueType font for the whole document. The built-in Helvetica font only covers Latin-1 and
|
|
484
|
+
* WinAnsi punctuation (é, ü, €, “ ”, •). Without this option other characters (₹, Greek,
|
|
485
|
+
* Cyrillic, CJK, Devanagari, U+202F used by some locales as a thousands separator) are
|
|
486
|
+
* replaced with `?` (spaces and minus signs with their ASCII forms) and a warning is logged.
|
|
487
|
+
* `data` is the `.ttf` file as a base64 string; `boldData` is an optional bold face for the
|
|
488
|
+
* title, header and totals (the regular face is used when omitted). jsPDF does not shape
|
|
489
|
+
* complex scripts, so Devanagari or Arabic ligatures may not join.
|
|
490
|
+
* @since v3.0
|
|
491
|
+
*/
|
|
492
|
+
font?: {
|
|
493
|
+
/** Font family name, e.g. 'NotoSans'. */
|
|
494
|
+
name: string;
|
|
495
|
+
/** Base64-encoded .ttf file. */
|
|
496
|
+
data: string;
|
|
497
|
+
/** Base64-encoded bold .ttf file. Default: `data`. */
|
|
498
|
+
boldData?: string;
|
|
499
|
+
};
|
|
500
|
+
|
|
393
501
|
/**
|
|
394
502
|
* Pre-built grouped export rows from `apiRef.current.getGroupedExportRows()`.
|
|
395
503
|
* When provided, the PDF table reflects the grouping structure (group headers,
|
|
396
504
|
* leaf rows, per-group subtotals, grand total) instead of a flat row list.
|
|
397
|
-
* Has no effect when the grid has no active `rowGroupingModel
|
|
505
|
+
* Has no effect when the grid has no active `rowGroupingModel`, or when `selectedRows` is non-empty.
|
|
398
506
|
*/
|
|
399
507
|
groupedRows?: GridGroupedExportRow[];
|
|
400
508
|
}
|
|
@@ -412,6 +520,13 @@ export interface GridGroupedExportRow {
|
|
|
412
520
|
groupField?: string;
|
|
413
521
|
/** The raw grouping value for this level (absent on 'leaf' and 'grand-total'). */
|
|
414
522
|
groupValue?: unknown;
|
|
523
|
+
/**
|
|
524
|
+
* The group label exactly as the grid shows it (from `groupingValueFormatter`, else `"field: value"`),
|
|
525
|
+
* on 'group-header' and 'group-subtotal' entries from `getGroupedExportRows()`. Exporters use it for
|
|
526
|
+
* group-header rows; when absent they apply the column's `groupingValueFormatter` themselves.
|
|
527
|
+
* @since v3.0
|
|
528
|
+
*/
|
|
529
|
+
groupLabel?: string;
|
|
415
530
|
/** Per-group aggregation results (present on 'group-subtotal' and 'grand-total'). */
|
|
416
531
|
aggregatedValues?: Record<string, unknown>;
|
|
417
532
|
/** The original data row (only present when `type === 'leaf'`). */
|
|
@@ -446,7 +561,7 @@ export interface GridColumnOrderChangeParams {
|
|
|
446
561
|
|
|
447
562
|
export type GridColumnOrder = string[];
|
|
448
563
|
|
|
449
|
-
export interface GridRowOrderChangeParams<R extends
|
|
564
|
+
export interface GridRowOrderChangeParams<R extends GridValidRowModel = GridRowModel> {
|
|
450
565
|
row: R;
|
|
451
566
|
oldIndex: number;
|
|
452
567
|
targetIndex: number;
|
|
@@ -461,7 +576,7 @@ export interface GridGetRowsParams {
|
|
|
461
576
|
aggregationModel?: GridAggregationModel;
|
|
462
577
|
}
|
|
463
578
|
|
|
464
|
-
export interface GridGetRowsResponse<R extends
|
|
579
|
+
export interface GridGetRowsResponse<R extends GridValidRowModel = GridRowModel> {
|
|
465
580
|
rows: R[];
|
|
466
581
|
rowCount?: number;
|
|
467
582
|
aggregationResults?: Record<string, unknown>;
|
|
@@ -471,7 +586,7 @@ export interface GridGetRowsResponse<R extends GridRowModel = GridRowModel> {
|
|
|
471
586
|
* Interface for providing data to the grid from a remote source.
|
|
472
587
|
* Enables server-side sorting, filtering, and pagination.
|
|
473
588
|
*/
|
|
474
|
-
export interface GridDataSource<R extends
|
|
589
|
+
export interface GridDataSource<R extends GridValidRowModel = GridRowModel> {
|
|
475
590
|
/**
|
|
476
591
|
* Fetches a chunk of rows based on current grid state.
|
|
477
592
|
* @param params Sorting, filtering, and range parameters.
|
|
@@ -495,26 +610,24 @@ export interface GridPinnedColumns {
|
|
|
495
610
|
right?: string[];
|
|
496
611
|
}
|
|
497
612
|
|
|
498
|
-
export interface GridPinnedRows<R extends
|
|
613
|
+
export interface GridPinnedRows<R extends GridValidRowModel = GridRowModel> {
|
|
499
614
|
top?: R[];
|
|
500
615
|
bottom?: R[];
|
|
501
616
|
}
|
|
502
617
|
|
|
503
|
-
export interface GridVirtualizationState {
|
|
504
|
-
renderContext: GridRenderContext;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
618
|
export type GridRowGroupingModel = string[];
|
|
508
619
|
|
|
509
|
-
export type GridAggregationFunction = (values: unknown[]) => unknown;
|
|
510
|
-
|
|
511
620
|
export interface GridAggregationModel {
|
|
512
621
|
[field: string]: string;
|
|
513
622
|
}
|
|
514
623
|
|
|
515
624
|
export type GridAggregationResult = Record<string, unknown>;
|
|
516
625
|
|
|
517
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Where a group's aggregates are shown, as returned by `getAggregationPosition`: `'inline'` on the group row,
|
|
628
|
+
* `'footer'` on a subtotal row after the group's children, `null` hidden.
|
|
629
|
+
*/
|
|
630
|
+
export type GridAggregationPosition = 'inline' | 'footer' | null;
|
|
518
631
|
|
|
519
632
|
export type GridPivotAggFn = 'sum' | 'avg' | 'count' | 'min' | 'max';
|
|
520
633
|
|
|
@@ -530,27 +643,16 @@ export interface GridPivotModel {
|
|
|
530
643
|
valueFields: GridPivotValueField[];
|
|
531
644
|
}
|
|
532
645
|
|
|
533
|
-
export interface GridRenderContext {
|
|
534
|
-
firstRowIndex: number;
|
|
535
|
-
lastRowIndex: number;
|
|
536
|
-
firstColumnIndex: number;
|
|
537
|
-
lastColumnIndex: number;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
646
|
export interface GridInternalState {
|
|
541
647
|
rows: {
|
|
542
648
|
idRowsLookup: Map<GridRowId, GridRowModel>;
|
|
543
649
|
allRows: GridRowId[];
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
sortModel: GridSortItem[];
|
|
547
|
-
};
|
|
548
|
-
filter: {
|
|
549
|
-
filterModel: GridFilterModel;
|
|
650
|
+
/** Row object → its getRowId() key. Rows are stored untouched, so this is how ids are resolved. */
|
|
651
|
+
idByRow: Map<GridRowModel, GridRowId>;
|
|
550
652
|
};
|
|
551
653
|
pagination: {
|
|
552
|
-
|
|
553
|
-
rowCount
|
|
654
|
+
/** Server-reported total (dataSource responses); undefined until one arrives. */
|
|
655
|
+
rowCount?: number;
|
|
554
656
|
};
|
|
555
657
|
columns: {
|
|
556
658
|
all: GridColDef[];
|
|
@@ -558,14 +660,10 @@ export interface GridInternalState {
|
|
|
558
660
|
orderedFields: string[];
|
|
559
661
|
columnVisibilityModel: GridColumnVisibilityModel;
|
|
560
662
|
};
|
|
561
|
-
selection: {
|
|
562
|
-
selectedRows: Set<GridRowId>;
|
|
563
|
-
};
|
|
564
663
|
pinning: {
|
|
565
664
|
pinnedColumns: GridPinnedColumns;
|
|
566
665
|
pinnedRows: GridPinnedRows;
|
|
567
666
|
};
|
|
568
|
-
virtualization: GridVirtualizationState;
|
|
569
667
|
dimensions: {
|
|
570
668
|
rowHeight: number;
|
|
571
669
|
headerHeight: number;
|
|
@@ -599,7 +697,7 @@ export interface GridLocaleText {
|
|
|
599
697
|
/**
|
|
600
698
|
* Main properties for the DataGrid component.
|
|
601
699
|
*/
|
|
602
|
-
export interface DataGridProps<R extends
|
|
700
|
+
export interface DataGridProps<R extends GridValidRowModel = GridRowModel> {
|
|
603
701
|
/** The dataset to display in the grid. */
|
|
604
702
|
rows: R[];
|
|
605
703
|
/** Column definitions governing how data is displayed and interacted with. */
|
|
@@ -683,8 +781,13 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
683
781
|
disableRowSelectionOnClick?: boolean;
|
|
684
782
|
/** If true, the user can only select a single row at a time. */
|
|
685
783
|
disableMultipleRowSelection?: boolean;
|
|
784
|
+
/**
|
|
785
|
+
* If true, Ctrl/Cmd+C does not copy the selected rows, so the page (or your own handler) owns
|
|
786
|
+
* the shortcut. `apiRef.current.copySelectedRows()` still works. Default: false.
|
|
787
|
+
*/
|
|
788
|
+
disableClipboardCopy?: boolean;
|
|
686
789
|
|
|
687
|
-
/**
|
|
790
|
+
/** Loading state. With no rows the body shows skeleton rows (or `slots.loadingOverlay`); with rows, they stay and a progress bar (or `slots.loadingOverlay`) is shown over them. */
|
|
688
791
|
loading?: boolean;
|
|
689
792
|
/** Visual density of the grid. */
|
|
690
793
|
density?: 'compact' | 'standard' | 'comfortable';
|
|
@@ -705,10 +808,17 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
705
808
|
|
|
706
809
|
/** Advanced: The starting internal state of the grid. */
|
|
707
810
|
initialState?: import('../state/types').GridInitialState;
|
|
708
|
-
/**
|
|
811
|
+
/**
|
|
812
|
+
* Called on mount and whenever the value of the sorting, filter, pagination, columns (widths, order,
|
|
813
|
+
* visibility, pinning) or density state changes. Selection, expansion and editing do not call it.
|
|
814
|
+
*/
|
|
709
815
|
onStateChange?: (state: import('../state/types').GridState) => void;
|
|
710
816
|
|
|
711
|
-
/**
|
|
817
|
+
/**
|
|
818
|
+
* Callback fired when a row is clicked. Tree-data parent rows are real rows: a click fires this and
|
|
819
|
+
* selects them like any row (the chevron expands them). Synthetic rows (row-grouping group rows,
|
|
820
|
+
* subtotal rows and auto-created tree parents) do not fire it: clicking a group row toggles it.
|
|
821
|
+
*/
|
|
712
822
|
onRowClick?: (params: GridRowParams<R>) => void;
|
|
713
823
|
/**
|
|
714
824
|
* Callback fired when a row is double-clicked. Also fires for group rows; check
|
|
@@ -720,9 +830,12 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
720
830
|
/** Callback fired when a cell is clicked. */
|
|
721
831
|
onCellClick?: (params: GridCellParams<R>) => void;
|
|
722
832
|
|
|
723
|
-
/**
|
|
833
|
+
/**
|
|
834
|
+
* Renders the detail panel content for a row in Master-Detail mode. Called for data rows only:
|
|
835
|
+
* synthetic group, subtotal and auto-created tree-parent rows have no detail panel.
|
|
836
|
+
*/
|
|
724
837
|
getDetailPanelContent?: (params: GridDetailPanelParams<R>) => React.ReactNode;
|
|
725
|
-
/** Defines the height of the detail panel. */
|
|
838
|
+
/** Defines the height of the detail panel. Called for data rows only, like `getDetailPanelContent`. */
|
|
726
839
|
getDetailPanelHeight?: (params: GridDetailPanelParams<R>) => GridDetailPanelHeight;
|
|
727
840
|
/** Controlled state for expanded detail panels. */
|
|
728
841
|
detailPanelExpandedRowIds?: Set<GridRowId>;
|
|
@@ -733,8 +846,17 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
733
846
|
disableColumnReorder?: boolean;
|
|
734
847
|
/** Controlled horizontal order of column fields. */
|
|
735
848
|
columnOrder?: GridColumnOrder;
|
|
736
|
-
/**
|
|
737
|
-
|
|
849
|
+
/**
|
|
850
|
+
* Fired when the user moves one column (header drag or Columns panel). `oldIndex` / `targetIndex`
|
|
851
|
+
* are positions in the grid's full column order: every current column, in order.
|
|
852
|
+
*/
|
|
853
|
+
onColumnOrderChange?: (params: GridColumnOrderChangeParams) => void;
|
|
854
|
+
/**
|
|
855
|
+
* Fired with the whole new column order after every change: a header drag, a Columns panel drag
|
|
856
|
+
* and the panel's Reset. The easiest way to keep a controlled `columnOrder` in sync.
|
|
857
|
+
* Not fired for the generated columns of pivot mode.
|
|
858
|
+
*/
|
|
859
|
+
onColumnOrderModelChange?: (columnOrder: GridColumnOrder) => void;
|
|
738
860
|
|
|
739
861
|
/** If true, rows can be reordered via drag-and-drop. */
|
|
740
862
|
rowReordering?: boolean;
|
|
@@ -743,10 +865,17 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
743
865
|
|
|
744
866
|
/** If true, enables hierarchical tree data display. */
|
|
745
867
|
treeData?: boolean;
|
|
746
|
-
/**
|
|
868
|
+
/**
|
|
869
|
+
* Function to get the path (array of strings) for a row in Tree Data mode. Required with `treeData`:
|
|
870
|
+
* without it the rows are shown flat. Segments may contain any character, including '/'. Keep the
|
|
871
|
+
* function identity stable (module scope or useCallback); a new function rebuilds the tree.
|
|
872
|
+
*/
|
|
747
873
|
getTreeDataPath?: (row: R) => string[];
|
|
748
|
-
/**
|
|
749
|
-
|
|
874
|
+
/**
|
|
875
|
+
* Adds a dedicated grouping column (pinned left) under row grouping or tree data, configured by these
|
|
876
|
+
* fields. Every key is optional: `field` is always `'__group__'` (a `field` you pass is ignored).
|
|
877
|
+
*/
|
|
878
|
+
groupingColDef?: Partial<GridColDef<R>>;
|
|
750
879
|
/** Initial expansion depth for Tree Data. */
|
|
751
880
|
defaultGroupingExpansionDepth?: number;
|
|
752
881
|
|
|
@@ -756,7 +885,12 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
756
885
|
aggregationModel?: GridAggregationModel;
|
|
757
886
|
/** Callback fired when aggregation model changes. */
|
|
758
887
|
onAggregationModelChange?: (model: GridAggregationModel) => void;
|
|
759
|
-
/**
|
|
888
|
+
/**
|
|
889
|
+
* Advanced: where aggregation results appear. Called for every group node (with its current
|
|
890
|
+
* `isExpanded`) and once with `null` for the grand total. `'inline'` (default for groups) shows them
|
|
891
|
+
* on the group row; `'footer'` on a subtotal row after the group's children while it is expanded
|
|
892
|
+
* (inline while collapsed); `null` hides them. For the grand total, `null` hides the footer row.
|
|
893
|
+
*/
|
|
760
894
|
getAggregationPosition?: (groupNode: GridTreeNode | null) => 'inline' | 'footer' | null;
|
|
761
895
|
|
|
762
896
|
/** If true, switches the grid to multidimensional Pivot Mode. */
|
|
@@ -778,29 +912,48 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
778
912
|
/** Callback fired when scrolling reaches the bottom of the grid viewport. */
|
|
779
913
|
onRowsScrollEnd?: (params: GridRowScrollEndParams) => void;
|
|
780
914
|
|
|
781
|
-
/**
|
|
782
|
-
|
|
915
|
+
/**
|
|
916
|
+
* Advanced: reactive reference to the internal API for imperative control. Pass
|
|
917
|
+
* `useGridApiRef<MyRow>()` to have the row getters typed as `MyRow`; a plain `useGridApiRef()` also works.
|
|
918
|
+
*/
|
|
919
|
+
apiRef?: React.MutableRefObject<GridApi<R>> | React.MutableRefObject<GridApi>;
|
|
783
920
|
|
|
784
921
|
/** Custom components to replace internal grid parts. */
|
|
785
922
|
slots?: {
|
|
786
|
-
/**
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
923
|
+
/**
|
|
924
|
+
* Component rendered as the grid toolbar. Receives `GridToolbarSlotProps` (plus `slotProps.toolbar`),
|
|
925
|
+
* so it can be typed with `GridToolbarProps` or wrap the exported `GridToolbar`.
|
|
926
|
+
*/
|
|
927
|
+
toolbar?: React.ComponentType<GridToolbarSlotProps & Record<string, unknown>>;
|
|
928
|
+
/**
|
|
929
|
+
* Component rendered as the pagination control. Receives `PaginationProps` (plus `slotProps.pagination`),
|
|
930
|
+
* so it can be typed with `PaginationProps` or wrap the exported `Pagination`.
|
|
931
|
+
*/
|
|
932
|
+
pagination?: React.ComponentType<GridPaginationSlotProps & Record<string, unknown>>;
|
|
933
|
+
/** Component rendered when the grid is empty. Receives only `slotProps.noRowsOverlay`. */
|
|
934
|
+
noRowsOverlay?: React.ComponentType<GridOverlaySlotProps>;
|
|
935
|
+
/** Component rendered during loading states. Receives only `slotProps.loadingOverlay`. */
|
|
936
|
+
loadingOverlay?: React.ComponentType<GridOverlaySlotProps>;
|
|
937
|
+
/**
|
|
938
|
+
* Component rendered at the very bottom of the grid, in place of the pagination area.
|
|
939
|
+
* Receives `GridFooterSlotProps` (plus `slotProps.footer`).
|
|
940
|
+
*/
|
|
941
|
+
footer?: React.ComponentType<GridFooterSlotProps & Record<string, unknown>>;
|
|
796
942
|
};
|
|
797
943
|
/** Properties passed directly to custom slots. */
|
|
798
944
|
slotProps?: {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
945
|
+
/**
|
|
946
|
+
* Merged over the props the grid passes to the toolbar. Typed as `GridToolbarProps` (so render props
|
|
947
|
+
* such as `renderQuickFilter` are checked and their parameters inferred), plus any extra keys a custom
|
|
948
|
+
* toolbar reads. `columns` / `baseColumns` are not checked, so typed `GridColDef<R>[]` can be passed.
|
|
949
|
+
*/
|
|
950
|
+
toolbar?: Omit<Partial<GridToolbarProps>, 'columns' | 'baseColumns'> & Record<string, unknown>;
|
|
951
|
+
/** Merged over the `PaginationProps` the grid passes to the pagination slot. */
|
|
952
|
+
pagination?: Partial<GridPaginationSlotProps> & Record<string, unknown>;
|
|
953
|
+
noRowsOverlay?: GridOverlaySlotProps;
|
|
954
|
+
loadingOverlay?: GridOverlaySlotProps;
|
|
955
|
+
/** Merged over the `GridFooterSlotProps` the grid passes to the footer slot. */
|
|
956
|
+
footer?: Partial<GridFooterSlotProps> & Record<string, unknown>;
|
|
804
957
|
};
|
|
805
958
|
|
|
806
959
|
/** When true, renders the grid as a single-column list of cards. Perfect for mobile/responsive views. */
|
|
@@ -815,26 +968,73 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
|
|
|
815
968
|
columnGroupingModel?: GridColumnGroupingModel;
|
|
816
969
|
}
|
|
817
970
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
971
|
+
/**
|
|
972
|
+
* `DataGridProps<R>` with untyped `columns` (`GridColDef[]`, i.e. `GridColDef<GridRowModel>[]`). `DataGrid`
|
|
973
|
+
* accepts these props as well as `DataGridProps<R>`, so columns written without a row type work with rows of
|
|
974
|
+
* any type `R`. Their callbacks then see `params.row` as `GridRowModel`; type the columns as
|
|
975
|
+
* `GridColDef<R>[]` to get your row type there.
|
|
976
|
+
* @since v3.0
|
|
977
|
+
*/
|
|
978
|
+
export type DataGridUntypedColumnsProps<R extends GridValidRowModel = GridRowModel> =
|
|
979
|
+
Omit<DataGridProps<R>, 'columns'> & { columns: GridColDef[] };
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Props the grid passes to `slots.toolbar`, before `slotProps.toolbar` is merged over them: the
|
|
983
|
+
* `GridToolbarProps` it controls (columns, models and their change handlers) plus `apiRef`.
|
|
984
|
+
* @since v3.0
|
|
985
|
+
*/
|
|
986
|
+
export interface GridToolbarSlotProps extends GridToolbarProps {
|
|
987
|
+
apiRef: React.MutableRefObject<GridApi>;
|
|
823
988
|
}
|
|
824
989
|
|
|
825
|
-
|
|
990
|
+
/**
|
|
991
|
+
* Props the grid passes to `slots.pagination`, before `slotProps.pagination` is merged over them.
|
|
992
|
+
* @since v3.0
|
|
993
|
+
*/
|
|
994
|
+
export type GridPaginationSlotProps = PaginationProps;
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Props of `slots.noRowsOverlay` and `slots.loadingOverlay`: the grid passes none of its own, only
|
|
998
|
+
* `slotProps.noRowsOverlay` / `slotProps.loadingOverlay`.
|
|
999
|
+
* @since v3.0
|
|
1000
|
+
*/
|
|
1001
|
+
export type GridOverlaySlotProps = Record<string, unknown>;
|
|
826
1002
|
|
|
827
|
-
|
|
828
|
-
|
|
1003
|
+
/**
|
|
1004
|
+
* Props the grid passes to `slots.footer`, before `slotProps.footer` is merged over them.
|
|
1005
|
+
* @since v3.0
|
|
1006
|
+
*/
|
|
1007
|
+
export interface GridFooterSlotProps {
|
|
1008
|
+
apiRef: React.MutableRefObject<GridApi>;
|
|
1009
|
+
/** The active aggregation model (`{}` when none). */
|
|
1010
|
+
aggregationModel: GridAggregationModel;
|
|
1011
|
+
/** The grand-total aggregation result, or `null` when no aggregation is active. */
|
|
1012
|
+
aggregationResult: GridAggregationResult | null;
|
|
1013
|
+
/**
|
|
1014
|
+
* The built-in pager's count: rows after filtering, pinned rows excluded (`rowCount` from the
|
|
1015
|
+
* server in server pagination mode). Under tree data / row grouping: the filtered data rows.
|
|
1016
|
+
*/
|
|
1017
|
+
rowCount: number;
|
|
1018
|
+
/** Whether pagination is in effect (false under row grouping and infinite scroll). */
|
|
1019
|
+
pagination: boolean;
|
|
1020
|
+
paginationModel: GridPaginationModel;
|
|
1021
|
+
pageSizeOptions: number[];
|
|
1022
|
+
onPaginationModelChange: (model: GridPaginationModel) => void;
|
|
829
1023
|
}
|
|
830
1024
|
|
|
831
|
-
|
|
1025
|
+
/** The `slots` prop of `DataGrid`: components that replace built-in parts of the grid. */
|
|
1026
|
+
export type GridSlots = NonNullable<DataGridProps['slots']>;
|
|
1027
|
+
|
|
1028
|
+
/** The `slotProps` prop of `DataGrid`: props for each slot, keyed like `GridSlots`. */
|
|
1029
|
+
export type GridSlotProps = NonNullable<DataGridProps['slotProps']>;
|
|
1030
|
+
|
|
1031
|
+
export interface GridRowParams<R extends GridValidRowModel = GridRowModel> {
|
|
832
1032
|
row: R;
|
|
833
1033
|
id: GridRowId;
|
|
834
1034
|
rowIndex: number;
|
|
835
1035
|
}
|
|
836
1036
|
|
|
837
|
-
export interface GridCellParams<R extends
|
|
1037
|
+
export interface GridCellParams<R extends GridValidRowModel = GridRowModel> {
|
|
838
1038
|
row: R;
|
|
839
1039
|
field: string;
|
|
840
1040
|
value: unknown;
|
|
@@ -843,7 +1043,7 @@ export interface GridCellParams<R extends GridRowModel = GridRowModel> {
|
|
|
843
1043
|
colIndex: number;
|
|
844
1044
|
}
|
|
845
1045
|
|
|
846
|
-
export interface GridDetailPanelParams<R extends
|
|
1046
|
+
export interface GridDetailPanelParams<R extends GridValidRowModel = GridRowModel> {
|
|
847
1047
|
row: R;
|
|
848
1048
|
id: GridRowId;
|
|
849
1049
|
rowIndex: number;
|
|
@@ -851,31 +1051,26 @@ export interface GridDetailPanelParams<R extends GridRowModel = GridRowModel> {
|
|
|
851
1051
|
|
|
852
1052
|
export type GridDetailPanelHeight = number | 'auto';
|
|
853
1053
|
|
|
854
|
-
export type GridDetailPanelContent<R extends GridRowModel = GridRowModel> =
|
|
855
|
-
| React.ReactNode
|
|
856
|
-
| ((params: GridDetailPanelParams<R>) => React.ReactNode);
|
|
857
|
-
|
|
858
|
-
export interface GridDetailPanelState {
|
|
859
|
-
expandedRowIds: Set<GridRowId>;
|
|
860
|
-
contentCache: Map<GridRowId, React.ReactNode>;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
1054
|
/**
|
|
864
1055
|
* The Imperative API for interacting with the DataGrid.
|
|
865
1056
|
* Access this via the `apiRef` prop or a ref passed to the component.
|
|
866
1057
|
*/
|
|
867
|
-
|
|
1058
|
+
/**
|
|
1059
|
+
* The imperative grid API. `R` types the row getters (`getRow`, `getAllRows`, `getVisibleRows`,
|
|
1060
|
+
* `getAllFilteredRows`); it defaults to `GridRowModel`, so `GridApi` alone keeps working.
|
|
1061
|
+
*/
|
|
1062
|
+
export interface GridApi<R extends GridValidRowModel = GridRowModel> {
|
|
868
1063
|
/**
|
|
869
1064
|
* Returns the row model with the given ID.
|
|
870
1065
|
* @param id The row unique ID.
|
|
871
1066
|
*/
|
|
872
|
-
getRow: (id: GridRowId) =>
|
|
1067
|
+
getRow: (id: GridRowId) => R | null;
|
|
873
1068
|
/** Returns all rows currently loaded into the grid. */
|
|
874
|
-
getAllRows: () =>
|
|
1069
|
+
getAllRows: () => R[];
|
|
875
1070
|
/** Returns all rows currently visible after filtering and sorting. */
|
|
876
|
-
getVisibleRows: () =>
|
|
1071
|
+
getVisibleRows: () => R[];
|
|
877
1072
|
/** Returns all filtered and sorted rows, ignoring pagination. Use this for full-dataset exports. */
|
|
878
|
-
getAllFilteredRows: () =>
|
|
1073
|
+
getAllFilteredRows: () => R[];
|
|
879
1074
|
/**
|
|
880
1075
|
* Returns an ordered flat list of `GridGroupedExportRow` entries that mirrors the
|
|
881
1076
|
* on-screen grouping tree: group-headers, leaf rows, per-group subtotals, and a
|
|
@@ -933,9 +1128,11 @@ export interface GridApi {
|
|
|
933
1128
|
scrollToIndexes: (params: { rowIndex?: number; colIndex?: number }) => void;
|
|
934
1129
|
|
|
935
1130
|
/**
|
|
936
|
-
* Programmatically copies all currently selected rows to the clipboard as TSV
|
|
937
|
-
*
|
|
938
|
-
*
|
|
1131
|
+
* Programmatically copies all currently selected rows to the clipboard as TSV: every selected
|
|
1132
|
+
* row that passes the filter (other pages, collapsed groups and pinned rows included), with the
|
|
1133
|
+
* visible columns in screen order. Equivalent to the user pressing Ctrl+C / Cmd+C.
|
|
1134
|
+
* @returns A Promise that resolves when the text is written (or when no selected row was found,
|
|
1135
|
+
* in which case nothing is written) and rejects when the clipboard write fails.
|
|
939
1136
|
*/
|
|
940
1137
|
copySelectedRows: () => Promise<void>;
|
|
941
1138
|
}
|