@mui/x-data-grid 7.0.0-alpha.4 → 7.0.0-alpha.6
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 +342 -0
- package/DataGrid/DataGrid.js +25 -19
- package/DataGrid/useDataGridProps.js +0 -1
- package/colDef/gridDateOperators.js +13 -6
- package/colDef/gridSingleSelectColDef.js +6 -15
- package/components/cell/GridEditSingleSelectCell.d.ts +1 -2
- package/components/cell/GridEditSingleSelectCell.js +9 -29
- package/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +25 -8
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -48
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -2
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -57
- package/components/panel/filterPanel/filterPanelUtils.d.ts +3 -2
- package/components/panel/filterPanel/filterPanelUtils.js +10 -5
- package/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/hooks/features/rowSelection/utils.d.ts +2 -0
- package/hooks/features/rowSelection/utils.js +8 -0
- package/hooks/utils/useGridAriaAttributes.js +2 -1
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +25 -19
- package/legacy/DataGrid/useDataGridProps.js +0 -1
- package/legacy/colDef/gridDateOperators.js +13 -13
- package/legacy/colDef/gridSingleSelectColDef.js +6 -15
- package/legacy/components/cell/GridEditSingleSelectCell.js +8 -28
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/legacy/components/panel/filterPanel/GridFilterForm.js +51 -19
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +27 -8
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -53
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -59
- package/legacy/components/panel/filterPanel/filterPanelUtils.js +10 -6
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/legacy/hooks/features/rowSelection/utils.js +8 -0
- package/legacy/hooks/utils/useGridAriaAttributes.js +2 -1
- package/legacy/index.js +1 -1
- package/legacy/locales/svSE.js +31 -33
- package/legacy/locales/urPK.js +26 -28
- package/locales/svSE.js +31 -33
- package/locales/urPK.js +26 -28
- package/models/controlStateItem.d.ts +1 -4
- package/models/props/DataGridProps.d.ts +26 -25
- package/modern/DataGrid/DataGrid.js +25 -19
- package/modern/DataGrid/useDataGridProps.js +0 -1
- package/modern/colDef/gridDateOperators.js +13 -6
- package/modern/colDef/gridSingleSelectColDef.js +6 -15
- package/modern/components/cell/GridEditSingleSelectCell.js +9 -29
- package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/modern/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +24 -6
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -47
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -56
- package/modern/components/panel/filterPanel/filterPanelUtils.js +10 -5
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/modern/hooks/features/rowSelection/utils.js +8 -0
- package/modern/hooks/utils/useGridAriaAttributes.js +2 -1
- package/modern/index.js +1 -1
- package/modern/locales/svSE.js +31 -33
- package/modern/locales/urPK.js +26 -28
- package/node/DataGrid/DataGrid.js +25 -19
- package/node/DataGrid/useDataGridProps.js +0 -1
- package/node/colDef/gridDateOperators.js +13 -6
- package/node/colDef/gridSingleSelectColDef.js +5 -14
- package/node/components/cell/GridEditSingleSelectCell.js +8 -28
- package/node/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/node/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputDate.js +24 -6
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -46
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -55
- package/node/components/panel/filterPanel/filterPanelUtils.js +12 -7
- package/node/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/node/hooks/features/rowSelection/utils.js +14 -0
- package/node/hooks/utils/useGridAriaAttributes.js +2 -1
- package/node/index.js +1 -1
- package/node/locales/svSE.js +31 -33
- package/node/locales/urPK.js +26 -28
- package/package.json +3 -3
- package/utils/createSelector.d.ts +1 -1
|
@@ -5,10 +5,7 @@ import { GridStateCommunity } from './gridStateCommunity';
|
|
|
5
5
|
export interface GridControlStateItem<State extends GridStateCommunity, E extends keyof GridControlledStateEventLookup> {
|
|
6
6
|
stateId: string;
|
|
7
7
|
propModel?: GridEventLookup[E]['params'];
|
|
8
|
-
stateSelector: OutputSelector<
|
|
9
|
-
state: State;
|
|
10
|
-
instanceId: string;
|
|
11
|
-
}, GridControlledStateEventLookup[E]['params']> | ((state: State) => GridControlledStateEventLookup[E]['params']);
|
|
8
|
+
stateSelector: OutputSelector<State, GridControlledStateEventLookup[E]['params']> | ((state: State) => GridControlledStateEventLookup[E]['params']);
|
|
12
9
|
propOnChange?: (model: GridControlledStateEventLookup[E]['params'], details: GridCallbackDetails) => void;
|
|
13
10
|
changeEvent: E;
|
|
14
11
|
}
|
|
@@ -56,7 +56,7 @@ export interface DataGridProcessedProps<R extends GridValidRowModel = any> exten
|
|
|
56
56
|
* The props of the `DataGrid` component after the pre-processing phase that the user should not be able to override.
|
|
57
57
|
* Those are usually used in feature-hook for which the pro-plan has more advanced features (eg: multi-sorting, multi-filtering, ...).
|
|
58
58
|
*/
|
|
59
|
-
export type DataGridForcedPropsKey = 'checkboxSelectionVisibleOnly' | 'disableMultipleColumnsFiltering' | 'disableMultipleColumnsSorting' | '
|
|
59
|
+
export type DataGridForcedPropsKey = 'checkboxSelectionVisibleOnly' | 'disableMultipleColumnsFiltering' | 'disableMultipleColumnsSorting' | 'disableColumnReorder' | 'disableColumnResize' | 'keepColumnPositionIfDraggedOutside' | 'throttleRowsMs' | 'hideFooterRowCount' | 'pagination' | 'signature';
|
|
60
60
|
/**
|
|
61
61
|
* The `DataGrid` options with a default value that must be merged with the value given through props.
|
|
62
62
|
*/
|
|
@@ -73,7 +73,7 @@ export interface DataGridPropsWithComplexDefaultValueBeforeProcessing {
|
|
|
73
73
|
*/
|
|
74
74
|
slots?: Partial<GridSlotsComponent>;
|
|
75
75
|
/**
|
|
76
|
-
* Set the locale text of the
|
|
76
|
+
* Set the locale text of the Data Grid.
|
|
77
77
|
* You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
|
|
78
78
|
*/
|
|
79
79
|
localeText?: Partial<GridLocaleText>;
|
|
@@ -86,7 +86,7 @@ export interface DataGridPropsWithComplexDefaultValueBeforeProcessing {
|
|
|
86
86
|
*/
|
|
87
87
|
export interface DataGridPropsWithDefaultValues {
|
|
88
88
|
/**
|
|
89
|
-
* If `true`, the
|
|
89
|
+
* If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
|
|
90
90
|
* @default false
|
|
91
91
|
*/
|
|
92
92
|
autoHeight: boolean;
|
|
@@ -96,7 +96,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
96
96
|
*/
|
|
97
97
|
autoPageSize: boolean;
|
|
98
98
|
/**
|
|
99
|
-
* If `true`, the
|
|
99
|
+
* If `true`, the Data Grid will display an extra column with checkboxes for selecting rows.
|
|
100
100
|
* @default false
|
|
101
101
|
*/
|
|
102
102
|
checkboxSelection: boolean;
|
|
@@ -132,7 +132,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
132
132
|
*/
|
|
133
133
|
columnThreshold: number;
|
|
134
134
|
/**
|
|
135
|
-
* Set the density of the
|
|
135
|
+
* Set the density of the Data Grid.
|
|
136
136
|
* @default "standard"
|
|
137
137
|
*/
|
|
138
138
|
density: GridDensity;
|
|
@@ -168,8 +168,9 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
168
168
|
*/
|
|
169
169
|
disableMultipleColumnsFiltering: boolean;
|
|
170
170
|
/**
|
|
171
|
-
* If `true`, multiple selection using the Ctrl or
|
|
172
|
-
*
|
|
171
|
+
* If `true`, multiple selection using the Ctrl/CMD or Shift key is disabled.
|
|
172
|
+
* The MIT DataGrid will ignore this prop, unless `checkboxSelection` is enabled.
|
|
173
|
+
* @default false (`!props.checkboxSelection` for MIT Data Grid)
|
|
173
174
|
*/
|
|
174
175
|
disableMultipleRowSelection: boolean;
|
|
175
176
|
/**
|
|
@@ -204,7 +205,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
204
205
|
*/
|
|
205
206
|
filterDebounceMs: number;
|
|
206
207
|
/**
|
|
207
|
-
* Sets the height in pixel of the column headers in the
|
|
208
|
+
* Sets the height in pixel of the column headers in the Data Grid.
|
|
208
209
|
* @default 56
|
|
209
210
|
*/
|
|
210
211
|
columnHeaderHeight: number;
|
|
@@ -265,7 +266,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
265
266
|
*/
|
|
266
267
|
paginationMode: GridFeatureMode;
|
|
267
268
|
/**
|
|
268
|
-
* Sets the height in pixel of a row in the
|
|
269
|
+
* Sets the height in pixel of a row in the Data Grid.
|
|
269
270
|
* @default 52
|
|
270
271
|
*/
|
|
271
272
|
rowHeight: number;
|
|
@@ -305,7 +306,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
305
306
|
*/
|
|
306
307
|
sortingMode: GridFeatureMode;
|
|
307
308
|
/**
|
|
308
|
-
* If positive, the Grid will throttle updates coming from `apiRef.current.updateRows` and `apiRef.current.setRows`.
|
|
309
|
+
* If positive, the Data Grid will throttle updates coming from `apiRef.current.updateRows` and `apiRef.current.setRows`.
|
|
309
310
|
* It can be useful if you have a high update rate but do not want to do heavy work like filtering / sorting or rendering on each individual update.
|
|
310
311
|
* @default 0
|
|
311
312
|
*/
|
|
@@ -321,13 +322,13 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
321
322
|
*/
|
|
322
323
|
disableColumnResize: boolean;
|
|
323
324
|
/**
|
|
324
|
-
* If `true`, moving the mouse pointer outside the
|
|
325
|
+
* If `true`, moving the mouse pointer outside the Data Grid before releasing the mouse button
|
|
325
326
|
* in a column re-order action will not cause the column to jump back to its original position.
|
|
326
327
|
* @default false
|
|
327
328
|
*/
|
|
328
329
|
keepColumnPositionIfDraggedOutside: boolean;
|
|
329
330
|
/**
|
|
330
|
-
* If `true`, the
|
|
331
|
+
* If `true`, the Data Grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
331
332
|
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
332
333
|
* @default false
|
|
333
334
|
*/
|
|
@@ -353,17 +354,17 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
353
354
|
*/
|
|
354
355
|
export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends CommonProps {
|
|
355
356
|
/**
|
|
356
|
-
* The ref object that allows
|
|
357
|
+
* The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
|
|
357
358
|
*/
|
|
358
359
|
apiRef?: React.MutableRefObject<GridApiCommunity>;
|
|
359
360
|
/**
|
|
360
|
-
* Forwarded props for the
|
|
361
|
+
* Forwarded props for the Data Grid root element.
|
|
361
362
|
* @ignore - do not document.
|
|
362
363
|
*/
|
|
363
364
|
forwardedProps?: Record<string, unknown>;
|
|
364
365
|
/**
|
|
365
366
|
* Signal to the underlying logic what version of the public component API
|
|
366
|
-
* of the
|
|
367
|
+
* of the Data Grid is exposed [[GridSignature]].
|
|
367
368
|
* @ignore - do not document.
|
|
368
369
|
*/
|
|
369
370
|
signature?: string;
|
|
@@ -377,7 +378,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
377
378
|
*/
|
|
378
379
|
rowCount?: number;
|
|
379
380
|
/**
|
|
380
|
-
* Override the height/width of the
|
|
381
|
+
* Override the height/width of the Data Grid inner scrollbar.
|
|
381
382
|
*/
|
|
382
383
|
scrollbarSize?: number;
|
|
383
384
|
/**
|
|
@@ -546,14 +547,14 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
546
547
|
*/
|
|
547
548
|
onRowDoubleClick?: GridEventListener<'rowDoubleClick'>;
|
|
548
549
|
/**
|
|
549
|
-
* Callback fired when the
|
|
550
|
+
* Callback fired when the Data Grid is resized.
|
|
550
551
|
* @param {ElementSize} containerSize With all properties from [[ElementSize]].
|
|
551
552
|
* @param {MuiEvent<{}>} event The event object.
|
|
552
553
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
553
554
|
*/
|
|
554
555
|
onResize?: GridEventListener<'debouncedResize'>;
|
|
555
556
|
/**
|
|
556
|
-
* Callback fired when the state of the
|
|
557
|
+
* Callback fired when the state of the Data Grid is updated.
|
|
557
558
|
* @param {GridState} state The new state.
|
|
558
559
|
* @param {MuiEvent<{}>} event The event object.
|
|
559
560
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -619,7 +620,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
619
620
|
*/
|
|
620
621
|
onRowModesModelChange?: (rowModesModel: GridRowModesModel, details: GridCallbackDetails) => void;
|
|
621
622
|
/**
|
|
622
|
-
* Set the filter model of the
|
|
623
|
+
* Set the filter model of the Data Grid.
|
|
623
624
|
*/
|
|
624
625
|
filterModel?: GridFilterModel;
|
|
625
626
|
/**
|
|
@@ -629,7 +630,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
629
630
|
*/
|
|
630
631
|
onFilterModelChange?: (model: GridFilterModel, details: GridCallbackDetails<'filter'>) => void;
|
|
631
632
|
/**
|
|
632
|
-
* Sets the row selection model of the
|
|
633
|
+
* Sets the row selection model of the Data Grid.
|
|
633
634
|
*/
|
|
634
635
|
rowSelectionModel?: GridInputRowSelectionModel;
|
|
635
636
|
/**
|
|
@@ -639,8 +640,8 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
639
640
|
*/
|
|
640
641
|
onRowSelectionModelChange?: (rowSelectionModel: GridRowSelectionModel, details: GridCallbackDetails) => void;
|
|
641
642
|
/**
|
|
642
|
-
* Set the column visibility model of the
|
|
643
|
-
* If defined, the
|
|
643
|
+
* Set the column visibility model of the Data Grid.
|
|
644
|
+
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
644
645
|
*/
|
|
645
646
|
columnVisibilityModel?: GridColumnVisibilityModel;
|
|
646
647
|
/**
|
|
@@ -650,7 +651,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
650
651
|
*/
|
|
651
652
|
onColumnVisibilityModelChange?: (model: GridColumnVisibilityModel, details: GridCallbackDetails) => void;
|
|
652
653
|
/**
|
|
653
|
-
* Set the sort model of the
|
|
654
|
+
* Set the sort model of the Data Grid.
|
|
654
655
|
*/
|
|
655
656
|
sortModel?: GridSortModel;
|
|
656
657
|
/**
|
|
@@ -660,11 +661,11 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
660
661
|
*/
|
|
661
662
|
onSortModelChange?: (model: GridSortModel, details: GridCallbackDetails) => void;
|
|
662
663
|
/**
|
|
663
|
-
* The label of the
|
|
664
|
+
* The label of the Data Grid.
|
|
664
665
|
*/
|
|
665
666
|
'aria-label'?: string;
|
|
666
667
|
/**
|
|
667
|
-
* The id of the element containing a label for the
|
|
668
|
+
* The id of the element containing a label for the Data Grid.
|
|
668
669
|
*/
|
|
669
670
|
'aria-labelledby'?: string;
|
|
670
671
|
/**
|
|
@@ -41,21 +41,21 @@ DataGridRaw.propTypes = {
|
|
|
41
41
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
42
42
|
// ----------------------------------------------------------------------
|
|
43
43
|
/**
|
|
44
|
-
* The ref object that allows
|
|
44
|
+
* The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
|
|
45
45
|
*/
|
|
46
46
|
apiRef: PropTypes.shape({
|
|
47
47
|
current: PropTypes.object.isRequired
|
|
48
48
|
}),
|
|
49
49
|
/**
|
|
50
|
-
* The label of the
|
|
50
|
+
* The label of the Data Grid.
|
|
51
51
|
*/
|
|
52
52
|
'aria-label': PropTypes.string,
|
|
53
53
|
/**
|
|
54
|
-
* The id of the element containing a label for the
|
|
54
|
+
* The id of the element containing a label for the Data Grid.
|
|
55
55
|
*/
|
|
56
56
|
'aria-labelledby': PropTypes.string,
|
|
57
57
|
/**
|
|
58
|
-
* If `true`, the
|
|
58
|
+
* If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
61
|
autoHeight: PropTypes.bool,
|
|
@@ -69,7 +69,7 @@ DataGridRaw.propTypes = {
|
|
|
69
69
|
*/
|
|
70
70
|
cellModesModel: PropTypes.object,
|
|
71
71
|
/**
|
|
72
|
-
* If `true`, the
|
|
72
|
+
* If `true`, the Data Grid will display an extra column with checkboxes for selecting rows.
|
|
73
73
|
* @default false
|
|
74
74
|
*/
|
|
75
75
|
checkboxSelection: PropTypes.bool,
|
|
@@ -89,7 +89,7 @@ DataGridRaw.propTypes = {
|
|
|
89
89
|
columnBuffer: PropTypes.number,
|
|
90
90
|
columnGroupingModel: PropTypes.arrayOf(PropTypes.object),
|
|
91
91
|
/**
|
|
92
|
-
* Sets the height in pixel of the column headers in the
|
|
92
|
+
* Sets the height in pixel of the column headers in the Data Grid.
|
|
93
93
|
* @default 56
|
|
94
94
|
*/
|
|
95
95
|
columnHeaderHeight: PropTypes.number,
|
|
@@ -109,12 +109,12 @@ DataGridRaw.propTypes = {
|
|
|
109
109
|
*/
|
|
110
110
|
columnThreshold: PropTypes.number,
|
|
111
111
|
/**
|
|
112
|
-
* Set the column visibility model of the
|
|
113
|
-
* If defined, the
|
|
112
|
+
* Set the column visibility model of the Data Grid.
|
|
113
|
+
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
114
114
|
*/
|
|
115
115
|
columnVisibilityModel: PropTypes.object,
|
|
116
116
|
/**
|
|
117
|
-
* Set the density of the
|
|
117
|
+
* Set the density of the Data Grid.
|
|
118
118
|
* @default "standard"
|
|
119
119
|
*/
|
|
120
120
|
density: PropTypes.oneOf(['comfortable', 'compact', 'standard']),
|
|
@@ -144,6 +144,12 @@ DataGridRaw.propTypes = {
|
|
|
144
144
|
* @ignore - do not document
|
|
145
145
|
*/
|
|
146
146
|
disableEval: PropTypes.bool,
|
|
147
|
+
/**
|
|
148
|
+
* If `true`, multiple selection using the Ctrl/CMD or Shift key is disabled.
|
|
149
|
+
* The MIT DataGrid will ignore this prop, unless `checkboxSelection` is enabled.
|
|
150
|
+
* @default false (`!props.checkboxSelection` for MIT Data Grid)
|
|
151
|
+
*/
|
|
152
|
+
disableMultipleRowSelection: PropTypes.bool,
|
|
147
153
|
/**
|
|
148
154
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
149
155
|
* @default false
|
|
@@ -180,7 +186,7 @@ DataGridRaw.propTypes = {
|
|
|
180
186
|
*/
|
|
181
187
|
filterMode: PropTypes.oneOf(['client', 'server']),
|
|
182
188
|
/**
|
|
183
|
-
* Set the filter model of the
|
|
189
|
+
* Set the filter model of the Data Grid.
|
|
184
190
|
*/
|
|
185
191
|
filterModel: PropTypes.shape({
|
|
186
192
|
items: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -195,7 +201,7 @@ DataGridRaw.propTypes = {
|
|
|
195
201
|
quickFilterValues: PropTypes.array
|
|
196
202
|
}),
|
|
197
203
|
/**
|
|
198
|
-
* Forwarded props for the
|
|
204
|
+
* Forwarded props for the Data Grid root element.
|
|
199
205
|
* @ignore - do not document.
|
|
200
206
|
*/
|
|
201
207
|
forwardedProps: PropTypes.object,
|
|
@@ -263,7 +269,7 @@ DataGridRaw.propTypes = {
|
|
|
263
269
|
*/
|
|
264
270
|
ignoreDiacritics: PropTypes.bool,
|
|
265
271
|
/**
|
|
266
|
-
* If `true`, the
|
|
272
|
+
* If `true`, the Data Grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
267
273
|
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
268
274
|
* @default false
|
|
269
275
|
*/
|
|
@@ -301,7 +307,7 @@ DataGridRaw.propTypes = {
|
|
|
301
307
|
*/
|
|
302
308
|
loading: PropTypes.bool,
|
|
303
309
|
/**
|
|
304
|
-
* Set the locale text of the
|
|
310
|
+
* Set the locale text of the Data Grid.
|
|
305
311
|
* You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
|
|
306
312
|
*/
|
|
307
313
|
localeText: PropTypes.object,
|
|
@@ -469,7 +475,7 @@ DataGridRaw.propTypes = {
|
|
|
469
475
|
*/
|
|
470
476
|
onProcessRowUpdateError: PropTypes.func,
|
|
471
477
|
/**
|
|
472
|
-
* Callback fired when the
|
|
478
|
+
* Callback fired when the Data Grid is resized.
|
|
473
479
|
* @param {ElementSize} containerSize With all properties from [[ElementSize]].
|
|
474
480
|
* @param {MuiEvent<{}>} event The event object.
|
|
475
481
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -527,7 +533,7 @@ DataGridRaw.propTypes = {
|
|
|
527
533
|
*/
|
|
528
534
|
onSortModelChange: PropTypes.func,
|
|
529
535
|
/**
|
|
530
|
-
* Callback fired when the state of the
|
|
536
|
+
* Callback fired when the state of the Data Grid is updated.
|
|
531
537
|
* @param {GridState} state The new state.
|
|
532
538
|
* @param {MuiEvent<{}>} event The event object.
|
|
533
539
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -581,7 +587,7 @@ DataGridRaw.propTypes = {
|
|
|
581
587
|
*/
|
|
582
588
|
rowCount: PropTypes.number,
|
|
583
589
|
/**
|
|
584
|
-
* Sets the height in pixel of a row in the
|
|
590
|
+
* Sets the height in pixel of a row in the Data Grid.
|
|
585
591
|
* @default 52
|
|
586
592
|
*/
|
|
587
593
|
rowHeight: PropTypes.number,
|
|
@@ -606,7 +612,7 @@ DataGridRaw.propTypes = {
|
|
|
606
612
|
*/
|
|
607
613
|
rowSelection: PropTypes.bool,
|
|
608
614
|
/**
|
|
609
|
-
* Sets the row selection model of the
|
|
615
|
+
* Sets the row selection model of the Data Grid.
|
|
610
616
|
*/
|
|
611
617
|
rowSelectionModel: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired), PropTypes.number, PropTypes.string]),
|
|
612
618
|
/**
|
|
@@ -620,7 +626,7 @@ DataGridRaw.propTypes = {
|
|
|
620
626
|
*/
|
|
621
627
|
rowThreshold: PropTypes.number,
|
|
622
628
|
/**
|
|
623
|
-
* Override the height/width of the
|
|
629
|
+
* Override the height/width of the Data Grid inner scrollbar.
|
|
624
630
|
*/
|
|
625
631
|
scrollbarSize: PropTypes.number,
|
|
626
632
|
/**
|
|
@@ -654,7 +660,7 @@ DataGridRaw.propTypes = {
|
|
|
654
660
|
*/
|
|
655
661
|
sortingOrder: PropTypes.arrayOf(PropTypes.oneOf(['asc', 'desc'])),
|
|
656
662
|
/**
|
|
657
|
-
* Set the sort model of the
|
|
663
|
+
* Set the sort model of the Data Grid.
|
|
658
664
|
*/
|
|
659
665
|
sortModel: PropTypes.arrayOf(PropTypes.shape({
|
|
660
666
|
field: PropTypes.string.isRequired,
|
|
@@ -8,7 +8,6 @@ import { computeSlots, useProps } from '../internals/utils';
|
|
|
8
8
|
const DATA_GRID_FORCED_PROPS = {
|
|
9
9
|
disableMultipleColumnsFiltering: true,
|
|
10
10
|
disableMultipleColumnsSorting: true,
|
|
11
|
-
disableMultipleRowSelection: true,
|
|
12
11
|
throttleRowsMs: undefined,
|
|
13
12
|
hideFooterRowCount: false,
|
|
14
13
|
pagination: true,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { GridFilterInputDate } from '../components/panel/filterPanel/GridFilterInputDate';
|
|
2
|
-
const dateRegex = /(\d+)-(\d+)-(\d+)/;
|
|
3
|
-
const dateTimeRegex = /(\d+)-(\d+)-(\d+)T(\d+):(\d+)/;
|
|
4
2
|
function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
5
3
|
if (!filterItem.value) {
|
|
6
4
|
return null;
|
|
7
5
|
}
|
|
8
|
-
const
|
|
9
|
-
|
|
6
|
+
const date = new Date(filterItem.value);
|
|
7
|
+
if (showTime) {
|
|
8
|
+
date.setSeconds(0, 0);
|
|
9
|
+
} else {
|
|
10
|
+
date.setHours(0, 0, 0, 0);
|
|
11
|
+
}
|
|
12
|
+
const time = date.getTime();
|
|
10
13
|
return value => {
|
|
11
14
|
if (!value) {
|
|
12
15
|
return false;
|
|
@@ -17,8 +20,12 @@ function buildApplyFilterFn(filterItem, compareFn, showTime, keepHours) {
|
|
|
17
20
|
|
|
18
21
|
// Make a copy of the date to not reset the hours in the original object
|
|
19
22
|
const dateCopy = new Date(value);
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
if (showTime) {
|
|
24
|
+
dateCopy.setSeconds(0, 0);
|
|
25
|
+
} else {
|
|
26
|
+
dateCopy.setHours(0, 0, 0, 0);
|
|
27
|
+
}
|
|
28
|
+
return compareFn(dateCopy.getTime(), time);
|
|
22
29
|
};
|
|
23
30
|
}
|
|
24
31
|
export const getGridDateOperators = showTime => [{
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { GRID_STRING_COL_DEF } from './gridStringColDef';
|
|
3
3
|
import { renderEditSingleSelectCell } from '../components/cell/GridEditSingleSelectCell';
|
|
4
4
|
import { getGridSingleSelectOperators } from './gridSingleSelectOperators';
|
|
5
|
-
import { isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
|
|
5
|
+
import { getValueOptions, isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
|
|
6
6
|
import { isObject } from '../utils/utils';
|
|
7
7
|
const isArrayOfObjects = options => {
|
|
8
8
|
return typeof options[0] === 'object';
|
|
@@ -28,16 +28,10 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
28
28
|
if (!isSingleSelectColDef(colDef)) {
|
|
29
29
|
return '';
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
row: id ? api.getRow(id) : null,
|
|
36
|
-
field
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
valueOptions = colDef.valueOptions;
|
|
40
|
-
}
|
|
31
|
+
const valueOptions = getValueOptions(colDef, {
|
|
32
|
+
id,
|
|
33
|
+
row: id ? api.getRow(id) : null
|
|
34
|
+
});
|
|
41
35
|
if (value == null) {
|
|
42
36
|
return '';
|
|
43
37
|
}
|
|
@@ -55,10 +49,7 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
55
49
|
// @ts-ignore
|
|
56
50
|
pastedValueParser: (value, params) => {
|
|
57
51
|
const colDef = params.colDef;
|
|
58
|
-
const
|
|
59
|
-
const valueOptions = typeof colDefValueOptions === 'function' ? colDefValueOptions({
|
|
60
|
-
field: colDef.field
|
|
61
|
-
}) : colDefValueOptions || [];
|
|
52
|
+
const valueOptions = getValueOptions(colDef) || [];
|
|
62
53
|
const getOptionValue = colDef.getOptionValue;
|
|
63
54
|
const valueOption = valueOptions.find(option => {
|
|
64
55
|
if (getOptionValue(option) === value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"
|
|
3
|
+
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"],
|
|
4
4
|
_excluded2 = ["MenuProps"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -9,7 +9,7 @@ import { GridCellEditStopReasons } from '../../models/params/gridEditCellParams'
|
|
|
9
9
|
import { isEscapeKey } from '../../utils/keyboardUtils';
|
|
10
10
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
11
11
|
import { GridEditModes } from '../../models/gridEditRowModel';
|
|
12
|
-
import { getValueFromValueOptions, isSingleSelectColDef } from '../panel/filterPanel/filterPanelUtils';
|
|
12
|
+
import { getValueFromValueOptions, getValueOptions, isSingleSelectColDef } from '../panel/filterPanel/filterPanelUtils';
|
|
13
13
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
14
14
|
import { createElement as _createElement } from "react";
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -27,9 +27,7 @@ function GridEditSingleSelectCell(props) {
|
|
|
27
27
|
hasFocus,
|
|
28
28
|
error,
|
|
29
29
|
onValueChange,
|
|
30
|
-
initialOpen = rootProps.editMode === GridEditModes.Cell
|
|
31
|
-
getOptionLabel: getOptionLabelProp,
|
|
32
|
-
getOptionValue: getOptionValueProp
|
|
30
|
+
initialOpen = rootProps.editMode === GridEditModes.Cell
|
|
33
31
|
} = props,
|
|
34
32
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
35
33
|
const apiRef = useGridApiContext();
|
|
@@ -51,21 +49,15 @@ function GridEditSingleSelectCell(props) {
|
|
|
51
49
|
if (!isSingleSelectColDef(colDef)) {
|
|
52
50
|
return null;
|
|
53
51
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
row,
|
|
59
|
-
field
|
|
60
|
-
});
|
|
61
|
-
} else {
|
|
62
|
-
valueOptions = colDef?.valueOptions;
|
|
63
|
-
}
|
|
52
|
+
const valueOptions = getValueOptions(colDef, {
|
|
53
|
+
id,
|
|
54
|
+
row
|
|
55
|
+
});
|
|
64
56
|
if (!valueOptions) {
|
|
65
57
|
return null;
|
|
66
58
|
}
|
|
67
|
-
const getOptionValue =
|
|
68
|
-
const getOptionLabel =
|
|
59
|
+
const getOptionValue = colDef.getOptionValue;
|
|
60
|
+
const getOptionLabel = colDef.getOptionLabel;
|
|
69
61
|
const handleChange = async event => {
|
|
70
62
|
if (!isSingleSelectColDef(colDef) || !valueOptions) {
|
|
71
63
|
return;
|
|
@@ -154,18 +146,6 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
154
146
|
* The cell value formatted with the column valueFormatter.
|
|
155
147
|
*/
|
|
156
148
|
formattedValue: PropTypes.any,
|
|
157
|
-
/**
|
|
158
|
-
* Used to determine the label displayed for a given value option.
|
|
159
|
-
* @param {ValueOptions} value The current value option.
|
|
160
|
-
* @returns {string} The text to be displayed.
|
|
161
|
-
*/
|
|
162
|
-
getOptionLabel: PropTypes.func,
|
|
163
|
-
/**
|
|
164
|
-
* Used to determine the value used for a value option.
|
|
165
|
-
* @param {ValueOptions} value The current value option.
|
|
166
|
-
* @returns {string} The value to be used.
|
|
167
|
-
*/
|
|
168
|
-
getOptionValue: PropTypes.func,
|
|
169
149
|
/**
|
|
170
150
|
* If true, the cell is the active element.
|
|
171
151
|
*/
|
|
@@ -4,6 +4,7 @@ const _excluded = ["field", "colDef"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
7
|
+
import { isMultipleRowSelectionEnabled } from '../../hooks/features/rowSelection/utils';
|
|
7
8
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
8
9
|
import { gridTabIndexColumnHeaderSelector } from '../../hooks/features/focus/gridFocusStateSelector';
|
|
9
10
|
import { gridRowSelectionStateSelector } from '../../hooks/features/rowSelection/gridRowSelectionSelector';
|
|
@@ -102,7 +103,8 @@ const GridHeaderCheckbox = /*#__PURE__*/React.forwardRef(function GridHeaderChec
|
|
|
102
103
|
'aria-label': label
|
|
103
104
|
},
|
|
104
105
|
tabIndex: tabIndex,
|
|
105
|
-
onKeyDown: handleKeyDown
|
|
106
|
+
onKeyDown: handleKeyDown,
|
|
107
|
+
disabled: !isMultipleRowSelectionEnabled(rootProps)
|
|
106
108
|
}, rootProps.slotProps?.baseCheckbox, other));
|
|
107
109
|
});
|
|
108
110
|
process.env.NODE_ENV !== "production" ? GridHeaderCheckbox.propTypes = {
|
|
@@ -14,6 +14,7 @@ import { GridLogicOperator } from '../../../models/gridFilterItem';
|
|
|
14
14
|
import { useGridApiContext } from '../../../hooks/utils/useGridApiContext';
|
|
15
15
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
16
16
|
import { getDataGridUtilityClass } from '../../../constants/gridClasses';
|
|
17
|
+
import { getValueFromValueOptions, getValueOptions } from './filterPanelUtils';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
import { createElement as _createElement } from "react";
|
|
19
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -130,23 +131,39 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
130
131
|
const hasLogicOperatorColumn = hasMultipleFilters && logicOperators.length > 0;
|
|
131
132
|
const baseFormControlProps = rootProps.slotProps?.baseFormControl || {};
|
|
132
133
|
const baseSelectProps = rootProps.slotProps?.baseSelect || {};
|
|
133
|
-
const isBaseSelectNative = baseSelectProps.native ??
|
|
134
|
+
const isBaseSelectNative = baseSelectProps.native ?? false;
|
|
134
135
|
const baseInputLabelProps = rootProps.slotProps?.baseInputLabel || {};
|
|
135
136
|
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
136
137
|
const {
|
|
137
138
|
InputComponentProps
|
|
138
139
|
} = valueInputProps,
|
|
139
140
|
valueInputPropsOther = _objectWithoutPropertiesLoose(valueInputProps, _excluded2);
|
|
140
|
-
const
|
|
141
|
+
const {
|
|
142
|
+
filteredColumns,
|
|
143
|
+
selectedField
|
|
144
|
+
} = React.useMemo(() => {
|
|
145
|
+
let itemField = item.field;
|
|
141
146
|
if (filterColumns === undefined || typeof filterColumns !== 'function') {
|
|
142
|
-
return
|
|
147
|
+
return {
|
|
148
|
+
filteredColumns: filterableColumns,
|
|
149
|
+
selectedField: itemField
|
|
150
|
+
};
|
|
143
151
|
}
|
|
144
152
|
const filteredFields = filterColumns({
|
|
145
153
|
field: item.field,
|
|
146
154
|
columns: filterableColumns,
|
|
147
155
|
currentFilters: filterModel?.items || []
|
|
148
156
|
});
|
|
149
|
-
return
|
|
157
|
+
return {
|
|
158
|
+
filteredColumns: filterableColumns.filter(column => {
|
|
159
|
+
const isFieldIncluded = filteredFields.includes(column.field);
|
|
160
|
+
if (column.field === item.field && !isFieldIncluded) {
|
|
161
|
+
itemField = undefined;
|
|
162
|
+
}
|
|
163
|
+
return isFieldIncluded;
|
|
164
|
+
}),
|
|
165
|
+
selectedField: itemField
|
|
166
|
+
};
|
|
150
167
|
}, [filterColumns, filterModel?.items, filterableColumns, item.field]);
|
|
151
168
|
const sortedFilteredColumns = React.useMemo(() => {
|
|
152
169
|
switch (columnsSort) {
|
|
@@ -177,11 +194,29 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
177
194
|
const newOperator = column.filterOperators.find(operator => operator.value === item.operator) || column.filterOperators[0];
|
|
178
195
|
|
|
179
196
|
// Erase filter value if the input component or filtered column type is modified
|
|
180
|
-
const
|
|
197
|
+
const eraseFilterValue = !newOperator.InputComponent || newOperator.InputComponent !== currentOperator?.InputComponent || column.type !== currentColumn.type;
|
|
198
|
+
let filterValue = eraseFilterValue ? undefined : item.value;
|
|
199
|
+
|
|
200
|
+
// Check filter value against the new valueOptions
|
|
201
|
+
if (column.type === 'singleSelect' && filterValue !== undefined) {
|
|
202
|
+
const colDef = column;
|
|
203
|
+
const valueOptions = getValueOptions(colDef);
|
|
204
|
+
if (Array.isArray(filterValue)) {
|
|
205
|
+
filterValue = filterValue.filter(val => {
|
|
206
|
+
return (
|
|
207
|
+
// Only keep values that are in the new value options
|
|
208
|
+
getValueFromValueOptions(val, valueOptions, colDef?.getOptionValue) !== undefined
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
} else if (getValueFromValueOptions(item.value, valueOptions, colDef?.getOptionValue) === undefined) {
|
|
212
|
+
// Reset the filter value if it is not in the new value options
|
|
213
|
+
filterValue = undefined;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
181
216
|
applyFilterChanges(_extends({}, item, {
|
|
182
217
|
field,
|
|
183
218
|
operator: newOperator.value,
|
|
184
|
-
value:
|
|
219
|
+
value: filterValue
|
|
185
220
|
}));
|
|
186
221
|
}, [apiRef, applyFilterChanges, item, currentColumn, currentOperator]);
|
|
187
222
|
const changeOperator = React.useCallback(event => {
|
|
@@ -256,7 +291,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
256
291
|
inputProps: {
|
|
257
292
|
'aria-label': apiRef.current.getLocaleText('filterPanelLogicOperator')
|
|
258
293
|
},
|
|
259
|
-
value: multiFilterOperator,
|
|
294
|
+
value: multiFilterOperator ?? '',
|
|
260
295
|
onChange: changeLogicOperator,
|
|
261
296
|
disabled: !!disableMultiFilterOperator || logicOperators.length === 1,
|
|
262
297
|
native: isBaseSelectNative
|
|
@@ -281,7 +316,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
281
316
|
labelId: columnSelectLabelId,
|
|
282
317
|
id: columnSelectId,
|
|
283
318
|
label: apiRef.current.getLocaleText('filterPanelColumns'),
|
|
284
|
-
value:
|
|
319
|
+
value: selectedField ?? '',
|
|
285
320
|
onChange: changeColumn,
|
|
286
321
|
native: isBaseSelectNative
|
|
287
322
|
}, rootProps.slotProps?.baseSelect, {
|
|
@@ -327,7 +362,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
327
362
|
item: item,
|
|
328
363
|
applyValue: applyFilterChanges,
|
|
329
364
|
focusElementRef: valueRef
|
|
330
|
-
}, currentOperator.InputComponentProps, InputComponentProps)) : null
|
|
365
|
+
}, currentOperator.InputComponentProps, InputComponentProps), item.field) : null
|
|
331
366
|
}))]
|
|
332
367
|
}));
|
|
333
368
|
});
|
|
@@ -32,7 +32,7 @@ function GridFilterInputBoolean(props) {
|
|
|
32
32
|
const labelId = useId();
|
|
33
33
|
const selectId = useId();
|
|
34
34
|
const baseSelectProps = rootProps.slotProps?.baseSelect || {};
|
|
35
|
-
const isSelectNative = baseSelectProps.native ??
|
|
35
|
+
const isSelectNative = baseSelectProps.native ?? false;
|
|
36
36
|
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
37
37
|
const onFilterChange = React.useCallback(event => {
|
|
38
38
|
const value = event.target.value;
|