@mui/x-data-grid 7.22.3 → 7.23.1
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 +160 -0
- package/DataGrid/DataGrid.js +9 -1
- package/README.md +3 -3
- package/components/cell/GridCell.js +10 -10
- package/components/toolbar/GridToolbarColumnsButton.js +3 -4
- package/components/toolbar/GridToolbarDensitySelector.js +3 -4
- package/components/toolbar/GridToolbarExportContainer.js +3 -4
- package/components/toolbar/GridToolbarFilterButton.d.ts +2 -0
- package/components/toolbar/GridToolbarFilterButton.js +7 -6
- package/components/toolbar/GridToolbarQuickFilter.js +1 -0
- package/constants/dataGridPropsDefaultValues.js +2 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +1 -0
- package/hooks/features/listView/gridListViewSelectors.d.ts +3 -1
- package/hooks/features/listView/gridListViewSelectors.js +3 -1
- package/hooks/features/listView/index.d.ts +1 -0
- package/hooks/features/listView/index.js +1 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +0 -9
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +55 -15
- package/index.js +1 -1
- package/joy/joySlots.js +7 -2
- package/locales/deDE.js +1 -2
- package/locales/esES.js +1 -2
- package/locales/ptBR.js +1 -2
- package/locales/ptPT.js +1 -2
- package/locales/zhCN.js +1 -2
- package/models/api/gridCoreApi.d.ts +1 -1
- package/models/colDef/gridColDef.d.ts +24 -24
- package/models/gridDataSource.d.ts +12 -12
- package/models/props/DataGridProps.d.ts +8 -0
- package/modern/DataGrid/DataGrid.js +9 -1
- package/modern/components/cell/GridCell.js +10 -10
- package/modern/components/toolbar/GridToolbarColumnsButton.js +3 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.js +3 -4
- package/modern/components/toolbar/GridToolbarExportContainer.js +3 -4
- package/modern/components/toolbar/GridToolbarFilterButton.js +7 -6
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -0
- package/modern/constants/dataGridPropsDefaultValues.js +2 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/listView/gridListViewSelectors.js +3 -1
- package/modern/hooks/features/listView/index.js +1 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +0 -9
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +55 -15
- package/modern/index.js +1 -1
- package/modern/joy/joySlots.js +7 -2
- package/modern/locales/deDE.js +1 -2
- package/modern/locales/esES.js +1 -2
- package/modern/locales/ptBR.js +1 -2
- package/modern/locales/ptPT.js +1 -2
- package/modern/locales/zhCN.js +1 -2
- package/node/DataGrid/DataGrid.js +9 -1
- package/node/components/cell/GridCell.js +10 -10
- package/node/components/toolbar/GridToolbarColumnsButton.js +3 -4
- package/node/components/toolbar/GridToolbarDensitySelector.js +3 -4
- package/node/components/toolbar/GridToolbarExportContainer.js +3 -4
- package/node/components/toolbar/GridToolbarFilterButton.js +7 -6
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -0
- package/node/constants/dataGridPropsDefaultValues.js +2 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/listView/gridListViewSelectors.js +3 -1
- package/node/hooks/features/listView/index.js +16 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +0 -9
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +55 -15
- package/node/index.js +1 -1
- package/node/joy/joySlots.js +7 -2
- package/node/locales/deDE.js +1 -2
- package/node/locales/esES.js +1 -2
- package/node/locales/ptBR.js +1 -2
- package/node/locales/ptPT.js +1 -2
- package/node/locales/zhCN.js +1 -2
- package/package.json +4 -4
|
@@ -4,8 +4,8 @@ import * as ReactDOM from 'react-dom';
|
|
|
4
4
|
import { unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
5
5
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
6
6
|
import useTimeout from '@mui/utils/useTimeout';
|
|
7
|
-
import { useResizeObserver } from '@mui/x-internals/useResizeObserver';
|
|
8
7
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
|
+
import reactMajor from '@mui/x-internals/reactMajor';
|
|
9
9
|
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
10
10
|
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
11
11
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
@@ -48,7 +48,7 @@ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, h
|
|
|
48
48
|
let isJSDOM = false;
|
|
49
49
|
try {
|
|
50
50
|
if (typeof window !== 'undefined') {
|
|
51
|
-
isJSDOM = /jsdom/.test(window.navigator.userAgent);
|
|
51
|
+
isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
52
52
|
}
|
|
53
53
|
} catch (_) {
|
|
54
54
|
/* ignore */
|
|
@@ -86,7 +86,44 @@ export const useGridVirtualScroller = () => {
|
|
|
86
86
|
const contentHeight = dimensions.contentSize.height;
|
|
87
87
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
88
88
|
const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
|
|
89
|
-
|
|
89
|
+
const mainRefCallback = React.useCallback(node => {
|
|
90
|
+
mainRef.current = node;
|
|
91
|
+
if (!node) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const initialRect = node.getBoundingClientRect();
|
|
95
|
+
let lastSize = {
|
|
96
|
+
width: initialRect.width,
|
|
97
|
+
height: initialRect.height
|
|
98
|
+
};
|
|
99
|
+
apiRef.current.publishEvent('resize', lastSize);
|
|
100
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const observer = new ResizeObserver(entries => {
|
|
104
|
+
const entry = entries[0];
|
|
105
|
+
if (!entry) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const newSize = {
|
|
109
|
+
width: entry.contentRect.width,
|
|
110
|
+
height: entry.contentRect.height
|
|
111
|
+
};
|
|
112
|
+
if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
apiRef.current.publishEvent('resize', newSize);
|
|
116
|
+
lastSize = newSize;
|
|
117
|
+
});
|
|
118
|
+
observer.observe(node);
|
|
119
|
+
if (reactMajor >= 19) {
|
|
120
|
+
return () => {
|
|
121
|
+
mainRef.current = null;
|
|
122
|
+
observer.disconnect();
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
}, [apiRef, mainRef]);
|
|
90
127
|
|
|
91
128
|
/*
|
|
92
129
|
* Scroll context logic
|
|
@@ -137,9 +174,13 @@ export const useGridVirtualScroller = () => {
|
|
|
137
174
|
previousContextScrollPosition.current = scrollPosition.current;
|
|
138
175
|
}, [apiRef, dimensions.isReady]);
|
|
139
176
|
const triggerUpdateRenderContext = useEventCallback(() => {
|
|
177
|
+
const scroller = scrollerRef.current;
|
|
178
|
+
if (!scroller) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
140
181
|
const newScroll = {
|
|
141
|
-
top:
|
|
142
|
-
left:
|
|
182
|
+
top: scroller.scrollTop,
|
|
183
|
+
left: scroller.scrollLeft
|
|
143
184
|
};
|
|
144
185
|
const dx = newScroll.left - scrollPosition.current.left;
|
|
145
186
|
const dy = newScroll.top - scrollPosition.current.top;
|
|
@@ -389,10 +430,6 @@ export const useGridVirtualScroller = () => {
|
|
|
389
430
|
React.useEffect(() => {
|
|
390
431
|
apiRef.current.publishEvent('virtualScrollerContentSizeChange');
|
|
391
432
|
}, [apiRef, contentSize]);
|
|
392
|
-
useEnhancedEffect(() => {
|
|
393
|
-
// FIXME: Is this really necessary?
|
|
394
|
-
apiRef.current.resize();
|
|
395
|
-
}, [apiRef, rowsMeta.currentPageTotalHeight]);
|
|
396
433
|
useEnhancedEffect(() => {
|
|
397
434
|
// TODO a scroll reset should not be necessary
|
|
398
435
|
if (enabledForColumns) {
|
|
@@ -428,7 +465,7 @@ export const useGridVirtualScroller = () => {
|
|
|
428
465
|
setPanels,
|
|
429
466
|
getRows,
|
|
430
467
|
getContainerProps: () => ({
|
|
431
|
-
ref:
|
|
468
|
+
ref: mainRefCallback
|
|
432
469
|
}),
|
|
433
470
|
getScrollerProps: () => ({
|
|
434
471
|
ref: scrollerRef,
|
|
@@ -485,7 +522,8 @@ function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
|
|
|
485
522
|
pinnedColumns: gridVisiblePinnedColumnDefinitionsSelector(apiRef),
|
|
486
523
|
visibleColumns,
|
|
487
524
|
hiddenCellsOriginMap,
|
|
488
|
-
listView: rootProps.unstable_listView ?? false
|
|
525
|
+
listView: rootProps.unstable_listView ?? false,
|
|
526
|
+
virtualizeColumnsWithAutoRowHeight: rootProps.virtualizeColumnsWithAutoRowHeight
|
|
489
527
|
};
|
|
490
528
|
}
|
|
491
529
|
function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
@@ -533,11 +571,13 @@ function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
|
533
571
|
positions: inputs.rowsMeta.positions,
|
|
534
572
|
lastSize: inputs.lastRowHeight
|
|
535
573
|
});
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
574
|
+
if (!inputs.virtualizeColumnsWithAutoRowHeight) {
|
|
575
|
+
for (let i = firstRowToRender; i < lastRowToRender && !hasRowWithAutoHeight; i += 1) {
|
|
576
|
+
const row = inputs.rows[i];
|
|
577
|
+
hasRowWithAutoHeight = inputs.apiRef.current.rowHasAutoHeight(row.id);
|
|
578
|
+
}
|
|
539
579
|
}
|
|
540
|
-
if (!hasRowWithAutoHeight) {
|
|
580
|
+
if (!hasRowWithAutoHeight || inputs.virtualizeColumnsWithAutoRowHeight) {
|
|
541
581
|
firstColumnIndex = binarySearch(realLeft, inputs.columnPositions, {
|
|
542
582
|
atStart: true,
|
|
543
583
|
lastPosition: inputs.columnsTotalWidth
|
package/modern/index.js
CHANGED
package/modern/joy/joySlots.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["slotProps", "variant", "color", "sx"],
|
|
3
|
+
const _excluded = ["slotProps", "variant", "color", "sx", "anchorOrigin"],
|
|
4
4
|
_excluded2 = ["touchRippleRef", "inputProps", "onChange", "color", "size", "checked", "sx", "value", "inputRef"],
|
|
5
5
|
_excluded3 = ["onChange", "label", "placeholder", "value", "inputRef", "type", "size", "variant"],
|
|
6
6
|
_excluded4 = ["startIcon", "color", "endIcon", "size", "sx", "variant"],
|
|
@@ -64,10 +64,15 @@ function convertVariant(variant, defaultVariant = 'plain') {
|
|
|
64
64
|
const Badge = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
65
65
|
let {
|
|
66
66
|
color,
|
|
67
|
-
sx
|
|
67
|
+
sx,
|
|
68
|
+
anchorOrigin
|
|
68
69
|
} = _ref,
|
|
69
70
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
70
71
|
return /*#__PURE__*/_jsx(JoyBadge, _extends({}, props, {
|
|
72
|
+
anchorOrigin: anchorOrigin?.horizontal && anchorOrigin?.vertical ? anchorOrigin : {
|
|
73
|
+
vertical: 'top',
|
|
74
|
+
horizontal: 'right'
|
|
75
|
+
},
|
|
71
76
|
color: convertColor(color),
|
|
72
77
|
variant: "plain",
|
|
73
78
|
sx: sx,
|
package/modern/locales/deDE.js
CHANGED
|
@@ -34,8 +34,7 @@ const deDEGrid = {
|
|
|
34
34
|
columnsManagementNoColumns: 'Keine Spalten',
|
|
35
35
|
columnsManagementShowHideAllText: 'Alle anzeigen/verbergen',
|
|
36
36
|
columnsManagementReset: 'Zurücksetzen',
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
columnsManagementDeleteIconLabel: 'Löschen',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: 'Filter hinzufügen',
|
|
41
40
|
filterPanelRemoveAll: 'Alle entfernen',
|
package/modern/locales/esES.js
CHANGED
|
@@ -34,8 +34,7 @@ const esESGrid = {
|
|
|
34
34
|
columnsManagementNoColumns: 'Sin columnas',
|
|
35
35
|
columnsManagementShowHideAllText: 'Mostrar/Ocultar todas',
|
|
36
36
|
columnsManagementReset: 'Restablecer',
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
columnsManagementDeleteIconLabel: 'Limpiar',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: 'Agregar filtro',
|
|
41
40
|
filterPanelRemoveAll: 'Remover todos',
|
package/modern/locales/ptBR.js
CHANGED
|
@@ -34,8 +34,7 @@ const ptBRGrid = {
|
|
|
34
34
|
columnsManagementNoColumns: 'Nenhuma coluna',
|
|
35
35
|
columnsManagementShowHideAllText: 'Mostrar/Ocultar Todas',
|
|
36
36
|
columnsManagementReset: 'Redefinir',
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
columnsManagementDeleteIconLabel: 'Limpar',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: 'Adicionar filtro',
|
|
41
40
|
filterPanelRemoveAll: 'Remover todos',
|
package/modern/locales/ptPT.js
CHANGED
|
@@ -34,8 +34,7 @@ const ptPTGrid = {
|
|
|
34
34
|
columnsManagementNoColumns: 'Sem colunas',
|
|
35
35
|
columnsManagementShowHideAllText: 'Mostrar/Ocultar Todas',
|
|
36
36
|
columnsManagementReset: 'Repor',
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
columnsManagementDeleteIconLabel: 'Limpar',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: 'Adicionar filtro',
|
|
41
40
|
filterPanelRemoveAll: 'Excluir todos',
|
package/modern/locales/zhCN.js
CHANGED
|
@@ -34,8 +34,7 @@ const zhCNGrid = {
|
|
|
34
34
|
columnsManagementNoColumns: '没有列',
|
|
35
35
|
columnsManagementShowHideAllText: '显示/隐藏所有',
|
|
36
36
|
columnsManagementReset: '重置',
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
columnsManagementDeleteIconLabel: '清除',
|
|
39
38
|
// Filter panel text
|
|
40
39
|
filterPanelAddFilter: '添加筛选器',
|
|
41
40
|
filterPanelRemoveAll: '清除全部',
|
|
@@ -773,5 +773,13 @@ DataGridRaw.propTypes = {
|
|
|
773
773
|
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
|
|
774
774
|
* @default false
|
|
775
775
|
*/
|
|
776
|
-
unstable_rowSpanning: _propTypes.default.bool
|
|
776
|
+
unstable_rowSpanning: _propTypes.default.bool,
|
|
777
|
+
/**
|
|
778
|
+
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
|
|
779
|
+
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.
|
|
780
|
+
* For datasets with a large number of columns, this can cause performance issues.
|
|
781
|
+
* The downside of enabling this prop is that the row height will be estimated based the cells that are currently rendered, which can cause row height change when scrolling horizontally.
|
|
782
|
+
* @default false
|
|
783
|
+
*/
|
|
784
|
+
virtualizeColumnsWithAutoRowHeight: _propTypes.default.bool
|
|
777
785
|
};
|
|
@@ -21,7 +21,6 @@ var _useGridSelector = require("../../hooks/utils/useGridSelector");
|
|
|
21
21
|
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
|
|
22
22
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
23
23
|
var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
|
|
24
|
-
var _useGridParamsApi = require("../../hooks/features/rows/useGridParamsApi");
|
|
25
24
|
var _cellBorderUtils = require("../../utils/cellBorderUtils");
|
|
26
25
|
var _gridColumnsInterfaces = require("../../hooks/features/columns/gridColumnsInterfaces");
|
|
27
26
|
var _gridRowSpanningSelectors = require("../../hooks/features/rows/gridRowSpanningSelectors");
|
|
@@ -122,16 +121,13 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
122
121
|
// This is required because `.getCellParams` tries to get the `state.rows.tree` entry
|
|
123
122
|
// associated with `rowId`/`fieldId`, but this selector runs after the state has been
|
|
124
123
|
// updated, while `rowId`/`fieldId` reference an entry in the old state.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return result;
|
|
129
|
-
} catch (error) {
|
|
130
|
-
if (error instanceof _useGridParamsApi.MissingRowIdError) {
|
|
131
|
-
return EMPTY_CELL_PARAMS;
|
|
132
|
-
}
|
|
133
|
-
throw error;
|
|
124
|
+
const row = apiRef.current.getRow(rowId);
|
|
125
|
+
if (!row) {
|
|
126
|
+
return EMPTY_CELL_PARAMS;
|
|
134
127
|
}
|
|
128
|
+
const result = apiRef.current.getCellParams(rowId, field);
|
|
129
|
+
result.api = apiRef.current;
|
|
130
|
+
return result;
|
|
135
131
|
}, _useGridSelector.objectShallowCompare);
|
|
136
132
|
const isSelected = (0, _useGridSelector.useGridSelector)(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
|
|
137
133
|
id: rowId,
|
|
@@ -219,6 +215,7 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
219
215
|
padding: 0,
|
|
220
216
|
opacity: 0,
|
|
221
217
|
width: 0,
|
|
218
|
+
height: 0,
|
|
222
219
|
border: 0
|
|
223
220
|
};
|
|
224
221
|
}
|
|
@@ -237,6 +234,9 @@ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
|
|
|
237
234
|
if (rowSpan > 1) {
|
|
238
235
|
cellStyle.height = `calc(var(--height) * ${rowSpan})`;
|
|
239
236
|
cellStyle.zIndex = 5;
|
|
237
|
+
if (isLeftPinned || isRightPinned) {
|
|
238
|
+
cellStyle.zIndex = 6;
|
|
239
|
+
}
|
|
240
240
|
}
|
|
241
241
|
return cellStyle;
|
|
242
242
|
}, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition, isRtl, rowSpan]);
|
|
@@ -44,7 +44,7 @@ const GridToolbarColumnsButton = exports.GridToolbarColumnsButton = /*#__PURE__*
|
|
|
44
44
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, (0, _extends2.default)({
|
|
45
45
|
title: apiRef.current.getLocaleText('toolbarColumnsLabel'),
|
|
46
46
|
enterDelay: 1000
|
|
47
|
-
},
|
|
47
|
+
}, rootProps.slotProps?.baseTooltip, tooltipProps, {
|
|
48
48
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
49
49
|
ref: ref,
|
|
50
50
|
id: columnButtonId,
|
|
@@ -53,10 +53,9 @@ const GridToolbarColumnsButton = exports.GridToolbarColumnsButton = /*#__PURE__*
|
|
|
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
|
-
}, buttonProps, {
|
|
56
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnSelectorIcon, {}),
|
|
58
57
|
onClick: showColumns
|
|
59
|
-
}, rootProps.slotProps?.baseButton, {
|
|
58
|
+
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
60
59
|
children: apiRef.current.getLocaleText('toolbarColumns')
|
|
61
60
|
}))
|
|
62
61
|
}));
|
|
@@ -93,7 +93,7 @@ const GridToolbarDensitySelector = exports.GridToolbarDensitySelector = /*#__PUR
|
|
|
93
93
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, (0, _extends2.default)({
|
|
94
94
|
title: apiRef.current.getLocaleText('toolbarDensityLabel'),
|
|
95
95
|
enterDelay: 1000
|
|
96
|
-
},
|
|
96
|
+
}, rootProps.slotProps?.baseTooltip, tooltipProps, {
|
|
97
97
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
98
98
|
ref: handleRef,
|
|
99
99
|
size: "small",
|
|
@@ -102,10 +102,9 @@ const GridToolbarDensitySelector = exports.GridToolbarDensitySelector = /*#__PUR
|
|
|
102
102
|
"aria-haspopup": "menu",
|
|
103
103
|
"aria-expanded": open,
|
|
104
104
|
"aria-controls": open ? densityMenuId : undefined,
|
|
105
|
-
id: densityButtonId
|
|
106
|
-
}, buttonProps, {
|
|
105
|
+
id: densityButtonId,
|
|
107
106
|
onClick: handleDensitySelectorOpen
|
|
108
|
-
}, rootProps.slotProps?.baseButton, {
|
|
107
|
+
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
109
108
|
children: apiRef.current.getLocaleText('toolbarDensity')
|
|
110
109
|
}))
|
|
111
110
|
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridMenu.GridMenu, {
|
|
@@ -51,7 +51,7 @@ const GridToolbarExportContainer = exports.GridToolbarExportContainer = /*#__PUR
|
|
|
51
51
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, (0, _extends2.default)({
|
|
52
52
|
title: apiRef.current.getLocaleText('toolbarExportLabel'),
|
|
53
53
|
enterDelay: 1000
|
|
54
|
-
},
|
|
54
|
+
}, rootProps.slotProps?.baseTooltip, tooltipProps, {
|
|
55
55
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
56
56
|
ref: handleRef,
|
|
57
57
|
size: "small",
|
|
@@ -60,10 +60,9 @@ const GridToolbarExportContainer = exports.GridToolbarExportContainer = /*#__PUR
|
|
|
60
60
|
"aria-label": apiRef.current.getLocaleText('toolbarExportLabel'),
|
|
61
61
|
"aria-haspopup": "menu",
|
|
62
62
|
"aria-controls": open ? exportMenuId : undefined,
|
|
63
|
-
id: exportButtonId
|
|
64
|
-
}, buttonProps, {
|
|
63
|
+
id: exportButtonId,
|
|
65
64
|
onClick: handleMenuOpen
|
|
66
|
-
}, rootProps.slotProps?.baseButton, {
|
|
65
|
+
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
67
66
|
children: apiRef.current.getLocaleText('toolbarExport')
|
|
68
67
|
}))
|
|
69
68
|
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridMenu.GridMenu, {
|
|
@@ -45,6 +45,7 @@ const GridToolbarFilterButton = exports.GridToolbarFilterButton = /*#__PURE__*/R
|
|
|
45
45
|
} = props;
|
|
46
46
|
const buttonProps = slotProps.button || {};
|
|
47
47
|
const tooltipProps = slotProps.tooltip || {};
|
|
48
|
+
const badgeProps = slotProps.badge || {};
|
|
48
49
|
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
49
50
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
50
51
|
const activeFilters = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridFilterActiveItemsSelector);
|
|
@@ -102,7 +103,7 @@ const GridToolbarFilterButton = exports.GridToolbarFilterButton = /*#__PURE__*/R
|
|
|
102
103
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, (0, _extends2.default)({
|
|
103
104
|
title: tooltipContentNode,
|
|
104
105
|
enterDelay: 1000
|
|
105
|
-
},
|
|
106
|
+
}, rootProps.slotProps?.baseTooltip, tooltipProps, {
|
|
106
107
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
|
|
107
108
|
ref: ref,
|
|
108
109
|
id: filterButtonId,
|
|
@@ -111,14 +112,14 @@ const GridToolbarFilterButton = exports.GridToolbarFilterButton = /*#__PURE__*/R
|
|
|
111
112
|
"aria-controls": isOpen ? filterPanelId : undefined,
|
|
112
113
|
"aria-expanded": isOpen,
|
|
113
114
|
"aria-haspopup": true,
|
|
114
|
-
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseBadge, {
|
|
115
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseBadge, (0, _extends2.default)({
|
|
115
116
|
badgeContent: activeFilters.length,
|
|
116
|
-
color: "primary"
|
|
117
|
+
color: "primary"
|
|
118
|
+
}, rootProps.slotProps?.baseBadge, badgeProps, {
|
|
117
119
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.openFilterButtonIcon, {})
|
|
118
|
-
})
|
|
119
|
-
}, buttonProps, {
|
|
120
|
+
})),
|
|
120
121
|
onClick: toggleFilter
|
|
121
|
-
}, rootProps.slotProps?.baseButton, {
|
|
122
|
+
}, rootProps.slotProps?.baseButton, buttonProps, {
|
|
122
123
|
children: apiRef.current.getLocaleText('toolbarFilters')
|
|
123
124
|
}))
|
|
124
125
|
}));
|
|
@@ -86,6 +86,7 @@ function GridToolbarQuickFilter(props) {
|
|
|
86
86
|
apiRef.current.setQuickFilterValues(newQuickFilterValues);
|
|
87
87
|
}, [apiRef, quickFilterParser]);
|
|
88
88
|
const debouncedUpdateSearchValue = React.useMemo(() => (0, _utils.unstable_debounce)(updateSearchValue, debounceMs), [updateSearchValue, debounceMs]);
|
|
89
|
+
React.useEffect(() => debouncedUpdateSearchValue.clear, [debouncedUpdateSearchValue]);
|
|
89
90
|
const handleSearchValueChange = React.useCallback(event => {
|
|
90
91
|
const newSearchValue = event.target.value;
|
|
91
92
|
setSearchValue(newSearchValue);
|
|
@@ -62,5 +62,6 @@ const DATA_GRID_PROPS_DEFAULT_VALUES = exports.DATA_GRID_PROPS_DEFAULT_VALUES =
|
|
|
62
62
|
sortingMode: 'client',
|
|
63
63
|
sortingOrder: ['asc', 'desc', null],
|
|
64
64
|
throttleRowsMs: 0,
|
|
65
|
-
unstable_rowSpanning: false
|
|
65
|
+
unstable_rowSpanning: false,
|
|
66
|
+
virtualizeColumnsWithAutoRowHeight: false
|
|
66
67
|
};
|
|
@@ -291,7 +291,7 @@ const useGridColumnHeaders = props => {
|
|
|
291
291
|
fields: headerInfo.fields,
|
|
292
292
|
colIndex: headerInfo.colIndex,
|
|
293
293
|
depth: depth,
|
|
294
|
-
isLastColumn:
|
|
294
|
+
isLastColumn: index === visibleColumnGroupHeader.length - 1,
|
|
295
295
|
maxDepth: headerGroupingMaxDepth,
|
|
296
296
|
height: dimensions.groupHeaderHeight,
|
|
297
297
|
hasFocus: hasFocus,
|
|
@@ -498,7 +498,8 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
498
498
|
const widthByField = extractColumnWidths(apiRef, options, columns);
|
|
499
499
|
const newColumns = columns.map(column => (0, _extends2.default)({}, column, {
|
|
500
500
|
width: widthByField[column.field],
|
|
501
|
-
computedWidth: widthByField[column.field]
|
|
501
|
+
computedWidth: widthByField[column.field],
|
|
502
|
+
flex: 0
|
|
502
503
|
}));
|
|
503
504
|
if (options.expand) {
|
|
504
505
|
const visibleColumns = state.orderedFields.map(field => state.lookup[field]).filter(c => state.columnVisibilityModel[c.field] !== false);
|
|
@@ -76,6 +76,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
76
76
|
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
77
77
|
const [savedSize, setSavedSize] = React.useState();
|
|
78
78
|
const debouncedSetSavedSize = React.useMemo(() => (0, _throttle.throttle)(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs]);
|
|
79
|
+
React.useEffect(() => debouncedSetSavedSize.clear, [debouncedSetSavedSize]);
|
|
79
80
|
const previousSize = React.useRef();
|
|
80
81
|
const getRootDimensions = () => apiRef.current.state.dimensions;
|
|
81
82
|
const setDimensions = (0, _utils.unstable_useEventCallback)(dimensions => {
|
|
@@ -248,7 +249,7 @@ function useGridDimensions(apiRef, props) {
|
|
|
248
249
|
rootDimensionsRef.current = size;
|
|
249
250
|
|
|
250
251
|
// jsdom has no layout capabilities
|
|
251
|
-
const isJSDOM = /jsdom/.test(window.navigator.userAgent);
|
|
252
|
+
const isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
252
253
|
if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
|
|
253
254
|
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'));
|
|
254
255
|
errorShown.current = true;
|
|
@@ -91,6 +91,17 @@ Object.keys(_focus).forEach(function (key) {
|
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
|
+
var _listView = require("./listView");
|
|
95
|
+
Object.keys(_listView).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _listView[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _listView[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
94
105
|
var _pagination = require("./pagination");
|
|
95
106
|
Object.keys(_pagination).forEach(function (key) {
|
|
96
107
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.gridListColumnSelector = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* Get
|
|
8
|
+
* Get the list column definition
|
|
9
|
+
* @category List View
|
|
10
|
+
* @ignore - Do not document
|
|
9
11
|
*/
|
|
10
12
|
const gridListColumnSelector = state => state.listViewColumn;
|
|
11
13
|
exports.gridListColumnSelector = gridListColumnSelector;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _gridListViewSelectors = require("./gridListViewSelectors");
|
|
7
|
+
Object.keys(_gridListViewSelectors).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _gridListViewSelectors[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _gridListViewSelectors[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -257,11 +257,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
257
257
|
/*
|
|
258
258
|
* EVENTS
|
|
259
259
|
*/
|
|
260
|
-
const isFirstRender = React.useRef(true);
|
|
261
260
|
const removeOutdatedSelection = React.useCallback((sortModelUpdated = false) => {
|
|
262
|
-
if (isFirstRender.current) {
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
261
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
266
262
|
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
267
263
|
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
@@ -489,10 +485,5 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
489
485
|
React.useEffect(() => {
|
|
490
486
|
runIfRowSelectionIsEnabled(removeOutdatedSelection);
|
|
491
487
|
}, [removeOutdatedSelection, runIfRowSelectionIsEnabled]);
|
|
492
|
-
React.useEffect(() => {
|
|
493
|
-
if (isFirstRender.current) {
|
|
494
|
-
isFirstRender.current = false;
|
|
495
|
-
}
|
|
496
|
-
}, []);
|
|
497
488
|
};
|
|
498
489
|
exports.useGridRowSelection = useGridRowSelection;
|
|
@@ -15,8 +15,8 @@ var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
|
|
15
15
|
var _utils = require("@mui/utils");
|
|
16
16
|
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
17
17
|
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
|
18
|
-
var _useResizeObserver = require("@mui/x-internals/useResizeObserver");
|
|
19
18
|
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
19
|
+
var _reactMajor = _interopRequireDefault(require("@mui/x-internals/reactMajor"));
|
|
20
20
|
var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
|
|
21
21
|
var _useGridRootProps = require("../../utils/useGridRootProps");
|
|
22
22
|
var _useGridSelector = require("../../utils/useGridSelector");
|
|
@@ -59,7 +59,7 @@ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, h
|
|
|
59
59
|
let isJSDOM = false;
|
|
60
60
|
try {
|
|
61
61
|
if (typeof window !== 'undefined') {
|
|
62
|
-
isJSDOM = /jsdom/.test(window.navigator.userAgent);
|
|
62
|
+
isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
|
|
63
63
|
}
|
|
64
64
|
} catch (_) {
|
|
65
65
|
/* ignore */
|
|
@@ -97,7 +97,44 @@ const useGridVirtualScroller = () => {
|
|
|
97
97
|
const contentHeight = dimensions.contentSize.height;
|
|
98
98
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
99
99
|
const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
|
|
100
|
-
|
|
100
|
+
const mainRefCallback = React.useCallback(node => {
|
|
101
|
+
mainRef.current = node;
|
|
102
|
+
if (!node) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const initialRect = node.getBoundingClientRect();
|
|
106
|
+
let lastSize = {
|
|
107
|
+
width: initialRect.width,
|
|
108
|
+
height: initialRect.height
|
|
109
|
+
};
|
|
110
|
+
apiRef.current.publishEvent('resize', lastSize);
|
|
111
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const observer = new ResizeObserver(entries => {
|
|
115
|
+
const entry = entries[0];
|
|
116
|
+
if (!entry) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const newSize = {
|
|
120
|
+
width: entry.contentRect.width,
|
|
121
|
+
height: entry.contentRect.height
|
|
122
|
+
};
|
|
123
|
+
if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
apiRef.current.publishEvent('resize', newSize);
|
|
127
|
+
lastSize = newSize;
|
|
128
|
+
});
|
|
129
|
+
observer.observe(node);
|
|
130
|
+
if (_reactMajor.default >= 19) {
|
|
131
|
+
return () => {
|
|
132
|
+
mainRef.current = null;
|
|
133
|
+
observer.disconnect();
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}, [apiRef, mainRef]);
|
|
101
138
|
|
|
102
139
|
/*
|
|
103
140
|
* Scroll context logic
|
|
@@ -148,9 +185,13 @@ const useGridVirtualScroller = () => {
|
|
|
148
185
|
previousContextScrollPosition.current = scrollPosition.current;
|
|
149
186
|
}, [apiRef, dimensions.isReady]);
|
|
150
187
|
const triggerUpdateRenderContext = (0, _utils.unstable_useEventCallback)(() => {
|
|
188
|
+
const scroller = scrollerRef.current;
|
|
189
|
+
if (!scroller) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
151
192
|
const newScroll = {
|
|
152
|
-
top:
|
|
153
|
-
left:
|
|
193
|
+
top: scroller.scrollTop,
|
|
194
|
+
left: scroller.scrollLeft
|
|
154
195
|
};
|
|
155
196
|
const dx = newScroll.left - scrollPosition.current.left;
|
|
156
197
|
const dy = newScroll.top - scrollPosition.current.top;
|
|
@@ -400,10 +441,6 @@ const useGridVirtualScroller = () => {
|
|
|
400
441
|
React.useEffect(() => {
|
|
401
442
|
apiRef.current.publishEvent('virtualScrollerContentSizeChange');
|
|
402
443
|
}, [apiRef, contentSize]);
|
|
403
|
-
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
404
|
-
// FIXME: Is this really necessary?
|
|
405
|
-
apiRef.current.resize();
|
|
406
|
-
}, [apiRef, rowsMeta.currentPageTotalHeight]);
|
|
407
444
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
408
445
|
// TODO a scroll reset should not be necessary
|
|
409
446
|
if (enabledForColumns) {
|
|
@@ -439,7 +476,7 @@ const useGridVirtualScroller = () => {
|
|
|
439
476
|
setPanels,
|
|
440
477
|
getRows,
|
|
441
478
|
getContainerProps: () => ({
|
|
442
|
-
ref:
|
|
479
|
+
ref: mainRefCallback
|
|
443
480
|
}),
|
|
444
481
|
getScrollerProps: () => ({
|
|
445
482
|
ref: scrollerRef,
|
|
@@ -497,7 +534,8 @@ function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
|
|
|
497
534
|
pinnedColumns: (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef),
|
|
498
535
|
visibleColumns,
|
|
499
536
|
hiddenCellsOriginMap,
|
|
500
|
-
listView: rootProps.unstable_listView ?? false
|
|
537
|
+
listView: rootProps.unstable_listView ?? false,
|
|
538
|
+
virtualizeColumnsWithAutoRowHeight: rootProps.virtualizeColumnsWithAutoRowHeight
|
|
501
539
|
};
|
|
502
540
|
}
|
|
503
541
|
function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
@@ -545,11 +583,13 @@ function computeRenderContext(inputs, scrollPosition, scrollCache) {
|
|
|
545
583
|
positions: inputs.rowsMeta.positions,
|
|
546
584
|
lastSize: inputs.lastRowHeight
|
|
547
585
|
});
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
586
|
+
if (!inputs.virtualizeColumnsWithAutoRowHeight) {
|
|
587
|
+
for (let i = firstRowToRender; i < lastRowToRender && !hasRowWithAutoHeight; i += 1) {
|
|
588
|
+
const row = inputs.rows[i];
|
|
589
|
+
hasRowWithAutoHeight = inputs.apiRef.current.rowHasAutoHeight(row.id);
|
|
590
|
+
}
|
|
551
591
|
}
|
|
552
|
-
if (!hasRowWithAutoHeight) {
|
|
592
|
+
if (!hasRowWithAutoHeight || inputs.virtualizeColumnsWithAutoRowHeight) {
|
|
553
593
|
firstColumnIndex = binarySearch(realLeft, inputs.columnPositions, {
|
|
554
594
|
atStart: true,
|
|
555
595
|
lastPosition: inputs.columnsTotalWidth
|
package/node/index.js
CHANGED