@mui/x-data-grid 7.24.1 → 7.25.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 +77 -0
- package/DataGrid/DataGrid.js +1 -7
- package/components/GridRow.d.ts +0 -1
- package/components/GridRow.js +25 -19
- package/components/cell/GridCell.d.ts +9 -6
- package/components/cell/GridCell.js +29 -52
- package/components/containers/GridRootStyles.js +135 -37
- 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 +18 -5
- package/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/columns/useGridColumns.js +7 -3
- package/hooks/features/dimensions/useGridDimensions.js +6 -8
- package/hooks/features/editing/gridEditingSelectors.d.ts +6 -0
- package/hooks/features/editing/gridEditingSelectors.js +7 -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 +5 -6
- 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/rowSelection/useGridRowSelection.js +3 -3
- 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 +3 -2
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +9 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +31 -45
- package/index.js +1 -1
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +29 -2
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/modern/DataGrid/DataGrid.js +1 -7
- package/modern/components/GridRow.js +25 -19
- package/modern/components/cell/GridCell.js +29 -52
- package/modern/components/containers/GridRootStyles.js +135 -37
- 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 +18 -5
- package/modern/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/columns/useGridColumns.js +7 -3
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -8
- package/modern/hooks/features/editing/gridEditingSelectors.js +7 -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 +5 -6
- 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/rowSelection/useGridRowSelection.js +3 -3
- 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 +3 -2
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +31 -45
- package/modern/index.js +1 -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/components/GridRow.js +22 -16
- package/node/components/cell/GridCell.js +27 -50
- package/node/components/containers/GridRootStyles.js +135 -37
- 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 +18 -5
- package/node/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/columns/useGridColumns.js +7 -3
- package/node/hooks/features/dimensions/useGridDimensions.js +6 -8
- package/node/hooks/features/editing/gridEditingSelectors.js +8 -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 +3 -4
- 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/rowSelection/useGridRowSelection.js +2 -2
- 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 +5 -4
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +31 -45
- package/node/index.js +1 -1
- 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 +2 -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
|
@@ -6,7 +6,7 @@ import { gridRenderContextSelector } from "./gridVirtualizationSelectors.js";
|
|
|
6
6
|
import { gridFocusCellSelector } from "../focus/index.js";
|
|
7
7
|
import { gridVisibleRowsSelector } from "../pagination/index.js";
|
|
8
8
|
import { gridRowsLookupSelector } from "../rows/index.js";
|
|
9
|
-
const
|
|
9
|
+
const gridIsFocusedCellOutOfContext = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
|
|
10
10
|
if (!focusedCell) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
@@ -19,7 +19,7 @@ const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridR
|
|
|
19
19
|
const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
|
|
20
20
|
return !isInRenderContext;
|
|
21
21
|
});
|
|
22
|
-
export const gridFocusedVirtualCellSelector = createSelectorMemoized(
|
|
22
|
+
export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContext, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
|
|
23
23
|
if (!isFocusedCellOutOfRenderContext) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
@@ -25,7 +25,9 @@ import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
|
|
|
25
25
|
import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
|
|
26
26
|
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
27
27
|
import { minimalContentHeight } from "../rows/gridRowsUtils.js";
|
|
28
|
+
import { EMPTY_PINNED_COLUMN_FIELDS } from "../columns/index.js";
|
|
28
29
|
import { gridFocusedVirtualCellSelector } from "./gridFocusedVirtualCellSelector.js";
|
|
30
|
+
import { roundToDecimalPlaces } from "../../../utils/roundToDecimalPlaces.js";
|
|
29
31
|
import { isJSDOM } from "../../../utils/isJSDOM.js";
|
|
30
32
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
33
|
const MINIMUM_COLUMN_WIDTH = 50;
|
|
@@ -58,17 +60,13 @@ export const useGridVirtualScroller = () => {
|
|
|
58
60
|
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
59
61
|
const outerSize = dimensions.viewportOuterSize;
|
|
60
62
|
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
61
|
-
const pinnedColumnDefinitions =
|
|
62
|
-
const pinnedColumns = listView ?
|
|
63
|
-
left: [],
|
|
64
|
-
right: []
|
|
65
|
-
} : pinnedColumnDefinitions;
|
|
63
|
+
const pinnedColumnDefinitions = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
|
|
64
|
+
const pinnedColumns = listView ? EMPTY_PINNED_COLUMN_FIELDS : pinnedColumnDefinitions;
|
|
66
65
|
const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
|
|
67
66
|
const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
|
|
68
67
|
const isRtl = useRtl();
|
|
69
|
-
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
70
68
|
const selectedRowsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
|
|
71
|
-
const currentPage = useGridVisibleRows(apiRef
|
|
69
|
+
const currentPage = useGridVisibleRows(apiRef);
|
|
72
70
|
const mainRef = apiRef.current.mainElementRef;
|
|
73
71
|
const scrollerRef = apiRef.current.virtualScrollerRef;
|
|
74
72
|
const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
@@ -84,7 +82,10 @@ export const useGridVirtualScroller = () => {
|
|
|
84
82
|
return undefined;
|
|
85
83
|
}
|
|
86
84
|
const initialRect = node.getBoundingClientRect();
|
|
87
|
-
let lastSize =
|
|
85
|
+
let lastSize = {
|
|
86
|
+
width: roundToDecimalPlaces(initialRect.width, 1),
|
|
87
|
+
height: roundToDecimalPlaces(initialRect.height, 1)
|
|
88
|
+
};
|
|
88
89
|
if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
|
|
89
90
|
previousSize.current = lastSize;
|
|
90
91
|
apiRef.current.publishEvent('resize', lastSize);
|
|
@@ -97,7 +98,10 @@ export const useGridVirtualScroller = () => {
|
|
|
97
98
|
if (!entry) {
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
|
-
const newSize =
|
|
101
|
+
const newSize = {
|
|
102
|
+
width: roundToDecimalPlaces(entry.contentRect.width, 1),
|
|
103
|
+
height: roundToDecimalPlaces(entry.contentRect.height, 1)
|
|
104
|
+
};
|
|
101
105
|
if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
@@ -165,9 +169,13 @@ export const useGridVirtualScroller = () => {
|
|
|
165
169
|
if (!scroller) {
|
|
166
170
|
return undefined;
|
|
167
171
|
}
|
|
172
|
+
const maxScrollTop = Math.ceil(dimensions.minimumSize.height - dimensions.viewportOuterSize.height);
|
|
173
|
+
const maxScrollLeft = Math.ceil(dimensions.minimumSize.width - dimensions.viewportInnerSize.width);
|
|
174
|
+
|
|
175
|
+
// Clamp the scroll position to the viewport to avoid re-calculating the render context for scroll bounce
|
|
168
176
|
const newScroll = {
|
|
169
|
-
top: scroller.scrollTop,
|
|
170
|
-
left: scroller.scrollLeft
|
|
177
|
+
top: clamp(scroller.scrollTop, 0, maxScrollTop),
|
|
178
|
+
left: isRtl ? clamp(scroller.scrollLeft, -maxScrollLeft, 0) : clamp(scroller.scrollLeft, 0, maxScrollLeft)
|
|
171
179
|
};
|
|
172
180
|
const dx = newScroll.left - scrollPosition.current.left;
|
|
173
181
|
const dy = newScroll.top - scrollPosition.current.top;
|
|
@@ -220,34 +228,15 @@ export const useGridVirtualScroller = () => {
|
|
|
220
228
|
frozenContext.current = undefined;
|
|
221
229
|
updateRenderContext(nextRenderContext);
|
|
222
230
|
};
|
|
223
|
-
const handleScroll = useEventCallback(
|
|
231
|
+
const handleScroll = useEventCallback(() => {
|
|
224
232
|
if (ignoreNextScrollEvent.current) {
|
|
225
233
|
ignoreNextScrollEvent.current = false;
|
|
226
234
|
return;
|
|
227
235
|
}
|
|
228
|
-
const {
|
|
229
|
-
scrollTop,
|
|
230
|
-
scrollLeft
|
|
231
|
-
} = event.currentTarget;
|
|
232
|
-
|
|
233
|
-
// On iOS and macOS, negative offsets are possible when swiping past the start
|
|
234
|
-
if (scrollTop < 0) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
if (!isRtl) {
|
|
238
|
-
if (scrollLeft < 0) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (isRtl) {
|
|
243
|
-
if (scrollLeft > 0) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
236
|
const nextRenderContext = triggerUpdateRenderContext();
|
|
248
237
|
apiRef.current.publishEvent('scrollPositionChange', {
|
|
249
|
-
top:
|
|
250
|
-
left:
|
|
238
|
+
top: scrollPosition.current.top,
|
|
239
|
+
left: scrollPosition.current.left,
|
|
251
240
|
renderContext: nextRenderContext
|
|
252
241
|
});
|
|
253
242
|
});
|
|
@@ -369,7 +358,6 @@ export const useGridVirtualScroller = () => {
|
|
|
369
358
|
rowId: id,
|
|
370
359
|
index: rowIndex,
|
|
371
360
|
selected: isSelected,
|
|
372
|
-
offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
|
|
373
361
|
offsetLeft: offsetLeft,
|
|
374
362
|
columnsTotalWidth: dimensions.columnsTotalWidth,
|
|
375
363
|
rowHeight: baseRowHeight,
|
|
@@ -527,11 +515,13 @@ export const useGridVirtualScroller = () => {
|
|
|
527
515
|
}),
|
|
528
516
|
getScrollbarVerticalProps: () => ({
|
|
529
517
|
ref: scrollbarVerticalRef,
|
|
530
|
-
role: 'presentation'
|
|
518
|
+
role: 'presentation',
|
|
519
|
+
scrollPosition
|
|
531
520
|
}),
|
|
532
521
|
getScrollbarHorizontalProps: () => ({
|
|
533
522
|
ref: scrollbarHorizontalRef,
|
|
534
|
-
role: 'presentation'
|
|
523
|
+
role: 'presentation',
|
|
524
|
+
scrollPosition
|
|
535
525
|
})
|
|
536
526
|
};
|
|
537
527
|
};
|
|
@@ -573,6 +563,11 @@ function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
|
573
563
|
firstColumnIndex: 0,
|
|
574
564
|
lastColumnIndex: inputs.visibleColumns.length
|
|
575
565
|
};
|
|
566
|
+
if (inputs.listView) {
|
|
567
|
+
return _extends({}, renderContext, {
|
|
568
|
+
lastColumnIndex: 1
|
|
569
|
+
});
|
|
570
|
+
}
|
|
576
571
|
const {
|
|
577
572
|
top,
|
|
578
573
|
left
|
|
@@ -824,13 +819,4 @@ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verti
|
|
|
824
819
|
// eslint unable to figure out enum exhaustiveness
|
|
825
820
|
throw new Error('unreachable');
|
|
826
821
|
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
// Round to avoid issues with subpixel rendering
|
|
830
|
-
// https://github.com/mui/mui-x/issues/15721
|
|
831
|
-
function roundDimensions(dimensions) {
|
|
832
|
-
return {
|
|
833
|
-
width: Math.round(dimensions.width * 10) / 10,
|
|
834
|
-
height: Math.round(dimensions.height * 10) / 10
|
|
835
|
-
};
|
|
836
822
|
}
|
package/modern/index.js
CHANGED
package/modern/utils/utils.js
CHANGED
|
@@ -196,4 +196,9 @@ export function deepClone(obj) {
|
|
|
196
196
|
* of a `eslint-disable-next-line react-hooks/exhaustive-deps` because
|
|
197
197
|
* that hint disables checks on all values instead of just one.
|
|
198
198
|
*/
|
|
199
|
-
export function eslintUseValue(_) {}
|
|
199
|
+
export function eslintUseValue(_) {}
|
|
200
|
+
export const runIf = (condition, fn) => params => {
|
|
201
|
+
if (condition) {
|
|
202
|
+
fn(params);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
@@ -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,
|
|
@@ -14,6 +14,7 @@ var _clsx = _interopRequireDefault(require("clsx"));
|
|
|
14
14
|
var _utils = require("@mui/utils");
|
|
15
15
|
var _fastMemo = require("@mui/x-internals/fastMemo");
|
|
16
16
|
var _forwardRef = require("@mui/x-internals/forwardRef");
|
|
17
|
+
var _isObjectEmpty = require("@mui/x-internals/isObjectEmpty");
|
|
17
18
|
var _gridEditRowModel = require("../models/gridEditRowModel");
|
|
18
19
|
var _gridClasses = require("../constants/gridClasses");
|
|
19
20
|
var _composeGridClasses = require("../utils/composeGridClasses");
|
|
@@ -33,8 +34,16 @@ var _GridScrollbarFillerCell = require("./GridScrollbarFillerCell");
|
|
|
33
34
|
var _getPinnedCellOffset = require("../internals/utils/getPinnedCellOffset");
|
|
34
35
|
var _useGridConfiguration = require("../hooks/utils/useGridConfiguration");
|
|
35
36
|
var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
|
|
37
|
+
var _createSelector = require("../utils/createSelector");
|
|
36
38
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
37
|
-
const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "pinnedColumns", "
|
|
39
|
+
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"];
|
|
40
|
+
const isRowReorderingEnabledSelector = (0, _createSelector.createSelectorV8)(_gridEditingSelectors.gridEditRowsStateSelector, (editRows, rowReordering) => {
|
|
41
|
+
if (!rowReordering) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const isEditingRows = !(0, _isObjectEmpty.isObjectEmpty)(editRows);
|
|
45
|
+
return !isEditingRows;
|
|
46
|
+
});
|
|
38
47
|
const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
39
48
|
const {
|
|
40
49
|
selected,
|
|
@@ -73,10 +82,11 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
73
82
|
const sortModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridSortingSelector.gridSortModelSelector);
|
|
74
83
|
const treeDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowMaximumTreeDepthSelector);
|
|
75
84
|
const columnPositions = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnPositionsSelector);
|
|
76
|
-
const
|
|
85
|
+
const rowReordering = rootProps.rowReordering;
|
|
86
|
+
const isRowReorderingEnabled = (0, _useGridSelector.useGridSelectorV8)(apiRef, isRowReorderingEnabledSelector, rowReordering);
|
|
77
87
|
const handleRef = (0, _utils.unstable_useForkRef)(ref, refProp);
|
|
78
88
|
const rowNode = apiRef.current.getRowNode(rowId);
|
|
79
|
-
const editing = apiRef.
|
|
89
|
+
const editing = (0, _useGridSelector.useGridSelectorV8)(apiRef, _gridEditingSelectors.gridRowIsEditingSelector, rowId);
|
|
80
90
|
const editable = rootProps.editMode === _gridEditRowModel.GridEditModes.Row;
|
|
81
91
|
const hasFocusCell = focusedColumnIndex !== undefined;
|
|
82
92
|
const hasVirtualFocusCellLeft = hasFocusCell && focusedColumnIndex >= pinnedColumns.left.length && focusedColumnIndex < firstColumnIndex;
|
|
@@ -153,7 +163,6 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
153
163
|
slotProps,
|
|
154
164
|
disableColumnReorder
|
|
155
165
|
} = rootProps;
|
|
156
|
-
const rowReordering = rootProps.rowReordering;
|
|
157
166
|
const heightEntry = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _extends2.default)({}, apiRef.current.getRowHeightEntry(rowId)), _useGridSelector.objectShallowCompare);
|
|
158
167
|
const style = React.useMemo(() => {
|
|
159
168
|
if (isNotVisible) {
|
|
@@ -196,6 +205,11 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
196
205
|
});
|
|
197
206
|
rowClassNames.push(rootProps.getRowClassName(rowParams));
|
|
198
207
|
}
|
|
208
|
+
|
|
209
|
+
/* Start of rendering */
|
|
210
|
+
if (!rowNode) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
199
213
|
const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = _constants.PinnedColumnPosition.NONE) => {
|
|
200
214
|
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
|
|
201
215
|
if (cellColSpanInfo?.spannedByColSpan) {
|
|
@@ -213,14 +227,12 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
213
227
|
align: column.align
|
|
214
228
|
}, column.field);
|
|
215
229
|
}
|
|
216
|
-
const editCellState = editRowsState[rowId]?.[column.field] ?? null;
|
|
217
230
|
|
|
218
231
|
// when the cell is a reorder cell we are not allowing to reorder the col
|
|
219
232
|
// fixes https://github.com/mui/mui-x/issues/11126
|
|
220
233
|
const isReorderCell = column.field === '__reorder__';
|
|
221
|
-
const isEditingRows = Object.keys(editRowsState).length > 0;
|
|
222
234
|
const canReorderColumn = !(disableColumnReorder || column.disableReorder);
|
|
223
|
-
const canReorderRow =
|
|
235
|
+
const canReorderRow = isRowReorderingEnabled && !sortModel.length && treeDepth <= 1;
|
|
224
236
|
const disableDragEvents = !(canReorderColumn || isReorderCell && canReorderRow);
|
|
225
237
|
const cellIsNotVisible = pinnedPosition === _constants.PinnedColumnPosition.VIRTUAL;
|
|
226
238
|
const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection);
|
|
@@ -233,20 +245,15 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
|
|
|
233
245
|
colIndex: indexRelativeToAllColumns,
|
|
234
246
|
colSpan: colSpan,
|
|
235
247
|
disableDragEvents: disableDragEvents,
|
|
236
|
-
editCellState: editCellState,
|
|
237
248
|
isNotVisible: cellIsNotVisible,
|
|
238
249
|
pinnedOffset: pinnedOffset,
|
|
239
250
|
pinnedPosition: pinnedPosition,
|
|
240
251
|
showLeftBorder: showLeftBorder,
|
|
241
|
-
showRightBorder: showRightBorder
|
|
252
|
+
showRightBorder: showRightBorder,
|
|
253
|
+
row: row,
|
|
254
|
+
rowNode: rowNode
|
|
242
255
|
}, slotProps?.cell), column.field);
|
|
243
256
|
};
|
|
244
|
-
|
|
245
|
-
/* Start of rendering */
|
|
246
|
-
|
|
247
|
-
if (!rowNode) {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
257
|
const leftCells = pinnedColumns.left.map((column, i) => {
|
|
251
258
|
const indexRelativeToAllColumns = i;
|
|
252
259
|
return getCell(column, i, indexRelativeToAllColumns, pinnedColumns.left.length, _constants.PinnedColumnPosition.LEFT);
|
|
@@ -324,7 +331,6 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
|
|
|
324
331
|
isNotVisible: _propTypes.default.bool.isRequired,
|
|
325
332
|
lastColumnIndex: _propTypes.default.number.isRequired,
|
|
326
333
|
offsetLeft: _propTypes.default.number.isRequired,
|
|
327
|
-
offsetTop: _propTypes.default.number,
|
|
328
334
|
onClick: _propTypes.default.func,
|
|
329
335
|
onDoubleClick: _propTypes.default.func,
|
|
330
336
|
onMouseEnter: _propTypes.default.func,
|
|
@@ -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
|