mgh-components 1.0.14 → 1.1.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 (29) hide show
  1. package/README.md +167 -53
  2. package/dist/components/CustomNoRowsOverlay/CustomNoRowsOverlay.types.d.ts +0 -0
  3. package/dist/components/Label/styles.d.ts +10 -6
  4. package/dist/components/MGHDataGrid/MGHDataGrid.d.ts +3 -2
  5. package/dist/components/MGHDataGrid/MGHDataGrid.types.d.ts +1 -1
  6. package/dist/components/MGHGrid/MGHGrid.d.ts +7 -0
  7. package/dist/components/MGHGrid/MGHGrid.styles.d.ts +10 -0
  8. package/dist/components/MGHGrid/MGHGrid.types.d.ts +708 -0
  9. package/dist/components/MGHGrid/components/ActionsCell.d.ts +22 -0
  10. package/dist/components/MGHGrid/components/ColumnMenu.d.ts +12 -0
  11. package/dist/components/MGHGrid/components/ColumnsPanel.d.ts +2 -0
  12. package/dist/components/MGHGrid/components/FilterPanel.d.ts +2 -0
  13. package/dist/components/MGHGrid/components/Footer.d.ts +3 -0
  14. package/dist/components/MGHGrid/components/Overlays.d.ts +5 -0
  15. package/dist/components/MGHGrid/components/Toolbar.d.ts +30 -0
  16. package/dist/components/MGHGrid/components/primitives.d.ts +81 -0
  17. package/dist/components/MGHGrid/context.d.ts +40 -0
  18. package/dist/components/MGHGrid/export.d.ts +18 -0
  19. package/dist/components/MGHGrid/grouping.d.ts +40 -0
  20. package/dist/components/MGHGrid/hooks.d.ts +23 -0
  21. package/dist/components/MGHGrid/icons.d.ts +32 -0
  22. package/dist/components/MGHGrid/index.d.ts +20 -0
  23. package/dist/components/MGHGrid/utils.d.ts +62 -0
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.esm.js +1 -1
  28. package/dist/index.esm.js.map +1 -1
  29. package/package.json +1 -1
@@ -0,0 +1,708 @@
1
+ import React, { JSX } from 'react';
2
+ export type MGHGridRowId = string | number;
3
+ export type MGHGridValidRowModel = {
4
+ [key: string]: any;
5
+ };
6
+ export type MGHGridColType = 'string' | 'number' | 'date' | 'dateTime' | 'boolean' | 'singleSelect' | 'actions';
7
+ export type MGHGridSortDirection = 'asc' | 'desc' | null | undefined;
8
+ export type MGHGridAlignment = 'left' | 'center' | 'right';
9
+ export type MGHGridDensity = 'compact' | 'standard' | 'comfortable';
10
+ export type MGHGridPinnedSide = 'left' | 'right';
11
+ export type MGHGridLogicOperator = 'and' | 'or';
12
+ export type MGHGridThemeMode = 'light' | 'dark';
13
+ export type MGHGridCellMode = 'view' | 'edit';
14
+ export type MGHGridAggregationFunctionName = 'sum' | 'avg' | 'min' | 'max' | 'size' | (string & {});
15
+ export interface MGHGridSortItem {
16
+ field: string;
17
+ sort: MGHGridSortDirection;
18
+ }
19
+ export type MGHGridSortModel = MGHGridSortItem[];
20
+ export interface MGHGridFilterItem {
21
+ id?: number | string;
22
+ field: string;
23
+ operator: string;
24
+ value?: any;
25
+ }
26
+ export interface MGHGridFilterModel {
27
+ items: MGHGridFilterItem[];
28
+ logicOperator?: MGHGridLogicOperator;
29
+ quickFilterValues?: any[];
30
+ quickFilterLogicOperator?: MGHGridLogicOperator;
31
+ quickFilterExcludeHiddenColumns?: boolean;
32
+ }
33
+ export interface MGHGridPaginationModel {
34
+ page: number;
35
+ pageSize: number;
36
+ }
37
+ export type MGHGridColumnVisibilityModel = Record<string, boolean>;
38
+ export interface MGHGridPinnedColumns {
39
+ left?: string[];
40
+ right?: string[];
41
+ }
42
+ export interface MGHGridPinnedRows<R extends MGHGridValidRowModel = any> {
43
+ top?: R[];
44
+ bottom?: R[];
45
+ }
46
+ export interface MGHGridRowSelectionModel {
47
+ type: 'include' | 'exclude';
48
+ ids: Set<MGHGridRowId>;
49
+ }
50
+ export type MGHGridRowSelectionModelInput = MGHGridRowSelectionModel | MGHGridRowId[] | Set<MGHGridRowId>;
51
+ export type MGHGridRowGroupingModel = string[];
52
+ export type MGHGridAggregationModel = Record<string, MGHGridAggregationFunctionName>;
53
+ export interface MGHGridColumnDimensions {
54
+ width?: number;
55
+ flex?: number;
56
+ }
57
+ export interface MGHGridInitialState {
58
+ columns?: {
59
+ columnVisibilityModel?: MGHGridColumnVisibilityModel;
60
+ orderedFields?: string[];
61
+ dimensions?: Record<string, MGHGridColumnDimensions>;
62
+ };
63
+ sorting?: {
64
+ sortModel?: MGHGridSortModel;
65
+ };
66
+ filter?: {
67
+ filterModel?: MGHGridFilterModel;
68
+ };
69
+ pagination?: {
70
+ paginationModel?: Partial<MGHGridPaginationModel>;
71
+ };
72
+ pinnedColumns?: MGHGridPinnedColumns;
73
+ density?: MGHGridDensity;
74
+ rowGrouping?: {
75
+ model?: MGHGridRowGroupingModel;
76
+ };
77
+ aggregation?: {
78
+ model?: MGHGridAggregationModel;
79
+ };
80
+ detailPanel?: {
81
+ expandedRowIds?: MGHGridRowId[] | Set<MGHGridRowId>;
82
+ };
83
+ }
84
+ export interface MGHGridLeafNode {
85
+ type: 'leaf';
86
+ id: MGHGridRowId;
87
+ depth: number;
88
+ parent: MGHGridRowId | null;
89
+ }
90
+ export interface MGHGridGroupNode {
91
+ type: 'group';
92
+ id: MGHGridRowId;
93
+ depth: number;
94
+ parent: MGHGridRowId | null;
95
+ groupingField: string;
96
+ groupingKey: any;
97
+ groupingLabel: string;
98
+ children: MGHGridRowId[];
99
+ leafIds: MGHGridRowId[];
100
+ isExpanded: boolean;
101
+ }
102
+ export interface MGHGridPinnedRowNode {
103
+ type: 'pinnedRow';
104
+ id: MGHGridRowId;
105
+ depth: 0;
106
+ parent: null;
107
+ position: 'top' | 'bottom';
108
+ }
109
+ export interface MGHGridFooterNode {
110
+ type: 'footer';
111
+ id: MGHGridRowId;
112
+ depth: 0;
113
+ parent: null;
114
+ }
115
+ export type MGHGridRowNode = MGHGridLeafNode | MGHGridGroupNode | MGHGridPinnedRowNode | MGHGridFooterNode;
116
+ export interface MGHGridCallbackDetails {
117
+ api: MGHGridApi<any>;
118
+ reason?: string;
119
+ }
120
+ export interface MGHGridCellParams<R extends MGHGridValidRowModel = any, V = any, F = V> {
121
+ id: MGHGridRowId;
122
+ field: string;
123
+ value: V;
124
+ formattedValue: F;
125
+ row: R;
126
+ rowNode: MGHGridRowNode;
127
+ colDef: MGHGridColDef<R, V, F>;
128
+ api: MGHGridApi<R>;
129
+ hasFocus: boolean;
130
+ tabIndex: 0 | -1;
131
+ cellMode: MGHGridCellMode;
132
+ isEditable: boolean;
133
+ }
134
+ export type MGHGridRenderCellParams<R extends MGHGridValidRowModel = any, V = any, F = V> = MGHGridCellParams<R, V, F>;
135
+ export interface MGHGridRenderEditCellParams<R extends MGHGridValidRowModel = any, V = any, F = V> extends MGHGridCellParams<R, V, F> {
136
+ /** Current (uncommitted) editing value. */
137
+ editValue: any;
138
+ /** Update the editing value. */
139
+ onValueChange: (value: any) => void;
140
+ /** Commit the edit. */
141
+ commit: () => void;
142
+ /** Cancel the edit. */
143
+ cancel: () => void;
144
+ }
145
+ export interface MGHGridColumnHeaderParams<R extends MGHGridValidRowModel = any> {
146
+ field: string;
147
+ colDef: MGHGridColDef<R>;
148
+ api: MGHGridApi<R>;
149
+ }
150
+ export interface MGHGridRowParams<R extends MGHGridValidRowModel = any> {
151
+ id: MGHGridRowId;
152
+ row: R;
153
+ columns: MGHGridColDef<R>[];
154
+ api: MGHGridApi<R>;
155
+ }
156
+ export interface MGHGridRowClassNameParams<R extends MGHGridValidRowModel = any> extends MGHGridRowParams<R> {
157
+ indexRelativeToCurrentPage: number;
158
+ isFirstVisible: boolean;
159
+ isLastVisible: boolean;
160
+ rowNode: MGHGridRowNode;
161
+ }
162
+ export interface MGHGridRowHeightParams<R extends MGHGridValidRowModel = any> {
163
+ id: MGHGridRowId;
164
+ model: R;
165
+ densityFactor: number;
166
+ }
167
+ export type MGHGridRowHeightReturnValue = number | 'auto' | null | undefined;
168
+ export interface MGHGridDetailPanelHeightParams<R extends MGHGridValidRowModel = any> {
169
+ id: MGHGridRowId;
170
+ row: R;
171
+ }
172
+ export interface MGHGridSortCellParams {
173
+ id: MGHGridRowId;
174
+ field: string;
175
+ value: any;
176
+ row: any;
177
+ api: MGHGridApi<any>;
178
+ }
179
+ export interface MGHGridColumnOrderChangeParams {
180
+ column: MGHGridColDef;
181
+ targetIndex: number;
182
+ oldIndex: number;
183
+ }
184
+ export interface MGHGridColumnResizeParams {
185
+ colDef: MGHGridColDef;
186
+ width: number;
187
+ }
188
+ export interface MGHGridRowEditStopParams<R extends MGHGridValidRowModel = any> {
189
+ id: MGHGridRowId;
190
+ field: string;
191
+ row: R;
192
+ reason: 'enterKeyDown' | 'escapeKeyDown' | 'cellFocusOut' | 'tabKeyDown' | 'api';
193
+ }
194
+ export interface MGHGridValueOptionObject {
195
+ value: any;
196
+ label: string;
197
+ }
198
+ export type MGHGridValueOption = string | number | MGHGridValueOptionObject;
199
+ export interface MGHGridValueOptionsParams<R extends MGHGridValidRowModel = any> {
200
+ field: string;
201
+ id?: MGHGridRowId;
202
+ row?: R;
203
+ }
204
+ export type MGHGridFilterInputType = 'text' | 'number' | 'date' | 'datetime-local' | 'select' | 'multiselect' | 'boolean' | 'none';
205
+ export interface MGHGridFilterInputProps {
206
+ item: MGHGridFilterItem;
207
+ column: MGHGridColDef;
208
+ applyValue: (item: MGHGridFilterItem) => void;
209
+ api: MGHGridApi;
210
+ }
211
+ export type MGHGridApplyFilterFn<R extends MGHGridValidRowModel = any, V = any> = (value: V, row: R, column: MGHGridColDef<R, V>, api: MGHGridApi<R>) => boolean;
212
+ export interface MGHGridFilterOperator<R extends MGHGridValidRowModel = any, V = any> {
213
+ value: string;
214
+ label?: string;
215
+ headerLabel?: string;
216
+ /** Return null to skip the filter (e.g. empty value). */
217
+ getApplyFilterFn: (filterItem: MGHGridFilterItem, column: MGHGridColDef<R, V>) => MGHGridApplyFilterFn<R, V> | null;
218
+ /** Which input the filter panel should render for this operator. */
219
+ inputType?: MGHGridFilterInputType;
220
+ /** Custom input component for the filter panel. */
221
+ InputComponent?: React.ComponentType<MGHGridFilterInputProps>;
222
+ /** Defaults to true (except for isEmpty / isNotEmpty). */
223
+ requiresFilterValue?: boolean;
224
+ }
225
+ export type MGHGridValueGetter<R extends MGHGridValidRowModel = any, V = any> = (value: any, row: R, column: MGHGridColDef<R, V>, api: MGHGridApi<R>) => V;
226
+ export type MGHGridValueFormatter<R extends MGHGridValidRowModel = any, V = any, F = V> = (value: V, row: R, column: MGHGridColDef<R, V, F>, api: MGHGridApi<R>) => F;
227
+ export type MGHGridValueSetter<R extends MGHGridValidRowModel = any, V = any> = (value: V, row: R, column: MGHGridColDef<R, V>, api: MGHGridApi<R>) => R;
228
+ export type MGHGridValueParser<R extends MGHGridValidRowModel = any, V = any> = (value: any, row: R | undefined, column: MGHGridColDef<R, V>, api: MGHGridApi<R>) => V;
229
+ export type MGHGridComparatorFn<V = any> = (v1: V, v2: V, cellParams1: MGHGridSortCellParams, cellParams2: MGHGridSortCellParams) => number;
230
+ export interface MGHGridColDef<R extends MGHGridValidRowModel = any, V = any, F = V> {
231
+ field: string;
232
+ headerName?: string;
233
+ description?: string;
234
+ type?: MGHGridColType;
235
+ width?: number;
236
+ minWidth?: number;
237
+ maxWidth?: number;
238
+ flex?: number;
239
+ align?: MGHGridAlignment;
240
+ headerAlign?: MGHGridAlignment;
241
+ sortable?: boolean;
242
+ filterable?: boolean;
243
+ hideable?: boolean;
244
+ resizable?: boolean;
245
+ pinnable?: boolean;
246
+ groupable?: boolean;
247
+ aggregable?: boolean;
248
+ editable?: boolean;
249
+ disableColumnMenu?: boolean;
250
+ disableExport?: boolean;
251
+ disableReorder?: boolean;
252
+ sortingOrder?: MGHGridSortDirection[];
253
+ display?: 'text' | 'flex';
254
+ valueGetter?: MGHGridValueGetter<R, V>;
255
+ valueSetter?: MGHGridValueSetter<R, V>;
256
+ valueFormatter?: MGHGridValueFormatter<R, V, F>;
257
+ valueParser?: MGHGridValueParser<R, V>;
258
+ /** Used for row grouping instead of the cell value when provided. */
259
+ groupingValueGetter?: MGHGridValueGetter<R, any>;
260
+ renderCell?: (params: MGHGridRenderCellParams<R, V, F>) => React.ReactNode;
261
+ renderEditCell?: (params: MGHGridRenderEditCellParams<R, V, F>) => React.ReactNode;
262
+ renderHeader?: (params: MGHGridColumnHeaderParams<R>) => React.ReactNode;
263
+ sortComparator?: MGHGridComparatorFn<V>;
264
+ filterOperators?: MGHGridFilterOperator<R, V>[];
265
+ getApplyQuickFilterFn?: (value: any, column: MGHGridColDef<R, V, F>, api: MGHGridApi<R>) => MGHGridApplyFilterFn<R, V> | null;
266
+ valueOptions?: MGHGridValueOption[] | ((params: MGHGridValueOptionsParams<R>) => MGHGridValueOption[]);
267
+ getOptionLabel?: (option: MGHGridValueOption) => string;
268
+ getOptionValue?: (option: MGHGridValueOption) => any;
269
+ getActions?: (params: MGHGridRowParams<R>) => React.ReactElement[];
270
+ cellClassName?: string | ((params: MGHGridCellParams<R, V, F>) => string);
271
+ headerClassName?: string | ((params: MGHGridColumnHeaderParams<R>) => string);
272
+ availableAggregationFunctions?: string[];
273
+ }
274
+ export interface MGHGridGroupingColDefOverrides extends Partial<Omit<MGHGridColDef, 'field'>> {
275
+ /** Hide the descendant count shown next to each group label. */
276
+ hideDescendantCount?: boolean;
277
+ }
278
+ export interface MGHGridAggregationFunction {
279
+ /** Apply the aggregation to the list of values. */
280
+ apply: (params: {
281
+ values: any[];
282
+ field: string;
283
+ }) => any;
284
+ /** Label displayed under the aggregated value in the footer. */
285
+ label?: string;
286
+ /** Column types this function is available for (all if omitted). */
287
+ columnTypes?: MGHGridColType[];
288
+ /** Format the aggregated value with the column value formatter (default true). */
289
+ valueFormatter?: (value: any) => any;
290
+ }
291
+ export interface MGHGridExportOptions {
292
+ fileName?: string;
293
+ /** Export all columns, including hidden ones (default false). */
294
+ allColumns?: boolean;
295
+ /** Explicit list of fields to export (overrides allColumns / visibility). */
296
+ fields?: string[];
297
+ /** Include the header row (default true). */
298
+ includeHeaders?: boolean;
299
+ /** Return the ids of the rows to export. Defaults to the sorted & filtered rows. */
300
+ getRowsToExport?: (params: {
301
+ api: MGHGridApi;
302
+ }) => MGHGridRowId[];
303
+ }
304
+ export interface MGHGridCsvExportOptions extends MGHGridExportOptions {
305
+ delimiter?: string;
306
+ utf8WithBom?: boolean;
307
+ /** Use the raw cell value instead of the formatted value. */
308
+ useRawValues?: boolean;
309
+ }
310
+ export interface MGHGridExcelExportOptions extends MGHGridExportOptions {
311
+ sheetName?: string;
312
+ /** Column widths (in characters) keyed by field. */
313
+ columnsStyles?: Record<string, {
314
+ width?: number;
315
+ }>;
316
+ }
317
+ export interface MGHGridPrintExportOptions extends MGHGridExportOptions {
318
+ hideToolbar?: boolean;
319
+ hideFooter?: boolean;
320
+ /** Title printed above the table. Defaults to the grid header. */
321
+ title?: string;
322
+ /** Extra CSS injected in the print document. */
323
+ pageStyle?: string;
324
+ }
325
+ export type MGHGridPreferencePanelValue = 'columns' | 'filters';
326
+ export interface MGHGridPreferencePanelState {
327
+ open: boolean;
328
+ openedPanelValue?: MGHGridPreferencePanelValue;
329
+ targetField?: string;
330
+ }
331
+ export interface MGHGridState {
332
+ sortModel: MGHGridSortModel;
333
+ filterModel: MGHGridFilterModel;
334
+ paginationModel: MGHGridPaginationModel;
335
+ pageCount: number;
336
+ /** Number of leaf rows after filtering. */
337
+ rowCount: number;
338
+ /** Total number of leaf rows before filtering. */
339
+ totalRowCount: number;
340
+ columnVisibilityModel: MGHGridColumnVisibilityModel;
341
+ orderedFields: string[];
342
+ columnWidths: Record<string, number>;
343
+ pinnedColumns: MGHGridPinnedColumns;
344
+ density: MGHGridDensity;
345
+ densityFactor: number;
346
+ rowSelectionModel: MGHGridRowSelectionModel;
347
+ rowGroupingModel: MGHGridRowGroupingModel;
348
+ aggregationModel: MGHGridAggregationModel;
349
+ expandedDetailPanels: Set<MGHGridRowId>;
350
+ preferencePanel: MGHGridPreferencePanelState;
351
+ filterCount: number;
352
+ quickFilterValues: any[];
353
+ }
354
+ export interface MGHGridApi<R extends MGHGridValidRowModel = any> {
355
+ getRow: (id: MGHGridRowId) => R | null;
356
+ getRowModels: () => Map<MGHGridRowId, R>;
357
+ getAllRowIds: () => MGHGridRowId[];
358
+ getRowNode: (id: MGHGridRowId) => MGHGridRowNode | null;
359
+ /** Leaf rows after filtering & sorting (all pages). */
360
+ getSortedRows: () => R[];
361
+ getSortedRowIds: () => MGHGridRowId[];
362
+ /** Rows displayed on the current page (leaf rows only). */
363
+ getVisibleRows: () => {
364
+ id: MGHGridRowId;
365
+ model: R;
366
+ }[];
367
+ getRowIndexRelativeToVisibleRows: (id: MGHGridRowId) => number;
368
+ updateRows: (updates: Partial<R>[]) => void;
369
+ getAllColumns: () => MGHGridColDef<R>[];
370
+ getVisibleColumns: () => MGHGridColDef<R>[];
371
+ getColumn: (field: string) => MGHGridColDef<R> | undefined;
372
+ getColumnIndex: (field: string, useVisibleColumns?: boolean) => number;
373
+ getColumnVisibilityModel: () => MGHGridColumnVisibilityModel;
374
+ setColumnVisibility: (field: string, isVisible: boolean) => void;
375
+ setColumnVisibilityModel: (model: MGHGridColumnVisibilityModel) => void;
376
+ setColumnWidth: (field: string, width: number) => void;
377
+ setColumnIndex: (field: string, targetIndex: number) => void;
378
+ autosizeColumns: (options?: {
379
+ columns?: string[];
380
+ includeHeaders?: boolean;
381
+ expand?: boolean;
382
+ }) => void;
383
+ pinColumn: (field: string, side: MGHGridPinnedSide) => void;
384
+ unpinColumn: (field: string) => void;
385
+ isColumnPinned: (field: string) => MGHGridPinnedSide | false;
386
+ getPinnedColumns: () => MGHGridPinnedColumns;
387
+ setPinnedColumns: (model: MGHGridPinnedColumns) => void;
388
+ getSortModel: () => MGHGridSortModel;
389
+ setSortModel: (model: MGHGridSortModel) => void;
390
+ sortColumn: (field: string, direction?: MGHGridSortDirection, allowMultipleSorting?: boolean) => void;
391
+ getFilterModel: () => MGHGridFilterModel;
392
+ setFilterModel: (model: MGHGridFilterModel) => void;
393
+ upsertFilterItem: (item: MGHGridFilterItem) => void;
394
+ upsertFilterItems: (items: MGHGridFilterItem[]) => void;
395
+ deleteFilterItem: (item: MGHGridFilterItem) => void;
396
+ setFilterLogicOperator: (operator: MGHGridLogicOperator) => void;
397
+ setQuickFilterValues: (values: any[]) => void;
398
+ showFilterPanel: (targetColumnField?: string, anchorEl?: HTMLElement | null) => void;
399
+ hideFilterPanel: () => void;
400
+ showPreferences: (panel: MGHGridPreferencePanelValue, anchorEl?: HTMLElement | null, targetField?: string) => void;
401
+ hidePreferences: () => void;
402
+ getSelectedRows: () => Map<MGHGridRowId, R>;
403
+ getRowSelectionModel: () => MGHGridRowSelectionModel;
404
+ setRowSelectionModel: (model: MGHGridRowSelectionModelInput) => void;
405
+ selectRow: (id: MGHGridRowId, isSelected?: boolean, resetSelection?: boolean) => void;
406
+ selectRows: (ids: MGHGridRowId[], isSelected?: boolean, resetSelection?: boolean) => void;
407
+ isRowSelected: (id: MGHGridRowId) => boolean;
408
+ isRowSelectable: (id: MGHGridRowId) => boolean;
409
+ setPage: (page: number) => void;
410
+ setPageSize: (pageSize: number) => void;
411
+ setPaginationModel: (model: MGHGridPaginationModel) => void;
412
+ setDensity: (density: MGHGridDensity) => void;
413
+ getDataAsCsv: (options?: MGHGridCsvExportOptions) => string;
414
+ exportDataAsCsv: (options?: MGHGridCsvExportOptions) => void;
415
+ exportDataAsExcel: (options?: MGHGridExcelExportOptions) => Promise<void>;
416
+ exportDataAsPrint: (options?: MGHGridPrintExportOptions) => void;
417
+ toggleDetailPanel: (id: MGHGridRowId) => void;
418
+ setExpandedDetailPanels: (ids: MGHGridRowId[]) => void;
419
+ getExpandedDetailPanels: () => MGHGridRowId[];
420
+ getRowGroupingModel: () => MGHGridRowGroupingModel;
421
+ setRowGroupingModel: (model: MGHGridRowGroupingModel) => void;
422
+ addRowGroupingCriteria: (field: string, groupingIndex?: number) => void;
423
+ removeRowGroupingCriteria: (field: string) => void;
424
+ setRowChildrenExpansion: (id: MGHGridRowId, isExpanded: boolean) => void;
425
+ getRowGroupChildren: (params: {
426
+ groupId: MGHGridRowId;
427
+ }) => MGHGridRowId[];
428
+ getAggregationModel: () => MGHGridAggregationModel;
429
+ setAggregationModel: (model: MGHGridAggregationModel) => void;
430
+ startCellEditMode: (params: {
431
+ id: MGHGridRowId;
432
+ field: string;
433
+ }) => void;
434
+ stopCellEditMode: (params: {
435
+ id: MGHGridRowId;
436
+ field: string;
437
+ ignoreModifications?: boolean;
438
+ }) => void;
439
+ getCellMode: (id: MGHGridRowId, field: string) => MGHGridCellMode;
440
+ setEditCellValue: (params: {
441
+ id: MGHGridRowId;
442
+ field: string;
443
+ value: any;
444
+ }) => void;
445
+ getCellValue: (id: MGHGridRowId, field: string) => any;
446
+ getCellParams: (id: MGHGridRowId, field: string) => MGHGridCellParams<R>;
447
+ setCellFocus: (id: MGHGridRowId, field: string) => void;
448
+ scrollToIndexes: (params: {
449
+ rowIndex?: number;
450
+ colIndex?: number;
451
+ }) => boolean;
452
+ scroll: (params: {
453
+ left?: number;
454
+ top?: number;
455
+ }) => void;
456
+ getScrollPosition: () => {
457
+ left: number;
458
+ top: number;
459
+ };
460
+ readonly state: MGHGridState;
461
+ forceUpdate: () => void;
462
+ rootElementRef: React.RefObject<HTMLDivElement | null>;
463
+ }
464
+ export interface MGHGridNoRowsOverlayProps {
465
+ text?: string;
466
+ /** Optional image rendered above the text. Defaults to an inline illustration. */
467
+ imageSrc?: string;
468
+ /** Compatibility with the legacy CustomNoRowsOverlay. */
469
+ useSettingsContext?: () => {
470
+ themeMode?: string;
471
+ };
472
+ themeMode?: MGHGridThemeMode;
473
+ }
474
+ export interface MGHGridLoadingOverlayProps {
475
+ text?: string;
476
+ }
477
+ export interface MGHGridToolbarProps {
478
+ showColumnsButton?: boolean;
479
+ showFilterButton?: boolean;
480
+ showExportButton?: boolean;
481
+ showQuickFilter?: boolean;
482
+ showDensitySelector?: boolean;
483
+ showCsvOption?: boolean;
484
+ showExcelOption?: boolean;
485
+ showPrintOption?: boolean;
486
+ csvOptions?: MGHGridCsvExportOptions;
487
+ excelOptions?: MGHGridExcelExportOptions;
488
+ printOptions?: MGHGridPrintExportOptions;
489
+ renderOtherButtons?: React.ReactNode;
490
+ renderDateRange?: React.ReactNode;
491
+ /** Extra items rendered at the top of the export menu. */
492
+ customMenuItem?: JSX.Element[] | JSX.Element;
493
+ /** Placeholder for the quick filter input. */
494
+ quickFilterPlaceholder?: string;
495
+ /** Debounce (ms) for the quick filter. */
496
+ quickFilterDebounceMs?: number;
497
+ /** Escape hatch for consumer-specific toolbar props (ignored by the default toolbar). */
498
+ [key: string]: any;
499
+ }
500
+ export interface MGHGridFooterProps {
501
+ /** Provided by the grid. */
502
+ api?: MGHGridApi;
503
+ }
504
+ export interface MGHGridSlots {
505
+ toolbar?: React.ComponentType<any> | null;
506
+ noRowsOverlay?: React.ComponentType<any>;
507
+ loadingOverlay?: React.ComponentType<any>;
508
+ footer?: React.ComponentType<any> | null;
509
+ }
510
+ export interface MGHGridSlotProps {
511
+ toolbar?: MGHGridToolbarProps & Record<string, any>;
512
+ noRowsOverlay?: MGHGridNoRowsOverlayProps & Record<string, any>;
513
+ loadingOverlay?: MGHGridLoadingOverlayProps & Record<string, any>;
514
+ footer?: Record<string, any>;
515
+ }
516
+ export interface MGHGridLocaleText {
517
+ noRowsLabel: string;
518
+ loadingLabel: string;
519
+ toolbarColumns: string;
520
+ toolbarFilters: string;
521
+ toolbarExport: string;
522
+ toolbarDensity: string;
523
+ toolbarQuickFilterPlaceholder: string;
524
+ toolbarQuickFilterLabel: string;
525
+ toolbarExportCSV: string;
526
+ toolbarExportExcel: string;
527
+ toolbarExportPrint: string;
528
+ densityCompact: string;
529
+ densityStandard: string;
530
+ densityComfortable: string;
531
+ columnsPanelSearchPlaceholder: string;
532
+ columnsPanelShowAll: string;
533
+ columnsPanelHideAll: string;
534
+ columnsPanelReset: string;
535
+ filterPanelAddFilter: string;
536
+ filterPanelRemoveAll: string;
537
+ filterPanelDeleteIcon: string;
538
+ filterPanelColumns: string;
539
+ filterPanelOperator: string;
540
+ filterPanelValue: string;
541
+ filterPanelInputPlaceholder: string;
542
+ filterPanelLogicOperator: string;
543
+ filterPanelOperatorAnd: string;
544
+ filterPanelOperatorOr: string;
545
+ columnMenuSortAsc: string;
546
+ columnMenuSortDesc: string;
547
+ columnMenuUnsort: string;
548
+ columnMenuFilter: string;
549
+ columnMenuHideColumn: string;
550
+ columnMenuManageColumns: string;
551
+ columnMenuPinLeft: string;
552
+ columnMenuPinRight: string;
553
+ columnMenuUnpin: string;
554
+ columnMenuGroup: (name: string) => string;
555
+ columnMenuUngroup: (name: string) => string;
556
+ columnMenuAggregation: string;
557
+ aggregationMenuItemHeader: string;
558
+ aggregationFunctionLabelNone: string;
559
+ aggregationFunctionLabelSum: string;
560
+ aggregationFunctionLabelAvg: string;
561
+ aggregationFunctionLabelMin: string;
562
+ aggregationFunctionLabelMax: string;
563
+ aggregationFunctionLabelSize: string;
564
+ footerRowSelected: (count: number) => string;
565
+ footerTotalRows: string;
566
+ footerPaginationRowsPerPage: string;
567
+ footerPaginationDisplayedRows: (from: number, to: number, count: number) => string;
568
+ footerPaginationFirstPage: string;
569
+ footerPaginationPreviousPage: string;
570
+ footerPaginationNextPage: string;
571
+ footerPaginationLastPage: string;
572
+ checkboxSelectionHeaderName: string;
573
+ checkboxSelectionSelectAllRows: string;
574
+ checkboxSelectionUnselectAllRows: string;
575
+ checkboxSelectionSelectRow: string;
576
+ checkboxSelectionUnselectRow: string;
577
+ booleanCellTrueLabel: string;
578
+ booleanCellFalseLabel: string;
579
+ detailPanelToggle: string;
580
+ expandDetailPanel: string;
581
+ collapseDetailPanel: string;
582
+ groupingColumnHeaderName: string;
583
+ groupColumn: (name: string) => string;
584
+ unGroupColumn: (name: string) => string;
585
+ actionsCellMore: string;
586
+ columnHeaderSortIconLabel: string;
587
+ columnMenuLabel: string;
588
+ clearSearch: string;
589
+ }
590
+ export type MGHGridRowEventHandler<R extends MGHGridValidRowModel = any> = (params: MGHGridRowParams<R>, event: React.MouseEvent<HTMLElement>, details: MGHGridCallbackDetails) => void;
591
+ export type MGHGridCellEventHandler<R extends MGHGridValidRowModel = any> = (params: MGHGridCellParams<R>, event: React.MouseEvent<HTMLElement>, details: MGHGridCallbackDetails) => void;
592
+ export interface MGHGridProps<R extends MGHGridValidRowModel = any> {
593
+ rows: R[];
594
+ columns: MGHGridColDef<R>[];
595
+ getRowId?: (row: R) => MGHGridRowId;
596
+ loading?: boolean;
597
+ header?: React.ReactNode;
598
+ renderHeaderEndContent?: React.ReactNode;
599
+ renderHeaderCenterContent?: React.ReactNode;
600
+ /** Render the grid without the surrounding card & header. */
601
+ disableCard?: boolean;
602
+ className?: string;
603
+ cardClassName?: string;
604
+ boxClassName?: string;
605
+ /** Inline style for the outer card. (`cardSx` is accepted as an alias for legacy code.) */
606
+ cardStyle?: React.CSSProperties;
607
+ cardSx?: React.CSSProperties;
608
+ /** Inline style for the box wrapping the grid. (`boxSx` is accepted as an alias for legacy code.) */
609
+ boxStyle?: React.CSSProperties;
610
+ boxSx?: React.CSSProperties;
611
+ /** Inline style for the grid root. (`sx` is accepted as an alias for legacy code.) */
612
+ style?: React.CSSProperties;
613
+ sx?: React.CSSProperties;
614
+ /** 'light' (default) or 'dark'. */
615
+ themeMode?: MGHGridThemeMode;
616
+ /** Override any `--mgh-grid-*` CSS variable. */
617
+ themeVars?: Record<string, string>;
618
+ showToolbar?: boolean;
619
+ toolbarProps?: MGHGridToolbarProps & Record<string, any>;
620
+ slots?: MGHGridSlots;
621
+ slotProps?: MGHGridSlotProps;
622
+ noRowsText?: string;
623
+ localeText?: Partial<MGHGridLocaleText>;
624
+ rowHeight?: number;
625
+ columnHeaderHeight?: number;
626
+ getRowHeight?: (params: MGHGridRowHeightParams<R>) => MGHGridRowHeightReturnValue;
627
+ autoHeight?: boolean;
628
+ disableVirtualization?: boolean;
629
+ density?: MGHGridDensity;
630
+ onDensityChange?: (density: MGHGridDensity, details: MGHGridCallbackDetails) => void;
631
+ disableDensitySelector?: boolean;
632
+ pagination?: boolean;
633
+ pageSize?: number;
634
+ pageSizeOptions?: number[];
635
+ paginationModel?: MGHGridPaginationModel;
636
+ onPaginationModelChange?: (model: MGHGridPaginationModel, details: MGHGridCallbackDetails) => void;
637
+ hideFooter?: boolean;
638
+ hideFooterPagination?: boolean;
639
+ hideFooterRowCount?: boolean;
640
+ hideFooterSelectedRowCount?: boolean;
641
+ sortModel?: MGHGridSortModel;
642
+ onSortModelChange?: (model: MGHGridSortModel, details: MGHGridCallbackDetails) => void;
643
+ sortingOrder?: MGHGridSortDirection[];
644
+ disableMultipleColumnsSorting?: boolean;
645
+ disableColumnSorting?: boolean;
646
+ filterModel?: MGHGridFilterModel;
647
+ onFilterModelChange?: (model: MGHGridFilterModel, details: MGHGridCallbackDetails) => void;
648
+ disableColumnFilter?: boolean;
649
+ disableMultipleColumnsFiltering?: boolean;
650
+ /** Debounce (ms) applied to the quick filter. Default 150. */
651
+ quickFilterDebounceMs?: number;
652
+ columnVisibilityModel?: MGHGridColumnVisibilityModel;
653
+ onColumnVisibilityModelChange?: (model: MGHGridColumnVisibilityModel, details: MGHGridCallbackDetails) => void;
654
+ columnVisibilityStorageKey?: string;
655
+ columnOrderStorageKey?: string;
656
+ columnWidthStorageKey?: string;
657
+ pinnedColumnsStorageKey?: string;
658
+ onColumnOrderChange?: (params: MGHGridColumnOrderChangeParams, event: React.DragEvent | null, details: MGHGridCallbackDetails) => void;
659
+ onColumnWidthChange?: (params: MGHGridColumnResizeParams, details: MGHGridCallbackDetails) => void;
660
+ disableColumnMenu?: boolean;
661
+ disableColumnSelector?: boolean;
662
+ disableColumnResize?: boolean;
663
+ disableColumnReorder?: boolean;
664
+ disableColumnPinning?: boolean;
665
+ pinnedColumns?: MGHGridPinnedColumns;
666
+ onPinnedColumnsChange?: (model: MGHGridPinnedColumns, details: MGHGridCallbackDetails) => void;
667
+ checkboxSelection?: boolean;
668
+ checkboxSelectionVisibleOnly?: boolean;
669
+ disableRowSelectionOnClick?: boolean;
670
+ disableMultipleRowSelection?: boolean;
671
+ rowSelectionModel?: MGHGridRowSelectionModelInput;
672
+ onRowSelectionModelChange?: (model: MGHGridRowSelectionModel, details: MGHGridCallbackDetails) => void;
673
+ isRowSelectable?: (params: MGHGridRowParams<R>) => boolean;
674
+ keepNonExistentRowsSelected?: boolean;
675
+ getRowClassName?: (params: MGHGridRowClassNameParams<R>) => string;
676
+ onRowClick?: MGHGridRowEventHandler<R>;
677
+ onRowDoubleClick?: MGHGridRowEventHandler<R>;
678
+ onCellClick?: MGHGridCellEventHandler<R>;
679
+ onCellDoubleClick?: MGHGridCellEventHandler<R>;
680
+ pinnedRows?: MGHGridPinnedRows<R>;
681
+ getDetailPanelContent?: (params: MGHGridRowParams<R>) => React.ReactNode;
682
+ getDetailPanelHeight?: (params: MGHGridDetailPanelHeightParams<R>) => number | 'auto';
683
+ detailPanelExpandedRowIds?: MGHGridRowId[] | Set<MGHGridRowId>;
684
+ onDetailPanelExpandedRowIdsChange?: (ids: MGHGridRowId[], details: MGHGridCallbackDetails) => void;
685
+ rowGroupingModel?: MGHGridRowGroupingModel;
686
+ onRowGroupingModelChange?: (model: MGHGridRowGroupingModel, details: MGHGridCallbackDetails) => void;
687
+ defaultGroupingExpansionDepth?: number;
688
+ groupingColDef?: MGHGridGroupingColDefOverrides;
689
+ disableRowGrouping?: boolean;
690
+ isGroupExpandedByDefault?: (node: MGHGridGroupNode) => boolean;
691
+ aggregationModel?: MGHGridAggregationModel;
692
+ onAggregationModelChange?: (model: MGHGridAggregationModel, details: MGHGridCallbackDetails) => void;
693
+ aggregationFunctions?: Record<string, MGHGridAggregationFunction>;
694
+ disableAggregation?: boolean;
695
+ /** Where to show aggregated values: in the footer, on group rows, or both (default 'both'). */
696
+ aggregationPosition?: 'footer' | 'inline' | 'both';
697
+ processRowUpdate?: (newRow: R, oldRow: R, params: {
698
+ rowId: MGHGridRowId;
699
+ }) => R | Promise<R>;
700
+ onProcessRowUpdateError?: (error: any) => void;
701
+ onCellEditStop?: (params: MGHGridRowEditStopParams<R>, details: MGHGridCallbackDetails) => void;
702
+ isCellEditable?: (params: MGHGridCellParams<R>) => boolean;
703
+ initialState?: MGHGridInitialState;
704
+ apiRef?: React.MutableRefObject<MGHGridApi<R> | null>;
705
+ onStateChange?: (state: MGHGridState, details: MGHGridCallbackDetails) => void;
706
+ /** Any legacy / unknown props are accepted and ignored so migration is painless. */
707
+ [legacyProp: string]: any;
708
+ }