@mui/x-data-grid 7.0.0-beta.0 → 7.0.0-beta.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 +247 -0
- package/DataGrid/useDataGridComponent.js +1 -1
- package/colDef/gridBooleanColDef.js +3 -6
- package/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/colDef/gridDateColDef.d.ts +3 -4
- package/colDef/gridDateColDef.js +10 -16
- package/colDef/gridNumericColDef.js +1 -3
- package/colDef/gridSingleSelectColDef.js +7 -12
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/columnsManagement/GridColumnsManagement.d.ts +7 -0
- package/components/columnsManagement/GridColumnsManagement.js +26 -21
- package/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/hooks/features/editing/useGridCellEditing.js +2 -5
- package/hooks/features/editing/useGridRowEditing.js +2 -5
- package/hooks/features/filter/gridFilterUtils.js +1 -1
- package/hooks/features/rows/useGridParamsApi.d.ts +1 -2
- package/hooks/features/rows/useGridParamsApi.js +14 -49
- package/index.js +1 -1
- package/legacy/DataGrid/useDataGridComponent.js +1 -1
- package/legacy/colDef/gridBooleanColDef.js +3 -5
- package/legacy/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/legacy/colDef/gridDateColDef.js +10 -14
- package/legacy/colDef/gridNumericColDef.js +1 -2
- package/legacy/colDef/gridSingleSelectColDef.js +7 -10
- package/legacy/components/cell/GridEditInputCell.js +1 -1
- package/legacy/components/columnsManagement/GridColumnsManagement.js +38 -31
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/legacy/hooks/features/editing/useGridCellEditing.js +2 -5
- package/legacy/hooks/features/editing/useGridRowEditing.js +2 -5
- package/legacy/hooks/features/filter/gridFilterUtils.js +2 -2
- package/legacy/hooks/features/rows/useGridParamsApi.js +14 -47
- package/legacy/index.js +1 -1
- package/legacy/locales/heIL.js +7 -8
- package/locales/heIL.js +7 -8
- package/models/colDef/gridColDef.d.ts +11 -17
- package/models/colDef/index.d.ts +1 -1
- package/models/params/gridCellParams.d.ts +0 -26
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/colDef/gridBooleanColDef.js +3 -6
- package/modern/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/modern/colDef/gridDateColDef.js +10 -16
- package/modern/colDef/gridNumericColDef.js +1 -3
- package/modern/colDef/gridSingleSelectColDef.js +7 -12
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/columnsManagement/GridColumnsManagement.js +26 -21
- package/modern/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +2 -5
- package/modern/hooks/features/editing/useGridRowEditing.js +2 -5
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/rows/useGridParamsApi.js +14 -47
- package/modern/index.js +1 -1
- package/modern/locales/heIL.js +7 -8
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/colDef/gridBooleanColDef.js +3 -6
- package/node/colDef/gridCheckboxSelectionColDef.js +4 -3
- package/node/colDef/gridDateColDef.js +13 -19
- package/node/colDef/gridNumericColDef.js +1 -3
- package/node/colDef/gridSingleSelectColDef.js +7 -12
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/columnsManagement/GridColumnsManagement.js +26 -21
- package/node/hooks/features/columns/useGridColumnSpanning.js +3 -1
- package/node/hooks/features/editing/useGridCellEditing.js +2 -5
- package/node/hooks/features/editing/useGridRowEditing.js +2 -5
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/rows/useGridParamsApi.js +14 -47
- package/node/index.js +1 -1
- package/node/locales/heIL.js +7 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,169 @@
|
|
|
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.0.0-beta.1
|
|
7
|
+
|
|
8
|
+
_Feb 1, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🏃 Improve the filtering performance of the Data Grid by changing the `GridColDef` methods signatures (#11573) @cherniavskii
|
|
13
|
+
- 🎁 The Line Chart component now has animation by default (#11620) @alexfauquette
|
|
14
|
+
- 🚀 All charts have click handlers (#11411) @alexfauquette
|
|
15
|
+
Test their respective documentation demonstrations to know more about the data format:
|
|
16
|
+
|
|
17
|
+
- [Scatter Chart](https://next.mui.com/x/react-charts/scatter/#click-event)
|
|
18
|
+
- [Line Chart](https://next.mui.com/x/react-charts/lines/#click-event)
|
|
19
|
+
- [Bar Chart](https://next.mui.com/x/react-charts/bars/#click-event)
|
|
20
|
+
- [Pie Chart](https://next.mui.com/x/react-charts/pie/#click-event)
|
|
21
|
+
|
|
22
|
+
Big thanks to @giladappsforce and @yaredtsy for their contribution on exploring this feature.
|
|
23
|
+
|
|
24
|
+
### Data Grid
|
|
25
|
+
|
|
26
|
+
### Breaking changes
|
|
27
|
+
|
|
28
|
+
- The signature of `GridColDef['valueGetter']` has been changed for performance reasons:
|
|
29
|
+
|
|
30
|
+
```diff
|
|
31
|
+
- valueGetter: ({ value, row }) => value,
|
|
32
|
+
+ valueGetter: (value, row, column, apiRef) => value,
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The `GridValueGetterParams` interface has been removed:
|
|
36
|
+
|
|
37
|
+
```diff
|
|
38
|
+
- const customValueGetter = (params: GridValueGetterParams) => params.row.budget;
|
|
39
|
+
+ const customValueGetter: GridValueGetterFn = (value, row) => row.budget;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- The signature of `GridColDef['valueFormatter']` has been changed for performance reasons:
|
|
43
|
+
|
|
44
|
+
```diff
|
|
45
|
+
- valueFormatter: ({ value }) => value,
|
|
46
|
+
+ valueFormatter: (value, row, column, apiRef) => value,
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The `GridValueFormatterParams` interface has been removed:
|
|
50
|
+
|
|
51
|
+
```diff
|
|
52
|
+
- const gridDateFormatter = ({ value, field, id }: GridValueFormatterParams<Date>) => value.toLocaleDateString();
|
|
53
|
+
+ const gridDateFormatter: GridValueFormatter = (value: Date) => value.toLocaleDateString();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- The signature of `GridColDef['valueSetter']` has been changed for performance reasons:
|
|
57
|
+
|
|
58
|
+
```diff
|
|
59
|
+
- valueSetter: (params) => {
|
|
60
|
+
- const [firstName, lastName] = params.value!.toString().split(' ');
|
|
61
|
+
- return { ...params.row, firstName, lastName };
|
|
62
|
+
- }
|
|
63
|
+
+ valueSetter: (value, row) => {
|
|
64
|
+
+ const [firstName, lastName] = value!.toString().split(' ');
|
|
65
|
+
+ return { ...row, firstName, lastName };
|
|
66
|
+
+}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The `GridValueSetterParams` interface has been removed:
|
|
70
|
+
|
|
71
|
+
```diff
|
|
72
|
+
- const setFullName = (params: GridValueSetterParams) => {
|
|
73
|
+
- const [firstName, lastName] = params.value!.toString().split(' ');
|
|
74
|
+
- return { ...params.row, firstName, lastName };
|
|
75
|
+
- };
|
|
76
|
+
+ const setFullName: GridValueSetter<Row> = (value, row) => {
|
|
77
|
+
+ const [firstName, lastName] = value!.toString().split(' ');
|
|
78
|
+
+ return { ...row, firstName, lastName };
|
|
79
|
+
+ }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- The signature of `GridColDef['valueParser']` has been changed for performance reasons:
|
|
83
|
+
|
|
84
|
+
```diff
|
|
85
|
+
- valueParser: (value, params: GridCellParams) => value.toLowerCase(),
|
|
86
|
+
+ valueParser: (value, row, column, apiRef) => value.toLowerCase(),
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- The signature of `GridColDef['colSpan']` has been changed for performance reasons:
|
|
90
|
+
|
|
91
|
+
```diff
|
|
92
|
+
- colSpan: ({ row, field, value }: GridCellParams) => (row.id === 'total' ? 2 : 1),
|
|
93
|
+
+ colSpan: (value, row, column, apiRef) => (row.id === 'total' ? 2 : 1),
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- The signature of `GridColDef['pastedValueParser']` has been changed for performance reasons:
|
|
97
|
+
|
|
98
|
+
```diff
|
|
99
|
+
- pastedValueParser: (value, params) => new Date(value),
|
|
100
|
+
+ pastedValueParser: (value, row, column, apiRef) => new Date(value),
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- The signature of `GridColDef['groupingValueGetter']` has been changed for performance reasons:
|
|
104
|
+
|
|
105
|
+
```diff
|
|
106
|
+
- groupingValueGetter: (params) => params.value.name,
|
|
107
|
+
+ groupingValueGetter: (value: { name: string }) => value.name,
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### `@mui/x-data-grid@7.0.0-beta.1`
|
|
111
|
+
|
|
112
|
+
- [DataGrid] Add `toggleAllMode` prop to the `columnsManagement` slot (#10794) @H999
|
|
113
|
+
- [DataGrid] Change `GridColDef` methods signatures (#11573) @cherniavskii
|
|
114
|
+
- [DataGrid] Fix row reorder with cell selection (#11783) @PEsteves8
|
|
115
|
+
- [DataGrid] Make columns management' casing consistent (#11858) @MBilalShafi
|
|
116
|
+
- [l10n] Improve Hebrew (he-IL) locale (#11788) @danielmishan85
|
|
117
|
+
|
|
118
|
+
#### `@mui/x-data-grid-pro@7.0.0-beta.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
119
|
+
|
|
120
|
+
Same changes as in `@mui/x-data-grid@7.0.0-beta.1`.
|
|
121
|
+
|
|
122
|
+
#### `@mui/x-data-grid-premium@7.0.0-beta.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
123
|
+
|
|
124
|
+
Same changes as in `@mui/x-data-grid-pro@7.0.0-beta.1`.
|
|
125
|
+
|
|
126
|
+
### Date Pickers
|
|
127
|
+
|
|
128
|
+
#### `@mui/x-date-pickers@7.0.0-beta.1`
|
|
129
|
+
|
|
130
|
+
- [TimePicker] Add missing toolbar classes descriptions (#11856) @LukasTy
|
|
131
|
+
|
|
132
|
+
#### `@mui/x-date-pickers-pro@7.0.0-beta.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
133
|
+
|
|
134
|
+
Same changes as in `@mui/x-date-pickers@7.0.0-beta.1`.
|
|
135
|
+
|
|
136
|
+
### Charts
|
|
137
|
+
|
|
138
|
+
#### Breaking changes
|
|
139
|
+
|
|
140
|
+
- The line chart now have animation by default.
|
|
141
|
+
You can disable it with `skipAnimation` prop.
|
|
142
|
+
See [animation documentation](next.mui.com/x/react-charts/lines/#animation) for more information.
|
|
143
|
+
|
|
144
|
+
- Pie charts `onClick` get renamed `onItemClick` for consistency with other charts click callback.
|
|
145
|
+
|
|
146
|
+
`@mui/x-charts@7.0.0-beta.1`
|
|
147
|
+
|
|
148
|
+
- [charts] Add `onClick` support (#11411) @alexfauquette
|
|
149
|
+
- [charts] Add line animation (#11620) @alexfauquette
|
|
150
|
+
- [charts] Document how to modify color according to values (#11824) @alexfauquette
|
|
151
|
+
- [charts] Fix Tooltip crash with out of range lines (#11898) @alexfauquette
|
|
152
|
+
|
|
153
|
+
### Docs
|
|
154
|
+
|
|
155
|
+
- [docs] Add a general uplift to the changelog page (#11396) @danilo-leal
|
|
156
|
+
- [docs] Do not reference the Tree View overview page in the API pages (#11826) @flaviendelangle
|
|
157
|
+
- [docs] Fix charts API links (#11832) @alexfauquette
|
|
158
|
+
- [docs] Improve Support page (#11556) @oliviertassinari
|
|
159
|
+
- [docs] Improve column visibility documentation (#11857) @MBilalShafi
|
|
160
|
+
- [docs] Polish header @oliviertassinari
|
|
161
|
+
- [docs] Sync support page with core @oliviertassinari
|
|
162
|
+
- [docs] Update whats new page with "v7 Beta blogpost" content (#11879) @joserodolfofreitas
|
|
163
|
+
|
|
164
|
+
### Core
|
|
165
|
+
|
|
166
|
+
- [core] Rely on immutable ref when possible (#11847) @oliviertassinari
|
|
167
|
+
- [core] Bump monorepo (#11897) @alexfauquette
|
|
168
|
+
|
|
6
169
|
## 7.0.0-beta.0
|
|
7
170
|
|
|
8
171
|
_Jan 26, 2024_
|
|
@@ -1873,6 +2036,90 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
|
|
|
1873
2036
|
- [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
|
|
1874
2037
|
- [license] Correctly throw errors (#10924) @oliviertassinari
|
|
1875
2038
|
|
|
2039
|
+
## 6.19.3
|
|
2040
|
+
|
|
2041
|
+
_Feb 1, 2024_
|
|
2042
|
+
|
|
2043
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
2044
|
+
|
|
2045
|
+
- 🌍 Improve Hebrew (he-IL) locale (#11831) @danielmishan85
|
|
2046
|
+
- 🐞 Bugfixes
|
|
2047
|
+
- 📚 Documentation improvements
|
|
2048
|
+
|
|
2049
|
+
### Data Grid
|
|
2050
|
+
|
|
2051
|
+
#### `@mui/x-data-grid@6.19.3`
|
|
2052
|
+
|
|
2053
|
+
- [l10n] Improve Hebrew (he-IL) locale (@danielmishan85) (#11831)
|
|
2054
|
+
|
|
2055
|
+
#### `@mui/x-data-grid-pro@6.19.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
2056
|
+
|
|
2057
|
+
Same changes as in `@mui/x-data-grid@6.19.3`.
|
|
2058
|
+
|
|
2059
|
+
#### `@mui/x-data-grid-premium@6.19.3` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
2060
|
+
|
|
2061
|
+
Same changes as in `@mui/x-data-grid-pro@6.19.3`.
|
|
2062
|
+
|
|
2063
|
+
### Date Pickers
|
|
2064
|
+
|
|
2065
|
+
#### `@mui/x-date-pickers@6.19.3`
|
|
2066
|
+
|
|
2067
|
+
- [TimePicker] Add missing toolbar classes descriptions (#11862) @LukasTy
|
|
2068
|
+
|
|
2069
|
+
#### `@mui/x-date-pickers-pro@6.19.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
2070
|
+
|
|
2071
|
+
Same changes as in `@mui/x-date-pickers@6.19.3`.
|
|
2072
|
+
|
|
2073
|
+
### Charts / `@mui/x-charts@6.19.3`
|
|
2074
|
+
|
|
2075
|
+
- [charts] Document how to modify color according to values (#11854) @alexfauquette
|
|
2076
|
+
|
|
2077
|
+
### Docs
|
|
2078
|
+
|
|
2079
|
+
- [docs] Add a general uplift to the whats new page (#11883) @danilo-leal
|
|
2080
|
+
- [docs] Fix 404 (#11852) @alexfauquette
|
|
2081
|
+
- [docs] Fix <title> generation (#11825) @alexfauquette
|
|
2082
|
+
- [docs] Fix docs:api when typo in slots typing (#11861) @alexfauquette
|
|
2083
|
+
- [docs] Improve Support page (#11556) @oliviertassinari
|
|
2084
|
+
- [docs] Sync support page with core @oliviertassinari
|
|
2085
|
+
- [docs] These API don't exist in MUI X v6 @oliviertassinari
|
|
2086
|
+
- [docs] Update whats new page with v7 Beta blogpost content (#11886) @joserodolfofreitas
|
|
2087
|
+
|
|
2088
|
+
## 6.19.2
|
|
2089
|
+
|
|
2090
|
+
_Jan 25, 2024_
|
|
2091
|
+
|
|
2092
|
+
We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
|
|
2093
|
+
|
|
2094
|
+
- 🚀 Apply the `layout.tabs` class to `Tabs` slot (@LukasTy) (#11782)
|
|
2095
|
+
- 🐞 Bugfixes
|
|
2096
|
+
|
|
2097
|
+
### Date Pickers
|
|
2098
|
+
|
|
2099
|
+
#### `@mui/x-date-pickers@6.19.2`
|
|
2100
|
+
|
|
2101
|
+
- [pickers] Apply the `layout.tabs` class to `Tabs` slot (@LukasTy) (#11782)
|
|
2102
|
+
|
|
2103
|
+
#### `@mui/x-date-pickers-pro@6.19.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
2104
|
+
|
|
2105
|
+
Same changes as in `@mui/x-date-pickers@6.19.2`, plus:
|
|
2106
|
+
|
|
2107
|
+
- [DateRangePicker] Remove `calendars` prop on `Mobile` (@LukasTy) (#11771)
|
|
2108
|
+
|
|
2109
|
+
### Data Grid
|
|
2110
|
+
|
|
2111
|
+
#### `@mui/x-data-grid@6.19.2`
|
|
2112
|
+
|
|
2113
|
+
- [DataGrid] Fix support for tree with more than 50,000 children (@zenazn) (#11808)
|
|
2114
|
+
|
|
2115
|
+
#### `@mui/x-data-grid-pro@6.19.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
2116
|
+
|
|
2117
|
+
Same changes as in `@mui/x-data-grid@6.19.2`.
|
|
2118
|
+
|
|
2119
|
+
#### `@mui/x-data-grid-premium@6.19.2` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
2120
|
+
|
|
2121
|
+
Same changes as in `@mui/x-data-grid-pro@6.19.2`.
|
|
2122
|
+
|
|
1876
2123
|
## 6.19.1
|
|
1877
2124
|
|
|
1878
2125
|
_Jan 19, 2024_
|
|
@@ -57,7 +57,7 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
57
57
|
useGridRowSelection(apiRef, props);
|
|
58
58
|
useGridColumns(apiRef, props);
|
|
59
59
|
useGridRows(apiRef, props);
|
|
60
|
-
useGridParamsApi(apiRef
|
|
60
|
+
useGridParamsApi(apiRef);
|
|
61
61
|
useGridColumnSpanning(apiRef);
|
|
62
62
|
useGridColumnGrouping(apiRef, props);
|
|
63
63
|
useGridEditing(apiRef, props);
|
|
@@ -4,12 +4,9 @@ import { renderBooleanCell } from '../components/cell/GridBooleanCell';
|
|
|
4
4
|
import { renderEditBooleanCell } from '../components/cell/GridEditBooleanCell';
|
|
5
5
|
import { gridNumberComparator } from '../hooks/features/sorting/gridSortingUtils';
|
|
6
6
|
import { getGridBooleanOperators } from './gridBooleanOperators';
|
|
7
|
-
|
|
8
|
-
value
|
|
9
|
-
|
|
10
|
-
}) {
|
|
11
|
-
return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
|
|
12
|
-
}
|
|
7
|
+
const gridBooleanFormatter = (value, row, column, apiRef) => {
|
|
8
|
+
return value ? apiRef.current.getLocaleText('booleanCellTrueLabel') : apiRef.current.getLocaleText('booleanCellFalseLabel');
|
|
9
|
+
};
|
|
13
10
|
const stringToBoolean = value => {
|
|
14
11
|
switch (value.toLowerCase().trim()) {
|
|
15
12
|
case 'true':
|
|
@@ -19,9 +19,10 @@ export const GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF
|
|
|
19
19
|
disableReorder: true,
|
|
20
20
|
disableExport: true,
|
|
21
21
|
getApplyQuickFilterFn: undefined,
|
|
22
|
-
valueGetter:
|
|
23
|
-
const selectionLookup = selectedIdsLookupSelector(
|
|
24
|
-
|
|
22
|
+
valueGetter: (value, row, column, apiRef) => {
|
|
23
|
+
const selectionLookup = selectedIdsLookupSelector(apiRef);
|
|
24
|
+
const rowId = apiRef.current.getRowId(row);
|
|
25
|
+
return selectionLookup[rowId] !== undefined;
|
|
25
26
|
},
|
|
26
27
|
renderHeader: params => /*#__PURE__*/_jsx(GridHeaderCheckbox, _extends({}, params)),
|
|
27
28
|
renderCell: params => /*#__PURE__*/_jsx(GridCellCheckboxRenderer, _extends({}, params))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { GridColTypeDef } from '../models/colDef/gridColDef';
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function gridDateTimeFormatter({ value, field, id }: GridValueFormatterParams<Date>): string;
|
|
1
|
+
import { GridColTypeDef, GridValueFormatter } from '../models/colDef/gridColDef';
|
|
2
|
+
export declare const gridDateFormatter: GridValueFormatter;
|
|
3
|
+
export declare const gridDateTimeFormatter: GridValueFormatter;
|
|
5
4
|
export declare const GRID_DATE_COL_DEF: GridColTypeDef<Date, string>;
|
|
6
5
|
export declare const GRID_DATETIME_COL_DEF: GridColTypeDef<Date, string>;
|
package/colDef/gridDateColDef.js
CHANGED
|
@@ -13,38 +13,32 @@ function throwIfNotDateObject({
|
|
|
13
13
|
throw new Error([`MUI X: \`${columnType}\` column type only accepts \`Date\` objects as values.`, 'Use `valueGetter` to transform the value into a `Date` object.', `Row ID: ${rowId}, field: "${field}".`].join('\n'));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
value,
|
|
18
|
-
field,
|
|
19
|
-
id
|
|
20
|
-
}) {
|
|
16
|
+
export const gridDateFormatter = (value, row, column, apiRef) => {
|
|
21
17
|
if (!value) {
|
|
22
18
|
return '';
|
|
23
19
|
}
|
|
20
|
+
const rowId = apiRef.current.getRowId(row);
|
|
24
21
|
throwIfNotDateObject({
|
|
25
22
|
value,
|
|
26
23
|
columnType: 'date',
|
|
27
|
-
rowId
|
|
28
|
-
field
|
|
24
|
+
rowId,
|
|
25
|
+
field: column.field
|
|
29
26
|
});
|
|
30
27
|
return value.toLocaleDateString();
|
|
31
|
-
}
|
|
32
|
-
export
|
|
33
|
-
value,
|
|
34
|
-
field,
|
|
35
|
-
id
|
|
36
|
-
}) {
|
|
28
|
+
};
|
|
29
|
+
export const gridDateTimeFormatter = (value, row, column, apiRef) => {
|
|
37
30
|
if (!value) {
|
|
38
31
|
return '';
|
|
39
32
|
}
|
|
33
|
+
const rowId = apiRef.current.getRowId(row);
|
|
40
34
|
throwIfNotDateObject({
|
|
41
35
|
value,
|
|
42
36
|
columnType: 'dateTime',
|
|
43
|
-
rowId
|
|
44
|
-
field
|
|
37
|
+
rowId,
|
|
38
|
+
field: column.field
|
|
45
39
|
});
|
|
46
40
|
return value.toLocaleString();
|
|
47
|
-
}
|
|
41
|
+
};
|
|
48
42
|
export const GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
49
43
|
type: 'date',
|
|
50
44
|
sortComparator: gridDateComparator,
|
|
@@ -9,9 +9,7 @@ export const GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
9
9
|
headerAlign: 'right',
|
|
10
10
|
sortComparator: gridNumberComparator,
|
|
11
11
|
valueParser: value => value === '' ? null : Number(value),
|
|
12
|
-
valueFormatter: (
|
|
13
|
-
value
|
|
14
|
-
}) => isNumber(value) ? value.toLocaleString() : value || '',
|
|
12
|
+
valueFormatter: value => isNumber(value) ? value.toLocaleString() : value || '',
|
|
15
13
|
filterOperators: getGridNumericOperators(),
|
|
16
14
|
getApplyQuickFilterFn: getGridNumericQuickFilterFn
|
|
17
15
|
});
|
|
@@ -17,20 +17,15 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
17
17
|
type: 'singleSelect',
|
|
18
18
|
getOptionLabel: defaultGetOptionLabel,
|
|
19
19
|
getOptionValue: defaultGetOptionValue,
|
|
20
|
-
valueFormatter(
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
field,
|
|
24
|
-
value,
|
|
25
|
-
api
|
|
26
|
-
} = params;
|
|
27
|
-
const colDef = params.api.getColumn(field);
|
|
20
|
+
valueFormatter(value, row, colDef, apiRef) {
|
|
21
|
+
// const { id, field, value, api } = params;
|
|
22
|
+
const rowId = apiRef.current.getRowId(row);
|
|
28
23
|
if (!isSingleSelectColDef(colDef)) {
|
|
29
24
|
return '';
|
|
30
25
|
}
|
|
31
26
|
const valueOptions = getValueOptions(colDef, {
|
|
32
|
-
id,
|
|
33
|
-
row
|
|
27
|
+
id: rowId,
|
|
28
|
+
row
|
|
34
29
|
});
|
|
35
30
|
if (value == null) {
|
|
36
31
|
return '';
|
|
@@ -47,8 +42,8 @@ export const GRID_SINGLE_SELECT_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
|
47
42
|
renderEditCell: renderEditSingleSelectCell,
|
|
48
43
|
filterOperators: getGridSingleSelectOperators(),
|
|
49
44
|
// @ts-ignore
|
|
50
|
-
pastedValueParser: (value,
|
|
51
|
-
const colDef =
|
|
45
|
+
pastedValueParser: (value, row, column) => {
|
|
46
|
+
const colDef = column;
|
|
52
47
|
const valueOptions = getValueOptions(colDef) || [];
|
|
53
48
|
const getOptionValue = colDef.getOptionValue;
|
|
54
49
|
const valueOption = valueOptions.find(option => {
|
|
@@ -57,7 +57,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
57
57
|
const column = apiRef.current.getColumn(field);
|
|
58
58
|
let parsedValue = newValue;
|
|
59
59
|
if (column.valueParser) {
|
|
60
|
-
parsedValue = column.valueParser(newValue, apiRef.current.
|
|
60
|
+
parsedValue = column.valueParser(newValue, apiRef.current.getRow(id), column, apiRef);
|
|
61
61
|
}
|
|
62
62
|
setValueState(parsedValue);
|
|
63
63
|
apiRef.current.setEditCellValue({
|
|
@@ -20,6 +20,13 @@ export interface GridColumnsManagementProps {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
disableResetButton?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Changes the behavior of the `Show/Hide All` toggle when the search field is used:
|
|
25
|
+
* - `all`: Will toggle all columns.
|
|
26
|
+
* - `filteredOnly`: Will only toggle columns that match the search criteria.
|
|
27
|
+
* @default 'all'
|
|
28
|
+
*/
|
|
29
|
+
toggleAllMode?: 'all' | 'filteredOnly';
|
|
23
30
|
/**
|
|
24
31
|
* Returns the list of togglable columns.
|
|
25
32
|
* If used, only those columns will be displayed in the panel
|
|
@@ -43,6 +43,7 @@ function GridColumnsManagement(props) {
|
|
|
43
43
|
autoFocusSearchField = true,
|
|
44
44
|
disableShowHideToggle = false,
|
|
45
45
|
disableResetButton = false,
|
|
46
|
+
toggleAllMode = 'all',
|
|
46
47
|
getTogglableColumns
|
|
47
48
|
} = props;
|
|
48
49
|
const isResetDisabled = React.useMemo(() => checkColumnVisibilityModelsSame(columnVisibilityModel, initialColumnVisibilityModel), [columnVisibilityModel, initialColumnVisibilityModel]);
|
|
@@ -62,11 +63,21 @@ function GridColumnsManagement(props) {
|
|
|
62
63
|
} = event.target;
|
|
63
64
|
apiRef.current.setColumnVisibility(field, columnVisibilityModel[field] === false);
|
|
64
65
|
};
|
|
66
|
+
const currentColumns = React.useMemo(() => {
|
|
67
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
68
|
+
const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
|
|
69
|
+
field
|
|
70
|
+
}) => togglableColumns.includes(field)) : sortedColumns;
|
|
71
|
+
if (!searchValue) {
|
|
72
|
+
return togglableSortedColumns;
|
|
73
|
+
}
|
|
74
|
+
return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
|
|
75
|
+
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
65
76
|
const toggleAllColumns = React.useCallback(isVisible => {
|
|
66
77
|
const currentModel = gridColumnVisibilityModelSelector(apiRef);
|
|
67
78
|
const newModel = _extends({}, currentModel);
|
|
68
79
|
const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
|
|
69
|
-
columns.forEach(col => {
|
|
80
|
+
(toggleAllMode === 'filteredOnly' ? currentColumns : columns).forEach(col => {
|
|
70
81
|
if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
|
|
71
82
|
if (isVisible) {
|
|
72
83
|
// delete the key from the model instead of setting it to `true`
|
|
@@ -77,20 +88,10 @@ function GridColumnsManagement(props) {
|
|
|
77
88
|
}
|
|
78
89
|
});
|
|
79
90
|
return apiRef.current.setColumnVisibilityModel(newModel);
|
|
80
|
-
}, [apiRef, columns, getTogglableColumns]);
|
|
91
|
+
}, [apiRef, columns, getTogglableColumns, toggleAllMode, currentColumns]);
|
|
81
92
|
const handleSearchValueChange = React.useCallback(event => {
|
|
82
93
|
setSearchValue(event.target.value);
|
|
83
94
|
}, []);
|
|
84
|
-
const currentColumns = React.useMemo(() => {
|
|
85
|
-
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
86
|
-
const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
|
|
87
|
-
field
|
|
88
|
-
}) => togglableColumns.includes(field)) : sortedColumns;
|
|
89
|
-
if (!searchValue) {
|
|
90
|
-
return togglableSortedColumns;
|
|
91
|
-
}
|
|
92
|
-
return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
|
|
93
|
-
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
94
95
|
const hideableColumns = React.useMemo(() => currentColumns.filter(col => col.hideable), [currentColumns]);
|
|
95
96
|
const allHideableColumnsVisible = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] == null || columnVisibilityModel[column.field] !== false), [columnVisibilityModel, hideableColumns]);
|
|
96
97
|
const allHideableColumnsHidden = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] === false), [columnVisibilityModel, hideableColumns]);
|
|
@@ -164,14 +165,11 @@ function GridColumnsManagement(props) {
|
|
|
164
165
|
checked: allHideableColumnsVisible,
|
|
165
166
|
indeterminate: !allHideableColumnsVisible && !allHideableColumnsHidden,
|
|
166
167
|
onClick: () => toggleAllColumns(!allHideableColumnsVisible),
|
|
167
|
-
name: apiRef.current.getLocaleText('columnsManagementShowHideAllText')
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
[`.MuiFormControlLabel-label`]: {
|
|
171
|
-
textTransform: 'uppercase',
|
|
172
|
-
fontSize: '14px'
|
|
168
|
+
name: apiRef.current.getLocaleText('columnsManagementShowHideAllText'),
|
|
169
|
+
sx: {
|
|
170
|
+
p: 0.5
|
|
173
171
|
}
|
|
174
|
-
},
|
|
172
|
+
}, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseCheckbox)),
|
|
175
173
|
label: apiRef.current.getLocaleText('columnsManagementShowHideAllText')
|
|
176
174
|
}) : /*#__PURE__*/_jsx("span", {}), !disableResetButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
|
|
177
175
|
onClick: () => apiRef.current.setColumnVisibilityModel(initialColumnVisibilityModel),
|
|
@@ -213,7 +211,14 @@ process.env.NODE_ENV !== "production" ? GridColumnsManagement.propTypes = {
|
|
|
213
211
|
*/
|
|
214
212
|
getTogglableColumns: PropTypes.func,
|
|
215
213
|
searchPredicate: PropTypes.func,
|
|
216
|
-
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
214
|
+
sort: PropTypes.oneOf(['asc', 'desc']),
|
|
215
|
+
/**
|
|
216
|
+
* Changes the behavior of the `Show/Hide All` toggle when the search field is used:
|
|
217
|
+
* - `all`: Will toggle all columns.
|
|
218
|
+
* - `filteredOnly`: Will only toggle columns that match the search criteria.
|
|
219
|
+
* @default 'all'
|
|
220
|
+
*/
|
|
221
|
+
toggleAllMode: PropTypes.oneOf(['all', 'filteredOnly'])
|
|
217
222
|
} : void 0;
|
|
218
223
|
const GridColumnsManagementBody = styled('div', {
|
|
219
224
|
name: 'MuiDataGrid',
|
|
@@ -246,7 +251,7 @@ const GridColumnsManagementFooter = styled('div', {
|
|
|
246
251
|
})(({
|
|
247
252
|
theme
|
|
248
253
|
}) => ({
|
|
249
|
-
padding: theme.spacing(0.5, 1, 0.5,
|
|
254
|
+
padding: theme.spacing(0.5, 1, 0.5, 3),
|
|
250
255
|
display: 'flex',
|
|
251
256
|
justifyContent: 'space-between',
|
|
252
257
|
borderTop: `1px solid ${theme.palette.divider}`
|
|
@@ -60,7 +60,9 @@ function calculateCellColSpan(params) {
|
|
|
60
60
|
} = params;
|
|
61
61
|
const columnsLength = columns.length;
|
|
62
62
|
const column = columns[columnIndex];
|
|
63
|
-
const
|
|
63
|
+
const row = apiRef.current.getRow(rowId);
|
|
64
|
+
const value = apiRef.current.getRowValue(row, column);
|
|
65
|
+
const colSpan = typeof column.colSpan === 'function' ? column.colSpan(value, row, column, apiRef) : column.colSpan;
|
|
64
66
|
if (!colSpan || colSpan === 1) {
|
|
65
67
|
setCellColSpanInfo(lookup, rowId, columnIndex, {
|
|
66
68
|
spannedByColSpan: false,
|
|
@@ -335,7 +335,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
335
335
|
const row = apiRef.current.getRow(id);
|
|
336
336
|
let parsedValue = value;
|
|
337
337
|
if (column.valueParser && !skipValueParser) {
|
|
338
|
-
parsedValue = column.valueParser(value,
|
|
338
|
+
parsedValue = column.valueParser(value, row, column, apiRef);
|
|
339
339
|
}
|
|
340
340
|
let editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
341
341
|
let newProps = _extends({}, editingState[id][field], {
|
|
@@ -383,10 +383,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
383
383
|
const {
|
|
384
384
|
value
|
|
385
385
|
} = editingState[id][field];
|
|
386
|
-
return column.valueSetter ? column.valueSetter({
|
|
387
|
-
value,
|
|
388
|
-
row
|
|
389
|
-
}) : _extends({}, row, {
|
|
386
|
+
return column.valueSetter ? column.valueSetter(value, row, column, apiRef) : _extends({}, row, {
|
|
390
387
|
[field]: value
|
|
391
388
|
});
|
|
392
389
|
}, [apiRef]);
|
|
@@ -410,7 +410,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
410
410
|
const row = apiRef.current.getRow(id);
|
|
411
411
|
let parsedValue = value;
|
|
412
412
|
if (column.valueParser && !skipValueParser) {
|
|
413
|
-
parsedValue = column.valueParser(value,
|
|
413
|
+
parsedValue = column.valueParser(value, row, column, apiRef);
|
|
414
414
|
}
|
|
415
415
|
let editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
416
416
|
let newProps = _extends({}, editingState[id][field], {
|
|
@@ -510,10 +510,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
510
510
|
Object.entries(editingState[id]).forEach(([field, fieldProps]) => {
|
|
511
511
|
const column = apiRef.current.getColumn(field);
|
|
512
512
|
if (column.valueSetter) {
|
|
513
|
-
rowUpdate = column.valueSetter(
|
|
514
|
-
value: fieldProps.value,
|
|
515
|
-
row: rowUpdate
|
|
516
|
-
});
|
|
513
|
+
rowUpdate = column.valueSetter(fieldProps.value, rowUpdate, column, apiRef);
|
|
517
514
|
} else {
|
|
518
515
|
rowUpdate[field] = fieldProps.value;
|
|
519
516
|
}
|
|
@@ -89,7 +89,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
|
|
|
89
89
|
if (column.valueParser) {
|
|
90
90
|
var _filterItem$value;
|
|
91
91
|
const parser = column.valueParser;
|
|
92
|
-
parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(x => parser(x)) : parser(filterItem.value);
|
|
92
|
+
parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(x => parser(x, undefined, column, apiRef)) : parser(filterItem.value, undefined, column, apiRef);
|
|
93
93
|
} else {
|
|
94
94
|
parsedValue = filterItem.value;
|
|
95
95
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
-
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
3
|
export declare class MissingRowIdError extends Error {
|
|
5
4
|
}
|
|
6
5
|
/**
|
|
@@ -11,4 +10,4 @@ export declare class MissingRowIdError extends Error {
|
|
|
11
10
|
* TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
|
|
12
11
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
13
12
|
*/
|
|
14
|
-
export declare function useGridParamsApi(apiRef: React.MutableRefObject<GridPrivateApiCommunity
|
|
13
|
+
export declare function useGridParamsApi(apiRef: React.MutableRefObject<GridPrivateApiCommunity>): void;
|