@mui/x-data-grid-pro 6.14.0 → 6.15.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 +83 -0
- package/DataGridPro/DataGridPro.js +20 -0
- package/DataGridPro/useDataGridProComponent.js +3 -1
- package/DataGridPro/useDataGridProProps.js +2 -0
- package/components/headerFiltering/GridHeaderFilterCell.js +16 -2
- package/components/headerFiltering/GridHeaderFilterMenu.js +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +19 -2
- package/hooks/features/columnPinning/useGridColumnPinning.js +1 -44
- package/hooks/features/columnResize/gridColumnResizeApi.d.ts +44 -0
- package/hooks/features/columnResize/gridColumnResizeApi.js +10 -0
- package/hooks/features/columnResize/index.d.ts +1 -0
- package/hooks/features/columnResize/index.js +2 -1
- package/hooks/features/columnResize/useGridColumnResize.d.ts +1 -1
- package/hooks/features/columnResize/useGridColumnResize.js +236 -56
- package/index.js +1 -1
- package/legacy/DataGridPro/DataGridPro.js +20 -0
- package/legacy/DataGridPro/useDataGridProComponent.js +3 -1
- package/legacy/DataGridPro/useDataGridProProps.js +2 -0
- package/legacy/components/headerFiltering/GridHeaderFilterCell.js +17 -3
- package/legacy/components/headerFiltering/GridHeaderFilterMenu.js +1 -1
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +22 -8
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +1 -44
- package/legacy/hooks/features/columnResize/gridColumnResizeApi.js +10 -0
- package/legacy/hooks/features/columnResize/index.js +2 -1
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +279 -57
- package/legacy/index.js +1 -1
- package/legacy/models/index.js +1 -0
- package/legacy/utils/domUtils.js +12 -0
- package/legacy/utils/releaseInfo.js +1 -1
- package/models/dataGridProProps.d.ts +15 -0
- package/models/gridApiPro.d.ts +2 -2
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/modern/DataGridPro/DataGridPro.js +20 -0
- package/modern/DataGridPro/useDataGridProComponent.js +3 -1
- package/modern/DataGridPro/useDataGridProProps.js +2 -0
- package/modern/components/headerFiltering/GridHeaderFilterCell.js +15 -2
- package/modern/components/headerFiltering/GridHeaderFilterMenu.js +1 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +18 -1
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +1 -43
- package/modern/hooks/features/columnResize/gridColumnResizeApi.js +10 -0
- package/modern/hooks/features/columnResize/index.js +2 -1
- package/modern/hooks/features/columnResize/useGridColumnResize.js +225 -52
- package/modern/index.js +1 -1
- package/modern/models/index.js +1 -0
- package/modern/utils/domUtils.js +10 -0
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPro/DataGridPro.js +20 -0
- package/node/DataGridPro/useDataGridProComponent.js +2 -0
- package/node/DataGridPro/useDataGridProProps.js +2 -0
- package/node/components/headerFiltering/GridHeaderFilterCell.js +15 -2
- package/node/components/headerFiltering/GridHeaderFilterMenu.js +1 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +18 -1
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +0 -42
- package/node/hooks/features/columnResize/gridColumnResizeApi.js +17 -0
- package/node/hooks/features/columnResize/index.js +11 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +222 -49
- package/node/index.js +1 -1
- package/node/models/index.js +11 -0
- package/node/utils/domUtils.js +12 -0
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +2 -2
- package/utils/domUtils.d.ts +2 -0
- package/utils/domUtils.js +10 -0
- package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,89 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 6.15.0
|
|
7
|
+
|
|
8
|
+
_Sep 22, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🚀 Implement columns auto-sizing (#10180) @romgrk
|
|
13
|
+
- 🎁 Add support for `getRowsToExport` option to print export on the data grid (#10084) @zreecespieces
|
|
14
|
+
- 🌍 Improve Finnish (fi-FI) locale
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
- 📚 Documentation improvements
|
|
17
|
+
|
|
18
|
+
### Data Grid
|
|
19
|
+
|
|
20
|
+
#### `@mui/x-data-grid@6.15.0`
|
|
21
|
+
|
|
22
|
+
- [DataGrid] Add support for `getRowsToExport` option to print export (#10084) @zreecespieces
|
|
23
|
+
- [DataGrid] Fix dev warning about `InputLabelProps` (#10413) @romgrk
|
|
24
|
+
- [DataGrid] Refactor `GridMenu` prop `onClickAway` to `onClose` (#10411) @romgrk
|
|
25
|
+
- [DataGrid] Restore focus after `GridMenu` closes (#10412) @romgrk
|
|
26
|
+
- [DataGrid] Fix typing of `GridActionsCellItem` (#10344) @romgrk
|
|
27
|
+
- [DataGrid] Hide `eval` from bundlers (#10329) @romgrk
|
|
28
|
+
- [DataGrid] Add `border: 0` to unmounted focused cell to avoid layout shifts in that row (#10318) @lauri865
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-pro@6.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid@6.15.0`, plus:
|
|
33
|
+
|
|
34
|
+
- [DataGridPro] Implement columns auto-sizing (#10180) @romgrk
|
|
35
|
+
- [DataGridPro] Fix keyboard navigation issue in header filters (#10358) @MBilalShafi
|
|
36
|
+
- [DataGridPro] Add missing row hover styles (#10252) @cherniavskii
|
|
37
|
+
- [DataGridPro] Make default filter items have stable references in header filters (#10338) @MBilalShafi
|
|
38
|
+
|
|
39
|
+
#### `@mui/x-data-grid-premium@6.15.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
40
|
+
|
|
41
|
+
Same changes as in `@mui/x-data-grid-pro@6.15.0`.
|
|
42
|
+
|
|
43
|
+
### Date Pickers
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-date-pickers@6.15.0`
|
|
46
|
+
|
|
47
|
+
- [pickers] Support tokens without spaces (#10185) @alexfauquette
|
|
48
|
+
- [l10n] Improve Finnish (fi-FI) locale (#10346) @samijouppila
|
|
49
|
+
|
|
50
|
+
#### `@mui/x-date-pickers-pro@6.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
51
|
+
|
|
52
|
+
Same changes as in `@mui/x-date-pickers@6.15.0`.
|
|
53
|
+
|
|
54
|
+
### Charts / `@mui/x-charts@6.0.0-alpha.12`
|
|
55
|
+
|
|
56
|
+
- [charts] Fix sparkline scale and rendering (#10402) @alexfauquette
|
|
57
|
+
- [charts] Remove components from `@mui/material` (#10115) @alexfauquette
|
|
58
|
+
|
|
59
|
+
### Tree View / `@mui/x-tree-view@6.0.0-alpha.4`
|
|
60
|
+
|
|
61
|
+
- [TreeView] Split features into plugins to prepare for Pro version (#10123) @flaviendelangle
|
|
62
|
+
|
|
63
|
+
### Docs
|
|
64
|
+
|
|
65
|
+
- [docs] Add charts documentation pages to complete pricing table (#10394) @alexfauquette
|
|
66
|
+
- [docs] Add missing MIT packages on the Licensing page (#10348) @flaviendelangle
|
|
67
|
+
- [docs] Clearer component pattern @oliviertassinari
|
|
68
|
+
- [docs] Easier to understand demo (#10370) @oliviertassinari
|
|
69
|
+
- [docs] Fix `301` to Material UI @oliviertassinari
|
|
70
|
+
- [docs] Improve the column visibility section (#10327) @MBilalShafi
|
|
71
|
+
- [docs] Improve the documentation section `rowIdentifier` (#10326) @MBilalShafi
|
|
72
|
+
- [docs] Improve pickers localization documentation (#10202) @flaviendelangle
|
|
73
|
+
- [docs] Polish typescript ref usage (#10359) @oliviertassinari
|
|
74
|
+
- [docs] Improve charts tooltip wording (#10406) @alexfauquette
|
|
75
|
+
|
|
76
|
+
### Core
|
|
77
|
+
|
|
78
|
+
- [core] Cleanup GitHub issues template (#10372) @romgrk
|
|
79
|
+
- [core] Fix Circle CI OOM (#10385) @romgrk
|
|
80
|
+
- [core] Improve sleep test helper @oliviertassinari
|
|
81
|
+
- [core] Remove unwanted prefixes @oliviertassinari
|
|
82
|
+
- [core] Remove duplicate label @oliviertassinari
|
|
83
|
+
- [core] Simplify source @oliviertassinari
|
|
84
|
+
- [core] Upgrade monorepo (#10425) @cherniavskii
|
|
85
|
+
- [core] Upgrade monorepo to have the new typescript-to-proptype (#10224) @flaviendelangle
|
|
86
|
+
- [test] Do not use deprecated adapter methods (#10416) @flaviendelangle
|
|
87
|
+
- [test] Name test suites according to sentence case (#10429) @alexfauquette
|
|
88
|
+
|
|
6
89
|
## 6.14.0
|
|
7
90
|
|
|
8
91
|
_Sep 14, 2023_
|
|
@@ -69,6 +69,21 @@ DataGridProRaw.propTypes = {
|
|
|
69
69
|
* @default false
|
|
70
70
|
*/
|
|
71
71
|
autoPageSize: PropTypes.bool,
|
|
72
|
+
/**
|
|
73
|
+
* If `true`, columns are autosized after the datagrid is mounted.
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
autosizeOnMount: PropTypes.bool,
|
|
77
|
+
/**
|
|
78
|
+
* The options for autosize when user-initiated.
|
|
79
|
+
*/
|
|
80
|
+
autosizeOptions: PropTypes.shape({
|
|
81
|
+
columns: PropTypes.arrayOf(PropTypes.string),
|
|
82
|
+
expand: PropTypes.bool,
|
|
83
|
+
includeHeaders: PropTypes.bool,
|
|
84
|
+
includeOutliers: PropTypes.bool,
|
|
85
|
+
outliersFactor: PropTypes.number
|
|
86
|
+
}),
|
|
72
87
|
/**
|
|
73
88
|
* Controls the modes of the cells.
|
|
74
89
|
*/
|
|
@@ -148,6 +163,11 @@ DataGridProRaw.propTypes = {
|
|
|
148
163
|
* The row ids to show the detail panel.
|
|
149
164
|
*/
|
|
150
165
|
detailPanelExpandedRowIds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired),
|
|
166
|
+
/**
|
|
167
|
+
* If `true`, column autosizing on header separator double-click is disabled.
|
|
168
|
+
* @default false
|
|
169
|
+
*/
|
|
170
|
+
disableAutosize: PropTypes.bool,
|
|
151
171
|
/**
|
|
152
172
|
* If `true`, the filtering will only be applied to the top level rows when grouping rows with the `treeData` prop.
|
|
153
173
|
* @default false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, editingStateInitializer, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridRowSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridRowSelectionPreProcessors, useGridColumnSpanning, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, rowSelectionStateInitializer, useGridColumnGrouping, columnGroupsStateInitializer, headerFilteringStateInitializer, useGridHeaderFiltering } from '@mui/x-data-grid/internals';
|
|
1
|
+
import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, editingStateInitializer, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridRowSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridRowSelectionPreProcessors, useGridColumnSpanning, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, rowSelectionStateInitializer, useGridColumnGrouping, columnGroupsStateInitializer, headerFilteringStateInitializer, useGridHeaderFiltering, virtualizationStateInitializer, useGridVirtualization } from '@mui/x-data-grid/internals';
|
|
2
2
|
// Pro-only features
|
|
3
3
|
import { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
|
|
4
4
|
import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
@@ -54,6 +54,7 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
54
54
|
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
55
55
|
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
56
56
|
useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
|
|
57
|
+
useGridInitializeState(virtualizationStateInitializer, apiRef, props);
|
|
57
58
|
useGridHeaderFiltering(apiRef, props);
|
|
58
59
|
useGridTreeData(apiRef);
|
|
59
60
|
useGridKeyboardNavigation(apiRef, props);
|
|
@@ -87,5 +88,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
87
88
|
useGridDimensions(apiRef, props);
|
|
88
89
|
useGridEvents(apiRef, props);
|
|
89
90
|
useGridStatePersistence(apiRef);
|
|
91
|
+
useGridVirtualization(apiRef, props);
|
|
90
92
|
return apiRef;
|
|
91
93
|
};
|
|
@@ -12,6 +12,8 @@ export const DATA_GRID_PRO_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PROPS_D
|
|
|
12
12
|
scrollEndThreshold: 80,
|
|
13
13
|
treeData: false,
|
|
14
14
|
defaultGroupingExpansionDepth: 0,
|
|
15
|
+
autosizeOnMount: false,
|
|
16
|
+
disableAutosize: false,
|
|
15
17
|
disableColumnPinning: false,
|
|
16
18
|
keepColumnPositionIfDraggedOutside: false,
|
|
17
19
|
disableChildrenFiltering: false,
|
|
@@ -130,7 +130,7 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
130
130
|
}, [apiRef, colDef.field]);
|
|
131
131
|
const onMouseDown = React.useCallback(event => {
|
|
132
132
|
if (!hasFocus) {
|
|
133
|
-
if (inputRef.current) {
|
|
133
|
+
if (inputRef.current && inputRef.current.contains(event.target)) {
|
|
134
134
|
inputRef.current.focus();
|
|
135
135
|
}
|
|
136
136
|
apiRef.current.setColumnHeaderFilterFocus(colDef.field, event);
|
|
@@ -172,7 +172,21 @@ const GridHeaderFilterCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
172
172
|
inputRef: inputRef,
|
|
173
173
|
applyValue: applyFilterChanges,
|
|
174
174
|
onFocus: () => apiRef.current.startHeaderFilterEditMode(colDef.field),
|
|
175
|
-
onBlur:
|
|
175
|
+
onBlur: event => {
|
|
176
|
+
var _event$relatedTarget;
|
|
177
|
+
apiRef.current.stopHeaderFilterEditMode();
|
|
178
|
+
// Blurring an input element should reset focus state only if `relatedTarget` is not the header filter cell
|
|
179
|
+
if (!((_event$relatedTarget = event.relatedTarget) != null && _event$relatedTarget.className.includes('columnHeader'))) {
|
|
180
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
181
|
+
focus: {
|
|
182
|
+
cell: null,
|
|
183
|
+
columnHeader: null,
|
|
184
|
+
columnHeaderFilter: null,
|
|
185
|
+
columnGroupHeader: null
|
|
186
|
+
}
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
},
|
|
176
190
|
label: capitalize(label),
|
|
177
191
|
placeholder: "",
|
|
178
192
|
isFilterActive: isFilterActive,
|
|
@@ -26,6 +26,7 @@ const GridHeaderFilterRow = styled('div', {
|
|
|
26
26
|
})(() => ({
|
|
27
27
|
display: 'flex'
|
|
28
28
|
}));
|
|
29
|
+
const filterItemsCache = Object.create(null);
|
|
29
30
|
export const useGridColumnHeaders = props => {
|
|
30
31
|
const apiRef = useGridPrivateApiContext();
|
|
31
32
|
const {
|
|
@@ -53,6 +54,22 @@ export const useGridColumnHeaders = props => {
|
|
|
53
54
|
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
54
55
|
const totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps.columnHeaderHeight) + (disableHeaderFiltering ? 0 : headerHeight);
|
|
55
56
|
const columnHeaderFilterFocus = useGridSelector(apiRef, unstable_gridFocusColumnHeaderFilterSelector);
|
|
57
|
+
const getFilterItem = React.useCallback(colDef => {
|
|
58
|
+
const filterModelItem = filterModel == null ? void 0 : filterModel.items.find(it => it.field === colDef.field && it.operator !== 'isAnyOf');
|
|
59
|
+
if (filterModelItem != null) {
|
|
60
|
+
// there's a valid `filterModelItem` for this column
|
|
61
|
+
return filterModelItem;
|
|
62
|
+
}
|
|
63
|
+
const defaultCachedItem = filterItemsCache[colDef.field];
|
|
64
|
+
if (defaultCachedItem != null) {
|
|
65
|
+
// there's a cached `defaultItem` for this column
|
|
66
|
+
return defaultCachedItem;
|
|
67
|
+
}
|
|
68
|
+
// there's no cached `defaultItem` for this column, let's generate one and cache it
|
|
69
|
+
const defaultItem = getGridFilter(colDef);
|
|
70
|
+
filterItemsCache[colDef.field] = defaultItem;
|
|
71
|
+
return defaultItem;
|
|
72
|
+
}, [filterModel]);
|
|
56
73
|
const getColumnFilters = (params, other = {}) => {
|
|
57
74
|
if (disableHeaderFiltering) {
|
|
58
75
|
return null;
|
|
@@ -67,7 +84,7 @@ export const useGridColumnHeaders = props => {
|
|
|
67
84
|
} = columnsToRender;
|
|
68
85
|
const filters = [];
|
|
69
86
|
for (let i = 0; i < renderedColumns.length; i += 1) {
|
|
70
|
-
var _colDef$filterOperato, _colDef$filterOperato2,
|
|
87
|
+
var _colDef$filterOperato, _colDef$filterOperato2, _rootProps$slotProps;
|
|
71
88
|
const colDef = renderedColumns[i];
|
|
72
89
|
const columnIndex = firstColumnToRender + i;
|
|
73
90
|
const hasFocus = (columnHeaderFilterFocus == null ? void 0 : columnHeaderFilterFocus.field) === colDef.field;
|
|
@@ -81,7 +98,7 @@ export const useGridColumnHeaders = props => {
|
|
|
81
98
|
|
|
82
99
|
// TODO: Support for `isAnyOf` operator
|
|
83
100
|
const filterOperators = (_colDef$filterOperato = (_colDef$filterOperato2 = colDef.filterOperators) == null ? void 0 : _colDef$filterOperato2.filter(operator => operator.value !== 'isAnyOf')) != null ? _colDef$filterOperato : [];
|
|
84
|
-
const item = (
|
|
101
|
+
const item = getFilterItem(colDef);
|
|
85
102
|
filters.push( /*#__PURE__*/_jsx(rootProps.slots.headerFilterCell, _extends({
|
|
86
103
|
colIndex: columnIndex,
|
|
87
104
|
height: headerHeight,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useTheme } from '@mui/material/styles';
|
|
4
|
-
import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector,
|
|
4
|
+
import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, useGridApiMethod, useGridApiEventHandler, gridColumnFieldsSelector } from '@mui/x-data-grid';
|
|
5
5
|
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
6
6
|
import { GridPinnedPosition } from './gridColumnPinningInterface';
|
|
7
7
|
import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
|
|
@@ -33,49 +33,6 @@ export const useGridColumnPinning = (apiRef, props) => {
|
|
|
33
33
|
var _props$initialState4;
|
|
34
34
|
const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
|
|
35
35
|
const theme = useTheme();
|
|
36
|
-
// Each visible row (not to be confused with a filter result) is composed of a central .MuiDataGrid-row element
|
|
37
|
-
// and up to two additional .MuiDataGrid-row's, one for the columns pinned to the left and another
|
|
38
|
-
// for those on the right side. When hovering any of these elements, the :hover styles are applied only to
|
|
39
|
-
// the row element that was actually hovered, not its additional siblings. To make it look like a contiguous row,
|
|
40
|
-
// this method adds/removes the .Mui-hovered class to all of the row elements inside one visible row.
|
|
41
|
-
const updateHoveredClassOnSiblingRows = React.useCallback(event => {
|
|
42
|
-
var _pinnedColumns$left$l, _pinnedColumns$left, _pinnedColumns$right$, _pinnedColumns$right;
|
|
43
|
-
if (props.disableColumnPinning) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (!Array.isArray(pinnedColumns.left) && !Array.isArray(pinnedColumns.right)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const nbLeftPinnedColumns = (_pinnedColumns$left$l = (_pinnedColumns$left = pinnedColumns.left) == null ? void 0 : _pinnedColumns$left.length) != null ? _pinnedColumns$left$l : 0;
|
|
50
|
-
const nbRightPinnedColumns = (_pinnedColumns$right$ = (_pinnedColumns$right = pinnedColumns.right) == null ? void 0 : _pinnedColumns$right.length) != null ? _pinnedColumns$right$ : 0;
|
|
51
|
-
if (nbLeftPinnedColumns + nbRightPinnedColumns === 0) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const rowContainer = apiRef.current.virtualScrollerRef.current;
|
|
55
|
-
if (!rowContainer) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const index = event.currentTarget.dataset.rowindex;
|
|
59
|
-
const rowElements = rowContainer.querySelectorAll(`.${gridClasses.row}[data-rowindex="${index}"]`);
|
|
60
|
-
rowElements.forEach(row => {
|
|
61
|
-
// Ignore rows from other grid inside the hovered row
|
|
62
|
-
if (row.closest(`.${gridClasses.virtualScroller}`) === apiRef.current.virtualScrollerRef.current) {
|
|
63
|
-
if (event.type === 'mouseenter') {
|
|
64
|
-
row.classList.add('Mui-hovered');
|
|
65
|
-
} else {
|
|
66
|
-
row.classList.remove('Mui-hovered');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}, [apiRef, pinnedColumns.left, pinnedColumns.right, props.disableColumnPinning]);
|
|
71
|
-
const handleMouseEnter = React.useCallback((params, event) => {
|
|
72
|
-
updateHoveredClassOnSiblingRows(event);
|
|
73
|
-
}, [updateHoveredClassOnSiblingRows]);
|
|
74
|
-
const handleMouseLeave = React.useCallback((params, event) => {
|
|
75
|
-
updateHoveredClassOnSiblingRows(event);
|
|
76
|
-
}, [updateHoveredClassOnSiblingRows]);
|
|
77
|
-
useGridApiEventHandler(apiRef, 'rowMouseEnter', handleMouseEnter);
|
|
78
|
-
useGridApiEventHandler(apiRef, 'rowMouseLeave', handleMouseLeave);
|
|
79
36
|
|
|
80
37
|
/**
|
|
81
38
|
* PRE-PROCESSING
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GridColDef } from '@mui/x-data-grid';
|
|
2
|
+
export declare const DEFAULT_GRID_AUTOSIZE_OPTIONS: {
|
|
3
|
+
includeHeaders: boolean;
|
|
4
|
+
includeOutliers: boolean;
|
|
5
|
+
outliersFactor: number;
|
|
6
|
+
expand: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type GridAutosizeOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* The columns to autosize. By default, applies to all columns.
|
|
11
|
+
*/
|
|
12
|
+
columns?: GridColDef['field'][];
|
|
13
|
+
/**
|
|
14
|
+
* If true, include the header widths in the calculation.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
includeHeaders?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* If true, width outliers will be ignored.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
includeOutliers?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The IQR factor range to detect outliers.
|
|
25
|
+
* @default 1.5
|
|
26
|
+
*/
|
|
27
|
+
outliersFactor?: number;
|
|
28
|
+
/**
|
|
29
|
+
* If the total width is less than the available width, expand columns to fill it.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
expand?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The Resize API interface that is available in the grid `apiRef`.
|
|
36
|
+
*/
|
|
37
|
+
export interface GridColumnResizeApi {
|
|
38
|
+
/**
|
|
39
|
+
* Auto-size the columns of the grid based on the cells' content and the space available.
|
|
40
|
+
* @param {GridAutosizeOptions} options The autosizing options
|
|
41
|
+
* @returns {Promise} A promise that resolves when autosizing is completed
|
|
42
|
+
*/
|
|
43
|
+
autosizeColumns: (options?: GridAutosizeOptions) => Promise<void>;
|
|
44
|
+
}
|
|
@@ -7,4 +7,4 @@ export declare const columnResizeStateInitializer: GridStateInitializer;
|
|
|
7
7
|
* @requires useGridColumns (method, event)
|
|
8
8
|
* TODO: improve experience for last column
|
|
9
9
|
*/
|
|
10
|
-
export declare const useGridColumnResize: (apiRef: React.MutableRefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, 'onColumnResize' | 'onColumnWidthChange'>) => void;
|
|
10
|
+
export declare const useGridColumnResize: (apiRef: React.MutableRefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, 'autosizeOptions' | 'autosizeOnMount' | 'disableAutosize' | 'onColumnResize' | 'onColumnWidthChange'>) => void;
|