@mui/x-data-grid 7.26.0 → 7.27.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 +115 -0
- package/DataGrid/DataGrid.js +8 -0
- package/DataGrid/useDataGridComponent.js +3 -1
- package/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/colDef/gridDateColDef.js +3 -2
- package/colDef/gridSingleSelectColDef.js +2 -2
- package/constants/dataGridPropsDefaultValues.js +1 -0
- package/hooks/core/gridPropsSelectors.d.ts +9 -0
- package/hooks/core/gridPropsSelectors.js +14 -0
- package/hooks/core/index.d.ts +1 -0
- package/hooks/core/index.js +1 -1
- package/hooks/core/useGridInitialization.js +2 -0
- package/hooks/core/useGridProps.d.ts +8 -0
- package/hooks/core/useGridProps.js +18 -0
- package/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/hooks/features/pagination/useGridPaginationModel.d.ts +1 -1
- package/hooks/features/pagination/useGridPaginationModel.js +45 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/hooks/features/rows/useGridRows.js +2 -10
- package/hooks/features/sorting/gridSortingUtils.js +2 -1
- package/hooks/utils/useGridNativeEventListener.d.ts +0 -1
- package/hooks/utils/useGridNativeEventListener.js +12 -22
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/locales/bnBD.d.ts +2 -0
- package/locales/bnBD.js +154 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/plPL.js +31 -35
- package/locales/ukUA.js +9 -10
- package/models/api/gridRowApi.d.ts +0 -1
- package/models/gridStateCommunity.d.ts +8 -0
- package/models/props/DataGridProps.d.ts +8 -0
- package/modern/DataGrid/DataGrid.js +8 -0
- package/modern/DataGrid/useDataGridComponent.js +3 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/modern/colDef/gridDateColDef.js +3 -2
- package/modern/colDef/gridSingleSelectColDef.js +2 -2
- package/modern/constants/dataGridPropsDefaultValues.js +1 -0
- package/modern/hooks/core/gridPropsSelectors.js +14 -0
- package/modern/hooks/core/index.js +1 -1
- package/modern/hooks/core/useGridInitialization.js +2 -0
- package/modern/hooks/core/useGridProps.js +18 -0
- package/modern/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/modern/hooks/features/pagination/useGridPaginationModel.js +45 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/modern/hooks/features/rows/useGridRows.js +2 -10
- package/modern/hooks/features/sorting/gridSortingUtils.js +2 -1
- package/modern/hooks/utils/useGridNativeEventListener.js +12 -22
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/locales/bnBD.js +154 -0
- package/modern/locales/index.js +1 -0
- package/modern/locales/plPL.js +31 -35
- package/modern/locales/ukUA.js +9 -10
- package/node/DataGrid/DataGrid.js +8 -0
- package/node/DataGrid/useDataGridComponent.js +3 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +2 -1
- package/node/colDef/gridDateColDef.js +3 -2
- package/node/colDef/gridSingleSelectColDef.js +2 -2
- package/node/constants/dataGridPropsDefaultValues.js +1 -0
- package/node/hooks/core/gridPropsSelectors.js +20 -0
- package/node/hooks/core/index.js +8 -1
- package/node/hooks/core/useGridInitialization.js +2 -0
- package/node/hooks/core/useGridProps.js +28 -0
- package/node/hooks/features/clipboard/useGridClipboard.js +1 -1
- package/node/hooks/features/dimensions/useGridDimensions.js +8 -9
- package/node/hooks/features/pagination/useGridPaginationModel.js +45 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/node/hooks/features/rows/useGridRows.js +2 -10
- package/node/hooks/features/sorting/gridSortingUtils.js +2 -1
- package/node/hooks/utils/useGridNativeEventListener.js +12 -23
- package/node/index.js +1 -1
- package/node/internals/index.js +8 -0
- package/node/locales/bnBD.js +160 -0
- package/node/locales/index.js +11 -0
- package/node/locales/plPL.js +31 -35
- package/node/locales/ukUA.js +9 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,121 @@
|
|
|
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
|
+
## 7.27.1
|
|
7
|
+
|
|
8
|
+
_Feb 25, 2025_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 5 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🐞 Bugfixes
|
|
13
|
+
- 🌍 Add Bangla (bn-BD) locale on the Data Grid and Date Pickers
|
|
14
|
+
|
|
15
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
16
|
+
@nusr, @officialkidmax.
|
|
17
|
+
Following are all team members who have contributed to this release:
|
|
18
|
+
@bernardobelchior, @MBilalShafi, @KenanYusuf.
|
|
19
|
+
|
|
20
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
21
|
+
|
|
22
|
+
### Data Grid
|
|
23
|
+
|
|
24
|
+
#### `@mui/x-data-grid@7.27.1`
|
|
25
|
+
|
|
26
|
+
- [DataGrid] Fix the pagination unexpected behavior when using -1 for "All" rows per page (#16485) @nusr
|
|
27
|
+
- [DataGrid] Extract `getRowId()` API method as a selector (#16574) @MBilalShafi
|
|
28
|
+
- [DataGrid] Fix scrollbars overlapping cells on mount (#16653) @KenanYusuf
|
|
29
|
+
- [l10n] Add Bangla (bn-BD) locale (#16649) @officialkidmax
|
|
30
|
+
|
|
31
|
+
#### `@mui/x-data-grid-pro@7.27.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
32
|
+
|
|
33
|
+
Same changes as in `@mui/x-data-grid@7.27.1`.
|
|
34
|
+
|
|
35
|
+
#### `@mui/x-data-grid-premium@7.27.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
36
|
+
|
|
37
|
+
Same changes as in `@mui/x-data-grid-pro@7.27.1`.
|
|
38
|
+
|
|
39
|
+
### Date and Time Pickers
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-date-pickers@7.27.1`
|
|
42
|
+
|
|
43
|
+
- [l10n] Add Bangla (bn-BD) locale (#16649) @officialkidmax
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-date-pickers-pro@7.27.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
46
|
+
|
|
47
|
+
Same changes as in `@mui/x-date-pickers@7.27.1`.
|
|
48
|
+
|
|
49
|
+
### Charts
|
|
50
|
+
|
|
51
|
+
#### `@mui/x-charts@7.27.1`
|
|
52
|
+
|
|
53
|
+
- [charts] Fix empty series array in pie chart (#16657) @bernardobelchior
|
|
54
|
+
|
|
55
|
+
#### `@mui/x-charts-pro@7.27.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
56
|
+
|
|
57
|
+
Same changes as in `@mui/x-charts@7.27.1`.
|
|
58
|
+
|
|
59
|
+
## 7.27.0
|
|
60
|
+
|
|
61
|
+
_Feb 17, 2025_
|
|
62
|
+
|
|
63
|
+
We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
64
|
+
|
|
65
|
+
- ⚡ Improve Data Grid Excel export serialization performance
|
|
66
|
+
- 🐞 Bugfixes
|
|
67
|
+
- 🌍 Improve Polish (pl-PL) and Ukrainian (uk-UA) locale on the Data Grid
|
|
68
|
+
|
|
69
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
70
|
+
@pawelkula, @Neonin.
|
|
71
|
+
Following are all team members who have contributed to this release:
|
|
72
|
+
@cherniavskii, @JCQuintas, @oliviertassinari, @arminmeh and @LukasTy
|
|
73
|
+
|
|
74
|
+
### Data Grid
|
|
75
|
+
|
|
76
|
+
#### `@mui/x-data-grid@7.27.0`
|
|
77
|
+
|
|
78
|
+
- [DataGrid] Add `resetPageOnSortFilter` prop that resets the page after sorting and filtering (#16580) @arminmeh
|
|
79
|
+
- [DataGrid] Avoid `undefined` value for pagination `rowCount` (#16558) @cherniavskii
|
|
80
|
+
- [l10n] Improve Polish (pl-PL) locale (#16594) @pawelkula
|
|
81
|
+
- [l10n] Improve Ukrainian (uk-UA) locale (#16593) @Neonin
|
|
82
|
+
|
|
83
|
+
#### `@mui/x-data-grid-pro@7.27.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
84
|
+
|
|
85
|
+
Same changes as in `@mui/x-data-grid@7.27.0`.
|
|
86
|
+
|
|
87
|
+
#### `@mui/x-data-grid-premium@7.27.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
88
|
+
|
|
89
|
+
Same changes as in `@mui/x-data-grid-pro@7.27.0`, plus:
|
|
90
|
+
|
|
91
|
+
- [DataGridPremium] Fix Excel export Web Worker demo not working in dev mode (#16532) @cherniavskii
|
|
92
|
+
- [DataGridPremium] Improve Excel export serialization performance (#16545) @cherniavskii
|
|
93
|
+
- [DataGridPremium] Namespace Excel export worker (#16539) @oliviertassinari
|
|
94
|
+
|
|
95
|
+
### Date and Time Pickers
|
|
96
|
+
|
|
97
|
+
#### `@mui/x-date-pickers@7.27.0`
|
|
98
|
+
|
|
99
|
+
Internal changes.
|
|
100
|
+
|
|
101
|
+
#### `@mui/x-date-pickers-pro@7.27.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
102
|
+
|
|
103
|
+
Same changes as in `@mui/x-date-pickers@7.27.0`, plus:
|
|
104
|
+
|
|
105
|
+
- [DateRangePicker] Avoid unnecessary field section focusing (#16569) @LukasTy
|
|
106
|
+
|
|
107
|
+
### Charts
|
|
108
|
+
|
|
109
|
+
#### `@mui/x-charts@7.27.0`
|
|
110
|
+
|
|
111
|
+
Internal changes.
|
|
112
|
+
|
|
113
|
+
#### `@mui/x-charts-pro@7.27.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
114
|
+
|
|
115
|
+
- [charts-pro] Fix automatic type overloads (#16579) @JCQuintas
|
|
116
|
+
|
|
117
|
+
### Core
|
|
118
|
+
|
|
119
|
+
- [test] Fix Data Grid data source error test on React 18 (#16565) @arminmeh
|
|
120
|
+
|
|
6
121
|
## 7.26.0
|
|
7
122
|
|
|
8
123
|
_Feb 7, 2025_
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -282,6 +282,8 @@ DataGridRaw.propTypes = {
|
|
|
282
282
|
getRowHeight: PropTypes.func,
|
|
283
283
|
/**
|
|
284
284
|
* Return the id of a given [[GridRowModel]].
|
|
285
|
+
* Ensure the reference of this prop is stable to avoid performance implications.
|
|
286
|
+
* It could be done by either defining the prop outside of the component or by memoizing it.
|
|
285
287
|
*/
|
|
286
288
|
getRowId: PropTypes.func,
|
|
287
289
|
/**
|
|
@@ -661,6 +663,12 @@ DataGridRaw.propTypes = {
|
|
|
661
663
|
* @returns {Promise<R> | R} The final values to update the row.
|
|
662
664
|
*/
|
|
663
665
|
processRowUpdate: PropTypes.func,
|
|
666
|
+
/**
|
|
667
|
+
* If `true`, the page is set to 0 after each sorting or filtering.
|
|
668
|
+
* This prop will be removed in the next major version and resetting the page will become the default behavior.
|
|
669
|
+
* @default false
|
|
670
|
+
*/
|
|
671
|
+
resetPageOnSortFilter: PropTypes.bool,
|
|
664
672
|
/**
|
|
665
673
|
* The milliseconds throttle delay for resizing the grid.
|
|
666
674
|
* @default 60
|
|
@@ -29,6 +29,7 @@ import { useGridVirtualization, virtualizationStateInitializer } from "../hooks/
|
|
|
29
29
|
import { columnResizeStateInitializer, useGridColumnResize } from "../hooks/features/columnResize/useGridColumnResize.js";
|
|
30
30
|
import { rowSpanningStateInitializer, useGridRowSpanning } from "../hooks/features/rows/useGridRowSpanning.js";
|
|
31
31
|
import { listViewStateInitializer, useGridListView } from "../hooks/features/listView/useGridListView.js";
|
|
32
|
+
import { propsStateInitializer } from "../hooks/core/useGridProps.js";
|
|
32
33
|
export const useDataGridComponent = (inputApiRef, props) => {
|
|
33
34
|
const apiRef = useGridInitialization(inputApiRef, props);
|
|
34
35
|
|
|
@@ -41,10 +42,11 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
41
42
|
/**
|
|
42
43
|
* Register all state initializers here.
|
|
43
44
|
*/
|
|
45
|
+
useGridInitializeState(propsStateInitializer, apiRef, props);
|
|
44
46
|
useGridInitializeState(rowSelectionStateInitializer, apiRef, props);
|
|
45
47
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
46
|
-
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
47
48
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
49
|
+
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
48
50
|
useGridInitializeState(editingStateInitializer, apiRef, props);
|
|
49
51
|
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
50
52
|
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
@@ -4,6 +4,7 @@ import { GridCellCheckboxRenderer } from "../components/columnSelection/GridCell
|
|
|
4
4
|
import { GridHeaderCheckbox } from "../components/columnSelection/GridHeaderCheckbox.js";
|
|
5
5
|
import { selectedIdsLookupSelector } from "../hooks/features/rowSelection/gridRowSelectionSelector.js";
|
|
6
6
|
import { GRID_BOOLEAN_COL_DEF } from "./gridBooleanColDef.js";
|
|
7
|
+
import { gridRowIdSelector } from "../hooks/core/gridPropsSelectors.js";
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
9
|
export const GRID_CHECKBOX_SELECTION_FIELD = '__check__';
|
|
9
10
|
export const GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF, {
|
|
@@ -22,7 +23,7 @@ export const GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF
|
|
|
22
23
|
display: 'flex',
|
|
23
24
|
valueGetter: (value, row, column, apiRef) => {
|
|
24
25
|
const selectionLookup = selectedIdsLookupSelector(apiRef);
|
|
25
|
-
const rowId = apiRef.current.
|
|
26
|
+
const rowId = gridRowIdSelector(apiRef.current.state, row);
|
|
26
27
|
return selectionLookup[rowId] !== undefined;
|
|
27
28
|
},
|
|
28
29
|
renderHeader: params => /*#__PURE__*/_jsx(GridHeaderCheckbox, _extends({}, params)),
|
package/colDef/gridDateColDef.js
CHANGED
|
@@ -3,6 +3,7 @@ import { gridDateComparator } from "../hooks/features/sorting/gridSortingUtils.j
|
|
|
3
3
|
import { getGridDateOperators } from "./gridDateOperators.js";
|
|
4
4
|
import { GRID_STRING_COL_DEF } from "./gridStringColDef.js";
|
|
5
5
|
import { renderEditDateCell } from "../components/cell/GridEditDateCell.js";
|
|
6
|
+
import { gridRowIdSelector } from "../hooks/core/gridPropsSelectors.js";
|
|
6
7
|
function throwIfNotDateObject({
|
|
7
8
|
value,
|
|
8
9
|
columnType,
|
|
@@ -17,7 +18,7 @@ export const gridDateFormatter = (value, row, column, apiRef) => {
|
|
|
17
18
|
if (!value) {
|
|
18
19
|
return '';
|
|
19
20
|
}
|
|
20
|
-
const rowId = apiRef.current.
|
|
21
|
+
const rowId = gridRowIdSelector(apiRef.current.state, row);
|
|
21
22
|
throwIfNotDateObject({
|
|
22
23
|
value,
|
|
23
24
|
columnType: 'date',
|
|
@@ -30,7 +31,7 @@ export const gridDateTimeFormatter = (value, row, column, apiRef) => {
|
|
|
30
31
|
if (!value) {
|
|
31
32
|
return '';
|
|
32
33
|
}
|
|
33
|
-
const rowId = apiRef.current.
|
|
34
|
+
const rowId = gridRowIdSelector(apiRef.current.state, row);
|
|
34
35
|
throwIfNotDateObject({
|
|
35
36
|
value,
|
|
36
37
|
columnType: 'dateTime',
|
|
@@ -4,6 +4,7 @@ import { renderEditSingleSelectCell } from "../components/cell/GridEditSingleSel
|
|
|
4
4
|
import { getGridSingleSelectOperators } from "./gridSingleSelectOperators.js";
|
|
5
5
|
import { getValueOptions, isSingleSelectColDef } from "../components/panel/filterPanel/filterPanelUtils.js";
|
|
6
6
|
import { isObject } from "../utils/utils.js";
|
|
7
|
+
import { gridRowIdSelector } from "../hooks/core/gridPropsSelectors.js";
|
|
7
8
|
const isArrayOfObjects = options => {
|
|
8
9
|
return typeof options[0] === 'object';
|
|
9
10
|
};
|
|
@@ -18,8 +19,7 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
18
19
|
getOptionLabel: defaultGetOptionLabel,
|
|
19
20
|
getOptionValue: defaultGetOptionValue,
|
|
20
21
|
valueFormatter(value, row, colDef, apiRef) {
|
|
21
|
-
|
|
22
|
-
const rowId = apiRef.current.getRowId(row);
|
|
22
|
+
const rowId = gridRowIdSelector(apiRef.current.state, row);
|
|
23
23
|
if (!isSingleSelectColDef(colDef)) {
|
|
24
24
|
return '';
|
|
25
25
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GridStateCommunity } from '../../models/gridStateCommunity';
|
|
2
|
+
import type { GridRowId, GridRowModel } from '../../models/gridRows';
|
|
3
|
+
/**
|
|
4
|
+
* Get the row id for a given row
|
|
5
|
+
* @param state - The grid state
|
|
6
|
+
* @param {GridRowModel} row - The row to get the id for
|
|
7
|
+
* @returns {GridRowId} The row id
|
|
8
|
+
*/
|
|
9
|
+
export declare const gridRowIdSelector: <State extends GridStateCommunity>(state: State, row: GridRowModel) => GridRowId;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GRID_ID_AUTOGENERATED } from "../features/rows/gridRowsUtils.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the row id for a given row
|
|
5
|
+
* @param state - The grid state
|
|
6
|
+
* @param {GridRowModel} row - The row to get the id for
|
|
7
|
+
* @returns {GridRowId} The row id
|
|
8
|
+
*/
|
|
9
|
+
export const gridRowIdSelector = (state, row) => {
|
|
10
|
+
if (GRID_ID_AUTOGENERATED in row) {
|
|
11
|
+
return row[GRID_ID_AUTOGENERATED];
|
|
12
|
+
}
|
|
13
|
+
return state.props.getRowId ? state.props.getRowId(row) : row.id;
|
|
14
|
+
};
|
package/hooks/core/index.d.ts
CHANGED
package/hooks/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { gridRowIdSelector } from "./gridPropsSelectors.js";
|
|
@@ -6,6 +6,7 @@ import { useGridLocaleText } from "./useGridLocaleText.js";
|
|
|
6
6
|
import { useGridPipeProcessing } from "./pipeProcessing/index.js";
|
|
7
7
|
import { useGridStrategyProcessing } from "./strategyProcessing/index.js";
|
|
8
8
|
import { useGridStateInitialization } from "./useGridStateInitialization.js";
|
|
9
|
+
import { useGridProps } from "./useGridProps.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Initialize the technical pieces of the DataGrid (logger, state, ...) that any DataGrid implementation needs
|
|
@@ -13,6 +14,7 @@ import { useGridStateInitialization } from "./useGridStateInitialization.js";
|
|
|
13
14
|
export const useGridInitialization = (inputApiRef, props) => {
|
|
14
15
|
const privateApiRef = useGridApiInitialization(inputApiRef, props);
|
|
15
16
|
useGridRefs(privateApiRef);
|
|
17
|
+
useGridProps(privateApiRef, props);
|
|
16
18
|
useGridIsRtl(privateApiRef);
|
|
17
19
|
useGridLoggerFactory(privateApiRef, props);
|
|
18
20
|
useGridStateInitialization(privateApiRef);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import type { DataGridProps } from '../../models/props/DataGridProps';
|
|
3
|
+
import type { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
|
|
4
|
+
import type { GridStateInitializer } from '../utils/useGridInitializeState';
|
|
5
|
+
type Props = Pick<DataGridProps, 'getRowId'>;
|
|
6
|
+
export declare const propsStateInitializer: GridStateInitializer<Props>;
|
|
7
|
+
export declare const useGridProps: <PrivateApi extends GridPrivateApiCommon>(apiRef: RefObject<PrivateApi>, props: Props) => void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export const propsStateInitializer = (state, props) => {
|
|
4
|
+
return _extends({}, state, {
|
|
5
|
+
props: {
|
|
6
|
+
getRowId: props.getRowId
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export const useGridProps = (apiRef, props) => {
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
13
|
+
props: {
|
|
14
|
+
getRowId: props.getRowId
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
}, [apiRef, props.getRowId]);
|
|
18
|
+
};
|
|
@@ -91,6 +91,6 @@ export const useGridClipboard = (apiRef, props) => {
|
|
|
91
91
|
apiRef.current.publishEvent('clipboardCopy', textToCopy);
|
|
92
92
|
}
|
|
93
93
|
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
|
|
94
|
-
useGridNativeEventListener(apiRef, apiRef.current.rootElementRef, 'keydown', handleCopy);
|
|
94
|
+
useGridNativeEventListener(apiRef, () => apiRef.current.rootElementRef.current, 'keydown', handleCopy);
|
|
95
95
|
useGridApiOptionHandler(apiRef, 'clipboardCopy', props.onClipboardCopy);
|
|
96
96
|
};
|
|
@@ -125,8 +125,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
125
125
|
// All the floating point dimensions should be rounded to .1 decimal places to avoid subpixel rendering issues
|
|
126
126
|
// https://github.com/mui/mui-x/issues/9550#issuecomment-1619020477
|
|
127
127
|
// https://github.com/mui/mui-x/issues/15721
|
|
128
|
-
const
|
|
129
|
-
const scrollbarSize = measureScrollbarSize(rootElement, props.scrollbarSize);
|
|
128
|
+
const scrollbarSize = measureScrollbarSize(apiRef.current.mainElementRef.current, props.scrollbarSize);
|
|
130
129
|
const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
131
130
|
const topContainerHeight = headersTotalHeight + rowsMeta.pinnedTopRowsTotalHeight;
|
|
132
131
|
const bottomContainerHeight = rowsMeta.pinnedBottomRowsTotalHeight;
|
|
@@ -287,28 +286,28 @@ function getStaticDimensions(props, apiRef, density, pinnedColumnns) {
|
|
|
287
286
|
};
|
|
288
287
|
}
|
|
289
288
|
const scrollbarSizeCache = new WeakMap();
|
|
290
|
-
function measureScrollbarSize(
|
|
289
|
+
function measureScrollbarSize(element, scrollbarSize) {
|
|
291
290
|
if (scrollbarSize !== undefined) {
|
|
292
291
|
return scrollbarSize;
|
|
293
292
|
}
|
|
294
|
-
if (
|
|
293
|
+
if (element === null) {
|
|
295
294
|
return 0;
|
|
296
295
|
}
|
|
297
|
-
const cachedSize = scrollbarSizeCache.get(
|
|
296
|
+
const cachedSize = scrollbarSizeCache.get(element);
|
|
298
297
|
if (cachedSize !== undefined) {
|
|
299
298
|
return cachedSize;
|
|
300
299
|
}
|
|
301
|
-
const doc = ownerDocument(
|
|
300
|
+
const doc = ownerDocument(element);
|
|
302
301
|
const scrollDiv = doc.createElement('div');
|
|
303
302
|
scrollDiv.style.width = '99px';
|
|
304
303
|
scrollDiv.style.height = '99px';
|
|
305
304
|
scrollDiv.style.position = 'absolute';
|
|
306
305
|
scrollDiv.style.overflow = 'scroll';
|
|
307
306
|
scrollDiv.className = 'scrollDiv';
|
|
308
|
-
|
|
307
|
+
element.appendChild(scrollDiv);
|
|
309
308
|
const size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
310
|
-
|
|
311
|
-
scrollbarSizeCache.set(
|
|
309
|
+
element.removeChild(scrollDiv);
|
|
310
|
+
scrollbarSizeCache.set(element, size);
|
|
312
311
|
return size;
|
|
313
312
|
}
|
|
314
313
|
function areElementSizesEqual(a, b) {
|
|
@@ -8,4 +8,4 @@ export declare const getDerivedPaginationModel: (paginationState: GridPagination
|
|
|
8
8
|
* @requires useGridFilter (state)
|
|
9
9
|
* @requires useGridDimensions (event) - can be after
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridPaginationModel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationModel" | "onPaginationModelChange" | "autoPageSize" | "initialState" | "paginationMode" | "pagination" | "signature" | "rowHeight">) => void;
|
|
11
|
+
export declare const useGridPaginationModel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationModel" | "onPaginationModelChange" | "autoPageSize" | "initialState" | "paginationMode" | "pagination" | "signature" | "rowHeight" | "resetPageOnSortFilter">) => void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { gridFilterModelSelector, gridFilterActiveItemsSelector } from "../filter/gridFilterSelector.js";
|
|
3
4
|
import { gridDensityFactorSelector } from "../density/index.js";
|
|
4
5
|
import { useGridLogger, useGridSelector, useGridApiMethod, useGridApiEventHandler } from "../../utils/index.js";
|
|
6
|
+
import { isDeepEqual, runIf } from "../../../utils/utils.js";
|
|
5
7
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
6
8
|
import { gridPageCountSelector, gridPaginationModelSelector } from "./gridPaginationSelector.js";
|
|
7
9
|
import { getPageCount, defaultPageSize, throwIfPageSizeExceedsTheLimit, getDefaultGridPaginationModel, getValidPage } from "./gridPaginationUtils.js";
|
|
@@ -14,7 +16,7 @@ export const getDerivedPaginationModel = (paginationState, signature, pagination
|
|
|
14
16
|
if (paginationModelProp && (paginationModelProp?.page !== paginationModel.page || paginationModelProp?.pageSize !== paginationModel.pageSize)) {
|
|
15
17
|
paginationModel = paginationModelProp;
|
|
16
18
|
}
|
|
17
|
-
const validPage = getValidPage(paginationModel.page, pageCount);
|
|
19
|
+
const validPage = pageSize === -1 ? 0 : getValidPage(paginationModel.page, pageCount);
|
|
18
20
|
if (validPage !== paginationModel.page) {
|
|
19
21
|
paginationModel = _extends({}, paginationModel, {
|
|
20
22
|
page: validPage
|
|
@@ -31,6 +33,7 @@ export const getDerivedPaginationModel = (paginationState, signature, pagination
|
|
|
31
33
|
export const useGridPaginationModel = (apiRef, props) => {
|
|
32
34
|
const logger = useGridLogger(apiRef, 'useGridPaginationModel');
|
|
33
35
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
36
|
+
const previousFilterModel = React.useRef(gridFilterModelSelector(apiRef));
|
|
34
37
|
const rowHeight = Math.floor(props.rowHeight * densityFactor);
|
|
35
38
|
apiRef.current.registerControlState({
|
|
36
39
|
stateId: 'paginationModel',
|
|
@@ -143,14 +146,55 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
148
|
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
149
|
+
if (paginationModel.page === 0) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
146
152
|
const pageCount = gridPageCountSelector(apiRef);
|
|
147
153
|
if (paginationModel.page > pageCount - 1) {
|
|
148
154
|
apiRef.current.setPage(Math.max(0, pageCount - 1));
|
|
149
155
|
}
|
|
150
156
|
}, [apiRef]);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Goes to the first row of the grid
|
|
160
|
+
*/
|
|
161
|
+
const navigateToStart = React.useCallback(() => {
|
|
162
|
+
const paginationModel = gridPaginationModelSelector(apiRef);
|
|
163
|
+
if (paginationModel.page !== 0) {
|
|
164
|
+
apiRef.current.setPage(0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// If the page was not changed it might be needed to scroll to the top
|
|
168
|
+
const scrollPosition = apiRef.current.getScrollPosition();
|
|
169
|
+
if (scrollPosition.top !== 0) {
|
|
170
|
+
apiRef.current.scroll({
|
|
171
|
+
top: 0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}, [apiRef]);
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Resets the page only if the active items or quick filter has changed from the last time.
|
|
178
|
+
* This is to avoid resetting the page when the filter model is changed
|
|
179
|
+
* because of and update of the operator from an item that does not have the value
|
|
180
|
+
* or reseting when the filter panel is just opened
|
|
181
|
+
*/
|
|
182
|
+
const handleFilterModelChange = React.useCallback(filterModel => {
|
|
183
|
+
const currentActiveFilters = _extends({}, filterModel, {
|
|
184
|
+
// replace items with the active items
|
|
185
|
+
items: gridFilterActiveItemsSelector(apiRef)
|
|
186
|
+
});
|
|
187
|
+
if (isDeepEqual(currentActiveFilters, previousFilterModel.current)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
previousFilterModel.current = currentActiveFilters;
|
|
191
|
+
navigateToStart();
|
|
192
|
+
}, [apiRef, navigateToStart]);
|
|
151
193
|
useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
|
|
152
194
|
useGridApiEventHandler(apiRef, 'paginationModelChange', handlePaginationModelChange);
|
|
153
195
|
useGridApiEventHandler(apiRef, 'rowCountChange', handleRowCountChange);
|
|
196
|
+
useGridApiEventHandler(apiRef, 'sortModelChange', runIf(props.resetPageOnSortFilter, navigateToStart));
|
|
197
|
+
useGridApiEventHandler(apiRef, 'filterModelChange', runIf(props.resetPageOnSortFilter, handleFilterModelChange));
|
|
154
198
|
|
|
155
199
|
/**
|
|
156
200
|
* EFFECTS
|
|
@@ -114,7 +114,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
114
114
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
|
-
const rowNode = apiRef
|
|
117
|
+
const rowNode = gridRowTreeSelector(apiRef)[id];
|
|
118
118
|
if (rowNode?.type === 'footer' || rowNode?.type === 'pinnedRow') {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
@@ -338,7 +338,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
338
338
|
return;
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
|
-
const rowNode = apiRef
|
|
341
|
+
const rowNode = gridRowTreeSelector(apiRef)[params.id];
|
|
342
342
|
if (rowNode.type === 'pinnedRow') {
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
@@ -4,6 +4,7 @@ import useLazyRef from '@mui/utils/useLazyRef';
|
|
|
4
4
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
5
5
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
6
6
|
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from "./gridRowsSelector.js";
|
|
7
|
+
import { gridRowIdSelector } from "../../core/gridPropsSelectors.js";
|
|
7
8
|
import { useTimeout } from "../../utils/useTimeout.js";
|
|
8
9
|
import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
10
|
import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
@@ -55,16 +56,7 @@ export const useGridRows = (apiRef, props) => {
|
|
|
55
56
|
}
|
|
56
57
|
return null;
|
|
57
58
|
}, [apiRef]);
|
|
58
|
-
const
|
|
59
|
-
const getRowId = React.useCallback(row => {
|
|
60
|
-
if (GRID_ID_AUTOGENERATED in row) {
|
|
61
|
-
return row[GRID_ID_AUTOGENERATED];
|
|
62
|
-
}
|
|
63
|
-
if (getRowIdProp) {
|
|
64
|
-
return getRowIdProp(row);
|
|
65
|
-
}
|
|
66
|
-
return row.id;
|
|
67
|
-
}, [getRowIdProp]);
|
|
59
|
+
const getRowId = React.useCallback(row => gridRowIdSelector(apiRef.current.state, row), [apiRef]);
|
|
68
60
|
const throttledRowsChange = React.useCallback(({
|
|
69
61
|
cache,
|
|
70
62
|
throttle
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
3
|
+
import { gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
3
4
|
export const sanitizeSortModel = (model, disableMultipleColumnsSorting) => {
|
|
4
5
|
if (disableMultipleColumnsSorting && model.length > 1) {
|
|
5
6
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -39,7 +40,7 @@ const parseSortItem = (sortItem, apiRef) => {
|
|
|
39
40
|
const getSortCellParams = id => ({
|
|
40
41
|
id,
|
|
41
42
|
field: column.field,
|
|
42
|
-
rowNode: apiRef
|
|
43
|
+
rowNode: gridRowTreeSelector(apiRef)[id],
|
|
43
44
|
value: apiRef.current.getCellValue(id, column.field),
|
|
44
45
|
api: apiRef.current
|
|
45
46
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
3
2
|
import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
|
|
4
3
|
export declare const useGridNativeEventListener: <PrivateApi extends GridPrivateApiCommon, K extends keyof HTMLElementEventMap>(apiRef: RefObject<PrivateApi>, ref: React.RefObject<HTMLDivElement | null> | (() => HTMLElement | undefined | null), eventName: K, handler?: (event: HTMLElementEventMap[K]) => any, options?: AddEventListenerOptions) => void;
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { isFunction } from "../../utils/utils.js";
|
|
3
1
|
import { useGridLogger } from "./useGridLogger.js";
|
|
2
|
+
import { useGridApiOptionHandler } from "./useGridApiEventHandler.js";
|
|
4
3
|
export const useGridNativeEventListener = (apiRef, ref, eventName, handler, options) => {
|
|
5
4
|
const logger = useGridLogger(apiRef, 'useNativeEventListener');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return handlerRef.current && handlerRef.current(event);
|
|
11
|
-
}, []);
|
|
12
|
-
React.useEffect(() => {
|
|
13
|
-
handlerRef.current = handler;
|
|
14
|
-
}, [handler]);
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
if (targetElement && eventName && !added) {
|
|
17
|
-
logger.debug(`Binding native ${eventName} event`);
|
|
18
|
-
targetElement.addEventListener(eventName, wrapHandler, options);
|
|
19
|
-
setAdded(true);
|
|
20
|
-
const unsubscribe = () => {
|
|
21
|
-
logger.debug(`Clearing native ${eventName} event`);
|
|
22
|
-
targetElement.removeEventListener(eventName, wrapHandler, options);
|
|
23
|
-
};
|
|
24
|
-
apiRef.current.subscribeEvent('unmount', unsubscribe);
|
|
5
|
+
useGridApiOptionHandler(apiRef, 'rootMount', () => {
|
|
6
|
+
const targetElement = typeof ref === 'function' ? ref() : ref.current;
|
|
7
|
+
if (!targetElement || !eventName || !handler) {
|
|
8
|
+
return undefined;
|
|
25
9
|
}
|
|
26
|
-
|
|
10
|
+
logger.debug(`Binding native ${eventName} event`);
|
|
11
|
+
targetElement.addEventListener(eventName, handler, options);
|
|
12
|
+
return () => {
|
|
13
|
+
logger.debug(`Clearing native ${eventName} event`);
|
|
14
|
+
targetElement.removeEventListener(eventName, handler, options);
|
|
15
|
+
};
|
|
16
|
+
});
|
|
27
17
|
};
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type { GridPinnedRowsProps } from '../components/GridPinnedRows';
|
|
|
7
7
|
export { GridHeaders } from '../components/GridHeaders';
|
|
8
8
|
export { GridBaseColumnHeaders } from '../components/columnHeaders/GridBaseColumnHeaders';
|
|
9
9
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from '../constants/defaultGridSlotsComponents';
|
|
10
|
+
export { propsStateInitializer } from '../hooks/core/useGridProps';
|
|
10
11
|
export { getGridFilter } from '../components/panel/filterPanel/GridFilterPanel';
|
|
11
12
|
export { useGridRegisterPipeProcessor } from '../hooks/core/pipeProcessing';
|
|
12
13
|
export type { GridPipeProcessor } from '../hooks/core/pipeProcessing';
|
package/internals/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { GridVirtualScrollerRenderZone } from "../components/virtualization/Grid
|
|
|
4
4
|
export { GridHeaders } from "../components/GridHeaders.js";
|
|
5
5
|
export { GridBaseColumnHeaders } from "../components/columnHeaders/GridBaseColumnHeaders.js";
|
|
6
6
|
export { DATA_GRID_DEFAULT_SLOTS_COMPONENTS } from "../constants/defaultGridSlotsComponents.js";
|
|
7
|
+
export { propsStateInitializer } from "../hooks/core/useGridProps.js";
|
|
7
8
|
export { getGridFilter } from "../components/panel/filterPanel/GridFilterPanel.js";
|
|
8
9
|
export { useGridRegisterPipeProcessor } from "../hooks/core/pipeProcessing/index.js";
|
|
9
10
|
export { useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY } from "../hooks/core/strategyProcessing/index.js";
|