@mui/x-data-grid 7.24.0 → 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 +148 -0
- package/DataGrid/DataGrid.js +1 -7
- package/DataGrid/useDataGridComponent.d.ts +2 -1
- 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/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/components/containers/GridRootStyles.js +135 -37
- package/components/panel/GridPanel.js +2 -1
- package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
- package/components/toolbar/GridToolbarColumnsButton.js +8 -2
- package/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/components/toolbar/GridToolbarFilterButton.js +8 -2
- 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/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/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 +2 -1
- 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/columns/useGridColumns.js +7 -3
- package/hooks/features/density/useGridDensity.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.js +7 -11
- 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.d.ts +2 -2
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridEditing.d.ts +2 -2
- package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
- package/hooks/features/editing/useGridRowEditing.js +5 -6
- 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/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/focus/useGridFocus.js +3 -2
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -4
- package/hooks/features/keyboardNavigation/utils.js +0 -5
- package/hooks/features/listView/useGridListView.d.ts +2 -2
- package/hooks/features/listView/useGridListView.js +2 -1
- package/hooks/features/pagination/useGridPagination.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
- 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/useGridRowSelection.js +3 -3
- 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/gridRowsUtils.d.ts +4 -4
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
- package/hooks/features/rows/useGridParamsApi.js +33 -14
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
- package/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +7 -8
- package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
- package/hooks/features/rows/useGridRowsMeta.js +3 -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.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +9 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +32 -53
- 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 +3 -3
- package/index.js +1 -1
- package/locales/faIR.js +5 -6
- 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/models/colDef/gridColDef.d.ts +9 -8
- package/models/gridExport.d.ts +2 -2
- package/models/gridFilterOperator.d.ts +2 -1
- package/models/props/DataGridProps.d.ts +2 -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/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/modern/components/containers/GridRootStyles.js +135 -37
- package/modern/components/panel/GridPanel.js +2 -1
- package/modern/components/toolbar/GridToolbarColumnsButton.js +8 -2
- package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/modern/components/toolbar/GridToolbarFilterButton.js +8 -2
- 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/columnMenu/useGridColumnMenu.js +0 -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 +7 -11
- 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/filter/gridFilterUtils.js +3 -3
- 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/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/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/sorting/gridSortingUtils.js +2 -2
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +32 -53
- package/modern/hooks/utils/useGridApiRef.js +3 -1
- package/modern/index.js +1 -1
- package/modern/locales/faIR.js +5 -6
- package/modern/models/api/index.js +0 -1
- package/modern/utils/isJSDOM.js +1 -0
- 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/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
- package/node/components/containers/GridRootStyles.js +135 -37
- package/node/components/panel/GridPanel.js +2 -1
- package/node/components/toolbar/GridToolbarColumnsButton.js +8 -2
- package/node/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/node/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/node/components/toolbar/GridToolbarFilterButton.js +8 -2
- 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/columnMenu/useGridColumnMenu.js +0 -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 +9 -13
- 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/filter/gridFilterUtils.js +3 -3
- 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/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/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/sorting/gridSortingUtils.js +2 -2
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +34 -55
- package/node/hooks/utils/useGridApiRef.js +3 -1
- package/node/index.js +1 -1
- package/node/locales/faIR.js +5 -6
- package/node/models/api/index.js +0 -11
- package/node/utils/isJSDOM.js +7 -0
- package/node/utils/roundToDecimalPlaces.js +9 -0
- package/node/utils/utils.js +8 -1
- package/package.json +2 -2
- package/utils/createSelector.d.ts +3 -3
- package/utils/getPublicApiRef.d.ts +2 -1
- package/utils/isJSDOM.d.ts +1 -0
- package/utils/isJSDOM.js +1 -0
- 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
|
@@ -53,9 +53,15 @@ const GridToolbarColumnsButton = exports.GridToolbarColumnsButton = (0, _forward
|
|
|
53
53
|
"aria-haspopup": "menu",
|
|
54
54
|
"aria-expanded": isOpen,
|
|
55
55
|
"aria-controls": isOpen ? columnPanelId : undefined,
|
|
56
|
-
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnSelectorIcon, {})
|
|
57
|
-
onClick: showColumns
|
|
56
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnSelectorIcon, {})
|
|
58
57
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
58
|
+
onPointerUp: event => {
|
|
59
|
+
if (preferencePanel.open) {
|
|
60
|
+
event.stopPropagation();
|
|
61
|
+
}
|
|
62
|
+
buttonProps.onPointerUp?.(event);
|
|
63
|
+
},
|
|
64
|
+
onClick: showColumns,
|
|
59
65
|
ref: ref,
|
|
60
66
|
children: apiRef.current.getLocaleText('toolbarColumns')
|
|
61
67
|
}))
|
|
@@ -102,9 +102,9 @@ const GridToolbarDensitySelector = exports.GridToolbarDensitySelector = (0, _for
|
|
|
102
102
|
"aria-haspopup": "menu",
|
|
103
103
|
"aria-expanded": open,
|
|
104
104
|
"aria-controls": open ? densityMenuId : undefined,
|
|
105
|
-
id: densityButtonId
|
|
106
|
-
onClick: handleDensitySelectorOpen
|
|
105
|
+
id: densityButtonId
|
|
107
106
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
107
|
+
onClick: handleDensitySelectorOpen,
|
|
108
108
|
ref: handleRef,
|
|
109
109
|
children: apiRef.current.getLocaleText('toolbarDensity')
|
|
110
110
|
}))
|
|
@@ -60,9 +60,9 @@ const GridToolbarExportContainer = exports.GridToolbarExportContainer = (0, _for
|
|
|
60
60
|
"aria-label": apiRef.current.getLocaleText('toolbarExportLabel'),
|
|
61
61
|
"aria-haspopup": "menu",
|
|
62
62
|
"aria-controls": open ? exportMenuId : undefined,
|
|
63
|
-
id: exportButtonId
|
|
64
|
-
onClick: handleMenuOpen
|
|
63
|
+
id: exportButtonId
|
|
65
64
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
65
|
+
onClick: handleMenuOpen,
|
|
66
66
|
ref: handleRef,
|
|
67
67
|
children: apiRef.current.getLocaleText('toolbarExport')
|
|
68
68
|
}))
|
|
@@ -117,9 +117,15 @@ const GridToolbarFilterButton = exports.GridToolbarFilterButton = (0, _forwardRe
|
|
|
117
117
|
color: "primary"
|
|
118
118
|
}, rootProps.slotProps?.baseBadge, badgeProps, {
|
|
119
119
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.openFilterButtonIcon, {})
|
|
120
|
-
}))
|
|
121
|
-
onClick: toggleFilter
|
|
120
|
+
}))
|
|
122
121
|
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
122
|
+
onClick: toggleFilter,
|
|
123
|
+
onPointerUp: event => {
|
|
124
|
+
if (preferencePanel.open) {
|
|
125
|
+
event.stopPropagation();
|
|
126
|
+
}
|
|
127
|
+
buttonProps.onPointerUp?.(event);
|
|
128
|
+
},
|
|
123
129
|
ref: ref,
|
|
124
130
|
children: apiRef.current.getLocaleText('toolbarFilters')
|
|
125
131
|
}))
|
|
@@ -22,7 +22,12 @@ const GridPanelAnchor = (0, _system.styled)('div')({
|
|
|
22
22
|
const Element = (0, _system.styled)('div', {
|
|
23
23
|
name: 'MuiDataGrid',
|
|
24
24
|
slot: 'Main',
|
|
25
|
-
overridesResolver: (props, styles) =>
|
|
25
|
+
overridesResolver: (props, styles) => {
|
|
26
|
+
const {
|
|
27
|
+
ownerState
|
|
28
|
+
} = props;
|
|
29
|
+
return [styles.main, ownerState.dimensions.rightPinnedWidth > 0 && styles['main--hasPinnedRight'], ownerState.loadingOverlayVariant === 'skeleton' && styles['main--hasSkeletonLoadingOverlay']];
|
|
30
|
+
}
|
|
26
31
|
})({
|
|
27
32
|
flexGrow: 1,
|
|
28
33
|
position: 'relative',
|
|
@@ -31,11 +36,14 @@ const Element = (0, _system.styled)('div', {
|
|
|
31
36
|
flexDirection: 'column'
|
|
32
37
|
});
|
|
33
38
|
const GridMainContainer = exports.GridMainContainer = (0, _forwardRef.forwardRef)((props, ref) => {
|
|
39
|
+
const {
|
|
40
|
+
ownerState
|
|
41
|
+
} = props;
|
|
34
42
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
35
43
|
const configuration = (0, _useGridConfiguration.useGridConfiguration)();
|
|
36
44
|
const ariaAttributes = configuration.hooks.useGridAriaAttributes();
|
|
37
45
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Element, (0, _extends2.default)({
|
|
38
|
-
ownerState:
|
|
46
|
+
ownerState: ownerState,
|
|
39
47
|
className: props.className,
|
|
40
48
|
tabIndex: -1
|
|
41
49
|
}, ariaAttributes, rootProps.slotProps?.main, {
|
|
@@ -74,26 +74,27 @@ const GridVirtualScrollbar = exports.GridVirtualScrollbar = (0, _forwardRef.forw
|
|
|
74
74
|
const dimensions = (0, _hooks.useGridSelector)(apiRef, _hooks.gridDimensionsSelector);
|
|
75
75
|
const propertyDimension = props.position === 'vertical' ? 'height' : 'width';
|
|
76
76
|
const propertyScroll = props.position === 'vertical' ? 'scrollTop' : 'scrollLeft';
|
|
77
|
+
const propertyScrollPosition = props.position === 'vertical' ? 'top' : 'left';
|
|
77
78
|
const hasScroll = props.position === 'vertical' ? dimensions.hasScrollX : dimensions.hasScrollY;
|
|
78
79
|
const contentSize = dimensions.minimumSize[propertyDimension] + (hasScroll ? dimensions.scrollbarSize : 0);
|
|
79
80
|
const scrollbarSize = props.position === 'vertical' ? dimensions.viewportInnerSize.height : dimensions.viewportOuterSize.width;
|
|
80
81
|
const scrollbarInnerSize = scrollbarSize * (contentSize / dimensions.viewportOuterSize[propertyDimension]);
|
|
81
82
|
const onScrollerScroll = (0, _utils.unstable_useEventCallback)(() => {
|
|
82
|
-
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
83
83
|
const scrollbar = scrollbarRef.current;
|
|
84
|
+
const scrollPosition = props.scrollPosition.current;
|
|
84
85
|
if (!scrollbar) {
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
if (
|
|
88
|
+
if (scrollPosition[propertyScrollPosition] === lastPosition.current) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
|
-
lastPosition.current =
|
|
91
|
+
lastPosition.current = scrollPosition[propertyScrollPosition];
|
|
91
92
|
if (isLocked.current) {
|
|
92
93
|
isLocked.current = false;
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
isLocked.current = true;
|
|
96
|
-
const value =
|
|
97
|
+
const value = scrollPosition[propertyScrollPosition] / contentSize;
|
|
97
98
|
scrollbar[propertyScroll] = value * scrollbarInnerSize;
|
|
98
99
|
});
|
|
99
100
|
const onScrollbarScroll = (0, _utils.unstable_useEventCallback)(() => {
|
|
@@ -114,7 +115,6 @@ const GridVirtualScrollbar = exports.GridVirtualScrollbar = (0, _forwardRef.forw
|
|
|
114
115
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
115
116
|
const scrollbar = scrollbarRef.current;
|
|
116
117
|
const options = {
|
|
117
|
-
capture: true,
|
|
118
118
|
passive: true
|
|
119
119
|
};
|
|
120
120
|
scroller.addEventListener('scroll', onScrollerScroll, options);
|
|
@@ -28,9 +28,11 @@ var _GridVirtualScrollerFiller = require("./GridVirtualScrollerFiller");
|
|
|
28
28
|
var _GridVirtualScrollerRenderZone = require("./GridVirtualScrollerRenderZone");
|
|
29
29
|
var _GridVirtualScrollbar = require("./GridVirtualScrollbar");
|
|
30
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
-
const useUtilityClasses =
|
|
31
|
+
const useUtilityClasses = ownerState => {
|
|
32
32
|
const {
|
|
33
|
-
classes
|
|
33
|
+
classes,
|
|
34
|
+
dimensions,
|
|
35
|
+
loadingOverlayVariant
|
|
34
36
|
} = ownerState;
|
|
35
37
|
const slots = {
|
|
36
38
|
root: ['main', dimensions.rightPinnedWidth > 0 && 'main--hasPinnedRight', loadingOverlayVariant === 'skeleton' && 'main--hasSkeletonLoadingOverlay'],
|
|
@@ -41,7 +43,12 @@ const useUtilityClasses = (ownerState, dimensions, loadingOverlayVariant) => {
|
|
|
41
43
|
const Scroller = (0, _system.styled)('div', {
|
|
42
44
|
name: 'MuiDataGrid',
|
|
43
45
|
slot: 'VirtualScroller',
|
|
44
|
-
overridesResolver: (props, styles) =>
|
|
46
|
+
overridesResolver: (props, styles) => {
|
|
47
|
+
const {
|
|
48
|
+
ownerState
|
|
49
|
+
} = props;
|
|
50
|
+
return [styles.virtualScroller, ownerState.dimensions.hasScrollX && styles['virtualScroller--hasScrollX']];
|
|
51
|
+
}
|
|
45
52
|
})({
|
|
46
53
|
position: 'relative',
|
|
47
54
|
height: '100%',
|
|
@@ -64,7 +71,12 @@ function GridVirtualScroller(props) {
|
|
|
64
71
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
65
72
|
const dimensions = (0, _useGridSelector.useGridSelector)(apiRef, _dimensions.gridDimensionsSelector);
|
|
66
73
|
const overlaysProps = (0, _useGridOverlays.useGridOverlays)();
|
|
67
|
-
const
|
|
74
|
+
const ownerState = {
|
|
75
|
+
classes: rootProps.classes,
|
|
76
|
+
dimensions,
|
|
77
|
+
loadingOverlayVariant: overlaysProps.loadingOverlayVariant
|
|
78
|
+
};
|
|
79
|
+
const classes = useUtilityClasses(ownerState);
|
|
68
80
|
const virtualScroller = (0, _useGridVirtualScroller.useGridVirtualScroller)();
|
|
69
81
|
const {
|
|
70
82
|
getContainerProps,
|
|
@@ -79,6 +91,7 @@ function GridVirtualScroller(props) {
|
|
|
79
91
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridMainContainer.GridMainContainer, (0, _extends2.default)({
|
|
80
92
|
className: classes.root
|
|
81
93
|
}, getContainerProps(), {
|
|
94
|
+
ownerState: ownerState,
|
|
82
95
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridScrollArea.GridScrollArea, {
|
|
83
96
|
scrollDirection: "left"
|
|
84
97
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridScrollArea.GridScrollArea, {
|
|
@@ -86,7 +99,7 @@ function GridVirtualScroller(props) {
|
|
|
86
99
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Scroller, (0, _extends2.default)({
|
|
87
100
|
className: classes.scroller
|
|
88
101
|
}, getScrollerProps(), {
|
|
89
|
-
ownerState:
|
|
102
|
+
ownerState: ownerState,
|
|
90
103
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridTopContainer.GridTopContainer, {
|
|
91
104
|
children: [!rootProps.unstable_listView && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridHeaders.GridHeaders, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.pinnedRows, {
|
|
92
105
|
position: "top",
|
|
@@ -27,14 +27,23 @@ const useUtilityClasses = (props, overflowedContent) => {
|
|
|
27
27
|
const VirtualScrollerContentRoot = (0, _system.styled)('div', {
|
|
28
28
|
name: 'MuiDataGrid',
|
|
29
29
|
slot: 'VirtualScrollerContent',
|
|
30
|
-
overridesResolver: (props, styles) =>
|
|
30
|
+
overridesResolver: (props, styles) => {
|
|
31
|
+
const {
|
|
32
|
+
ownerState
|
|
33
|
+
} = props;
|
|
34
|
+
return [styles.virtualScrollerContent, ownerState.overflowedContent && styles['virtualScrollerContent--overflowed']];
|
|
35
|
+
}
|
|
31
36
|
})({});
|
|
32
37
|
const GridVirtualScrollerContent = exports.GridVirtualScrollerContent = (0, _forwardRef.forwardRef)(function GridVirtualScrollerContent(props, ref) {
|
|
33
38
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
34
39
|
const overflowedContent = !rootProps.autoHeight && props.style?.minHeight === 'auto';
|
|
35
40
|
const classes = useUtilityClasses(rootProps, overflowedContent);
|
|
41
|
+
const ownerState = {
|
|
42
|
+
classes: rootProps.classes,
|
|
43
|
+
overflowedContent
|
|
44
|
+
};
|
|
36
45
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerContentRoot, (0, _extends2.default)({}, props, {
|
|
37
|
-
ownerState:
|
|
46
|
+
ownerState: ownerState,
|
|
38
47
|
className: (0, _clsx.default)(classes.root, props.className),
|
|
39
48
|
ref: ref
|
|
40
49
|
}));
|
|
@@ -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 => {
|
|
@@ -509,7 +509,8 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
509
509
|
if (options.expand) {
|
|
510
510
|
const visibleColumns = state.orderedFields.map(field => state.lookup[field]).filter(c => state.columnVisibilityModel[c.field] !== false);
|
|
511
511
|
const totalWidth = visibleColumns.reduce((total, column) => total + (widthByField[column.field] ?? column.computedWidth ?? column.width), 0);
|
|
512
|
-
const
|
|
512
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
513
|
+
const availableWidth = dimensions.viewportInnerSize.width;
|
|
513
514
|
const remainingWidth = availableWidth - totalWidth;
|
|
514
515
|
if (remainingWidth > 0) {
|
|
515
516
|
const widthPerColumn = remainingWidth / (newColumns.length || 1);
|
|
@@ -252,9 +252,13 @@ function useGridColumns(apiRef, props) {
|
|
|
252
252
|
*/
|
|
253
253
|
|
|
254
254
|
const prevInnerWidth = React.useRef(null);
|
|
255
|
-
const handleGridSizeChange =
|
|
256
|
-
if (prevInnerWidth.current !==
|
|
257
|
-
prevInnerWidth.current =
|
|
255
|
+
const handleGridSizeChange = size => {
|
|
256
|
+
if (prevInnerWidth.current !== size.width) {
|
|
257
|
+
prevInnerWidth.current = size.width;
|
|
258
|
+
const hasFlexColumns = (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef).some(col => col.flex && col.flex > 0);
|
|
259
|
+
if (!hasFlexColumns) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
258
262
|
setGridColumnsState((0, _gridColumnsUtils.hydrateColumnsWidth)((0, _gridColumnsSelector.gridColumnsStateSelector)(apiRef.current.state), apiRef.current.getRootDimensions()));
|
|
259
263
|
}
|
|
260
264
|
};
|
|
@@ -24,6 +24,8 @@ 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 _roundToDecimalPlaces = require("../../../utils/roundToDecimalPlaces");
|
|
28
|
+
var _isJSDOM = require("../../../utils/isJSDOM");
|
|
27
29
|
const EMPTY_SIZE = {
|
|
28
30
|
width: 0,
|
|
29
31
|
height: 0
|
|
@@ -70,7 +72,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
70
72
|
const headerHeight = Math.floor(props.columnHeaderHeight * densityFactor);
|
|
71
73
|
const groupHeaderHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
72
74
|
const headerFilterHeight = Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
73
|
-
const columnsTotalWidth = roundToDecimalPlaces((0, _columns.gridColumnsTotalWidthSelector)(apiRef),
|
|
75
|
+
const columnsTotalWidth = (0, _roundToDecimalPlaces.roundToDecimalPlaces)((0, _columns.gridColumnsTotalWidthSelector)(apiRef), 1);
|
|
74
76
|
const headersTotalHeight = (0, _gridColumnsUtils.getTotalHeaderHeight)(apiRef, props);
|
|
75
77
|
const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
|
|
76
78
|
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
@@ -120,6 +122,9 @@ function useGridDimensions(apiRef, props) {
|
|
|
120
122
|
return Math.min(maximumPageSizeWithoutScrollBar, currentPage.rows.length);
|
|
121
123
|
}, [apiRef, props.pagination, props.paginationMode, props.getRowHeight, rowHeight]);
|
|
122
124
|
const updateDimensions = React.useCallback(() => {
|
|
125
|
+
// All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
|
|
126
|
+
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
127
|
+
// https://github.com/mui/mui-x/issues/15721
|
|
123
128
|
const rootElement = apiRef.current.rootElementRef.current;
|
|
124
129
|
const pinnedRowsHeight = (0, _gridRowsUtils.calculatePinnedRowsHeight)(apiRef);
|
|
125
130
|
const scrollbarSize = measureScrollbarSize(rootElement, columnsTotalWidth, props.scrollbarSize);
|
|
@@ -128,7 +133,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
128
133
|
const nonPinnedColumnsTotalWidth = columnsTotalWidth - leftPinnedWidth - rightPinnedWidth;
|
|
129
134
|
const contentSize = {
|
|
130
135
|
width: nonPinnedColumnsTotalWidth,
|
|
131
|
-
height: rowsMeta.currentPageTotalHeight
|
|
136
|
+
height: (0, _roundToDecimalPlaces.roundToDecimalPlaces)(rowsMeta.currentPageTotalHeight, 1)
|
|
132
137
|
};
|
|
133
138
|
let viewportOuterSize;
|
|
134
139
|
let viewportInnerSize;
|
|
@@ -247,14 +252,11 @@ function useGridDimensions(apiRef, props) {
|
|
|
247
252
|
const isFirstSizing = React.useRef(true);
|
|
248
253
|
const handleResize = React.useCallback(size => {
|
|
249
254
|
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) {
|
|
255
|
+
if (size.height === 0 && !errorShown.current && !props.autoHeight && !_isJSDOM.isJSDOM) {
|
|
254
256
|
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
257
|
errorShown.current = true;
|
|
256
258
|
}
|
|
257
|
-
if (size.width === 0 && !errorShown.current && !isJSDOM) {
|
|
259
|
+
if (size.width === 0 && !errorShown.current && !_isJSDOM.isJSDOM) {
|
|
258
260
|
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
261
|
errorShown.current = true;
|
|
260
262
|
}
|
|
@@ -292,12 +294,6 @@ function measureScrollbarSize(rootElement, columnsTotalWidth, scrollbarSize) {
|
|
|
292
294
|
rootElement.removeChild(scrollDiv);
|
|
293
295
|
return size;
|
|
294
296
|
}
|
|
295
|
-
|
|
296
|
-
// Get rid of floating point imprecision errors
|
|
297
|
-
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
298
|
-
function roundToDecimalPlaces(value, decimals) {
|
|
299
|
-
return Math.round(value * 10 ** decimals) / 10 ** decimals;
|
|
300
|
-
}
|
|
301
297
|
function areElementSizesEqual(a, b) {
|
|
302
298
|
return a.width === b.width && a.height === b.height;
|
|
303
299
|
}
|
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.gridEditRowsStateSelector = void 0;
|
|
6
|
+
exports.gridRowIsEditingSelector = exports.gridEditRowsStateSelector = exports.gridEditCellStateSelector = void 0;
|
|
7
|
+
var _createSelector = require("../../../utils/createSelector");
|
|
7
8
|
/**
|
|
8
9
|
* Select the row editing state.
|
|
9
10
|
*/
|
|
10
11
|
const gridEditRowsStateSelector = state => state.editRows;
|
|
11
|
-
exports.gridEditRowsStateSelector = gridEditRowsStateSelector;
|
|
12
|
+
exports.gridEditRowsStateSelector = gridEditRowsStateSelector;
|
|
13
|
+
const gridRowIsEditingSelector = exports.gridRowIsEditingSelector = (0, _createSelector.createSelectorV8)(gridEditRowsStateSelector, (editRows, rowId) => Boolean(editRows[rowId]));
|
|
14
|
+
const gridEditCellStateSelector = exports.gridEditCellStateSelector = (0, _createSelector.createSelectorV8)(gridEditRowsStateSelector, (editRows, {
|
|
15
|
+
rowId,
|
|
16
|
+
field
|
|
17
|
+
}) => editRows[rowId]?.[field] ?? null);
|
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return _gridEditingSelectors[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
6
|
+
Object.defineProperty(exports, "gridEditRowsStateSelector", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _gridEditingSelectors.gridEditRowsStateSelector;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _gridEditingSelectors = require("./gridEditingSelectors");
|
|
@@ -450,7 +450,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
450
450
|
|
|
451
451
|
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
452
452
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
453
|
-
const
|
|
453
|
+
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
454
454
|
|
|
455
455
|
// Update the ref here because updateStateToStopCellEditMode may change it later
|
|
456
456
|
const copyOfPrevCellModes = prevCellModesModel.current;
|
|
@@ -459,7 +459,7 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
459
459
|
Object.entries(cellModesModel).forEach(([id, fields]) => {
|
|
460
460
|
Object.entries(fields).forEach(([field, params]) => {
|
|
461
461
|
const prevMode = copyOfPrevCellModes[id]?.[field]?.mode || _gridEditRowModel.GridCellModes.View;
|
|
462
|
-
const originalId =
|
|
462
|
+
const originalId = rowsLookup[id] ? apiRef.current.getRowId(rowsLookup[id]) : id;
|
|
463
463
|
if (params.mode === _gridEditRowModel.GridCellModes.Edit && prevMode === _gridEditRowModel.GridCellModes.View) {
|
|
464
464
|
updateStateToStartCellEditMode((0, _extends2.default)({
|
|
465
465
|
id: originalId,
|
|
@@ -243,8 +243,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
243
243
|
if (props.editMode === _gridEditRowModel.GridEditModes.Cell) {
|
|
244
244
|
return _gridEditRowModel.GridRowModes.View;
|
|
245
245
|
}
|
|
246
|
-
const
|
|
247
|
-
const isEditing = editingState[id] && Object.keys(editingState[id]).length > 0;
|
|
246
|
+
const isEditing = (0, _gridEditingSelectors.gridRowIsEditingSelector)(apiRef, id);
|
|
248
247
|
return isEditing ? _gridEditRowModel.GridRowModes.Edit : _gridEditRowModel.GridRowModes.View;
|
|
249
248
|
}, [apiRef, props.editMode]);
|
|
250
249
|
const updateRowModesModel = (0, _utils.unstable_useEventCallback)(newModel => {
|
|
@@ -579,7 +578,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
579
578
|
|
|
580
579
|
// Run this effect synchronously so that the keyboard event can impact the yet-to-be-rendered input.
|
|
581
580
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
582
|
-
const
|
|
581
|
+
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
583
582
|
|
|
584
583
|
// Update the ref here because updateStateToStopRowEditMode may change it later
|
|
585
584
|
const copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
@@ -591,7 +590,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
591
590
|
mode: _gridEditRowModel.GridRowModes.View
|
|
592
591
|
};
|
|
593
592
|
const prevMode = copyOfPrevRowModesModel[id]?.mode || _gridEditRowModel.GridRowModes.View;
|
|
594
|
-
const originalId =
|
|
593
|
+
const originalId = rowsLookup[id] ? apiRef.current.getRowId(rowsLookup[id]) : id;
|
|
595
594
|
if (params.mode === _gridEditRowModel.GridRowModes.Edit && prevMode === _gridEditRowModel.GridRowModes.View) {
|
|
596
595
|
updateStateToStartRowEditMode((0, _extends2.default)({
|
|
597
596
|
id: originalId
|
|
@@ -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;
|
|
@@ -335,10 +335,11 @@ const useGridFocus = (apiRef, props) => {
|
|
|
335
335
|
// If the focused cell is in a row which does not exist anymore,
|
|
336
336
|
// focus previous row or remove the focus
|
|
337
337
|
if (cell && !apiRef.current.getRow(cell.id)) {
|
|
338
|
-
const lastFocusedRowId =
|
|
338
|
+
const lastFocusedRowId = cell.id;
|
|
339
339
|
let nextRowId = null;
|
|
340
340
|
if (typeof lastFocusedRowId !== 'undefined') {
|
|
341
|
-
const
|
|
341
|
+
const rowEl = apiRef.current.getRowElement(lastFocusedRowId);
|
|
342
|
+
const lastFocusedRowIndex = rowEl?.dataset.rowindex ? Number(rowEl?.dataset.rowindex) : 0;
|
|
342
343
|
const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef, {
|
|
343
344
|
pagination: props.pagination,
|
|
344
345
|
paginationMode: props.paginationMode
|
|
@@ -13,7 +13,6 @@ var _gridColumnsSelector = require("../columns/gridColumnsSelector");
|
|
|
13
13
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
14
14
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
15
15
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
16
|
-
var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
17
16
|
var _gridCheckboxSelectionColDef = require("../../../colDef/gridCheckboxSelectionColDef");
|
|
18
17
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
19
18
|
var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
@@ -25,6 +24,13 @@ var _pipeProcessing = require("../../core/pipeProcessing");
|
|
|
25
24
|
var _domUtils = require("../../../utils/domUtils");
|
|
26
25
|
var _utils = require("./utils");
|
|
27
26
|
var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
27
|
+
var _createSelector = require("../../../utils/createSelector");
|
|
28
|
+
var _pagination = require("../pagination");
|
|
29
|
+
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
30
|
+
const gridVisibleRowsWithPinnedRowsSelector = (0, _createSelector.createSelectorMemoized)(_pagination.gridVisibleRowsSelector, _gridRowsSelector.gridPinnedRowsSelector, (visibleRows, pinnedRows) => {
|
|
31
|
+
return (pinnedRows.top || []).concat(visibleRows.rows, pinnedRows.bottom || []);
|
|
32
|
+
});
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* @requires useGridSorting (method) - can be after
|
|
30
36
|
* @requires useGridFilter (state) - can be after
|
|
@@ -36,10 +42,11 @@ var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
|
36
42
|
*/
|
|
37
43
|
const useGridKeyboardNavigation = (apiRef, props) => {
|
|
38
44
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridKeyboardNavigation');
|
|
39
|
-
const initialCurrentPageRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props).rows;
|
|
40
45
|
const isRtl = (0, _RtlProvider.useRtl)();
|
|
41
46
|
const listView = props.unstable_listView;
|
|
42
|
-
const
|
|
47
|
+
const getCurrentPageRows = React.useCallback(() => {
|
|
48
|
+
return gridVisibleRowsWithPinnedRowsSelector(apiRef);
|
|
49
|
+
}, [apiRef]);
|
|
43
50
|
const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
|
|
44
51
|
|
|
45
52
|
/**
|
|
@@ -98,8 +105,8 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
98
105
|
apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
|
|
99
106
|
}, [apiRef, logger]);
|
|
100
107
|
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
101
|
-
return
|
|
102
|
-
}, [
|
|
108
|
+
return getCurrentPageRows()[rowIndex]?.id;
|
|
109
|
+
}, [getCurrentPageRows]);
|
|
103
110
|
const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
|
|
104
111
|
const headerTitleNode = event.currentTarget.querySelector(`.${_gridClasses.gridClasses.columnHeaderTitleContainerContent}`);
|
|
105
112
|
const isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
|
|
@@ -108,6 +115,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
108
115
|
// There is one exception for the checkBoxHeader
|
|
109
116
|
return;
|
|
110
117
|
}
|
|
118
|
+
const currentPageRows = getCurrentPageRows();
|
|
111
119
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
112
120
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
113
121
|
const firstRowIndexInPage = currentPageRows.length > 0 ? 0 : null;
|
|
@@ -119,12 +127,10 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
119
127
|
switch (event.key) {
|
|
120
128
|
case 'ArrowDown':
|
|
121
129
|
{
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
127
|
-
}
|
|
130
|
+
if (headerFilteringEnabled) {
|
|
131
|
+
goToHeaderFilter(colIndexBefore, event);
|
|
132
|
+
} else if (firstRowIndexInPage !== null) {
|
|
133
|
+
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
128
134
|
}
|
|
129
135
|
break;
|
|
130
136
|
}
|
|
@@ -198,13 +204,14 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
198
204
|
if (shouldPreventDefault) {
|
|
199
205
|
event.preventDefault();
|
|
200
206
|
}
|
|
201
|
-
}, [apiRef,
|
|
207
|
+
}, [apiRef, getCurrentPageRows, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, isRtl, goToHeader, goToGroupHeader]);
|
|
202
208
|
const handleHeaderFilterKeyDown = React.useCallback((params, event) => {
|
|
203
209
|
const isEditing = (0, _gridHeaderFilteringSelectors.gridHeaderFilteringEditFieldSelector)(apiRef) === params.field;
|
|
204
210
|
const isHeaderMenuOpen = (0, _gridHeaderFilteringSelectors.gridHeaderFilteringMenuSelector)(apiRef) === params.field;
|
|
205
211
|
if (isEditing || isHeaderMenuOpen || !(0, _keyboardUtils.isNavigationKey)(event.key)) {
|
|
206
212
|
return;
|
|
207
213
|
}
|
|
214
|
+
const currentPageRows = getCurrentPageRows();
|
|
208
215
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
209
216
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
210
217
|
const firstRowIndexInPage = 0;
|
|
@@ -284,7 +291,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
284
291
|
if (shouldPreventDefault) {
|
|
285
292
|
event.preventDefault();
|
|
286
293
|
}
|
|
287
|
-
}, [apiRef,
|
|
294
|
+
}, [apiRef, getCurrentPageRows, goToHeaderFilter, isRtl, goToHeader, goToCell, getRowIdFromIndex]);
|
|
288
295
|
const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
|
|
289
296
|
const focusedColumnGroup = (0, _focus.gridFocusColumnGroupHeaderSelector)(apiRef);
|
|
290
297
|
if (focusedColumnGroup === null) {
|
|
@@ -299,6 +306,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
299
306
|
depth,
|
|
300
307
|
maxDepth
|
|
301
308
|
} = params;
|
|
309
|
+
const currentPageRows = getCurrentPageRows();
|
|
302
310
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
303
311
|
const currentColIndex = apiRef.current.getColumnIndex(currentField);
|
|
304
312
|
const colIndexBefore = currentField ? apiRef.current.getColumnIndex(currentField) : 0;
|
|
@@ -370,7 +378,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
370
378
|
if (shouldPreventDefault) {
|
|
371
379
|
event.preventDefault();
|
|
372
380
|
}
|
|
373
|
-
}, [apiRef,
|
|
381
|
+
}, [apiRef, getCurrentPageRows, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
374
382
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
375
383
|
// Ignore portal
|
|
376
384
|
if ((0, _domUtils.isEventTargetInPortal)(event)) {
|
|
@@ -389,6 +397,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
389
397
|
if (!canUpdateFocus) {
|
|
390
398
|
return;
|
|
391
399
|
}
|
|
400
|
+
const currentPageRows = getCurrentPageRows();
|
|
392
401
|
if (currentPageRows.length === 0) {
|
|
393
402
|
return;
|
|
394
403
|
}
|
|
@@ -517,7 +526,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
517
526
|
if (shouldPreventDefault) {
|
|
518
527
|
event.preventDefault();
|
|
519
528
|
}
|
|
520
|
-
}, [apiRef,
|
|
529
|
+
}, [apiRef, getCurrentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
|
|
521
530
|
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
522
531
|
event
|
|
523
532
|
}) => {
|
|
@@ -3,16 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.enrichPageRowsWithPinnedRows = enrichPageRowsWithPinnedRows;
|
|
7
6
|
exports.findNonRowSpannedCell = findNonRowSpannedCell;
|
|
8
7
|
exports.getRightColumnIndex = exports.getLeftColumnIndex = void 0;
|
|
9
8
|
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
10
9
|
var _gridRowSpanningSelectors = require("../rows/gridRowSpanningSelectors");
|
|
11
|
-
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
12
|
-
function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
13
|
-
const pinnedRows = (0, _gridRowsSelector.gridPinnedRowsSelector)(apiRef) || {};
|
|
14
|
-
return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
|
|
15
|
-
}
|
|
16
10
|
const getLeftColumnIndex = ({
|
|
17
11
|
currentColIndex,
|
|
18
12
|
firstColIndex,
|
|
@@ -9,6 +9,7 @@ exports.listViewStateInitializer = void 0;
|
|
|
9
9
|
exports.useGridListView = useGridListView;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
12
13
|
var _warning = require("@mui/x-internals/warning");
|
|
13
14
|
var _dimensions = require("../dimensions");
|
|
14
15
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
@@ -47,7 +48,7 @@ function useGridListView(apiRef, props) {
|
|
|
47
48
|
/*
|
|
48
49
|
* EFFECTS
|
|
49
50
|
*/
|
|
50
|
-
|
|
51
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
51
52
|
const listColumn = props.unstable_listColumn;
|
|
52
53
|
if (listColumn) {
|
|
53
54
|
apiRef.current.setState(state => {
|