@mui/x-data-grid 6.3.1 → 6.5.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 +113 -0
- package/DataGrid/DataGrid.js +20 -1
- package/DataGrid/useDataGridComponent.js +2 -2
- package/DataGrid/useDataGridProps.js +8 -13
- package/colDef/gridBooleanColDef.js +19 -1
- package/colDef/gridDateColDef.js +6 -2
- package/colDef/gridNumericOperators.js +0 -6
- package/colDef/gridSingleSelectColDef.js +21 -1
- package/components/base/GridBody.js +2 -1
- package/components/cell/GridEditInputCell.js +4 -1
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +15 -2
- package/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +8 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +11 -4
- package/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/components/panel/filterPanel/GridFilterPanel.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/components/panel/filterPanel/index.d.ts +3 -1
- package/components/panel/filterPanel/index.js +2 -1
- package/constants/localeTextConstants.js +26 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +12 -1
- package/hooks/features/clipboard/useGridClipboard.d.ts +2 -1
- package/hooks/features/clipboard/useGridClipboard.js +43 -26
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +9 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/hooks/features/dimensions/useGridDimensions.js +4 -6
- package/hooks/features/editing/useGridCellEditing.js +7 -3
- package/hooks/features/editing/useGridEditing.js +0 -3
- package/hooks/features/editing/useGridRowEditing.js +7 -3
- package/hooks/features/export/serializers/csvSerializer.d.ts +5 -0
- package/hooks/features/export/serializers/csvSerializer.js +46 -6
- package/hooks/features/export/useGridCsvExport.d.ts +2 -1
- package/hooks/features/export/useGridCsvExport.js +7 -5
- package/hooks/features/focus/gridFocusState.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.d.ts +2 -0
- package/hooks/features/focus/gridFocusStateSelector.js +6 -0
- package/hooks/features/focus/useGridFocus.js +55 -9
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +4 -0
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/hooks/features/headerFiltering/index.d.ts +1 -0
- package/hooks/features/headerFiltering/index.js +1 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +6 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +91 -0
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +2 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
- package/hooks/features/rows/useGridRows.js +16 -1
- package/index.js +1 -1
- package/internals/index.d.ts +9 -3
- package/internals/index.js +7 -2
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/internals/utils/useProps.d.ts +8 -0
- package/internals/utils/useProps.js +13 -0
- package/joy/icons.d.ts +33 -0
- package/joy/icons.js +433 -0
- package/joy/joySlots.js +114 -4
- package/legacy/DataGrid/DataGrid.js +20 -1
- package/legacy/DataGrid/useDataGridComponent.js +2 -2
- package/legacy/DataGrid/useDataGridProps.js +11 -9
- package/legacy/colDef/gridBooleanColDef.js +21 -1
- package/legacy/colDef/gridDateColDef.js +10 -2
- package/legacy/colDef/gridNumericOperators.js +0 -6
- package/legacy/colDef/gridSingleSelectColDef.js +21 -1
- package/legacy/components/base/GridBody.js +2 -1
- package/legacy/components/cell/GridEditInputCell.js +4 -1
- package/legacy/components/containers/GridRootStyles.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +79 -35
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +26 -5
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +54 -31
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +28 -5
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/legacy/components/panel/filterPanel/index.js +2 -1
- package/legacy/constants/localeTextConstants.js +26 -0
- package/legacy/hooks/features/clipboard/useGridClipboard.js +44 -26
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -5
- package/legacy/hooks/features/dimensions/useGridDimensions.js +4 -6
- package/legacy/hooks/features/editing/useGridCellEditing.js +7 -3
- package/legacy/hooks/features/editing/useGridEditing.js +0 -3
- package/legacy/hooks/features/editing/useGridRowEditing.js +7 -3
- package/legacy/hooks/features/export/serializers/csvSerializer.js +43 -6
- package/legacy/hooks/features/export/useGridCsvExport.js +8 -5
- package/legacy/hooks/features/focus/gridFocusStateSelector.js +10 -0
- package/legacy/hooks/features/focus/useGridFocus.js +58 -9
- package/legacy/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +11 -0
- package/legacy/hooks/features/headerFiltering/index.js +1 -0
- package/legacy/hooks/features/headerFiltering/useGridHeaderFiltering.js +93 -0
- package/legacy/hooks/features/index.js +2 -1
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +123 -4
- package/legacy/hooks/features/rows/useGridRows.js +16 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +7 -2
- package/legacy/internals/utils/index.js +2 -1
- package/legacy/internals/utils/useProps.js +11 -0
- package/legacy/joy/icons.js +432 -0
- package/legacy/joy/joySlots.js +118 -4
- package/legacy/locales/arSD.js +28 -0
- package/legacy/locales/beBY.js +28 -0
- package/legacy/locales/bgBG.js +28 -0
- package/legacy/locales/csCZ.js +36 -8
- package/legacy/locales/daDK.js +28 -0
- package/legacy/locales/deDE.js +30 -2
- package/legacy/locales/elGR.js +27 -0
- package/legacy/locales/esES.js +28 -0
- package/legacy/locales/faIR.js +28 -0
- package/legacy/locales/fiFI.js +28 -0
- package/legacy/locales/frFR.js +34 -6
- package/legacy/locales/heIL.js +30 -2
- package/legacy/locales/huHU.js +28 -0
- package/legacy/locales/itIT.js +28 -0
- package/legacy/locales/jaJP.js +28 -0
- package/legacy/locales/koKR.js +28 -0
- package/legacy/locales/nbNO.js +28 -0
- package/legacy/locales/nlNL.js +28 -0
- package/legacy/locales/plPL.js +28 -0
- package/legacy/locales/ptBR.js +29 -1
- package/legacy/locales/roRO.js +28 -0
- package/legacy/locales/ruRU.js +28 -0
- package/legacy/locales/skSK.js +28 -0
- package/legacy/locales/svSE.js +28 -0
- package/legacy/locales/trTR.js +28 -0
- package/legacy/locales/ukUA.js +36 -9
- package/legacy/locales/urPK.js +28 -0
- package/legacy/locales/viVN.js +27 -0
- package/legacy/locales/zhCN.js +28 -0
- package/legacy/locales/zhTW.js +28 -0
- package/legacy/material/index.js +5 -1
- package/legacy/models/api/index.js +0 -1
- package/legacy/models/index.js +0 -1
- package/legacy/utils/domUtils.js +14 -1
- package/locales/arSD.js +28 -0
- package/locales/beBY.js +28 -0
- package/locales/bgBG.js +28 -0
- package/locales/csCZ.js +36 -8
- package/locales/daDK.js +28 -0
- package/locales/deDE.js +30 -2
- package/locales/elGR.js +27 -0
- package/locales/esES.js +28 -0
- package/locales/faIR.js +28 -0
- package/locales/fiFI.js +28 -0
- package/locales/frFR.js +34 -6
- package/locales/heIL.js +30 -2
- package/locales/huHU.js +28 -0
- package/locales/itIT.js +28 -0
- package/locales/jaJP.js +28 -0
- package/locales/koKR.js +28 -0
- package/locales/nbNO.js +28 -0
- package/locales/nlNL.js +28 -0
- package/locales/plPL.js +28 -0
- package/locales/ptBR.js +29 -1
- package/locales/roRO.js +28 -0
- package/locales/ruRU.js +28 -0
- package/locales/skSK.js +28 -0
- package/locales/svSE.js +28 -0
- package/locales/trTR.js +28 -0
- package/locales/ukUA.js +36 -9
- package/locales/urPK.js +28 -0
- package/locales/viVN.js +27 -0
- package/locales/zhCN.js +28 -0
- package/locales/zhTW.js +28 -0
- package/material/index.d.ts +3 -65
- package/material/index.js +5 -1
- package/models/api/gridApiCommon.d.ts +3 -3
- package/models/api/gridCoreApi.d.ts +8 -0
- package/models/api/gridFocusApi.d.ts +6 -0
- package/models/api/gridHeaderFilteringApi.d.ts +30 -0
- package/models/api/gridLocaleTextApi.d.ts +25 -0
- package/models/api/index.d.ts +0 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +33 -1
- package/models/gridFilterOperator.d.ts +4 -0
- package/models/gridHeaderFilteringModel.d.ts +5 -0
- package/models/gridHeaderFilteringModel.js +1 -0
- package/models/gridSlotsComponent.d.ts +21 -4
- package/models/gridSlotsComponentsProps.d.ts +4 -0
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/index.d.ts +1 -1
- package/models/index.js +0 -1
- package/models/props/DataGridProps.d.ts +19 -0
- package/modern/DataGrid/DataGrid.js +20 -1
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/DataGrid/useDataGridProps.js +8 -13
- package/modern/colDef/gridBooleanColDef.js +19 -1
- package/modern/colDef/gridDateColDef.js +6 -2
- package/modern/colDef/gridNumericOperators.js +0 -6
- package/modern/colDef/gridSingleSelectColDef.js +21 -1
- package/modern/components/base/GridBody.js +2 -1
- package/modern/components/cell/GridEditInputCell.js +4 -1
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +80 -36
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/modern/components/panel/filterPanel/GridFilterPanel.js +1 -1
- package/modern/components/panel/filterPanel/index.js +2 -1
- package/modern/constants/localeTextConstants.js +26 -0
- package/modern/hooks/features/clipboard/useGridClipboard.js +43 -26
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -5
- package/modern/hooks/features/editing/useGridCellEditing.js +7 -3
- package/modern/hooks/features/editing/useGridEditing.js +0 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -3
- package/modern/hooks/features/export/serializers/csvSerializer.js +44 -6
- package/modern/hooks/features/export/useGridCsvExport.js +7 -5
- package/modern/hooks/features/focus/gridFocusStateSelector.js +6 -0
- package/modern/hooks/features/focus/useGridFocus.js +55 -9
- package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +5 -0
- package/modern/hooks/features/headerFiltering/index.js +1 -0
- package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +90 -0
- package/modern/hooks/features/index.js +2 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
- package/modern/hooks/features/rows/useGridRows.js +16 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +7 -2
- package/modern/internals/utils/index.js +2 -1
- package/modern/internals/utils/useProps.js +13 -0
- package/modern/joy/icons.js +433 -0
- package/modern/joy/joySlots.js +110 -4
- package/modern/locales/arSD.js +28 -0
- package/modern/locales/beBY.js +28 -0
- package/modern/locales/bgBG.js +28 -0
- package/modern/locales/csCZ.js +36 -8
- package/modern/locales/daDK.js +28 -0
- package/modern/locales/deDE.js +30 -2
- package/modern/locales/elGR.js +27 -0
- package/modern/locales/esES.js +28 -0
- package/modern/locales/faIR.js +28 -0
- package/modern/locales/fiFI.js +28 -0
- package/modern/locales/frFR.js +34 -6
- package/modern/locales/heIL.js +30 -2
- package/modern/locales/huHU.js +28 -0
- package/modern/locales/itIT.js +28 -0
- package/modern/locales/jaJP.js +28 -0
- package/modern/locales/koKR.js +28 -0
- package/modern/locales/nbNO.js +28 -0
- package/modern/locales/nlNL.js +28 -0
- package/modern/locales/plPL.js +28 -0
- package/modern/locales/ptBR.js +29 -1
- package/modern/locales/roRO.js +28 -0
- package/modern/locales/ruRU.js +28 -0
- package/modern/locales/skSK.js +28 -0
- package/modern/locales/svSE.js +28 -0
- package/modern/locales/trTR.js +28 -0
- package/modern/locales/ukUA.js +36 -9
- package/modern/locales/urPK.js +28 -0
- package/modern/locales/viVN.js +27 -0
- package/modern/locales/zhCN.js +28 -0
- package/modern/locales/zhTW.js +28 -0
- package/modern/material/index.js +5 -1
- package/modern/models/api/gridHeaderFilteringApi.js +1 -0
- package/modern/models/api/index.js +0 -1
- package/modern/models/gridHeaderFilteringModel.js +1 -0
- package/modern/models/index.js +0 -1
- package/modern/utils/domUtils.js +13 -1
- package/node/DataGrid/DataGrid.js +20 -1
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/DataGrid/useDataGridProps.js +7 -12
- package/node/colDef/gridBooleanColDef.js +19 -1
- package/node/colDef/gridDateColDef.js +6 -2
- package/node/colDef/gridNumericOperators.js +0 -6
- package/node/colDef/gridSingleSelectColDef.js +21 -1
- package/node/components/base/GridBody.js +2 -1
- package/node/components/cell/GridEditInputCell.js +4 -1
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +78 -35
- package/node/components/panel/filterPanel/GridFilterInputDate.js +27 -6
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -2
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -2
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +55 -32
- package/node/components/panel/filterPanel/GridFilterInputValue.js +29 -6
- package/node/components/panel/filterPanel/GridFilterPanel.js +2 -1
- package/node/components/panel/filterPanel/index.js +26 -8
- package/node/constants/localeTextConstants.js +26 -0
- package/node/hooks/features/clipboard/useGridClipboard.js +42 -25
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +4 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
- package/node/hooks/features/editing/useGridCellEditing.js +7 -3
- package/node/hooks/features/editing/useGridEditing.js +0 -3
- package/node/hooks/features/editing/useGridRowEditing.js +7 -3
- package/node/hooks/features/export/serializers/csvSerializer.js +46 -6
- package/node/hooks/features/export/useGridCsvExport.js +6 -3
- package/node/hooks/features/focus/gridFocusStateSelector.js +9 -1
- package/node/hooks/features/focus/useGridFocus.js +55 -9
- package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +15 -0
- package/node/hooks/features/headerFiltering/index.js +16 -0
- package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +101 -0
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +124 -4
- package/node/hooks/features/rows/useGridRows.js +16 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +69 -1
- package/node/internals/utils/index.js +11 -0
- package/node/internals/utils/useProps.js +22 -0
- package/node/joy/icons.js +471 -0
- package/node/joy/joySlots.js +110 -3
- package/node/locales/arSD.js +28 -0
- package/node/locales/beBY.js +28 -0
- package/node/locales/bgBG.js +28 -0
- package/node/locales/csCZ.js +36 -8
- package/node/locales/daDK.js +28 -0
- package/node/locales/deDE.js +30 -2
- package/node/locales/elGR.js +27 -0
- package/node/locales/esES.js +28 -0
- package/node/locales/faIR.js +28 -0
- package/node/locales/fiFI.js +28 -0
- package/node/locales/frFR.js +34 -6
- package/node/locales/heIL.js +30 -2
- package/node/locales/huHU.js +28 -0
- package/node/locales/itIT.js +28 -0
- package/node/locales/jaJP.js +28 -0
- package/node/locales/koKR.js +28 -0
- package/node/locales/nbNO.js +28 -0
- package/node/locales/nlNL.js +28 -0
- package/node/locales/plPL.js +28 -0
- package/node/locales/ptBR.js +29 -1
- package/node/locales/roRO.js +28 -0
- package/node/locales/ruRU.js +28 -0
- package/node/locales/skSK.js +28 -0
- package/node/locales/svSE.js +28 -0
- package/node/locales/trTR.js +28 -0
- package/node/locales/ukUA.js +36 -9
- package/node/locales/urPK.js +28 -0
- package/node/locales/viVN.js +27 -0
- package/node/locales/zhCN.js +28 -0
- package/node/locales/zhTW.js +28 -0
- package/node/material/index.js +5 -1
- package/node/models/api/index.js +0 -11
- package/node/models/gridHeaderFilteringModel.js +5 -0
- package/node/models/index.js +0 -11
- package/node/utils/domUtils.js +15 -1
- package/package.json +1 -1
- package/utils/domUtils.d.ts +1 -0
- package/utils/domUtils.js +13 -1
- package/models/api/gridClipboardApi.d.ts +0 -11
- /package/legacy/models/api/{gridClipboardApi.js → gridHeaderFilteringApi.js} +0 -0
- /package/{models/api/gridClipboardApi.js → legacy/models/gridHeaderFilteringModel.js} +0 -0
- /package/{modern/models/api/gridClipboardApi.js → models/api/gridHeaderFilteringApi.js} +0 -0
- /package/node/models/api/{gridClipboardApi.js → gridHeaderFilteringApi.js} +0 -0
|
@@ -16,17 +16,20 @@ var _gridFocusStateSelector = require("./gridFocusStateSelector");
|
|
|
16
16
|
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
17
17
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
18
18
|
var _utils2 = require("../../../utils/utils");
|
|
19
|
+
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
19
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
22
|
const focusStateInitializer = state => (0, _extends2.default)({}, state, {
|
|
22
23
|
focus: {
|
|
23
24
|
cell: null,
|
|
24
25
|
columnHeader: null,
|
|
26
|
+
columnHeaderFilter: null,
|
|
25
27
|
columnGroupHeader: null
|
|
26
28
|
},
|
|
27
29
|
tabIndex: {
|
|
28
30
|
cell: null,
|
|
29
31
|
columnHeader: null,
|
|
32
|
+
columnHeaderFilter: null,
|
|
30
33
|
columnGroupHeader: null
|
|
31
34
|
}
|
|
32
35
|
});
|
|
@@ -62,6 +65,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
62
65
|
field
|
|
63
66
|
},
|
|
64
67
|
columnHeader: null,
|
|
68
|
+
columnHeaderFilter: null,
|
|
65
69
|
columnGroupHeader: null
|
|
66
70
|
},
|
|
67
71
|
focus: {
|
|
@@ -70,6 +74,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
70
74
|
field
|
|
71
75
|
},
|
|
72
76
|
columnHeader: null,
|
|
77
|
+
columnHeaderFilter: null,
|
|
73
78
|
columnGroupHeader: null
|
|
74
79
|
}
|
|
75
80
|
});
|
|
@@ -97,6 +102,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
97
102
|
columnHeader: {
|
|
98
103
|
field
|
|
99
104
|
},
|
|
105
|
+
columnHeaderFilter: null,
|
|
100
106
|
cell: null,
|
|
101
107
|
columnGroupHeader: null
|
|
102
108
|
},
|
|
@@ -104,6 +110,33 @@ const useGridFocus = (apiRef, props) => {
|
|
|
104
110
|
columnHeader: {
|
|
105
111
|
field
|
|
106
112
|
},
|
|
113
|
+
columnHeaderFilter: null,
|
|
114
|
+
cell: null,
|
|
115
|
+
columnGroupHeader: null
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
apiRef.current.forceUpdate();
|
|
120
|
+
}, [apiRef, logger, publishCellFocusOut]);
|
|
121
|
+
const setColumnHeaderFilterFocus = React.useCallback((field, event = {}) => {
|
|
122
|
+
const cell = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
|
|
123
|
+
publishCellFocusOut(cell, event);
|
|
124
|
+
apiRef.current.setState(state => {
|
|
125
|
+
logger.debug(`Focusing on column header filter with colIndex=${field}`);
|
|
126
|
+
return (0, _extends2.default)({}, state, {
|
|
127
|
+
tabIndex: {
|
|
128
|
+
columnHeader: null,
|
|
129
|
+
columnHeaderFilter: {
|
|
130
|
+
field
|
|
131
|
+
},
|
|
132
|
+
cell: null,
|
|
133
|
+
columnGroupHeader: null
|
|
134
|
+
},
|
|
135
|
+
focus: {
|
|
136
|
+
columnHeader: null,
|
|
137
|
+
columnHeaderFilter: {
|
|
138
|
+
field
|
|
139
|
+
},
|
|
107
140
|
cell: null,
|
|
108
141
|
columnGroupHeader: null
|
|
109
142
|
}
|
|
@@ -124,6 +157,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
124
157
|
depth
|
|
125
158
|
},
|
|
126
159
|
columnHeader: null,
|
|
160
|
+
columnHeaderFilter: null,
|
|
127
161
|
cell: null
|
|
128
162
|
},
|
|
129
163
|
focus: {
|
|
@@ -132,6 +166,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
132
166
|
depth
|
|
133
167
|
},
|
|
134
168
|
columnHeader: null,
|
|
169
|
+
columnHeaderFilter: null,
|
|
135
170
|
cell: null
|
|
136
171
|
}
|
|
137
172
|
});
|
|
@@ -141,8 +176,16 @@ const useGridFocus = (apiRef, props) => {
|
|
|
141
176
|
const getColumnGroupHeaderFocus = React.useCallback(() => (0, _gridFocusStateSelector.unstable_gridFocusColumnGroupHeaderSelector)(apiRef), [apiRef]);
|
|
142
177
|
const moveFocusToRelativeCell = React.useCallback((id, field, direction) => {
|
|
143
178
|
let columnIndexToFocus = apiRef.current.getColumnIndex(field);
|
|
144
|
-
let rowIndexToFocus = apiRef.current.getRowIndexRelativeToVisibleRows(id);
|
|
145
179
|
const visibleColumns = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
|
|
180
|
+
const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef, {
|
|
181
|
+
pagination: props.pagination,
|
|
182
|
+
paginationMode: props.paginationMode
|
|
183
|
+
});
|
|
184
|
+
const pinnedRows = (0, _gridRowsSelector.gridPinnedRowsSelector)(apiRef);
|
|
185
|
+
|
|
186
|
+
// Include pinned rows as well
|
|
187
|
+
const currentPageRows = [].concat(pinnedRows.top || [], currentPage.rows, pinnedRows.bottom || []);
|
|
188
|
+
let rowIndexToFocus = currentPageRows.findIndex(row => row.id === id);
|
|
146
189
|
if (direction === 'right') {
|
|
147
190
|
columnIndexToFocus += 1;
|
|
148
191
|
} else if (direction === 'left') {
|
|
@@ -150,14 +193,10 @@ const useGridFocus = (apiRef, props) => {
|
|
|
150
193
|
} else {
|
|
151
194
|
rowIndexToFocus += 1;
|
|
152
195
|
}
|
|
153
|
-
const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef, {
|
|
154
|
-
pagination: props.pagination,
|
|
155
|
-
paginationMode: props.paginationMode
|
|
156
|
-
});
|
|
157
196
|
if (columnIndexToFocus >= visibleColumns.length) {
|
|
158
197
|
// Go to next row if we are after the last column
|
|
159
198
|
rowIndexToFocus += 1;
|
|
160
|
-
if (rowIndexToFocus <
|
|
199
|
+
if (rowIndexToFocus < currentPageRows.length) {
|
|
161
200
|
// Go to first column of the next row if there's one more row
|
|
162
201
|
columnIndexToFocus = 0;
|
|
163
202
|
}
|
|
@@ -169,8 +208,11 @@ const useGridFocus = (apiRef, props) => {
|
|
|
169
208
|
columnIndexToFocus = visibleColumns.length - 1;
|
|
170
209
|
}
|
|
171
210
|
}
|
|
172
|
-
rowIndexToFocus = (0, _utils2.clamp)(rowIndexToFocus, 0,
|
|
173
|
-
const rowToFocus =
|
|
211
|
+
rowIndexToFocus = (0, _utils2.clamp)(rowIndexToFocus, 0, currentPageRows.length - 1);
|
|
212
|
+
const rowToFocus = currentPageRows[rowIndexToFocus];
|
|
213
|
+
if (!rowToFocus) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
174
216
|
const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
175
217
|
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
176
218
|
if (direction === 'left' || direction === 'below') {
|
|
@@ -224,6 +266,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
224
266
|
focus: {
|
|
225
267
|
cell: null,
|
|
226
268
|
columnHeader: null,
|
|
269
|
+
columnHeaderFilter: null,
|
|
227
270
|
columnGroupHeader: null
|
|
228
271
|
}
|
|
229
272
|
}));
|
|
@@ -262,6 +305,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
262
305
|
focus: {
|
|
263
306
|
cell: null,
|
|
264
307
|
columnHeader: null,
|
|
308
|
+
columnHeaderFilter: null,
|
|
265
309
|
columnGroupHeader: null
|
|
266
310
|
}
|
|
267
311
|
}));
|
|
@@ -290,6 +334,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
290
334
|
focus: {
|
|
291
335
|
cell: null,
|
|
292
336
|
columnHeader: null,
|
|
337
|
+
columnHeaderFilter: null,
|
|
293
338
|
columnGroupHeader: null
|
|
294
339
|
}
|
|
295
340
|
}));
|
|
@@ -297,7 +342,8 @@ const useGridFocus = (apiRef, props) => {
|
|
|
297
342
|
}, [apiRef]);
|
|
298
343
|
const focusApi = {
|
|
299
344
|
setCellFocus,
|
|
300
|
-
setColumnHeaderFocus
|
|
345
|
+
setColumnHeaderFocus,
|
|
346
|
+
setColumnHeaderFilterFocus
|
|
301
347
|
};
|
|
302
348
|
const focusPrivateApi = {
|
|
303
349
|
moveFocusToRelativeCell,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unstable_gridHeaderFilteringStateSelector = exports.unstable_gridHeaderFilteringMenuSelector = exports.unstable_gridHeaderFilteringEditFieldSelector = void 0;
|
|
7
|
+
var _createSelector = require("../../../utils/createSelector");
|
|
8
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
9
|
+
|
|
10
|
+
const unstable_gridHeaderFilteringStateSelector = state => state.headerFiltering;
|
|
11
|
+
exports.unstable_gridHeaderFilteringStateSelector = unstable_gridHeaderFilteringStateSelector;
|
|
12
|
+
const unstable_gridHeaderFilteringEditFieldSelector = (0, _createSelector.createSelector)(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.editing);
|
|
13
|
+
exports.unstable_gridHeaderFilteringEditFieldSelector = unstable_gridHeaderFilteringEditFieldSelector;
|
|
14
|
+
const unstable_gridHeaderFilteringMenuSelector = (0, _createSelector.createSelector)(unstable_gridHeaderFilteringStateSelector, headerFilteringState => headerFilteringState.menuOpen);
|
|
15
|
+
exports.unstable_gridHeaderFilteringMenuSelector = unstable_gridHeaderFilteringMenuSelector;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _gridHeaderFilteringSelectors = require("./gridHeaderFilteringSelectors");
|
|
7
|
+
Object.keys(_gridHeaderFilteringSelectors).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _gridHeaderFilteringSelectors[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _gridHeaderFilteringSelectors[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useGridHeaderFiltering = exports.headerFilteringStateInitializer = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
11
|
+
var _utils = require("../../utils");
|
|
12
|
+
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
const headerFilteringStateInitializer = state => (0, _extends2.default)({}, state, {
|
|
16
|
+
headerFiltering: {
|
|
17
|
+
editing: null,
|
|
18
|
+
menuOpen: null
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
exports.headerFilteringStateInitializer = headerFilteringStateInitializer;
|
|
22
|
+
const useGridHeaderFiltering = (apiRef, props) => {
|
|
23
|
+
const logger = (0, _utils.useGridLogger)(apiRef, 'useGridHeaderFiltering');
|
|
24
|
+
const setHeaderFilterState = React.useCallback(headerFilterState => {
|
|
25
|
+
apiRef.current.setState(state => {
|
|
26
|
+
// Safety check to avoid MIT users from using it
|
|
27
|
+
// This hook should ultimately be moved to the Pro package
|
|
28
|
+
if (props.signature === 'DataGrid') {
|
|
29
|
+
return state;
|
|
30
|
+
}
|
|
31
|
+
return (0, _extends2.default)({}, state, {
|
|
32
|
+
headerFiltering: {
|
|
33
|
+
editing: headerFilterState.editing ?? null,
|
|
34
|
+
menuOpen: headerFilterState.menuOpen ?? null
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
apiRef.current.forceUpdate();
|
|
39
|
+
}, [apiRef, props.signature]);
|
|
40
|
+
const startHeaderFilterEditMode = React.useCallback(field => {
|
|
41
|
+
logger.debug(`Starting edit mode on header filter for field: ${field}`);
|
|
42
|
+
apiRef.current.setHeaderFilterState({
|
|
43
|
+
editing: field
|
|
44
|
+
});
|
|
45
|
+
}, [apiRef, logger]);
|
|
46
|
+
const stopHeaderFilterEditMode = React.useCallback(() => {
|
|
47
|
+
logger.debug(`Stopping edit mode on header filter`);
|
|
48
|
+
apiRef.current.setHeaderFilterState({
|
|
49
|
+
editing: null
|
|
50
|
+
});
|
|
51
|
+
}, [apiRef, logger]);
|
|
52
|
+
const showHeaderFilterMenu = React.useCallback(field => {
|
|
53
|
+
logger.debug(`Opening header filter menu for field: ${field}`);
|
|
54
|
+
apiRef.current.setHeaderFilterState({
|
|
55
|
+
menuOpen: field
|
|
56
|
+
});
|
|
57
|
+
}, [apiRef, logger]);
|
|
58
|
+
const hideHeaderFilterMenu = React.useCallback(() => {
|
|
59
|
+
logger.debug(`Hiding header filter menu for active field`);
|
|
60
|
+
let fieldToFocus = apiRef.current.state.headerFiltering.menuOpen;
|
|
61
|
+
if (fieldToFocus) {
|
|
62
|
+
const columnLookup = (0, _gridColumnsSelector.gridColumnLookupSelector)(apiRef);
|
|
63
|
+
const columnVisibilityModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
64
|
+
const orderedFields = (0, _gridColumnsSelector.gridColumnFieldsSelector)(apiRef);
|
|
65
|
+
|
|
66
|
+
// If the column was removed from the grid, we need to find the closest visible field
|
|
67
|
+
if (!columnLookup[fieldToFocus]) {
|
|
68
|
+
fieldToFocus = orderedFields[0];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// If the field to focus is hidden, we need to find the closest visible field
|
|
72
|
+
if (columnVisibilityModel[fieldToFocus] === false) {
|
|
73
|
+
// contains visible column fields + the field that was just hidden
|
|
74
|
+
const visibleOrderedFields = orderedFields.filter(field => {
|
|
75
|
+
if (field === fieldToFocus) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return columnVisibilityModel[field] !== false;
|
|
79
|
+
});
|
|
80
|
+
const fieldIndex = visibleOrderedFields.indexOf(fieldToFocus);
|
|
81
|
+
fieldToFocus = visibleOrderedFields[fieldIndex + 1] || visibleOrderedFields[fieldIndex - 1];
|
|
82
|
+
}
|
|
83
|
+
apiRef.current.setHeaderFilterState({
|
|
84
|
+
menuOpen: null
|
|
85
|
+
});
|
|
86
|
+
apiRef.current.setColumnHeaderFilterFocus(fieldToFocus);
|
|
87
|
+
}
|
|
88
|
+
}, [apiRef, logger]);
|
|
89
|
+
const headerFilterPrivateApi = {
|
|
90
|
+
setHeaderFilterState
|
|
91
|
+
};
|
|
92
|
+
const headerFilterApi = {
|
|
93
|
+
startHeaderFilterEditMode,
|
|
94
|
+
stopHeaderFilterEditMode,
|
|
95
|
+
showHeaderFilterMenu,
|
|
96
|
+
hideHeaderFilterMenu
|
|
97
|
+
};
|
|
98
|
+
(0, _useGridApiMethod.useGridApiMethod)(apiRef, headerFilterApi, 'public');
|
|
99
|
+
(0, _useGridApiMethod.useGridApiMethod)(apiRef, headerFilterPrivateApi, 'private');
|
|
100
|
+
};
|
|
101
|
+
exports.useGridHeaderFiltering = useGridHeaderFiltering;
|
|
@@ -145,4 +145,15 @@ Object.keys(_statePersistence).forEach(function (key) {
|
|
|
145
145
|
return _statePersistence[key];
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
|
+
});
|
|
149
|
+
var _headerFiltering = require("./headerFiltering");
|
|
150
|
+
Object.keys(_headerFiltering).forEach(function (key) {
|
|
151
|
+
if (key === "default" || key === "__esModule") return;
|
|
152
|
+
if (key in exports && exports[key] === _headerFiltering[key]) return;
|
|
153
|
+
Object.defineProperty(exports, key, {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function () {
|
|
156
|
+
return _headerFiltering[key];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
148
159
|
});
|
|
@@ -20,6 +20,8 @@ var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
|
20
20
|
var _focus = require("../focus");
|
|
21
21
|
var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
|
|
22
22
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
23
|
+
var _gridHeaderFilteringSelectors = require("../headerFiltering/gridHeaderFilteringSelectors");
|
|
24
|
+
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
23
25
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
27
|
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
@@ -75,6 +77,9 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
75
77
|
const initialCurrentPageRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props).rows;
|
|
76
78
|
const theme = (0, _styles.useTheme)();
|
|
77
79
|
const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
|
|
80
|
+
const headerFilteringEnabled =
|
|
81
|
+
// @ts-expect-error // TODO move relevant code to the `DataGridPro`
|
|
82
|
+
props.signature !== 'DataGrid' && props.unstable_headerFilters;
|
|
78
83
|
|
|
79
84
|
/**
|
|
80
85
|
* @param {number} colIndex Index of the column to focus
|
|
@@ -111,6 +116,14 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
111
116
|
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
112
117
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
113
118
|
}, [apiRef, logger]);
|
|
119
|
+
const goToHeaderFilter = React.useCallback((colIndex, event) => {
|
|
120
|
+
logger.debug(`Navigating to header filter col ${colIndex}`);
|
|
121
|
+
apiRef.current.scrollToIndexes({
|
|
122
|
+
colIndex
|
|
123
|
+
});
|
|
124
|
+
const field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
125
|
+
apiRef.current.setColumnHeaderFilterFocus(field, event);
|
|
126
|
+
}, [apiRef, logger]);
|
|
114
127
|
const goToGroupHeader = React.useCallback((colIndex, depth, event) => {
|
|
115
128
|
logger.debug(`Navigating to header col ${colIndex}`);
|
|
116
129
|
apiRef.current.scrollToIndexes({
|
|
@@ -122,7 +135,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
122
135
|
apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
|
|
123
136
|
}, [apiRef, logger]);
|
|
124
137
|
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
125
|
-
return currentPageRows[rowIndex].id;
|
|
138
|
+
return currentPageRows?.[rowIndex].id;
|
|
126
139
|
}, [currentPageRows]);
|
|
127
140
|
const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
|
|
128
141
|
const headerTitleNode = event.currentTarget.querySelector(`.${_gridClasses.gridClasses.columnHeaderTitleContainerContent}`);
|
|
@@ -148,7 +161,11 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
148
161
|
case 'ArrowDown':
|
|
149
162
|
{
|
|
150
163
|
if (firstRowIndexInPage !== null) {
|
|
151
|
-
|
|
164
|
+
if (headerFilteringEnabled) {
|
|
165
|
+
goToHeaderFilter(colIndexBefore, event);
|
|
166
|
+
} else {
|
|
167
|
+
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
168
|
+
}
|
|
152
169
|
}
|
|
153
170
|
break;
|
|
154
171
|
}
|
|
@@ -222,7 +239,97 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
222
239
|
if (shouldPreventDefault) {
|
|
223
240
|
event.preventDefault();
|
|
224
241
|
}
|
|
225
|
-
}, [apiRef, currentPageRows.length,
|
|
242
|
+
}, [apiRef, currentPageRows.length, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, theme.direction, goToHeader, goToGroupHeader]);
|
|
243
|
+
const handleHeaderFilterKeyDown = React.useCallback((params, event) => {
|
|
244
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
245
|
+
if (!dimensions) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const isEditing = (0, _gridHeaderFilteringSelectors.unstable_gridHeaderFilteringEditFieldSelector)(apiRef) === params.field;
|
|
249
|
+
const isHeaderMenuOpen = (0, _gridHeaderFilteringSelectors.unstable_gridHeaderFilteringMenuSelector)(apiRef) === params.field;
|
|
250
|
+
if (isEditing || isHeaderMenuOpen || !(0, _keyboardUtils.isNavigationKey)(event.key)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
254
|
+
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
255
|
+
const firstRowIndexInPage = 0;
|
|
256
|
+
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
257
|
+
const firstColIndex = 0;
|
|
258
|
+
const lastColIndex = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef).length - 1;
|
|
259
|
+
let shouldPreventDefault = true;
|
|
260
|
+
switch (event.key) {
|
|
261
|
+
case 'ArrowDown':
|
|
262
|
+
{
|
|
263
|
+
const rowId = getRowIdFromIndex(firstRowIndexInPage);
|
|
264
|
+
if (firstRowIndexInPage !== null && rowId != null) {
|
|
265
|
+
goToCell(colIndexBefore, rowId);
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
case 'ArrowRight':
|
|
270
|
+
{
|
|
271
|
+
const rightColIndex = getRightColumnIndex({
|
|
272
|
+
currentColIndex: colIndexBefore,
|
|
273
|
+
firstColIndex,
|
|
274
|
+
lastColIndex,
|
|
275
|
+
direction: theme.direction
|
|
276
|
+
});
|
|
277
|
+
if (rightColIndex !== null) {
|
|
278
|
+
goToHeaderFilter(rightColIndex, event);
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case 'ArrowLeft':
|
|
283
|
+
{
|
|
284
|
+
const leftColIndex = getLeftColumnIndex({
|
|
285
|
+
currentColIndex: colIndexBefore,
|
|
286
|
+
firstColIndex,
|
|
287
|
+
lastColIndex,
|
|
288
|
+
direction: theme.direction
|
|
289
|
+
});
|
|
290
|
+
if (leftColIndex !== null) {
|
|
291
|
+
goToHeaderFilter(leftColIndex, event);
|
|
292
|
+
} else {
|
|
293
|
+
apiRef.current.setColumnHeaderFilterFocus(params.field, event);
|
|
294
|
+
}
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
case 'ArrowUp':
|
|
298
|
+
{
|
|
299
|
+
goToHeader(colIndexBefore, event);
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
case 'PageDown':
|
|
303
|
+
{
|
|
304
|
+
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
305
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
case 'Home':
|
|
310
|
+
{
|
|
311
|
+
goToHeaderFilter(firstColIndex, event);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case 'End':
|
|
315
|
+
{
|
|
316
|
+
goToHeaderFilter(lastColIndex, event);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
case ' ':
|
|
320
|
+
{
|
|
321
|
+
// prevent Space event from scrolling
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
default:
|
|
325
|
+
{
|
|
326
|
+
shouldPreventDefault = false;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (shouldPreventDefault) {
|
|
330
|
+
event.preventDefault();
|
|
331
|
+
}
|
|
332
|
+
}, [apiRef, currentPageRows.length, goToHeaderFilter, theme.direction, goToHeader, goToCell, getRowIdFromIndex]);
|
|
226
333
|
const focusedColumnGroup = (0, _useGridSelector.useGridSelector)(apiRef, _focus.unstable_gridFocusColumnGroupHeaderSelector);
|
|
227
334
|
const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
|
|
228
335
|
const dimensions = apiRef.current.getRootDimensions();
|
|
@@ -357,6 +464,8 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
357
464
|
{
|
|
358
465
|
if (rowIndexBefore > firstRowIndexInPage) {
|
|
359
466
|
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));
|
|
467
|
+
} else if (headerFilteringEnabled) {
|
|
468
|
+
goToHeaderFilter(colIndexBefore, event);
|
|
360
469
|
} else {
|
|
361
470
|
goToHeader(colIndexBefore, event);
|
|
362
471
|
}
|
|
@@ -457,8 +566,19 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
457
566
|
if (shouldPreventDefault) {
|
|
458
567
|
event.preventDefault();
|
|
459
568
|
}
|
|
460
|
-
}, [apiRef, currentPageRows, theme.direction, getRowIdFromIndex,
|
|
569
|
+
}, [apiRef, currentPageRows, theme.direction, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
|
|
570
|
+
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
571
|
+
event
|
|
572
|
+
}) => {
|
|
573
|
+
if (event.key === ' ') {
|
|
574
|
+
// Space scrolls to the last row
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
return initialValue;
|
|
578
|
+
}, []);
|
|
579
|
+
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'canStartEditing', checkIfCanStartEditing);
|
|
461
580
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderKeyDown', handleColumnHeaderKeyDown);
|
|
581
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'headerFilterKeyDown', handleHeaderFilterKeyDown);
|
|
462
582
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnGroupHeaderKeyDown', handleColumnGroupHeaderKeyDown);
|
|
463
583
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
464
584
|
};
|
|
@@ -125,8 +125,23 @@ const useGridRows = (apiRef, props) => {
|
|
|
125
125
|
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid && updates.length > 1) {
|
|
126
126
|
throw new Error(["MUI: You can't update several rows at once in `apiRef.current.updateRows` on the DataGrid.", 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
|
|
127
127
|
}
|
|
128
|
+
const nonPinnedRowsUpdates = [];
|
|
129
|
+
updates.forEach(update => {
|
|
130
|
+
const id = (0, _gridRowsUtils.getRowIdFromRowModel)(update, props.getRowId, 'A row was provided without id when calling updateRows():');
|
|
131
|
+
const rowNode = apiRef.current.getRowNode(id);
|
|
132
|
+
if (rowNode?.type === 'pinnedRow') {
|
|
133
|
+
// @ts-ignore because otherwise `release:build` doesn't work
|
|
134
|
+
const pinnedRowsCache = apiRef.current.caches.pinnedRows;
|
|
135
|
+
const prevModel = pinnedRowsCache.idLookup[id];
|
|
136
|
+
if (prevModel) {
|
|
137
|
+
pinnedRowsCache.idLookup[id] = (0, _extends2.default)({}, prevModel, update);
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
nonPinnedRowsUpdates.push(update);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
128
143
|
const cache = (0, _gridRowsUtils.updateCacheWithNewRows)({
|
|
129
|
-
updates,
|
|
144
|
+
updates: nonPinnedRowsUpdates,
|
|
130
145
|
getRowId: props.getRowId,
|
|
131
146
|
previousCache: apiRef.current.caches.rows
|
|
132
147
|
});
|
package/node/index.js
CHANGED