@mui/x-data-grid 7.19.0 → 7.21.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 +224 -43
- package/DataGrid/DataGrid.js +8 -0
- package/DataGrid/index.d.ts +0 -1
- package/DataGrid/index.js +1 -2
- package/DataGrid/useDataGridComponent.js +4 -1
- package/DataGrid/useDataGridProps.d.ts +1 -5
- package/DataGrid/useDataGridProps.js +3 -62
- package/components/GridPagination.js +1 -0
- package/components/GridRow.js +25 -36
- package/components/base/GridOverlays.js +8 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +1 -0
- package/components/containers/GridRootStyles.js +1 -0
- package/components/menu/columnMenu/GridColumnMenu.js +32 -0
- package/components/toolbar/GridToolbarExport.d.ts +9 -3
- package/components/toolbar/GridToolbarExport.js +55 -3
- package/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/components/virtualization/GridVirtualScroller.js +2 -2
- package/constants/dataGridPropsDefaultValues.d.ts +5 -0
- package/constants/dataGridPropsDefaultValues.js +60 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
- package/hooks/core/useGridRefs.js +4 -0
- package/hooks/features/clipboard/useGridClipboard.js +2 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +1 -1
- package/hooks/features/columns/gridColumnsUtils.js +3 -0
- package/hooks/features/dimensions/useGridDimensions.js +6 -4
- package/hooks/features/editing/useGridCellEditing.js +3 -1
- package/hooks/features/editing/useGridRowEditing.js +3 -1
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +1 -0
- package/hooks/features/filter/gridFilterUtils.js +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
- package/hooks/features/listView/gridListViewSelectors.d.ts +5 -0
- package/hooks/features/listView/gridListViewSelectors.js +4 -0
- package/hooks/features/listView/useGridListView.d.ts +10 -0
- package/hooks/features/listView/useGridListView.js +54 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +11 -2
- package/hooks/features/rowSelection/utils.js +6 -6
- package/hooks/features/rows/gridRowsMetaInterfaces.d.ts +16 -0
- package/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +3 -0
- package/hooks/features/rows/gridRowsUtils.js +15 -2
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
- package/hooks/features/rows/useGridParamsApi.js +4 -3
- package/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.js +10 -5
- package/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
- package/hooks/utils/useGridApiContext.js +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.js +1 -1
- package/hooks/utils/useGridApiMethod.js +2 -1
- package/hooks/utils/useGridConfiguration.js +1 -1
- package/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/index.d.ts +3 -2
- package/index.js +4 -3
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/joy/icons.js +0 -1
- package/locales/jaJP.js +4 -4
- package/models/api/gridApiCommunity.d.ts +1 -1
- package/models/api/gridCoreApi.d.ts +9 -1
- package/models/api/gridFilterApi.d.ts +1 -1
- package/models/api/gridRowsMetaApi.d.ts +15 -14
- package/models/colDef/gridColDef.d.ts +6 -0
- package/models/colDef/index.d.ts +1 -1
- package/models/events/gridEventLookup.d.ts +7 -0
- package/models/gridApiCaches.d.ts +2 -0
- package/models/gridStateCommunity.d.ts +4 -2
- package/models/props/DataGridProps.d.ts +37 -17
- package/modern/DataGrid/DataGrid.js +8 -0
- package/modern/DataGrid/index.js +1 -2
- package/modern/DataGrid/useDataGridComponent.js +4 -1
- package/modern/DataGrid/useDataGridProps.js +3 -62
- package/modern/components/GridPagination.js +1 -0
- package/modern/components/GridRow.js +25 -36
- package/modern/components/base/GridOverlays.js +8 -0
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -0
- package/modern/components/containers/GridRootStyles.js +1 -0
- package/modern/components/menu/columnMenu/GridColumnMenu.js +32 -0
- package/modern/components/toolbar/GridToolbarExport.js +55 -3
- package/modern/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/modern/components/virtualization/GridVirtualScroller.js +2 -2
- package/modern/constants/dataGridPropsDefaultValues.js +60 -0
- package/modern/hooks/core/useGridRefs.js +4 -0
- package/modern/hooks/features/clipboard/useGridClipboard.js +2 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +3 -0
- package/modern/hooks/features/dimensions/useGridDimensions.js +6 -4
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +3 -1
- package/modern/hooks/features/events/useGridEvents.js +1 -0
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
- package/modern/hooks/features/listView/gridListViewSelectors.js +4 -0
- package/modern/hooks/features/listView/useGridListView.js +54 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +11 -2
- package/modern/hooks/features/rowSelection/utils.js +6 -6
- package/modern/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +15 -2
- package/modern/hooks/features/rows/useGridParamsApi.js +4 -3
- package/modern/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/modern/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/modern/hooks/features/scroll/useGridScroll.js +10 -5
- package/modern/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
- package/modern/hooks/utils/useGridApiContext.js +1 -1
- package/modern/hooks/utils/useGridApiEventHandler.js +1 -1
- package/modern/hooks/utils/useGridApiMethod.js +2 -1
- package/modern/hooks/utils/useGridConfiguration.js +1 -1
- package/modern/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/modern/index.js +4 -3
- package/modern/internals/index.js +2 -1
- package/modern/joy/icons.js +0 -1
- package/modern/locales/jaJP.js +4 -4
- package/modern/utils/ResizeObserver.js +10 -0
- package/modern/utils/domUtils.js +1 -1
- package/modern/utils/keyboardUtils.js +12 -4
- package/node/DataGrid/DataGrid.js +8 -0
- package/node/DataGrid/index.js +1 -12
- package/node/DataGrid/useDataGridComponent.js +4 -1
- package/node/DataGrid/useDataGridProps.js +6 -65
- package/node/components/GridPagination.js +1 -0
- package/node/components/GridRow.js +25 -36
- package/node/components/base/GridOverlays.js +8 -0
- package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -0
- package/node/components/containers/GridRootStyles.js +1 -0
- package/node/components/menu/columnMenu/GridColumnMenu.js +32 -0
- package/node/components/toolbar/GridToolbarExport.js +52 -0
- package/node/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/node/components/virtualization/GridVirtualScroller.js +2 -2
- package/node/constants/dataGridPropsDefaultValues.js +66 -0
- package/node/hooks/core/useGridRefs.js +4 -0
- package/node/hooks/features/clipboard/useGridClipboard.js +2 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +3 -1
- package/node/hooks/features/columns/gridColumnsUtils.js +3 -0
- package/node/hooks/features/dimensions/useGridDimensions.js +5 -3
- package/node/hooks/features/editing/useGridCellEditing.js +3 -1
- package/node/hooks/features/editing/useGridRowEditing.js +3 -1
- package/node/hooks/features/events/useGridEvents.js +1 -0
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +9 -5
- package/node/hooks/features/listView/gridListViewSelectors.js +11 -0
- package/node/hooks/features/listView/useGridListView.js +64 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +11 -2
- package/node/hooks/features/rowSelection/utils.js +6 -6
- package/node/hooks/features/rows/gridRowsMetaInterfaces.js +5 -0
- package/node/hooks/features/rows/gridRowsUtils.js +17 -3
- package/node/hooks/features/rows/useGridParamsApi.js +4 -3
- package/node/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/node/hooks/features/rows/useGridRowsMeta.js +136 -154
- package/node/hooks/features/scroll/useGridScroll.js +10 -5
- package/node/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +25 -11
- package/node/hooks/utils/useGridApiContext.js +1 -1
- package/node/hooks/utils/useGridApiEventHandler.js +1 -1
- package/node/hooks/utils/useGridApiMethod.js +3 -1
- package/node/hooks/utils/useGridConfiguration.js +1 -1
- package/node/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/node/index.js +13 -1
- package/node/internals/index.js +22 -0
- package/node/joy/icons.js +0 -1
- package/node/locales/jaJP.js +4 -4
- package/node/utils/ResizeObserver.js +16 -0
- package/node/utils/domUtils.js +1 -1
- package/node/utils/keyboardUtils.js +15 -5
- package/package.json +4 -4
- package/utils/ResizeObserver.d.ts +4 -0
- package/utils/ResizeObserver.js +10 -0
- package/utils/domUtils.js +1 -1
- package/utils/keyboardUtils.d.ts +1 -0
- package/utils/keyboardUtils.js +12 -4
|
@@ -7,7 +7,6 @@ import clsx from 'clsx';
|
|
|
7
7
|
import { unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
8
8
|
import { fastMemo } from '@mui/x-internals/fastMemo';
|
|
9
9
|
import { GridEditModes, GridRowModes, GridCellModes } from "../models/gridEditRowModel.js";
|
|
10
|
-
import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
|
|
11
10
|
import { gridClasses } from "../constants/gridClasses.js";
|
|
12
11
|
import { composeGridClasses } from "../utils/composeGridClasses.js";
|
|
13
12
|
import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
|
|
@@ -25,6 +24,7 @@ import { PinnedPosition, gridPinnedColumnPositionLookup } from "./cell/GridCell.
|
|
|
25
24
|
import { GridScrollbarFillerCell as ScrollbarFiller } from "./GridScrollbarFillerCell.js";
|
|
26
25
|
import { getPinnedCellOffset } from "../internals/utils/getPinnedCellOffset.js";
|
|
27
26
|
import { useGridConfiguration } from "../hooks/utils/useGridConfiguration.js";
|
|
27
|
+
import { useGridPrivateApiContext } from "../hooks/utils/useGridPrivateApiContext.js";
|
|
28
28
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
29
|
function EmptyCell({
|
|
30
30
|
width
|
|
@@ -40,6 +40,13 @@ function EmptyCell({
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
process.env.NODE_ENV !== "production" ? EmptyCell.propTypes = {
|
|
44
|
+
// ----------------------------- Warning --------------------------------
|
|
45
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
46
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
47
|
+
// ----------------------------------------------------------------------
|
|
48
|
+
width: PropTypes.number.isRequired
|
|
49
|
+
} : void 0;
|
|
43
50
|
const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
44
51
|
const {
|
|
45
52
|
selected,
|
|
@@ -67,7 +74,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
67
74
|
onMouseOver
|
|
68
75
|
} = props,
|
|
69
76
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
70
|
-
const apiRef =
|
|
77
|
+
const apiRef = useGridPrivateApiContext();
|
|
71
78
|
const configuration = useGridConfiguration();
|
|
72
79
|
const ref = React.useRef(null);
|
|
73
80
|
const rootProps = useGridRootProps();
|
|
@@ -91,30 +98,17 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
91
98
|
const getRowAriaAttributes = configuration.hooks.useGridRowAriaAttributes();
|
|
92
99
|
React.useLayoutEffect(() => {
|
|
93
100
|
if (currentPage.range) {
|
|
94
|
-
// The index prop is relative to the rows from all pages. As example, the index prop of the
|
|
95
|
-
// first row is 5 if `paginationModel.pageSize=5` and `paginationModel.page=1`. However, the index used by the virtualization
|
|
96
|
-
// doesn't care about pagination and considers the rows from the current page only, so the
|
|
97
|
-
// first row always has index=0. We need to subtract the index of the first row to make it
|
|
98
|
-
// compatible with the index used by the virtualization.
|
|
99
101
|
const rowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(rowId);
|
|
100
|
-
//
|
|
101
|
-
if (rowIndex
|
|
102
|
+
// Pinned rows are not part of the visible rows
|
|
103
|
+
if (rowIndex !== undefined) {
|
|
102
104
|
apiRef.current.unstable_setLastMeasuredRowIndex(rowIndex);
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (!rootElement || hasFixedHeight || typeof ResizeObserver === 'undefined') {
|
|
108
|
-
return undefined;
|
|
107
|
+
if (ref.current && rowHeight === 'auto') {
|
|
108
|
+
return apiRef.current.observeRowHeight(ref.current, rowId);
|
|
109
109
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
|
|
113
|
-
apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
|
|
114
|
-
});
|
|
115
|
-
resizeObserver.observe(rootElement);
|
|
116
|
-
return () => resizeObserver.disconnect();
|
|
117
|
-
}, [apiRef, currentPage.range, index, rowHeight, rowId]);
|
|
110
|
+
return undefined;
|
|
111
|
+
}, [apiRef, currentPage.range, rowHeight, rowId]);
|
|
118
112
|
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
119
113
|
// Ignore portal
|
|
120
114
|
if (isEventTargetInPortal(event)) {
|
|
@@ -171,15 +165,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
171
165
|
disableColumnReorder
|
|
172
166
|
} = rootProps;
|
|
173
167
|
const rowReordering = rootProps.rowReordering;
|
|
174
|
-
const
|
|
175
|
-
let minHeight = rowHeight;
|
|
176
|
-
if (minHeight === 'auto' && sizes) {
|
|
177
|
-
const numberOfBaseSizes = 1;
|
|
178
|
-
const maximumSize = sizes.baseCenter ?? 0;
|
|
179
|
-
if (maximumSize > 0 && numberOfBaseSizes > 1) {
|
|
180
|
-
minHeight = maximumSize;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
168
|
+
const heightEntry = useGridSelector(apiRef, () => _extends({}, apiRef.current.getRowHeightEntry(rowId)), objectShallowCompare);
|
|
183
169
|
const style = React.useMemo(() => {
|
|
184
170
|
if (isNotVisible) {
|
|
185
171
|
return {
|
|
@@ -191,25 +177,25 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
191
177
|
const rowStyle = _extends({}, styleProp, {
|
|
192
178
|
maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
|
|
193
179
|
// max-height doesn't support "auto"
|
|
194
|
-
minHeight,
|
|
180
|
+
minHeight: rowHeight,
|
|
195
181
|
'--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
|
|
196
182
|
});
|
|
197
|
-
if (
|
|
183
|
+
if (heightEntry.spacingTop) {
|
|
198
184
|
const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
|
|
199
|
-
rowStyle[property] =
|
|
185
|
+
rowStyle[property] = heightEntry.spacingTop;
|
|
200
186
|
}
|
|
201
|
-
if (
|
|
187
|
+
if (heightEntry.spacingBottom) {
|
|
202
188
|
const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
|
|
203
189
|
let propertyValue = rowStyle[property];
|
|
204
190
|
// avoid overriding existing value
|
|
205
191
|
if (typeof propertyValue !== 'number') {
|
|
206
192
|
propertyValue = parseInt(propertyValue || '0', 10);
|
|
207
193
|
}
|
|
208
|
-
propertyValue +=
|
|
194
|
+
propertyValue += heightEntry.spacingBottom;
|
|
209
195
|
rowStyle[property] = propertyValue;
|
|
210
196
|
}
|
|
211
197
|
return rowStyle;
|
|
212
|
-
}, [isNotVisible, rowHeight, styleProp,
|
|
198
|
+
}, [isNotVisible, rowHeight, styleProp, heightEntry, rootProps.rowSpacingType]);
|
|
213
199
|
const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
|
|
214
200
|
const ariaAttributes = rowNode ? getRowAriaAttributes(rowNode, index) : undefined;
|
|
215
201
|
if (typeof rootProps.getRowClassName === 'function') {
|
|
@@ -287,6 +273,9 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
287
273
|
for (let i = renderContext.firstColumnIndex; i < renderContext.lastColumnIndex; i += 1) {
|
|
288
274
|
const column = visibleColumns[i];
|
|
289
275
|
const indexInSection = i - pinnedColumns.left.length;
|
|
276
|
+
if (!column) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
290
279
|
cells.push(getCell(column, indexInSection, i, middleColumnsLength));
|
|
291
280
|
}
|
|
292
281
|
if (hasVirtualFocusCellRight) {
|
|
@@ -74,6 +74,14 @@ function GridOverlayWrapper(props) {
|
|
|
74
74
|
}, props))
|
|
75
75
|
}));
|
|
76
76
|
}
|
|
77
|
+
process.env.NODE_ENV !== "production" ? GridOverlayWrapper.propTypes = {
|
|
78
|
+
// ----------------------------- Warning --------------------------------
|
|
79
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
80
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
81
|
+
// ----------------------------------------------------------------------
|
|
82
|
+
loadingOverlayVariant: PropTypes.oneOf(['circular-progress', 'linear-progress', 'skeleton']),
|
|
83
|
+
overlayType: PropTypes.oneOf(['loadingOverlay', 'noResultsOverlay', 'noRowsOverlay'])
|
|
84
|
+
} : void 0;
|
|
77
85
|
process.env.NODE_ENV !== "production" ? GridOverlays.propTypes = {
|
|
78
86
|
// ----------------------------- Warning --------------------------------
|
|
79
87
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -92,6 +92,7 @@ function GridColumnHeaderItem(props) {
|
|
|
92
92
|
}, [apiRef, colDef.field]);
|
|
93
93
|
const mouseEventsHandlers = React.useMemo(() => ({
|
|
94
94
|
onClick: publish('columnHeaderClick'),
|
|
95
|
+
onContextMenu: publish('columnHeaderContextMenu'),
|
|
95
96
|
onDoubleClick: publish('columnHeaderDoubleClick'),
|
|
96
97
|
onMouseOver: publish('columnHeaderOver'),
|
|
97
98
|
// TODO remove as it's not used
|
|
@@ -45,6 +45,38 @@ const GridGenericColumnMenu = /*#__PURE__*/React.forwardRef(function GridGeneric
|
|
|
45
45
|
children: orderedSlots.map(([Component, otherProps], index) => /*#__PURE__*/_jsx(Component, _extends({}, otherProps), index))
|
|
46
46
|
}));
|
|
47
47
|
});
|
|
48
|
+
process.env.NODE_ENV !== "production" ? GridGenericColumnMenu.propTypes = {
|
|
49
|
+
// ----------------------------- Warning --------------------------------
|
|
50
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
51
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
52
|
+
// ----------------------------------------------------------------------
|
|
53
|
+
colDef: PropTypes.object.isRequired,
|
|
54
|
+
/**
|
|
55
|
+
* Initial `slotProps` - it is internal, to be overrriden by Pro or Premium packages
|
|
56
|
+
* @ignore - do not document.
|
|
57
|
+
*/
|
|
58
|
+
defaultSlotProps: PropTypes.object.isRequired,
|
|
59
|
+
/**
|
|
60
|
+
* Initial `slots` - it is internal, to be overrriden by Pro or Premium packages
|
|
61
|
+
* @ignore - do not document.
|
|
62
|
+
*/
|
|
63
|
+
defaultSlots: PropTypes.object.isRequired,
|
|
64
|
+
hideMenu: PropTypes.func.isRequired,
|
|
65
|
+
id: PropTypes.string,
|
|
66
|
+
labelledby: PropTypes.string,
|
|
67
|
+
open: PropTypes.bool.isRequired,
|
|
68
|
+
/**
|
|
69
|
+
* Could be used to pass new props or override props specific to a column menu component
|
|
70
|
+
* e.g. `displayOrder`
|
|
71
|
+
*/
|
|
72
|
+
slotProps: PropTypes.object,
|
|
73
|
+
/**
|
|
74
|
+
* `slots` could be used to add new and (or) override default column menu items
|
|
75
|
+
* If you register a nee component you must pass it's `displayOrder` in `slotProps`
|
|
76
|
+
* or it will be placed in the end of the list
|
|
77
|
+
*/
|
|
78
|
+
slots: PropTypes.object
|
|
79
|
+
} : void 0;
|
|
48
80
|
const GridColumnMenu = /*#__PURE__*/React.forwardRef(function GridColumnMenu(props, ref) {
|
|
49
81
|
return /*#__PURE__*/_jsx(GridGenericColumnMenu, _extends({}, props, {
|
|
50
82
|
ref: ref,
|
|
@@ -9,7 +9,7 @@ import MenuItem from '@mui/material/MenuItem';
|
|
|
9
9
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
10
10
|
import { GridToolbarExportContainer } from "./GridToolbarExportContainer.js";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
|
|
12
|
+
function GridCsvExportMenuItem(props) {
|
|
13
13
|
const apiRef = useGridApiContext();
|
|
14
14
|
const {
|
|
15
15
|
hideMenu,
|
|
@@ -25,7 +25,27 @@ export function GridCsvExportMenuItem(props) {
|
|
|
25
25
|
children: apiRef.current.getLocaleText('toolbarExportCSV')
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
process.env.NODE_ENV !== "production" ? GridCsvExportMenuItem.propTypes = {
|
|
29
|
+
// ----------------------------- Warning --------------------------------
|
|
30
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
31
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
32
|
+
// ----------------------------------------------------------------------
|
|
33
|
+
hideMenu: PropTypes.func,
|
|
34
|
+
options: PropTypes.shape({
|
|
35
|
+
allColumns: PropTypes.bool,
|
|
36
|
+
delimiter: PropTypes.string,
|
|
37
|
+
disableToolbarButton: PropTypes.bool,
|
|
38
|
+
escapeFormulas: PropTypes.bool,
|
|
39
|
+
fields: PropTypes.arrayOf(PropTypes.string),
|
|
40
|
+
fileName: PropTypes.string,
|
|
41
|
+
getRowsToExport: PropTypes.func,
|
|
42
|
+
includeColumnGroupsHeaders: PropTypes.bool,
|
|
43
|
+
includeHeaders: PropTypes.bool,
|
|
44
|
+
shouldAppendQuotes: PropTypes.bool,
|
|
45
|
+
utf8WithBom: PropTypes.bool
|
|
46
|
+
})
|
|
47
|
+
} : void 0;
|
|
48
|
+
function GridPrintExportMenuItem(props) {
|
|
29
49
|
const apiRef = useGridApiContext();
|
|
30
50
|
const {
|
|
31
51
|
hideMenu,
|
|
@@ -41,6 +61,38 @@ export function GridPrintExportMenuItem(props) {
|
|
|
41
61
|
children: apiRef.current.getLocaleText('toolbarExportPrint')
|
|
42
62
|
}));
|
|
43
63
|
}
|
|
64
|
+
process.env.NODE_ENV !== "production" ? GridPrintExportMenuItem.propTypes = {
|
|
65
|
+
// ----------------------------- Warning --------------------------------
|
|
66
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
67
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
68
|
+
// ----------------------------------------------------------------------
|
|
69
|
+
hideMenu: PropTypes.func,
|
|
70
|
+
options: PropTypes.shape({
|
|
71
|
+
allColumns: PropTypes.bool,
|
|
72
|
+
bodyClassName: PropTypes.string,
|
|
73
|
+
copyStyles: PropTypes.bool,
|
|
74
|
+
disableToolbarButton: PropTypes.bool,
|
|
75
|
+
fields: PropTypes.arrayOf(PropTypes.string),
|
|
76
|
+
fileName: PropTypes.string,
|
|
77
|
+
getRowsToExport: PropTypes.func,
|
|
78
|
+
hideFooter: PropTypes.bool,
|
|
79
|
+
hideToolbar: PropTypes.bool,
|
|
80
|
+
includeCheckboxes: PropTypes.bool,
|
|
81
|
+
pageStyle: PropTypes.oneOfType([PropTypes.shape({
|
|
82
|
+
'__@hasInstance@646': PropTypes.func.isRequired,
|
|
83
|
+
'__@metadata@648': PropTypes.any,
|
|
84
|
+
apply: PropTypes.func.isRequired,
|
|
85
|
+
arguments: PropTypes.any.isRequired,
|
|
86
|
+
bind: PropTypes.func.isRequired,
|
|
87
|
+
call: PropTypes.func.isRequired,
|
|
88
|
+
caller: PropTypes.object.isRequired,
|
|
89
|
+
length: PropTypes.number.isRequired,
|
|
90
|
+
name: PropTypes.string.isRequired,
|
|
91
|
+
prototype: PropTypes.any.isRequired,
|
|
92
|
+
toString: PropTypes.func.isRequired
|
|
93
|
+
}), PropTypes.string])
|
|
94
|
+
})
|
|
95
|
+
} : void 0;
|
|
44
96
|
const GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExport(props, ref) {
|
|
45
97
|
const {
|
|
46
98
|
csvOptions = {},
|
|
@@ -77,4 +129,4 @@ process.env.NODE_ENV !== "production" ? GridToolbarExport.propTypes = {
|
|
|
77
129
|
*/
|
|
78
130
|
slotProps: PropTypes.object
|
|
79
131
|
} : void 0;
|
|
80
|
-
export { GridToolbarExport };
|
|
132
|
+
export { GridToolbarExport, GridCsvExportMenuItem, GridPrintExportMenuItem };
|
|
@@ -119,6 +119,10 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
119
119
|
return /*#__PURE__*/_jsx(Container, {
|
|
120
120
|
ref: useForkRef(ref, scrollbarRef),
|
|
121
121
|
className: classes.root,
|
|
122
|
+
style: props.position === 'vertical' && rootProps.unstable_listView ? {
|
|
123
|
+
height: '100%',
|
|
124
|
+
top: 0
|
|
125
|
+
} : undefined,
|
|
122
126
|
tabIndex: -1,
|
|
123
127
|
"aria-hidden": "true",
|
|
124
128
|
children: /*#__PURE__*/_jsx("div", {
|
|
@@ -78,7 +78,7 @@ function GridVirtualScroller(props) {
|
|
|
78
78
|
}, getScrollerProps(), {
|
|
79
79
|
ownerState: rootProps,
|
|
80
80
|
children: [/*#__PURE__*/_jsxs(TopContainer, {
|
|
81
|
-
children: [/*#__PURE__*/_jsx(GridHeaders, {}), /*#__PURE__*/_jsx(rootProps.slots.pinnedRows, {
|
|
81
|
+
children: [!rootProps.unstable_listView && /*#__PURE__*/_jsx(GridHeaders, {}), /*#__PURE__*/_jsx(rootProps.slots.pinnedRows, {
|
|
82
82
|
position: "top",
|
|
83
83
|
virtualScroller: virtualScroller
|
|
84
84
|
})]
|
|
@@ -98,7 +98,7 @@ function GridVirtualScroller(props) {
|
|
|
98
98
|
})]
|
|
99
99
|
})), dimensions.hasScrollY && /*#__PURE__*/_jsx(Scrollbar, _extends({
|
|
100
100
|
position: "vertical"
|
|
101
|
-
}, getScrollbarVerticalProps())), dimensions.hasScrollX && /*#__PURE__*/_jsx(Scrollbar, _extends({
|
|
101
|
+
}, getScrollbarVerticalProps())), dimensions.hasScrollX && !rootProps.unstable_listView && /*#__PURE__*/_jsx(Scrollbar, _extends({
|
|
102
102
|
position: "horizontal"
|
|
103
103
|
}, getScrollbarHorizontalProps())), props.children]
|
|
104
104
|
}));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { GridEditModes } from "../models/gridEditRowModel.js";
|
|
2
|
+
/**
|
|
3
|
+
* The default values of `DataGridPropsWithDefaultValues` to inject in the props of DataGrid.
|
|
4
|
+
*/
|
|
5
|
+
export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
6
|
+
autoHeight: false,
|
|
7
|
+
autoPageSize: false,
|
|
8
|
+
autosizeOnMount: false,
|
|
9
|
+
checkboxSelection: false,
|
|
10
|
+
checkboxSelectionVisibleOnly: false,
|
|
11
|
+
clipboardCopyCellDelimiter: '\t',
|
|
12
|
+
columnBufferPx: 150,
|
|
13
|
+
columnHeaderHeight: 56,
|
|
14
|
+
disableAutosize: false,
|
|
15
|
+
disableColumnFilter: false,
|
|
16
|
+
disableColumnMenu: false,
|
|
17
|
+
disableColumnReorder: false,
|
|
18
|
+
disableColumnResize: false,
|
|
19
|
+
disableColumnSelector: false,
|
|
20
|
+
disableColumnSorting: false,
|
|
21
|
+
disableDensitySelector: false,
|
|
22
|
+
disableEval: false,
|
|
23
|
+
disableMultipleColumnsFiltering: false,
|
|
24
|
+
disableMultipleColumnsSorting: false,
|
|
25
|
+
disableMultipleRowSelection: false,
|
|
26
|
+
disableRowSelectionOnClick: false,
|
|
27
|
+
disableVirtualization: false,
|
|
28
|
+
editMode: GridEditModes.Cell,
|
|
29
|
+
filterDebounceMs: 150,
|
|
30
|
+
filterMode: 'client',
|
|
31
|
+
hideFooter: false,
|
|
32
|
+
hideFooterPagination: false,
|
|
33
|
+
hideFooterRowCount: false,
|
|
34
|
+
hideFooterSelectedRowCount: false,
|
|
35
|
+
ignoreDiacritics: false,
|
|
36
|
+
ignoreValueFormatterDuringExport: false,
|
|
37
|
+
// TODO v8: Update to 'select'
|
|
38
|
+
indeterminateCheckboxAction: 'deselect',
|
|
39
|
+
keepColumnPositionIfDraggedOutside: false,
|
|
40
|
+
keepNonExistentRowsSelected: false,
|
|
41
|
+
loading: false,
|
|
42
|
+
logger: console,
|
|
43
|
+
logLevel: process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
|
44
|
+
pageSizeOptions: [25, 50, 100],
|
|
45
|
+
pagination: false,
|
|
46
|
+
paginationMode: 'client',
|
|
47
|
+
resizeThrottleMs: 60,
|
|
48
|
+
rowBufferPx: 150,
|
|
49
|
+
rowHeight: 52,
|
|
50
|
+
rowPositionsDebounceMs: 166,
|
|
51
|
+
rows: [],
|
|
52
|
+
rowSelection: true,
|
|
53
|
+
rowSpacingType: 'margin',
|
|
54
|
+
showCellVerticalBorder: false,
|
|
55
|
+
showColumnVerticalBorder: false,
|
|
56
|
+
sortingMode: 'client',
|
|
57
|
+
sortingOrder: ['asc', 'desc', null],
|
|
58
|
+
throttleRowsMs: 0,
|
|
59
|
+
unstable_rowSpanning: false
|
|
60
|
+
};
|
|
@@ -3,6 +3,8 @@ export const useGridRefs = apiRef => {
|
|
|
3
3
|
const rootElementRef = React.useRef(null);
|
|
4
4
|
const mainElementRef = React.useRef(null);
|
|
5
5
|
const virtualScrollerRef = React.useRef(null);
|
|
6
|
+
const virtualScrollbarVerticalRef = React.useRef(null);
|
|
7
|
+
const virtualScrollbarHorizontalRef = React.useRef(null);
|
|
6
8
|
const columnHeadersContainerRef = React.useRef(null);
|
|
7
9
|
apiRef.current.register('public', {
|
|
8
10
|
rootElementRef
|
|
@@ -10,6 +12,8 @@ export const useGridRefs = apiRef => {
|
|
|
10
12
|
apiRef.current.register('private', {
|
|
11
13
|
mainElementRef,
|
|
12
14
|
virtualScrollerRef,
|
|
15
|
+
virtualScrollbarVerticalRef,
|
|
16
|
+
virtualScrollbarHorizontalRef,
|
|
13
17
|
columnHeadersContainerRef
|
|
14
18
|
});
|
|
15
19
|
};
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { useGridApiOptionHandler, useGridNativeEventListener } from "../../utils/index.js";
|
|
3
3
|
import { gridFocusCellSelector } from "../focus/gridFocusStateSelector.js";
|
|
4
4
|
import { serializeCellValue } from "../export/serializers/csvSerializer.js";
|
|
5
|
+
import { isCopyShortcut } from "../../../utils/keyboardUtils.js";
|
|
5
6
|
function writeToClipboardPolyfill(data) {
|
|
6
7
|
const span = document.createElement('span');
|
|
7
8
|
span.style.whiteSpace = 'pre';
|
|
@@ -53,7 +54,7 @@ export const useGridClipboard = (apiRef, props) => {
|
|
|
53
54
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
|
|
54
55
|
const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
55
56
|
const handleCopy = React.useCallback(event => {
|
|
56
|
-
if (!(
|
|
57
|
+
if (!isCopyShortcut(event)) {
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -56,7 +56,9 @@ export const useGridColumnHeaders = props => {
|
|
|
56
56
|
const offsetLeft = computeOffsetLeft(columnPositions, renderContext, pinnedColumns.left.length);
|
|
57
57
|
const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
|
|
58
58
|
React.useEffect(() => {
|
|
59
|
-
apiRef.current.columnHeadersContainerRef.current
|
|
59
|
+
if (apiRef.current.columnHeadersContainerRef.current) {
|
|
60
|
+
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
61
|
+
}
|
|
60
62
|
}, [apiRef]);
|
|
61
63
|
const handleColumnResizeStart = React.useCallback(params => setResizeCol(params.field), []);
|
|
62
64
|
const handleColumnResizeStop = React.useCallback(() => setResizeCol(''), []);
|
|
@@ -312,6 +312,9 @@ export function getFirstNonSpannedColumnToRender({
|
|
|
312
312
|
return firstNonSpannedColumnToRender;
|
|
313
313
|
}
|
|
314
314
|
export function getTotalHeaderHeight(apiRef, props) {
|
|
315
|
+
if (props.unstable_listView) {
|
|
316
|
+
return 0;
|
|
317
|
+
}
|
|
315
318
|
const densityFactor = gridDensityFactorSelector(apiRef);
|
|
316
319
|
const maxDepth = gridColumnGroupsHeaderMaxDepthSelector(apiRef);
|
|
317
320
|
const isHeaderFilteringEnabled = gridHeaderFilteringEnabledSelector(apiRef);
|
|
@@ -12,8 +12,9 @@ import { gridRenderContextSelector } from "../virtualization/index.js";
|
|
|
12
12
|
import { useGridSelector } from "../../utils/index.js";
|
|
13
13
|
import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
14
14
|
import { gridRowsMetaSelector } from "../rows/gridRowsMetaSelector.js";
|
|
15
|
-
import { calculatePinnedRowsHeight } from "../rows/gridRowsUtils.js";
|
|
15
|
+
import { calculatePinnedRowsHeight, getValidRowHeight, rowHeightWarning } from "../rows/gridRowsUtils.js";
|
|
16
16
|
import { getTotalHeaderHeight } from "../columns/gridColumnsUtils.js";
|
|
17
|
+
import { DATA_GRID_PROPS_DEFAULT_VALUES } from "../../../constants/dataGridPropsDefaultValues.js";
|
|
17
18
|
const EMPTY_SIZE = {
|
|
18
19
|
width: 0,
|
|
19
20
|
height: 0
|
|
@@ -54,7 +55,8 @@ export function useGridDimensions(apiRef, props) {
|
|
|
54
55
|
const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
|
|
55
56
|
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
56
57
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
57
|
-
const
|
|
58
|
+
const validRowHeight = React.useMemo(() => getValidRowHeight(props.rowHeight, DATA_GRID_PROPS_DEFAULT_VALUES.rowHeight, rowHeightWarning), [props.rowHeight]);
|
|
59
|
+
const rowHeight = Math.floor(validRowHeight * densityFactor);
|
|
58
60
|
const headerHeight = Math.floor(props.columnHeaderHeight * densityFactor);
|
|
59
61
|
const groupHeaderHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
60
62
|
const headerFilterHeight = Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
@@ -238,11 +240,11 @@ export function useGridDimensions(apiRef, props) {
|
|
|
238
240
|
// jsdom has no layout capabilities
|
|
239
241
|
const isJSDOM = /jsdom/.test(window.navigator.userAgent);
|
|
240
242
|
if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
|
|
241
|
-
logger.error(['The parent DOM element of the
|
|
243
|
+
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'));
|
|
242
244
|
errorShown.current = true;
|
|
243
245
|
}
|
|
244
246
|
if (size.width === 0 && !errorShown.current && !isJSDOM) {
|
|
245
|
-
logger.error(['The parent DOM element of the
|
|
247
|
+
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'));
|
|
246
248
|
errorShown.current = true;
|
|
247
249
|
}
|
|
248
250
|
if (isFirstSizing.current) {
|
|
@@ -324,7 +324,9 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
324
324
|
};
|
|
325
325
|
try {
|
|
326
326
|
const row = apiRef.current.getRow(id);
|
|
327
|
-
Promise.resolve(processRowUpdate(rowUpdate, row
|
|
327
|
+
Promise.resolve(processRowUpdate(rowUpdate, row, {
|
|
328
|
+
rowId: id
|
|
329
|
+
})).then(finalRowUpdate => {
|
|
328
330
|
apiRef.current.updateRows([finalRowUpdate]);
|
|
329
331
|
finishCellEditMode();
|
|
330
332
|
}).catch(handleError);
|
|
@@ -397,7 +397,9 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
397
397
|
}
|
|
398
398
|
};
|
|
399
399
|
try {
|
|
400
|
-
Promise.resolve(processRowUpdate(rowUpdate, row
|
|
400
|
+
Promise.resolve(processRowUpdate(rowUpdate, row, {
|
|
401
|
+
rowId: id
|
|
402
|
+
})).then(finalRowUpdate => {
|
|
401
403
|
apiRef.current.updateRows([finalRowUpdate]);
|
|
402
404
|
finishRowEditMode();
|
|
403
405
|
}).catch(handleError);
|
|
@@ -5,6 +5,7 @@ import { useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export function useGridEvents(apiRef, props) {
|
|
7
7
|
useGridApiOptionHandler(apiRef, 'columnHeaderClick', props.onColumnHeaderClick);
|
|
8
|
+
useGridApiOptionHandler(apiRef, 'columnHeaderContextMenu', props.onColumnHeaderContextMenu);
|
|
8
9
|
useGridApiOptionHandler(apiRef, 'columnHeaderDoubleClick', props.onColumnHeaderDoubleClick);
|
|
9
10
|
useGridApiOptionHandler(apiRef, 'columnHeaderOver', props.onColumnHeaderOver);
|
|
10
11
|
useGridApiOptionHandler(apiRef, 'columnHeaderOut', props.onColumnHeaderOut);
|
|
@@ -41,7 +41,7 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
|
|
|
41
41
|
let items;
|
|
42
42
|
if (hasSeveralItems && disableMultipleColumnsFiltering) {
|
|
43
43
|
if (process.env.NODE_ENV !== 'production') {
|
|
44
|
-
warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the
|
|
44
|
+
warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
|
|
45
45
|
}
|
|
46
46
|
items = [model.items[0]];
|
|
47
47
|
} else {
|
|
@@ -16,6 +16,7 @@ import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector }
|
|
|
16
16
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
17
17
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
18
18
|
import { enrichPageRowsWithPinnedRows, getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
|
|
19
|
+
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* @requires useGridSorting (method) - can be after
|
|
@@ -30,6 +31,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
30
31
|
const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
|
|
31
32
|
const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
|
|
32
33
|
const isRtl = useRtl();
|
|
34
|
+
const listView = props.unstable_listView;
|
|
33
35
|
const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
|
|
34
36
|
const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
|
|
35
37
|
|
|
@@ -50,7 +52,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
50
52
|
colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
|
-
const field = gridVisibleColumnFieldsSelector(apiRef)[colIndex];
|
|
55
|
+
const field = listView ? gridListColumnSelector(apiRef.current.state).field : gridVisibleColumnFieldsSelector(apiRef)[colIndex];
|
|
54
56
|
const nonRowSpannedRowId = findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection);
|
|
55
57
|
// `scrollToIndexes` requires a rowIndex relative to all visible rows.
|
|
56
58
|
// Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
|
|
@@ -61,7 +63,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
61
63
|
rowIndex: rowIndexRelativeToAllRows
|
|
62
64
|
});
|
|
63
65
|
apiRef.current.setCellFocus(nonRowSpannedRowId, field);
|
|
64
|
-
}, [apiRef, logger]);
|
|
66
|
+
}, [apiRef, logger, listView]);
|
|
65
67
|
const goToHeader = React.useCallback((colIndex, event) => {
|
|
66
68
|
logger.debug(`Navigating to header col ${colIndex}`);
|
|
67
69
|
apiRef.current.scrollToIndexes({
|
|
@@ -384,12 +386,14 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
384
386
|
return;
|
|
385
387
|
}
|
|
386
388
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
387
|
-
const
|
|
389
|
+
const getColumnIndexFn = listView ? () => 0 : apiRef.current.getColumnIndex;
|
|
390
|
+
const colIndexBefore = params.field ? getColumnIndexFn(params.field) : 0;
|
|
388
391
|
const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
|
|
389
392
|
const firstRowIndexInPage = 0;
|
|
390
393
|
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
391
394
|
const firstColIndex = 0;
|
|
392
|
-
const
|
|
395
|
+
const visibleColumns = listView ? [gridListColumnSelector(apiRef.current.state)] : gridVisibleColumnDefinitionsSelector(apiRef);
|
|
396
|
+
const lastColIndex = visibleColumns.length - 1;
|
|
393
397
|
let shouldPreventDefault = true;
|
|
394
398
|
switch (event.key) {
|
|
395
399
|
case 'ArrowDown':
|
|
@@ -508,7 +512,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
508
512
|
if (shouldPreventDefault) {
|
|
509
513
|
event.preventDefault();
|
|
510
514
|
}
|
|
511
|
-
}, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
|
|
515
|
+
}, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
|
|
512
516
|
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
513
517
|
event
|
|
514
518
|
}) => {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
4
|
+
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
5
|
+
export const listViewStateInitializer = (state, props, apiRef) => _extends({}, state, {
|
|
6
|
+
listViewColumn: _extends({}, props.unstable_listColumn, {
|
|
7
|
+
computedWidth: getListColumnWidth(apiRef)
|
|
8
|
+
})
|
|
9
|
+
});
|
|
10
|
+
export function useGridListView(apiRef, props) {
|
|
11
|
+
/*
|
|
12
|
+
* EVENTS
|
|
13
|
+
*/
|
|
14
|
+
const updateListColumnWidth = () => {
|
|
15
|
+
apiRef.current.setState(state => {
|
|
16
|
+
if (!state.listViewColumn) {
|
|
17
|
+
return state;
|
|
18
|
+
}
|
|
19
|
+
return _extends({}, state, {
|
|
20
|
+
listViewColumn: _extends({}, state.listViewColumn, {
|
|
21
|
+
computedWidth: getListColumnWidth(apiRef)
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const prevInnerWidth = React.useRef(null);
|
|
27
|
+
const handleGridSizeChange = viewportInnerSize => {
|
|
28
|
+
if (prevInnerWidth.current !== viewportInnerSize.width) {
|
|
29
|
+
prevInnerWidth.current = viewportInnerSize.width;
|
|
30
|
+
updateListColumnWidth();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleGridSizeChange);
|
|
34
|
+
useGridApiEventHandler(apiRef, 'columnVisibilityModelChange', updateListColumnWidth);
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* EFFECTS
|
|
38
|
+
*/
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
const listColumn = props.unstable_listColumn;
|
|
41
|
+
if (listColumn) {
|
|
42
|
+
apiRef.current.setState(state => {
|
|
43
|
+
return _extends({}, state, {
|
|
44
|
+
listViewColumn: _extends({}, listColumn, {
|
|
45
|
+
computedWidth: getListColumnWidth(apiRef)
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, [apiRef, props.unstable_listColumn]);
|
|
51
|
+
}
|
|
52
|
+
function getListColumnWidth(apiRef) {
|
|
53
|
+
return gridDimensionsSelector(apiRef.current.state).viewportInnerSize.width;
|
|
54
|
+
}
|