@mui/x-data-grid 7.23.5 → 7.24.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 +159 -0
- package/DataGrid/DataGrid.js +4 -5
- package/DataGrid/useDataGridComponent.d.ts +1 -1
- package/DataGrid/useDataGridComponent.js +1 -1
- package/components/GridHeaders.js +2 -2
- package/components/GridRow.d.ts +5 -9
- package/components/GridRow.js +28 -105
- package/components/GridSkeletonLoadingOverlay.js +18 -18
- package/components/cell/GridActionsCellItem.d.ts +3 -3
- package/components/cell/GridCell.d.ts +9 -16
- package/components/cell/GridCell.js +17 -35
- package/components/cell/GridEditDateCell.js +1 -1
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +2 -2
- package/components/columnHeaders/ColumnHeaderMenuIcon.d.ts +1 -1
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -5
- package/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -5
- package/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
- package/components/columnSelection/GridHeaderCheckbox.js +6 -2
- package/components/containers/GridRoot.d.ts +2 -2
- package/components/containers/GridRoot.js +14 -6
- package/components/containers/GridRootStyles.js +1 -0
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +7 -10
- package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/components/virtualization/GridVirtualScroller.js +4 -4
- package/context/GridContextProvider.d.ts +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +1 -1
- package/hooks/core/useGridApiInitialization.d.ts +1 -1
- package/hooks/core/useGridApiInitialization.js +2 -2
- package/hooks/core/useGridInitialization.d.ts +1 -1
- package/hooks/core/useGridIsRtl.d.ts +1 -1
- package/hooks/core/useGridLocaleText.d.ts +1 -1
- package/hooks/core/useGridLoggerFactory.d.ts +1 -1
- package/hooks/core/useGridRefs.d.ts +1 -1
- package/hooks/core/useGridStateInitialization.d.ts +1 -1
- package/hooks/features/clipboard/useGridClipboard.d.ts +1 -1
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +1 -1
- package/hooks/features/columnResize/useGridColumnResize.d.ts +1 -1
- package/hooks/features/columnResize/useGridColumnResize.js +8 -6
- package/hooks/features/columns/gridColumnsUtils.d.ts +3 -3
- package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/density/useGridDensity.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +1 -1
- package/hooks/features/editing/useGridCellEditing.d.ts +1 -1
- package/hooks/features/editing/useGridEditing.d.ts +1 -1
- package/hooks/features/editing/useGridRowEditing.d.ts +1 -1
- package/hooks/features/editing/useGridRowEditing.js +1 -1
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/export/serializers/csvSerializer.d.ts +1 -1
- package/hooks/features/export/useGridCsvExport.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.d.ts +1 -1
- package/hooks/features/export/useGridPrintExport.js +1 -1
- package/hooks/features/export/utils.d.ts +1 -1
- package/hooks/features/filter/gridFilterSelector.js +6 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +6 -6
- package/hooks/features/filter/gridFilterUtils.js +3 -3
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/focus/useGridFocus.d.ts +1 -1
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/utils.d.ts +2 -2
- package/hooks/features/listView/useGridListView.d.ts +1 -1
- package/hooks/features/pagination/gridPaginationInterfaces.d.ts +3 -0
- package/hooks/features/pagination/gridPaginationSelector.d.ts +20 -1
- package/hooks/features/pagination/gridPaginationSelector.js +39 -1
- package/hooks/features/pagination/useGridPagination.d.ts +2 -2
- package/hooks/features/pagination/useGridPagination.js +5 -3
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/hooks/features/pagination/useGridRowCount.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +1 -1
- package/hooks/features/rowSelection/utils.d.ts +2 -2
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsSelector.js +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +3 -3
- package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
- package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
- package/hooks/features/rows/useGridRows.d.ts +1 -1
- package/hooks/features/rows/useGridRows.js +2 -2
- package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
- package/hooks/features/rows/useGridRowsPreProcessors.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/sorting/gridSortingUtils.d.ts +2 -2
- package/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/statePersistence/useGridStatePersistence.d.ts +1 -1
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +6 -0
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +5 -4
- package/hooks/features/virtualization/useGridVirtualScroller.js +96 -43
- package/hooks/features/virtualization/useGridVirtualization.d.ts +1 -1
- package/hooks/utils/useGridApiContext.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +3 -3
- package/hooks/utils/useGridApiEventHandler.js +1 -1
- package/hooks/utils/useGridApiMethod.d.ts +1 -1
- package/hooks/utils/useGridApiRef.d.ts +1 -1
- package/hooks/utils/useGridInitializeState.d.ts +2 -2
- package/hooks/utils/useGridLogger.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +2 -2
- package/hooks/utils/useGridVisibleRows.d.ts +7 -5
- package/hooks/utils/useGridVisibleRows.js +5 -28
- package/index.js +1 -1
- package/internals/constants.d.ts +6 -0
- package/internals/constants.js +8 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/utils/attachPinnedStyle.d.ts +2 -0
- package/internals/utils/attachPinnedStyle.js +9 -0
- package/internals/utils/getPinnedCellOffset.d.ts +3 -3
- package/internals/utils/getPinnedCellOffset.js +6 -7
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/locales/urPK.js +9 -10
- package/models/api/gridCoreApi.d.ts +7 -7
- package/models/api/gridDensityApi.d.ts +1 -1
- package/models/colDef/gridColDef.d.ts +8 -8
- package/models/events/gridEventLookup.d.ts +6 -1
- package/models/gridExport.d.ts +1 -1
- package/models/gridFilterOperator.d.ts +1 -1
- package/models/gridStateCommunity.d.ts +4 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/DataGrid/DataGrid.js +4 -5
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/components/GridHeaders.js +2 -2
- package/modern/components/GridRow.js +28 -105
- package/modern/components/GridSkeletonLoadingOverlay.js +18 -18
- package/modern/components/cell/GridCell.js +17 -35
- package/modern/components/cell/GridEditDateCell.js +1 -1
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -2
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
- package/modern/components/columnSelection/GridHeaderCheckbox.js +6 -2
- package/modern/components/containers/GridRoot.js +14 -6
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +7 -10
- package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/modern/components/virtualization/GridVirtualScroller.js +4 -4
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
- package/modern/hooks/core/useGridApiInitialization.js +2 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/modern/hooks/features/columnResize/useGridColumnResize.js +8 -6
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
- package/modern/hooks/features/export/useGridPrintExport.js +1 -1
- package/modern/hooks/features/filter/gridFilterSelector.js +6 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
- package/modern/hooks/features/pagination/gridPaginationSelector.js +39 -1
- package/modern/hooks/features/pagination/useGridPagination.js +5 -3
- package/modern/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +2 -2
- package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +96 -43
- package/modern/hooks/utils/useGridApiEventHandler.js +1 -1
- package/modern/hooks/utils/useGridVisibleRows.js +5 -28
- package/modern/index.js +1 -1
- package/modern/internals/constants.js +8 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/attachPinnedStyle.js +9 -0
- package/modern/internals/utils/getPinnedCellOffset.js +6 -7
- package/modern/internals/utils/index.js +2 -1
- package/modern/locales/urPK.js +9 -10
- package/modern/utils/cellBorderUtils.js +5 -5
- package/modern/utils/domUtils.js +7 -2
- package/modern/utils/rtlFlipSide.js +22 -0
- package/node/DataGrid/DataGrid.js +2 -3
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/components/GridHeaders.js +2 -2
- package/node/components/GridRow.js +27 -104
- package/node/components/GridSkeletonLoadingOverlay.js +17 -17
- package/node/components/cell/GridCell.js +18 -36
- package/node/components/cell/GridEditDateCell.js +1 -1
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +2 -2
- package/node/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/node/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +3 -2
- package/node/components/columnSelection/GridHeaderCheckbox.js +6 -2
- package/node/components/containers/GridRoot.js +14 -6
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/filterPanel/GridFilterInputValue.js +7 -10
- package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/node/components/virtualization/GridVirtualScroller.js +4 -4
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
- package/node/hooks/core/useGridApiInitialization.js +2 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
- package/node/hooks/features/columnResize/useGridColumnResize.js +8 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +1 -1
- package/node/hooks/features/editing/useGridRowEditing.js +1 -1
- package/node/hooks/features/export/useGridPrintExport.js +1 -1
- package/node/hooks/features/filter/gridFilterSelector.js +6 -1
- package/node/hooks/features/filter/gridFilterUtils.js +3 -3
- package/node/hooks/features/pagination/gridPaginationSelector.js +41 -3
- package/node/hooks/features/pagination/useGridPagination.js +5 -3
- package/node/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
- package/node/hooks/features/rows/gridRowsSelector.js +1 -1
- package/node/hooks/features/rows/useGridRows.js +1 -1
- package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +49 -0
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +96 -43
- package/node/hooks/utils/useGridApiEventHandler.js +1 -1
- package/node/hooks/utils/useGridVisibleRows.js +3 -28
- package/node/index.js +1 -1
- package/node/internals/constants.js +9 -2
- package/node/internals/index.js +12 -0
- package/node/internals/utils/attachPinnedStyle.js +15 -0
- package/node/internals/utils/getPinnedCellOffset.js +6 -7
- package/node/internals/utils/index.js +11 -0
- package/node/locales/urPK.js +9 -10
- package/node/utils/cellBorderUtils.js +5 -5
- package/node/utils/domUtils.js +7 -2
- package/node/utils/rtlFlipSide.js +29 -0
- package/package.json +2 -2
- package/utils/cellBorderUtils.d.ts +3 -3
- package/utils/cellBorderUtils.js +5 -5
- package/utils/createSelector.d.ts +2 -2
- package/utils/domUtils.js +7 -2
- package/utils/getPublicApiRef.d.ts +1 -1
- package/utils/rtlFlipSide.d.ts +2 -0
- package/utils/rtlFlipSide.js +22 -0
|
@@ -26,7 +26,7 @@ function getHasEval() {
|
|
|
26
26
|
/**
|
|
27
27
|
* Adds default values to the optional fields of a filter items.
|
|
28
28
|
* @param {GridFilterItem} item The raw filter item.
|
|
29
|
-
* @param {React.
|
|
29
|
+
* @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
30
30
|
* @return {GridFilterItem} The clean filter item with an uniq ID and an always-defined operator.
|
|
31
31
|
* TODO: Make the typing reflect the different between GridFilterInputItem and GridFilterItem.
|
|
32
32
|
*/
|
|
@@ -144,7 +144,7 @@ let filterItemsApplierId = 1;
|
|
|
144
144
|
/**
|
|
145
145
|
* Generates a method to easily check if a row is matching the current filter model.
|
|
146
146
|
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
147
|
-
* @param {React.
|
|
147
|
+
* @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
148
148
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
149
149
|
*/
|
|
150
150
|
const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) => {
|
|
@@ -192,7 +192,7 @@ const shouldQuickFilterExcludeHiddenColumns = filterModel => {
|
|
|
192
192
|
/**
|
|
193
193
|
* Generates a method to easily check if a row is matching the current quick filter.
|
|
194
194
|
* @param {any[]} filterModel The model with which we want to filter the rows.
|
|
195
|
-
* @param {React.
|
|
195
|
+
* @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
|
|
196
196
|
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
197
197
|
*/
|
|
198
198
|
exports.shouldQuickFilterExcludeHiddenColumns = shouldQuickFilterExcludeHiddenColumns;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridPaginationSelector = exports.gridPaginationRowRangeSelector = exports.gridPaginationRowCountSelector = exports.gridPaginationModelSelector = exports.gridPaginationMetaSelector = exports.gridPaginatedVisibleSortedGridRowIdsSelector = exports.gridPaginatedVisibleSortedGridRowEntriesSelector = exports.gridPageSizeSelector = exports.gridPageSelector = exports.gridPageCountSelector = void 0;
|
|
6
|
+
exports.gridVisibleRowsSelector = exports.gridPaginationSelector = exports.gridPaginationRowRangeSelector = exports.gridPaginationRowCountSelector = exports.gridPaginationModelSelector = exports.gridPaginationMetaSelector = exports.gridPaginationEnabledClientSideSelector = exports.gridPaginatedVisibleSortedGridRowIdsSelector = exports.gridPaginatedVisibleSortedGridRowEntriesSelector = exports.gridPageSizeSelector = exports.gridPageSelector = exports.gridPageCountSelector = void 0;
|
|
7
7
|
var _createSelector = require("../../../utils/createSelector");
|
|
8
8
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
9
9
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
@@ -17,10 +17,16 @@ const ALL_RESULTS_PAGE_VALUE = -1;
|
|
|
17
17
|
const gridPaginationSelector = state => state.pagination;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Get the pagination model
|
|
21
20
|
* @category Pagination
|
|
21
|
+
* @ignore - do not document.
|
|
22
22
|
*/
|
|
23
23
|
exports.gridPaginationSelector = gridPaginationSelector;
|
|
24
|
+
const gridPaginationEnabledClientSideSelector = exports.gridPaginationEnabledClientSideSelector = (0, _createSelector.createSelector)(gridPaginationSelector, pagination => pagination.enabled && pagination.paginationMode === 'client');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get the pagination model
|
|
28
|
+
* @category Pagination
|
|
29
|
+
*/
|
|
24
30
|
const gridPaginationModelSelector = exports.gridPaginationModelSelector = (0, _createSelector.createSelector)(gridPaginationSelector, pagination => pagination.paginationModel);
|
|
25
31
|
|
|
26
32
|
/**
|
|
@@ -57,7 +63,10 @@ const gridPageCountSelector = exports.gridPageCountSelector = (0, _createSelecto
|
|
|
57
63
|
* Get the index of the first and the last row to include in the current page if the pagination is enabled.
|
|
58
64
|
* @category Pagination
|
|
59
65
|
*/
|
|
60
|
-
const gridPaginationRowRangeSelector = exports.gridPaginationRowRangeSelector = (0, _createSelector.createSelectorMemoized)(gridPaginationModelSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.gridRowMaximumTreeDepthSelector, _gridFilterSelector.gridExpandedSortedRowEntriesSelector, _gridFilterSelector.gridFilteredSortedTopLevelRowEntriesSelector, (paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
|
|
66
|
+
const gridPaginationRowRangeSelector = exports.gridPaginationRowRangeSelector = (0, _createSelector.createSelectorMemoized)(gridPaginationEnabledClientSideSelector, gridPaginationModelSelector, _gridRowsSelector.gridRowTreeSelector, _gridRowsSelector.gridRowMaximumTreeDepthSelector, _gridFilterSelector.gridExpandedSortedRowEntriesSelector, _gridFilterSelector.gridFilteredSortedTopLevelRowEntriesSelector, (clientSidePaginationEnabled, paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
|
|
67
|
+
if (!clientSidePaginationEnabled) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
61
70
|
const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
|
|
62
71
|
const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
|
|
63
72
|
const topLevelLastRowIndex = paginationModel.pageSize === ALL_RESULTS_PAGE_VALUE ? visibleTopLevelRowCount - 1 : Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
|
|
@@ -119,4 +128,33 @@ const gridPaginatedVisibleSortedGridRowIdsSelector = exports.gridPaginatedVisibl
|
|
|
119
128
|
return [];
|
|
120
129
|
}
|
|
121
130
|
return visibleSortedRowIds.slice(paginationRange.firstRowIndex, paginationRange.lastRowIndex + 1);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get the rows, range and rowIndex lookup map after filtering and sorting.
|
|
135
|
+
* Does not contain the collapsed children.
|
|
136
|
+
* @category Pagination
|
|
137
|
+
*/
|
|
138
|
+
const gridVisibleRowsSelector = exports.gridVisibleRowsSelector = (0, _createSelector.createSelectorMemoized)(gridPaginationEnabledClientSideSelector, gridPaginationRowRangeSelector, gridPaginatedVisibleSortedGridRowEntriesSelector, _gridFilterSelector.gridExpandedSortedRowEntriesSelector, (clientPaginationEnabled, paginationRowRange, paginationRows, expandedSortedRowEntries) => {
|
|
139
|
+
if (clientPaginationEnabled) {
|
|
140
|
+
return {
|
|
141
|
+
rows: paginationRows,
|
|
142
|
+
range: paginationRowRange,
|
|
143
|
+
rowToIndexMap: paginationRows.reduce((lookup, row, index) => {
|
|
144
|
+
lookup.set(row.model, index);
|
|
145
|
+
return lookup;
|
|
146
|
+
}, new Map())
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
rows: expandedSortedRowEntries,
|
|
151
|
+
range: expandedSortedRowEntries.length === 0 ? null : {
|
|
152
|
+
firstRowIndex: 0,
|
|
153
|
+
lastRowIndex: expandedSortedRowEntries.length - 1
|
|
154
|
+
},
|
|
155
|
+
rowToIndexMap: expandedSortedRowEntries.reduce((lookup, row, index) => {
|
|
156
|
+
lookup.set(row.model, index);
|
|
157
|
+
return lookup;
|
|
158
|
+
}, new Map())
|
|
159
|
+
};
|
|
122
160
|
});
|
|
@@ -16,11 +16,13 @@ const paginationStateInitializer = (state, props) => {
|
|
|
16
16
|
const rowCount = props.rowCount ?? props.initialState?.pagination?.rowCount;
|
|
17
17
|
const meta = props.paginationMeta ?? props.initialState?.pagination?.meta ?? {};
|
|
18
18
|
return (0, _extends2.default)({}, state, {
|
|
19
|
-
pagination: {
|
|
19
|
+
pagination: (0, _extends2.default)({}, state.pagination, {
|
|
20
20
|
paginationModel,
|
|
21
21
|
rowCount,
|
|
22
|
-
meta
|
|
23
|
-
|
|
22
|
+
meta,
|
|
23
|
+
enabled: props.pagination === true,
|
|
24
|
+
paginationMode: props.paginationMode
|
|
25
|
+
})
|
|
24
26
|
});
|
|
25
27
|
};
|
|
26
28
|
|
|
@@ -164,13 +164,35 @@ const useGridPaginationModel = (apiRef, props) => {
|
|
|
164
164
|
/**
|
|
165
165
|
* EFFECTS
|
|
166
166
|
*/
|
|
167
|
+
const isFirstRender = React.useRef(true);
|
|
167
168
|
React.useEffect(() => {
|
|
169
|
+
if (isFirstRender.current) {
|
|
170
|
+
isFirstRender.current = false;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!props.pagination) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
168
176
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
169
177
|
pagination: (0, _extends2.default)({}, state.pagination, {
|
|
170
178
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, props.paginationModel)
|
|
171
179
|
})
|
|
172
180
|
}));
|
|
173
|
-
}, [apiRef, props.paginationModel, props.
|
|
181
|
+
}, [apiRef, props.paginationModel, props.signature, props.pagination]);
|
|
182
|
+
React.useEffect(() => {
|
|
183
|
+
apiRef.current.setState(state => {
|
|
184
|
+
const isEnabled = props.pagination === true;
|
|
185
|
+
if (state.pagination.paginationMode === props.paginationMode || state.pagination.enabled === isEnabled) {
|
|
186
|
+
return state;
|
|
187
|
+
}
|
|
188
|
+
return (0, _extends2.default)({}, state, {
|
|
189
|
+
pagination: (0, _extends2.default)({}, state.pagination, {
|
|
190
|
+
paginationMode: props.paginationMode,
|
|
191
|
+
enabled: props.pagination === true
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}, [apiRef, props.paginationMode, props.pagination]);
|
|
174
196
|
React.useEffect(handleUpdateAutoPageSize, [handleUpdateAutoPageSize]);
|
|
175
197
|
};
|
|
176
198
|
exports.useGridPaginationModel = useGridPaginationModel;
|
|
@@ -24,8 +24,8 @@ const preferencePanelStateInitializer = (state, props) => (0, _extends2.default)
|
|
|
24
24
|
exports.preferencePanelStateInitializer = preferencePanelStateInitializer;
|
|
25
25
|
const useGridPreferencesPanel = (apiRef, props) => {
|
|
26
26
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridPreferencesPanel');
|
|
27
|
-
const hideTimeout = React.useRef();
|
|
28
|
-
const immediateTimeout = React.useRef();
|
|
27
|
+
const hideTimeout = React.useRef(undefined);
|
|
28
|
+
const immediateTimeout = React.useRef(undefined);
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* API METHODS
|
|
@@ -22,7 +22,7 @@ const gridRowMaximumTreeDepthSelector = exports.gridRowMaximumTreeDepthSelector
|
|
|
22
22
|
if (entries.length === 0) {
|
|
23
23
|
return 1;
|
|
24
24
|
}
|
|
25
|
-
return entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] + 1;
|
|
25
|
+
return (entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] ?? 0) + 1;
|
|
26
26
|
});
|
|
27
27
|
const gridDataRowIdsSelector = exports.gridDataRowIdsSelector = (0, _createSelector.createSelector)(gridRowsStateSelector, rows => rows.dataRowIds);
|
|
28
28
|
|
|
@@ -48,7 +48,7 @@ const useGridRows = (apiRef, props) => {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridRows');
|
|
51
|
-
const currentPage = (0, _useGridVisibleRows.
|
|
51
|
+
const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef);
|
|
52
52
|
const lastUpdateMs = React.useRef(Date.now());
|
|
53
53
|
const lastRowCount = React.useRef(props.rowCount);
|
|
54
54
|
const timeout = (0, _useTimeout.useTimeout)();
|
|
@@ -28,7 +28,7 @@ const isDesc = direction => direction === 'desc';
|
|
|
28
28
|
/**
|
|
29
29
|
* Transform an item of the sorting model into a method comparing two rows.
|
|
30
30
|
* @param {GridSortItem} sortItem The sort item we want to apply.
|
|
31
|
-
* @param {React.
|
|
31
|
+
* @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
32
32
|
* @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
|
|
33
33
|
*/
|
|
34
34
|
const parseSortItem = (sortItem, apiRef) => {
|
|
@@ -81,7 +81,7 @@ const compareRows = (parsedSortItems, row1, row2) => {
|
|
|
81
81
|
/**
|
|
82
82
|
* Generates a method to easily sort a list of rows according to the current sort model.
|
|
83
83
|
* @param {GridSortModel} sortModel The model with which we want to sort the rows.
|
|
84
|
-
* @param {React.
|
|
84
|
+
* @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
85
85
|
* @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
|
|
86
86
|
*/
|
|
87
87
|
const buildAggregatedSortingApplier = (sortModel, apiRef) => {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.gridFocusedVirtualCellSelector = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _reselect = require("reselect");
|
|
10
|
+
var _createSelector = require("../../../utils/createSelector");
|
|
11
|
+
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
12
|
+
var _gridVirtualizationSelectors = require("./gridVirtualizationSelectors");
|
|
13
|
+
var _focus = require("../focus");
|
|
14
|
+
var _pagination = require("../pagination");
|
|
15
|
+
var _rows = require("../rows");
|
|
16
|
+
const gridIsFocusedCellOutOfContex = (0, _reselect.createSelector)(_focus.gridFocusCellSelector, _gridVirtualizationSelectors.gridRenderContextSelector, _pagination.gridVisibleRowsSelector, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector, _rows.gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
|
|
17
|
+
if (!focusedCell) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const row = rows[focusedCell.id];
|
|
21
|
+
if (!row) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const rowIndex = currentPage.rowToIndexMap.get(row);
|
|
25
|
+
const columnIndex = visibleColumns.slice(renderContext.firstColumnIndex, renderContext.lastColumnIndex).findIndex(column => column.field === focusedCell.field);
|
|
26
|
+
const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
|
|
27
|
+
return !isInRenderContext;
|
|
28
|
+
});
|
|
29
|
+
const gridFocusedVirtualCellSelector = exports.gridFocusedVirtualCellSelector = (0, _createSelector.createSelectorMemoized)(gridIsFocusedCellOutOfContex, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector, _pagination.gridVisibleRowsSelector, _rows.gridRowsLookupSelector, _focus.gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
|
|
30
|
+
if (!isFocusedCellOutOfRenderContext) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const row = rows[focusedCell.id];
|
|
34
|
+
if (!row) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const rowIndex = currentPage.rowToIndexMap.get(row);
|
|
38
|
+
if (rowIndex === undefined) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const columnIndex = visibleColumns.findIndex(column => column.field === focusedCell.field);
|
|
42
|
+
if (columnIndex === -1) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return (0, _extends2.default)({}, focusedCell, {
|
|
46
|
+
rowIndex,
|
|
47
|
+
columnIndex
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -24,7 +24,6 @@ var _useRunOnce = require("../../utils/useRunOnce");
|
|
|
24
24
|
var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
25
25
|
var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
|
|
26
26
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
27
|
-
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
28
27
|
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
29
28
|
var _utils2 = require("../../utils");
|
|
30
29
|
var platform = _interopRequireWildcard(require("../../../utils/platform"));
|
|
@@ -37,6 +36,7 @@ var _useGridVirtualization = require("./useGridVirtualization");
|
|
|
37
36
|
var _gridRowSpanningSelectors = require("../rows/gridRowSpanningSelectors");
|
|
38
37
|
var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
39
38
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
39
|
+
var _gridFocusedVirtualCellSelector = require("./gridFocusedVirtualCellSelector");
|
|
40
40
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
41
41
|
const MINIMUM_COLUMN_WIDTH = 50;
|
|
42
42
|
var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
@@ -84,12 +84,9 @@ const useGridVirtualScroller = () => {
|
|
|
84
84
|
const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
|
|
85
85
|
const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
|
|
86
86
|
const isRtl = (0, _RtlProvider.useRtl)();
|
|
87
|
-
const cellFocus = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridFocusCellSelector);
|
|
88
|
-
const cellTabIndex = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridTabIndexCellSelector);
|
|
89
87
|
const rowsMeta = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
|
|
90
88
|
const selectedRowsLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowSelectionSelector.selectedIdsLookupSelector);
|
|
91
89
|
const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, rootProps);
|
|
92
|
-
const gridRootRef = apiRef.current.rootElementRef;
|
|
93
90
|
const mainRef = apiRef.current.mainElementRef;
|
|
94
91
|
const scrollerRef = apiRef.current.virtualScrollerRef;
|
|
95
92
|
const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
@@ -97,6 +94,8 @@ const useGridVirtualScroller = () => {
|
|
|
97
94
|
const contentHeight = dimensions.contentSize.height;
|
|
98
95
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
99
96
|
const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
|
|
97
|
+
const isRenderContextReady = React.useRef(false);
|
|
98
|
+
const previousSize = React.useRef(null);
|
|
100
99
|
const mainRefCallback = React.useCallback(node => {
|
|
101
100
|
mainRef.current = node;
|
|
102
101
|
if (!node) {
|
|
@@ -104,7 +103,10 @@ const useGridVirtualScroller = () => {
|
|
|
104
103
|
}
|
|
105
104
|
const initialRect = node.getBoundingClientRect();
|
|
106
105
|
let lastSize = roundDimensions(initialRect);
|
|
107
|
-
|
|
106
|
+
if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
|
|
107
|
+
previousSize.current = lastSize;
|
|
108
|
+
apiRef.current.publishEvent('resize', lastSize);
|
|
109
|
+
}
|
|
108
110
|
if (typeof ResizeObserver === 'undefined') {
|
|
109
111
|
return undefined;
|
|
110
112
|
}
|
|
@@ -145,17 +147,15 @@ const useGridVirtualScroller = () => {
|
|
|
145
147
|
* work that's not necessary. Thus we store the context at the start of the scroll in `frozenContext`, and the rows
|
|
146
148
|
* that are part of this old context will keep their same render context as to avoid re-rendering.
|
|
147
149
|
*/
|
|
148
|
-
const scrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
150
|
+
const scrollPosition = React.useRef(rootProps.initialState?.scroll ?? EMPTY_SCROLL_POSITION);
|
|
151
|
+
const ignoreNextScrollEvent = React.useRef(false);
|
|
149
152
|
const previousContextScrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
|
|
150
153
|
const previousRowContext = React.useRef(_useGridVirtualization.EMPTY_RENDER_CONTEXT);
|
|
151
154
|
const renderContext = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridRenderContextSelector);
|
|
155
|
+
const focusedVirtualCell = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusedVirtualCellSelector.gridFocusedVirtualCellSelector);
|
|
152
156
|
const scrollTimeout = (0, _useTimeout.default)();
|
|
153
157
|
const frozenContext = React.useRef(undefined);
|
|
154
158
|
const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
|
|
155
|
-
const focusedCell = {
|
|
156
|
-
rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
|
|
157
|
-
columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
|
|
158
|
-
};
|
|
159
159
|
const updateRenderContext = React.useCallback(nextRenderContext => {
|
|
160
160
|
if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
|
|
161
161
|
return;
|
|
@@ -239,6 +239,10 @@ const useGridVirtualScroller = () => {
|
|
|
239
239
|
updateRenderContext(nextRenderContext);
|
|
240
240
|
};
|
|
241
241
|
const handleScroll = (0, _utils.unstable_useEventCallback)(event => {
|
|
242
|
+
if (ignoreNextScrollEvent.current) {
|
|
243
|
+
ignoreNextScrollEvent.current = false;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
242
246
|
const {
|
|
243
247
|
scrollTop,
|
|
244
248
|
scrollLeft
|
|
@@ -297,14 +301,14 @@ const useGridVirtualScroller = () => {
|
|
|
297
301
|
const lastRowToRender = Math.min(baseRenderContext.lastRowIndex, rowModels.length);
|
|
298
302
|
const rowIndexes = params.rows ? (0, _utils3.range)(0, params.rows.length) : (0, _utils3.range)(firstRowToRender, lastRowToRender);
|
|
299
303
|
let virtualRowIndex = -1;
|
|
300
|
-
if (!isPinnedSection &&
|
|
301
|
-
if (
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
if (!isPinnedSection && focusedVirtualCell) {
|
|
305
|
+
if (focusedVirtualCell.rowIndex < firstRowToRender) {
|
|
306
|
+
rowIndexes.unshift(focusedVirtualCell.rowIndex);
|
|
307
|
+
virtualRowIndex = focusedVirtualCell.rowIndex;
|
|
304
308
|
}
|
|
305
|
-
if (
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
if (focusedVirtualCell.rowIndex > lastRowToRender) {
|
|
310
|
+
rowIndexes.push(focusedVirtualCell.rowIndex);
|
|
311
|
+
virtualRowIndex = focusedVirtualCell.rowIndex;
|
|
308
312
|
}
|
|
309
313
|
}
|
|
310
314
|
const rows = [];
|
|
@@ -344,7 +348,6 @@ const useGridVirtualScroller = () => {
|
|
|
344
348
|
});
|
|
345
349
|
}
|
|
346
350
|
}
|
|
347
|
-
const hasFocus = cellFocus?.id === id;
|
|
348
351
|
const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
|
|
349
352
|
let isSelected;
|
|
350
353
|
if (selectedRowsLookup[id] == null) {
|
|
@@ -369,19 +372,16 @@ const useGridVirtualScroller = () => {
|
|
|
369
372
|
isLastVisible = isLastVisibleInSection;
|
|
370
373
|
}
|
|
371
374
|
}
|
|
372
|
-
const isVirtualRow = rowIndexInPage === virtualRowIndex;
|
|
373
|
-
const isNotVisible = isVirtualRow;
|
|
374
|
-
let tabbableCell = null;
|
|
375
|
-
if (cellTabIndex !== null && cellTabIndex.id === id) {
|
|
376
|
-
const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
|
|
377
|
-
tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
|
|
378
|
-
}
|
|
379
375
|
let currentRenderContext = baseRenderContext;
|
|
380
376
|
if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
|
|
381
377
|
currentRenderContext = frozenContext.current;
|
|
382
378
|
}
|
|
379
|
+
const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
|
|
380
|
+
const isVirtualFocusColumn = focusedVirtualCell?.rowIndex === rowIndex;
|
|
383
381
|
const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, pinnedColumns.left.length);
|
|
384
382
|
const showBottomBorder = isLastVisibleInSection && params.position === 'top';
|
|
383
|
+
const firstColumnIndex = currentRenderContext.firstColumnIndex;
|
|
384
|
+
const lastColumnIndex = currentRenderContext.lastColumnIndex;
|
|
385
385
|
rows.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.row, (0, _extends2.default)({
|
|
386
386
|
row: model,
|
|
387
387
|
rowId: id,
|
|
@@ -389,19 +389,21 @@ const useGridVirtualScroller = () => {
|
|
|
389
389
|
selected: isSelected,
|
|
390
390
|
offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
|
|
391
391
|
offsetLeft: offsetLeft,
|
|
392
|
-
|
|
392
|
+
columnsTotalWidth: dimensions.columnsTotalWidth,
|
|
393
393
|
rowHeight: baseRowHeight,
|
|
394
|
-
tabbableCell: tabbableCell,
|
|
395
394
|
pinnedColumns: pinnedColumns,
|
|
396
395
|
visibleColumns: visibleColumns,
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
firstColumnIndex: firstColumnIndex,
|
|
397
|
+
lastColumnIndex: lastColumnIndex,
|
|
398
|
+
focusedColumnIndex: isVirtualFocusColumn ? focusedVirtualCell.columnIndex : undefined,
|
|
399
399
|
isFirstVisible: isFirstVisible,
|
|
400
400
|
isLastVisible: isLastVisible,
|
|
401
|
-
isNotVisible:
|
|
402
|
-
showBottomBorder: showBottomBorder
|
|
401
|
+
isNotVisible: isVirtualFocusRow,
|
|
402
|
+
showBottomBorder: showBottomBorder,
|
|
403
|
+
scrollbarWidth: dimensions.hasScrollY ? dimensions.scrollbarSize : 0,
|
|
404
|
+
gridHasFiller: dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width
|
|
403
405
|
}, rowProps), id));
|
|
404
|
-
if (
|
|
406
|
+
if (isVirtualFocusRow) {
|
|
405
407
|
return;
|
|
406
408
|
}
|
|
407
409
|
const panel = panels.get(id);
|
|
@@ -432,18 +434,21 @@ const useGridVirtualScroller = () => {
|
|
|
432
434
|
}
|
|
433
435
|
return size;
|
|
434
436
|
}, [columnsTotalWidth, contentHeight, needsHorizontalScrollbar]);
|
|
435
|
-
React.
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
439
|
-
// TODO a scroll reset should not be necessary
|
|
440
|
-
if (enabledForColumns) {
|
|
441
|
-
scrollerRef.current.scrollLeft = 0;
|
|
437
|
+
const onContentSizeApplied = React.useCallback(node => {
|
|
438
|
+
if (!node) {
|
|
439
|
+
return;
|
|
442
440
|
}
|
|
443
|
-
|
|
444
|
-
|
|
441
|
+
apiRef.current.publishEvent('virtualScrollerContentSizeChange', {
|
|
442
|
+
columnsTotalWidth,
|
|
443
|
+
contentHeight
|
|
444
|
+
});
|
|
445
|
+
}, [apiRef, columnsTotalWidth, contentHeight]);
|
|
446
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
447
|
+
if (!isRenderContextReady.current) {
|
|
448
|
+
return;
|
|
445
449
|
}
|
|
446
|
-
|
|
450
|
+
apiRef.current.updateRenderContext?.();
|
|
451
|
+
}, [apiRef, enabledForColumns, enabledForRows]);
|
|
447
452
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
448
453
|
if (listView) {
|
|
449
454
|
scrollerRef.current.scrollLeft = 0;
|
|
@@ -458,6 +463,53 @@ const useGridVirtualScroller = () => {
|
|
|
458
463
|
left: scrollPosition.current.left,
|
|
459
464
|
renderContext: initialRenderContext
|
|
460
465
|
});
|
|
466
|
+
isRenderContextReady.current = true;
|
|
467
|
+
if (rootProps.initialState?.scroll && scrollerRef.current) {
|
|
468
|
+
const scroller = scrollerRef.current;
|
|
469
|
+
const {
|
|
470
|
+
top,
|
|
471
|
+
left
|
|
472
|
+
} = rootProps.initialState.scroll;
|
|
473
|
+
|
|
474
|
+
// On initial mount, if we have columns available, we can restore the horizontal scroll immediately, but we need to skip the resulting scroll event, otherwise we would recalculate the render context at position top=0, left=restoredValue, but the initial render context is already calculated based on the initial value of scrollPosition ref.
|
|
475
|
+
const isScrollRestored = {
|
|
476
|
+
top: !(top > 0),
|
|
477
|
+
left: !(left > 0)
|
|
478
|
+
};
|
|
479
|
+
if (!isScrollRestored.left && columnsTotalWidth) {
|
|
480
|
+
scroller.scrollLeft = left;
|
|
481
|
+
ignoreNextScrollEvent.current = true;
|
|
482
|
+
isScrollRestored.left = true;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// For the sake of completeness, but I'm not sure if contentHeight is ever available at this point. Maybe when virtualisation is disabled?
|
|
486
|
+
if (!isScrollRestored.top && contentHeight) {
|
|
487
|
+
scroller.scrollTop = top;
|
|
488
|
+
ignoreNextScrollEvent.current = true;
|
|
489
|
+
isScrollRestored.top = true;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// To restore the vertical scroll, we need to wait until the rows are available in the DOM (otherwise there's nowhere to scroll), but before paint to avoid reflows
|
|
493
|
+
if (!isScrollRestored.top || !isScrollRestored.left) {
|
|
494
|
+
const unsubscribeContentSizeChange = apiRef.current.subscribeEvent('virtualScrollerContentSizeChange', params => {
|
|
495
|
+
if (!isScrollRestored.left && params.columnsTotalWidth) {
|
|
496
|
+
scroller.scrollLeft = left;
|
|
497
|
+
ignoreNextScrollEvent.current = true;
|
|
498
|
+
isScrollRestored.left = true;
|
|
499
|
+
}
|
|
500
|
+
if (!isScrollRestored.top && params.contentHeight) {
|
|
501
|
+
scroller.scrollTop = top;
|
|
502
|
+
ignoreNextScrollEvent.current = true;
|
|
503
|
+
isScrollRestored.top = true;
|
|
504
|
+
}
|
|
505
|
+
if (isScrollRestored.left && isScrollRestored.top) {
|
|
506
|
+
unsubscribeContentSizeChange();
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
return unsubscribeContentSizeChange;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return undefined;
|
|
461
513
|
});
|
|
462
514
|
apiRef.current.register('private', {
|
|
463
515
|
updateRenderContext: forceUpdateRenderContext
|
|
@@ -485,7 +537,8 @@ const useGridVirtualScroller = () => {
|
|
|
485
537
|
}),
|
|
486
538
|
getContentProps: () => ({
|
|
487
539
|
style: contentSize,
|
|
488
|
-
role: 'presentation'
|
|
540
|
+
role: 'presentation',
|
|
541
|
+
ref: onContentSizeApplied
|
|
489
542
|
}),
|
|
490
543
|
getRenderZoneProps: () => ({
|
|
491
544
|
role: 'rowgroup'
|
|
@@ -34,7 +34,7 @@ function createUseGridApiEventHandler(registryContainer) {
|
|
|
34
34
|
}
|
|
35
35
|
const [objectRetainedByReact] = React.useState(new ObjectToBeRetainedByReact());
|
|
36
36
|
const subscription = React.useRef(null);
|
|
37
|
-
const handlerRef = React.useRef();
|
|
37
|
+
const handlerRef = React.useRef(null);
|
|
38
38
|
handlerRef.current = handler;
|
|
39
39
|
const cleanupTokenRef = React.useRef(null);
|
|
40
40
|
if (!subscription.current && handlerRef.current) {
|
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.useGridVisibleRows = exports.getVisibleRows = void 0;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
7
|
var _gridPaginationSelector = require("../features/pagination/gridPaginationSelector");
|
|
10
|
-
var
|
|
8
|
+
var _ = require(".");
|
|
11
9
|
const getVisibleRows = (apiRef, props) => {
|
|
12
|
-
|
|
13
|
-
let range;
|
|
14
|
-
if (props.pagination && props.paginationMode === 'client') {
|
|
15
|
-
range = (0, _gridPaginationSelector.gridPaginationRowRangeSelector)(apiRef);
|
|
16
|
-
rows = (0, _gridPaginationSelector.gridPaginatedVisibleSortedGridRowEntriesSelector)(apiRef);
|
|
17
|
-
} else {
|
|
18
|
-
rows = (0, _gridFilterSelector.gridExpandedSortedRowEntriesSelector)(apiRef);
|
|
19
|
-
if (rows.length === 0) {
|
|
20
|
-
range = null;
|
|
21
|
-
} else {
|
|
22
|
-
range = {
|
|
23
|
-
firstRowIndex: 0,
|
|
24
|
-
lastRowIndex: rows.length - 1
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
rows,
|
|
30
|
-
range
|
|
31
|
-
};
|
|
10
|
+
return (0, _gridPaginationSelector.gridVisibleRowsSelector)(apiRef);
|
|
32
11
|
};
|
|
33
12
|
|
|
34
13
|
/**
|
|
@@ -40,10 +19,6 @@ const getVisibleRows = (apiRef, props) => {
|
|
|
40
19
|
*/
|
|
41
20
|
exports.getVisibleRows = getVisibleRows;
|
|
42
21
|
const useGridVisibleRows = (apiRef, props) => {
|
|
43
|
-
|
|
44
|
-
return React.useMemo(() => ({
|
|
45
|
-
rows: response.rows,
|
|
46
|
-
range: response.range
|
|
47
|
-
}), [response.rows, response.range]);
|
|
22
|
+
return (0, _.useGridSelector)(apiRef, _gridPaginationSelector.gridVisibleRowsSelector);
|
|
48
23
|
};
|
|
49
24
|
exports.useGridVisibleRows = useGridVisibleRows;
|
package/node/index.js
CHANGED
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.GRID_TREE_DATA_GROUPING_FIELD = exports.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = void 0;
|
|
6
|
+
exports.PinnedColumnPosition = exports.GRID_TREE_DATA_GROUPING_FIELD = exports.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = void 0;
|
|
7
7
|
const GRID_TREE_DATA_GROUPING_FIELD = exports.GRID_TREE_DATA_GROUPING_FIELD = '__tree_data_group__';
|
|
8
8
|
const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = exports.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
|
|
9
|
-
const GRID_DETAIL_PANEL_TOGGLE_FIELD = exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|
|
9
|
+
const GRID_DETAIL_PANEL_TOGGLE_FIELD = exports.GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
|
|
10
|
+
let PinnedColumnPosition = exports.PinnedColumnPosition = /*#__PURE__*/function (PinnedColumnPosition) {
|
|
11
|
+
PinnedColumnPosition[PinnedColumnPosition["NONE"] = 0] = "NONE";
|
|
12
|
+
PinnedColumnPosition[PinnedColumnPosition["LEFT"] = 1] = "LEFT";
|
|
13
|
+
PinnedColumnPosition[PinnedColumnPosition["RIGHT"] = 2] = "RIGHT";
|
|
14
|
+
PinnedColumnPosition[PinnedColumnPosition["VIRTUAL"] = 3] = "VIRTUAL";
|
|
15
|
+
return PinnedColumnPosition;
|
|
16
|
+
}({});
|
package/node/internals/index.js
CHANGED
|
@@ -821,6 +821,18 @@ Object.keys(_createControllablePromise).forEach(function (key) {
|
|
|
821
821
|
}
|
|
822
822
|
});
|
|
823
823
|
});
|
|
824
|
+
var _rtlFlipSide = require("../utils/rtlFlipSide");
|
|
825
|
+
Object.keys(_rtlFlipSide).forEach(function (key) {
|
|
826
|
+
if (key === "default" || key === "__esModule") return;
|
|
827
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
828
|
+
if (key in exports && exports[key] === _rtlFlipSide[key]) return;
|
|
829
|
+
Object.defineProperty(exports, key, {
|
|
830
|
+
enumerable: true,
|
|
831
|
+
get: function () {
|
|
832
|
+
return _rtlFlipSide[key];
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
});
|
|
824
836
|
var _createSelector = require("../utils/createSelector");
|
|
825
837
|
var _useGridSelector = require("../hooks/utils/useGridSelector");
|
|
826
838
|
var _domUtils = require("../utils/domUtils");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attachPinnedStyle = attachPinnedStyle;
|
|
7
|
+
var _rtlFlipSide = require("../../utils/rtlFlipSide");
|
|
8
|
+
function attachPinnedStyle(style, isRtl, pinnedPosition, pinnedOffset) {
|
|
9
|
+
const side = (0, _rtlFlipSide.rtlFlipSide)(pinnedPosition, isRtl);
|
|
10
|
+
if (!side || pinnedOffset === undefined) {
|
|
11
|
+
return style;
|
|
12
|
+
}
|
|
13
|
+
style[side] = pinnedOffset;
|
|
14
|
+
return style;
|
|
15
|
+
}
|