@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
|
|
3
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
@@ -9,6 +10,12 @@ import { gridClasses } from '../../../constants/gridClasses';
|
|
|
9
10
|
import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
10
11
|
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
11
12
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
13
|
+
import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
|
|
14
|
+
|
|
15
|
+
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
16
|
+
var pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
17
|
+
return [].concat(_toConsumableArray(pinnedRows.top || []), _toConsumableArray(rows), _toConsumableArray(pinnedRows.bottom || []));
|
|
18
|
+
}
|
|
12
19
|
/**
|
|
13
20
|
* @requires useGridSorting (method) - can be after
|
|
14
21
|
* @requires useGridFilter (state) - can be after
|
|
@@ -19,21 +26,22 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
|
|
|
19
26
|
* @requires useGridColumnSpanning (method) - can be after
|
|
20
27
|
*/
|
|
21
28
|
|
|
29
|
+
|
|
22
30
|
export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef, props) {
|
|
23
31
|
var logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
|
|
24
|
-
var
|
|
32
|
+
var initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
|
|
33
|
+
var currentPageRows = React.useMemo(function () {
|
|
34
|
+
return enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows);
|
|
35
|
+
}, [apiRef, initialCurrentPageRows]);
|
|
25
36
|
/**
|
|
26
37
|
* @param {number} colIndex Index of the column to focus
|
|
27
38
|
* @param {number} rowIndex index of the row to focus
|
|
28
39
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
29
40
|
*/
|
|
30
41
|
|
|
31
|
-
var goToCell = React.useCallback(function (colIndex,
|
|
32
|
-
var _visibleSortedRows$ro;
|
|
33
|
-
|
|
42
|
+
var goToCell = React.useCallback(function (colIndex, rowId) {
|
|
34
43
|
var closestColumnToUse = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'left';
|
|
35
44
|
var visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
36
|
-
var rowId = (_visibleSortedRows$ro = visibleSortedRows[rowIndex]) == null ? void 0 : _visibleSortedRows$ro.id;
|
|
37
45
|
var nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
38
46
|
|
|
39
47
|
if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {
|
|
@@ -42,12 +50,17 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
42
50
|
} else if (closestColumnToUse === 'right') {
|
|
43
51
|
colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
|
|
44
52
|
}
|
|
45
|
-
}
|
|
53
|
+
} // `scrollToIndexes` requires a rowIndex relative to all visible rows.
|
|
54
|
+
// Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
|
|
57
|
+
var rowIndexRelativeToAllRows = visibleSortedRows.findIndex(function (row) {
|
|
58
|
+
return row.id === rowId;
|
|
59
|
+
});
|
|
60
|
+
logger.debug("Navigating to cell row ".concat(rowIndexRelativeToAllRows, ", col ").concat(colIndex));
|
|
48
61
|
apiRef.current.scrollToIndexes({
|
|
49
62
|
colIndex: colIndex,
|
|
50
|
-
rowIndex:
|
|
63
|
+
rowIndex: rowIndexRelativeToAllRows
|
|
51
64
|
});
|
|
52
65
|
var field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
53
66
|
apiRef.current.setCellFocus(rowId, field);
|
|
@@ -60,21 +73,23 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
60
73
|
var field = apiRef.current.getVisibleColumns()[colIndex].field;
|
|
61
74
|
apiRef.current.setColumnHeaderFocus(field, event);
|
|
62
75
|
}, [apiRef, logger]);
|
|
76
|
+
var getRowIdFromIndex = React.useCallback(function (rowIndex) {
|
|
77
|
+
return currentPageRows[rowIndex].id;
|
|
78
|
+
}, [currentPageRows]);
|
|
63
79
|
var handleCellNavigationKeyDown = React.useCallback(function (params, event) {
|
|
64
80
|
var dimensions = apiRef.current.getRootDimensions();
|
|
65
81
|
|
|
66
|
-
if (
|
|
82
|
+
if (currentPageRows.length === 0 || !dimensions) {
|
|
67
83
|
return;
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
var viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
71
|
-
var visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
|
|
72
87
|
var colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
73
|
-
var rowIndexBefore =
|
|
88
|
+
var rowIndexBefore = currentPageRows.findIndex(function (row) {
|
|
74
89
|
return row.id === params.id;
|
|
75
90
|
});
|
|
76
|
-
var firstRowIndexInPage =
|
|
77
|
-
var lastRowIndexInPage =
|
|
91
|
+
var firstRowIndexInPage = 0;
|
|
92
|
+
var lastRowIndexInPage = currentPageRows.length - 1;
|
|
78
93
|
var firstColIndex = 0;
|
|
79
94
|
var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
80
95
|
var shouldPreventDefault = true;
|
|
@@ -85,7 +100,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
85
100
|
{
|
|
86
101
|
// "Enter" is only triggered by the row / cell editing feature
|
|
87
102
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
88
|
-
goToCell(colIndexBefore, rowIndexBefore + 1);
|
|
103
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
break;
|
|
@@ -94,7 +109,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
94
109
|
case 'ArrowUp':
|
|
95
110
|
{
|
|
96
111
|
if (rowIndexBefore > firstRowIndexInPage) {
|
|
97
|
-
goToCell(colIndexBefore, rowIndexBefore - 1);
|
|
112
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));
|
|
98
113
|
} else {
|
|
99
114
|
goToHeader(colIndexBefore, event);
|
|
100
115
|
}
|
|
@@ -105,7 +120,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
105
120
|
case 'ArrowRight':
|
|
106
121
|
{
|
|
107
122
|
if (colIndexBefore < lastColIndex) {
|
|
108
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
123
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
break;
|
|
@@ -114,7 +129,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
114
129
|
case 'ArrowLeft':
|
|
115
130
|
{
|
|
116
131
|
if (colIndexBefore > firstColIndex) {
|
|
117
|
-
goToCell(colIndexBefore - 1, rowIndexBefore);
|
|
132
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore));
|
|
118
133
|
}
|
|
119
134
|
|
|
120
135
|
break;
|
|
@@ -124,9 +139,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
124
139
|
{
|
|
125
140
|
// "Tab" is only triggered by the row / cell editing feature
|
|
126
141
|
if (event.shiftKey && colIndexBefore > firstColIndex) {
|
|
127
|
-
goToCell(colIndexBefore - 1, rowIndexBefore, 'left');
|
|
142
|
+
goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore), 'left');
|
|
128
143
|
} else if (!event.shiftKey && colIndexBefore < lastColIndex) {
|
|
129
|
-
goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
|
|
144
|
+
goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
|
|
130
145
|
}
|
|
131
146
|
|
|
132
147
|
break;
|
|
@@ -147,7 +162,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
147
162
|
}
|
|
148
163
|
|
|
149
164
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
150
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
165
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
151
166
|
}
|
|
152
167
|
|
|
153
168
|
break;
|
|
@@ -156,7 +171,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
156
171
|
case 'PageDown':
|
|
157
172
|
{
|
|
158
173
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
159
|
-
goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
|
|
174
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
break;
|
|
@@ -168,7 +183,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
168
183
|
var nextRowIndex = Math.max(rowIndexBefore - viewportPageSize, firstRowIndexInPage);
|
|
169
184
|
|
|
170
185
|
if (nextRowIndex !== rowIndexBefore && nextRowIndex >= firstRowIndexInPage) {
|
|
171
|
-
goToCell(colIndexBefore, nextRowIndex);
|
|
186
|
+
goToCell(colIndexBefore, getRowIdFromIndex(nextRowIndex));
|
|
172
187
|
} else {
|
|
173
188
|
goToHeader(colIndexBefore, event);
|
|
174
189
|
}
|
|
@@ -179,9 +194,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
179
194
|
case 'Home':
|
|
180
195
|
{
|
|
181
196
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
182
|
-
goToCell(firstColIndex, firstRowIndexInPage);
|
|
197
|
+
goToCell(firstColIndex, getRowIdFromIndex(firstRowIndexInPage));
|
|
183
198
|
} else {
|
|
184
|
-
goToCell(firstColIndex, rowIndexBefore);
|
|
199
|
+
goToCell(firstColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
185
200
|
}
|
|
186
201
|
|
|
187
202
|
break;
|
|
@@ -190,9 +205,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
190
205
|
case 'End':
|
|
191
206
|
{
|
|
192
207
|
if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
193
|
-
goToCell(lastColIndex, lastRowIndexInPage);
|
|
208
|
+
goToCell(lastColIndex, getRowIdFromIndex(lastRowIndexInPage));
|
|
194
209
|
} else {
|
|
195
|
-
goToCell(lastColIndex, rowIndexBefore);
|
|
210
|
+
goToCell(lastColIndex, getRowIdFromIndex(rowIndexBefore));
|
|
196
211
|
}
|
|
197
212
|
|
|
198
213
|
break;
|
|
@@ -207,10 +222,8 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
207
222
|
if (shouldPreventDefault) {
|
|
208
223
|
event.preventDefault();
|
|
209
224
|
}
|
|
210
|
-
}, [apiRef,
|
|
225
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
211
226
|
var handleColumnHeaderKeyDown = React.useCallback(function (params, event) {
|
|
212
|
-
var _currentPage$range$fi, _currentPage$range, _currentPage$range$la, _currentPage$range2;
|
|
213
|
-
|
|
214
227
|
var headerTitleNode = event.currentTarget.querySelector(".".concat(gridClasses.columnHeaderTitleContainerContent));
|
|
215
228
|
var isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
|
|
216
229
|
|
|
@@ -228,8 +241,8 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
228
241
|
|
|
229
242
|
var viewportPageSize = apiRef.current.unstable_getViewportPageSize();
|
|
230
243
|
var colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
231
|
-
var firstRowIndexInPage =
|
|
232
|
-
var lastRowIndexInPage =
|
|
244
|
+
var firstRowIndexInPage = 0;
|
|
245
|
+
var lastRowIndexInPage = currentPageRows.length - 1;
|
|
233
246
|
var firstColIndex = 0;
|
|
234
247
|
var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
|
|
235
248
|
var shouldPreventDefault = true;
|
|
@@ -238,7 +251,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
238
251
|
case 'ArrowDown':
|
|
239
252
|
{
|
|
240
253
|
if (firstRowIndexInPage !== null) {
|
|
241
|
-
goToCell(colIndexBefore, firstRowIndexInPage);
|
|
254
|
+
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
242
255
|
}
|
|
243
256
|
|
|
244
257
|
break;
|
|
@@ -265,7 +278,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
265
278
|
case 'PageDown':
|
|
266
279
|
{
|
|
267
280
|
if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
|
|
268
|
-
goToCell(colIndexBefore, Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage));
|
|
281
|
+
goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
|
|
269
282
|
}
|
|
270
283
|
|
|
271
284
|
break;
|
|
@@ -307,7 +320,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
307
320
|
if (shouldPreventDefault) {
|
|
308
321
|
event.preventDefault();
|
|
309
322
|
}
|
|
310
|
-
}, [apiRef,
|
|
323
|
+
}, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
|
|
311
324
|
var handleCellKeyDown = React.useCallback(function (params, event) {
|
|
312
325
|
// Ignore portal
|
|
313
326
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -4,6 +4,7 @@ import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelecto
|
|
|
4
4
|
import { gridPageSizeSelector } from './gridPaginationSelector';
|
|
5
5
|
import { gridDensityRowHeightSelector } from '../density';
|
|
6
6
|
import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
|
|
7
|
+
import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
|
|
7
8
|
export var defaultPageSize = function defaultPageSize(autoPageSize) {
|
|
8
9
|
return autoPageSize ? 0 : 100;
|
|
9
10
|
};
|
|
@@ -103,7 +104,8 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
|
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
var
|
|
107
|
+
var pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
|
|
108
|
+
var maximumPageSizeWithoutScrollBar = Math.floor((dimensions.viewportInnerSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom) / rowHeight);
|
|
107
109
|
apiRef.current.setPageSize(maximumPageSizeWithoutScrollBar);
|
|
108
110
|
}, [apiRef, props.autoPageSize, rowHeight]);
|
|
109
111
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
@@ -28,4 +28,27 @@ export var gridRowTreeDepthSelector = createSelector(gridRowsStateSelector, func
|
|
|
28
28
|
});
|
|
29
29
|
export var gridRowIdsSelector = createSelector(gridRowsStateSelector, function (rows) {
|
|
30
30
|
return rows.ids;
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* @ignore - do not document.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
export var gridAdditionalRowGroupsSelector = createSelector(gridRowsStateSelector, function (rows) {
|
|
37
|
+
return rows == null ? void 0 : rows.additionalRowGroups;
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* @ignore - do not document.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export var gridPinnedRowsSelector = createSelector(gridAdditionalRowGroupsSelector, function (additionalRowGroups) {
|
|
44
|
+
return additionalRowGroups == null ? void 0 : additionalRowGroups.pinnedRows;
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* @ignore - do not document.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
export var gridPinnedRowsCountSelector = createSelector(gridPinnedRowsSelector, function (pinnedRows) {
|
|
51
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
52
|
+
|
|
53
|
+
return ((pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.length) || 0) + ((pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.length) || 0);
|
|
31
54
|
});
|
|
@@ -2,13 +2,14 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["rowsBeforePartialUpdates"];
|
|
5
|
-
|
|
5
|
+
import { gridPinnedRowsSelector } from './gridRowsSelector';
|
|
6
6
|
/**
|
|
7
7
|
* A helper function to check if the id provided is valid.
|
|
8
8
|
* @param {GridRowId} id Id as [[GridRowId]].
|
|
9
9
|
* @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
|
|
10
10
|
* @param {string} detailErrorMessage A custom error message to display for invalid IDs
|
|
11
11
|
*/
|
|
12
|
+
|
|
12
13
|
export function checkGridRowIdIsValid(id, row) {
|
|
13
14
|
var detailErrorMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'A row was provided without id in the rows prop:';
|
|
14
15
|
|
|
@@ -59,7 +60,7 @@ export var getRowsStateFromCache = function getRowsStateFromCache(_ref2) {
|
|
|
59
60
|
}));
|
|
60
61
|
var processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
|
|
61
62
|
var dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(function (node) {
|
|
62
|
-
return node.parent == null;
|
|
63
|
+
return node.parent == null && !node.isPinned;
|
|
63
64
|
}).length;
|
|
64
65
|
return _extends({}, processedGroupingResponse, {
|
|
65
66
|
groupingResponseBeforeRowHydration: groupingResponse,
|
|
@@ -91,4 +92,21 @@ export var getTreeNodeDescendants = function getTreeNodeDescendants(tree, parent
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
return validDescendants;
|
|
94
|
-
};
|
|
95
|
+
};
|
|
96
|
+
export function calculatePinnedRowsHeight(apiRef) {
|
|
97
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
98
|
+
|
|
99
|
+
var pinnedRows = gridPinnedRowsSelector(apiRef);
|
|
100
|
+
var topPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.reduce(function (acc, value) {
|
|
101
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
102
|
+
return acc;
|
|
103
|
+
}, 0)) || 0;
|
|
104
|
+
var bottomPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.reduce(function (acc, value) {
|
|
105
|
+
acc += apiRef.current.unstable_getRowHeight(value.id);
|
|
106
|
+
return acc;
|
|
107
|
+
}, 0)) || 0;
|
|
108
|
+
return {
|
|
109
|
+
top: topPinnedRowsHeight,
|
|
110
|
+
bottom: bottomPinnedRowsHeight
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './gridRowsMetaSelector';
|
|
2
2
|
export * from './gridRowsMetaState';
|
|
3
|
-
export
|
|
3
|
+
export { gridRowsStateSelector, gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthSelector, gridRowIdsSelector } from './gridRowsSelector';
|
|
4
4
|
export { checkGridRowIdIsValid } from './gridRowsUtils';
|
|
@@ -28,8 +28,11 @@ export var rowsStateInitializer = function rowsStateInitializer(state, props, ap
|
|
|
28
28
|
};
|
|
29
29
|
export var useGridRows = function useGridRows(apiRef, props) {
|
|
30
30
|
if (process.env.NODE_ENV !== 'production') {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
try {
|
|
32
|
+
// Freeze the `rows` prop so developers have a fast failure if they try to use Array.prototype.push().
|
|
33
|
+
Object.freeze(props.rows);
|
|
34
|
+
} catch (error) {// Sometimes, it's impossible to freeze, so we give up on it.
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
var logger = useGridLogger(apiRef, 'useGridRows');
|
|
@@ -9,6 +9,7 @@ import { gridFilterStateSelector } from '../filter/gridFilterSelector';
|
|
|
9
9
|
import { gridPaginationSelector } from '../pagination/gridPaginationSelector';
|
|
10
10
|
import { gridSortingStateSelector } from '../sorting/gridSortingSelector';
|
|
11
11
|
import { useGridRegisterPipeApplier } from '../../core/pipeProcessing';
|
|
12
|
+
import { gridPinnedRowsSelector } from './gridRowsSelector';
|
|
12
13
|
export var rowsMetaStateInitializer = function rowsMetaStateInitializer(state) {
|
|
13
14
|
return _extends({}, state, {
|
|
14
15
|
rowsMeta: {
|
|
@@ -35,13 +36,14 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
|
|
|
35
36
|
var paginationState = useGridSelector(apiRef, gridPaginationSelector);
|
|
36
37
|
var sortingState = useGridSelector(apiRef, gridSortingStateSelector);
|
|
37
38
|
var currentPage = useGridVisibleRows(apiRef, props);
|
|
39
|
+
var pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
38
40
|
var hydrateRowsMeta = React.useCallback(function () {
|
|
41
|
+
var _pinnedRows$top, _pinnedRows$bottom;
|
|
42
|
+
|
|
39
43
|
hasRowWithAutoHeight.current = false;
|
|
40
44
|
var densityFactor = gridDensityFactorSelector(apiRef.current.state, apiRef.current.instanceId);
|
|
41
|
-
var positions = [];
|
|
42
|
-
var currentPageTotalHeight = currentPage.rows.reduce(function (acc, row) {
|
|
43
|
-
positions.push(acc);
|
|
44
45
|
|
|
46
|
+
var calculateRowProcessedSizes = function calculateRowProcessedSizes(row) {
|
|
45
47
|
if (!rowsHeightLookup.current[row.id]) {
|
|
46
48
|
rowsHeightLookup.current[row.id] = {
|
|
47
49
|
sizes: {
|
|
@@ -112,11 +114,24 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
|
|
|
112
114
|
|
|
113
115
|
var processedSizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
|
|
114
116
|
rowsHeightLookup.current[row.id].sizes = processedSizes;
|
|
117
|
+
return processedSizes;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var positions = [];
|
|
121
|
+
var currentPageTotalHeight = currentPage.rows.reduce(function (acc, row) {
|
|
122
|
+
positions.push(acc);
|
|
123
|
+
var processedSizes = calculateRowProcessedSizes(row);
|
|
115
124
|
var finalRowHeight = Object.values(processedSizes).reduce(function (acc2, value) {
|
|
116
125
|
return acc2 + value;
|
|
117
126
|
}, 0);
|
|
118
127
|
return acc + finalRowHeight;
|
|
119
128
|
}, 0);
|
|
129
|
+
pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(function (row) {
|
|
130
|
+
calculateRowProcessedSizes(row);
|
|
131
|
+
});
|
|
132
|
+
pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(function (row) {
|
|
133
|
+
calculateRowProcessedSizes(row);
|
|
134
|
+
});
|
|
120
135
|
apiRef.current.setState(function (state) {
|
|
121
136
|
return _extends({}, state, {
|
|
122
137
|
rowsMeta: {
|
|
@@ -132,7 +147,7 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
|
|
|
132
147
|
}
|
|
133
148
|
|
|
134
149
|
apiRef.current.forceUpdate();
|
|
135
|
-
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight]);
|
|
150
|
+
}, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight, pinnedRows]);
|
|
136
151
|
var getRowHeight = React.useCallback(function (rowId) {
|
|
137
152
|
var height = rowsHeightLookup.current[rowId];
|
|
138
153
|
return height ? height.sizes.base : rowHeightFromDensity;
|
|
@@ -10,7 +10,8 @@ var flatRowTreeCreationMethod = function flatRowTreeCreationMethod(_ref) {
|
|
|
10
10
|
for (var i = 0; i < ids.length; i += 1) {
|
|
11
11
|
var rowId = ids[i];
|
|
12
12
|
|
|
13
|
-
if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null
|
|
13
|
+
if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null && // pinned row can be unpinned
|
|
14
|
+
!previousTree[rowId].isPinned) {
|
|
14
15
|
tree[rowId] = previousTree[rowId];
|
|
15
16
|
} else {
|
|
16
17
|
tree[rowId] = {
|
|
@@ -7,7 +7,8 @@ import { gridPageSelector, gridPageSizeSelector } from '../pagination/gridPagina
|
|
|
7
7
|
import { gridRowCountSelector } from '../rows/gridRowsSelector';
|
|
8
8
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
9
9
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
10
|
-
import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
10
|
+
import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
11
|
+
import { gridClasses } from '../../../constants/gridClasses'; // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
|
|
11
12
|
// Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
|
12
13
|
|
|
13
14
|
function scrollIntoView(dimensions) {
|
|
@@ -87,13 +88,17 @@ export var useGridScroll = function useGridScroll(apiRef, props) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
if (params.rowIndex != null) {
|
|
91
|
+
var _querySelector, _querySelector2;
|
|
92
|
+
|
|
90
93
|
var rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
91
94
|
var page = gridPageSelector(apiRef);
|
|
92
95
|
var pageSize = gridPageSizeSelector(apiRef);
|
|
93
96
|
var elementIndex = !props.pagination ? params.rowIndex : params.rowIndex - page * pageSize;
|
|
94
97
|
var targetOffsetHeight = rowsMeta.positions[elementIndex + 1] ? rowsMeta.positions[elementIndex + 1] - rowsMeta.positions[elementIndex] : rowsMeta.currentPageTotalHeight - rowsMeta.positions[elementIndex];
|
|
98
|
+
var topPinnedRowsHeight = ((_querySelector = windowRef.current.querySelector(".".concat(gridClasses['pinnedRows--top']))) == null ? void 0 : _querySelector.clientHeight) || 0;
|
|
99
|
+
var bottomPinnedRowsHeight = ((_querySelector2 = windowRef.current.querySelector(".".concat(gridClasses['pinnedRows--bottom']))) == null ? void 0 : _querySelector2.clientHeight) || 0;
|
|
95
100
|
scrollCoordinates.top = scrollIntoView({
|
|
96
|
-
clientHeight: windowRef.current.clientHeight,
|
|
101
|
+
clientHeight: windowRef.current.clientHeight - topPinnedRowsHeight - bottomPinnedRowsHeight,
|
|
97
102
|
scrollTop: windowRef.current.scrollTop,
|
|
98
103
|
offsetHeight: targetOffsetHeight,
|
|
99
104
|
offsetTop: rowsMeta.positions[elementIndex]
|
|
@@ -120,13 +120,13 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
120
120
|
return gridSelectionStateSelector(apiRef.current.state).includes(id);
|
|
121
121
|
}, [apiRef]);
|
|
122
122
|
var isRowSelectable = React.useCallback(function (id) {
|
|
123
|
-
var _apiRef$current$getRo;
|
|
124
|
-
|
|
125
123
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
126
124
|
return false;
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
|
|
127
|
+
var rowNode = apiRef.current.getRowNode(id);
|
|
128
|
+
|
|
129
|
+
if ((rowNode == null ? void 0 : rowNode.position) === 'footer' || rowNode != null && rowNode.isPinned) {
|
|
130
130
|
return false;
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -296,6 +296,10 @@ export var useGridSelection = function useGridSelection(apiRef, props) {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
if (params.rowNode.isPinned) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
299
303
|
if (event.shiftKey && (canHaveMultipleSelection || checkboxSelection)) {
|
|
300
304
|
expandMouseRowRangeSelection(params.id);
|
|
301
305
|
} else {
|
|
@@ -211,6 +211,10 @@ export var useGridSorting = function useGridSorting(apiRef, props) {
|
|
|
211
211
|
var bodyRowIds = [];
|
|
212
212
|
var _footerRowIds = [];
|
|
213
213
|
gridRowIdsSelector(apiRef).forEach(function (rowId) {
|
|
214
|
+
if (rowTree[rowId].isPinned) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
214
218
|
if (rowTree[rowId].position === 'footer') {
|
|
215
219
|
_footerRowIds.push(rowId);
|
|
216
220
|
} else {
|
|
@@ -223,6 +227,10 @@ export var useGridSorting = function useGridSorting(apiRef, props) {
|
|
|
223
227
|
var bodyRows = [];
|
|
224
228
|
var footerRowIds = [];
|
|
225
229
|
Object.values(rowTree).forEach(function (rowNode) {
|
|
230
|
+
if (rowNode.isPinned) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
226
234
|
if (rowNode.position === 'footer') {
|
|
227
235
|
footerRowIds.push(rowNode.id);
|
|
228
236
|
} else {
|
|
@@ -186,10 +186,8 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
186
186
|
React.useEffect(function () {
|
|
187
187
|
setContainerWidth(rootRef.current.clientWidth);
|
|
188
188
|
}, [rowsMeta.currentPageTotalHeight]);
|
|
189
|
-
var handleResize = React.useCallback(function () {
|
|
190
|
-
|
|
191
|
-
setContainerWidth(rootRef.current.clientWidth);
|
|
192
|
-
}
|
|
189
|
+
var handleResize = React.useCallback(function (params) {
|
|
190
|
+
setContainerWidth(params.width);
|
|
193
191
|
}, []);
|
|
194
192
|
useGridApiEventHandler(apiRef, 'resize', handleResize);
|
|
195
193
|
var updateRenderZonePosition = React.useCallback(function (nextRenderContext) {
|
|
@@ -313,9 +311,11 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
313
311
|
maxLastColumn = _params$maxLastColumn === void 0 ? renderZoneMaxColumnIndex : _params$maxLastColumn,
|
|
314
312
|
_params$availableSpac = params.availableSpace,
|
|
315
313
|
availableSpace = _params$availableSpac === void 0 ? containerWidth : _params$availableSpac,
|
|
316
|
-
ignoreAutoHeight = params.ignoreAutoHeight
|
|
314
|
+
ignoreAutoHeight = params.ignoreAutoHeight,
|
|
315
|
+
_params$rowIndexOffse = params.rowIndexOffset,
|
|
316
|
+
rowIndexOffset = _params$rowIndexOffse === void 0 ? 0 : _params$rowIndexOffse;
|
|
317
317
|
|
|
318
|
-
if (!
|
|
318
|
+
if (!nextRenderContext || availableSpace == null) {
|
|
319
319
|
return null;
|
|
320
320
|
}
|
|
321
321
|
|
|
@@ -335,15 +335,31 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
335
335
|
|
|
336
336
|
var renderedRows = [];
|
|
337
337
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
338
|
+
if (params.rows) {
|
|
339
|
+
params.rows.forEach(function (row) {
|
|
340
|
+
renderedRows.push(row);
|
|
341
|
+
apiRef.current.unstable_calculateColSpan({
|
|
342
|
+
rowId: row.id,
|
|
343
|
+
minFirstColumn: minFirstColumn,
|
|
344
|
+
maxLastColumn: maxLastColumn,
|
|
345
|
+
columns: visibleColumns
|
|
346
|
+
});
|
|
346
347
|
});
|
|
348
|
+
} else {
|
|
349
|
+
if (!currentPage.range) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
for (var i = firstRowToRender; i < lastRowToRender; i += 1) {
|
|
354
|
+
var row = currentPage.rows[i];
|
|
355
|
+
renderedRows.push(row);
|
|
356
|
+
apiRef.current.unstable_calculateColSpan({
|
|
357
|
+
rowId: row.id,
|
|
358
|
+
minFirstColumn: minFirstColumn,
|
|
359
|
+
maxLastColumn: maxLastColumn,
|
|
360
|
+
columns: visibleColumns
|
|
361
|
+
});
|
|
362
|
+
}
|
|
347
363
|
}
|
|
348
364
|
|
|
349
365
|
var _getRenderableIndexes9 = getRenderableIndexes({
|
|
@@ -368,7 +384,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
368
384
|
var rows = [];
|
|
369
385
|
|
|
370
386
|
for (var i = 0; i < renderedRows.length; i += 1) {
|
|
371
|
-
var _rootProps$components;
|
|
387
|
+
var _currentPage$range5, _rootProps$components;
|
|
372
388
|
|
|
373
389
|
var _renderedRows$i = renderedRows[i],
|
|
374
390
|
_id = _renderedRows$i.id,
|
|
@@ -398,7 +414,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
|
|
|
398
414
|
firstColumnToRender: firstColumnToRender,
|
|
399
415
|
lastColumnToRender: lastColumnToRender,
|
|
400
416
|
selected: isSelected,
|
|
401
|
-
index: currentPage.range.firstRowIndex + firstRowToRender + i,
|
|
417
|
+
index: rowIndexOffset + ((currentPage == null ? void 0 : (_currentPage$range5 = currentPage.range) == null ? void 0 : _currentPage$range5.firstRowIndex) || 0) + firstRowToRender + i,
|
|
402
418
|
containerWidth: availableSpace,
|
|
403
419
|
isLastVisible: lastVisibleRowIndex
|
|
404
420
|
}, typeof getRowProps === 'function' ? getRowProps(_id, _model) : {}, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.row), _id));
|
package/legacy/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export { useGridDensity, densityStateInitializer } from '../hooks/features/densi
|
|
|
15
15
|
export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
|
|
16
16
|
export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
|
|
17
17
|
export { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
|
|
18
|
+
export { passFilterLogic } from '../hooks/features/filter/gridFilterUtils';
|
|
18
19
|
export { useGridFocus, focusStateInitializer } from '../hooks/features/focus/useGridFocus';
|
|
19
20
|
export { useGridKeyboardNavigation } from '../hooks/features/keyboardNavigation/useGridKeyboardNavigation';
|
|
20
21
|
export { useGridPagination, paginationStateInitializer } from '../hooks/features/pagination/useGridPagination';
|
|
@@ -25,6 +26,9 @@ export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGri
|
|
|
25
26
|
export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
|
|
26
27
|
export { useGridRowsMeta, rowsMetaStateInitializer } from '../hooks/features/rows/useGridRowsMeta';
|
|
27
28
|
export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
29
|
+
export { getRowIdFromRowModel } from '../hooks/features/rows/gridRowsUtils';
|
|
30
|
+
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
31
|
+
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|
|
28
32
|
export { useGridSelection, selectionStateInitializer } from '../hooks/features/selection/useGridSelection';
|
|
29
33
|
export { useGridSelectionPreProcessors } from '../hooks/features/selection/useGridSelectionPreProcessors';
|
|
30
34
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
package/legacy/locales/arSD.js
CHANGED
|
@@ -23,7 +23,7 @@ var arSDGrid = {
|
|
|
23
23
|
return count !== 1 ? "".concat(count, " \u0645\u0646 \u0627\u0644\u0645\u0631\u0634\u0650\u062D\u0627\u062A \u0627\u0644\u0646\u0634\u0637\u0629") : "\u0645\u0631\u0634\u0650\u062D \u0646\u0634\u0637";
|
|
24
24
|
},
|
|
25
25
|
// Quick filter toolbar field
|
|
26
|
-
// toolbarQuickFilterPlaceholder: 'Search
|
|
26
|
+
// toolbarQuickFilterPlaceholder: 'Search…',
|
|
27
27
|
// toolbarQuickFilterLabel: 'Search',
|
|
28
28
|
// toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
29
29
|
// Export selector toolbar button text
|
package/legacy/locales/bgBG.js
CHANGED
|
@@ -23,7 +23,7 @@ var bgBGGrid = {
|
|
|
23
23
|
return "".concat(count, " \u0430\u043A\u0442\u0438\u0432\u043D\u0438 \u0444\u0438\u043B\u0442\u0440\u0438");
|
|
24
24
|
},
|
|
25
25
|
// Quick filter toolbar field
|
|
26
|
-
// toolbarQuickFilterPlaceholder: 'Search
|
|
26
|
+
// toolbarQuickFilterPlaceholder: 'Search…',
|
|
27
27
|
// toolbarQuickFilterLabel: 'Search',
|
|
28
28
|
// toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
29
29
|
// Export selector toolbar button text
|
package/legacy/locales/csCZ.js
CHANGED
|
@@ -31,7 +31,7 @@ var csCZGrid = {
|
|
|
31
31
|
return "".concat(count, " ").concat(pluralForm);
|
|
32
32
|
},
|
|
33
33
|
// Quick filter toolbar field
|
|
34
|
-
// toolbarQuickFilterPlaceholder: 'Search
|
|
34
|
+
// toolbarQuickFilterPlaceholder: 'Search…',
|
|
35
35
|
// toolbarQuickFilterLabel: 'Search',
|
|
36
36
|
// toolbarQuickFilterDeleteIconLabel: 'Clear',
|
|
37
37
|
// Export selector toolbar button text
|