@mui/x-data-grid 7.20.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 +120 -31
- package/DataGrid/DataGrid.js +1 -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/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/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 +4 -2
- 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 +1 -1
- 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 +14 -1
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
- package/hooks/features/rows/useGridParamsApi.js +4 -3
- package/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/hooks/features/scroll/useGridScroll.d.ts +1 -1
- package/hooks/features/scroll/useGridScroll.js +3 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
- package/hooks/utils/useGridApiMethod.js +2 -1
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -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/gridApiCaches.d.ts +2 -0
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/props/DataGridProps.d.ts +14 -3
- package/modern/DataGrid/DataGrid.js +1 -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/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/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 +4 -2
- 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 +1 -1
- package/modern/hooks/features/rows/gridRowsMetaInterfaces.js +1 -0
- package/modern/hooks/features/rows/gridRowsUtils.js +14 -1
- package/modern/hooks/features/rows/useGridParamsApi.js +4 -3
- package/modern/hooks/features/rows/useGridRowsMeta.js +135 -154
- package/modern/hooks/features/scroll/useGridScroll.js +3 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
- package/modern/hooks/utils/useGridApiMethod.js +2 -1
- package/modern/index.js +2 -1
- package/modern/internals/index.js +2 -1
- package/modern/utils/ResizeObserver.js +10 -0
- package/modern/utils/keyboardUtils.js +12 -4
- package/node/DataGrid/DataGrid.js +1 -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/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/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 +3 -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 +1 -1
- package/node/hooks/features/rows/gridRowsMetaInterfaces.js +5 -0
- package/node/hooks/features/rows/gridRowsUtils.js +16 -2
- package/node/hooks/features/rows/useGridParamsApi.js +4 -3
- package/node/hooks/features/rows/useGridRowsMeta.js +136 -154
- package/node/hooks/features/scroll/useGridScroll.js +3 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +23 -9
- package/node/hooks/utils/useGridApiMethod.js +3 -1
- package/node/index.js +13 -1
- package/node/internals/index.js +22 -0
- package/node/utils/ResizeObserver.js +16 -0
- package/node/utils/keyboardUtils.js +15 -5
- package/package.json +2 -2
- package/utils/ResizeObserver.d.ts +4 -0
- package/utils/ResizeObserver.js +10 -0
- package/utils/keyboardUtils.d.ts +1 -0
- package/utils/keyboardUtils.js +12 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DATA_GRID_PROPS_DEFAULT_VALUES = void 0;
|
|
7
|
+
var _gridEditRowModel = require("../models/gridEditRowModel");
|
|
8
|
+
/**
|
|
9
|
+
* The default values of `DataGridPropsWithDefaultValues` to inject in the props of DataGrid.
|
|
10
|
+
*/
|
|
11
|
+
const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
12
|
+
autoHeight: false,
|
|
13
|
+
autoPageSize: false,
|
|
14
|
+
autosizeOnMount: false,
|
|
15
|
+
checkboxSelection: false,
|
|
16
|
+
checkboxSelectionVisibleOnly: false,
|
|
17
|
+
clipboardCopyCellDelimiter: '\t',
|
|
18
|
+
columnBufferPx: 150,
|
|
19
|
+
columnHeaderHeight: 56,
|
|
20
|
+
disableAutosize: false,
|
|
21
|
+
disableColumnFilter: false,
|
|
22
|
+
disableColumnMenu: false,
|
|
23
|
+
disableColumnReorder: false,
|
|
24
|
+
disableColumnResize: false,
|
|
25
|
+
disableColumnSelector: false,
|
|
26
|
+
disableColumnSorting: false,
|
|
27
|
+
disableDensitySelector: false,
|
|
28
|
+
disableEval: false,
|
|
29
|
+
disableMultipleColumnsFiltering: false,
|
|
30
|
+
disableMultipleColumnsSorting: false,
|
|
31
|
+
disableMultipleRowSelection: false,
|
|
32
|
+
disableRowSelectionOnClick: false,
|
|
33
|
+
disableVirtualization: false,
|
|
34
|
+
editMode: _gridEditRowModel.GridEditModes.Cell,
|
|
35
|
+
filterDebounceMs: 150,
|
|
36
|
+
filterMode: 'client',
|
|
37
|
+
hideFooter: false,
|
|
38
|
+
hideFooterPagination: false,
|
|
39
|
+
hideFooterRowCount: false,
|
|
40
|
+
hideFooterSelectedRowCount: false,
|
|
41
|
+
ignoreDiacritics: false,
|
|
42
|
+
ignoreValueFormatterDuringExport: false,
|
|
43
|
+
// TODO v8: Update to 'select'
|
|
44
|
+
indeterminateCheckboxAction: 'deselect',
|
|
45
|
+
keepColumnPositionIfDraggedOutside: false,
|
|
46
|
+
keepNonExistentRowsSelected: false,
|
|
47
|
+
loading: false,
|
|
48
|
+
logger: console,
|
|
49
|
+
logLevel: process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
|
50
|
+
pageSizeOptions: [25, 50, 100],
|
|
51
|
+
pagination: false,
|
|
52
|
+
paginationMode: 'client',
|
|
53
|
+
resizeThrottleMs: 60,
|
|
54
|
+
rowBufferPx: 150,
|
|
55
|
+
rowHeight: 52,
|
|
56
|
+
rowPositionsDebounceMs: 166,
|
|
57
|
+
rows: [],
|
|
58
|
+
rowSelection: true,
|
|
59
|
+
rowSpacingType: 'margin',
|
|
60
|
+
showCellVerticalBorder: false,
|
|
61
|
+
showColumnVerticalBorder: false,
|
|
62
|
+
sortingMode: 'client',
|
|
63
|
+
sortingOrder: ['asc', 'desc', null],
|
|
64
|
+
throttleRowsMs: 0,
|
|
65
|
+
unstable_rowSpanning: false
|
|
66
|
+
};
|
|
@@ -9,6 +9,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _utils = require("../../utils");
|
|
10
10
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
11
11
|
var _csvSerializer = require("../export/serializers/csvSerializer");
|
|
12
|
+
var _keyboardUtils = require("../../../utils/keyboardUtils");
|
|
12
13
|
function writeToClipboardPolyfill(data) {
|
|
13
14
|
const span = document.createElement('span');
|
|
14
15
|
span.style.whiteSpace = 'pre';
|
|
@@ -60,7 +61,7 @@ const useGridClipboard = (apiRef, props) => {
|
|
|
60
61
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
|
|
61
62
|
const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
62
63
|
const handleCopy = React.useCallback(event => {
|
|
63
|
-
if (!(
|
|
64
|
+
if (!(0, _keyboardUtils.isCopyShortcut)(event)) {
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -64,7 +64,9 @@ const useGridColumnHeaders = props => {
|
|
|
64
64
|
const offsetLeft = (0, _useGridVirtualScroller.computeOffsetLeft)(columnPositions, renderContext, pinnedColumns.left.length);
|
|
65
65
|
const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
|
|
66
66
|
React.useEffect(() => {
|
|
67
|
-
apiRef.current.columnHeadersContainerRef.current
|
|
67
|
+
if (apiRef.current.columnHeadersContainerRef.current) {
|
|
68
|
+
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
69
|
+
}
|
|
68
70
|
}, [apiRef]);
|
|
69
71
|
const handleColumnResizeStart = React.useCallback(params => setResizeCol(params.field), []);
|
|
70
72
|
const handleColumnResizeStop = React.useCallback(() => setResizeCol(''), []);
|
|
@@ -327,6 +327,9 @@ function getFirstNonSpannedColumnToRender({
|
|
|
327
327
|
return firstNonSpannedColumnToRender;
|
|
328
328
|
}
|
|
329
329
|
function getTotalHeaderHeight(apiRef, props) {
|
|
330
|
+
if (props.unstable_listView) {
|
|
331
|
+
return 0;
|
|
332
|
+
}
|
|
330
333
|
const densityFactor = (0, _densitySelector.gridDensityFactorSelector)(apiRef);
|
|
331
334
|
const maxDepth = (0, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector)(apiRef);
|
|
332
335
|
const isHeaderFilteringEnabled = (0, _gridHeaderFilteringSelectors.gridHeaderFilteringEnabledSelector)(apiRef);
|
|
@@ -23,6 +23,7 @@ var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
|
23
23
|
var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
|
|
24
24
|
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
25
25
|
var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
26
|
+
var _dataGridPropsDefaultValues = require("../../../constants/dataGridPropsDefaultValues");
|
|
26
27
|
const EMPTY_SIZE = {
|
|
27
28
|
width: 0,
|
|
28
29
|
height: 0
|
|
@@ -64,7 +65,8 @@ function useGridDimensions(apiRef, props) {
|
|
|
64
65
|
const rowsMeta = (0, _utils2.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
|
|
65
66
|
const pinnedColumns = (0, _utils2.useGridSelector)(apiRef, _columns.gridVisiblePinnedColumnDefinitionsSelector);
|
|
66
67
|
const densityFactor = (0, _utils2.useGridSelector)(apiRef, _density.gridDensityFactorSelector);
|
|
67
|
-
const
|
|
68
|
+
const validRowHeight = React.useMemo(() => (0, _gridRowsUtils.getValidRowHeight)(props.rowHeight, _dataGridPropsDefaultValues.DATA_GRID_PROPS_DEFAULT_VALUES.rowHeight, _gridRowsUtils.rowHeightWarning), [props.rowHeight]);
|
|
69
|
+
const rowHeight = Math.floor(validRowHeight * densityFactor);
|
|
68
70
|
const headerHeight = Math.floor(props.columnHeaderHeight * densityFactor);
|
|
69
71
|
const groupHeaderHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
70
72
|
const headerFilterHeight = Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
@@ -23,6 +23,7 @@ var _gridHeaderFilteringSelectors = require("../headerFiltering/gridHeaderFilter
|
|
|
23
23
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
24
24
|
var _domUtils = require("../../../utils/domUtils");
|
|
25
25
|
var _utils = require("./utils");
|
|
26
|
+
var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
26
27
|
/**
|
|
27
28
|
* @requires useGridSorting (method) - can be after
|
|
28
29
|
* @requires useGridFilter (state) - can be after
|
|
@@ -36,6 +37,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
36
37
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridKeyboardNavigation');
|
|
37
38
|
const initialCurrentPageRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props).rows;
|
|
38
39
|
const isRtl = (0, _RtlProvider.useRtl)();
|
|
40
|
+
const listView = props.unstable_listView;
|
|
39
41
|
const currentPageRows = React.useMemo(() => (0, _utils.enrichPageRowsWithPinnedRows)(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
|
|
40
42
|
const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
|
|
41
43
|
|
|
@@ -56,7 +58,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
56
58
|
colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
|
-
const field = (0, _gridColumnsSelector.gridVisibleColumnFieldsSelector)(apiRef)[colIndex];
|
|
61
|
+
const field = listView ? (0, _gridListViewSelectors.gridListColumnSelector)(apiRef.current.state).field : (0, _gridColumnsSelector.gridVisibleColumnFieldsSelector)(apiRef)[colIndex];
|
|
60
62
|
const nonRowSpannedRowId = (0, _utils.findNonRowSpannedCell)(apiRef, rowId, field, rowSpanScanDirection);
|
|
61
63
|
// `scrollToIndexes` requires a rowIndex relative to all visible rows.
|
|
62
64
|
// Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
|
|
@@ -67,7 +69,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
67
69
|
rowIndex: rowIndexRelativeToAllRows
|
|
68
70
|
});
|
|
69
71
|
apiRef.current.setCellFocus(nonRowSpannedRowId, field);
|
|
70
|
-
}, [apiRef, logger]);
|
|
72
|
+
}, [apiRef, logger, listView]);
|
|
71
73
|
const goToHeader = React.useCallback((colIndex, event) => {
|
|
72
74
|
logger.debug(`Navigating to header col ${colIndex}`);
|
|
73
75
|
apiRef.current.scrollToIndexes({
|
|
@@ -390,12 +392,14 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
390
392
|
return;
|
|
391
393
|
}
|
|
392
394
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
393
|
-
const
|
|
395
|
+
const getColumnIndexFn = listView ? () => 0 : apiRef.current.getColumnIndex;
|
|
396
|
+
const colIndexBefore = params.field ? getColumnIndexFn(params.field) : 0;
|
|
394
397
|
const rowIndexBefore = currentPageRows.findIndex(row => row.id === params.id);
|
|
395
398
|
const firstRowIndexInPage = 0;
|
|
396
399
|
const lastRowIndexInPage = currentPageRows.length - 1;
|
|
397
400
|
const firstColIndex = 0;
|
|
398
|
-
const
|
|
401
|
+
const visibleColumns = listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef.current.state)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef);
|
|
402
|
+
const lastColIndex = visibleColumns.length - 1;
|
|
399
403
|
let shouldPreventDefault = true;
|
|
400
404
|
switch (event.key) {
|
|
401
405
|
case 'ArrowDown':
|
|
@@ -514,7 +518,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
514
518
|
if (shouldPreventDefault) {
|
|
515
519
|
event.preventDefault();
|
|
516
520
|
}
|
|
517
|
-
}, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader]);
|
|
521
|
+
}, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
|
|
518
522
|
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
519
523
|
event
|
|
520
524
|
}) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.gridListColumnSelector = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Get a list column definition
|
|
9
|
+
*/
|
|
10
|
+
const gridListColumnSelector = state => state.listViewColumn;
|
|
11
|
+
exports.gridListColumnSelector = gridListColumnSelector;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.listViewStateInitializer = void 0;
|
|
9
|
+
exports.useGridListView = useGridListView;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _dimensions = require("../dimensions");
|
|
13
|
+
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
14
|
+
const listViewStateInitializer = (state, props, apiRef) => (0, _extends2.default)({}, state, {
|
|
15
|
+
listViewColumn: (0, _extends2.default)({}, props.unstable_listColumn, {
|
|
16
|
+
computedWidth: getListColumnWidth(apiRef)
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
exports.listViewStateInitializer = listViewStateInitializer;
|
|
20
|
+
function useGridListView(apiRef, props) {
|
|
21
|
+
/*
|
|
22
|
+
* EVENTS
|
|
23
|
+
*/
|
|
24
|
+
const updateListColumnWidth = () => {
|
|
25
|
+
apiRef.current.setState(state => {
|
|
26
|
+
if (!state.listViewColumn) {
|
|
27
|
+
return state;
|
|
28
|
+
}
|
|
29
|
+
return (0, _extends2.default)({}, state, {
|
|
30
|
+
listViewColumn: (0, _extends2.default)({}, state.listViewColumn, {
|
|
31
|
+
computedWidth: getListColumnWidth(apiRef)
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const prevInnerWidth = React.useRef(null);
|
|
37
|
+
const handleGridSizeChange = viewportInnerSize => {
|
|
38
|
+
if (prevInnerWidth.current !== viewportInnerSize.width) {
|
|
39
|
+
prevInnerWidth.current = viewportInnerSize.width;
|
|
40
|
+
updateListColumnWidth();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'viewportInnerSizeChange', handleGridSizeChange);
|
|
44
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnVisibilityModelChange', updateListColumnWidth);
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
* EFFECTS
|
|
48
|
+
*/
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
const listColumn = props.unstable_listColumn;
|
|
51
|
+
if (listColumn) {
|
|
52
|
+
apiRef.current.setState(state => {
|
|
53
|
+
return (0, _extends2.default)({}, state, {
|
|
54
|
+
listViewColumn: (0, _extends2.default)({}, listColumn, {
|
|
55
|
+
computedWidth: getListColumnWidth(apiRef)
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, [apiRef, props.unstable_listColumn]);
|
|
61
|
+
}
|
|
62
|
+
function getListColumnWidth(apiRef) {
|
|
63
|
+
return (0, _dimensions.gridDimensionsSelector)(apiRef.current.state).viewportInnerSize.width;
|
|
64
|
+
}
|
|
@@ -255,7 +255,11 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
255
255
|
/*
|
|
256
256
|
* EVENTS
|
|
257
257
|
*/
|
|
258
|
+
const isFirstRender = React.useRef(true);
|
|
258
259
|
const removeOutdatedSelection = React.useCallback((sortModelUpdated = false) => {
|
|
260
|
+
if (isFirstRender.current) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
259
263
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
260
264
|
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
261
265
|
|
|
@@ -263,7 +267,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
263
267
|
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
264
268
|
let hasChanged = false;
|
|
265
269
|
currentSelection.forEach(id => {
|
|
266
|
-
if (filteredRowsLookup[id]
|
|
270
|
+
if (filteredRowsLookup[id] !== true) {
|
|
267
271
|
if (props.keepNonExistentRowsSelected) {
|
|
268
272
|
return;
|
|
269
273
|
}
|
|
@@ -417,7 +421,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
417
421
|
handleSingleRowSelection(params.id, event);
|
|
418
422
|
return;
|
|
419
423
|
}
|
|
420
|
-
if (event.
|
|
424
|
+
if (String.fromCharCode(event.keyCode) === 'A' && (event.ctrlKey || event.metaKey)) {
|
|
421
425
|
event.preventDefault();
|
|
422
426
|
selectRows(apiRef.current.getAllRowIds(), true);
|
|
423
427
|
}
|
|
@@ -471,5 +475,10 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
471
475
|
React.useEffect(() => {
|
|
472
476
|
runIfRowSelectionIsEnabled(removeOutdatedSelection);
|
|
473
477
|
}, [removeOutdatedSelection, runIfRowSelectionIsEnabled]);
|
|
478
|
+
React.useEffect(() => {
|
|
479
|
+
if (isFirstRender.current) {
|
|
480
|
+
isFirstRender.current = false;
|
|
481
|
+
}
|
|
482
|
+
}, []);
|
|
474
483
|
};
|
|
475
484
|
exports.useGridRowSelection = useGridRowSelection;
|
|
@@ -65,7 +65,7 @@ function getCheckboxPropsSelector(groupId, autoSelectParents) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
return {
|
|
68
|
-
isIndeterminate: selectedDescendantsCount > 0 && selectedDescendantsCount < selectableDescendantsCount ||
|
|
68
|
+
isIndeterminate: selectedDescendantsCount > 0 && (selectedDescendantsCount < selectableDescendantsCount || rowSelectionLookup[groupId] === undefined),
|
|
69
69
|
isChecked: autoSelectParents ? selectedDescendantsCount > 0 : rowSelectionLookup[groupId] === groupId
|
|
70
70
|
};
|
|
71
71
|
});
|
|
@@ -10,7 +10,7 @@ exports.checkGridRowIdIsValid = checkGridRowIdIsValid;
|
|
|
10
10
|
exports.computeRowsUpdates = computeRowsUpdates;
|
|
11
11
|
exports.createRowsInternalCache = void 0;
|
|
12
12
|
exports.getMinimalContentHeight = getMinimalContentHeight;
|
|
13
|
-
exports.updateCacheWithNewRows = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowIdFromRowModel = void 0;
|
|
13
|
+
exports.updateCacheWithNewRows = exports.rowHeightWarning = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getValidRowHeight = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowIdFromRowModel = exports.getRowHeightWarning = void 0;
|
|
14
14
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
15
|
var _gridRowsSelector = require("./gridRowsSelector");
|
|
16
16
|
var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
|
|
@@ -328,4 +328,18 @@ function computeRowsUpdates(apiRef, updates, getRowId) {
|
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
return nonPinnedRowsUpdates;
|
|
331
|
-
}
|
|
331
|
+
}
|
|
332
|
+
let warnedOnceInvalidRowHeight = false;
|
|
333
|
+
const getValidRowHeight = (rowHeightProp, defaultRowHeight, warningMessage) => {
|
|
334
|
+
if (typeof rowHeightProp === 'number' && rowHeightProp > 0) {
|
|
335
|
+
return rowHeightProp;
|
|
336
|
+
}
|
|
337
|
+
if (process.env.NODE_ENV !== 'production' && !warnedOnceInvalidRowHeight && typeof rowHeightProp !== 'undefined' && rowHeightProp !== null) {
|
|
338
|
+
console.warn(warningMessage);
|
|
339
|
+
warnedOnceInvalidRowHeight = true;
|
|
340
|
+
}
|
|
341
|
+
return defaultRowHeight;
|
|
342
|
+
};
|
|
343
|
+
exports.getValidRowHeight = getValidRowHeight;
|
|
344
|
+
const rowHeightWarning = exports.rowHeightWarning = [`MUI X: The \`rowHeight\` prop should be a number greater than 0.`, `The default value will be used instead.`].join('\n');
|
|
345
|
+
const getRowHeightWarning = exports.getRowHeightWarning = [`MUI X: The \`getRowHeight\` prop should return a number greater than 0 or 'auto'.`, `The default value will be used instead.`].join('\n');
|
|
@@ -10,6 +10,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _domUtils = require("../../../utils/domUtils");
|
|
11
11
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
12
12
|
var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
|
|
13
|
+
var _gridListViewSelectors = require("../listView/gridListViewSelectors");
|
|
13
14
|
class MissingRowIdError extends Error {}
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -21,7 +22,7 @@ class MissingRowIdError extends Error {}
|
|
|
21
22
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
22
23
|
*/
|
|
23
24
|
exports.MissingRowIdError = MissingRowIdError;
|
|
24
|
-
function useGridParamsApi(apiRef) {
|
|
25
|
+
function useGridParamsApi(apiRef, props) {
|
|
25
26
|
const getColumnHeaderParams = React.useCallback(field => ({
|
|
26
27
|
field,
|
|
27
28
|
colDef: apiRef.current.getColumn(field)
|
|
@@ -39,7 +40,7 @@ function useGridParamsApi(apiRef) {
|
|
|
39
40
|
return params;
|
|
40
41
|
}, [apiRef]);
|
|
41
42
|
const getCellParams = React.useCallback((id, field) => {
|
|
42
|
-
const colDef = apiRef.current.getColumn(field);
|
|
43
|
+
const colDef = props.unstable_listView ? (0, _gridListViewSelectors.gridListColumnSelector)(apiRef.current.state) : apiRef.current.getColumn(field);
|
|
43
44
|
const row = apiRef.current.getRow(id);
|
|
44
45
|
const rowNode = apiRef.current.getRowNode(id);
|
|
45
46
|
if (!row || !rowNode) {
|
|
@@ -68,7 +69,7 @@ function useGridParamsApi(apiRef) {
|
|
|
68
69
|
}
|
|
69
70
|
params.isEditable = colDef && apiRef.current.isCellEditable(params);
|
|
70
71
|
return params;
|
|
71
|
-
}, [apiRef]);
|
|
72
|
+
}, [apiRef, props.unstable_listView]);
|
|
72
73
|
const getCellValue = React.useCallback((id, field) => {
|
|
73
74
|
const colDef = apiRef.current.getColumn(field);
|
|
74
75
|
const row = apiRef.current.getRow(id);
|