@mui/x-data-grid 5.14.0 → 5.15.2
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 +147 -5
- package/DataGrid/DataGrid.js +7 -1
- package/DataGrid/useDataGridProps.js +1 -0
- package/colDef/gridStringColDef.js +1 -1
- package/components/GridRow.js +5 -1
- package/components/base/GridOverlays.js +2 -2
- package/components/cell/GridEditInputCell.d.ts +2 -5
- package/components/cell/GridEditInputCell.js +13 -14
- package/components/cell/GridEditSingleSelectCell.d.ts +4 -0
- package/components/cell/GridEditSingleSelectCell.js +11 -4
- package/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
- package/components/containers/GridRoot.js +4 -2
- package/components/toolbar/GridToolbarDensitySelector.js +13 -4
- package/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/constants/envConstants.d.ts +1 -1
- package/constants/envConstants.js +2 -11
- package/constants/gridClasses.d.ts +16 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +26 -16
- package/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/hooks/features/editRows/useGridEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +16 -10
- package/hooks/features/export/utils.js +8 -1
- package/hooks/features/filter/gridFilterState.d.ts +12 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +8 -5
- package/hooks/features/filter/gridFilterUtils.js +74 -43
- package/hooks/features/filter/useGridFilter.js +16 -3
- package/hooks/features/focus/useGridFocus.js +11 -6
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -34
- package/hooks/features/pagination/useGridPageSize.js +3 -1
- package/hooks/features/rows/gridRowsSelector.d.ts +14 -0
- package/hooks/features/rows/gridRowsSelector.js +20 -1
- package/hooks/features/rows/gridRowsState.d.ts +8 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +4 -0
- package/hooks/features/rows/gridRowsUtils.js +21 -3
- package/hooks/features/rows/index.d.ts +1 -1
- package/hooks/features/rows/index.js +1 -1
- package/hooks/features/rows/useGridRows.js +5 -2
- package/hooks/features/rows/useGridRowsMeta.js +19 -4
- package/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/hooks/features/scroll/useGridScroll.js +7 -2
- package/hooks/features/selection/useGridSelection.js +7 -3
- package/hooks/features/sorting/useGridSorting.js +8 -0
- package/hooks/features/statePersistence/gridStatePersistenceInterface.d.ts +3 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +31 -16
- package/index.js +1 -1
- package/internals/index.d.ts +5 -1
- package/internals/index.js +4 -0
- package/legacy/DataGrid/DataGrid.js +7 -1
- package/legacy/DataGrid/useDataGridProps.js +1 -0
- package/legacy/colDef/gridStringColDef.js +1 -1
- package/legacy/components/GridRow.js +5 -1
- package/legacy/components/base/GridOverlays.js +2 -2
- package/legacy/components/cell/GridEditInputCell.js +13 -14
- package/legacy/components/cell/GridEditSingleSelectCell.js +11 -3
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
- package/legacy/components/containers/GridRoot.js +4 -2
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +14 -5
- package/legacy/components/toolbar/GridToolbarExportContainer.js +15 -2
- package/legacy/constants/envConstants.js +2 -11
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +1 -1
- package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +27 -17
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/legacy/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +16 -10
- package/legacy/hooks/features/export/utils.js +13 -1
- package/legacy/hooks/features/filter/gridFilterUtils.js +84 -55
- package/legacy/hooks/features/filter/useGridFilter.js +16 -3
- package/legacy/hooks/features/focus/useGridFocus.js +11 -6
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +47 -34
- package/legacy/hooks/features/pagination/useGridPageSize.js +3 -1
- package/legacy/hooks/features/rows/gridRowsSelector.js +23 -0
- package/legacy/hooks/features/rows/gridRowsUtils.js +21 -3
- package/legacy/hooks/features/rows/index.js +1 -1
- package/legacy/hooks/features/rows/useGridRows.js +5 -2
- package/legacy/hooks/features/rows/useGridRowsMeta.js +19 -4
- package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/legacy/hooks/features/scroll/useGridScroll.js +7 -2
- package/legacy/hooks/features/selection/useGridSelection.js +7 -3
- package/legacy/hooks/features/sorting/useGridSorting.js +8 -0
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +32 -16
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +4 -0
- package/legacy/locales/arSD.js +1 -1
- package/legacy/locales/bgBG.js +1 -1
- package/legacy/locales/csCZ.js +1 -1
- package/legacy/locales/daDK.js +1 -1
- package/legacy/locales/deDE.js +9 -9
- package/legacy/locales/elGR.js +1 -1
- package/legacy/locales/esES.js +1 -1
- package/legacy/locales/faIR.js +1 -1
- package/legacy/locales/fiFI.js +1 -1
- package/legacy/locales/frFR.js +1 -1
- package/legacy/locales/heIL.js +1 -1
- package/legacy/locales/huHU.js +1 -1
- package/legacy/locales/itIT.js +15 -15
- package/legacy/locales/jaJP.js +3 -3
- package/legacy/locales/koKR.js +34 -30
- package/legacy/locales/nbNO.js +1 -1
- package/legacy/locales/nlNL.js +1 -1
- package/legacy/locales/plPL.js +1 -1
- package/legacy/locales/ptBR.js +1 -1
- package/legacy/locales/roRO.js +1 -1
- package/legacy/locales/ruRU.js +1 -1
- package/legacy/locales/skSK.js +1 -1
- package/legacy/locales/svSE.js +1 -1
- package/legacy/locales/trTR.js +1 -1
- package/legacy/locales/ukUA.js +1 -1
- package/legacy/locales/viVN.js +1 -1
- package/legacy/locales/zhCN.js +37 -33
- package/legacy/locales/zhTW.js +1 -1
- package/legacy/utils/keyboardUtils.js +8 -5
- package/locales/arSD.js +1 -1
- package/locales/bgBG.js +1 -1
- package/locales/csCZ.js +1 -1
- package/locales/daDK.js +1 -1
- package/locales/deDE.js +9 -9
- package/locales/elGR.js +1 -1
- package/locales/esES.js +1 -1
- package/locales/faIR.js +1 -1
- package/locales/fiFI.js +1 -1
- package/locales/frFR.js +1 -1
- package/locales/heIL.js +1 -1
- package/locales/huHU.js +1 -1
- package/locales/itIT.js +15 -15
- package/locales/jaJP.js +3 -3
- package/locales/koKR.js +30 -30
- package/locales/nbNO.js +1 -1
- package/locales/nlNL.js +1 -1
- package/locales/plPL.js +1 -1
- package/locales/ptBR.js +1 -1
- package/locales/roRO.js +1 -1
- package/locales/ruRU.js +1 -1
- package/locales/skSK.js +1 -1
- package/locales/svSE.js +1 -1
- package/locales/trTR.js +1 -1
- package/locales/ukUA.js +1 -1
- package/locales/viVN.js +1 -1
- package/locales/zhCN.js +33 -33
- package/locales/zhTW.js +1 -1
- package/models/gridRows.d.ts +5 -0
- package/models/props/DataGridProps.d.ts +8 -3
- package/modern/DataGrid/DataGrid.js +7 -1
- package/modern/DataGrid/useDataGridProps.js +1 -0
- package/modern/colDef/gridStringColDef.js +1 -1
- package/modern/components/GridRow.js +5 -1
- package/modern/components/base/GridOverlays.js +2 -2
- package/modern/components/cell/GridEditInputCell.js +13 -14
- package/modern/components/cell/GridEditSingleSelectCell.js +11 -4
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
- package/modern/components/containers/GridRoot.js +4 -2
- package/modern/components/toolbar/GridToolbarDensitySelector.js +11 -4
- package/modern/components/toolbar/GridToolbarExportContainer.js +11 -2
- package/modern/constants/envConstants.js +2 -11
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +1 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +24 -16
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/modern/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +16 -10
- package/modern/hooks/features/export/utils.js +6 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +73 -42
- package/modern/hooks/features/filter/useGridFilter.js +16 -3
- package/modern/hooks/features/focus/useGridFocus.js +11 -6
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -30
- package/modern/hooks/features/pagination/useGridPageSize.js +3 -1
- package/modern/hooks/features/rows/gridRowsSelector.js +18 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +19 -3
- package/modern/hooks/features/rows/index.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +5 -2
- package/modern/hooks/features/rows/useGridRowsMeta.js +17 -4
- package/modern/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/modern/hooks/features/scroll/useGridScroll.js +5 -2
- package/modern/hooks/features/selection/useGridSelection.js +7 -1
- package/modern/hooks/features/sorting/useGridSorting.js +8 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +30 -15
- package/modern/index.js +1 -1
- package/modern/internals/index.js +4 -0
- package/modern/locales/arSD.js +1 -1
- package/modern/locales/bgBG.js +1 -1
- package/modern/locales/csCZ.js +1 -1
- package/modern/locales/daDK.js +1 -1
- package/modern/locales/deDE.js +9 -9
- package/modern/locales/elGR.js +1 -1
- package/modern/locales/esES.js +1 -1
- package/modern/locales/faIR.js +1 -1
- package/modern/locales/fiFI.js +1 -1
- package/modern/locales/frFR.js +1 -1
- package/modern/locales/heIL.js +1 -1
- package/modern/locales/huHU.js +1 -1
- package/modern/locales/itIT.js +15 -15
- package/modern/locales/jaJP.js +3 -3
- package/modern/locales/koKR.js +30 -30
- package/modern/locales/nbNO.js +1 -1
- package/modern/locales/nlNL.js +1 -1
- package/modern/locales/plPL.js +1 -1
- package/modern/locales/ptBR.js +1 -1
- package/modern/locales/roRO.js +1 -1
- package/modern/locales/ruRU.js +1 -1
- package/modern/locales/skSK.js +1 -1
- package/modern/locales/svSE.js +1 -1
- package/modern/locales/trTR.js +1 -1
- package/modern/locales/ukUA.js +1 -1
- package/modern/locales/viVN.js +1 -1
- package/modern/locales/zhCN.js +33 -33
- package/modern/locales/zhTW.js +1 -1
- package/modern/utils/keyboardUtils.js +7 -2
- package/node/DataGrid/DataGrid.js +7 -1
- package/node/DataGrid/useDataGridProps.js +1 -0
- package/node/colDef/gridStringColDef.js +1 -1
- package/node/components/GridRow.js +5 -1
- package/node/components/base/GridOverlays.js +2 -2
- package/node/components/cell/GridEditInputCell.js +15 -16
- package/node/components/cell/GridEditSingleSelectCell.js +10 -4
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +5 -0
- package/node/components/containers/GridRoot.js +3 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +13 -4
- package/node/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/node/constants/envConstants.js +2 -13
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +1 -1
- package/node/hooks/features/dimensions/useGridDimensions.js +7 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +26 -16
- package/node/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/node/hooks/features/editRows/useGridEditing.new.js +4 -0
- package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +16 -10
- package/node/hooks/features/export/utils.js +7 -0
- package/node/hooks/features/filter/gridFilterUtils.js +81 -47
- package/node/hooks/features/filter/useGridFilter.js +15 -2
- package/node/hooks/features/focus/useGridFocus.js +11 -6
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +43 -34
- package/node/hooks/features/pagination/useGridPageSize.js +4 -1
- package/node/hooks/features/rows/gridRowsSelector.js +24 -2
- package/node/hooks/features/rows/gridRowsUtils.js +23 -2
- package/node/hooks/features/rows/index.js +70 -12
- package/node/hooks/features/rows/useGridRows.js +5 -2
- package/node/hooks/features/rows/useGridRowsMeta.js +20 -4
- package/node/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
- package/node/hooks/features/scroll/useGridScroll.js +7 -1
- package/node/hooks/features/selection/useGridSelection.js +7 -3
- package/node/hooks/features/sorting/useGridSorting.js +8 -0
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +31 -16
- package/node/index.js +1 -1
- package/node/internals/index.js +36 -0
- package/node/locales/arSD.js +1 -1
- package/node/locales/bgBG.js +1 -1
- package/node/locales/csCZ.js +1 -1
- package/node/locales/daDK.js +1 -1
- package/node/locales/deDE.js +9 -9
- package/node/locales/elGR.js +1 -1
- package/node/locales/esES.js +1 -1
- package/node/locales/faIR.js +1 -1
- package/node/locales/fiFI.js +1 -1
- package/node/locales/frFR.js +1 -1
- package/node/locales/heIL.js +1 -1
- package/node/locales/huHU.js +1 -1
- package/node/locales/itIT.js +15 -15
- package/node/locales/jaJP.js +3 -3
- package/node/locales/koKR.js +30 -30
- package/node/locales/nbNO.js +1 -1
- package/node/locales/nlNL.js +1 -1
- package/node/locales/plPL.js +1 -1
- package/node/locales/ptBR.js +1 -1
- package/node/locales/roRO.js +1 -1
- package/node/locales/ruRU.js +1 -1
- package/node/locales/skSK.js +1 -1
- package/node/locales/svSE.js +1 -1
- package/node/locales/trTR.js +1 -1
- package/node/locales/ukUA.js +1 -1
- package/node/locales/viVN.js +1 -1
- package/node/locales/zhCN.js +33 -33
- package/node/locales/zhTW.js +1 -1
- package/node/utils/keyboardUtils.js +10 -4
- package/package.json +1 -1
- package/utils/keyboardUtils.d.ts +2 -2
- package/utils/keyboardUtils.js +7 -2
|
@@ -23,6 +23,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
23
23
|
cellModesModel = _React$useState2[0],
|
|
24
24
|
setCellModesModel = _React$useState2[1];
|
|
25
25
|
|
|
26
|
+
var cellModesModelRef = React.useRef(cellModesModel);
|
|
26
27
|
var prevCellModesModel = React.useRef({});
|
|
27
28
|
var processRowUpdate = props.processRowUpdate,
|
|
28
29
|
onProcessRowUpdateError = props.onProcessRowUpdateError,
|
|
@@ -70,6 +71,10 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
if (apiRef.current.getCellMode(params.id, params.field) === GridCellModes.View) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
var newParams = _extends({}, params, {
|
|
74
79
|
reason: GridCellEditStopReasons.cellFocusOut
|
|
75
80
|
});
|
|
@@ -105,15 +110,14 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
105
110
|
} else if (params.isEditable) {
|
|
106
111
|
var _reason;
|
|
107
112
|
|
|
108
|
-
if (isPrintableKey(event
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
+
if (isPrintableKey(event)) {
|
|
114
|
+
_reason = GridCellEditStartReasons.printableKeyDown;
|
|
115
|
+
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
113
116
|
_reason = GridCellEditStartReasons.printableKeyDown;
|
|
114
117
|
} else if (event.key === 'Enter') {
|
|
115
118
|
_reason = GridCellEditStartReasons.enterKeyDown;
|
|
116
|
-
} else if (event.key === 'Delete') {
|
|
119
|
+
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
120
|
+
// Delete on Windows, Backspace on macOS
|
|
117
121
|
_reason = GridCellEditStartReasons.deleteKeyDown;
|
|
118
122
|
}
|
|
119
123
|
|
|
@@ -145,6 +149,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
145
149
|
var id = params.id,
|
|
146
150
|
field = params.field,
|
|
147
151
|
reason = params.reason;
|
|
152
|
+
apiRef.current.unstable_runPendingEditCellValueMutation(id, field);
|
|
148
153
|
var cellToFocusAfter;
|
|
149
154
|
|
|
150
155
|
if (reason === GridCellEditStopReasons.enterKeyDown) {
|
|
@@ -158,7 +163,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
158
163
|
var ignoreModifications = reason === 'escapeKeyDown';
|
|
159
164
|
var editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
160
165
|
|
|
161
|
-
if (editingState[id][field].isProcessingProps) {
|
|
166
|
+
if (editingState[id][field].isProcessingProps && !props.disableIgnoreModificationsIfProcessingProps) {
|
|
162
167
|
// The user wants to stop editing the cell but we can't wait for the props to be processed.
|
|
163
168
|
// In this case, discard the modifications.
|
|
164
169
|
ignoreModifications = true;
|
|
@@ -170,7 +175,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
170
175
|
ignoreModifications: ignoreModifications,
|
|
171
176
|
cellToFocusAfter: cellToFocusAfter
|
|
172
177
|
});
|
|
173
|
-
}, [apiRef]);
|
|
178
|
+
}, [apiRef, props.disableIgnoreModificationsIfProcessingProps]);
|
|
174
179
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsCell(handleCellDoubleClick));
|
|
175
180
|
useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsCell(handleCellFocusOut));
|
|
176
181
|
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfEditModeIsCell(handleCellKeyDown));
|
|
@@ -198,17 +203,20 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
198
203
|
}
|
|
199
204
|
|
|
200
205
|
setCellModesModel(newModel);
|
|
206
|
+
cellModesModelRef.current = newModel;
|
|
201
207
|
apiRef.current.publishEvent('cellModesModelChange', newModel);
|
|
202
208
|
}, [apiRef, onCellModesModelChange, props.cellModesModel, signature]);
|
|
203
209
|
var updateFieldInCellModesModel = React.useCallback(function (id, field, newProps) {
|
|
204
|
-
|
|
210
|
+
// We use the ref because it always contain the up-to-date value, different from the state
|
|
211
|
+
// that needs a rerender to reflect the new value
|
|
212
|
+
var newModel = _extends({}, cellModesModelRef.current);
|
|
205
213
|
|
|
206
214
|
if (newProps !== null) {
|
|
207
215
|
newModel[id] = _extends({}, newModel[id], _defineProperty({}, field, _extends({}, newProps)));
|
|
208
216
|
} else {
|
|
209
|
-
var
|
|
210
|
-
fieldToRemove =
|
|
211
|
-
otherFields = _objectWithoutProperties(
|
|
217
|
+
var _newModel$id = newModel[id],
|
|
218
|
+
fieldToRemove = _newModel$id[field],
|
|
219
|
+
otherFields = _objectWithoutProperties(_newModel$id, [field].map(_toPropertyKey)); // Ensure that we have a new object, not a reference
|
|
212
220
|
|
|
213
221
|
|
|
214
222
|
newModel[id] = otherFields;
|
|
@@ -219,7 +227,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
updateCellModesModel(newModel);
|
|
222
|
-
}, [
|
|
230
|
+
}, [updateCellModesModel]);
|
|
223
231
|
var updateOrDeleteFieldState = React.useCallback(function (id, field, newProps) {
|
|
224
232
|
apiRef.current.setState(function (state) {
|
|
225
233
|
var newEditingState = _extends({}, state.editRows);
|
|
@@ -286,12 +294,12 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
286
294
|
apiRef.current.unstable_runPendingEditCellValueMutation(id, field);
|
|
287
295
|
|
|
288
296
|
finishCellEditMode = function finishCellEditMode() {
|
|
297
|
+
updateOrDeleteFieldState(id, field, null);
|
|
298
|
+
updateFieldInCellModesModel(id, field, null);
|
|
299
|
+
|
|
289
300
|
if (cellToFocusAfter !== 'none') {
|
|
290
301
|
apiRef.current.unstable_moveFocusToRelativeCell(id, field, cellToFocusAfter);
|
|
291
302
|
}
|
|
292
|
-
|
|
293
|
-
updateOrDeleteFieldState(id, field, null);
|
|
294
|
-
updateFieldInCellModesModel(id, field, null);
|
|
295
303
|
};
|
|
296
304
|
|
|
297
305
|
if (!ignoreModifications) {
|
|
@@ -358,6 +366,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
358
366
|
}(), [apiRef, onProcessRowUpdateError, processRowUpdate, throwIfNotInMode, updateFieldInCellModesModel, updateOrDeleteFieldState]);
|
|
359
367
|
var setCellEditingEditCellValue = React.useCallback( /*#__PURE__*/function () {
|
|
360
368
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
|
|
369
|
+
var _editingState$id, _editingState$id$fiel2;
|
|
370
|
+
|
|
361
371
|
var id, field, value, column, row, parsedValue, editingState, newProps, hasChanged;
|
|
362
372
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
363
373
|
while (1) {
|
|
@@ -419,7 +429,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
419
429
|
newProps.value = column.preProcessEditCellProps ? editingState[id][field].value : parsedValue;
|
|
420
430
|
updateOrDeleteFieldState(id, field, newProps);
|
|
421
431
|
editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
422
|
-
return _context2.abrupt("return", !editingState[id][field].error);
|
|
432
|
+
return _context2.abrupt("return", !((_editingState$id = editingState[id]) != null && (_editingState$id$fiel2 = _editingState$id[field]) != null && _editingState$id$fiel2.error));
|
|
423
433
|
|
|
424
434
|
case 24:
|
|
425
435
|
case "end":
|
|
@@ -210,7 +210,7 @@ export var useCellEditing = function useCellEditing(apiRef, props) {
|
|
|
210
210
|
isEditMode = cellMode === GridCellModes.Edit;
|
|
211
211
|
isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey;
|
|
212
212
|
|
|
213
|
-
if (!isEditMode && isCellEnterEditModeKeys(event
|
|
213
|
+
if (!isEditMode && isCellEnterEditModeKeys(event) && !isModifierKeyPressed && !(event.key === ' ' && event.shiftKey)) {
|
|
214
214
|
apiRef.current.publishEvent('cellEditStart', params, event);
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -327,7 +327,7 @@ export var useCellEditing = function useCellEditing(apiRef, props) {
|
|
|
327
327
|
|
|
328
328
|
apiRef.current.setCellMode(params.id, params.field, GridCellModes.Edit);
|
|
329
329
|
|
|
330
|
-
if (isKeyboardEvent(event) && isPrintableKey(event
|
|
330
|
+
if (isKeyboardEvent(event) && isPrintableKey(event)) {
|
|
331
331
|
apiRef.current.unstable_setEditCellProps({
|
|
332
332
|
id: params.id,
|
|
333
333
|
field: params.field,
|
|
@@ -34,7 +34,7 @@ export function useGridEditing(apiRef, props) {
|
|
|
34
34
|
changeEvent: 'editRowsModelChange'
|
|
35
35
|
});
|
|
36
36
|
var isCellEditable = React.useCallback(function (params) {
|
|
37
|
-
return !params.rowNode.isAutoGenerated && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params));
|
|
37
|
+
return !params.rowNode.isAutoGenerated && !params.rowNode.isPinned && !!params.colDef.editable && !!params.colDef.renderEditCell && (!props.isCellEditable || props.isCellEditable(params));
|
|
38
38
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
39
|
[props.isCellEditable]);
|
|
40
40
|
|
|
@@ -22,6 +22,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
22
22
|
rowModesModel = _React$useState2[0],
|
|
23
23
|
setRowModesModel = _React$useState2[1];
|
|
24
24
|
|
|
25
|
+
var rowModesModelRef = React.useRef(rowModesModel);
|
|
25
26
|
var prevRowModesModel = React.useRef({});
|
|
26
27
|
var focusTimeout = React.useRef(null);
|
|
27
28
|
var nextFocusedCell = React.useRef(null);
|
|
@@ -96,6 +97,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
96
97
|
// The row might have been deleted during the click
|
|
97
98
|
if (!apiRef.current.getRow(params.id)) {
|
|
98
99
|
return;
|
|
100
|
+
} // The row may already changed its mode
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if (apiRef.current.getRowMode(params.id) === GridRowModes.View) {
|
|
104
|
+
return;
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
var rowParams = apiRef.current.getRowParams(params.id);
|
|
@@ -161,15 +167,14 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
161
167
|
} else if (params.isEditable) {
|
|
162
168
|
var _reason;
|
|
163
169
|
|
|
164
|
-
if (isPrintableKey(event
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
170
|
+
if (isPrintableKey(event)) {
|
|
171
|
+
_reason = GridRowEditStartReasons.printableKeyDown;
|
|
172
|
+
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
169
173
|
_reason = GridRowEditStartReasons.printableKeyDown;
|
|
170
174
|
} else if (event.key === 'Enter') {
|
|
171
175
|
_reason = GridRowEditStartReasons.enterKeyDown;
|
|
172
|
-
} else if (event.key === 'Delete') {
|
|
176
|
+
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
177
|
+
// Delete on Windows, Backspace on macOS
|
|
173
178
|
_reason = GridRowEditStartReasons.deleteKeyDown;
|
|
174
179
|
}
|
|
175
180
|
|
|
@@ -218,7 +223,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
218
223
|
var ignoreModifications = reason === 'escapeKeyDown';
|
|
219
224
|
var editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
220
225
|
|
|
221
|
-
if (!ignoreModifications) {
|
|
226
|
+
if (!ignoreModifications && !props.disableIgnoreModificationsIfProcessingProps) {
|
|
222
227
|
// The user wants to stop editing the cell but we can't wait for the props to be processed.
|
|
223
228
|
// In this case, discard the modifications if any field is processing its props.
|
|
224
229
|
ignoreModifications = Object.values(editingState[id]).some(function (fieldProps) {
|
|
@@ -232,7 +237,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
232
237
|
field: field,
|
|
233
238
|
cellToFocusAfter: cellToFocusAfter
|
|
234
239
|
});
|
|
235
|
-
}, [apiRef]);
|
|
240
|
+
}, [apiRef, props.disableIgnoreModificationsIfProcessingProps]);
|
|
236
241
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', runIfEditModeIsRow(handleCellDoubleClick));
|
|
237
242
|
useGridApiEventHandler(apiRef, 'cellFocusIn', runIfEditModeIsRow(handleCellFocusIn));
|
|
238
243
|
useGridApiEventHandler(apiRef, 'cellFocusOut', runIfEditModeIsRow(handleCellFocusOut));
|
|
@@ -265,10 +270,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
setRowModesModel(newModel);
|
|
273
|
+
rowModesModelRef.current = newModel;
|
|
268
274
|
apiRef.current.publishEvent('rowModesModelChange', newModel);
|
|
269
275
|
}, [apiRef, onRowModesModelChange, props.rowModesModel, signature]);
|
|
270
276
|
var updateRowInRowModesModel = React.useCallback(function (id, newProps) {
|
|
271
|
-
var newModel = _extends({},
|
|
277
|
+
var newModel = _extends({}, rowModesModelRef.current);
|
|
272
278
|
|
|
273
279
|
if (newProps !== null) {
|
|
274
280
|
newModel[id] = _extends({}, newProps);
|
|
@@ -277,7 +283,7 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
277
283
|
}
|
|
278
284
|
|
|
279
285
|
updateRowModesModel(newModel);
|
|
280
|
-
}, [
|
|
286
|
+
}, [updateRowModesModel]);
|
|
281
287
|
var updateOrDeleteRowState = React.useCallback(function (id, newProps) {
|
|
282
288
|
apiRef.current.setState(function (state) {
|
|
283
289
|
var newEditingState = _extends({}, state.editRows);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from '../columns';
|
|
2
3
|
import { gridFilteredSortedRowIdsSelector } from '../filter';
|
|
3
|
-
import { gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
4
|
+
import { gridPinnedRowsSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
4
5
|
export var getColumnsToExport = function getColumnsToExport(_ref) {
|
|
5
6
|
var apiRef = _ref.apiRef,
|
|
6
7
|
options = _ref.options;
|
|
@@ -22,6 +23,8 @@ export var getColumnsToExport = function getColumnsToExport(_ref) {
|
|
|
22
23
|
});
|
|
23
24
|
};
|
|
24
25
|
export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
|
|
26
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
27
|
+
|
|
25
28
|
var apiRef = _ref2.apiRef;
|
|
26
29
|
var filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
27
30
|
var rowTree = gridRowTreeSelector(apiRef);
|
|
@@ -31,6 +34,15 @@ export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
|
|
|
31
34
|
|
|
32
35
|
return ((_rowTree$id$position = rowTree[id].position) != null ? _rowTree$id$position : 'body') === 'body';
|
|
33
36
|
});
|
|
37
|
+
var pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
38
|
+
var topPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(function (row) {
|
|
39
|
+
return row.id;
|
|
40
|
+
})) || [];
|
|
41
|
+
var bottomPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(function (row) {
|
|
42
|
+
return row.id;
|
|
43
|
+
})) || [];
|
|
44
|
+
bodyRows.unshift.apply(bodyRows, _toConsumableArray(topPinnedRowsIds));
|
|
45
|
+
bodyRows.push.apply(bodyRows, _toConsumableArray(bottomPinnedRowsIds));
|
|
34
46
|
|
|
35
47
|
if (selectedRows.size > 0) {
|
|
36
48
|
return bodyRows.filter(function (id) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { GridLinkOperator } from '../../../models';
|
|
3
|
+
import { getDefaultGridFilterModel } from './gridFilterState';
|
|
3
4
|
import { buildWarning } from '../../../utils/warning';
|
|
4
5
|
import { gridColumnFieldsSelector, gridColumnLookupSelector } from '../columns';
|
|
5
|
-
import { gridRowTreeSelector } from '../rows/gridRowsSelector';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Adds default values to the optional fields of a filter items.
|
|
@@ -87,10 +87,7 @@ export var mergeStateWithFilterModel = function mergeStateWithFilterModel(filter
|
|
|
87
87
|
*/
|
|
88
88
|
|
|
89
89
|
export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterItemsApplier(filterModel, apiRef) {
|
|
90
|
-
var items = filterModel.items
|
|
91
|
-
_filterModel$linkOper = filterModel.linkOperator,
|
|
92
|
-
linkOperator = _filterModel$linkOper === void 0 ? GridLinkOperator.And : _filterModel$linkOper;
|
|
93
|
-
var tree = gridRowTreeSelector(apiRef);
|
|
90
|
+
var items = filterModel.items;
|
|
94
91
|
|
|
95
92
|
var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem) {
|
|
96
93
|
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
@@ -160,24 +157,14 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
|
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
return function (rowId, shouldApplyFilter) {
|
|
163
|
-
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
|
|
160
|
+
var resultPerItemId = {};
|
|
167
161
|
var filteredAppliers = shouldApplyFilter ? appliers.filter(function (applier) {
|
|
168
162
|
return shouldApplyFilter(applier.item.columnField);
|
|
169
|
-
}) : appliers;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return filteredAppliers.every(function (applier) {
|
|
173
|
-
return applier.fn(rowId);
|
|
174
|
-
});
|
|
175
|
-
} // Return `true` as soon as we have a passing filter
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return filteredAppliers.some(function (applier) {
|
|
179
|
-
return applier.fn(rowId);
|
|
163
|
+
}) : appliers;
|
|
164
|
+
filteredAppliers.forEach(function (applier) {
|
|
165
|
+
resultPerItemId[applier.item.id] = applier.fn(rowId);
|
|
180
166
|
});
|
|
167
|
+
return resultPerItemId;
|
|
181
168
|
};
|
|
182
169
|
};
|
|
183
170
|
/**
|
|
@@ -189,9 +176,7 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
|
|
|
189
176
|
|
|
190
177
|
export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterApplier(filterModel, apiRef) {
|
|
191
178
|
var _filterModel$quickFil = filterModel.quickFilterValues,
|
|
192
|
-
quickFilterValues = _filterModel$quickFil === void 0 ? [] : _filterModel$quickFil
|
|
193
|
-
_filterModel$quickFil2 = filterModel.quickFilterLogicOperator,
|
|
194
|
-
quickFilterLogicOperator = _filterModel$quickFil2 === void 0 ? GridLinkOperator.And : _filterModel$quickFil2;
|
|
179
|
+
quickFilterValues = _filterModel$quickFil === void 0 ? [] : _filterModel$quickFil;
|
|
195
180
|
|
|
196
181
|
if (quickFilterValues.length === 0) {
|
|
197
182
|
return null;
|
|
@@ -217,6 +202,11 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
217
202
|
return appliersPerColumnField[field][index] != null;
|
|
218
203
|
});
|
|
219
204
|
});
|
|
205
|
+
|
|
206
|
+
if (sanitizedQuickFilterValues.length === 0) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
|
|
220
210
|
return function (rowId, shouldApplyFilter) {
|
|
221
211
|
var usedCellParams = {};
|
|
222
212
|
var columnsFieldsToFilter = [];
|
|
@@ -225,53 +215,92 @@ export var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilt
|
|
|
225
215
|
usedCellParams[columnField] = apiRef.current.getCellParams(rowId, columnField);
|
|
226
216
|
columnsFieldsToFilter.push(columnField);
|
|
227
217
|
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
var _appliersPerColumnFie, _appliersPerColumnFie2;
|
|
234
|
-
|
|
235
|
-
if (appliersPerColumnField[field][index] == null) {
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return (_appliersPerColumnFie = (_appliersPerColumnFie2 = appliersPerColumnField[field])[index]) == null ? void 0 : _appliersPerColumnFie.call(_appliersPerColumnFie2, usedCellParams[field]);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
} // Return `true` as soon as we have have a quick filter value that match any column
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
return sanitizedQuickFilterValues.some(function (value, index) {
|
|
246
|
-
return columnsFieldsToFilter.some(function (field) {
|
|
247
|
-
var _appliersPerColumnFie3, _appliersPerColumnFie4;
|
|
218
|
+
});
|
|
219
|
+
var quickFilterValueResult = {};
|
|
220
|
+
sanitizedQuickFilterValues.forEach(function (value, index) {
|
|
221
|
+
var isPassing = columnsFieldsToFilter.some(function (field) {
|
|
222
|
+
var _appliersPerColumnFie, _appliersPerColumnFie2;
|
|
248
223
|
|
|
249
224
|
if (appliersPerColumnField[field][index] == null) {
|
|
250
225
|
return false;
|
|
251
226
|
}
|
|
252
227
|
|
|
253
|
-
return (
|
|
228
|
+
return (_appliersPerColumnFie = (_appliersPerColumnFie2 = appliersPerColumnField[field])[index]) == null ? void 0 : _appliersPerColumnFie.call(_appliersPerColumnFie2, usedCellParams[field]);
|
|
254
229
|
});
|
|
230
|
+
quickFilterValueResult[value] = isPassing;
|
|
255
231
|
});
|
|
232
|
+
return quickFilterValueResult;
|
|
256
233
|
};
|
|
257
234
|
};
|
|
258
235
|
export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(filterModel, apiRef) {
|
|
259
236
|
var isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(filterModel, apiRef);
|
|
260
237
|
var isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(filterModel, apiRef);
|
|
238
|
+
return function (rowId, shouldApplyFilter) {
|
|
239
|
+
return {
|
|
240
|
+
passingFilterItems: isRowMatchingFilterItems && isRowMatchingFilterItems(rowId, shouldApplyFilter),
|
|
241
|
+
passingQuickFilterValues: isRowMatchingQuickFilter && isRowMatchingQuickFilter(rowId, shouldApplyFilter)
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
export var passFilterLogic = function passFilterLogic(allFilterItemResults, allQuickFilterResults, filterModel) {
|
|
246
|
+
var _filterModel$quickFil2, _filterModel$linkOper;
|
|
261
247
|
|
|
262
|
-
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
248
|
+
var cleanedAllFilterItemResults = allFilterItemResults.filter(function (result) {
|
|
249
|
+
return result != null;
|
|
250
|
+
});
|
|
251
|
+
var cleanedAllQuickFilterResults = allQuickFilterResults.filter(function (result) {
|
|
252
|
+
return result != null;
|
|
253
|
+
}); // Defaultize operators
|
|
254
|
+
|
|
255
|
+
var quickFilterLogicOperator = (_filterModel$quickFil2 = filterModel.quickFilterLogicOperator) != null ? _filterModel$quickFil2 : getDefaultGridFilterModel().quickFilterLogicOperator;
|
|
256
|
+
var linkOperator = (_filterModel$linkOper = filterModel.linkOperator) != null ? _filterModel$linkOper : getDefaultGridFilterModel().linkOperator; // get result for filter items model
|
|
257
|
+
|
|
258
|
+
if (cleanedAllFilterItemResults.length > 0) {
|
|
259
|
+
// Return true if the item pass with one of the rows
|
|
260
|
+
var filterItemPredicate = function filterItemPredicate(item) {
|
|
261
|
+
return cleanedAllFilterItemResults.some(function (filterItemResult) {
|
|
262
|
+
return filterItemResult[item.id];
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
if (linkOperator === GridLinkOperator.And) {
|
|
267
|
+
var passesAllFilters = filterModel.items.every(filterItemPredicate);
|
|
268
|
+
|
|
269
|
+
if (!passesAllFilters) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
var passesSomeFilters = filterModel.items.some(filterItemPredicate);
|
|
274
|
+
|
|
275
|
+
if (!passesSomeFilters) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
} // get result for quick filter model
|
|
265
280
|
|
|
266
|
-
if (isRowMatchingFilterItems == null) {
|
|
267
|
-
return isRowMatchingQuickFilter;
|
|
268
|
-
}
|
|
269
281
|
|
|
270
|
-
if (
|
|
271
|
-
|
|
282
|
+
if (cleanedAllQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
|
|
283
|
+
// Return true if the item pass with one of the rows
|
|
284
|
+
var quickFilterValuePredicate = function quickFilterValuePredicate(value) {
|
|
285
|
+
return cleanedAllQuickFilterResults.some(function (quickFilterValueResult) {
|
|
286
|
+
return quickFilterValueResult[value];
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
if (quickFilterLogicOperator === GridLinkOperator.And) {
|
|
291
|
+
var passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
|
|
292
|
+
|
|
293
|
+
if (!passesAllQuickFilterValues) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
var passesSomeQuickFilterValues = filterModel.quickFilterValues.some(quickFilterValuePredicate);
|
|
298
|
+
|
|
299
|
+
if (!passesSomeQuickFilterValues) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
272
303
|
}
|
|
273
304
|
|
|
274
|
-
return
|
|
275
|
-
return isRowMatchingFilterItems(rowId, shouldApplyFilter) && isRowMatchingQuickFilter(rowId, shouldApplyFilter);
|
|
276
|
-
};
|
|
305
|
+
return true;
|
|
277
306
|
};
|
|
@@ -13,7 +13,7 @@ import { useFirstRender } from '../../utils/useFirstRender';
|
|
|
13
13
|
import { gridRowIdsSelector } from '../rows';
|
|
14
14
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
15
15
|
import { GRID_DEFAULT_STRATEGY, useGridRegisterStrategyProcessor } from '../../core/strategyProcessing';
|
|
16
|
-
import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel, cleanFilterItem } from './gridFilterUtils';
|
|
16
|
+
import { buildAggregatedFilterApplier, sanitizeFilterModel, mergeStateWithFilterModel, cleanFilterItem, passFilterLogic } from './gridFilterUtils';
|
|
17
17
|
import { isDeepEqual } from '../../../utils/utils';
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
19
|
export var filterStateInitializer = function filterStateInitializer(state, props, apiRef) {
|
|
@@ -50,7 +50,8 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
50
50
|
var filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
|
|
51
51
|
var isRowMatchingFilters = props.filterMode === GridFeatureModeConstant.client ? buildAggregatedFilterApplier(filterModel, apiRef) : null;
|
|
52
52
|
var filteringResult = apiRef.current.unstable_applyStrategyProcessor('filtering', {
|
|
53
|
-
isRowMatchingFilters: isRowMatchingFilters
|
|
53
|
+
isRowMatchingFilters: isRowMatchingFilters,
|
|
54
|
+
filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
|
|
54
55
|
});
|
|
55
56
|
return _extends({}, state, {
|
|
56
57
|
filter: _extends({}, state.filter, filteringResult)
|
|
@@ -278,7 +279,19 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
278
279
|
|
|
279
280
|
for (var i = 0; i < rowIds.length; i += 1) {
|
|
280
281
|
var rowId = rowIds[i];
|
|
281
|
-
|
|
282
|
+
var isRowPassing = void 0;
|
|
283
|
+
|
|
284
|
+
if (typeof rowId === 'string' && rowId.startsWith('auto-generated-group-footer')) {
|
|
285
|
+
isRowPassing = true;
|
|
286
|
+
} else {
|
|
287
|
+
var _params$isRowMatching = params.isRowMatchingFilters(rowId),
|
|
288
|
+
passingFilterItems = _params$isRowMatching.passingFilterItems,
|
|
289
|
+
passingQuickFilterValues = _params$isRowMatching.passingQuickFilterValues;
|
|
290
|
+
|
|
291
|
+
isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
filteredRowsLookup[rowId] = isRowPassing;
|
|
282
295
|
}
|
|
283
296
|
|
|
284
297
|
return {
|
|
@@ -62,6 +62,12 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
if (focusedCell) {
|
|
66
|
+
// There's a focused cell but another cell was clicked
|
|
67
|
+
// Publishes an event to notify that the focus was lost
|
|
68
|
+
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(focusedCell.id, focusedCell.field));
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
apiRef.current.publishEvent('cellFocusIn', apiRef.current.getCellParams(id, field));
|
|
66
72
|
}, [apiRef, logger]);
|
|
67
73
|
var setColumnHeaderFocus = React.useCallback(function (field) {
|
|
@@ -195,11 +201,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
195
201
|
|
|
196
202
|
if (!apiRef.current.getRow(focusedCell.id)) {
|
|
197
203
|
return;
|
|
198
|
-
}
|
|
199
|
-
// Publishes an event to notify that the focus was lost
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(focusedCell.id, focusedCell.field), event);
|
|
204
|
+
}
|
|
203
205
|
|
|
204
206
|
if (cellParams) {
|
|
205
207
|
apiRef.current.setCellFocus(cellParams.id, cellParams.field);
|
|
@@ -212,7 +214,10 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
212
214
|
}
|
|
213
215
|
});
|
|
214
216
|
});
|
|
215
|
-
apiRef.current.forceUpdate();
|
|
217
|
+
apiRef.current.forceUpdate(); // There's a focused cell but another element (not a cell) was clicked
|
|
218
|
+
// Publishes an event to notify that the focus was lost
|
|
219
|
+
|
|
220
|
+
apiRef.current.publishEvent('cellFocusOut', apiRef.current.getCellParams(focusedCell.id, focusedCell.field), event);
|
|
216
221
|
}
|
|
217
222
|
}, [apiRef]);
|
|
218
223
|
var handleCellModeChange = React.useCallback(function (params) {
|