@mui/x-data-grid 7.0.0-beta.7 → 7.1.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 +266 -12
- package/DataGrid/DataGrid.js +18 -17
- package/DataGrid/useDataGridProps.js +4 -5
- package/README.md +1 -1
- package/components/GridFooter.js +2 -3
- package/components/GridHeader.js +1 -2
- package/components/GridPagination.d.ts +6 -5
- package/components/GridPagination.js +12 -4
- package/components/GridRow.js +13 -17
- package/components/base/GridFooterPlaceholder.js +1 -2
- package/components/base/GridOverlays.js +3 -6
- package/components/cell/GridActionsCell.js +4 -6
- package/components/cell/GridActionsCellItem.d.ts +8 -25
- package/components/cell/GridActionsCellItem.js +8 -5
- package/components/cell/GridBooleanCell.d.ts +1 -0
- package/components/cell/GridBooleanCell.js +3 -2
- package/components/cell/GridCell.js +7 -8
- package/components/cell/GridEditBooleanCell.js +1 -2
- package/components/cell/GridEditDateCell.js +2 -3
- package/components/cell/GridEditInputCell.js +2 -2
- package/components/cell/GridEditSingleSelectCell.js +5 -8
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +2 -3
- package/components/columnHeaders/GridColumnGroupHeader.js +4 -5
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +2 -3
- package/components/columnHeaders/GridColumnHeaderItem.js +8 -7
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
- package/components/columnHeaders/GridColumnHeaderTitle.js +2 -3
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +4 -2
- package/components/columnSelection/GridCellCheckboxRenderer.js +3 -5
- package/components/columnSelection/GridHeaderCheckbox.js +1 -2
- package/components/columnsManagement/GridColumnsManagement.js +17 -21
- package/components/containers/GridRoot.js +3 -3
- package/components/menu/GridMenu.js +4 -6
- package/components/menu/columnMenu/GridColumnHeaderMenu.js +1 -1
- package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +2 -3
- package/components/panel/GridColumnsPanel.js +1 -2
- package/components/panel/GridPanel.d.ts +1 -10
- package/components/panel/GridPanel.js +1 -2
- package/components/panel/GridPreferencesPanel.js +2 -3
- package/components/panel/filterPanel/GridFilterForm.js +24 -27
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -7
- package/components/panel/filterPanel/GridFilterInputDate.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +3 -4
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +11 -15
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +10 -14
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +10 -11
- package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputValue.js +5 -7
- package/components/panel/filterPanel/GridFilterPanel.js +5 -9
- package/components/panel/filterPanel/filterPanelUtils.js +1 -1
- package/components/toolbar/GridToolbarColumnsButton.js +3 -5
- package/components/toolbar/GridToolbarDensitySelector.js +8 -10
- package/components/toolbar/GridToolbarExport.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +3 -5
- package/components/toolbar/GridToolbarFilterButton.js +3 -5
- package/components/toolbar/GridToolbarQuickFilter.js +21 -7
- package/components/virtualization/GridVirtualScrollerContent.js +1 -2
- package/components/virtualization/GridVirtualScrollerRenderZone.js +1 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +1 -2
- package/hooks/core/useGridApiInitialization.js +4 -6
- package/hooks/features/clipboard/useGridClipboard.js +6 -5
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.js +4 -16
- package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +4 -8
- package/hooks/features/columnGrouping/useGridColumnGrouping.js +12 -23
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +6 -8
- package/hooks/features/columnMenu/useGridColumnMenuSlots.js +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +9 -19
- package/hooks/features/columns/gridColumnsSelector.js +1 -2
- package/hooks/features/columns/gridColumnsUtils.d.ts +0 -9
- package/hooks/features/columns/gridColumnsUtils.js +2 -22
- package/hooks/features/columns/useGridColumnSpanning.js +1 -2
- package/hooks/features/columns/useGridColumns.js +11 -19
- package/hooks/features/density/densitySelector.d.ts +4 -2
- package/hooks/features/density/densitySelector.js +8 -2
- package/hooks/features/density/densityState.d.ts +1 -4
- package/hooks/features/density/useGridDensity.d.ts +2 -4
- package/hooks/features/density/useGridDensity.js +21 -29
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +6 -7
- package/hooks/features/editing/useGridCellEditing.js +4 -6
- package/hooks/features/editing/useGridEditing.js +1 -2
- package/hooks/features/editing/useGridRowEditing.js +17 -10
- package/hooks/features/export/serializers/csvSerializer.d.ts +2 -0
- package/hooks/features/export/serializers/csvSerializer.js +25 -16
- package/hooks/features/export/useGridCsvExport.js +9 -10
- package/hooks/features/export/useGridPrintExport.js +9 -15
- package/hooks/features/export/utils.js +2 -3
- package/hooks/features/filter/gridFilterSelector.js +15 -22
- package/hooks/features/filter/gridFilterUtils.js +10 -16
- package/hooks/features/filter/useGridFilter.js +9 -15
- package/hooks/features/focus/useGridFocus.js +5 -6
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +1 -4
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +12 -17
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -2
- package/hooks/features/pagination/gridPaginationSelector.js +1 -2
- package/hooks/features/pagination/useGridPagination.js +2 -3
- package/hooks/features/pagination/useGridPaginationModel.js +6 -11
- package/hooks/features/pagination/useGridRowCount.js +3 -6
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +7 -12
- package/hooks/features/rowSelection/useGridRowSelection.js +11 -16
- package/hooks/features/rows/gridRowsSelector.js +11 -19
- package/hooks/features/rows/gridRowsUtils.js +7 -9
- package/hooks/features/rows/useGridParamsApi.js +1 -1
- package/hooks/features/rows/useGridRows.js +4 -13
- package/hooks/features/rows/useGridRowsMeta.js +7 -13
- package/hooks/features/scroll/useGridScroll.js +2 -3
- package/hooks/features/sorting/gridSortingSelector.js +4 -7
- package/hooks/features/sorting/useGridSorting.js +8 -14
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +220 -71
- package/hooks/utils/useGridApiEventHandler.js +5 -10
- package/hooks/utils/useGridNativeEventListener.js +1 -2
- package/index.js +1 -1
- package/internals/index.d.ts +2 -0
- package/internals/index.js +1 -0
- package/internals/utils/useProps.js +1 -2
- package/joy/joySlots.js +7 -13
- package/models/api/gridRowsMetaApi.d.ts +1 -1
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/events/gridEventLookup.d.ts +7 -0
- package/models/gridExport.d.ts +6 -0
- package/models/gridStateCommunity.d.ts +1 -0
- package/models/props/DataGridProps.d.ts +26 -25
- package/modern/DataGrid/DataGrid.js +18 -17
- package/modern/DataGrid/useDataGridProps.js +4 -5
- package/modern/components/GridPagination.js +11 -2
- package/modern/components/cell/GridActionsCell.js +1 -1
- package/modern/components/cell/GridActionsCellItem.js +4 -0
- package/modern/components/cell/GridBooleanCell.js +3 -2
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -1
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
- package/modern/components/containers/GridRoot.js +3 -3
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/modern/components/toolbar/GridToolbarDensitySelector.js +5 -5
- package/modern/components/toolbar/GridToolbarQuickFilter.js +17 -2
- package/modern/hooks/features/clipboard/useGridClipboard.js +4 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +1 -1
- package/modern/hooks/features/columns/gridColumnsUtils.js +0 -19
- package/modern/hooks/features/density/densitySelector.js +8 -2
- package/modern/hooks/features/density/useGridDensity.js +21 -29
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
- package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +14 -5
- package/modern/hooks/features/export/serializers/csvSerializer.js +23 -12
- package/modern/hooks/features/export/useGridCsvExport.js +2 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/models/api/index.js +0 -1
- package/modern/utils/createSelector.js +1 -1
- package/modern/utils/domUtils.js +1 -1
- package/modern/utils/keyboardUtils.js +1 -1
- package/modern/utils/throttle.js +19 -0
- package/node/DataGrid/DataGrid.js +18 -17
- package/node/DataGrid/useDataGridProps.js +4 -5
- package/node/components/GridPagination.js +9 -1
- package/node/components/cell/GridActionsCell.js +1 -1
- package/node/components/cell/GridActionsCellItem.js +4 -0
- package/node/components/cell/GridBooleanCell.js +3 -2
- package/node/components/columnHeaders/GridColumnHeaderItem.js +3 -1
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
- package/node/components/containers/GridRoot.js +2 -2
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputDate.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputValue.js +1 -1
- package/node/components/toolbar/GridToolbarDensitySelector.js +4 -4
- package/node/components/toolbar/GridToolbarQuickFilter.js +17 -2
- package/node/hooks/features/clipboard/useGridClipboard.js +4 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +1 -1
- package/node/hooks/features/columns/gridColumnsUtils.js +0 -20
- package/node/hooks/features/density/densitySelector.js +9 -3
- package/node/hooks/features/density/useGridDensity.js +22 -30
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -1
- package/node/hooks/features/editing/useGridCellEditing.js +1 -1
- package/node/hooks/features/editing/useGridRowEditing.js +14 -5
- package/node/hooks/features/export/serializers/csvSerializer.js +23 -12
- package/node/hooks/features/export/useGridCsvExport.js +2 -1
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +211 -57
- package/node/index.js +1 -1
- package/node/internals/index.js +12 -0
- package/node/models/api/index.js +0 -11
- package/node/utils/createSelector.js +1 -1
- package/node/utils/domUtils.js +1 -1
- package/node/utils/keyboardUtils.js +1 -1
- package/node/utils/throttle.js +25 -0
- package/package.json +4 -4
- package/utils/createSelector.js +9 -9
- package/utils/domUtils.js +4 -7
- package/utils/getGridLocalization.js +9 -12
- package/utils/keyboardUtils.js +1 -1
- package/utils/throttle.d.ts +4 -0
- package/utils/throttle.js +19 -0
package/components/GridRow.js
CHANGED
|
@@ -157,7 +157,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
157
157
|
}, [apiRef, rowId]);
|
|
158
158
|
const publishClick = React.useCallback(event => {
|
|
159
159
|
const cell = findParentElementFromClassName(event.target, gridClasses.cell);
|
|
160
|
-
const field = cell
|
|
160
|
+
const field = cell?.getAttribute('data-field');
|
|
161
161
|
|
|
162
162
|
// Check if the field is available because the cell that fills the empty
|
|
163
163
|
// space of the row has no field.
|
|
@@ -184,7 +184,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
184
184
|
|
|
185
185
|
// User clicked a button from the "actions" column type
|
|
186
186
|
const column = apiRef.current.getColumn(field);
|
|
187
|
-
if (
|
|
187
|
+
if (column?.type === GRID_ACTIONS_COLUMN_TYPE) {
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -199,9 +199,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
199
199
|
const sizes = useGridSelector(apiRef, () => _extends({}, apiRef.current.unstable_getRowInternalSizes(rowId)), objectShallowCompare);
|
|
200
200
|
let minHeight = rowHeight;
|
|
201
201
|
if (minHeight === 'auto' && sizes) {
|
|
202
|
-
var _sizes$baseCenter;
|
|
203
202
|
const numberOfBaseSizes = 1;
|
|
204
|
-
const maximumSize =
|
|
203
|
+
const maximumSize = sizes.baseCenter ?? 0;
|
|
205
204
|
if (maximumSize > 0 && numberOfBaseSizes > 1) {
|
|
206
205
|
minHeight = maximumSize;
|
|
207
206
|
}
|
|
@@ -220,11 +219,11 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
220
219
|
minHeight,
|
|
221
220
|
'--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
|
|
222
221
|
});
|
|
223
|
-
if (sizes
|
|
222
|
+
if (sizes?.spacingTop) {
|
|
224
223
|
const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
|
|
225
224
|
rowStyle[property] = sizes.spacingTop;
|
|
226
225
|
}
|
|
227
|
-
if (sizes
|
|
226
|
+
if (sizes?.spacingBottom) {
|
|
228
227
|
const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
|
|
229
228
|
let propertyValue = rowStyle[property];
|
|
230
229
|
// avoid overriding existing value
|
|
@@ -238,8 +237,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
238
237
|
}, [isNotVisible, rowHeight, styleProp, minHeight, sizes, rootProps.rowSpacingType]);
|
|
239
238
|
const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
|
|
240
239
|
if (typeof rootProps.getRowClassName === 'function') {
|
|
241
|
-
|
|
242
|
-
const indexRelativeToCurrentPage = index - (((_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0);
|
|
240
|
+
const indexRelativeToCurrentPage = index - (currentPage.range?.firstRowIndex || 0);
|
|
243
241
|
const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
|
|
244
242
|
isFirstVisible: indexRelativeToCurrentPage === 0,
|
|
245
243
|
isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
|
|
@@ -248,24 +246,22 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
248
246
|
rowClassNames.push(rootProps.getRowClassName(rowParams));
|
|
249
247
|
}
|
|
250
248
|
const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = PinnedPosition.NONE) => {
|
|
251
|
-
var _cellColSpanInfo$cell, _cellColSpanInfo$cell2, _editRowsState$rowId$, _editRowsState$rowId;
|
|
252
249
|
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
|
|
253
|
-
if (cellColSpanInfo
|
|
250
|
+
if (cellColSpanInfo?.spannedByColSpan) {
|
|
254
251
|
return null;
|
|
255
252
|
}
|
|
256
|
-
const width =
|
|
257
|
-
const colSpan =
|
|
253
|
+
const width = cellColSpanInfo?.cellProps.width ?? column.computedWidth;
|
|
254
|
+
const colSpan = cellColSpanInfo?.cellProps.colSpan ?? 1;
|
|
258
255
|
const pinnedOffset = getPinnedCellOffset(gridPinnedColumnPositionLookup[pinnedPosition], column.computedWidth, indexRelativeToAllColumns, columnPositions, dimensions);
|
|
259
|
-
if (
|
|
260
|
-
var _column$align;
|
|
256
|
+
if (rowNode?.type === 'skeletonRow') {
|
|
261
257
|
return /*#__PURE__*/_jsx(slots.skeletonCell, {
|
|
262
258
|
width: width,
|
|
263
259
|
height: rowHeight,
|
|
264
260
|
field: column.field,
|
|
265
|
-
align:
|
|
261
|
+
align: column.align ?? 'left'
|
|
266
262
|
}, column.field);
|
|
267
263
|
}
|
|
268
|
-
const editCellState =
|
|
264
|
+
const editCellState = editRowsState[rowId]?.[column.field] ?? null;
|
|
269
265
|
|
|
270
266
|
// when the cell is a reorder cell we are not allowing to reorder the col
|
|
271
267
|
// fixes https://github.com/mui/mui-x/issues/11126
|
|
@@ -289,7 +285,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
289
285
|
pinnedPosition: pinnedPosition,
|
|
290
286
|
sectionIndex: indexInSection,
|
|
291
287
|
sectionLength: sectionLength
|
|
292
|
-
}, slotProps
|
|
288
|
+
}, slotProps?.cell), column.field);
|
|
293
289
|
};
|
|
294
290
|
|
|
295
291
|
/* Start of rendering */
|
|
@@ -3,10 +3,9 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
export function GridFooterPlaceholder() {
|
|
6
|
-
var _rootProps$slotProps;
|
|
7
6
|
const rootProps = useGridRootProps();
|
|
8
7
|
if (rootProps.hideFooter) {
|
|
9
8
|
return null;
|
|
10
9
|
}
|
|
11
|
-
return /*#__PURE__*/_jsx(rootProps.slots.footer, _extends({},
|
|
10
|
+
return /*#__PURE__*/_jsx(rootProps.slots.footer, _extends({}, rootProps.slotProps?.footer /* FIXME: typing error */));
|
|
12
11
|
}
|
|
@@ -91,18 +91,15 @@ export function GridOverlays() {
|
|
|
91
91
|
let overlay = null;
|
|
92
92
|
let overlayType = '';
|
|
93
93
|
if (showNoRowsOverlay) {
|
|
94
|
-
|
|
95
|
-
overlay = /*#__PURE__*/_jsx(rootProps.slots.noRowsOverlay, _extends({}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.noRowsOverlay));
|
|
94
|
+
overlay = /*#__PURE__*/_jsx(rootProps.slots.noRowsOverlay, _extends({}, rootProps.slotProps?.noRowsOverlay));
|
|
96
95
|
overlayType = 'noRowsOverlay';
|
|
97
96
|
}
|
|
98
97
|
if (showNoResultsOverlay) {
|
|
99
|
-
|
|
100
|
-
overlay = /*#__PURE__*/_jsx(rootProps.slots.noResultsOverlay, _extends({}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.noResultsOverlay));
|
|
98
|
+
overlay = /*#__PURE__*/_jsx(rootProps.slots.noResultsOverlay, _extends({}, rootProps.slotProps?.noResultsOverlay));
|
|
101
99
|
overlayType = 'noResultsOverlay';
|
|
102
100
|
}
|
|
103
101
|
if (loading) {
|
|
104
|
-
|
|
105
|
-
overlay = /*#__PURE__*/_jsx(rootProps.slots.loadingOverlay, _extends({}, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.loadingOverlay));
|
|
102
|
+
overlay = /*#__PURE__*/_jsx(rootProps.slots.loadingOverlay, _extends({}, rootProps.slotProps?.loadingOverlay));
|
|
106
103
|
overlayType = 'loadingOverlay';
|
|
107
104
|
}
|
|
108
105
|
if (overlay === null) {
|
|
@@ -14,7 +14,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
const hasActions = colDef => typeof colDef.getActions === 'function';
|
|
16
16
|
function GridActionsCell(props) {
|
|
17
|
-
var _rootProps$slotProps;
|
|
18
17
|
const {
|
|
19
18
|
colDef,
|
|
20
19
|
id,
|
|
@@ -45,7 +44,7 @@ function GridActionsCell(props) {
|
|
|
45
44
|
React.useLayoutEffect(() => {
|
|
46
45
|
if (!hasFocus) {
|
|
47
46
|
Object.entries(touchRippleRefs.current).forEach(([index, ref]) => {
|
|
48
|
-
ref
|
|
47
|
+
ref?.stop({}, () => {
|
|
49
48
|
delete touchRippleRefs.current[index];
|
|
50
49
|
});
|
|
51
50
|
});
|
|
@@ -107,7 +106,6 @@ function GridActionsCell(props) {
|
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
109
108
|
const getNewIndex = (index, direction) => {
|
|
110
|
-
var _options;
|
|
111
109
|
if (index < 0 || index > options.length) {
|
|
112
110
|
return index;
|
|
113
111
|
}
|
|
@@ -117,7 +115,7 @@ function GridActionsCell(props) {
|
|
|
117
115
|
const indexMod = (direction === 'left' ? -1 : 1) * rtlMod;
|
|
118
116
|
|
|
119
117
|
// if the button that should receive focus is disabled go one more step
|
|
120
|
-
return
|
|
118
|
+
return options[index + indexMod]?.props.disabled ? getNewIndex(index + indexMod, direction) : index + indexMod;
|
|
121
119
|
};
|
|
122
120
|
let newIndex = focusedButtonIndex;
|
|
123
121
|
if (event.key === 'ArrowRight') {
|
|
@@ -130,7 +128,7 @@ function GridActionsCell(props) {
|
|
|
130
128
|
}
|
|
131
129
|
if (newIndex !== focusedButtonIndex) {
|
|
132
130
|
event.preventDefault(); // Prevent scrolling
|
|
133
|
-
event.stopPropagation(); // Don't stop propagation for other keys,
|
|
131
|
+
event.stopPropagation(); // Don't stop propagation for other keys, for example ArrowUp
|
|
134
132
|
setFocusedButtonIndex(newIndex);
|
|
135
133
|
}
|
|
136
134
|
};
|
|
@@ -166,7 +164,7 @@ function GridActionsCell(props) {
|
|
|
166
164
|
onClick: showMenu,
|
|
167
165
|
touchRippleRef: handleTouchRippleRef(buttonId),
|
|
168
166
|
tabIndex: focusedButtonIndex === iconButtons.length ? tabIndex : -1
|
|
169
|
-
},
|
|
167
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
170
168
|
children: /*#__PURE__*/_jsx(rootProps.slots.moreActionsIcon, {
|
|
171
169
|
fontSize: "small"
|
|
172
170
|
})
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IconButtonProps } from '@mui/material/IconButton';
|
|
3
3
|
import { MenuItemProps } from '@mui/material/MenuItem';
|
|
4
|
-
|
|
4
|
+
interface GridActionsCellItemCommonProps {
|
|
5
5
|
label: string;
|
|
6
6
|
icon?: React.ReactElement;
|
|
7
7
|
/** from https://mui.com/material-ui/api/button-base/#ButtonBase-prop-component */
|
|
8
8
|
component?: React.ElementType;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
|
+
export type GridActionsCellItemProps = GridActionsCellItemCommonProps & (({
|
|
10
11
|
showInMenu?: false;
|
|
11
12
|
icon: React.ReactElement;
|
|
12
|
-
} & IconButtonProps) | ({
|
|
13
|
+
} & Omit<IconButtonProps, 'component'>) | ({
|
|
13
14
|
showInMenu: true;
|
|
14
15
|
/**
|
|
15
16
|
* If false, the menu will not close when this item is clicked.
|
|
@@ -17,25 +18,11 @@ export type GridActionsCellItemProps = {
|
|
|
17
18
|
*/
|
|
18
19
|
closeMenuOnClick?: boolean;
|
|
19
20
|
closeMenu?: () => void;
|
|
20
|
-
} & MenuItemProps));
|
|
21
|
-
declare const GridActionsCellItem: React.ForwardRefExoticComponent<(Omit<{
|
|
22
|
-
label: string;
|
|
23
|
-
icon?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
24
|
-
/** from https://mui.com/material-ui/api/button-base/#ButtonBase-prop-component */
|
|
25
|
-
component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
26
|
-
} & {
|
|
21
|
+
} & Omit<MenuItemProps, 'component'>));
|
|
22
|
+
declare const GridActionsCellItem: React.ForwardRefExoticComponent<(Omit<GridActionsCellItemCommonProps & {
|
|
27
23
|
showInMenu?: false | undefined;
|
|
28
24
|
icon: React.ReactElement;
|
|
29
|
-
} &
|
|
30
|
-
ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
|
|
31
|
-
}, "color" | "size" | "style" | "disabled" | "action" | "className" | "tabIndex" | "children" | "sx" | "classes" | "onFocusVisible" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "edge"> & {
|
|
32
|
-
component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
33
|
-
}, "ref"> | Omit<{
|
|
34
|
-
label: string;
|
|
35
|
-
icon?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
36
|
-
/** from https://mui.com/material-ui/api/button-base/#ButtonBase-prop-component */
|
|
37
|
-
component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
38
|
-
} & {
|
|
25
|
+
} & Omit<IconButtonProps, "component">, "ref"> | Omit<GridActionsCellItemCommonProps & {
|
|
39
26
|
showInMenu: true;
|
|
40
27
|
/**
|
|
41
28
|
* If false, the menu will not close when this item is clicked.
|
|
@@ -43,9 +30,5 @@ declare const GridActionsCellItem: React.ForwardRefExoticComponent<(Omit<{
|
|
|
43
30
|
*/
|
|
44
31
|
closeMenuOnClick?: boolean | undefined;
|
|
45
32
|
closeMenu?: (() => void) | undefined;
|
|
46
|
-
} &
|
|
47
|
-
ref?: ((instance: HTMLLIElement | null) => void) | React.RefObject<HTMLLIElement> | null | undefined;
|
|
48
|
-
}, "style" | "dense" | "disabled" | "action" | "selected" | "autoFocus" | "className" | "tabIndex" | "children" | "sx" | "classes" | "disableGutters" | "divider" | "onFocusVisible" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "TouchRippleProps" | "touchRippleRef"> & {
|
|
49
|
-
component?: React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined;
|
|
50
|
-
}, "ref">) & React.RefAttributes<HTMLElement>>;
|
|
33
|
+
} & Omit<MenuItemProps, "component">, "ref">) & React.RefAttributes<HTMLElement>>;
|
|
51
34
|
export { GridActionsCellItem };
|
|
@@ -12,7 +12,6 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
const GridActionsCellItem = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
13
13
|
const rootProps = useGridRootProps();
|
|
14
14
|
if (!props.showInMenu) {
|
|
15
|
-
var _rootProps$slotProps;
|
|
16
15
|
const {
|
|
17
16
|
label,
|
|
18
17
|
icon,
|
|
@@ -20,7 +19,7 @@ const GridActionsCellItem = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
20
19
|
} = props,
|
|
21
20
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
22
21
|
const handleClick = event => {
|
|
23
|
-
onClick
|
|
22
|
+
onClick?.(event);
|
|
24
23
|
};
|
|
25
24
|
return /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
26
25
|
ref: ref,
|
|
@@ -29,7 +28,7 @@ const GridActionsCellItem = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
29
28
|
"aria-label": label
|
|
30
29
|
}, other, {
|
|
31
30
|
onClick: handleClick
|
|
32
|
-
},
|
|
31
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
33
32
|
children: /*#__PURE__*/React.cloneElement(icon, {
|
|
34
33
|
fontSize: 'small'
|
|
35
34
|
})
|
|
@@ -44,9 +43,9 @@ const GridActionsCellItem = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
44
43
|
} = props,
|
|
45
44
|
other = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
46
45
|
const handleClick = event => {
|
|
47
|
-
onClick
|
|
46
|
+
onClick?.(event);
|
|
48
47
|
if (closeMenuOnClick) {
|
|
49
|
-
closeMenu
|
|
48
|
+
closeMenu?.();
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
51
|
return /*#__PURE__*/_jsxs(MenuItem, _extends({
|
|
@@ -63,6 +62,10 @@ process.env.NODE_ENV !== "production" ? GridActionsCellItem.propTypes = {
|
|
|
63
62
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
64
63
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
65
64
|
// ----------------------------------------------------------------------
|
|
65
|
+
/**
|
|
66
|
+
* from https://mui.com/material-ui/api/button-base/#ButtonBase-prop-component
|
|
67
|
+
*/
|
|
68
|
+
component: PropTypes.elementType,
|
|
66
69
|
icon: PropTypes.element,
|
|
67
70
|
label: PropTypes.string.isRequired,
|
|
68
71
|
showInMenu: PropTypes.bool
|
|
@@ -3,6 +3,7 @@ import { SvgIconProps } from '@mui/material/SvgIcon';
|
|
|
3
3
|
import { GridRenderCellParams } from '../../models/params/gridCellParams';
|
|
4
4
|
import { GridColDef } from '../../models/colDef/gridColDef';
|
|
5
5
|
interface GridBooleanCellProps extends GridRenderCellParams, Omit<SvgIconProps, 'tabIndex' | 'id'> {
|
|
6
|
+
hideDescendantCount?: boolean;
|
|
6
7
|
}
|
|
7
8
|
declare function GridBooleanCellRaw(props: GridBooleanCellProps): React.JSX.Element;
|
|
8
9
|
declare namespace GridBooleanCellRaw {
|
|
@@ -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 = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "hasFocus", "tabIndex"];
|
|
3
|
+
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "hasFocus", "tabIndex", "hideDescendantCount"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
@@ -76,6 +76,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
76
76
|
* If true, the cell is the active element.
|
|
77
77
|
*/
|
|
78
78
|
hasFocus: PropTypes.bool.isRequired,
|
|
79
|
+
hideDescendantCount: PropTypes.bool,
|
|
79
80
|
/**
|
|
80
81
|
* The grid row id.
|
|
81
82
|
*/
|
|
@@ -105,7 +106,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
105
106
|
const GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
|
|
106
107
|
export { GridBooleanCell };
|
|
107
108
|
export const renderBooleanCell = params => {
|
|
108
|
-
if (isAutoGeneratedRow(params.rowNode)) {
|
|
109
|
+
if (params.field !== '__row_group_by_columns_group__' && isAutoGeneratedRow(params.rowNode)) {
|
|
109
110
|
return '';
|
|
110
111
|
}
|
|
111
112
|
return /*#__PURE__*/_jsx(GridBooleanCell, _extends({}, params));
|
|
@@ -76,7 +76,6 @@ let warnedOnce = false;
|
|
|
76
76
|
// TODO(v7): Removing the wrapper will break the docs performance visualization demo.
|
|
77
77
|
|
|
78
78
|
const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
79
|
-
var _getActions, _ref, _rootProps$cellSelect, _rootProps$experiment;
|
|
80
79
|
const {
|
|
81
80
|
column,
|
|
82
81
|
rowId,
|
|
@@ -134,7 +133,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
134
133
|
value,
|
|
135
134
|
formattedValue
|
|
136
135
|
} = cellParamsWithAPI;
|
|
137
|
-
const canManageOwnFocus = column.type === 'actions' &&
|
|
136
|
+
const canManageOwnFocus = column.type === 'actions' && column.getActions?.(apiRef.current.getRowParams(rowId)).some(action => !action.props.disabled);
|
|
138
137
|
const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
|
|
139
138
|
const {
|
|
140
139
|
classes: rootClasses,
|
|
@@ -161,7 +160,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
161
160
|
const handleRef = useForkRef(ref, cellRef);
|
|
162
161
|
const focusElementRef = React.useRef(null);
|
|
163
162
|
// @ts-expect-error To access `cellSelection` flag as it's a `premium` feature
|
|
164
|
-
const isSelectionMode =
|
|
163
|
+
const isSelectionMode = rootProps.cellSelection ?? false;
|
|
165
164
|
const position = gridPinnedColumnPositionLookup[pinnedPosition];
|
|
166
165
|
const showLeftBorder = shouldCellShowLeftBorder(position, sectionIndex);
|
|
167
166
|
const showRightBorder = shouldCellShowRightBorder(position, sectionIndex, sectionLength, rootProps.showCellVerticalBorder);
|
|
@@ -244,17 +243,17 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
244
243
|
return null;
|
|
245
244
|
}
|
|
246
245
|
let handleFocus = other.onFocus;
|
|
247
|
-
if (process.env.NODE_ENV === 'test' &&
|
|
246
|
+
if (process.env.NODE_ENV === 'test' && rootProps.experimentalFeatures?.warnIfFocusStateIsNotSynced) {
|
|
248
247
|
handleFocus = event => {
|
|
249
248
|
const focusedCell = gridFocusCellSelector(apiRef);
|
|
250
|
-
if (
|
|
249
|
+
if (focusedCell?.id === rowId && focusedCell.field === field) {
|
|
251
250
|
if (typeof other.onFocus === 'function') {
|
|
252
251
|
other.onFocus(event);
|
|
253
252
|
}
|
|
254
253
|
return;
|
|
255
254
|
}
|
|
256
255
|
if (!warnedOnce) {
|
|
257
|
-
console.warn([`MUI X: The cell with id=${rowId} and field=${field} received focus.`, `According to the state, the focus should be at id=${focusedCell
|
|
256
|
+
console.warn([`MUI X: The cell with id=${rowId} and field=${field} received focus.`, `According to the state, the focus should be at id=${focusedCell?.id}, field=${focusedCell?.field}.`, "Not syncing the state may cause unwanted behaviors since the `cellFocusIn` event won't be fired.", 'Call `fireEvent.mouseUp` before the `fireEvent.click` to sync the focus with the state.'].join('\n'));
|
|
258
257
|
warnedOnce = true;
|
|
259
258
|
}
|
|
260
259
|
};
|
|
@@ -274,10 +273,10 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
274
273
|
}, editCellStateRest);
|
|
275
274
|
children = column.renderEditCell(params);
|
|
276
275
|
classNames.push(gridClasses['cell--editing']);
|
|
277
|
-
classNames.push(rootClasses
|
|
276
|
+
classNames.push(rootClasses?.['cell--editing']);
|
|
278
277
|
}
|
|
279
278
|
if (children === undefined) {
|
|
280
|
-
const valueString = valueToRender
|
|
279
|
+
const valueString = valueToRender?.toString();
|
|
281
280
|
children = valueString;
|
|
282
281
|
title = valueString;
|
|
283
282
|
}
|
|
@@ -19,7 +19,6 @@ const useUtilityClasses = ownerState => {
|
|
|
19
19
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
20
20
|
};
|
|
21
21
|
function GridEditBooleanCell(props) {
|
|
22
|
-
var _rootProps$slotProps;
|
|
23
22
|
const {
|
|
24
23
|
id: idProp,
|
|
25
24
|
value,
|
|
@@ -68,7 +67,7 @@ function GridEditBooleanCell(props) {
|
|
|
68
67
|
checked: Boolean(valueState),
|
|
69
68
|
onChange: handleChange,
|
|
70
69
|
size: "small"
|
|
71
|
-
},
|
|
70
|
+
}, rootProps.slotProps?.baseCheckbox))
|
|
72
71
|
}));
|
|
73
72
|
}
|
|
74
73
|
process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
@@ -43,7 +43,7 @@ function GridEditDateCell(props) {
|
|
|
43
43
|
} else if (valueProp instanceof Date) {
|
|
44
44
|
parsedDate = valueProp;
|
|
45
45
|
} else {
|
|
46
|
-
parsedDate = new Date((valueProp
|
|
46
|
+
parsedDate = new Date((valueProp ?? '').toString());
|
|
47
47
|
}
|
|
48
48
|
let formattedDate;
|
|
49
49
|
if (parsedDate == null || Number.isNaN(parsedDate.getTime())) {
|
|
@@ -96,8 +96,7 @@ function GridEditDateCell(props) {
|
|
|
96
96
|
}, [apiRef, field, id, onValueChange, parseValueToDate]);
|
|
97
97
|
React.useEffect(() => {
|
|
98
98
|
setValueState(state => {
|
|
99
|
-
|
|
100
|
-
if (valueTransformed.parsed !== state.parsed && ((_valueTransformed$par = valueTransformed.parsed) == null ? void 0 : _valueTransformed$par.getTime()) !== ((_state$parsed = state.parsed) == null ? void 0 : _state$parsed.getTime())) {
|
|
99
|
+
if (valueTransformed.parsed !== state.parsed && valueTransformed.parsed?.getTime() !== state.parsed?.getTime()) {
|
|
101
100
|
return valueTransformed;
|
|
102
101
|
}
|
|
103
102
|
return state;
|
|
@@ -70,7 +70,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
70
70
|
}, [apiRef, debounceMs, field, id, onValueChange]);
|
|
71
71
|
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
72
72
|
React.useEffect(() => {
|
|
73
|
-
if (
|
|
73
|
+
if (meta?.changeReason !== 'debouncedSetEditCellValue') {
|
|
74
74
|
setValueState(value);
|
|
75
75
|
}
|
|
76
76
|
}, [meta, value]);
|
|
@@ -86,7 +86,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
86
86
|
ownerState: rootProps,
|
|
87
87
|
fullWidth: true,
|
|
88
88
|
type: colDef.type === 'number' ? colDef.type : 'text',
|
|
89
|
-
value: valueState
|
|
89
|
+
value: valueState ?? '',
|
|
90
90
|
onChange: handleChange,
|
|
91
91
|
endAdornment: isProcessingProps ? /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {
|
|
92
92
|
fontSize: "small",
|
|
@@ -17,7 +17,6 @@ function isKeyboardEvent(event) {
|
|
|
17
17
|
return !!event.key;
|
|
18
18
|
}
|
|
19
19
|
function GridEditSingleSelectCell(props) {
|
|
20
|
-
var _rootProps$slotProps, _baseSelectProps$nati, _rootProps$slotProps2;
|
|
21
20
|
const rootProps = useGridRootProps();
|
|
22
21
|
const {
|
|
23
22
|
id,
|
|
@@ -35,17 +34,16 @@ function GridEditSingleSelectCell(props) {
|
|
|
35
34
|
const ref = React.useRef();
|
|
36
35
|
const inputRef = React.useRef();
|
|
37
36
|
const [open, setOpen] = React.useState(initialOpen);
|
|
38
|
-
const baseSelectProps =
|
|
39
|
-
const isSelectNative =
|
|
40
|
-
const _ref =
|
|
37
|
+
const baseSelectProps = rootProps.slotProps?.baseSelect || {};
|
|
38
|
+
const isSelectNative = baseSelectProps.native ?? false;
|
|
39
|
+
const _ref = rootProps.slotProps?.baseSelect || {},
|
|
41
40
|
{
|
|
42
41
|
MenuProps
|
|
43
42
|
} = _ref,
|
|
44
43
|
otherBaseSelectProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
45
44
|
useEnhancedEffect(() => {
|
|
46
45
|
if (hasFocus) {
|
|
47
|
-
|
|
48
|
-
(_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
|
|
46
|
+
inputRef.current?.focus();
|
|
49
47
|
}
|
|
50
48
|
}, [hasFocus]);
|
|
51
49
|
if (!isSingleSelectColDef(colDef)) {
|
|
@@ -113,9 +111,8 @@ function GridEditSingleSelectCell(props) {
|
|
|
113
111
|
fullWidth: true
|
|
114
112
|
}, other, otherBaseSelectProps, {
|
|
115
113
|
children: valueOptions.map(valueOption => {
|
|
116
|
-
var _rootProps$slotProps3;
|
|
117
114
|
const value = getOptionValue(valueOption);
|
|
118
|
-
return /*#__PURE__*/_createElement(rootProps.slots.baseSelectOption, _extends({},
|
|
115
|
+
return /*#__PURE__*/_createElement(rootProps.slots.baseSelectOption, _extends({}, rootProps.slotProps?.baseSelectOption || {}, {
|
|
119
116
|
native: isSelectNative,
|
|
120
117
|
key: value,
|
|
121
118
|
value: value
|
|
@@ -17,7 +17,6 @@ const useUtilityClasses = ownerState => {
|
|
|
17
17
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
18
18
|
};
|
|
19
19
|
export const ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(props => {
|
|
20
|
-
var _rootProps$slotProps, _rootProps$slotProps2;
|
|
21
20
|
const {
|
|
22
21
|
colDef,
|
|
23
22
|
open,
|
|
@@ -41,7 +40,7 @@ export const ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(props => {
|
|
|
41
40
|
children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
|
|
42
41
|
title: apiRef.current.getLocaleText('columnMenuLabel'),
|
|
43
42
|
enterDelay: 1000
|
|
44
|
-
},
|
|
43
|
+
}, rootProps.slotProps?.baseTooltip, {
|
|
45
44
|
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
46
45
|
ref: iconButtonRef,
|
|
47
46
|
tabIndex: -1,
|
|
@@ -53,7 +52,7 @@ export const ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(props => {
|
|
|
53
52
|
"aria-expanded": open,
|
|
54
53
|
"aria-controls": open ? columnMenuId : undefined,
|
|
55
54
|
id: columnMenuButtonId
|
|
56
|
-
},
|
|
55
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
57
56
|
children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuIcon, {
|
|
58
57
|
fontSize: "small"
|
|
59
58
|
})
|
|
@@ -29,7 +29,6 @@ const useUtilityClasses = ownerState => {
|
|
|
29
29
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
30
30
|
};
|
|
31
31
|
function GridColumnGroupHeader(props) {
|
|
32
|
-
var _columnGroupsLookup$g;
|
|
33
32
|
const {
|
|
34
33
|
groupId,
|
|
35
34
|
width,
|
|
@@ -52,12 +51,12 @@ function GridColumnGroupHeader(props) {
|
|
|
52
51
|
const columnGroupsLookup = useGridSelector(apiRef, gridColumnGroupsLookupSelector);
|
|
53
52
|
const group = groupId ? columnGroupsLookup[groupId] : {};
|
|
54
53
|
const {
|
|
55
|
-
headerName = groupId
|
|
54
|
+
headerName = groupId ?? '',
|
|
56
55
|
description = '',
|
|
57
56
|
headerAlign = undefined
|
|
58
57
|
} = group;
|
|
59
58
|
let headerComponent;
|
|
60
|
-
const render = groupId &&
|
|
59
|
+
const render = groupId && columnGroupsLookup[groupId]?.renderHeaderGroup;
|
|
61
60
|
const renderParams = React.useMemo(() => ({
|
|
62
61
|
groupId,
|
|
63
62
|
headerName,
|
|
@@ -81,7 +80,7 @@ function GridColumnGroupHeader(props) {
|
|
|
81
80
|
depth,
|
|
82
81
|
isDragging: false
|
|
83
82
|
});
|
|
84
|
-
const label = headerName
|
|
83
|
+
const label = headerName ?? groupId;
|
|
85
84
|
const id = useId();
|
|
86
85
|
const elementId = groupId === null ? `empty-group-cell-${id}` : groupId;
|
|
87
86
|
const classes = useUtilityClasses(ownerState);
|
|
@@ -89,7 +88,7 @@ function GridColumnGroupHeader(props) {
|
|
|
89
88
|
if (hasFocus) {
|
|
90
89
|
const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
|
|
91
90
|
const elementToFocus = focusableElement || headerCellRef.current;
|
|
92
|
-
elementToFocus
|
|
91
|
+
elementToFocus?.focus();
|
|
93
92
|
}
|
|
94
93
|
}, [apiRef, hasFocus]);
|
|
95
94
|
const publish = React.useCallback(eventName => event => {
|
|
@@ -22,7 +22,6 @@ const useUtilityClasses = ownerState => {
|
|
|
22
22
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
23
23
|
};
|
|
24
24
|
function GridColumnHeaderFilterIconButton(props) {
|
|
25
|
-
var _rootProps$slotProps, _rootProps$slotProps2;
|
|
26
25
|
const {
|
|
27
26
|
counter,
|
|
28
27
|
field,
|
|
@@ -67,7 +66,7 @@ function GridColumnHeaderFilterIconButton(props) {
|
|
|
67
66
|
"aria-haspopup": "menu",
|
|
68
67
|
"aria-expanded": open,
|
|
69
68
|
"aria-controls": open ? panelId : undefined
|
|
70
|
-
},
|
|
69
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
71
70
|
children: /*#__PURE__*/_jsx(rootProps.slots.columnFilteredIcon, {
|
|
72
71
|
className: classes.icon,
|
|
73
72
|
fontSize: "small"
|
|
@@ -76,7 +75,7 @@ function GridColumnHeaderFilterIconButton(props) {
|
|
|
76
75
|
return /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
|
|
77
76
|
title: apiRef.current.getLocaleText('columnHeaderFiltersTooltipActive')(counter),
|
|
78
77
|
enterDelay: 1000
|
|
79
|
-
},
|
|
78
|
+
}, rootProps.slotProps?.baseTooltip, {
|
|
80
79
|
children: /*#__PURE__*/_jsxs(GridIconButtonContainer, {
|
|
81
80
|
children: [counter > 1 && /*#__PURE__*/_jsx(Badge, {
|
|
82
81
|
badgeContent: counter,
|
|
@@ -38,7 +38,6 @@ const useUtilityClasses = ownerState => {
|
|
|
38
38
|
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
39
39
|
};
|
|
40
40
|
function GridColumnHeaderItem(props) {
|
|
41
|
-
var _rootProps$slotProps, _colDef$sortingOrder, _rootProps$slotProps2, _colDef$headerName;
|
|
42
41
|
const {
|
|
43
42
|
colDef,
|
|
44
43
|
columnMenuOpen,
|
|
@@ -132,16 +131,16 @@ function GridColumnHeaderItem(props) {
|
|
|
132
131
|
open: columnMenuOpen,
|
|
133
132
|
target: iconButtonRef.current,
|
|
134
133
|
ContentComponent: rootProps.slots.columnMenu,
|
|
135
|
-
contentComponentProps:
|
|
134
|
+
contentComponentProps: rootProps.slotProps?.columnMenu,
|
|
136
135
|
onExited: handleExited
|
|
137
136
|
});
|
|
138
|
-
const sortingOrder =
|
|
137
|
+
const sortingOrder = colDef.sortingOrder ?? rootProps.sortingOrder;
|
|
139
138
|
const showSortIcon = (colDef.sortable || sortDirection != null) && !colDef.hideSortIcons && !rootProps.disableColumnSorting;
|
|
140
139
|
const columnTitleIconButtons = /*#__PURE__*/_jsxs(React.Fragment, {
|
|
141
140
|
children: [!rootProps.disableColumnFilter && /*#__PURE__*/_jsx(rootProps.slots.columnHeaderFilterIconButton, _extends({
|
|
142
141
|
field: colDef.field,
|
|
143
142
|
counter: filterItemsCounter
|
|
144
|
-
},
|
|
143
|
+
}, rootProps.slotProps?.columnHeaderFilterIconButton)), showSortIcon && /*#__PURE__*/_jsx(GridColumnHeaderSortIcon, {
|
|
145
144
|
direction: sortDirection,
|
|
146
145
|
index: sortIndex,
|
|
147
146
|
sortingOrder: sortingOrder,
|
|
@@ -153,15 +152,17 @@ function GridColumnHeaderItem(props) {
|
|
|
153
152
|
if (hasFocus && !columnMenuState.open) {
|
|
154
153
|
const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
|
|
155
154
|
const elementToFocus = focusableElement || headerCellRef.current;
|
|
156
|
-
elementToFocus
|
|
157
|
-
apiRef.current.columnHeadersContainerRef
|
|
155
|
+
elementToFocus?.focus();
|
|
156
|
+
if (apiRef.current.columnHeadersContainerRef?.current) {
|
|
157
|
+
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
158
|
+
}
|
|
158
159
|
}
|
|
159
160
|
}, [apiRef, hasFocus]);
|
|
160
161
|
const headerClassName = typeof colDef.headerClassName === 'function' ? colDef.headerClassName({
|
|
161
162
|
field: colDef.field,
|
|
162
163
|
colDef
|
|
163
164
|
}) : colDef.headerClassName;
|
|
164
|
-
const label =
|
|
165
|
+
const label = colDef.headerName ?? colDef.field;
|
|
165
166
|
return /*#__PURE__*/_jsx(GridGenericColumnHeaderItem, _extends({
|
|
166
167
|
ref: headerCellRef,
|
|
167
168
|
classes: classes,
|
|
@@ -35,7 +35,6 @@ function getIcon(icons, direction, className, sortingOrder) {
|
|
|
35
35
|
}, iconProps)) : null;
|
|
36
36
|
}
|
|
37
37
|
function GridColumnHeaderSortIconRaw(props) {
|
|
38
|
-
var _rootProps$slotProps;
|
|
39
38
|
const {
|
|
40
39
|
direction,
|
|
41
40
|
index,
|
|
@@ -58,7 +57,7 @@ function GridColumnHeaderSortIconRaw(props) {
|
|
|
58
57
|
title: apiRef.current.getLocaleText('columnHeaderSortIconLabel'),
|
|
59
58
|
size: "small",
|
|
60
59
|
disabled: disabled
|
|
61
|
-
},
|
|
60
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
62
61
|
children: iconElement
|
|
63
62
|
}));
|
|
64
63
|
return /*#__PURE__*/_jsxs(GridIconButtonContainer, {
|