@mui/x-data-grid 7.23.6 → 7.24.1
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 +150 -0
- package/DataGrid/DataGrid.js +4 -5
- package/DataGrid/useDataGridComponent.d.ts +2 -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/GridCell.d.ts +9 -16
- package/components/cell/GridCell.js +17 -35
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -5
- package/components/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -5
- package/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -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.js +2 -1
- package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
- package/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/components/virtualization/GridVirtualScroller.js +4 -4
- package/context/GridContextProvider.d.ts +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +2 -2
- package/hooks/core/useGridApiInitialization.d.ts +2 -2
- package/hooks/core/useGridInitialization.d.ts +2 -2
- package/hooks/core/useGridIsRtl.d.ts +2 -2
- package/hooks/core/useGridLocaleText.d.ts +2 -2
- package/hooks/core/useGridLoggerFactory.d.ts +2 -2
- package/hooks/core/useGridRefs.d.ts +2 -2
- package/hooks/core/useGridStateInitialization.d.ts +2 -2
- package/hooks/features/clipboard/useGridClipboard.d.ts +2 -2
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +2 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -2
- package/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/hooks/features/columns/gridColumnsUtils.d.ts +4 -4
- package/hooks/features/columns/useGridColumnSpanning.d.ts +2 -2
- package/hooks/features/columns/useGridColumns.d.ts +2 -2
- package/hooks/features/density/useGridDensity.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.js +1 -3
- package/hooks/features/editing/useGridCellEditing.d.ts +2 -2
- package/hooks/features/editing/useGridEditing.d.ts +2 -2
- package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
- package/hooks/features/events/useGridEvents.d.ts +2 -2
- package/hooks/features/export/serializers/csvSerializer.d.ts +2 -1
- package/hooks/features/export/useGridCsvExport.d.ts +2 -2
- package/hooks/features/export/useGridPrintExport.d.ts +2 -2
- package/hooks/features/export/utils.d.ts +2 -2
- package/hooks/features/filter/gridFilterSelector.js +6 -1
- package/hooks/features/filter/gridFilterUtils.d.ts +7 -7
- package/hooks/features/filter/gridFilterUtils.js +3 -3
- package/hooks/features/filter/useGridFilter.d.ts +2 -2
- package/hooks/features/focus/useGridFocus.d.ts +2 -2
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
- package/hooks/features/listView/useGridListView.d.ts +2 -2
- 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 +3 -3
- package/hooks/features/pagination/useGridPagination.js +5 -3
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.js +23 -1
- package/hooks/features/pagination/useGridRowCount.d.ts +2 -2
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +1 -0
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
- package/hooks/features/preferencesPanel/index.d.ts +1 -1
- package/hooks/features/preferencesPanel/index.js +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +2 -2
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +2 -2
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +2 -2
- package/hooks/features/rowSelection/utils.d.ts +3 -2
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +2 -2
- package/hooks/features/rows/gridRowsSelector.js +1 -1
- package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +2 -2
- package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
- package/hooks/features/rows/useGridRowsPreProcessors.d.ts +2 -2
- package/hooks/features/scroll/useGridScroll.d.ts +2 -2
- package/hooks/features/sorting/gridSortingUtils.d.ts +3 -3
- package/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/hooks/features/sorting/useGridSorting.d.ts +2 -2
- package/hooks/features/statePersistence/useGridStatePersistence.d.ts +2 -2
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +6 -0
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +92 -50
- package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
- package/hooks/utils/useGridApiContext.d.ts +2 -2
- package/hooks/utils/useGridApiEventHandler.d.ts +4 -4
- package/hooks/utils/useGridApiMethod.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +2 -2
- package/hooks/utils/useGridApiRef.js +3 -1
- package/hooks/utils/useGridInitializeState.d.ts +3 -3
- package/hooks/utils/useGridLogger.d.ts +2 -2
- package/hooks/utils/useGridNativeEventListener.d.ts +2 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +2 -1
- package/hooks/utils/useGridSelector.d.ts +3 -3
- package/hooks/utils/useGridVisibleRows.d.ts +8 -6
- 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/faIR.js +5 -6
- package/locales/urPK.js +9 -10
- package/models/colDef/gridColDef.d.ts +9 -8
- package/models/events/gridEventLookup.d.ts +6 -1
- package/models/gridExport.d.ts +2 -2
- package/models/gridFilterOperator.d.ts +2 -1
- package/models/gridStateCommunity.d.ts +4 -0
- package/models/props/DataGridProps.d.ts +2 -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/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
- package/modern/components/containers/GridRoot.js +14 -6
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/panel/GridPanel.js +2 -1
- package/modern/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/modern/components/virtualization/GridVirtualScroller.js +4 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
- 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/gridPreferencePanelSelector.js +8 -1
- package/modern/hooks/features/preferencesPanel/index.js +1 -1
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- 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 +92 -50
- package/modern/hooks/utils/useGridApiRef.js +3 -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/faIR.js +5 -6
- package/modern/locales/urPK.js +9 -10
- package/modern/utils/cellBorderUtils.js +5 -5
- package/modern/utils/domUtils.js +7 -2
- package/modern/utils/isJSDOM.js +1 -0
- 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/columnHeaders/GridColumnGroupHeader.js +7 -10
- package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
- package/node/components/columnHeaders/GridColumnHeaderItem.js +13 -12
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
- package/node/components/containers/GridRoot.js +14 -6
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/panel/GridPanel.js +2 -1
- package/node/components/toolbar/GridToolbarColumnsButton.js +6 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +6 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
- package/node/components/virtualization/GridVirtualScroller.js +4 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +4 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
- 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/gridPreferencePanelSelector.js +9 -2
- package/node/hooks/features/preferencesPanel/index.js +11 -10
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- 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 +94 -52
- package/node/hooks/utils/useGridApiRef.js +3 -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/faIR.js +5 -6
- package/node/locales/urPK.js +9 -10
- package/node/utils/cellBorderUtils.js +5 -5
- package/node/utils/domUtils.js +7 -2
- package/node/utils/isJSDOM.js +7 -0
- 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 +3 -3
- package/utils/domUtils.js +7 -2
- package/utils/getPublicApiRef.d.ts +2 -1
- package/utils/isJSDOM.d.ts +1 -0
- package/utils/isJSDOM.js +1 -0
- package/utils/rtlFlipSide.d.ts +2 -0
- package/utils/rtlFlipSide.js +22 -0
|
@@ -10,7 +10,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
12
12
|
var _styles = require("@mui/material/styles");
|
|
13
|
-
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
14
13
|
var _utils = require("../../utils");
|
|
15
14
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
16
15
|
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
@@ -26,6 +25,8 @@ var _GridScrollbarFillerCell = require("../../../components/GridScrollbarFillerC
|
|
|
26
25
|
var _getPinnedCellOffset = require("../../../internals/utils/getPinnedCellOffset");
|
|
27
26
|
var _GridColumnHeaderSeparator = require("../../../components/columnHeaders/GridColumnHeaderSeparator");
|
|
28
27
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
28
|
+
var _cellBorderUtils = require("../../../utils/cellBorderUtils");
|
|
29
|
+
var _constants = require("../../../internals/constants");
|
|
29
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
30
31
|
const GridColumnHeaderRow = exports.GridColumnHeaderRow = (0, _styles.styled)('div', {
|
|
31
32
|
name: 'MuiDataGrid',
|
|
@@ -52,10 +53,8 @@ const useGridColumnHeaders = props => {
|
|
|
52
53
|
const [dragCol, setDragCol] = React.useState('');
|
|
53
54
|
const [resizeCol, setResizeCol] = React.useState('');
|
|
54
55
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
55
|
-
const isRtl = (0, _RtlProvider.useRtl)();
|
|
56
56
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
57
57
|
const dimensions = (0, _utils.useGridSelector)(apiRef, _dimensions.gridDimensionsSelector);
|
|
58
|
-
const hasColumnVirtualization = (0, _utils.useGridSelector)(apiRef, _virtualization.gridVirtualizationColumnEnabledSelector);
|
|
59
58
|
const columnGroupsModel = (0, _utils.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsUnwrappedModelSelector);
|
|
60
59
|
const columnPositions = (0, _utils.useGridSelector)(apiRef, _columns.gridColumnPositionsSelector);
|
|
61
60
|
const renderContext = (0, _utils.useGridSelector)(apiRef, _virtualization.gridRenderContextColumnsSelector);
|
|
@@ -92,18 +91,10 @@ const useGridColumnHeaders = props => {
|
|
|
92
91
|
// Helper for computation common between getColumnHeaders and getColumnGroupHeaders
|
|
93
92
|
const getColumnsToRender = params => {
|
|
94
93
|
const {
|
|
95
|
-
renderContext: currentContext = renderContext
|
|
96
|
-
maxLastColumn = visibleColumns.length
|
|
94
|
+
renderContext: currentContext = renderContext
|
|
97
95
|
} = params || {};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (!rootProps.disableVirtualization && !hasColumnVirtualization) {
|
|
101
|
-
firstColumnToRender = 0;
|
|
102
|
-
lastColumnToRender = maxLastColumn;
|
|
103
|
-
} else {
|
|
104
|
-
firstColumnToRender = currentContext.firstColumnIndex;
|
|
105
|
-
lastColumnToRender = currentContext.lastColumnIndex;
|
|
106
|
-
}
|
|
96
|
+
const firstColumnToRender = currentContext.firstColumnIndex;
|
|
97
|
+
const lastColumnToRender = currentContext.lastColumnIndex;
|
|
107
98
|
const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
|
|
108
99
|
return {
|
|
109
100
|
renderedColumns,
|
|
@@ -112,7 +103,7 @@ const useGridColumnHeaders = props => {
|
|
|
112
103
|
};
|
|
113
104
|
};
|
|
114
105
|
const getFillers = (params, children, leftOverflow, borderBottom = false) => {
|
|
115
|
-
const isPinnedRight = params?.position ===
|
|
106
|
+
const isPinnedRight = params?.position === _constants.PinnedColumnPosition.RIGHT;
|
|
116
107
|
const isNotPinned = params?.position === undefined;
|
|
117
108
|
const hasScrollbarFiller = pinnedColumns.right.length > 0 && isPinnedRight || pinnedColumns.right.length === 0 && isNotPinned;
|
|
118
109
|
const leftOffsetWidth = offsetLeft - leftOverflow;
|
|
@@ -133,33 +124,6 @@ const useGridColumnHeaders = props => {
|
|
|
133
124
|
})]
|
|
134
125
|
});
|
|
135
126
|
};
|
|
136
|
-
const getCellOffsetStyle = ({
|
|
137
|
-
pinnedPosition,
|
|
138
|
-
columnIndex,
|
|
139
|
-
computedWidth
|
|
140
|
-
}) => {
|
|
141
|
-
let style;
|
|
142
|
-
const isLeftPinned = pinnedPosition === _columns.GridPinnedColumnPosition.LEFT;
|
|
143
|
-
const isRightPinned = pinnedPosition === _columns.GridPinnedColumnPosition.RIGHT;
|
|
144
|
-
if (isLeftPinned || isRightPinned) {
|
|
145
|
-
const pinnedOffset = (0, _getPinnedCellOffset.getPinnedCellOffset)(pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions);
|
|
146
|
-
let side = isLeftPinned ? 'left' : 'right';
|
|
147
|
-
if (isRtl) {
|
|
148
|
-
side = isLeftPinned ? 'right' : 'left';
|
|
149
|
-
}
|
|
150
|
-
if (pinnedPosition === 'left') {
|
|
151
|
-
style = {
|
|
152
|
-
[side]: pinnedOffset
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
if (pinnedPosition === 'right') {
|
|
156
|
-
style = {
|
|
157
|
-
[side]: pinnedOffset
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return style;
|
|
162
|
-
};
|
|
163
127
|
const getColumnHeaders = (params, other = {}) => {
|
|
164
128
|
const {
|
|
165
129
|
renderedColumns,
|
|
@@ -174,14 +138,15 @@ const useGridColumnHeaders = props => {
|
|
|
174
138
|
const hasFocus = columnHeaderFocus !== null && columnHeaderFocus.field === colDef.field;
|
|
175
139
|
const open = columnMenuState.open && columnMenuState.field === colDef.field;
|
|
176
140
|
const pinnedPosition = params?.position;
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
computedWidth: colDef.computedWidth
|
|
181
|
-
});
|
|
182
|
-
const siblingWithBorderingSeparator = pinnedPosition === _columns.GridPinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
141
|
+
const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
|
|
142
|
+
const pinnedOffset = (0, _getPinnedCellOffset.getPinnedCellOffset)(pinnedPosition, colDef.computedWidth, columnIndex, columnPositions, dimensions.columnsTotalWidth, scrollbarWidth);
|
|
143
|
+
const siblingWithBorderingSeparator = pinnedPosition === _constants.PinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
183
144
|
const isSiblingFocused = siblingWithBorderingSeparator ? columnHeaderFocus !== null && columnHeaderFocus.field === siblingWithBorderingSeparator.field : false;
|
|
184
145
|
const isLastUnpinned = columnIndex + 1 === columnPositions.length - pinnedColumns.right.length;
|
|
146
|
+
const indexInSection = i;
|
|
147
|
+
const sectionLength = renderedColumns.length;
|
|
148
|
+
const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection);
|
|
149
|
+
const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder, gridHasFiller);
|
|
185
150
|
columns.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridColumnHeaderItem.GridColumnHeaderItem, (0, _extends2.default)({}, sortColumnLookup[colDef.field], {
|
|
186
151
|
columnMenuOpen: open,
|
|
187
152
|
filterItemsCounter: filterColumnLookup[colDef.field] && filterColumnLookup[colDef.field].length,
|
|
@@ -194,12 +159,11 @@ const useGridColumnHeaders = props => {
|
|
|
194
159
|
hasFocus: hasFocus,
|
|
195
160
|
tabIndex: tabIndex,
|
|
196
161
|
pinnedPosition: pinnedPosition,
|
|
197
|
-
|
|
198
|
-
indexInSection: i,
|
|
199
|
-
sectionLength: renderedColumns.length,
|
|
200
|
-
gridHasFiller: gridHasFiller,
|
|
162
|
+
pinnedOffset: pinnedOffset,
|
|
201
163
|
isLastUnpinned: isLastUnpinned,
|
|
202
|
-
isSiblingFocused: isSiblingFocused
|
|
164
|
+
isSiblingFocused: isSiblingFocused,
|
|
165
|
+
showLeftBorder: showLeftBorder,
|
|
166
|
+
showRightBorder: showRightBorder
|
|
203
167
|
}, other), colDef.field));
|
|
204
168
|
}
|
|
205
169
|
return getFillers(params, columns, 0);
|
|
@@ -211,18 +175,15 @@ const useGridColumnHeaders = props => {
|
|
|
211
175
|
ownerState: rootProps,
|
|
212
176
|
className: _gridClasses.gridClasses['row--borderBottom'],
|
|
213
177
|
children: [leftRenderContext && getColumnHeaders({
|
|
214
|
-
position:
|
|
215
|
-
renderContext: leftRenderContext
|
|
216
|
-
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
178
|
+
position: _constants.PinnedColumnPosition.LEFT,
|
|
179
|
+
renderContext: leftRenderContext
|
|
217
180
|
}, {
|
|
218
181
|
disableReorder: true
|
|
219
182
|
}), getColumnHeaders({
|
|
220
|
-
renderContext
|
|
221
|
-
maxLastColumn: visibleColumns.length - pinnedColumns.right.length
|
|
183
|
+
renderContext
|
|
222
184
|
}), rightRenderContext && getColumnHeaders({
|
|
223
|
-
position:
|
|
224
|
-
renderContext: rightRenderContext
|
|
225
|
-
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
185
|
+
position: _constants.PinnedColumnPosition.RIGHT,
|
|
186
|
+
renderContext: rightRenderContext
|
|
226
187
|
}, {
|
|
227
188
|
disableReorder: true,
|
|
228
189
|
separatorSide: _GridColumnHeaderSeparator.GridColumnHeaderSeparatorSides.Left
|
|
@@ -281,14 +242,11 @@ const useGridColumnHeaders = props => {
|
|
|
281
242
|
tabIndex
|
|
282
243
|
};
|
|
283
244
|
const pinnedPosition = params.position;
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
columnIndex,
|
|
287
|
-
computedWidth: headerInfo.width
|
|
288
|
-
});
|
|
245
|
+
const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
|
|
246
|
+
const pinnedOffset = (0, _getPinnedCellOffset.getPinnedCellOffset)(pinnedPosition, headerInfo.width, columnIndex, columnPositions, dimensions.columnsTotalWidth, scrollbarWidth);
|
|
289
247
|
columnIndex += columnFields.length;
|
|
290
248
|
let indexInSection = index;
|
|
291
|
-
if (pinnedPosition ===
|
|
249
|
+
if (pinnedPosition === _constants.PinnedColumnPosition.LEFT) {
|
|
292
250
|
// Group headers can expand to multiple columns, we need to adjust the index
|
|
293
251
|
indexInSection = columnIndex - 1;
|
|
294
252
|
}
|
|
@@ -304,10 +262,9 @@ const useGridColumnHeaders = props => {
|
|
|
304
262
|
hasFocus: hasFocus,
|
|
305
263
|
tabIndex: tabIndex,
|
|
306
264
|
pinnedPosition: pinnedPosition,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
gridHasFiller: gridHasFiller
|
|
265
|
+
pinnedOffset: pinnedOffset,
|
|
266
|
+
showLeftBorder: (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection),
|
|
267
|
+
showRightBorder: (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, visibleColumnGroupHeader.length, rootProps.showCellVerticalBorder, gridHasFiller)
|
|
311
268
|
}, index);
|
|
312
269
|
});
|
|
313
270
|
return getFillers(params, children, leftOverflow);
|
|
@@ -325,7 +282,7 @@ const useGridColumnHeaders = props => {
|
|
|
325
282
|
children: [leftRenderContext && getColumnGroupHeaders({
|
|
326
283
|
depth,
|
|
327
284
|
params: {
|
|
328
|
-
position:
|
|
285
|
+
position: _constants.PinnedColumnPosition.LEFT,
|
|
329
286
|
renderContext: leftRenderContext,
|
|
330
287
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
331
288
|
}
|
|
@@ -337,7 +294,7 @@ const useGridColumnHeaders = props => {
|
|
|
337
294
|
}), rightRenderContext && getColumnGroupHeaders({
|
|
338
295
|
depth,
|
|
339
296
|
params: {
|
|
340
|
-
position:
|
|
297
|
+
position: _constants.PinnedColumnPosition.RIGHT,
|
|
341
298
|
renderContext: rightRenderContext,
|
|
342
299
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
343
300
|
}
|
|
@@ -352,11 +309,12 @@ const useGridColumnHeaders = props => {
|
|
|
352
309
|
rightRenderContext,
|
|
353
310
|
pinnedColumns,
|
|
354
311
|
visibleColumns,
|
|
355
|
-
|
|
312
|
+
columnPositions,
|
|
356
313
|
getFillers,
|
|
357
314
|
getColumnHeadersRow,
|
|
358
315
|
getColumnsToRender,
|
|
359
316
|
getColumnGroupHeadersRows,
|
|
317
|
+
getPinnedCellOffset: _getPinnedCellOffset.getPinnedCellOffset,
|
|
360
318
|
isDragging: !!dragCol,
|
|
361
319
|
getInnerProps: () => ({
|
|
362
320
|
role: 'rowgroup'
|
|
@@ -49,7 +49,6 @@ const useGridColumnMenu = apiRef => {
|
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
apiRef.current.hidePreferences();
|
|
52
|
-
apiRef.current.forceUpdate();
|
|
53
52
|
}
|
|
54
53
|
}, [apiRef, logger]);
|
|
55
54
|
const hideColumnMenu = React.useCallback(() => {
|
|
@@ -91,7 +90,6 @@ const useGridColumnMenu = apiRef => {
|
|
|
91
90
|
columnMenu: newState
|
|
92
91
|
});
|
|
93
92
|
});
|
|
94
|
-
apiRef.current.forceUpdate();
|
|
95
93
|
}
|
|
96
94
|
}, [apiRef, logger]);
|
|
97
95
|
const toggleColumnMenu = React.useCallback(field => {
|
|
@@ -202,8 +202,10 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
202
202
|
const prevWidth = refs.columnHeaderElement.offsetWidth;
|
|
203
203
|
const widthDiff = newWidth - prevWidth;
|
|
204
204
|
const columnWidthDiff = newWidth - refs.initialColWidth;
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
if (columnWidthDiff > 0) {
|
|
206
|
+
const newTotalWidth = refs.initialTotalWidth + columnWidthDiff;
|
|
207
|
+
apiRef.current.rootElementRef?.current?.style.setProperty('--DataGrid-rowWidth', `${newTotalWidth}px`);
|
|
208
|
+
}
|
|
207
209
|
refs.colDef.computedWidth = newWidth;
|
|
208
210
|
refs.colDef.width = newWidth;
|
|
209
211
|
refs.colDef.flex = 0;
|
|
@@ -24,6 +24,7 @@ var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
|
24
24
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
25
25
|
var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
26
26
|
var _dataGridPropsDefaultValues = require("../../../constants/dataGridPropsDefaultValues");
|
|
27
|
+
var _isJSDOM = require("../../../utils/isJSDOM");
|
|
27
28
|
const EMPTY_SIZE = {
|
|
28
29
|
width: 0,
|
|
29
30
|
height: 0
|
|
@@ -247,14 +248,11 @@ function useGridDimensions(apiRef, props) {
|
|
|
247
248
|
const isFirstSizing = React.useRef(true);
|
|
248
249
|
const handleResize = React.useCallback(size => {
|
|
249
250
|
rootDimensionsRef.current = size;
|
|
250
|
-
|
|
251
|
-
// jsdom has no layout capabilities
|
|
252
|
-
const isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
253
|
-
if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
|
|
251
|
+
if (size.height === 0 && !errorShown.current && !props.autoHeight && !_isJSDOM.isJSDOM) {
|
|
254
252
|
logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
255
253
|
errorShown.current = true;
|
|
256
254
|
}
|
|
257
|
-
if (size.width === 0 && !errorShown.current && !isJSDOM) {
|
|
255
|
+
if (size.width === 0 && !errorShown.current && !_isJSDOM.isJSDOM) {
|
|
258
256
|
logger.error(['The parent DOM element of the Data Grid has an empty width.', 'Please make sure that this element has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
|
|
259
257
|
errorShown.current = true;
|
|
260
258
|
}
|
|
@@ -55,7 +55,12 @@ const gridFilteredDescendantCountLookupSelector = exports.gridFilteredDescendant
|
|
|
55
55
|
* Does not contain the collapsed children.
|
|
56
56
|
* @category Filtering
|
|
57
57
|
*/
|
|
58
|
-
const gridExpandedSortedRowEntriesSelector = exports.gridExpandedSortedRowEntriesSelector = (0, _createSelector.createSelectorMemoized)(gridVisibleRowsLookupSelector, _gridSortingSelector.gridSortedRowEntriesSelector, (visibleRowsLookup, sortedRows
|
|
58
|
+
const gridExpandedSortedRowEntriesSelector = exports.gridExpandedSortedRowEntriesSelector = (0, _createSelector.createSelectorMemoized)(gridVisibleRowsLookupSelector, _gridSortingSelector.gridSortedRowEntriesSelector, _gridRowsSelector.gridRowMaximumTreeDepthSelector, gridFilterModelSelector, gridQuickFilterValuesSelector, (visibleRowsLookup, sortedRows, maxDepth, filterModel, quickFilterValues) => {
|
|
59
|
+
if (maxDepth < 2 && !filterModel.items.length && !quickFilterValues?.length) {
|
|
60
|
+
return sortedRows;
|
|
61
|
+
}
|
|
62
|
+
return sortedRows.filter(row => visibleRowsLookup[row.id] !== false);
|
|
63
|
+
});
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
66
|
* Get the id of the rows accessible after the filtering process.
|
|
@@ -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 {
|
|
29
|
+
* @param {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 {
|
|
147
|
+
* @param {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 {
|
|
195
|
+
* @param {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;
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridPreferencePanelStateSelector = void 0;
|
|
6
|
+
exports.gridPreferencePanelStateSelector = exports.gridPreferencePanelSelectorWithLabel = void 0;
|
|
7
|
+
var _createSelector = require("../../../utils/createSelector");
|
|
7
8
|
const gridPreferencePanelStateSelector = state => state.preferencePanel;
|
|
8
|
-
exports.gridPreferencePanelStateSelector = gridPreferencePanelStateSelector;
|
|
9
|
+
exports.gridPreferencePanelStateSelector = gridPreferencePanelStateSelector;
|
|
10
|
+
const gridPreferencePanelSelectorWithLabel = exports.gridPreferencePanelSelectorWithLabel = (0, _createSelector.createSelectorV8)(gridPreferencePanelStateSelector, (panel, labelId) => {
|
|
11
|
+
if (panel.open && panel.labelId === labelId) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
});
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
gridPreferencePanelStateSelector: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "gridPreferencePanelStateSelector", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _gridPreferencePanelSelector.gridPreferencePanelStateSelector;
|
|
13
|
+
}
|
|
16
14
|
});
|
|
15
|
+
var _gridPreferencePanelSelector = require("./gridPreferencePanelSelector");
|
|
17
16
|
var _gridPreferencePanelState = require("./gridPreferencePanelState");
|
|
18
17
|
Object.keys(_gridPreferencePanelState).forEach(function (key) {
|
|
19
18
|
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
20
|
if (key in exports && exports[key] === _gridPreferencePanelState[key]) return;
|
|
21
21
|
Object.defineProperty(exports, key, {
|
|
22
22
|
enumerable: true,
|
|
@@ -28,6 +28,7 @@ Object.keys(_gridPreferencePanelState).forEach(function (key) {
|
|
|
28
28
|
var _gridPreferencePanelsValue = require("./gridPreferencePanelsValue");
|
|
29
29
|
Object.keys(_gridPreferencePanelsValue).forEach(function (key) {
|
|
30
30
|
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
32
|
if (key in exports && exports[key] === _gridPreferencePanelsValue[key]) return;
|
|
32
33
|
Object.defineProperty(exports, key, {
|
|
33
34
|
enumerable: true,
|
|
@@ -24,42 +24,29 @@ 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(undefined);
|
|
28
|
-
const immediateTimeout = React.useRef(undefined);
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
29
|
* API METHODS
|
|
32
30
|
*/
|
|
33
31
|
const hidePreferences = React.useCallback(() => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
apiRef.current.setState(state => {
|
|
33
|
+
if (!state.preferencePanel.open) {
|
|
34
|
+
return state;
|
|
35
|
+
}
|
|
36
|
+
logger.debug('Hiding Preferences Panel');
|
|
37
|
+
const preferencePanelState = (0, _gridPreferencePanelSelector.gridPreferencePanelStateSelector)(state);
|
|
37
38
|
apiRef.current.publishEvent('preferencePanelClose', {
|
|
38
39
|
openedPanelValue: preferencePanelState.openedPanelValue
|
|
39
40
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
apiRef.current.forceUpdate();
|
|
41
|
+
return (0, _extends2.default)({}, state, {
|
|
42
|
+
preferencePanel: {
|
|
43
|
+
open: false
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
47
|
}, [apiRef, logger]);
|
|
48
|
-
|
|
49
|
-
// This is to prevent the preferences from closing when you open a select box or another panel,
|
|
50
|
-
// The issue is in MUI core V4 => Fixed in V5
|
|
51
|
-
const doNotHidePanel = React.useCallback(() => {
|
|
52
|
-
immediateTimeout.current = setTimeout(() => clearTimeout(hideTimeout.current), 0);
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
|
-
// This is a hack for the issue with Core V4, by delaying hiding the panel on the clickAwayListener,
|
|
56
|
-
// we can cancel the action if the trigger element still need the panel...
|
|
57
|
-
const hidePreferencesDelayed = React.useCallback(() => {
|
|
58
|
-
hideTimeout.current = setTimeout(hidePreferences, 100);
|
|
59
|
-
}, [hidePreferences]);
|
|
60
48
|
const showPreferences = React.useCallback((newValue, panelId, labelId) => {
|
|
61
49
|
logger.debug('Opening Preferences Panel');
|
|
62
|
-
doNotHidePanel();
|
|
63
50
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
64
51
|
preferencePanel: (0, _extends2.default)({}, state.preferencePanel, {
|
|
65
52
|
open: true,
|
|
@@ -71,11 +58,10 @@ const useGridPreferencesPanel = (apiRef, props) => {
|
|
|
71
58
|
apiRef.current.publishEvent('preferencePanelOpen', {
|
|
72
59
|
openedPanelValue: newValue
|
|
73
60
|
});
|
|
74
|
-
|
|
75
|
-
}, [logger, doNotHidePanel, apiRef]);
|
|
61
|
+
}, [logger, apiRef]);
|
|
76
62
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, {
|
|
77
63
|
showPreferences,
|
|
78
|
-
hidePreferences
|
|
64
|
+
hidePreferences
|
|
79
65
|
}, 'public');
|
|
80
66
|
|
|
81
67
|
/**
|
|
@@ -108,15 +94,5 @@ const useGridPreferencesPanel = (apiRef, props) => {
|
|
|
108
94
|
}, [apiRef]);
|
|
109
95
|
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'exportState', stateExportPreProcessing);
|
|
110
96
|
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* EFFECTS
|
|
114
|
-
*/
|
|
115
|
-
React.useEffect(() => {
|
|
116
|
-
return () => {
|
|
117
|
-
clearTimeout(hideTimeout.current);
|
|
118
|
-
clearTimeout(immediateTimeout.current);
|
|
119
|
-
};
|
|
120
|
-
}, []);
|
|
121
97
|
};
|
|
122
98
|
exports.useGridPreferencesPanel = useGridPreferencesPanel;
|
|
@@ -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 {
|
|
31
|
+
* @param {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 {
|
|
84
|
+
* @param {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) => {
|