@mui/x-data-grid 7.24.1 → 7.26.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 +148 -0
- package/DataGrid/DataGrid.js +1 -7
- package/DataGrid/useDataGridComponent.js +2 -2
- package/components/GridRow.d.ts +0 -1
- package/components/GridRow.js +32 -20
- package/components/GridScrollArea.d.ts +5 -2
- package/components/GridScrollArea.js +32 -25
- package/components/GridSkeletonLoadingOverlay.js +2 -1
- package/components/cell/GridCell.d.ts +9 -6
- package/components/cell/GridCell.js +29 -52
- package/components/containers/GridRoot.js +11 -9
- package/components/containers/GridRootStyles.js +138 -40
- package/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/components/virtualization/GridMainContainer.d.ts +10 -0
- package/components/virtualization/GridMainContainer.js +10 -2
- package/components/virtualization/GridVirtualScrollbar.d.ts +4 -0
- package/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/components/virtualization/GridVirtualScroller.js +36 -16
- package/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/hooks/core/useGridStateInitialization.js +3 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +0 -5
- package/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/hooks/features/columns/useGridColumns.js +7 -3
- package/hooks/features/dimensions/gridDimensionsSelectors.d.ts +16 -0
- package/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/hooks/features/dimensions/index.d.ts +1 -1
- package/hooks/features/dimensions/index.js +1 -2
- package/hooks/features/dimensions/useGridDimensions.js +102 -77
- package/hooks/features/editing/gridEditingSelectors.d.ts +10 -0
- package/hooks/features/editing/gridEditingSelectors.js +12 -1
- package/hooks/features/editing/index.d.ts +1 -1
- package/hooks/features/editing/index.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridRowEditing.js +8 -9
- package/hooks/features/filter/gridFilterState.d.ts +5 -0
- package/hooks/features/filter/gridFilterState.js +5 -0
- package/hooks/features/filter/useGridFilter.js +6 -13
- package/hooks/features/focus/useGridFocus.js +3 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/hooks/features/keyboardNavigation/utils.d.ts +1 -2
- package/hooks/features/keyboardNavigation/utils.js +0 -5
- package/hooks/features/listView/useGridListView.js +2 -1
- package/hooks/features/pagination/useGridPagination.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +4 -4
- package/hooks/features/rowSelection/utils.js +1 -1
- package/hooks/features/rows/gridRowsMetaState.d.ts +8 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +0 -4
- package/hooks/features/rows/gridRowsUtils.js +0 -16
- package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
- package/hooks/features/rows/useGridParamsApi.js +33 -14
- package/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/hooks/features/rows/useGridRows.js +7 -8
- package/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +15 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
- package/hooks/utils/useGridSelector.d.ts +8 -1
- package/hooks/utils/useGridSelector.js +42 -8
- package/hooks/utils/useIsSSR.d.ts +1 -0
- package/hooks/utils/useIsSSR.js +5 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +29 -2
- package/models/api/gridStateApi.d.ts +1 -0
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +6 -0
- package/modern/DataGrid/DataGrid.js +1 -7
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/components/GridRow.js +32 -20
- package/modern/components/GridScrollArea.js +32 -25
- package/modern/components/GridSkeletonLoadingOverlay.js +2 -1
- package/modern/components/cell/GridCell.js +29 -52
- package/modern/components/containers/GridRoot.js +11 -9
- package/modern/components/containers/GridRootStyles.js +138 -40
- package/modern/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/modern/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/modern/components/virtualization/GridMainContainer.js +10 -2
- package/modern/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/modern/components/virtualization/GridVirtualScroller.js +36 -16
- package/modern/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/modern/hooks/core/useGridStateInitialization.js +3 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/modern/hooks/features/columns/useGridColumns.js +7 -3
- package/modern/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/modern/hooks/features/dimensions/index.js +1 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +102 -77
- package/modern/hooks/features/editing/gridEditingSelectors.js +12 -1
- package/modern/hooks/features/editing/index.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +8 -9
- package/modern/hooks/features/filter/gridFilterState.js +5 -0
- package/modern/hooks/features/filter/useGridFilter.js +6 -13
- package/modern/hooks/features/focus/useGridFocus.js +3 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/modern/hooks/features/keyboardNavigation/utils.js +0 -5
- package/modern/hooks/features/listView/useGridListView.js +2 -1
- package/modern/hooks/features/pagination/useGridPagination.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +4 -4
- package/modern/hooks/features/rowSelection/utils.js +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -16
- package/modern/hooks/features/rows/useGridParamsApi.js +33 -14
- package/modern/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/modern/hooks/features/rows/useGridRows.js +7 -8
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/modern/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
- package/modern/hooks/utils/useGridSelector.js +42 -8
- package/modern/hooks/utils/useIsSSR.js +5 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -1
- package/modern/models/api/index.js +0 -1
- package/modern/utils/roundToDecimalPlaces.js +3 -0
- package/modern/utils/utils.js +6 -1
- package/node/DataGrid/DataGrid.js +1 -7
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/components/GridRow.js +28 -17
- package/node/components/GridScrollArea.js +31 -24
- package/node/components/GridSkeletonLoadingOverlay.js +2 -1
- package/node/components/cell/GridCell.js +27 -50
- package/node/components/containers/GridRoot.js +10 -8
- package/node/components/containers/GridRootStyles.js +138 -40
- package/node/components/toolbar/GridToolbarColumnsButton.js +5 -4
- package/node/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/node/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/node/components/toolbar/GridToolbarFilterButton.js +4 -3
- package/node/components/virtualization/GridMainContainer.js +10 -2
- package/node/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/node/components/virtualization/GridVirtualScroller.js +36 -16
- package/node/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/node/hooks/core/useGridStateInitialization.js +3 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/columns/gridColumnsSelector.js +1 -13
- package/node/hooks/features/columns/useGridColumns.js +7 -3
- package/node/hooks/features/dimensions/gridDimensionsSelectors.js +38 -2
- package/node/hooks/features/dimensions/index.js +13 -11
- package/node/hooks/features/dimensions/useGridDimensions.js +99 -74
- package/node/hooks/features/editing/gridEditingSelectors.js +12 -2
- package/node/hooks/features/editing/index.js +7 -11
- package/node/hooks/features/editing/useGridCellEditing.js +2 -2
- package/node/hooks/features/editing/useGridRowEditing.js +6 -7
- package/node/hooks/features/filter/gridFilterState.js +6 -1
- package/node/hooks/features/filter/useGridFilter.js +5 -12
- package/node/hooks/features/focus/useGridFocus.js +3 -2
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -15
- package/node/hooks/features/keyboardNavigation/utils.js +0 -6
- package/node/hooks/features/listView/useGridListView.js +2 -1
- package/node/hooks/features/pagination/useGridPagination.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +3 -3
- package/node/hooks/features/rowSelection/utils.js +1 -1
- package/node/hooks/features/rows/gridRowsUtils.js +0 -17
- package/node/hooks/features/rows/useGridParamsApi.js +33 -14
- package/node/hooks/features/rows/useGridRowSpanning.js +92 -89
- package/node/hooks/features/rows/useGridRows.js +7 -8
- package/node/hooks/features/rows/useGridRowsMeta.js +36 -19
- package/node/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +73 -71
- package/node/hooks/utils/useGridSelector.js +42 -8
- package/node/hooks/utils/useIsSSR.js +12 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +20 -7
- package/node/models/api/index.js +0 -11
- package/node/utils/roundToDecimalPlaces.js +9 -0
- package/node/utils/utils.js +8 -1
- package/package.json +3 -2
- package/utils/roundToDecimalPlaces.d.ts +1 -0
- package/utils/roundToDecimalPlaces.js +3 -0
- package/utils/utils.d.ts +1 -0
- package/utils/utils.js +6 -1
|
@@ -25,17 +25,11 @@ const configuration = {
|
|
|
25
25
|
useGridRowAriaAttributes: _useGridRowAriaAttributes.useGridRowAriaAttributes
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
let propValidators;
|
|
29
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
30
|
-
propValidators = [..._propValidation.propValidatorsDataGrid,
|
|
31
|
-
// Only validate in MIT version
|
|
32
|
-
props => props.columns && props.columns.some(column => column.resizable) && [`MUI X: \`column.resizable = true\` is not a valid prop.`, 'Column resizing is not available in the MIT version.', '', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n') || undefined];
|
|
33
|
-
}
|
|
34
28
|
const DataGridRaw = (0, _forwardRef.forwardRef)(function DataGrid(inProps, ref) {
|
|
35
29
|
const props = (0, _useDataGridProps.useDataGridProps)(inProps);
|
|
36
30
|
const privateApiRef = (0, _useDataGridComponent.useDataGridComponent)(props.apiRef, props);
|
|
37
31
|
if (process.env.NODE_ENV !== 'production') {
|
|
38
|
-
(0, _propValidation.validateProps)(props,
|
|
32
|
+
(0, _propValidation.validateProps)(props, _propValidation.propValidatorsDataGrid);
|
|
39
33
|
}
|
|
40
34
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridContextProvider.GridContextProvider, {
|
|
41
35
|
privateApiRef: privateApiRef,
|
|
@@ -47,7 +47,6 @@ const useDataGridComponent = (inputApiRef, props) => {
|
|
|
47
47
|
/**
|
|
48
48
|
* Register all state initializers here.
|
|
49
49
|
*/
|
|
50
|
-
(0, _useGridInitializeState.useGridInitializeState)(_useGridDimensions.dimensionsStateInitializer, apiRef, props);
|
|
51
50
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridRowSelection.rowSelectionStateInitializer, apiRef, props);
|
|
52
51
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridColumns.columnsStateInitializer, apiRef, props);
|
|
53
52
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridPagination.paginationStateInitializer, apiRef, props);
|
|
@@ -60,10 +59,11 @@ const useDataGridComponent = (inputApiRef, props) => {
|
|
|
60
59
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridRowSpanning.rowSpanningStateInitializer, apiRef, props);
|
|
61
60
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridDensity.densityStateInitializer, apiRef, props);
|
|
62
61
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridColumnResize.columnResizeStateInitializer, apiRef, props);
|
|
63
|
-
(0, _useGridInitializeState.useGridInitializeState)(_useGridRowsMeta.rowsMetaStateInitializer, apiRef, props);
|
|
64
62
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridColumnMenu.columnMenuStateInitializer, apiRef, props);
|
|
65
63
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridColumnGrouping.columnGroupsStateInitializer, apiRef, props);
|
|
66
64
|
(0, _useGridInitializeState.useGridInitializeState)(_virtualization.virtualizationStateInitializer, apiRef, props);
|
|
65
|
+
(0, _useGridInitializeState.useGridInitializeState)(_useGridDimensions.dimensionsStateInitializer, apiRef, props);
|
|
66
|
+
(0, _useGridInitializeState.useGridInitializeState)(_useGridRowsMeta.rowsMetaStateInitializer, apiRef, props);
|
|
67
67
|
(0, _useGridInitializeState.useGridInitializeState)(_useGridListView.listViewStateInitializer, apiRef, props);
|
|
68
68
|
(0, _useGridKeyboardNavigation.useGridKeyboardNavigation)(apiRef, props);
|
|
69
69
|
(0, _useGridRowSelection.useGridRowSelection)(apiRef, props);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
'use client';
|
|
2
3
|
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
5
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
@@ -14,6 +15,7 @@ var _clsx = _interopRequireDefault(require("clsx"));
|
|
|
14
15
|
var _utils = require("@mui/utils");
|
|
15
16
|
var _fastMemo = require("@mui/x-internals/fastMemo");
|
|
16
17
|
var _forwardRef = require("@mui/x-internals/forwardRef");
|
|
18
|
+
var _isObjectEmpty = require("@mui/x-internals/isObjectEmpty");
|
|
17
19
|
var _gridEditRowModel = require("../models/gridEditRowModel");
|
|
18
20
|
var _gridClasses = require("../constants/gridClasses");
|
|
19
21
|
var _composeGridClasses = require("../utils/composeGridClasses");
|
|
@@ -33,8 +35,16 @@ var _GridScrollbarFillerCell = require("./GridScrollbarFillerCell");
|
|
|
33
35
|
var _getPinnedCellOffset = require("../internals/utils/getPinnedCellOffset");
|
|
34
36
|
var _useGridConfiguration = require("../hooks/utils/useGridConfiguration");
|
|
35
37
|
var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
|
|
38
|
+
var _createSelector = require("../utils/createSelector");
|
|
36
39
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
37
|
-
const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "pinnedColumns", "
|
|
40
|
+
const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "pinnedColumns", "offsetLeft", "columnsTotalWidth", "firstColumnIndex", "lastColumnIndex", "focusedColumnIndex", "isFirstVisible", "isLastVisible", "isNotVisible", "showBottomBorder", "scrollbarWidth", "gridHasFiller", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
|
|
41
|
+
const isRowReorderingEnabledSelector = (0, _createSelector.createSelectorV8)(_gridEditingSelectors.gridEditRowsStateSelector, (editRows, rowReordering) => {
|
|
42
|
+
if (!rowReordering) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const isEditingRows = !(0, _isObjectEmpty.isObjectEmpty)(editRows);
|
|
46
|
+
return !isEditingRows;
|
|
47
|
+
});
|
|
38
48
|
const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
39
49
|
const {
|
|
40
50
|
selected,
|
|
@@ -73,10 +83,14 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
73
83
|
const sortModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridSortingSelector.gridSortModelSelector);
|
|
74
84
|
const treeDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowMaximumTreeDepthSelector);
|
|
75
85
|
const columnPositions = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnPositionsSelector);
|
|
76
|
-
const
|
|
86
|
+
const rowReordering = rootProps.rowReordering;
|
|
87
|
+
const isRowReorderingEnabled = (0, _useGridSelector.useGridSelectorV8)(apiRef, isRowReorderingEnabledSelector, rowReordering);
|
|
77
88
|
const handleRef = (0, _utils.unstable_useForkRef)(ref, refProp);
|
|
78
89
|
const rowNode = apiRef.current.getRowNode(rowId);
|
|
79
|
-
const editing =
|
|
90
|
+
const editing = (0, _useGridSelector.useGridSelectorV8)(apiRef, _gridEditingSelectors.gridRowIsEditingSelector, {
|
|
91
|
+
rowId,
|
|
92
|
+
editMode: rootProps.editMode
|
|
93
|
+
});
|
|
80
94
|
const editable = rootProps.editMode === _gridEditRowModel.GridEditModes.Row;
|
|
81
95
|
const hasFocusCell = focusedColumnIndex !== undefined;
|
|
82
96
|
const hasVirtualFocusCellLeft = hasFocusCell && focusedColumnIndex >= pinnedColumns.left.length && focusedColumnIndex < firstColumnIndex;
|
|
@@ -153,7 +167,6 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
153
167
|
slotProps,
|
|
154
168
|
disableColumnReorder
|
|
155
169
|
} = rootProps;
|
|
156
|
-
const rowReordering = rootProps.rowReordering;
|
|
157
170
|
const heightEntry = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _extends2.default)({}, apiRef.current.getRowHeightEntry(rowId)), _useGridSelector.objectShallowCompare);
|
|
158
171
|
const style = React.useMemo(() => {
|
|
159
172
|
if (isNotVisible) {
|
|
@@ -196,6 +209,11 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
196
209
|
});
|
|
197
210
|
rowClassNames.push(rootProps.getRowClassName(rowParams));
|
|
198
211
|
}
|
|
212
|
+
|
|
213
|
+
/* Start of rendering */
|
|
214
|
+
if (!rowNode) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
199
217
|
const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = _constants.PinnedColumnPosition.NONE) => {
|
|
200
218
|
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
|
|
201
219
|
if (cellColSpanInfo?.spannedByColSpan) {
|
|
@@ -213,14 +231,12 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
213
231
|
align: column.align
|
|
214
232
|
}, column.field);
|
|
215
233
|
}
|
|
216
|
-
const editCellState = editRowsState[rowId]?.[column.field] ?? null;
|
|
217
234
|
|
|
218
235
|
// when the cell is a reorder cell we are not allowing to reorder the col
|
|
219
236
|
// fixes https://github.com/mui/mui-x/issues/11126
|
|
220
237
|
const isReorderCell = column.field === '__reorder__';
|
|
221
|
-
const isEditingRows = Object.keys(editRowsState).length > 0;
|
|
222
238
|
const canReorderColumn = !(disableColumnReorder || column.disableReorder);
|
|
223
|
-
const canReorderRow =
|
|
239
|
+
const canReorderRow = isRowReorderingEnabled && !sortModel.length && treeDepth <= 1;
|
|
224
240
|
const disableDragEvents = !(canReorderColumn || isReorderCell && canReorderRow);
|
|
225
241
|
const cellIsNotVisible = pinnedPosition === _constants.PinnedColumnPosition.VIRTUAL;
|
|
226
242
|
const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection);
|
|
@@ -233,20 +249,15 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
233
249
|
colIndex: indexRelativeToAllColumns,
|
|
234
250
|
colSpan: colSpan,
|
|
235
251
|
disableDragEvents: disableDragEvents,
|
|
236
|
-
editCellState: editCellState,
|
|
237
252
|
isNotVisible: cellIsNotVisible,
|
|
238
253
|
pinnedOffset: pinnedOffset,
|
|
239
254
|
pinnedPosition: pinnedPosition,
|
|
240
255
|
showLeftBorder: showLeftBorder,
|
|
241
|
-
showRightBorder: showRightBorder
|
|
256
|
+
showRightBorder: showRightBorder,
|
|
257
|
+
row: row,
|
|
258
|
+
rowNode: rowNode
|
|
242
259
|
}, slotProps?.cell), column.field);
|
|
243
260
|
};
|
|
244
|
-
|
|
245
|
-
/* Start of rendering */
|
|
246
|
-
|
|
247
|
-
if (!rowNode) {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
261
|
const leftCells = pinnedColumns.left.map((column, i) => {
|
|
251
262
|
const indexRelativeToAllColumns = i;
|
|
252
263
|
return getCell(column, i, indexRelativeToAllColumns, pinnedColumns.left.length, _constants.PinnedColumnPosition.LEFT);
|
|
@@ -297,7 +308,8 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
297
308
|
role: "presentation",
|
|
298
309
|
className: (0, _clsx.default)(_gridClasses.gridClasses.cell, _gridClasses.gridClasses.cellEmpty)
|
|
299
310
|
}), rightCells, scrollbarWidth !== 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridScrollbarFillerCell.GridScrollbarFillerCell, {
|
|
300
|
-
pinnedRight: pinnedColumns.right.length > 0
|
|
311
|
+
pinnedRight: pinnedColumns.right.length > 0,
|
|
312
|
+
borderTop: !isFirstVisible
|
|
301
313
|
})]
|
|
302
314
|
}));
|
|
303
315
|
});
|
|
@@ -324,7 +336,6 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
324
336
|
isNotVisible: _propTypes.default.bool.isRequired,
|
|
325
337
|
lastColumnIndex: _propTypes.default.number.isRequired,
|
|
326
338
|
offsetLeft: _propTypes.default.number.isRequired,
|
|
327
|
-
offsetTop: _propTypes.default.number,
|
|
328
339
|
onClick: _propTypes.default.func,
|
|
329
340
|
onDoubleClick: _propTypes.default.func,
|
|
330
341
|
onMouseEnter: _propTypes.default.func,
|
|
@@ -19,9 +19,9 @@ var _useGridApiEventHandler = require("../hooks/utils/useGridApiEventHandler");
|
|
|
19
19
|
var _useGridSelector = require("../hooks/utils/useGridSelector");
|
|
20
20
|
var _gridDimensionsSelectors = require("../hooks/features/dimensions/gridDimensionsSelectors");
|
|
21
21
|
var _densitySelector = require("../hooks/features/density/densitySelector");
|
|
22
|
-
var _gridColumnsSelector = require("../hooks/features/columns/gridColumnsSelector");
|
|
23
22
|
var _useTimeout = require("../hooks/utils/useTimeout");
|
|
24
23
|
var _gridColumnsUtils = require("../hooks/features/columns/gridColumnsUtils");
|
|
24
|
+
var _createSelector = require("../utils/createSelector");
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
26
|
const CLIFF = 1;
|
|
27
27
|
const SLOP = 1.5;
|
|
@@ -56,21 +56,38 @@ const GridScrollAreaRawRoot = (0, _system.styled)('div', {
|
|
|
56
56
|
right: 0
|
|
57
57
|
}
|
|
58
58
|
}));
|
|
59
|
-
|
|
59
|
+
const offsetSelector = (0, _createSelector.createSelectorV8)(_gridDimensionsSelectors.gridDimensionsSelector, (dimensions, direction) => {
|
|
60
|
+
if (direction === 'left') {
|
|
61
|
+
return dimensions.leftPinnedWidth;
|
|
62
|
+
}
|
|
63
|
+
if (direction === 'right') {
|
|
64
|
+
return dimensions.rightPinnedWidth + (dimensions.hasScrollX ? dimensions.scrollbarSize : 0);
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
});
|
|
68
|
+
function GridScrollAreaWrapper(props) {
|
|
69
|
+
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
70
|
+
const [dragging, setDragging] = React.useState(false);
|
|
71
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderDragStart', () => setDragging(true));
|
|
72
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderDragEnd', () => setDragging(false));
|
|
73
|
+
if (!dragging) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridScrollAreaContent, (0, _extends2.default)({}, props));
|
|
77
|
+
}
|
|
78
|
+
function GridScrollAreaContent(props) {
|
|
60
79
|
const {
|
|
61
|
-
scrollDirection
|
|
80
|
+
scrollDirection,
|
|
81
|
+
scrollPosition
|
|
62
82
|
} = props;
|
|
63
83
|
const rootRef = React.useRef(null);
|
|
64
84
|
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
65
85
|
const timeout = (0, _useTimeout.useTimeout)();
|
|
66
86
|
const densityFactor = (0, _useGridSelector.useGridSelector)(apiRef, _densitySelector.gridDensityFactorSelector);
|
|
67
|
-
const columnsTotalWidth = (0, _useGridSelector.useGridSelector)(apiRef,
|
|
68
|
-
const
|
|
69
|
-
const scrollPosition = React.useRef({
|
|
70
|
-
left: 0,
|
|
71
|
-
top: 0
|
|
72
|
-
});
|
|
87
|
+
const columnsTotalWidth = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridColumnsTotalWidthSelector);
|
|
88
|
+
const sideOffset = (0, _useGridSelector.useGridSelectorV8)(apiRef, offsetSelector, scrollDirection);
|
|
73
89
|
const getCanScrollMore = () => {
|
|
90
|
+
const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state);
|
|
74
91
|
if (scrollDirection === 'left') {
|
|
75
92
|
// Only render if the user has not reached yet the start of the list
|
|
76
93
|
return scrollPosition.current.left > 0;
|
|
@@ -82,7 +99,6 @@ function GridScrollAreaRaw(props) {
|
|
|
82
99
|
}
|
|
83
100
|
return false;
|
|
84
101
|
};
|
|
85
|
-
const [dragging, setDragging] = React.useState(false);
|
|
86
102
|
const [canScrollMore, setCanScrollMore] = React.useState(getCanScrollMore);
|
|
87
103
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
88
104
|
const ownerState = (0, _extends2.default)({}, rootProps, {
|
|
@@ -96,12 +112,11 @@ function GridScrollAreaRaw(props) {
|
|
|
96
112
|
top: totalHeaderHeight - headerHeight
|
|
97
113
|
};
|
|
98
114
|
if (scrollDirection === 'left') {
|
|
99
|
-
style.left =
|
|
115
|
+
style.left = sideOffset;
|
|
100
116
|
} else if (scrollDirection === 'right') {
|
|
101
|
-
style.right =
|
|
117
|
+
style.right = sideOffset;
|
|
102
118
|
}
|
|
103
|
-
const handleScrolling =
|
|
104
|
-
scrollPosition.current = newScrollPosition;
|
|
119
|
+
const handleScrolling = () => {
|
|
105
120
|
setCanScrollMore(getCanScrollMore);
|
|
106
121
|
};
|
|
107
122
|
const handleDragOver = (0, _utils.unstable_useEventCallback)(event => {
|
|
@@ -126,16 +141,8 @@ function GridScrollAreaRaw(props) {
|
|
|
126
141
|
});
|
|
127
142
|
});
|
|
128
143
|
});
|
|
129
|
-
const handleColumnHeaderDragStart = (0, _utils.unstable_useEventCallback)(() => {
|
|
130
|
-
setDragging(true);
|
|
131
|
-
});
|
|
132
|
-
const handleColumnHeaderDragEnd = (0, _utils.unstable_useEventCallback)(() => {
|
|
133
|
-
setDragging(false);
|
|
134
|
-
});
|
|
135
144
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'scrollPositionChange', handleScrolling);
|
|
136
|
-
(
|
|
137
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderDragEnd', handleColumnHeaderDragEnd);
|
|
138
|
-
if (!dragging || !canScrollMore) {
|
|
145
|
+
if (!canScrollMore) {
|
|
139
146
|
return null;
|
|
140
147
|
}
|
|
141
148
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridScrollAreaRawRoot, {
|
|
@@ -146,4 +153,4 @@ function GridScrollAreaRaw(props) {
|
|
|
146
153
|
style: style
|
|
147
154
|
});
|
|
148
155
|
}
|
|
149
|
-
const GridScrollArea = exports.GridScrollArea = (0, _fastMemo.fastMemo)(
|
|
156
|
+
const GridScrollArea = exports.GridScrollArea = (0, _fastMemo.fastMemo)(GridScrollAreaWrapper);
|
|
@@ -18,6 +18,7 @@ var _useGridApiContext = require("../hooks/utils/useGridApiContext");
|
|
|
18
18
|
var _useGridRootProps = require("../hooks/utils/useGridRootProps");
|
|
19
19
|
var _hooks = require("../hooks");
|
|
20
20
|
var _constants = require("../internals/constants");
|
|
21
|
+
var _gridDimensionsSelectors = require("../hooks/features/dimensions/gridDimensionsSelectors");
|
|
21
22
|
var _gridClasses = require("../constants/gridClasses");
|
|
22
23
|
var _getPinnedCellOffset = require("../internals/utils/getPinnedCellOffset");
|
|
23
24
|
var _cellBorderUtils = require("../utils/cellBorderUtils");
|
|
@@ -62,7 +63,7 @@ const GridSkeletonLoadingOverlay = exports.GridSkeletonLoadingOverlay = (0, _for
|
|
|
62
63
|
const dimensions = (0, _hooks.useGridSelector)(apiRef, _hooks.gridDimensionsSelector);
|
|
63
64
|
const viewportHeight = dimensions?.viewportInnerSize.height ?? 0;
|
|
64
65
|
const skeletonRowsCount = Math.ceil(viewportHeight / dimensions.rowHeight);
|
|
65
|
-
const totalWidth = (0, _hooks.useGridSelector)(apiRef,
|
|
66
|
+
const totalWidth = (0, _hooks.useGridSelector)(apiRef, _gridDimensionsSelectors.gridColumnsTotalWidthSelector);
|
|
66
67
|
const positions = (0, _hooks.useGridSelector)(apiRef, _hooks.gridColumnPositionsSelector);
|
|
67
68
|
const inViewportCount = React.useMemo(() => positions.filter(value => value <= totalWidth).length, [totalWidth, positions]);
|
|
68
69
|
const allVisibleColumns = (0, _hooks.useGridSelector)(apiRef, _hooks.gridVisibleColumnDefinitionsSelector);
|
|
@@ -19,15 +19,16 @@ var _doesSupportPreventScroll = require("../../utils/doesSupportPreventScroll");
|
|
|
19
19
|
var _gridClasses = require("../../constants/gridClasses");
|
|
20
20
|
var _models = require("../../models");
|
|
21
21
|
var _useGridSelector = require("../../hooks/utils/useGridSelector");
|
|
22
|
-
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
|
|
23
22
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
24
23
|
var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
|
|
25
24
|
var _gridColumnsInterfaces = require("../../hooks/features/columns/gridColumnsInterfaces");
|
|
26
25
|
var _constants = require("../../internals/constants");
|
|
27
26
|
var _gridRowSpanningSelectors = require("../../hooks/features/rows/gridRowSpanningSelectors");
|
|
27
|
+
var _useGridPrivateApiContext = require("../../hooks/utils/useGridPrivateApiContext");
|
|
28
|
+
var _gridEditingSelectors = require("../../hooks/features/editing/gridEditingSelectors");
|
|
28
29
|
var _utils2 = require("../../internals/utils");
|
|
29
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
30
|
-
const _excluded = ["column", "rowId", "
|
|
31
|
+
const _excluded = ["column", "row", "rowId", "rowNode", "align", "children", "colIndex", "width", "className", "style", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "showRightBorder", "showLeftBorder", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
31
32
|
_excluded2 = ["changeReason", "unstable_updateValueOnRender"];
|
|
32
33
|
const gridPinnedColumnPositionLookup = exports.gridPinnedColumnPositionLookup = {
|
|
33
34
|
[_constants.PinnedColumnPosition.LEFT]: _gridColumnsInterfaces.GridPinnedColumnPosition.LEFT,
|
|
@@ -35,30 +36,6 @@ const gridPinnedColumnPositionLookup = exports.gridPinnedColumnPositionLookup =
|
|
|
35
36
|
[_constants.PinnedColumnPosition.NONE]: undefined,
|
|
36
37
|
[_constants.PinnedColumnPosition.VIRTUAL]: undefined
|
|
37
38
|
};
|
|
38
|
-
const EMPTY_CELL_PARAMS = {
|
|
39
|
-
id: -1,
|
|
40
|
-
field: '__unset__',
|
|
41
|
-
row: {},
|
|
42
|
-
rowNode: {
|
|
43
|
-
id: -1,
|
|
44
|
-
depth: 0,
|
|
45
|
-
type: 'leaf',
|
|
46
|
-
parent: -1,
|
|
47
|
-
groupingKey: null
|
|
48
|
-
},
|
|
49
|
-
colDef: {
|
|
50
|
-
type: 'string',
|
|
51
|
-
field: '__unset__',
|
|
52
|
-
computedWidth: 0
|
|
53
|
-
},
|
|
54
|
-
cellMode: _models.GridCellModes.View,
|
|
55
|
-
hasFocus: false,
|
|
56
|
-
tabIndex: -1,
|
|
57
|
-
value: null,
|
|
58
|
-
formattedValue: '__unset__',
|
|
59
|
-
isEditable: false,
|
|
60
|
-
api: {}
|
|
61
|
-
};
|
|
62
39
|
const useUtilityClasses = ownerState => {
|
|
63
40
|
const {
|
|
64
41
|
align,
|
|
@@ -82,8 +59,9 @@ let warnedOnce = false;
|
|
|
82
59
|
const GridCell = (0, _forwardRef.forwardRef)(function GridCell(props, ref) {
|
|
83
60
|
const {
|
|
84
61
|
column,
|
|
62
|
+
row,
|
|
85
63
|
rowId,
|
|
86
|
-
|
|
64
|
+
rowNode,
|
|
87
65
|
align,
|
|
88
66
|
colIndex,
|
|
89
67
|
width,
|
|
@@ -107,22 +85,29 @@ const GridCell = (0, _forwardRef.forwardRef)(function GridCell(props, ref) {
|
|
|
107
85
|
onDragOver
|
|
108
86
|
} = props,
|
|
109
87
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
110
|
-
const apiRef = (0,
|
|
88
|
+
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
111
89
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
112
90
|
const isRtl = (0, _RtlProvider.useRtl)();
|
|
113
91
|
const field = column.field;
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
92
|
+
const editCellState = (0, _useGridSelector.useGridSelectorV8)(apiRef, _gridEditingSelectors.gridEditCellStateSelector, {
|
|
93
|
+
rowId,
|
|
94
|
+
field
|
|
95
|
+
});
|
|
96
|
+
const cellMode = editCellState ? _models.GridCellModes.Edit : _models.GridCellModes.View;
|
|
97
|
+
const cellParams = apiRef.current.getCellParamsForRow(rowId, field, row, {
|
|
98
|
+
colDef: column,
|
|
99
|
+
cellMode,
|
|
100
|
+
rowNode: rowNode,
|
|
101
|
+
tabIndex: (0, _useGridSelector.useGridSelector)(apiRef, () => {
|
|
102
|
+
const cellTabIndex = (0, _gridFocusStateSelector.gridTabIndexCellSelector)(apiRef);
|
|
103
|
+
return cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === rowId ? 0 : -1;
|
|
104
|
+
}),
|
|
105
|
+
hasFocus: (0, _useGridSelector.useGridSelector)(apiRef, () => {
|
|
106
|
+
const focus = (0, _gridFocusStateSelector.gridFocusCellSelector)(apiRef);
|
|
107
|
+
return focus?.id === rowId && focus.field === field;
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
cellParams.api = apiRef.current;
|
|
126
111
|
const isSelected = (0, _useGridSelector.useGridSelector)(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
|
|
127
112
|
id: rowId,
|
|
128
113
|
field
|
|
@@ -130,7 +115,6 @@ const GridCell = (0, _forwardRef.forwardRef)(function GridCell(props, ref) {
|
|
|
130
115
|
const hiddenCells = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowSpanningSelectors.gridRowSpanningHiddenCellsSelector);
|
|
131
116
|
const spannedCells = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowSpanningSelectors.gridRowSpanningSpannedCellsSelector);
|
|
132
117
|
const {
|
|
133
|
-
cellMode,
|
|
134
118
|
hasFocus,
|
|
135
119
|
isEditable = false,
|
|
136
120
|
value
|
|
@@ -252,9 +236,6 @@ const GridCell = (0, _forwardRef.forwardRef)(function GridCell(props, ref) {
|
|
|
252
236
|
}, style)
|
|
253
237
|
});
|
|
254
238
|
}
|
|
255
|
-
if (cellParams === EMPTY_CELL_PARAMS) {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
239
|
let handleFocus = other.onFocus;
|
|
259
240
|
if (process.env.NODE_ENV === 'test' && rootProps.experimentalFeatures?.warnIfFocusStateIsNotSynced) {
|
|
260
241
|
handleFocus = event => {
|
|
@@ -338,16 +319,12 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
338
319
|
colSpan: _propTypes.default.number,
|
|
339
320
|
column: _propTypes.default.object.isRequired,
|
|
340
321
|
disableDragEvents: _propTypes.default.bool,
|
|
341
|
-
editCellState: _propTypes.default.shape({
|
|
342
|
-
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
343
|
-
isProcessingProps: _propTypes.default.bool,
|
|
344
|
-
isValidating: _propTypes.default.bool,
|
|
345
|
-
value: _propTypes.default.any
|
|
346
|
-
}),
|
|
347
322
|
isNotVisible: _propTypes.default.bool.isRequired,
|
|
348
323
|
pinnedOffset: _propTypes.default.number,
|
|
349
324
|
pinnedPosition: _propTypes.default.oneOf([0, 1, 2, 3]).isRequired,
|
|
325
|
+
row: _propTypes.default.object.isRequired,
|
|
350
326
|
rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
327
|
+
rowNode: _propTypes.default.object.isRequired,
|
|
351
328
|
showLeftBorder: _propTypes.default.bool.isRequired,
|
|
352
329
|
showRightBorder: _propTypes.default.bool.isRequired,
|
|
353
330
|
width: _propTypes.default.number.isRequired
|
|
@@ -20,6 +20,7 @@ var _useGridPrivateApiContext = require("../../hooks/utils/useGridPrivateApiCont
|
|
|
20
20
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
21
21
|
var _gridClasses = require("../../constants/gridClasses");
|
|
22
22
|
var _densitySelector = require("../../hooks/features/density/densitySelector");
|
|
23
|
+
var _useIsSSR = require("../../hooks/utils/useIsSSR");
|
|
23
24
|
var _GridHeader = require("../GridHeader");
|
|
24
25
|
var _base = require("../base");
|
|
25
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -45,16 +46,17 @@ const GridRoot = (0, _forwardRef.forwardRef)(function GridRoot(props, ref) {
|
|
|
45
46
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
46
47
|
const density = (0, _useGridSelector.useGridSelector)(apiRef, _densitySelector.gridDensitySelector);
|
|
47
48
|
const rootElementRef = apiRef.current.rootElementRef;
|
|
48
|
-
const
|
|
49
|
+
const rootMountCallback = React.useCallback(node => {
|
|
50
|
+
if (node === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
apiRef.current.publishEvent('rootMount', node);
|
|
54
|
+
}, [apiRef]);
|
|
55
|
+
const handleRef = (0, _utils.unstable_useForkRef)(rootElementRef, ref, rootMountCallback);
|
|
49
56
|
const ownerState = rootProps;
|
|
50
57
|
const classes = useUtilityClasses(ownerState, density);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const [mountedState, setMountedState] = React.useState(false);
|
|
54
|
-
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
55
|
-
setMountedState(true);
|
|
56
|
-
}, []);
|
|
57
|
-
if (!mountedState) {
|
|
58
|
+
const isSSR = (0, _useIsSSR.useIsSSR)();
|
|
59
|
+
if (isSSR) {
|
|
58
60
|
return null;
|
|
59
61
|
}
|
|
60
62
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridRootStyles.GridRootStyles, (0, _extends2.default)({
|