@mui/x-data-grid 7.0.0 → 7.1.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +246 -4
  2. package/DataGrid/DataGrid.js +5 -0
  3. package/DataGrid/useDataGridProps.js +1 -0
  4. package/README.md +1 -1
  5. package/components/cell/GridCell.js +0 -1
  6. package/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  7. package/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  8. package/components/toolbar/GridToolbarQuickFilter.js +17 -2
  9. package/components/virtualization/GridMainContainer.js +8 -1
  10. package/components/virtualization/GridTopContainer.js +1 -0
  11. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  12. package/hooks/features/dimensions/useGridDimensions.js +3 -2
  13. package/hooks/features/editing/useGridRowEditing.js +13 -4
  14. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
  15. package/hooks/features/headerFiltering/useGridHeaderFiltering.js +4 -7
  16. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
  17. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -3
  18. package/hooks/features/virtualization/useGridVirtualScroller.js +17 -6
  19. package/index.js +1 -1
  20. package/internals/index.d.ts +1 -1
  21. package/internals/utils/propValidation.d.ts +1 -0
  22. package/internals/utils/propValidation.js +9 -4
  23. package/locales/esES.js +3 -4
  24. package/locales/faIR.js +3 -4
  25. package/locales/ptBR.js +3 -4
  26. package/models/gridExport.d.ts +2 -2
  27. package/models/gridFilterModel.d.ts +3 -3
  28. package/models/params/gridCellParams.d.ts +0 -22
  29. package/models/props/DataGridProps.d.ts +24 -0
  30. package/modern/DataGrid/DataGrid.js +5 -0
  31. package/modern/DataGrid/useDataGridProps.js +1 -0
  32. package/modern/components/cell/GridCell.js +0 -1
  33. package/modern/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  34. package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  35. package/modern/components/toolbar/GridToolbarQuickFilter.js +17 -2
  36. package/modern/components/virtualization/GridMainContainer.js +8 -1
  37. package/modern/components/virtualization/GridTopContainer.js +1 -0
  38. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -2
  39. package/modern/hooks/features/editing/useGridRowEditing.js +13 -4
  40. package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +4 -7
  41. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -3
  42. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -6
  43. package/modern/index.js +1 -1
  44. package/modern/internals/utils/propValidation.js +9 -4
  45. package/modern/locales/esES.js +3 -4
  46. package/modern/locales/faIR.js +3 -4
  47. package/modern/locales/ptBR.js +3 -4
  48. package/modern/utils/throttle.js +19 -0
  49. package/node/DataGrid/DataGrid.js +5 -0
  50. package/node/DataGrid/useDataGridProps.js +1 -0
  51. package/node/components/cell/GridCell.js +0 -1
  52. package/node/components/columnHeaders/GridColumnHeaderItem.js +3 -1
  53. package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +3 -1
  54. package/node/components/toolbar/GridToolbarQuickFilter.js +17 -2
  55. package/node/components/virtualization/GridMainContainer.js +8 -1
  56. package/node/components/virtualization/GridTopContainer.js +1 -0
  57. package/node/hooks/features/dimensions/useGridDimensions.js +2 -1
  58. package/node/hooks/features/editing/useGridRowEditing.js +13 -4
  59. package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +4 -7
  60. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +1 -3
  61. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -6
  62. package/node/index.js +1 -1
  63. package/node/internals/utils/propValidation.js +12 -6
  64. package/node/locales/esES.js +3 -4
  65. package/node/locales/faIR.js +3 -4
  66. package/node/locales/ptBR.js +3 -4
  67. package/node/utils/throttle.js +25 -0
  68. package/package.json +2 -2
  69. package/utils/throttle.d.ts +4 -0
  70. package/utils/throttle.js +19 -0
package/CHANGELOG.md CHANGED
@@ -3,7 +3,179 @@
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
- ## v7.0.0
6
+ ## 7.1.1
7
+
8
+ _Apr 5, 2024_
9
+
10
+ We'd like to offer a big thanks to the 19 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🚀 Add `setItemExpansion` Tree View API method (#12595) @flaviendelangle
13
+ - 🌍 Improve Persian (fa-IR), Portuguese (pt-BR), and Spanish (es-ES) locale on the Data Grid
14
+ - 🌍 Improve Persian (fa-IR), Portuguese (pt-BR), and Ukrainian (uk-UA) locale on the Pickers
15
+ - 🐞 Bugfixes
16
+ - 📚 Documentation improvements
17
+
18
+ ### Data Grid
19
+
20
+ #### `@mui/x-data-grid@7.1.1`
21
+
22
+ - [DataGrid] Allow higher packages' props to be used in MIT (#12365) @MBilalShafi
23
+ - [DataGrid] Fix RTL mode (#12583) @romgrk
24
+ - [DataGrid] Fix `ColDefChangesGridNoSnap` demo crash (#12663) @MBilalShafi
25
+ - [DataGrid] Fix server-side filter demo not working (#12662) @MBilalShafi
26
+ - [DataGrid] Log error if `rowCount` is used with client-side pagination (#12448) @michelengelen
27
+ - [DataGrid] Remove `GridFormatterParams` completely (#12660) @romgrk
28
+ - [DataGrid] Restore main slot (#12657) @romgrk
29
+ - [l10n] Improve Persian (fa-IR) locale (#12630) @amirhosseinzf
30
+ - [l10n] Improve Portuguese (pt-BR) locale (#12618) @hugoalkimim
31
+ - [l10n] Improve Spanish (es-ES) locale (#12606) @aitor40
32
+
33
+ #### `@mui/x-data-grid-pro@7.1.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
34
+
35
+ Same changes as in `@mui/x-data-grid@7.1.1`.
36
+
37
+ #### `@mui/x-data-grid-premium@7.1.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
38
+
39
+ Same changes as in `@mui/x-data-grid-pro@7.1.1`.
40
+
41
+ ### Date and Time Pickers
42
+
43
+ #### `@mui/x-date-pickers@7.1.1`
44
+
45
+ - [fields] Fix `readOnly` behavior (#12609) @LukasTy
46
+ - [l10n] Improve Persian (fa-IR) locale (#12632) @misafari
47
+ - [l10n] Improve Portuguese (pt-BR) locale (#12613) @cnHealth
48
+ - [l10n] Improve Ukrainian (uk-UA) locale (#12627) @alexkobylansky
49
+
50
+ #### `@mui/x-date-pickers-pro@7.1.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
51
+
52
+ Same changes as in `@mui/x-date-pickers@7.1.1`, plus:
53
+
54
+ - [DateTimeRangePicker] Fix selection on same day (#12604) @LukasTy
55
+
56
+ ### Charts
57
+
58
+ #### `@mui/x-charts@7.1.1`
59
+
60
+ - [charts] Fix `tickInterval` usage for y-axis (#12592) @alexfauquette
61
+ - [charts] Fix Scatter series highlight when `id` is a `number` (#12677) @JCQuintas
62
+ - [charts] Fix TS error when using `sx` property on `ChartsTooltip` (#12659) @JCQuintas
63
+
64
+ ### Tree View
65
+
66
+ #### `@mui/x-tree-view@7.1.1`
67
+
68
+ - [TreeView] Add JSDoc to all `publicAPI` methods (#12649) @flaviendelangle
69
+ - [TreeView] Create `RichTreeViewPro` component (not released yet) (#12610) @flaviendelangle
70
+ - [TreeView] Create pro package (not released yet) (#12240) @flaviendelangle
71
+ - [TreeView] Fix typo in errors (#12623) @alissa-tung
72
+ - [TreeView] New API method: `setItemExpansion` (#12595) @flaviendelangle
73
+
74
+ ### Docs
75
+
76
+ - [docs] Add a recipe for the `checkboxSelectionVisibleOnly` prop (#12646) @michelengelen
77
+ - [docs] Explain the use of `_action: 'delete'` in `processRowUpdate` (#12670) @michelengelen
78
+ - [docs] Fix formatting and typo on migration guide @oliviertassinari
79
+ - [docs] Fix formatting in changelog @oliviertassinari
80
+ - [docs] Fix grammar in TreeView migration doc (#12615) @joshkel
81
+ - [docs] Fix missing closing props in `PieShapeNoSnap` demo (#12636) @alp-ex
82
+ - [docs] Fix type arguments in Custom Field page (#12619) @Juneezee
83
+ - [docs] Fix typo in `getItemId` prop description (#12637) @flaviendelangle
84
+ - [docs] Make the Charts `margin` usage more visible (#12591) @alexfauquette
85
+ - [docs] Match IE 11 spacing with Material UI @oliviertassinari
86
+ - [docs] Move data grid interfaces to standard API page layout (#12016) @alexfauquette
87
+ - [docs] Remove ` around @default values (#12158) @alexfauquette
88
+ - [docs] Remove `day` from the default `dayOfWeekFormatter` function params (#12644) @LukasTy
89
+ - [docs] Use `TreeItem2` for icon expansion example on `RichTreeView` (#12563) @flaviendelangle
90
+
91
+ ### Core
92
+
93
+ - [core] Add cherry-pick `master` to `v6` action (#12648) @LukasTy
94
+ - [core] Fix typo in `@mui/x-tree-view-pro/themeAugmentation` (#12674) @flaviendelangle
95
+ - [core] Introduce `describeTreeView` to run test on `SimpleTreeView` and `RichTreeView`, using `TreeItem` and `TreeItem2` + migrate expansion tests (#12428) @flaviendelangle
96
+ - [core] Limit `test-types` CI step allowed memory (#12651) @LukasTy
97
+ - [core] Remove explicit `express` package (#12602) @LukasTy
98
+ - [core] Update to new embedded translations in the docs package (#12232) @Janpot
99
+ - [core] Use PR labels to identify the package a `l10n` PR belongs to (#12639) @LukasTy
100
+ - [core] Use `describeTreeView` for selection tests (#12647) @flaviendelangle
101
+ - [docs-infra] Adjust the links to search for issues (#11995) @michelengelen
102
+ - [infra] Polish support survey experience (#12624) @oliviertassinari
103
+ - [support-infra] Replace author association with a permission check in survey action (#12068) @michelengelen
104
+ - [support-infra] Fix user permission check (#12669) @michelengelen
105
+ - [test] Fix Tree View test import (#12668) @LukasTy
106
+
107
+ ## 7.1.0
108
+
109
+ _Mar 28, 2024_
110
+
111
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
112
+
113
+ - 🚀 Add `resizeThrottleMs` prop (#12556) @romgrk
114
+ - 🌍 Improve Chinese (Hong Kong) (zh-HK) and Italian (it-IT) locale on the Pickers
115
+ - 🐞 Bugfixes
116
+ - 📚 Documentation improvements
117
+
118
+ ### Data Grid
119
+
120
+ #### `@mui/x-data-grid@7.1.0`
121
+
122
+ - [DataGrid] Add `resizeThrottleMs` prop (#12556) @romgrk
123
+ - [DataGrid] Do not publish `rowEditStop` event if row has fields with errors (#11383) @cherniavskii
124
+ - [DataGrid] Fix bug in suspense (#12553) @romgrk
125
+ - [DataGrid] Fix missing class name in the `GridToolbarQuickFilter` component (#12484) @jhawkins11
126
+
127
+ #### `@mui/x-data-grid-pro@7.1.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
128
+
129
+ Same changes as in `@mui/x-data-grid@7.1.0`.
130
+
131
+ #### `@mui/x-data-grid-premium@7.1.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
132
+
133
+ Same changes as in `@mui/x-data-grid-pro@7.1.0`.
134
+
135
+ ### Date and Time Pickers
136
+
137
+ #### `@mui/x-date-pickers@7.1.0`
138
+
139
+ - [fields] Fix placeholder override (#12589) @flaviendelangle
140
+ - [l10n] Improve Chinese (Hong Kong) (zh-HK) locale (#12547) @samchiu90
141
+ - [l10n] Improve Italian (it-IT) locale (#12549) @antomanc
142
+ - [pickers] Prepare compatibility with `@mui/zero-runtime` (stop using `ownerState` in `styled`) (#12003) @flaviendelangle
143
+
144
+ #### `@mui/x-date-pickers-pro@7.1.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
145
+
146
+ Same changes as in `@mui/x-date-pickers@7.1.0`, plus:
147
+
148
+ - [DateRangePicker] Fix selection behavior with single input field when `readOnly` (#12593) @LukasTy
149
+
150
+ ### Charts
151
+
152
+ #### `@mui/x-charts@7.1.0`
153
+
154
+ - [charts] Fix tooltip causing crash on data change (#12571) @Rishi556
155
+
156
+ ### Tree View
157
+
158
+ #### `@mui/x-tree-view@7.1.0`
159
+
160
+ - [TreeView] Do not use outdated version of the state to compute new label first char in `RichTreeView` (#12512) @flaviendelangle
161
+
162
+ ### Docs
163
+
164
+ - [docs] Add example to add a second icon next to the field's opening button (#12524) @flaviendelangle
165
+ - [docs] Add missing note to Data Grid migration guide (#12557) @romgrk
166
+ - [docs] Fix Charts title for SEO (#12545) @oliviertassinari
167
+ - [docs] Fix small typo (#12558) @diogoparente
168
+ - [docs] Improve codemod related documentation (#12582) @MBilalShafi
169
+ - [docs] Reduce noise in migration docs side navigation (#12552) @cherniavskii
170
+ - [docs] Sync static images from core repository (#12525) @LukasTy
171
+
172
+ ### Core
173
+
174
+ - [core] Fix `l10n` script on Windows (#12550) @LukasTy
175
+ - [core] Include `DateTimeRangePicker` tag in `releaseChangelog` (#12526) @LukasTy
176
+ - [core] Upgrade monorepo (#12536) @cherniavskii
177
+
178
+ ## 7.0.0
7
179
 
8
180
  _Mar 22, 2024_
9
181
 
@@ -459,13 +631,13 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
459
631
 
460
632
  - 🎁 Introduce a new DOM structure for the field components that provides a better accessibility
461
633
  - 🚀 Simplify Data Grid DOM structure for improved performance (#12013) @romgrk
462
- - 🕥 The support for IE11 has been removed (#12151) @flaviendelangle
634
+ - 🕥 The support for IE 11 has been removed (#12151) @flaviendelangle
463
635
  - 🐞 Bugfixes
464
636
  - 📚 Documentation improvements
465
637
 
466
638
  ### Breaking changes
467
639
 
468
- - The support for IE11 has been removed from all MUI X packages. The `legacy` bundle that used to support old browsers like IE11 is no longer included.
640
+ - The support for IE 11 has been removed from all MUI X packages. The `legacy` bundle that used to support old browsers like IE 11 is no longer included.
469
641
 
470
642
  ### Data Grid
471
643
 
@@ -570,7 +742,7 @@ These components are no longer exported from `@mui/x-charts`:
570
742
 
571
743
  ### Tree View / `@mui/x-tree-view@7.0.0-beta.4`
572
744
 
573
- - [TreeView] Stop using custom `findIndex` to support IE11 (#12129) @flaviendelangle
745
+ - [TreeView] Stop using custom `findIndex` to support IE 11 (#12129) @flaviendelangle
574
746
 
575
747
  ### Docs
576
748
 
@@ -2800,6 +2972,76 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
2800
2972
  - [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
2801
2973
  - [license] Correctly throw errors (#10924) @oliviertassinari
2802
2974
 
2975
+ ## 6.19.9
2976
+
2977
+ _Apr 5, 2024_
2978
+
2979
+ We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
2980
+
2981
+ - 🐞 Bugfixes
2982
+ - 📚 Documentation improvements
2983
+
2984
+ ### Data Grid
2985
+
2986
+ #### `@mui/x-data-grid@6.19.9`
2987
+
2988
+ - [DataGrid] Remove legacy editing API event: `rowEditCommit` (#12087) @MBilalShafi
2989
+
2990
+ #### `@mui/x-data-grid-pro@6.19.9` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
2991
+
2992
+ Same changes as in `@mui/x-data-grid@6.19.9`.
2993
+
2994
+ #### `@mui/x-data-grid-premium@6.19.9` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
2995
+
2996
+ Same changes as in `@mui/x-data-grid-pro@6.19.9`.
2997
+
2998
+ ### Date Pickers
2999
+
3000
+ #### `@mui/x-date-pickers@6.19.9`
3001
+
3002
+ No changes.
3003
+
3004
+ #### `@mui/x-date-pickers-pro@6.19.9` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
3005
+
3006
+ - [DateRangePicker] Fix selection behavior with single input field when `readOnly` (#12605) @LukasTy
3007
+
3008
+ ### Docs
3009
+
3010
+ - [docs] Add a recipe for the `checkboxSelectionVisibleOnly` prop (#12667) @michelengelen
3011
+ - [docs] Explain the use of `_action: 'delete'` in `processRowUpdate` (#12673) @michelengelen
3012
+
3013
+ ### Core
3014
+
3015
+ - [core] Use Circle CI context (#12607) @cherniavskii
3016
+
3017
+ ## 6.19.8
3018
+
3019
+ _Mar 20, 2024_
3020
+
3021
+ We'd like to offer a big thanks to the 3 contributors who made this release possible.
3022
+
3023
+ ### Data Grid
3024
+
3025
+ #### `@mui/x-data-grid@6.19.8`
3026
+
3027
+ - [DataGrid] Fix `ElementType` usage (#12505) @cherniavskii
3028
+ - [DataGrid] Fix cell value formatting on copy (#12483) @sai6855
3029
+ - [DataGrid] Fix checkbox selection when filtering (#12485) @g1mishra
3030
+
3031
+ #### `@mui/x-data-grid-pro@6.19.8` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
3032
+
3033
+ Same changes as in `@mui/x-data-grid@6.19.8`.
3034
+
3035
+ #### `@mui/x-data-grid-premium@6.19.8` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
3036
+
3037
+ Same changes as in `@mui/x-data-grid-pro@6.19.8`, plus:
3038
+
3039
+ - [DataGridPremium] Add support for confirmation before clipboard paste (#12466) @cherniavskii
3040
+
3041
+ ### Docs
3042
+
3043
+ - [docs] Update links to v7 (#12495) @cherniavskii
3044
+
2803
3045
  ## 6.19.7
2804
3046
 
2805
3047
  _Mar 14, 2024_
@@ -608,6 +608,11 @@ DataGridRaw.propTypes = {
608
608
  * @returns {Promise<R> | R} The final values to update the row.
609
609
  */
610
610
  processRowUpdate: PropTypes.func,
611
+ /**
612
+ * The milliseconds throttle delay for resizing the grid.
613
+ * @default 60
614
+ */
615
+ resizeThrottleMs: PropTypes.number,
611
616
  /**
612
617
  * Row region in pixels to render before/after the viewport
613
618
  * @default 150
@@ -54,6 +54,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
54
54
  pagination: false,
55
55
  paginationMode: 'client',
56
56
  rowHeight: 52,
57
+ resizeThrottleMs: 60,
57
58
  pageSizeOptions: [25, 50, 100],
58
59
  rowSpacingType: 'margin',
59
60
  showCellVerticalBorder: false,
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MUI X Data Grid
2
2
 
3
- This package is the Community plan edition of the data grid component.
3
+ This package is the Community plan edition of the Data Grid components.
4
4
  It's part of [MUI X](https://mui.com/x/), an open-core extension of MUI Core, with advanced components.
5
5
 
6
6
  ## Installation
@@ -159,7 +159,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
159
159
  const cellRef = React.useRef(null);
160
160
  const handleRef = useForkRef(ref, cellRef);
161
161
  const focusElementRef = React.useRef(null);
162
- // @ts-expect-error To access `cellSelection` flag as it's a `premium` feature
163
162
  const isSelectionMode = rootProps.cellSelection ?? false;
164
163
  const position = gridPinnedColumnPositionLookup[pinnedPosition];
165
164
  const showLeftBorder = shouldCellShowLeftBorder(position, sectionIndex);
@@ -153,7 +153,9 @@ function GridColumnHeaderItem(props) {
153
153
  const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
154
154
  const elementToFocus = focusableElement || headerCellRef.current;
155
155
  elementToFocus?.focus();
156
- apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
156
+ if (apiRef.current.columnHeadersContainerRef?.current) {
157
+ apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
158
+ }
157
159
  }
158
160
  }, [apiRef, hasFocus]);
159
161
  const headerClassName = typeof colDef.headerClassName === 'function' ? colDef.headerClassName({
@@ -56,7 +56,9 @@ const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridG
56
56
  const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
57
57
  const elementToFocus = focusableElement || headerCellRef.current;
58
58
  elementToFocus?.focus();
59
- apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
59
+ if (apiRef.current.columnHeadersContainerRef?.current) {
60
+ apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
61
+ }
60
62
  }
61
63
  }, [apiRef, hasFocus]);
62
64
  return /*#__PURE__*/_jsxs("div", _extends({
@@ -1,17 +1,29 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs"];
3
+ const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs", "className"];
4
4
  import * as React from 'react';
5
+ import clsx from 'clsx';
5
6
  import PropTypes from 'prop-types';
6
7
  import TextField from '@mui/material/TextField';
7
8
  import { styled } from '@mui/material/styles';
8
9
  import { unstable_debounce as debounce } from '@mui/utils';
10
+ import composeClasses from '@mui/utils/composeClasses';
11
+ import { getDataGridUtilityClass } from '../../constants';
9
12
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
10
13
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
11
14
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
12
15
  import { gridQuickFilterValuesSelector } from '../../hooks/features/filter';
13
16
  import { isDeepEqual } from '../../utils/utils';
14
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
+ const useUtilityClasses = ownerState => {
19
+ const {
20
+ classes
21
+ } = ownerState;
22
+ const slots = {
23
+ root: ['toolbarQuickFilter']
24
+ };
25
+ return composeClasses(slots, getDataGridUtilityClass, classes);
26
+ };
15
27
  const GridToolbarQuickFilterRoot = styled(TextField, {
16
28
  name: 'MuiDataGrid',
17
29
  slot: 'ToolbarQuickFilter',
@@ -47,11 +59,13 @@ const defaultSearchValueFormatter = values => values.join(' ');
47
59
  function GridToolbarQuickFilter(props) {
48
60
  const apiRef = useGridApiContext();
49
61
  const rootProps = useGridRootProps();
62
+ const classes = useUtilityClasses(rootProps);
50
63
  const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
51
64
  const {
52
65
  quickFilterParser = defaultSearchValueParser,
53
66
  quickFilterFormatter = defaultSearchValueFormatter,
54
- debounceMs = rootProps.filterDebounceMs
67
+ debounceMs = rootProps.filterDebounceMs,
68
+ className
55
69
  } = props,
56
70
  other = _objectWithoutPropertiesLoose(props, _excluded);
57
71
  const [searchValue, setSearchValue] = React.useState(() => quickFilterFormatter(quickFilterValues ?? []));
@@ -86,6 +100,7 @@ function GridToolbarQuickFilter(props) {
86
100
  variant: "standard",
87
101
  value: searchValue,
88
102
  onChange: handleSearchValueChange,
103
+ className: clsx(className, classes.root),
89
104
  placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
90
105
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
91
106
  type: "search"
@@ -1,17 +1,24 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { styled } from '@mui/system';
4
+ import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
4
5
  import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';
5
6
  import { jsx as _jsx } from "react/jsx-runtime";
6
- const Element = styled('div')({
7
+ const Element = styled('div', {
8
+ name: 'MuiDataGrid',
9
+ slot: 'Main',
10
+ overridesResolver: (props, styles) => styles.main
11
+ })({
7
12
  flexGrow: 1,
8
13
  position: 'relative',
9
14
  overflow: 'hidden'
10
15
  });
11
16
  export const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
12
17
  const ariaAttributes = useGridAriaAttributes();
18
+ const rootProps = useGridRootProps();
13
19
  return /*#__PURE__*/_jsx(Element, _extends({
14
20
  ref: ref,
21
+ ownerState: rootProps,
15
22
  className: props.className,
16
23
  tabIndex: -1
17
24
  }, ariaAttributes, {
@@ -21,6 +21,7 @@ const Element = styled('div')({
21
21
  zIndex: 5,
22
22
  bottom: 0,
23
23
  left: 0,
24
+ right: 0,
24
25
  height: 1,
25
26
  width: 'var(--DataGrid-rowWidth)',
26
27
  backgroundColor: 'var(--DataGrid-rowBorderColor)'
@@ -3,7 +3,7 @@ import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import { GridDimensions } from './gridDimensionsApi';
5
5
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
6
- type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'columnHeaderHeight'>;
6
+ type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight'>;
7
7
  export type GridDimensionsState = GridDimensions;
8
8
  export declare const dimensionsStateInitializer: GridStateInitializer<RootProps>;
9
9
  export declare function useGridDimensions(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: RootProps): void;
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { unstable_debounce as debounce, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback, unstable_ownerWindow as ownerWindow } from '@mui/utils';
3
+ import { unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback, unstable_ownerWindow as ownerWindow } from '@mui/utils';
4
4
  import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
5
5
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
6
+ import { throttle } from '../../../utils/throttle';
6
7
  import { useGridLogger } from '../../utils/useGridLogger';
7
8
  import { gridColumnsTotalWidthSelector, gridVisiblePinnedColumnDefinitionsSelector } from '../columns';
8
9
  import { gridDimensionsSelector } from './gridDimensionsSelectors';
@@ -57,7 +58,7 @@ export function useGridDimensions(apiRef, props) {
57
58
  const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
58
59
  const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
59
60
  const [savedSize, setSavedSize] = React.useState();
60
- const debouncedSetSavedSize = React.useMemo(() => debounce(setSavedSize, 60), []);
61
+ const debouncedSetSavedSize = React.useMemo(() => throttle(setSavedSize, props.resizeThrottleMs), [props.resizeThrottleMs]);
61
62
  const previousSize = React.useRef();
62
63
  const getRootDimensions = () => apiRef.current.state.dimensions;
63
64
  const setDimensions = useEventCallback(dimensions => {
@@ -45,6 +45,10 @@ export const useGridRowEditing = (apiRef, props) => {
45
45
  throw new Error(`MUI X: The row with id=${id} is not in ${mode} mode.`);
46
46
  }
47
47
  }, [apiRef]);
48
+ const hasFieldsWithErrors = React.useCallback(rowId => {
49
+ const editingState = gridEditRowsStateSelector(apiRef.current.state);
50
+ return Object.values(editingState[rowId]).some(fieldProps => fieldProps.error);
51
+ }, [apiRef]);
48
52
  const handleCellDoubleClick = React.useCallback((params, event) => {
49
53
  if (!params.isEditable) {
50
54
  return;
@@ -86,6 +90,9 @@ export const useGridRowEditing = (apiRef, props) => {
86
90
  if (apiRef.current.getRowMode(params.id) === GridRowModes.View) {
87
91
  return;
88
92
  }
93
+ if (hasFieldsWithErrors(params.id)) {
94
+ return;
95
+ }
89
96
  const rowParams = apiRef.current.getRowParams(params.id);
90
97
  const newParams = _extends({}, rowParams, {
91
98
  field: params.field,
@@ -94,7 +101,7 @@ export const useGridRowEditing = (apiRef, props) => {
94
101
  apiRef.current.publishEvent('rowEditStop', newParams, event);
95
102
  }
96
103
  });
97
- }, [apiRef]);
104
+ }, [apiRef, hasFieldsWithErrors]);
98
105
  React.useEffect(() => {
99
106
  return () => {
100
107
  clearTimeout(focusTimeout.current);
@@ -140,6 +147,9 @@ export const useGridRowEditing = (apiRef, props) => {
140
147
  }
141
148
  }
142
149
  if (reason) {
150
+ if (reason !== GridRowEditStopReasons.escapeKeyDown && hasFieldsWithErrors(params.id)) {
151
+ return;
152
+ }
143
153
  const newParams = _extends({}, apiRef.current.getRowParams(params.id), {
144
154
  reason,
145
155
  field: params.field
@@ -174,7 +184,7 @@ export const useGridRowEditing = (apiRef, props) => {
174
184
  apiRef.current.publishEvent('rowEditStart', newParams, event);
175
185
  }
176
186
  }
177
- }, [apiRef]);
187
+ }, [apiRef, hasFieldsWithErrors]);
178
188
  const handleRowEditStart = React.useCallback(params => {
179
189
  const {
180
190
  id,
@@ -358,8 +368,7 @@ export const useGridRowEditing = (apiRef, props) => {
358
368
  prevRowModesModel.current[id].mode = GridRowModes.Edit;
359
369
  return;
360
370
  }
361
- const hasSomeFieldWithError = Object.values(editingState[id]).some(fieldProps => fieldProps.error);
362
- if (hasSomeFieldWithError) {
371
+ if (hasFieldsWithErrors(id)) {
363
372
  prevRowModesModel.current[id].mode = GridRowModes.Edit;
364
373
  // Revert the mode in the rowModesModel prop back to "edit"
365
374
  updateRowInRowModesModel(id, {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
- import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
+ import { DataGridProcessedPropsWithShared } from '../../../models/props/DataGridProps';
4
4
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
5
5
  export declare const headerFilteringStateInitializer: GridStateInitializer;
6
- export declare const useGridHeaderFiltering: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'signature'>) => void;
6
+ export declare const useGridHeaderFiltering: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedPropsWithShared, 'signature' | 'headerFilters'>) => void;
@@ -4,7 +4,6 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
4
  import { useGridLogger } from '../../utils';
5
5
  import { gridColumnLookupSelector, gridColumnVisibilityModelSelector, gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
6
6
  export const headerFilteringStateInitializer = (state, props) => _extends({}, state, {
7
- // @ts-expect-error Access `Pro` prop in MIT
8
7
  headerFiltering: {
9
8
  enabled: props.headerFilters ?? false,
10
9
  editing: null,
@@ -13,8 +12,6 @@ export const headerFilteringStateInitializer = (state, props) => _extends({}, st
13
12
  });
14
13
  export const useGridHeaderFiltering = (apiRef, props) => {
15
14
  const logger = useGridLogger(apiRef, 'useGridHeaderFiltering');
16
- // @ts-expect-error Access `Pro` prop in MIT
17
- const isHeaderFilteringEnabled = props.headerFilters ?? false;
18
15
  const setHeaderFilterState = React.useCallback(headerFilterState => {
19
16
  apiRef.current.setState(state => {
20
17
  // Safety check to avoid MIT users from using it
@@ -24,14 +21,14 @@ export const useGridHeaderFiltering = (apiRef, props) => {
24
21
  }
25
22
  return _extends({}, state, {
26
23
  headerFiltering: {
27
- enabled: isHeaderFilteringEnabled ?? false,
24
+ enabled: props.headerFilters ?? false,
28
25
  editing: headerFilterState.editing ?? null,
29
26
  menuOpen: headerFilterState.menuOpen ?? null
30
27
  }
31
28
  });
32
29
  });
33
30
  apiRef.current.forceUpdate();
34
- }, [apiRef, props.signature, isHeaderFilteringEnabled]);
31
+ }, [apiRef, props.signature, props.headerFilters]);
35
32
  const startHeaderFilterEditMode = React.useCallback(field => {
36
33
  logger.debug(`Starting edit mode on header filter for field: ${field}`);
37
34
  apiRef.current.setHeaderFilterState({
@@ -102,8 +99,8 @@ export const useGridHeaderFiltering = (apiRef, props) => {
102
99
  isFirstRender.current = false;
103
100
  } else {
104
101
  apiRef.current.setHeaderFilterState({
105
- enabled: isHeaderFilteringEnabled
102
+ enabled: props.headerFilters ?? false
106
103
  });
107
104
  }
108
- }, [apiRef, isHeaderFilteringEnabled]);
105
+ }, [apiRef, props.headerFilters]);
109
106
  };
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
- import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
+ import { DataGridProcessedPropsWithShared } from '../../../models/props/DataGridProps';
4
4
  /**
5
5
  * @requires useGridSorting (method) - can be after
6
6
  * @requires useGridFilter (state) - can be after
@@ -10,4 +10,4 @@ import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
10
10
  * @requires useGridScroll (method) - can be after
11
11
  * @requires useGridColumnSpanning (method) - can be after
12
12
  */
13
- export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode' | 'getRowId' | 'experimentalFeatures' | 'signature'>) => void;
13
+ export declare const useGridKeyboardNavigation: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedPropsWithShared, 'pagination' | 'paginationMode' | 'getRowId' | 'experimentalFeatures' | 'signature' | 'headerFilters'>) => void;
@@ -69,9 +69,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
69
69
  const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
70
70
  const theme = useTheme();
71
71
  const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
72
- const headerFilteringEnabled =
73
- // @ts-expect-error // TODO move relevant code to the `DataGridPro`
74
- props.signature !== 'DataGrid' && props.headerFilters;
72
+ const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
75
73
 
76
74
  /**
77
75
  * @param {number} colIndex Index of the column to focus