@mui/x-data-grid 6.0.0-alpha.2 → 6.0.0-alpha.3
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 +231 -12
- package/DataGrid/DataGrid.js +0 -20
- package/DataGrid/useDataGridComponent.js +2 -6
- package/colDef/gridNumericOperators.d.ts +1 -1
- package/colDef/gridSingleSelectOperators.d.ts +1 -1
- package/colDef/gridStringOperators.d.ts +1 -1
- package/components/cell/GridEditInputCell.js +3 -8
- package/components/cell/GridEditSingleSelectCell.js +6 -38
- package/components/panel/filterPanel/GridFilterForm.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/components/panel/filterPanel/GridFilterPanel.d.ts +12 -0
- package/components/panel/filterPanel/GridFilterPanel.js +64 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
- package/hooks/core/useGridInitialization.d.ts +1 -1
- package/hooks/core/useGridStateInitialization.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/{editRows/gridEditRowsSelector.d.ts → editing/gridEditingSelectors.d.ts} +0 -0
- package/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/hooks/features/editing/index.d.ts +1 -0
- package/hooks/features/editing/index.js +1 -0
- package/hooks/features/{editRows/useGridCellEditing.new.d.ts → editing/useGridCellEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/hooks/features/{editRows/useGridEditing.new.d.ts → editing/useGridEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/hooks/features/{editRows/useGridRowEditing.new.d.ts → editing/useGridRowEditing.d.ts} +0 -0
- package/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/hooks/features/index.d.ts +1 -1
- package/hooks/features/index.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/hooks/utils/useGridApi.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +1 -1
- package/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridSelector.d.ts +1 -1
- package/hooks/utils/useGridState.d.ts +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.js +1 -1
- package/internals/index.d.ts +1 -2
- package/internals/index.js +1 -2
- package/legacy/DataGrid/DataGrid.js +0 -20
- package/legacy/DataGrid/useDataGridComponent.js +2 -6
- package/legacy/components/cell/GridEditInputCell.js +3 -8
- package/legacy/components/cell/GridEditSingleSelectCell.js +6 -52
- package/legacy/components/panel/filterPanel/GridFilterForm.js +31 -7
- package/legacy/components/panel/filterPanel/GridFilterPanel.js +67 -18
- package/legacy/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/legacy/hooks/features/editing/index.js +1 -0
- package/legacy/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/legacy/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/legacy/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/legacy/hooks/features/index.js +1 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -2
- package/legacy/models/params/gridEditCellParams.js +0 -4
- package/models/api/gridApiCommon.d.ts +2 -5
- package/models/api/gridApiCommunity.d.ts +1 -7
- package/models/api/gridEditingApi.d.ts +36 -121
- package/models/api/index.d.ts +1 -1
- package/models/events/gridEventLookup.d.ts +1 -15
- package/models/params/gridEditCellParams.d.ts +4 -17
- package/models/params/gridEditCellParams.js +0 -4
- package/models/params/gridRowParams.d.ts +4 -4
- package/models/props/DataGridProps.d.ts +0 -24
- package/modern/DataGrid/DataGrid.js +0 -20
- package/modern/DataGrid/useDataGridComponent.js +2 -4
- package/modern/components/cell/GridEditInputCell.js +3 -4
- package/modern/components/cell/GridEditSingleSelectCell.js +6 -34
- package/modern/components/panel/filterPanel/GridFilterForm.js +29 -7
- package/modern/components/panel/filterPanel/GridFilterPanel.js +62 -17
- package/modern/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/modern/hooks/features/editing/index.js +1 -0
- package/modern/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +21 -6
- package/modern/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +3 -3
- package/modern/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +20 -6
- package/modern/hooks/features/index.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -2
- package/modern/models/params/gridEditCellParams.js +0 -4
- package/node/DataGrid/DataGrid.js +0 -20
- package/node/DataGrid/useDataGridComponent.js +3 -8
- package/node/components/cell/GridEditInputCell.js +3 -9
- package/node/components/cell/GridEditSingleSelectCell.js +6 -38
- package/node/components/panel/filterPanel/GridFilterForm.js +30 -7
- package/node/components/panel/filterPanel/GridFilterPanel.js +63 -19
- package/node/hooks/features/{editRows/gridEditRowsSelector.js → editing/gridEditingSelectors.js} +0 -0
- package/node/hooks/features/{editRows → editing}/index.js +4 -4
- package/node/hooks/features/{editRows/useGridCellEditing.new.js → editing/useGridCellEditing.js} +28 -13
- package/node/hooks/features/{editRows/useGridEditing.new.js → editing/useGridEditing.js} +4 -4
- package/node/hooks/features/{editRows/useGridRowEditing.new.js → editing/useGridRowEditing.js} +28 -14
- package/node/hooks/features/index.js +4 -4
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/index.js +3 -17
- package/node/models/params/gridEditCellParams.js +0 -3
- package/package.json +2 -2
- package/hooks/features/editRows/index.d.ts +0 -1
- package/hooks/features/editRows/index.js +0 -1
- package/hooks/features/editRows/useGridCellEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridCellEditing.old.js +0 -359
- package/hooks/features/editRows/useGridEditing.old.d.ts +0 -11
- package/hooks/features/editRows/useGridEditing.old.js +0 -167
- package/hooks/features/editRows/useGridRowEditing.old.d.ts +0 -4
- package/hooks/features/editRows/useGridRowEditing.old.js +0 -334
- package/legacy/hooks/features/editRows/index.js +0 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +0 -411
- package/legacy/hooks/features/editRows/useGridEditing.old.js +0 -184
- package/legacy/hooks/features/editRows/useGridRowEditing.old.js +0 -505
- package/modern/hooks/features/editRows/index.js +0 -1
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +0 -355
- package/modern/hooks/features/editRows/useGridEditing.old.js +0 -163
- package/modern/hooks/features/editRows/useGridRowEditing.old.js +0 -326
- package/node/hooks/features/editRows/useGridCellEditing.old.js +0 -380
- package/node/hooks/features/editRows/useGridEditing.old.js +0 -193
- package/node/hooks/features/editRows/useGridRowEditing.old.js +0 -358
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,214 @@
|
|
|
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
|
+
## v6.0.0-alpha.3
|
|
7
|
+
|
|
8
|
+
_Oct 13, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 8 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- ⌚️ New components to edit date and time with <kbd>keyboard</kbd>—without using any modal or dropdown UI.
|
|
13
|
+
Please check out our [documentation](https://next.mui.com/x/react-date-pickers/fields/) to discover those new components.
|
|
14
|
+
- [`DateField`](https://next.mui.com/x/react-date-pickers/date-field/) to edit date
|
|
15
|
+
- [`TimeField`](https://next.mui.com/x/react-date-pickers/time-field/) to edit time
|
|
16
|
+
- [`DateTimeField`](https://next.mui.com/x/react-date-pickers/date-time-field/) to edit date and time
|
|
17
|
+
- [`MultiInputDateRangeField` / `SingleInputDateRangeField`](https://next.mui.com/x/react-date-pickers/date-range-field/) to edit date range
|
|
18
|
+
- [`MultiInputTimeRangeField`](https://next.mui.com/x/react-date-pickers/time-range-field/) to edit time range with two inputs
|
|
19
|
+
- [`MultiInputDateTimeRangeField`](https://next.mui.com/x/react-date-pickers/date-time-range-field/) to edit date and time range with two inputs
|
|
20
|
+
|
|
21
|
+
⚠️ These components are unstable.
|
|
22
|
+
They might receive breaking changes on their props to have the best components possible by the time of the stable release.
|
|
23
|
+
|
|
24
|
+
- 📝 Allow to limit to one filter per column for `DataGridPro` and `DataGridPremium` (#6333) @MBilalShafi
|
|
25
|
+
- 📚 New [page describing the validation props on each picker](https://next.mui.com/x/react-date-pickers/validation/) (#6064) @flaviendelangle
|
|
26
|
+
- 📚 Documentation improvements
|
|
27
|
+
- 🐞 Bugfixes
|
|
28
|
+
|
|
29
|
+
### `@mui/x-data-grid@v6.0.0-alpha.3` / `@mui/x-data-grid-pro@v6.0.0-alpha.3` / `@mui/x-data-grid-premium@v6.0.0-alpha.3`
|
|
30
|
+
|
|
31
|
+
#### Breaking changes
|
|
32
|
+
|
|
33
|
+
- [DataGrid] Remove legacy editing API
|
|
34
|
+
|
|
35
|
+
The editing API that is enabled by default was replaced with a new API that contains better support for server-side persistence, validation and customization. This new editing feature was already available in v5 under the `newEditingApi` experimental flag. In v6, this flag can be removed.
|
|
36
|
+
|
|
37
|
+
```diff
|
|
38
|
+
<DataGrid
|
|
39
|
+
- experimentalFeatures={{ newEditingApi: true }}
|
|
40
|
+
/>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For users that didn't migrate to the new editing API in v5, additional work may be needed because the new API is not equivalent to the legacy API. Although, some migration steps are available to help in this task.
|
|
44
|
+
|
|
45
|
+
- The `editCellPropsChange` event was removed. If you still need it please file a new issue so we can propose an alternative.
|
|
46
|
+
- The `cellEditCommit` event was removed and the `processRowUpdate` prop can be used in place. More information, check the [docs](https://next.mui.com/x/react-data-grid/editing/#persistence) section about the topic.
|
|
47
|
+
- The `editRowsModel` and `onEditRowsModelChange` props were removed. The [`cellModesModel`](https://next.mui.com/x/react-data-grid/editing/#controlled-mode) or [`rowModesModel`](https://next.mui.com/x/react-data-grid/editing/#controlled-mode) props can be used to achieve the same goal.
|
|
48
|
+
- The following API methods were removed:
|
|
49
|
+
- Use `apiRef.current.stopCellEditMode` to replace `apiRef.current.commitCellChange`
|
|
50
|
+
- Use `apiRef.current.startCellEditMode` to replace `apiRef.current.setCellMode(id, field, 'edit')`
|
|
51
|
+
- Use `apiRef.current.stopRowEditMode` to replace `apiRef.current.commitRowChange`
|
|
52
|
+
- Use `apiRef.current.startRowMode` to replace `apiRef.current.setRowMode(id, 'edit')`
|
|
53
|
+
- Use the [`cellModesModel`](https://next.mui.com/x/react-data-grid/editing/#controlled-mode) or [`rowModesModel`](https://next.mui.com/x/react-data-grid/editing/#controlled-mode) props to replace `apiRef.current.setEditRowsModel`
|
|
54
|
+
|
|
55
|
+
#### Changes
|
|
56
|
+
|
|
57
|
+
- [DataGrid] Fix start edit mode with printable character in React 18 (#6257) @m4theushw
|
|
58
|
+
- [DataGrid] Remove legacy editing API (#6016) @m4theushw
|
|
59
|
+
- [DataGrid] Simplify `useGridApiContext` and `useGridApiRef` type overrides (#6423) @cherniavskii
|
|
60
|
+
- [DataGrid] Use generics instead of verbose state overrides (#6409) @cherniavskii
|
|
61
|
+
- [DataGridPro] Allow to limit to one filter per column (#6333) @MBilalShafi
|
|
62
|
+
|
|
63
|
+
### `@mui/x-date-pickers@v6.0.0-alpha.3` / `@mui/x-date-pickers-pro@v6.0.0-alpha.3`
|
|
64
|
+
|
|
65
|
+
#### Breaking changes
|
|
66
|
+
|
|
67
|
+
- All the props used by the mobile and desktop wrappers to override components or components' props have been replaced by component slots. You can find more information about this pattern in the [MUI Base documentation](https://mui.com/base/getting-started/usage/#shared-props).
|
|
68
|
+
|
|
69
|
+
Some of the names have also been prefixed by `desktop` when it was unclear that the behavior was only applied on the desktop version of the pickers (or the responsive version when used on a desktop).
|
|
70
|
+
|
|
71
|
+
The `DialogProps` prop has been replaced by a `dialog` component props slot on responsive and mobile pickers:
|
|
72
|
+
|
|
73
|
+
```diff
|
|
74
|
+
// Same on MobileDatePicker, DateTimePicker, MobileDateTimePicker,
|
|
75
|
+
// TimePicker, MobileTimePicker, DateRangePicker and MobileDateRangePicker.
|
|
76
|
+
<DatePicker
|
|
77
|
+
- DialogProps={{ backgroundColor: 'red' }}
|
|
78
|
+
+ componentsProps={{ dialog: { backgroundColor: 'red }}}
|
|
79
|
+
/>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The `PaperProps` prop has been replaced by a `desktopPaper` component props slot on all responsive and desktop pickers:
|
|
83
|
+
|
|
84
|
+
```diff
|
|
85
|
+
// Same on DesktopDatePicker, DateTimePicker, DesktopDateTimePicker,
|
|
86
|
+
// TimePicker, DesktopTimePicker, DateRangePicker and DesktopDateRangePicker.
|
|
87
|
+
<DatePicker
|
|
88
|
+
- PaperProps={{ backgroundColor: 'red' }}
|
|
89
|
+
+ componentsProps={{ desktopPaper: { backgroundColor: 'red }}}
|
|
90
|
+
/>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The `PopperProps` prop has been replaced by a `popper` component props slot on all responsive and desktop pickers:
|
|
94
|
+
|
|
95
|
+
```diff
|
|
96
|
+
// Same on DesktopDatePicker, DateTimePicker, DesktopDateTimePicker,
|
|
97
|
+
// TimePicker, DesktopTimePicker, DateRangePicker and DesktopDateRangePicker.
|
|
98
|
+
<DatePicker
|
|
99
|
+
- PopperProps={{ onClick: handleClick }}
|
|
100
|
+
+ componentsProps={{ popper: { onClick: handleClick }}}
|
|
101
|
+
/>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The `TransitionComponent` prop has been replaced by a `DesktopTransition` component slot on all responsive and desktop pickers:
|
|
105
|
+
|
|
106
|
+
```diff
|
|
107
|
+
// Same on DesktopDatePicker, DateTimePicker, DesktopDateTimePicker,
|
|
108
|
+
// TimePicker, DesktopTimePicker, DateRangePicker and DesktopDateRangePicker.
|
|
109
|
+
<DatePicker
|
|
110
|
+
- TransitionComponent={Fade}
|
|
111
|
+
+ components={{ DesktopTransition: Fade }}
|
|
112
|
+
/>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The `TrapFocusProps` prop has been replaced by a `desktopTrapFocus` component props slot on all responsive and desktop pickers:
|
|
116
|
+
|
|
117
|
+
```diff
|
|
118
|
+
// Same on DesktopDatePicker, DateTimePicker, DesktopDateTimePicker,
|
|
119
|
+
// TimePicker, DesktopTimePicker, DateRangePicker and DesktopDateRangePicker.
|
|
120
|
+
<DatePicker
|
|
121
|
+
- TrapFocusProps={{ isEnabled: () => false }}
|
|
122
|
+
+ componentsProps={{ desktopTrapFocus: { isEnabled: () => false }}}
|
|
123
|
+
/>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- The view components allowing to pick a date or parts of a date without an input have been renamed to better fit their usage:
|
|
127
|
+
|
|
128
|
+
```diff
|
|
129
|
+
-<CalendarPicker {...props} />
|
|
130
|
+
+<DateCalendar {...props} />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```diff
|
|
134
|
+
-<DayPicker {...props} />
|
|
135
|
+
+<DayCalendar {...props} />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```diff
|
|
139
|
+
-<CalendarPickerSkeleton {...props} />
|
|
140
|
+
+<DayCalendarSkeleton {...props} />
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```diff
|
|
144
|
+
-<MonthPicker {...props} />
|
|
145
|
+
+<MonthCalendar {...props} />
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```diff
|
|
149
|
+
-<YearPicker {...props} />
|
|
150
|
+
+<YearCalendar {...props} />
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- Component names in the theme have changed as well:
|
|
154
|
+
|
|
155
|
+
```diff
|
|
156
|
+
-MuiCalendarPicker: {
|
|
157
|
+
+MuiDateCalendar: {
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```diff
|
|
161
|
+
-MuiDayPicker: {
|
|
162
|
+
+MuiDayCalendar: {
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```diff
|
|
166
|
+
-MuiCalendarPickerSkeleton: {
|
|
167
|
+
+MuiDayCalendarSkeleton: {
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
```diff
|
|
171
|
+
-MuiMonthPicker: {
|
|
172
|
+
+MuiMonthCalendar: {
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```diff
|
|
176
|
+
-MuiYearPicker: {
|
|
177
|
+
+MuiYearCalendar: {
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Changes
|
|
181
|
+
|
|
182
|
+
- [DatePicker] Allows to fix the number of week displayed (#6299) @alexfauquette
|
|
183
|
+
- [DateRangePicker] Fix calendar day outside of month layout shifting on hover (#6448) @alexfauquette
|
|
184
|
+
- [fields] New components: `MultiInputDateTimeRangePicker` and `MultiInputTimeRangePicker` (#6392) @alexfauquette
|
|
185
|
+
- [fields] Prepare the field exports for the public release (#6467) @flaviendelangle
|
|
186
|
+
- [fields] Support paste in single section (#6422) @alexfauquette
|
|
187
|
+
- [pickers] Add field placeholders to the locale (#6337) @flaviendelangle
|
|
188
|
+
- [pickers] Do not use `Partial` for `components` and `componentsProps` props (#6463) @flaviendelangle
|
|
189
|
+
- [pickers] New component: `DateRangeCalendar` (#6416) @flaviendelangle
|
|
190
|
+
- [pickers] Replace the `Picker` prefix in the view component by `Calendar` (eg: `MonthPicker` => `MonthCalendar`) (#6389) @flaviendelangle
|
|
191
|
+
- [pickers] Support pasting on fields (#6364) @flaviendelangle
|
|
192
|
+
- [pickers] Use slots in the mobile and desktop wrappers instead of `XXXComponent` and `XXXProps` (#6381) @flaviendelangle
|
|
193
|
+
|
|
194
|
+
### Docs
|
|
195
|
+
|
|
196
|
+
- [docs] Add migration to DataGrid v6 page (#6235) @m4theushw
|
|
197
|
+
- [docs] Create first publishable version of the field doc (#6323) @flaviendelangle
|
|
198
|
+
- [docs] Fix trailing spaces in the readme @oliviertassinari
|
|
199
|
+
- [docs] New page for the pickers: Validation (#6064) @flaviendelangle
|
|
200
|
+
- [docs] Organize migration pages (#6480) @flaviendelangle
|
|
201
|
+
|
|
202
|
+
### Core
|
|
203
|
+
|
|
204
|
+
- [core] Add CodeQL workflow (#6387) @DanailH
|
|
205
|
+
- [core] Add missing breaking change to the changelog (#6471) @flaviendelangle
|
|
206
|
+
- [core] Fix playground structure (#6466) @LukasTy
|
|
207
|
+
- [core] Fix tests for pasting on fields (#6465) @flaviendelangle
|
|
208
|
+
- [core] Remove absolute link (#6420) @flaviendelangle
|
|
209
|
+
- [core] Remove unused `react-text-mask` package (#6408) @LukasTy
|
|
210
|
+
- [core] Send explicit warning when dayjs locale is not found (#6424) @alexfauquette
|
|
211
|
+
- [core] Test validation on textfield and date views (#6265) @alexfauquette
|
|
212
|
+
- [test] Sync comment with monorepo @oliviertassinari
|
|
213
|
+
|
|
6
214
|
## v6.0.0-alpha.2
|
|
7
215
|
|
|
8
216
|
_Oct 7, 2022_
|
|
@@ -24,9 +232,9 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
|
|
|
24
232
|
You can now use the aggregation without the `experimentalFeatures.aggregation` flag enabled.
|
|
25
233
|
|
|
26
234
|
```diff
|
|
27
|
-
|
|
235
|
+
<DataGridPremium
|
|
28
236
|
- experimentalFeatures={{ aggregation: true }}
|
|
29
|
-
|
|
237
|
+
/>
|
|
30
238
|
```
|
|
31
239
|
|
|
32
240
|
The aggregation of the columns through the column menu is now enabled by default on `DataGridPremium`. You can set `disableAggregation={true}` to disable it.
|
|
@@ -49,10 +257,10 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
|
|
|
49
257
|
|
|
50
258
|
```diff
|
|
51
259
|
// Same for any other date, date time or date range picker.
|
|
52
|
-
|
|
260
|
+
<DatePicker
|
|
53
261
|
- renderDay={(_, dayProps) => <CustomDay {...dayProps} />}
|
|
54
262
|
+ components={{ Day: CustomDay }}
|
|
55
|
-
|
|
263
|
+
/>
|
|
56
264
|
```
|
|
57
265
|
|
|
58
266
|
#### Changes
|
|
@@ -114,7 +322,7 @@ We'd like to offer a big thanks to the 8 contributors who made this release poss
|
|
|
114
322
|
Here is an example of the old and new approach showing how to apply a custom value formatter in groups for the grouping column:
|
|
115
323
|
|
|
116
324
|
```diff
|
|
117
|
-
<DataGridPremium
|
|
325
|
+
<DataGridPremium
|
|
118
326
|
groupingColDef={() => ({
|
|
119
327
|
valueFormatter: (params) => {
|
|
120
328
|
if (params.id == null) {
|
|
@@ -155,9 +363,8 @@ We'd like to offer a big thanks to the 8 contributors who made this release poss
|
|
|
155
363
|
|
|
156
364
|
#### Breaking changes
|
|
157
365
|
|
|
158
|
-
-
|
|
366
|
+
- The `value` prop of the pickers now expects a parsed value.
|
|
159
367
|
|
|
160
|
-
The `value` prop of the pickers now expects a parsed value.
|
|
161
368
|
Until now, it was possible to provide any format that your date management library was able to parse.
|
|
162
369
|
For instance, you could pass `value={new Date()}` when using `AdapterDayjs`.
|
|
163
370
|
|
|
@@ -296,12 +503,24 @@ We'd like to offer a big thanks to the 12 contributors who made this release pos
|
|
|
296
503
|
|
|
297
504
|
You can find more information about the new api, including how to set those translations on all your components at once in the [documentation](https://next.mui.com/x/react-date-pickers/localization/)
|
|
298
505
|
|
|
506
|
+
- The deprecated `locale` prop of the `LocalizationProvider` component have been renamed `adapterLocale`:
|
|
507
|
+
|
|
508
|
+
```diff
|
|
509
|
+
<LocalizationProvider
|
|
510
|
+
dateAdapter={AdapterDayjs}
|
|
511
|
+
- locale="fr"
|
|
512
|
+
+ adapterLocale="fr"
|
|
513
|
+
>
|
|
514
|
+
{children}
|
|
515
|
+
</LocalizationProvider>
|
|
516
|
+
```
|
|
517
|
+
|
|
299
518
|
- The component slots `LeftArrowButton` and `RightArrowButton` have been renamed `PreviousIconButton` and `NextIconButton` to better describe there usage:
|
|
300
519
|
|
|
301
520
|
```diff
|
|
302
|
-
<DatePicker
|
|
521
|
+
<DatePicker
|
|
303
522
|
components={{
|
|
304
|
-
- LeftArrowButton: CustomButton,
|
|
523
|
+
- LeftArrowButton: CustomButton,
|
|
305
524
|
+ PreviousIconButton: CustomButton,
|
|
306
525
|
|
|
307
526
|
- RightArrowButton: CustomButton,
|
|
@@ -309,7 +528,7 @@ You can find more information about the new api, including how to set those tran
|
|
|
309
528
|
}}
|
|
310
529
|
|
|
311
530
|
componentsProps={{
|
|
312
|
-
- leftArrowButton: {},
|
|
531
|
+
- leftArrowButton: {},
|
|
313
532
|
+ previousIconButton: {},
|
|
314
533
|
|
|
315
534
|
- rightArrowButton: {},
|
|
@@ -2496,8 +2715,8 @@ _Nov 23, 2021_
|
|
|
2496
2715
|
|
|
2497
2716
|
🎉 We are excited to introduce [MUI X v5.0.0](https://mui.com/blog/mui-x-v5/) 🎉!
|
|
2498
2717
|
|
|
2499
|
-
If you want to migrate the DataGrid or DataGridPro from v4 to v5, take a look at the [migration guide](https://mui.com/x/
|
|
2500
|
-
This version is fully compatible with `@mui/material@5.X` and can be used with `@material-ui/core@4.x` with some [additional steps](https://mui.com/x/
|
|
2718
|
+
If you want to migrate the DataGrid or DataGridPro from v4 to v5, take a look at the [migration guide](https://mui.com/x/migration/migration-data-grid-v4/).
|
|
2719
|
+
This version is fully compatible with `@mui/material@5.X` and can be used with `@material-ui/core@4.x` with some [additional steps](https://mui.com/x/migration/migration-data-grid-v4/#using-mui-x-v5-with-mui-core-v4).
|
|
2501
2720
|
|
|
2502
2721
|
A big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
2503
2722
|
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -196,8 +196,6 @@ DataGridRaw.propTypes = {
|
|
|
196
196
|
*/
|
|
197
197
|
experimentalFeatures: PropTypes.shape({
|
|
198
198
|
columnGrouping: PropTypes.bool,
|
|
199
|
-
newEditingApi: PropTypes.bool,
|
|
200
|
-
preventCommitWhileValidating: PropTypes.bool,
|
|
201
199
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
202
200
|
}),
|
|
203
201
|
|
|
@@ -374,14 +372,6 @@ DataGridRaw.propTypes = {
|
|
|
374
372
|
*/
|
|
375
373
|
onCellDoubleClick: PropTypes.func,
|
|
376
374
|
|
|
377
|
-
/**
|
|
378
|
-
* Callback fired when the cell changes are committed.
|
|
379
|
-
* @param {GridCellEditCommitParams} params With all properties from [[GridCellEditCommitParams]].
|
|
380
|
-
* @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
|
|
381
|
-
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
382
|
-
*/
|
|
383
|
-
onCellEditCommit: PropTypes.func,
|
|
384
|
-
|
|
385
375
|
/**
|
|
386
376
|
* Callback fired when the cell turns to edit mode.
|
|
387
377
|
* @param {GridCellParams} params With all properties from [[GridCellParams]].
|
|
@@ -482,15 +472,6 @@ DataGridRaw.propTypes = {
|
|
|
482
472
|
*/
|
|
483
473
|
onColumnVisibilityModelChange: PropTypes.func,
|
|
484
474
|
|
|
485
|
-
/**
|
|
486
|
-
* Callback fired when the edit cell value changes.
|
|
487
|
-
* @param {GridEditCellPropsParams} params With all properties from [[GridEditCellPropsParams]].
|
|
488
|
-
* @param {MuiEvent<React.SyntheticEvent>} event The event that caused this prop to be called.
|
|
489
|
-
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
490
|
-
* @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/x/api/data-grid/grid-col-def/)
|
|
491
|
-
*/
|
|
492
|
-
onEditCellPropsChange: PropTypes.func,
|
|
493
|
-
|
|
494
475
|
/**
|
|
495
476
|
* Callback fired when the `editRowsModel` changes.
|
|
496
477
|
* @param {GridEditRowsModel} editRowsModel With all properties from [[GridEditRowsModel]].
|
|
@@ -677,7 +658,6 @@ DataGridRaw.propTypes = {
|
|
|
677
658
|
|
|
678
659
|
/**
|
|
679
660
|
* Callback called before updating a row with new values in the row and cell editing.
|
|
680
|
-
* Only applied if `props.experimentalFeatures.newEditingApi: true`.
|
|
681
661
|
* @template R
|
|
682
662
|
* @param {R} newRow Row object with the new values.
|
|
683
663
|
* @param {R} oldRow Row object with the old values.
|
|
@@ -11,8 +11,7 @@ import { focusStateInitializer, useGridFocus } from '../hooks/features/focus/use
|
|
|
11
11
|
import { useGridKeyboardNavigation } from '../hooks/features/keyboardNavigation/useGridKeyboardNavigation';
|
|
12
12
|
import { useGridPagination, paginationStateInitializer } from '../hooks/features/pagination/useGridPagination';
|
|
13
13
|
import { useGridPreferencesPanel, preferencePanelStateInitializer } from '../hooks/features/preferencesPanel/useGridPreferencesPanel';
|
|
14
|
-
import { useGridEditing
|
|
15
|
-
import { useGridEditing as useGridEditing_new, editingStateInitializer as editingStateInitializer_new } from '../hooks/features/editRows/useGridEditing.new';
|
|
14
|
+
import { useGridEditing, editingStateInitializer } from '../hooks/features/editing/useGridEditing';
|
|
16
15
|
import { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
|
|
17
16
|
import { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
|
|
18
17
|
import { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
@@ -28,8 +27,6 @@ import { useGridColumnSpanning } from '../hooks/features/columns/useGridColumnSp
|
|
|
28
27
|
import { useGridColumnGrouping, columnGroupsStateInitializer } from '../hooks/features/columnGrouping/useGridColumnGrouping';
|
|
29
28
|
import { useGridColumnGroupingPreProcessors } from '../hooks/features/columnGrouping/useGridColumnGroupingPreProcessors';
|
|
30
29
|
export const useDataGridComponent = props => {
|
|
31
|
-
var _props$experimentalFe, _props$experimentalFe2;
|
|
32
|
-
|
|
33
30
|
const apiRef = useGridInitialization(undefined, props);
|
|
34
31
|
/**
|
|
35
32
|
* Register all pre-processors called during state initialization here.
|
|
@@ -46,7 +43,7 @@ export const useDataGridComponent = props => {
|
|
|
46
43
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
47
44
|
useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
|
|
48
45
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
49
|
-
useGridInitializeState(
|
|
46
|
+
useGridInitializeState(editingStateInitializer, apiRef, props);
|
|
50
47
|
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
51
48
|
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
52
49
|
useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
|
|
@@ -62,7 +59,6 @@ export const useDataGridComponent = props => {
|
|
|
62
59
|
useGridParamsApi(apiRef);
|
|
63
60
|
useGridColumnSpanning(apiRef);
|
|
64
61
|
useGridColumnGrouping(apiRef, props);
|
|
65
|
-
const useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
|
|
66
62
|
useGridEditing(apiRef, props);
|
|
67
63
|
useGridFocus(apiRef, props);
|
|
68
64
|
useGridPreferencesPanel(apiRef, props);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridFilterOperator } from '../models/gridFilterOperator';
|
|
2
2
|
import { GridCellParams } from '../models';
|
|
3
|
-
export declare const getGridNumericQuickFilterFn: (value: any) => (({ value }: GridCellParams) => boolean) | null;
|
|
3
|
+
export declare const getGridNumericQuickFilterFn: (value: any) => (({ value: columnValue }: GridCellParams) => boolean) | null;
|
|
4
4
|
export declare const getGridNumericOperators: () => GridFilterOperator<any, number | string | null, any>[];
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated Use `getGridNumericOperators` instead.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridFilterOperator } from '../models/gridFilterOperator';
|
|
2
2
|
import { GridCellParams, GridColDef } from '../models';
|
|
3
3
|
import { GridApiCommunity } from '../models/api/gridApiCommunity';
|
|
4
|
-
export declare const getGridSingleSelectQuickFilterFn: (value: any, column: GridColDef, apiRef: React.MutableRefObject<GridApiCommunity>) => (({ value }: GridCellParams) => boolean) | null;
|
|
4
|
+
export declare const getGridSingleSelectQuickFilterFn: (value: any, column: GridColDef, apiRef: React.MutableRefObject<GridApiCommunity>) => (({ value: columnValue }: GridCellParams) => boolean) | null;
|
|
5
5
|
export declare const getGridSingleSelectOperators: () => GridFilterOperator[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GridFilterOperator } from '../models/gridFilterOperator';
|
|
2
2
|
import { GridCellParams } from '../models';
|
|
3
|
-
export declare const getGridStringQuickFilterFn: (value: any) => (({ value }: GridCellParams) => boolean) | null;
|
|
3
|
+
export declare const getGridStringQuickFilterFn: (value: any) => (({ value: columnValue }: GridCellParams) => boolean) | null;
|
|
4
4
|
export declare const getGridStringOperators: (disableTrim?: boolean) => GridFilterOperator<any, number | string | null, any>[];
|
|
@@ -10,7 +10,6 @@ import InputBase from '@mui/material/InputBase';
|
|
|
10
10
|
import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
11
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
12
|
import { GridLoadIcon } from '../icons/index';
|
|
13
|
-
import { SUBMIT_FILTER_STROKE_TIME } from '../panel/filterPanel/GridFilterInputValue';
|
|
14
13
|
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
15
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
15
|
|
|
@@ -38,8 +37,6 @@ const GridEditInputCellRoot = styled(InputBase, {
|
|
|
38
37
|
}
|
|
39
38
|
}));
|
|
40
39
|
const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
41
|
-
var _rootProps$experiment, _rootProps$experiment3;
|
|
42
|
-
|
|
43
40
|
const rootProps = useGridRootProps();
|
|
44
41
|
|
|
45
42
|
const {
|
|
@@ -48,7 +45,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
48
45
|
field,
|
|
49
46
|
colDef,
|
|
50
47
|
hasFocus,
|
|
51
|
-
debounceMs =
|
|
48
|
+
debounceMs = 200,
|
|
52
49
|
isProcessingProps,
|
|
53
50
|
onValueChange
|
|
54
51
|
} = props,
|
|
@@ -62,8 +59,6 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
62
59
|
};
|
|
63
60
|
const classes = useUtilityClasses(ownerState);
|
|
64
61
|
const handleChange = React.useCallback(async event => {
|
|
65
|
-
var _rootProps$experiment2;
|
|
66
|
-
|
|
67
62
|
const newValue = event.target.value;
|
|
68
63
|
|
|
69
64
|
if (onValueChange) {
|
|
@@ -73,7 +68,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
73
68
|
const column = apiRef.current.getColumn(field);
|
|
74
69
|
let parsedValue = newValue;
|
|
75
70
|
|
|
76
|
-
if (column.valueParser
|
|
71
|
+
if (column.valueParser) {
|
|
77
72
|
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
|
|
78
73
|
}
|
|
79
74
|
|
|
@@ -85,7 +80,7 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
85
80
|
debounceMs,
|
|
86
81
|
unstable_skipValueParser: true
|
|
87
82
|
}, event);
|
|
88
|
-
}, [apiRef, debounceMs, field, id, onValueChange
|
|
83
|
+
}, [apiRef, debounceMs, field, id, onValueChange]);
|
|
89
84
|
const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
|
|
90
85
|
React.useEffect(() => {
|
|
91
86
|
if (meta.changeReason !== 'debouncedSetEditCellValue') {
|
|
@@ -83,8 +83,6 @@ function GridEditSingleSelectCell(props) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
const handleChange = async event => {
|
|
86
|
-
var _rootProps$experiment;
|
|
87
|
-
|
|
88
86
|
setOpen(false);
|
|
89
87
|
const target = event.target; // NativeSelect casts the value to a string.
|
|
90
88
|
|
|
@@ -94,35 +92,11 @@ function GridEditSingleSelectCell(props) {
|
|
|
94
92
|
await onValueChange(event, formattedTargetValue);
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
|
|
95
|
+
await apiRef.current.setEditCellValue({
|
|
98
96
|
id,
|
|
99
97
|
field,
|
|
100
98
|
value: formattedTargetValue
|
|
101
99
|
}, event);
|
|
102
|
-
|
|
103
|
-
if ((_rootProps$experiment = rootProps.experimentalFeatures) != null && _rootProps$experiment.newEditingApi) {
|
|
104
|
-
return;
|
|
105
|
-
} // We use isValid === false because the default return is undefined which evaluates to true with !isValid
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (rootProps.editMode === GridEditModes.Row || isValid === false) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const canCommit = await Promise.resolve(apiRef.current.commitCellChange({
|
|
113
|
-
id,
|
|
114
|
-
field
|
|
115
|
-
}, event));
|
|
116
|
-
|
|
117
|
-
if (canCommit) {
|
|
118
|
-
apiRef.current.setCellMode(id, field, 'view');
|
|
119
|
-
|
|
120
|
-
if (event.key) {
|
|
121
|
-
// TODO v6: remove once we stop ignoring events fired from portals
|
|
122
|
-
const params = apiRef.current.getCellParams(id, field);
|
|
123
|
-
apiRef.current.publishEvent('cellNavigationKeyDown', params, event);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
100
|
};
|
|
127
101
|
|
|
128
102
|
const handleClose = (event, reason) => {
|
|
@@ -132,17 +106,11 @@ function GridEditSingleSelectCell(props) {
|
|
|
132
106
|
}
|
|
133
107
|
|
|
134
108
|
if (reason === 'backdropClick' || isEscapeKey(event.key)) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
field,
|
|
141
|
-
ignoreModifications: true
|
|
142
|
-
});
|
|
143
|
-
} else {
|
|
144
|
-
apiRef.current.setCellMode(id, field, 'view');
|
|
145
|
-
}
|
|
109
|
+
apiRef.current.stopCellEditMode({
|
|
110
|
+
id,
|
|
111
|
+
field,
|
|
112
|
+
ignoreModifications: true
|
|
113
|
+
});
|
|
146
114
|
}
|
|
147
115
|
};
|
|
148
116
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridFilterItem, GridLinkOperator } from '../../../models/gridFilterItem';
|
|
3
|
+
import { GridColDef, GridStateColDef } from '../../../models/colDef/gridColDef';
|
|
4
|
+
export interface FilterColumnsArgs {
|
|
5
|
+
field: GridColDef['field'];
|
|
6
|
+
columns: GridStateColDef[];
|
|
7
|
+
currentFilters: GridFilterItem[];
|
|
8
|
+
}
|
|
3
9
|
export interface GridFilterFormProps {
|
|
4
10
|
/**
|
|
5
11
|
* The [[GridFilterItem]] representing this form.
|
|
@@ -42,6 +48,12 @@ export interface GridFilterFormProps {
|
|
|
42
48
|
* @param {GridFilterItem} item The deleted [[GridFilterItem]].
|
|
43
49
|
*/
|
|
44
50
|
deleteFilter: (item: GridFilterItem) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Allows to filter the columns displayed in the filter form.
|
|
53
|
+
* @param {FilterColumnsArgs} args The columns of the grid and name of field.
|
|
54
|
+
* @returns {GridColDef['field'][]} The filtered fields array.
|
|
55
|
+
*/
|
|
56
|
+
filterColumns?: (args: FilterColumnsArgs) => GridColDef['field'][];
|
|
45
57
|
/**
|
|
46
58
|
* Sets the available logic operators.
|
|
47
59
|
* @default [GridLinkOperator.And, GridLinkOperator.Or]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "multiFilterOperator", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "linkOperators", "columnsSort", "deleteIconProps", "linkOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "children"],
|
|
3
|
+
const _excluded = ["item", "hasMultipleFilters", "deleteFilter", "applyFilterChanges", "multiFilterOperator", "showMultiFilterOperators", "disableMultiFilterOperator", "applyMultiFilterOperatorChanges", "focusElementRef", "linkOperators", "columnsSort", "filterColumns", "deleteIconProps", "linkOperatorInputProps", "operatorInputProps", "columnInputProps", "valueInputProps", "children"],
|
|
4
4
|
_excluded2 = ["InputComponentProps"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -13,6 +13,7 @@ import { capitalize, unstable_useId as useId } from '@mui/material/utils';
|
|
|
13
13
|
import { styled } from '@mui/material/styles';
|
|
14
14
|
import clsx from 'clsx';
|
|
15
15
|
import { gridFilterableColumnDefinitionsSelector } from '../../../hooks/features/columns/gridColumnsSelector';
|
|
16
|
+
import { gridFilterModelSelector } from '../../../hooks/features/filter/gridFilterSelector';
|
|
16
17
|
import { useGridSelector } from '../../../hooks/utils/useGridSelector';
|
|
17
18
|
import { GridLinkOperator } from '../../../models/gridFilterItem';
|
|
18
19
|
import { useGridApiContext } from '../../../hooks/utils/useGridApiContext';
|
|
@@ -120,6 +121,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
120
121
|
focusElementRef,
|
|
121
122
|
linkOperators = [GridLinkOperator.And, GridLinkOperator.Or],
|
|
122
123
|
columnsSort,
|
|
124
|
+
filterColumns,
|
|
123
125
|
deleteIconProps = {},
|
|
124
126
|
linkOperatorInputProps = {},
|
|
125
127
|
operatorInputProps = {},
|
|
@@ -130,6 +132,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
130
132
|
|
|
131
133
|
const apiRef = useGridApiContext();
|
|
132
134
|
const filterableColumns = useGridSelector(apiRef, gridFilterableColumnDefinitionsSelector);
|
|
135
|
+
const filterModel = useGridSelector(apiRef, gridFilterModelSelector);
|
|
133
136
|
const columnSelectId = useId();
|
|
134
137
|
const columnSelectLabelId = useId();
|
|
135
138
|
const operatorSelectId = useId();
|
|
@@ -152,18 +155,30 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
152
155
|
} = valueInputProps,
|
|
153
156
|
valueInputPropsOther = _objectWithoutPropertiesLoose(valueInputProps, _excluded2);
|
|
154
157
|
|
|
155
|
-
const
|
|
158
|
+
const filteredColumns = React.useMemo(() => {
|
|
159
|
+
if (filterColumns === undefined || typeof filterColumns !== 'function') {
|
|
160
|
+
return filterableColumns;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const filteredFields = filterColumns({
|
|
164
|
+
field: item.columnField,
|
|
165
|
+
columns: filterableColumns,
|
|
166
|
+
currentFilters: (filterModel == null ? void 0 : filterModel.items) || []
|
|
167
|
+
});
|
|
168
|
+
return filterableColumns.filter(column => filteredFields.includes(column.field));
|
|
169
|
+
}, [filterColumns, filterModel == null ? void 0 : filterModel.items, filterableColumns, item.columnField]);
|
|
170
|
+
const sortedFilteredColumns = React.useMemo(() => {
|
|
156
171
|
switch (columnsSort) {
|
|
157
172
|
case 'asc':
|
|
158
|
-
return
|
|
173
|
+
return filteredColumns.sort((a, b) => collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
159
174
|
|
|
160
175
|
case 'desc':
|
|
161
|
-
return
|
|
176
|
+
return filteredColumns.sort((a, b) => -collator.compare(getColumnLabel(a), getColumnLabel(b)));
|
|
162
177
|
|
|
163
178
|
default:
|
|
164
|
-
return
|
|
179
|
+
return filteredColumns;
|
|
165
180
|
}
|
|
166
|
-
}, [
|
|
181
|
+
}, [filteredColumns, columnsSort]);
|
|
167
182
|
const currentColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null;
|
|
168
183
|
const currentOperator = React.useMemo(() => {
|
|
169
184
|
var _currentColumn$filter;
|
|
@@ -292,7 +307,7 @@ const GridFilterForm = /*#__PURE__*/React.forwardRef(function GridFilterForm(pro
|
|
|
292
307
|
onChange: changeColumn,
|
|
293
308
|
native: isBaseSelectNative
|
|
294
309
|
}, (_rootProps$components4 = rootProps.componentsProps) == null ? void 0 : _rootProps$components4.baseSelect, {
|
|
295
|
-
children:
|
|
310
|
+
children: sortedFilteredColumns.map(col => /*#__PURE__*/_jsx(OptionComponent, {
|
|
296
311
|
value: col.field,
|
|
297
312
|
children: getColumnLabel(col)
|
|
298
313
|
}, col.field))
|
|
@@ -386,6 +401,13 @@ process.env.NODE_ENV !== "production" ? GridFilterForm.propTypes = {
|
|
|
386
401
|
*/
|
|
387
402
|
disableMultiFilterOperator: PropTypes.bool,
|
|
388
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Allows to filter the columns displayed in the filter form.
|
|
406
|
+
* @param {FilterColumnsArgs} args The columns of the grid and name of field.
|
|
407
|
+
* @returns {GridColDef['field'][]} The filtered fields array.
|
|
408
|
+
*/
|
|
409
|
+
filterColumns: PropTypes.func,
|
|
410
|
+
|
|
389
411
|
/**
|
|
390
412
|
* A ref allowing to set imperative focus.
|
|
391
413
|
* It can be passed to the el
|