@mui/x-data-grid 6.6.0 → 6.8.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.
- package/CHANGELOG.md +147 -13
- package/components/GridColumnHeaders.d.ts +2 -2
- package/components/GridColumnHeaders.js +3 -1
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +23 -69
- package/components/cell/GridCell.d.ts +24 -15
- package/components/cell/GridCell.js +422 -45
- package/components/cell/index.d.ts +2 -1
- package/components/cell/index.js +1 -1
- package/components/containers/GridRootStyles.js +38 -17
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/panel/GridColumnsPanel.d.ts +14 -0
- package/components/panel/GridColumnsPanel.js +14 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +1 -6
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +5 -6
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +0 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +1 -6
- package/components/panel/filterPanel/GridFilterPanel.d.ts +8 -0
- package/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/components/toolbar/GridToolbar.js +2 -2
- package/components/virtualization/GridVirtualScroller.js +4 -9
- package/components/virtualization/GridVirtualScrollerContent.js +11 -20
- package/constants/defaultGridSlotsComponents.js +6 -2
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +4 -4
- package/hooks/core/useGridApiInitialization.js +4 -1
- package/hooks/core/useGridStateInitialization.js +2 -9
- package/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -3
- package/hooks/features/editing/useGridRowEditing.js +14 -6
- package/hooks/features/filter/gridFilterUtils.d.ts +4 -1
- package/hooks/features/filter/gridFilterUtils.js +19 -13
- package/hooks/features/filter/useGridFilter.js +4 -2
- package/hooks/features/focus/useGridFocus.js +10 -4
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -0
- package/hooks/features/rows/useGridParamsApi.js +7 -15
- package/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/hooks/features/sorting/useGridSorting.js +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -816
- package/hooks/features/virtualization/useGridVirtualScroller.js +42 -40
- package/hooks/utils/index.d.ts +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/useGridSelector.d.ts +3 -1
- package/hooks/utils/useGridSelector.js +37 -6
- package/hooks/utils/useLazyRef.d.ts +2 -0
- package/hooks/utils/useLazyRef.js +9 -0
- package/hooks/utils/useOnMount.d.ts +2 -0
- package/hooks/utils/useOnMount.js +7 -0
- package/index.js +1 -1
- package/legacy/components/GridColumnHeaders.js +3 -1
- package/legacy/components/GridRow.js +25 -69
- package/legacy/components/cell/GridCell.js +425 -46
- package/legacy/components/cell/index.js +1 -1
- package/legacy/components/containers/GridRootStyles.js +25 -18
- package/legacy/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/legacy/components/panel/GridColumnsPanel.js +14 -0
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +7 -7
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +1 -5
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -6
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +1 -5
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/legacy/components/toolbar/GridToolbar.js +2 -2
- package/legacy/components/virtualization/GridVirtualScroller.js +4 -7
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +10 -17
- package/legacy/constants/defaultGridSlotsComponents.js +6 -2
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +4 -4
- package/legacy/hooks/core/useGridApiInitialization.js +4 -1
- package/legacy/hooks/core/useGridStateInitialization.js +2 -7
- package/legacy/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/legacy/hooks/features/editing/useGridCellEditing.js +5 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +15 -7
- package/legacy/hooks/features/filter/gridFilterUtils.js +23 -19
- package/legacy/hooks/features/filter/useGridFilter.js +4 -2
- package/legacy/hooks/features/focus/useGridFocus.js +10 -4
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/legacy/hooks/features/rows/useGridParamsApi.js +23 -15
- package/legacy/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/legacy/hooks/features/sorting/useGridSorting.js +2 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +40 -36
- package/legacy/hooks/utils/index.js +1 -1
- package/legacy/hooks/utils/useGridSelector.js +43 -5
- package/legacy/hooks/utils/useLazyRef.js +9 -0
- package/legacy/hooks/utils/useOnMount.js +7 -0
- package/legacy/index.js +1 -1
- package/legacy/locales/arSD.js +4 -4
- package/legacy/locales/beBY.js +4 -4
- package/legacy/locales/bgBG.js +4 -4
- package/legacy/locales/csCZ.js +25 -27
- package/legacy/locales/daDK.js +4 -4
- package/legacy/locales/deDE.js +25 -27
- package/legacy/locales/elGR.js +70 -79
- package/legacy/locales/esES.js +4 -4
- package/legacy/locales/faIR.js +4 -4
- package/legacy/locales/fiFI.js +4 -4
- package/legacy/locales/heIL.js +4 -4
- package/legacy/locales/huHU.js +4 -4
- package/legacy/locales/itIT.js +4 -4
- package/legacy/locales/jaJP.js +4 -4
- package/legacy/locales/koKR.js +4 -4
- package/legacy/locales/nbNO.js +4 -4
- package/legacy/locales/plPL.js +4 -4
- package/legacy/locales/ptBR.js +4 -4
- package/legacy/locales/roRO.js +4 -4
- package/legacy/locales/ruRU.js +4 -4
- package/legacy/locales/skSK.js +4 -4
- package/legacy/locales/svSE.js +4 -4
- package/legacy/locales/trTR.js +16 -17
- package/legacy/locales/ukUA.js +4 -4
- package/legacy/locales/urPK.js +4 -4
- package/legacy/locales/viVN.js +4 -4
- package/legacy/locales/zhCN.js +4 -4
- package/legacy/locales/zhTW.js +4 -4
- package/legacy/utils/EventManager.js +2 -2
- package/legacy/utils/Store.js +34 -0
- package/legacy/utils/doesSupportPreventScroll.js +13 -0
- package/legacy/utils/fastMemo.js +5 -0
- package/legacy/utils/fastObjectShallowCompare.js +32 -0
- package/legacy/utils/keyboardUtils.js +4 -2
- package/locales/arSD.js +4 -4
- package/locales/beBY.js +4 -4
- package/locales/bgBG.js +4 -4
- package/locales/csCZ.js +25 -27
- package/locales/daDK.js +4 -4
- package/locales/deDE.js +25 -27
- package/locales/elGR.js +66 -79
- package/locales/esES.js +4 -4
- package/locales/faIR.js +4 -4
- package/locales/fiFI.js +4 -4
- package/locales/heIL.js +4 -4
- package/locales/huHU.js +4 -4
- package/locales/itIT.js +4 -4
- package/locales/jaJP.js +4 -4
- package/locales/koKR.js +4 -4
- package/locales/nbNO.js +4 -4
- package/locales/plPL.js +4 -4
- package/locales/ptBR.js +4 -4
- package/locales/roRO.js +4 -4
- package/locales/ruRU.js +4 -4
- package/locales/skSK.js +4 -4
- package/locales/svSE.js +4 -4
- package/locales/trTR.js +16 -17
- package/locales/ukUA.js +4 -4
- package/locales/urPK.js +4 -4
- package/locales/viVN.js +4 -4
- package/locales/zhCN.js +4 -4
- package/locales/zhTW.js +4 -4
- package/models/api/gridCoreApi.d.ts +6 -0
- package/models/colDef/gridColDef.d.ts +4 -3
- package/models/colDef/gridColType.d.ts +3 -1
- package/models/events/gridEventLookup.d.ts +11 -3
- package/modern/components/GridColumnHeaders.js +3 -1
- package/modern/components/GridRow.js +22 -69
- package/modern/components/cell/GridCell.js +421 -45
- package/modern/components/cell/index.js +1 -1
- package/modern/components/containers/GridRootStyles.js +38 -17
- package/modern/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/modern/components/panel/GridColumnsPanel.js +14 -0
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +5 -6
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/modern/components/toolbar/GridToolbar.js +2 -2
- package/modern/components/virtualization/GridVirtualScroller.js +4 -9
- package/modern/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/modern/constants/defaultGridSlotsComponents.js +6 -2
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +4 -4
- package/modern/hooks/core/useGridApiInitialization.js +4 -1
- package/modern/hooks/core/useGridStateInitialization.js +2 -9
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +9 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +14 -6
- package/modern/hooks/features/filter/gridFilterUtils.js +17 -12
- package/modern/hooks/features/filter/useGridFilter.js +4 -2
- package/modern/hooks/features/focus/useGridFocus.js +9 -4
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/modern/hooks/features/rows/useGridParamsApi.js +7 -15
- package/modern/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/modern/hooks/features/sorting/useGridSorting.js +2 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +42 -40
- package/modern/hooks/utils/index.js +1 -1
- package/modern/hooks/utils/useGridSelector.js +37 -6
- package/modern/hooks/utils/useLazyRef.js +9 -0
- package/modern/hooks/utils/useOnMount.js +7 -0
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +4 -4
- package/modern/locales/beBY.js +4 -4
- package/modern/locales/bgBG.js +4 -4
- package/modern/locales/csCZ.js +25 -27
- package/modern/locales/daDK.js +4 -4
- package/modern/locales/deDE.js +25 -27
- package/modern/locales/elGR.js +66 -79
- package/modern/locales/esES.js +4 -4
- package/modern/locales/faIR.js +4 -4
- package/modern/locales/fiFI.js +4 -4
- package/modern/locales/heIL.js +4 -4
- package/modern/locales/huHU.js +4 -4
- package/modern/locales/itIT.js +4 -4
- package/modern/locales/jaJP.js +4 -4
- package/modern/locales/koKR.js +4 -4
- package/modern/locales/nbNO.js +4 -4
- package/modern/locales/plPL.js +4 -4
- package/modern/locales/ptBR.js +4 -4
- package/modern/locales/roRO.js +4 -4
- package/modern/locales/ruRU.js +4 -4
- package/modern/locales/skSK.js +4 -4
- package/modern/locales/svSE.js +4 -4
- package/modern/locales/trTR.js +16 -17
- package/modern/locales/ukUA.js +4 -4
- package/modern/locales/urPK.js +4 -4
- package/modern/locales/viVN.js +4 -4
- package/modern/locales/zhCN.js +4 -4
- package/modern/locales/zhTW.js +4 -4
- package/modern/utils/EventManager.js +2 -2
- package/modern/utils/Store.js +24 -0
- package/modern/utils/doesSupportPreventScroll.js +13 -0
- package/modern/utils/fastMemo.js +5 -0
- package/modern/utils/fastObjectShallowCompare.js +32 -0
- package/modern/utils/keyboardUtils.js +4 -2
- package/node/components/GridColumnHeaders.js +4 -2
- package/node/components/GridRow.js +22 -69
- package/node/components/cell/GridCell.js +424 -47
- package/node/components/cell/index.js +17 -10
- package/node/components/containers/GridRootStyles.js +38 -17
- package/node/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/node/components/panel/GridColumnsPanel.js +14 -0
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -6
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +5 -6
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +8 -0
- package/node/components/toolbar/GridToolbar.js +2 -2
- package/node/components/virtualization/GridVirtualScroller.js +4 -9
- package/node/components/virtualization/GridVirtualScrollerContent.js +10 -20
- package/node/constants/defaultGridSlotsComponents.js +4 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +4 -4
- package/node/hooks/core/useGridApiInitialization.js +4 -1
- package/node/hooks/core/useGridStateInitialization.js +2 -9
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -2
- package/node/hooks/features/editing/useGridCellEditing.js +5 -3
- package/node/hooks/features/editing/useGridRowEditing.js +14 -6
- package/node/hooks/features/filter/gridFilterUtils.js +17 -12
- package/node/hooks/features/filter/useGridFilter.js +7 -5
- package/node/hooks/features/focus/useGridFocus.js +9 -4
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -3
- package/node/hooks/features/rows/useGridParamsApi.js +9 -15
- package/node/hooks/features/rows/useGridRowsMeta.js +1 -1
- package/node/hooks/features/sorting/useGridSorting.js +2 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +42 -38
- package/node/hooks/utils/index.js +14 -10
- package/node/hooks/utils/useGridSelector.js +41 -7
- package/node/hooks/utils/useLazyRef.js +17 -0
- package/node/hooks/utils/useOnMount.js +15 -0
- package/node/index.js +1 -1
- package/node/locales/arSD.js +4 -4
- package/node/locales/beBY.js +4 -4
- package/node/locales/bgBG.js +4 -4
- package/node/locales/csCZ.js +25 -27
- package/node/locales/daDK.js +4 -4
- package/node/locales/deDE.js +25 -27
- package/node/locales/elGR.js +66 -79
- package/node/locales/esES.js +4 -4
- package/node/locales/faIR.js +4 -4
- package/node/locales/fiFI.js +4 -4
- package/node/locales/heIL.js +4 -4
- package/node/locales/huHU.js +4 -4
- package/node/locales/itIT.js +4 -4
- package/node/locales/jaJP.js +4 -4
- package/node/locales/koKR.js +4 -4
- package/node/locales/nbNO.js +4 -4
- package/node/locales/plPL.js +4 -4
- package/node/locales/ptBR.js +4 -4
- package/node/locales/roRO.js +4 -4
- package/node/locales/ruRU.js +4 -4
- package/node/locales/skSK.js +4 -4
- package/node/locales/svSE.js +4 -4
- package/node/locales/trTR.js +16 -17
- package/node/locales/ukUA.js +4 -4
- package/node/locales/urPK.js +4 -4
- package/node/locales/viVN.js +4 -4
- package/node/locales/zhCN.js +4 -4
- package/node/locales/zhTW.js +4 -4
- package/node/utils/EventManager.js +2 -2
- package/node/utils/Store.js +31 -0
- package/node/utils/doesSupportPreventScroll.js +19 -0
- package/node/utils/fastMemo.js +13 -0
- package/node/utils/fastObjectShallowCompare.js +38 -0
- package/node/utils/keyboardUtils.js +4 -2
- package/package.json +1 -1
- package/themeAugmentation/overrides.d.ts +1 -1
- package/utils/EventManager.js +2 -2
- package/utils/Store.d.ts +11 -0
- package/utils/Store.js +24 -0
- package/utils/doesSupportPreventScroll.d.ts +1 -0
- package/utils/doesSupportPreventScroll.js +13 -0
- package/utils/fastMemo.d.ts +1 -0
- package/utils/fastMemo.js +5 -0
- package/utils/fastObjectShallowCompare.d.ts +1 -0
- package/utils/fastObjectShallowCompare.js +32 -0
- package/utils/keyboardUtils.js +4 -2
|
@@ -183,22 +183,26 @@ export const buildAggregatedFilterApplier = (filterModel, apiRef) => {
|
|
|
183
183
|
passingQuickFilterValues: isRowMatchingQuickFilter && isRowMatchingQuickFilter(rowId, shouldApplyFilter)
|
|
184
184
|
});
|
|
185
185
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
186
|
+
const isNotNull = result => result != null;
|
|
187
|
+
const filterModelItems = (cache, apiRef, items) => {
|
|
188
|
+
if (!cache.cleanedFilterItems) {
|
|
189
|
+
cache.cleanedFilterItems = items.filter(item => getFilterCallbackFromItem(item, apiRef) !== null);
|
|
190
|
+
}
|
|
191
|
+
return cache.cleanedFilterItems;
|
|
192
|
+
};
|
|
193
|
+
export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, filterModel, apiRef, cache) => {
|
|
194
|
+
const cleanedFilterItems = filterModelItems(cache, apiRef, filterModel.items);
|
|
195
|
+
const cleanedFilterItemResults = allFilterItemResults.filter(isNotNull);
|
|
196
|
+
const cleanedQuickFilterResults = allQuickFilterResults.filter(isNotNull);
|
|
195
197
|
|
|
196
198
|
// get result for filter items model
|
|
197
|
-
if (
|
|
199
|
+
if (cleanedFilterItemResults.length > 0) {
|
|
200
|
+
var _filterModel$logicOpe;
|
|
198
201
|
// Return true if the item pass with one of the rows
|
|
199
202
|
const filterItemPredicate = item => {
|
|
200
|
-
return
|
|
203
|
+
return cleanedFilterItemResults.some(filterItemResult => filterItemResult[item.id]);
|
|
201
204
|
};
|
|
205
|
+
const logicOperator = (_filterModel$logicOpe = filterModel.logicOperator) != null ? _filterModel$logicOpe : getDefaultGridFilterModel().logicOperator;
|
|
202
206
|
if (logicOperator === GridLogicOperator.And) {
|
|
203
207
|
const passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
|
|
204
208
|
if (!passesAllFilters) {
|
|
@@ -213,11 +217,13 @@ export const passFilterLogic = (allFilterItemResults, allQuickFilterResults, fil
|
|
|
213
217
|
}
|
|
214
218
|
|
|
215
219
|
// get result for quick filter model
|
|
216
|
-
if (
|
|
220
|
+
if (cleanedQuickFilterResults.length > 0 && filterModel.quickFilterValues != null) {
|
|
221
|
+
var _filterModel$quickFil;
|
|
217
222
|
// Return true if the item pass with one of the rows
|
|
218
223
|
const quickFilterValuePredicate = value => {
|
|
219
|
-
return
|
|
224
|
+
return cleanedQuickFilterResults.some(quickFilterValueResult => quickFilterValueResult[value]);
|
|
220
225
|
};
|
|
226
|
+
const quickFilterLogicOperator = (_filterModel$quickFil = filterModel.quickFilterLogicOperator) != null ? _filterModel$quickFil : getDefaultGridFilterModel().quickFilterLogicOperator;
|
|
221
227
|
if (quickFilterLogicOperator === GridLogicOperator.And) {
|
|
222
228
|
const passesAllQuickFilterValues = filterModel.quickFilterValues.every(quickFilterValuePredicate);
|
|
223
229
|
if (!passesAllQuickFilterValues) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
3
4
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
4
5
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
5
6
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
@@ -260,6 +261,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
260
261
|
const tree = gridRowTreeSelector(apiRef);
|
|
261
262
|
const rowIds = tree[GRID_ROOT_GROUP_ID].children;
|
|
262
263
|
const filteredRowsLookup = {};
|
|
264
|
+
const filterCache = {};
|
|
263
265
|
for (let i = 0; i < rowIds.length; i += 1) {
|
|
264
266
|
const rowId = rowIds[i];
|
|
265
267
|
let isRowPassing;
|
|
@@ -270,7 +272,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
270
272
|
passingFilterItems,
|
|
271
273
|
passingQuickFilterValues
|
|
272
274
|
} = params.isRowMatchingFilters(rowId);
|
|
273
|
-
isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef);
|
|
275
|
+
isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef, filterCache);
|
|
274
276
|
}
|
|
275
277
|
filteredRowsLookup[rowId] = isRowPassing;
|
|
276
278
|
}
|
|
@@ -336,7 +338,7 @@ export const useGridFilter = (apiRef, props) => {
|
|
|
336
338
|
/**
|
|
337
339
|
* EFFECTS
|
|
338
340
|
*/
|
|
339
|
-
|
|
341
|
+
useEnhancedEffect(() => {
|
|
340
342
|
if (props.filterModel !== undefined) {
|
|
341
343
|
apiRef.current.setFilterModel(props.filterModel);
|
|
342
344
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { unstable_ownerDocument as ownerDocument } from '@mui/utils';
|
|
4
|
+
import { gridClasses } from '../../../constants/gridClasses';
|
|
4
5
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
5
6
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
6
7
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
@@ -236,7 +237,6 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
236
237
|
}
|
|
237
238
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
238
239
|
}, [apiRef]);
|
|
239
|
-
const focussedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
240
240
|
const handleColumnGroupHeaderFocus = React.useCallback(({
|
|
241
241
|
fields,
|
|
242
242
|
depth
|
|
@@ -244,13 +244,18 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
244
244
|
if (event.target !== event.currentTarget) {
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
|
-
|
|
247
|
+
const focusedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
248
|
+
if (focusedColumnGroup !== null && focusedColumnGroup.depth === depth && fields.includes(focusedColumnGroup.field)) {
|
|
248
249
|
// This group cell has already been focused
|
|
249
250
|
return;
|
|
250
251
|
}
|
|
251
252
|
apiRef.current.setColumnGroupHeaderFocus(fields[0], depth, event);
|
|
252
|
-
}, [apiRef
|
|
253
|
-
const handleBlur = React.useCallback(() => {
|
|
253
|
+
}, [apiRef]);
|
|
254
|
+
const handleBlur = React.useCallback((_, event) => {
|
|
255
|
+
var _event$relatedTarget;
|
|
256
|
+
if ((_event$relatedTarget = event.relatedTarget) != null && _event$relatedTarget.className.includes(gridClasses.columnHeader)) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
254
259
|
logger.debug(`Clearing focus`);
|
|
255
260
|
apiRef.current.setState(state => _extends({}, state, {
|
|
256
261
|
focus: {
|
|
@@ -350,6 +355,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
350
355
|
};
|
|
351
356
|
}, [apiRef, handleDocumentClick]);
|
|
352
357
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
358
|
+
useGridApiEventHandler(apiRef, 'headerFilterBlur', handleBlur);
|
|
353
359
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
354
360
|
useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
355
361
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
@@ -13,7 +13,6 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
|
|
|
13
13
|
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
14
14
|
import { unstable_gridFocusColumnGroupHeaderSelector } from '../focus';
|
|
15
15
|
import { gridColumnGroupsHeaderMaxDepthSelector } from '../columnGrouping/gridColumnGroupsSelector';
|
|
16
|
-
import { useGridSelector } from '../../utils/useGridSelector';
|
|
17
16
|
import { unstable_gridHeaderFilteringEditFieldSelector, unstable_gridHeaderFilteringMenuSelector } from '../headerFiltering/gridHeaderFilteringSelectors';
|
|
18
17
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
19
18
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
@@ -322,12 +321,12 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
322
321
|
event.preventDefault();
|
|
323
322
|
}
|
|
324
323
|
}, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
|
|
325
|
-
const focusedColumnGroup = useGridSelector(apiRef, unstable_gridFocusColumnGroupHeaderSelector);
|
|
326
324
|
const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
|
|
327
325
|
const dimensions = apiRef.current.getRootDimensions();
|
|
328
326
|
if (!dimensions) {
|
|
329
327
|
return;
|
|
330
328
|
}
|
|
329
|
+
const focusedColumnGroup = unstable_gridFocusColumnGroupHeaderSelector(apiRef);
|
|
331
330
|
if (focusedColumnGroup === null) {
|
|
332
331
|
return;
|
|
333
332
|
}
|
|
@@ -411,7 +410,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
411
410
|
if (shouldPreventDefault) {
|
|
412
411
|
event.preventDefault();
|
|
413
412
|
}
|
|
414
|
-
}, [apiRef,
|
|
413
|
+
}, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
415
414
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
416
415
|
// Ignore portal
|
|
417
416
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -2,11 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from '../../../utils/domUtils';
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
4
|
import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
|
|
5
|
-
|
|
6
|
-
function warnMissingColumn(field) {
|
|
7
|
-
console.warn([`MUI: You are calling getValue('${field}') but the column \`${field}\` is not defined.`, `Instead, you can access the data from \`params.row.${field}\`.`].join('\n'));
|
|
8
|
-
warnedOnceMissingColumn = true;
|
|
9
|
-
}
|
|
5
|
+
export class MissingRowIdError extends Error {}
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* @requires useGridColumns (method)
|
|
@@ -24,7 +20,7 @@ export function useGridParamsApi(apiRef) {
|
|
|
24
20
|
const getRowParams = React.useCallback(id => {
|
|
25
21
|
const row = apiRef.current.getRow(id);
|
|
26
22
|
if (!row) {
|
|
27
|
-
throw new
|
|
23
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
28
24
|
}
|
|
29
25
|
const params = {
|
|
30
26
|
id,
|
|
@@ -37,7 +33,7 @@ export function useGridParamsApi(apiRef) {
|
|
|
37
33
|
const row = apiRef.current.getRow(id);
|
|
38
34
|
const rowNode = apiRef.current.getRowNode(id);
|
|
39
35
|
if (!row || !rowNode) {
|
|
40
|
-
throw new
|
|
36
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
41
37
|
}
|
|
42
38
|
const cellFocus = gridFocusCellSelector(apiRef);
|
|
43
39
|
const cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
@@ -61,7 +57,7 @@ export function useGridParamsApi(apiRef) {
|
|
|
61
57
|
const row = apiRef.current.getRow(id);
|
|
62
58
|
const rowNode = apiRef.current.getRowNode(id);
|
|
63
59
|
if (!row || !rowNode) {
|
|
64
|
-
throw new
|
|
60
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
65
61
|
}
|
|
66
62
|
const cellFocus = gridFocusCellSelector(apiRef);
|
|
67
63
|
const cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
@@ -75,7 +71,8 @@ export function useGridParamsApi(apiRef) {
|
|
|
75
71
|
hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
|
|
76
72
|
tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
|
|
77
73
|
value,
|
|
78
|
-
formattedValue: value
|
|
74
|
+
formattedValue: value,
|
|
75
|
+
isEditable: false
|
|
79
76
|
};
|
|
80
77
|
if (colDef && colDef.valueFormatter) {
|
|
81
78
|
params.formattedValue = colDef.valueFormatter({
|
|
@@ -90,15 +87,10 @@ export function useGridParamsApi(apiRef) {
|
|
|
90
87
|
}, [apiRef]);
|
|
91
88
|
const getCellValue = React.useCallback((id, field) => {
|
|
92
89
|
const colDef = apiRef.current.getColumn(field);
|
|
93
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
94
|
-
if (!colDef && !warnedOnceMissingColumn) {
|
|
95
|
-
warnMissingColumn(field);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
90
|
if (!colDef || !colDef.valueGetter) {
|
|
99
91
|
const rowModel = apiRef.current.getRow(id);
|
|
100
92
|
if (!rowModel) {
|
|
101
|
-
throw new
|
|
93
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
102
94
|
}
|
|
103
95
|
return rowModel[field];
|
|
104
96
|
}
|
|
@@ -41,7 +41,7 @@ export const useGridRowsMeta = (apiRef, props) => {
|
|
|
41
41
|
getRowSpacing,
|
|
42
42
|
getEstimatedRowHeight
|
|
43
43
|
} = props;
|
|
44
|
-
const rowsHeightLookup = React.useRef(
|
|
44
|
+
const rowsHeightLookup = React.useRef(Object.create(null));
|
|
45
45
|
|
|
46
46
|
// Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
|
|
47
47
|
const lastMeasuredRowIndex = React.useRef(-1);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
3
4
|
import { isEnterKey } from '../../../utils/keyboardUtils';
|
|
4
5
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
5
6
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
@@ -244,7 +245,7 @@ export const useGridSorting = (apiRef, props) => {
|
|
|
244
245
|
/**
|
|
245
246
|
* EFFECTS
|
|
246
247
|
*/
|
|
247
|
-
|
|
248
|
+
useEnhancedEffect(() => {
|
|
248
249
|
if (props.sortModel !== undefined) {
|
|
249
250
|
apiRef.current.setSortModel(props.sortModel);
|
|
250
251
|
}
|