@mui/x-data-grid 5.16.0 → 5.17.2

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 (141) hide show
  1. package/CHANGELOG.md +138 -1
  2. package/components/GridRow.d.ts +2 -1
  3. package/components/GridRow.js +132 -83
  4. package/components/cell/GridBooleanCell.js +2 -1
  5. package/components/cell/GridCell.js +9 -1
  6. package/components/cell/GridEditBooleanCell.js +2 -1
  7. package/components/cell/GridEditDateCell.js +2 -1
  8. package/components/cell/GridEditInputCell.js +2 -1
  9. package/components/cell/GridEditSingleSelectCell.js +2 -1
  10. package/components/cell/GridSkeletonCell.d.ts +12 -0
  11. package/components/cell/GridSkeletonCell.js +60 -0
  12. package/components/cell/index.d.ts +1 -0
  13. package/components/cell/index.js +2 -1
  14. package/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  15. package/components/containers/GridRootStyles.js +2 -0
  16. package/components/panel/GridColumnsPanel.d.ts +6 -1
  17. package/components/panel/GridColumnsPanel.js +38 -6
  18. package/constants/defaultGridSlotsComponents.js +2 -1
  19. package/constants/gridClasses.d.ts +8 -0
  20. package/constants/gridClasses.js +1 -1
  21. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -1
  22. package/hooks/features/editRows/useGridCellEditing.new.js +8 -2
  23. package/hooks/features/editRows/useGridRowEditing.new.js +8 -2
  24. package/hooks/features/filter/gridFilterUtils.d.ts +1 -1
  25. package/hooks/features/filter/gridFilterUtils.js +55 -54
  26. package/hooks/features/filter/useGridFilter.js +1 -1
  27. package/hooks/features/focus/useGridFocus.js +13 -3
  28. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  29. package/hooks/features/rows/useGridParamsApi.js +1 -1
  30. package/hooks/features/rows/useGridRows.js +65 -8
  31. package/hooks/features/rows/useGridRowsMeta.js +36 -16
  32. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  33. package/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
  34. package/index.js +1 -1
  35. package/internals/index.d.ts +1 -1
  36. package/internals/index.js +1 -1
  37. package/legacy/components/GridRow.js +135 -83
  38. package/legacy/components/cell/GridBooleanCell.js +2 -1
  39. package/legacy/components/cell/GridCell.js +11 -1
  40. package/legacy/components/cell/GridEditBooleanCell.js +2 -1
  41. package/legacy/components/cell/GridEditDateCell.js +2 -1
  42. package/legacy/components/cell/GridEditInputCell.js +2 -1
  43. package/legacy/components/cell/GridEditSingleSelectCell.js +2 -1
  44. package/legacy/components/cell/GridSkeletonCell.js +57 -0
  45. package/legacy/components/cell/index.js +2 -1
  46. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  47. package/legacy/components/containers/GridRootStyles.js +3 -3
  48. package/legacy/components/panel/GridColumnsPanel.js +41 -6
  49. package/legacy/constants/defaultGridSlotsComponents.js +2 -1
  50. package/legacy/constants/gridClasses.js +1 -1
  51. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +11 -5
  52. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +8 -2
  53. package/legacy/hooks/features/filter/gridFilterUtils.js +61 -56
  54. package/legacy/hooks/features/filter/useGridFilter.js +1 -1
  55. package/legacy/hooks/features/focus/useGridFocus.js +13 -3
  56. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  57. package/legacy/hooks/features/rows/useGridParamsApi.js +1 -1
  58. package/legacy/hooks/features/rows/useGridRows.js +73 -8
  59. package/legacy/hooks/features/rows/useGridRowsMeta.js +45 -18
  60. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +31 -13
  61. package/legacy/index.js +1 -1
  62. package/legacy/internals/index.js +1 -1
  63. package/legacy/models/events/gridEvents.js +2 -0
  64. package/legacy/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
  65. package/legacy/models/params/index.js +2 -1
  66. package/legacy/utils/utils.js +25 -0
  67. package/models/api/gridParamsApi.d.ts +1 -1
  68. package/models/api/gridRowApi.d.ts +6 -0
  69. package/models/api/gridRowsMetaApi.d.ts +6 -1
  70. package/models/events/gridEventLookup.d.ts +7 -1
  71. package/models/events/gridEvents.d.ts +3 -1
  72. package/models/events/gridEvents.js +2 -0
  73. package/models/gridSlotsComponent.d.ts +5 -0
  74. package/models/params/gridCellParams.d.ts +7 -2
  75. package/models/params/gridRenderedRowsIntervalChangeParams.d.ts +10 -0
  76. package/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
  77. package/models/params/index.d.ts +1 -0
  78. package/models/params/index.js +2 -1
  79. package/modern/components/GridRow.js +129 -82
  80. package/modern/components/cell/GridBooleanCell.js +2 -1
  81. package/modern/components/cell/GridCell.js +9 -1
  82. package/modern/components/cell/GridEditBooleanCell.js +2 -1
  83. package/modern/components/cell/GridEditDateCell.js +2 -1
  84. package/modern/components/cell/GridEditInputCell.js +2 -1
  85. package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
  86. package/modern/components/cell/GridSkeletonCell.js +60 -0
  87. package/modern/components/cell/index.js +2 -1
  88. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  89. package/modern/components/containers/GridRootStyles.js +2 -0
  90. package/modern/components/panel/GridColumnsPanel.js +38 -6
  91. package/modern/constants/defaultGridSlotsComponents.js +2 -1
  92. package/modern/constants/gridClasses.js +1 -1
  93. package/modern/hooks/features/editRows/useGridCellEditing.new.js +8 -2
  94. package/modern/hooks/features/editRows/useGridRowEditing.new.js +8 -2
  95. package/modern/hooks/features/filter/gridFilterUtils.js +54 -53
  96. package/modern/hooks/features/filter/useGridFilter.js +1 -1
  97. package/modern/hooks/features/focus/useGridFocus.js +13 -3
  98. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  99. package/modern/hooks/features/rows/useGridParamsApi.js +1 -1
  100. package/modern/hooks/features/rows/useGridRows.js +65 -8
  101. package/modern/hooks/features/rows/useGridRowsMeta.js +36 -16
  102. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
  103. package/modern/index.js +1 -1
  104. package/modern/internals/index.js +1 -1
  105. package/modern/models/events/gridEvents.js +2 -0
  106. package/modern/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
  107. package/modern/models/params/index.js +2 -1
  108. package/modern/utils/utils.js +23 -0
  109. package/node/components/GridRow.js +131 -75
  110. package/node/components/cell/GridBooleanCell.js +2 -1
  111. package/node/components/cell/GridCell.js +9 -1
  112. package/node/components/cell/GridEditBooleanCell.js +2 -1
  113. package/node/components/cell/GridEditDateCell.js +2 -1
  114. package/node/components/cell/GridEditInputCell.js +2 -1
  115. package/node/components/cell/GridEditSingleSelectCell.js +2 -1
  116. package/node/components/cell/GridSkeletonCell.js +81 -0
  117. package/node/components/cell/index.js +13 -0
  118. package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  119. package/node/components/containers/GridRootStyles.js +2 -0
  120. package/node/components/panel/GridColumnsPanel.js +36 -5
  121. package/node/constants/defaultGridSlotsComponents.js +1 -0
  122. package/node/constants/gridClasses.js +1 -1
  123. package/node/hooks/features/editRows/useGridCellEditing.new.js +9 -2
  124. package/node/hooks/features/editRows/useGridRowEditing.new.js +9 -2
  125. package/node/hooks/features/filter/gridFilterUtils.js +55 -55
  126. package/node/hooks/features/filter/useGridFilter.js +1 -1
  127. package/node/hooks/features/focus/useGridFocus.js +13 -3
  128. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  129. package/node/hooks/features/rows/useGridParamsApi.js +1 -1
  130. package/node/hooks/features/rows/useGridRows.js +60 -7
  131. package/node/hooks/features/rows/useGridRowsMeta.js +35 -15
  132. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
  133. package/node/index.js +1 -1
  134. package/node/internals/index.js +6 -0
  135. package/node/models/events/gridEvents.js +2 -0
  136. package/node/models/params/gridRenderedRowsIntervalChangeParams.js +5 -0
  137. package/node/models/params/index.js +13 -0
  138. package/node/utils/utils.js +27 -0
  139. package/package.json +1 -1
  140. package/utils/utils.d.ts +2 -0
  141. package/utils/utils.js +23 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,143 @@
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
+ ## 5.17.2
7
+
8
+ _Sep 9, 2022_
9
+
10
+ This release will the last regular release for our `v5` packages.
11
+ From now on, we'll be focusing on developing MUI X v6.
12
+ You can check the [roadmap](https://github.com/mui/mui-x/projects/1) for more details on what's coming next.
13
+
14
+ And if you'd like to help, please consider volunteering to give us a [user interview](https://docs.google.com/forms/d/11L_zxL7oD_B-ZrZDuSyIkUzJLzOTUU2M4vHXxMVtWhU/edit).
15
+ We'd love to know more about your use cases, pain points and expectations for the future.
16
+
17
+ The `v5` packages will only get new versions to patch critical bug fixes.
18
+
19
+ We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
20
+
21
+ - 📃 Add support for column grouping when exporting to Excel (#5895) @alexfauquette
22
+ - 🐞 Bugfixes
23
+
24
+ ### `@mui/x-data-grid@v5.17.2` / `@mui/x-data-grid-pro@v5.17.2` / `@mui/x-data-grid-premium@v5.17.2`
25
+
26
+ #### Changes
27
+
28
+ - [DataGrid] Revert mode if cell/row couldn't be saved due to validation error (#5897) @m4theushw
29
+ - [DataGridPremium] Export column grouping in Excel (#5895) @alexfauquette
30
+
31
+ ### `@mui/x-date-pickers@v5.0.1` / `@mui/x-date-pickers-pro@v5.0.1`
32
+
33
+ #### Changes
34
+
35
+ - [DateTimePicker] Remove circular import (#6087) @flaviendelangle
36
+ - [pickers] Add `sx` prop to the equality check of `PickersDay` (#6030) @TheUnlocked
37
+ - [pickers] Add warning when `openTo` is invalid based on available `views` (#6042) @LukasTy
38
+ - [pickers] Allow keyboard navigation to ignore disabled date for left / right arrow (#6082) @alexfauquette
39
+ - [pickers] Fix mobile picker not opening on label click (#6074) @LukasTy
40
+
41
+ ### Docs
42
+
43
+ - [docs] Add Recipes section
44
+
45
+ ### Core
46
+
47
+ - [core] Add `yarn release:tag` script (#5169) @DanailH
48
+ - [core] Upgrade monorepo (#6072) @m4theushw
49
+
50
+ ## 5.17.1
51
+
52
+ _Sep 5, 2022_
53
+
54
+ We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
55
+
56
+ - 🐞 Bugfixes
57
+
58
+ ### `@mui/x-data-grid@v5.17.1` / `@mui/x-data-grid-pro@v5.17.1` / `@mui/x-data-grid-premium@v5.17.1`
59
+
60
+ #### Changes
61
+
62
+ - [DataGrid] Fix cells being focused on mouseUp (#5980) @cherniavskii
63
+ - [DataGrid] Fix focused cell if column is spanned and new editing API is used (#5962) @m4theushw
64
+ - [DataGridPro] Fix import in lazy-loading causing a bundling error (#6031) @flaviendelangle
65
+
66
+ ## 5.17.0
67
+
68
+ _Sep 2, 2022_
69
+
70
+ 🎉 We are excited to finally introduce a stable release (v5.0.0) for the `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` packages!
71
+
72
+ If you are still using picker components from the `lab`, take a look at the [migration guide](https://mui.com/x/react-date-pickers/migration-lab/).
73
+
74
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
75
+
76
+ - 🎁 Implement Lazy loading (#5214) @DanailH
77
+
78
+ Pro users now can try the experimental lazy loading feature.
79
+ In a few steps, you can load your data on demand, as the rows are displayed.
80
+
81
+ To enable this feature, add `experimentalFeatures={{ lazyLoading: true }}`.
82
+ Lazy Loading requires a few other settings.
83
+ See the [documentation](https://mui.com/x/react-data-grid/row-updates/#lazy-loading) to explore the example in detail.
84
+
85
+ - 🚀 Improve `pickers` focus management (#5820) @alexfauquette
86
+ - 🎉 Enable disabling `day` on date range picker depending on `position` (#5773) @alexfauquette
87
+ - ✨ Various improvements
88
+ - 📚 Documentation improvements
89
+ - 🐞 Bugfixes
90
+
91
+ ### `@mui/x-data-grid@v5.17.0` / `@mui/x-data-grid-pro@v5.17.0` / `@mui/x-data-grid-premium@v5.17.0`
92
+
93
+ #### Changes
94
+
95
+ - [DataGrid] Add `sort` prop to columns panel slot (#5888) @gavbrennan
96
+ - [DataGrid] Do not throw if `fieldToFocus` cannot be found (#5871) @cherniavskii
97
+ - [DataGrid] Support `getRowId` in the `replaceRows` method (#5988) @flaviendelangle
98
+ - [DataGridPro] Add class name to row with open detail panel (#5924) @m4theushw
99
+ - [DataGridPro] Fix crash when using `pinnedRows` + `getRowClassName` props and `rows=[]` (#5851) @cherniavskii
100
+ - [DataGridPro] Fix filtering with inactive filter items (#5993) @alexfauquette
101
+ - [DataGridPro] Implement Lazy loading (#5214) @DanailH
102
+ - [DataGridPro] Support pinned columns and dynamic row height (#5782) @m4theushw
103
+ - [DataGridPremium] Add state initializer for column groups (#5963) @alexfauquette
104
+ - [DataGridPremium] Update grouping when `groupingValueGetter` changes (#5919) @flaviendelangle
105
+ - [DataGridPremium] Use the aggregated value on tree data real groups (#5953) @flaviendelangle
106
+
107
+ ### `@mui/x-date-pickers@v5.0.0` / `@mui/x-date-pickers-pro@v5.0.0`
108
+
109
+ #### Changes
110
+
111
+ - [DatePicker] Improve focus management (#5820) @alexfauquette
112
+ - [DateRangePicker] Enable disabling `day` depending on `position` (#5773) @alexfauquette
113
+ - [DateTimePicker] Create a new `tabs` component slot (#5972) @LukasTy
114
+ - [pickers] Do not forward validation props to the DOM on field components (#5971) @flaviendelangle
115
+ - [pickers] Do not hardcode `date-fns` elements in field components (#5975) @flaviendelangle
116
+ - [pickers] Do not require `date-fns` in `@mui/x-date-pickers-pro` (#5941) @flaviendelangle
117
+ - [pickers] Fix mobile picker not opening on label click (#5651) @LukasTy
118
+ - [pickers] Improve DOM event management on `useField` (#5901) @flaviendelangle
119
+ - [pickers] Include `community` package `themeAugmentation` in `pro` package types (#5969) @LukasTy
120
+ - [pickers] Rename `DateRangeField` into `SingleInputDateRangeField` (#5961) @flaviendelangle
121
+ - [pickers] Support `isSameError` on field components (#5984) @flaviendelangle
122
+
123
+ ### Docs
124
+
125
+ - [docs] Add `description` and `default` to pickers slots (#5893) @alexfauquette
126
+ - [docs] Fix typo (#5945) @wettopa
127
+ - [docs] Fix typo `onYearPicker` to `onYearChange` (#5954) @alexfauquette
128
+ - [docs] Update `GridCellParams`'s `value` description (#5849) @cherniavskii
129
+ - [docs] Update `README.md` to match Introduction section of the docs (#5754) @samuelsycamore
130
+
131
+ ### Core
132
+
133
+ - [core] Fix typo (#5990) @flaviendelangle
134
+ - [core] Remove old babel resolve rule (#5939) @oliviertassinari
135
+ - [core] Remove outdated TODO (#5956) @flaviendelangle
136
+ - [core] Upgrade monorepo (#5960) @cherniavskii
137
+ - [core] Fix statics (#5986) @DanailH
138
+ - [core] Remove unused dependencies (#5937) @oliviertassinari
139
+ - [license] Remove CLI (#5757) @flaviendelangle
140
+ - [test] Fix time zone sensitive test (#5955) @LukasTy
141
+ - [test] Use `userEvent.mousePress` instead of `fireClickEvent` (#5920) @cherniavskii
142
+
6
143
  ## 5.16.0
7
144
 
8
145
  _Aug 25, 2022_
@@ -585,7 +722,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
585
722
 
586
723
  **MonthPicker**: The prop `onMonthChange` has been removed, you can use `onChange` instead since every change is a month change
587
724
 
588
- **YearPicker**: The prop `onYearPicker` has been removed, you can use `onChange` instead since every change is a year change
725
+ **YearPicker**: The prop `onYearChange` has been removed, you can use `onChange` instead since every change is a year change
589
726
 
590
727
  **DayPicker**: The prop `isDateDisabled` has been removed, you can now use the same validation props as for the other components (`maxDate`, `minDate`, `shouldDisableDate`, `disableFuture` and `disablePast`)
591
728
 
@@ -13,7 +13,6 @@ export interface GridRowProps {
13
13
  index: number;
14
14
  rowHeight: number | 'auto';
15
15
  containerWidth: number;
16
- row: GridRowModel;
17
16
  firstColumnToRender: number;
18
17
  lastColumnToRender: number;
19
18
  visibleColumns: GridStateColDef[];
@@ -21,6 +20,8 @@ export interface GridRowProps {
21
20
  cellFocus: GridCellIdentifier | null;
22
21
  cellTabIndex: GridCellIdentifier | null;
23
22
  editRowsState: GridEditRowsModel;
23
+ position: 'left' | 'center' | 'right';
24
+ row?: GridRowModel;
24
25
  isLastVisible?: boolean;
25
26
  onClick?: React.MouseEventHandler<HTMLDivElement>;
26
27
  onDoubleClick?: React.MouseEventHandler<HTMLDivElement>;
@@ -1,10 +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 = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
4
-
5
- /* eslint-disable jsx-a11y/click-events-have-key-events */
6
-
7
- /* eslint-disable jsx-a11y/interactive-supports-focus */
3
+ const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"];
8
4
  import * as React from 'react';
9
5
  import PropTypes from 'prop-types';
10
6
  import clsx from 'clsx';
@@ -23,6 +19,7 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../constants/gridDetailPanelTogg
23
19
  import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSelector';
24
20
  import { gridRowTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
25
21
  import { gridDensityHeaderGroupingMaxDepthSelector } from '../hooks/features/density/densitySelector';
22
+ import { randomNumberBetween } from '../utils/utils';
26
23
  import { jsx as _jsx } from "react/jsx-runtime";
27
24
  import { jsxs as _jsxs } from "react/jsx-runtime";
28
25
 
@@ -66,6 +63,7 @@ function GridRow(props) {
66
63
  row,
67
64
  index,
68
65
  style: styleProp,
66
+ position,
69
67
  rowHeight,
70
68
  className,
71
69
  visibleColumns,
@@ -112,9 +110,9 @@ function GridRow(props) {
112
110
  React.useLayoutEffect(() => {
113
111
  if (rowHeight === 'auto' && ref.current && typeof ResizeObserver === 'undefined') {
114
112
  // Fallback for IE
115
- apiRef.current.unstable_storeRowHeightMeasurement(rowId, ref.current.clientHeight);
113
+ apiRef.current.unstable_storeRowHeightMeasurement(rowId, ref.current.clientHeight, position);
116
114
  }
117
- }, [apiRef, rowHeight, rowId]);
115
+ }, [apiRef, rowHeight, rowId, position]);
118
116
  React.useLayoutEffect(() => {
119
117
  if (currentPage.range) {
120
118
  // The index prop is relative to the rows from all pages. As example, the index prop of the
@@ -139,11 +137,11 @@ function GridRow(props) {
139
137
  const resizeObserver = new ResizeObserver(entries => {
140
138
  const [entry] = entries;
141
139
  const height = entry.borderBoxSize && entry.borderBoxSize.length > 0 ? entry.borderBoxSize[0].blockSize : entry.contentRect.height;
142
- apiRef.current.unstable_storeRowHeightMeasurement(rowId, height);
140
+ apiRef.current.unstable_storeRowHeightMeasurement(rowId, height, position);
143
141
  });
144
142
  resizeObserver.observe(rootElement);
145
143
  return () => resizeObserver.disconnect();
146
- }, [apiRef, currentPage.range, index, rowHeight, rowId]);
144
+ }, [apiRef, currentPage.range, index, rowHeight, rowId, position]);
147
145
  const publish = React.useCallback((eventName, propHandler) => event => {
148
146
  // Ignore portal
149
147
  // The target is not an element when triggered by a Select inside the cell
@@ -199,47 +197,9 @@ function GridRow(props) {
199
197
 
200
198
  publish('rowClick', onClick)(event);
201
199
  }, [apiRef, onClick, publish, rowId]);
200
+ const getCell = React.useCallback((column, cellProps) => {
201
+ var _rootProps$components;
202
202
 
203
- const style = _extends({}, styleProp, {
204
- maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
205
- // max-height doesn't support "auto"
206
- minHeight: rowHeight
207
- });
208
-
209
- const sizes = apiRef.current.unstable_getRowInternalSizes(rowId);
210
-
211
- if (sizes != null && sizes.spacingTop) {
212
- const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
213
- style[property] = sizes.spacingTop;
214
- }
215
-
216
- if (sizes != null && sizes.spacingBottom) {
217
- const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
218
- style[property] = sizes.spacingBottom;
219
- }
220
-
221
- let rowClassName = null;
222
-
223
- if (typeof rootProps.getRowClassName === 'function') {
224
- const indexRelativeToCurrentPage = index - currentPage.range.firstRowIndex;
225
-
226
- const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
227
- isFirstVisible: indexRelativeToCurrentPage === 0,
228
- isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
229
- indexRelativeToCurrentPage
230
- });
231
-
232
- rowClassName = rootProps.getRowClassName(rowParams);
233
- }
234
-
235
- const cells = [];
236
-
237
- for (let i = 0; i < renderedColumns.length; i += 1) {
238
- const column = renderedColumns[i];
239
- const indexRelativeToAllColumns = firstColumnToRender + i;
240
- const isLastColumn = indexRelativeToAllColumns === visibleColumns.length - 1;
241
- const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
242
- const showRightBorder = !isLastColumn ? rootProps.showCellRightBorder : !removeLastBorderRight && rootProps.disableExtendRowFullWidth;
243
203
  const cellParams = apiRef.current.getCellParams(rowId, column.field);
244
204
  const classNames = [];
245
205
  const disableDragEvents = rootProps.disableColumnReorder && column.disableReorder || !rootProps.rowReordering && !!sortModel.length && treeDepth > 1 && Object.keys(editRowsState).length > 0;
@@ -289,53 +249,141 @@ function GridRow(props) {
289
249
 
290
250
  const hasFocus = cellFocus !== null && cellFocus.id === rowId && cellFocus.field === column.field;
291
251
  const tabIndex = cellTabIndex !== null && cellTabIndex.id === rowId && cellTabIndex.field === column.field && cellParams.cellMode === 'view' ? 0 : -1;
252
+ return /*#__PURE__*/_jsx(rootProps.components.Cell, _extends({
253
+ value: cellParams.value,
254
+ field: column.field,
255
+ width: cellProps.width,
256
+ rowId: rowId,
257
+ height: rowHeight,
258
+ showRightBorder: cellProps.showRightBorder,
259
+ formattedValue: cellParams.formattedValue,
260
+ align: column.align || 'left',
261
+ cellMode: cellParams.cellMode,
262
+ colIndex: cellProps.indexRelativeToAllColumns,
263
+ isEditable: cellParams.isEditable,
264
+ hasFocus: hasFocus,
265
+ tabIndex: tabIndex,
266
+ className: clsx(classNames),
267
+ colSpan: cellProps.colSpan,
268
+ disableDragEvents: disableDragEvents
269
+ }, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.cell, {
270
+ children: content
271
+ }), column.field);
272
+ }, [apiRef, cellTabIndex, editRowsState, cellFocus, rootProps, row, rowHeight, rowId, treeDepth, sortModel.length]);
273
+ const sizes = apiRef.current.unstable_getRowInternalSizes(rowId);
274
+ let minHeight = rowHeight;
275
+
276
+ if (minHeight === 'auto' && sizes) {
277
+ let numberOfBaseSizes = 0;
278
+ const maximumSize = Object.entries(sizes).reduce((acc, [key, size]) => {
279
+ const isBaseHeight = /^base[A-Z]/.test(key);
280
+
281
+ if (!isBaseHeight) {
282
+ return acc;
283
+ }
284
+
285
+ numberOfBaseSizes += 1;
286
+
287
+ if (size > acc) {
288
+ return size;
289
+ }
290
+
291
+ return acc;
292
+ }, 0);
293
+
294
+ if (maximumSize > 0 && numberOfBaseSizes > 1) {
295
+ minHeight = maximumSize;
296
+ }
297
+ }
298
+
299
+ const style = _extends({}, styleProp, {
300
+ maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
301
+ // max-height doesn't support "auto"
302
+ minHeight
303
+ });
304
+
305
+ if (sizes != null && sizes.spacingTop) {
306
+ const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
307
+ style[property] = sizes.spacingTop;
308
+ }
309
+
310
+ if (sizes != null && sizes.spacingBottom) {
311
+ const property = rootProps.rowSpacingType === 'border' ? 'borderBottomWidth' : 'marginBottom';
312
+ style[property] = sizes.spacingBottom;
313
+ }
314
+
315
+ const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
316
+
317
+ if (typeof rootProps.getRowClassName === 'function') {
318
+ var _currentPage$range;
319
+
320
+ const indexRelativeToCurrentPage = index - (((_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0);
321
+
322
+ const rowParams = _extends({}, apiRef.current.getRowParams(rowId), {
323
+ isFirstVisible: indexRelativeToCurrentPage === 0,
324
+ isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
325
+ indexRelativeToCurrentPage
326
+ });
327
+
328
+ rowClassNames.push(rootProps.getRowClassName(rowParams));
329
+ }
330
+
331
+ const randomNumber = randomNumberBetween(10000, 20, 80);
332
+ const cells = [];
333
+
334
+ for (let i = 0; i < renderedColumns.length; i += 1) {
335
+ const column = renderedColumns[i];
336
+ const indexRelativeToAllColumns = firstColumnToRender + i;
337
+ const isLastColumn = indexRelativeToAllColumns === visibleColumns.length - 1;
338
+ const removeLastBorderRight = isLastColumn && hasScrollX && !hasScrollY;
339
+ const showRightBorder = !isLastColumn ? rootProps.showCellRightBorder : !removeLastBorderRight && rootProps.disableExtendRowFullWidth;
292
340
  const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
293
341
 
294
342
  if (cellColSpanInfo && !cellColSpanInfo.spannedByColSpan) {
295
- var _rootProps$components;
296
-
297
- const {
298
- colSpan,
299
- width
300
- } = cellColSpanInfo.cellProps;
301
- cells.push( /*#__PURE__*/_jsx(rootProps.components.Cell, _extends({
302
- value: cellParams.value,
303
- field: column.field,
304
- width: width,
305
- rowId: rowId,
306
- height: rowHeight,
307
- showRightBorder: showRightBorder,
308
- formattedValue: cellParams.formattedValue,
309
- align: column.align || 'left',
310
- cellMode: cellParams.cellMode,
311
- colIndex: indexRelativeToAllColumns,
312
- isEditable: cellParams.isEditable,
313
- hasFocus: hasFocus,
314
- tabIndex: tabIndex,
315
- className: clsx(classNames),
316
- colSpan: colSpan,
317
- disableDragEvents: disableDragEvents
318
- }, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.cell, {
319
- children: content
320
- }), column.field));
343
+ if (row) {
344
+ const {
345
+ colSpan,
346
+ width
347
+ } = cellColSpanInfo.cellProps;
348
+ const cellProps = {
349
+ width,
350
+ colSpan,
351
+ showRightBorder,
352
+ indexRelativeToAllColumns
353
+ };
354
+ cells.push(getCell(column, cellProps));
355
+ } else {
356
+ const {
357
+ width
358
+ } = cellColSpanInfo.cellProps;
359
+ const contentWidth = Math.round(randomNumber());
360
+ cells.push( /*#__PURE__*/_jsx(rootProps.components.SkeletonCell, {
361
+ width: width,
362
+ contentWidth: contentWidth,
363
+ field: column.field,
364
+ align: column.align
365
+ }, column.field));
366
+ }
321
367
  }
322
368
  }
323
369
 
324
370
  const emptyCellWidth = containerWidth - columnsTotalWidth;
371
+ const eventHandlers = row ? {
372
+ onClick: publishClick,
373
+ onDoubleClick: publish('rowDoubleClick', onDoubleClick),
374
+ onMouseEnter: publish('rowMouseEnter', onMouseEnter),
375
+ onMouseLeave: publish('rowMouseLeave', onMouseLeave)
376
+ } : null;
325
377
  return /*#__PURE__*/_jsxs("div", _extends({
326
378
  ref: ref,
327
379
  "data-id": rowId,
328
380
  "data-rowindex": index,
329
381
  role: "row",
330
- className: clsx(rowClassName, classes.root, className),
382
+ className: clsx(...rowClassNames, classes.root, className),
331
383
  "aria-rowindex": ariaRowIndex,
332
384
  "aria-selected": selected,
333
- style: style,
334
- onClick: publishClick,
335
- onDoubleClick: publish('rowDoubleClick', onDoubleClick),
336
- onMouseEnter: publish('rowMouseEnter', onMouseEnter),
337
- onMouseLeave: publish('rowMouseLeave', onMouseLeave)
338
- }, other, {
385
+ style: style
386
+ }, eventHandlers, other, {
339
387
  children: [cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
340
388
  width: emptyCellWidth
341
389
  })]
@@ -360,8 +408,9 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
360
408
  index: PropTypes.number.isRequired,
361
409
  isLastVisible: PropTypes.bool,
362
410
  lastColumnToRender: PropTypes.number.isRequired,
411
+ position: PropTypes.oneOf(['center', 'left', 'right']).isRequired,
363
412
  renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
364
- row: PropTypes.object.isRequired,
413
+ row: PropTypes.object,
365
414
  rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
366
415
  rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
367
416
  selected: PropTypes.bool.isRequired,
@@ -123,7 +123,8 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
123
123
  tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
124
124
 
125
125
  /**
126
- * The cell value, but if the column has valueGetter, use getValue.
126
+ * The cell value.
127
+ * If the column has `valueGetter`, use `params.row` to directly access the fields.
127
128
  */
128
129
  value: PropTypes.any
129
130
  } : void 0;
@@ -98,6 +98,14 @@ function GridCell(props) {
98
98
  onMouseUp(event);
99
99
  }
100
100
  }, [apiRef, field, onMouseUp, rowId]);
101
+ const publishMouseDown = React.useCallback(eventName => event => {
102
+ const params = apiRef.current.getCellParams(rowId, field || '');
103
+ apiRef.current.publishEvent(eventName, params, event);
104
+
105
+ if (onMouseDown) {
106
+ onMouseDown(event);
107
+ }
108
+ }, [apiRef, field, onMouseDown, rowId]);
101
109
  const publish = React.useCallback((eventName, propHandler) => event => {
102
110
  // Ignore portal
103
111
  if (!event.currentTarget.contains(event.target)) {
@@ -202,7 +210,7 @@ function GridCell(props) {
202
210
  tabIndex: (cellMode === 'view' || !isEditable) && !managesOwnFocus ? tabIndex : -1,
203
211
  onClick: publish('cellClick', onClick),
204
212
  onDoubleClick: publish('cellDoubleClick', onDoubleClick),
205
- onMouseDown: publish('cellMouseDown', onMouseDown),
213
+ onMouseDown: publishMouseDown('cellMouseDown'),
206
214
  onMouseUp: publishMouseUp('cellMouseUp'),
207
215
  onKeyDown: publish('cellKeyDown', onKeyDown)
208
216
  }, draggableEventHandlers, other, {
@@ -161,7 +161,8 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
161
161
  tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
162
162
 
163
163
  /**
164
- * The cell value, but if the column has valueGetter, use getValue.
164
+ * The cell value.
165
+ * If the column has `valueGetter`, use `params.row` to directly access the fields.
165
166
  */
166
167
  value: PropTypes.any
167
168
  } : void 0;
@@ -215,7 +215,8 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
215
215
  tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
216
216
 
217
217
  /**
218
- * The cell value, but if the column has valueGetter, use getValue.
218
+ * The cell value.
219
+ * If the column has `valueGetter`, use `params.row` to directly access the fields.
219
220
  */
220
221
  value: PropTypes.any
221
222
  } : void 0;
@@ -178,7 +178,8 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
178
178
  tabIndex: PropTypes.oneOf([-1, 0]),
179
179
 
180
180
  /**
181
- * The cell value, but if the column has valueGetter, use getValue.
181
+ * The cell value.
182
+ * If the column has `valueGetter`, use `params.row` to directly access the fields.
182
183
  */
183
184
  value: PropTypes.any
184
185
  } : void 0;
@@ -264,7 +264,8 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
264
264
  tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
265
265
 
266
266
  /**
267
- * The cell value, but if the column has valueGetter, use getValue.
267
+ * The cell value.
268
+ * If the column has `valueGetter`, use `params.row` to directly access the fields.
268
269
  */
269
270
  value: PropTypes.any
270
271
  } : void 0;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ export interface GridSkeletonCellProps {
3
+ width: number;
4
+ contentWidth: number;
5
+ field: string;
6
+ align: string;
7
+ }
8
+ declare function GridSkeletonCell(props: React.HTMLAttributes<HTMLDivElement> & GridSkeletonCellProps): JSX.Element;
9
+ declare namespace GridSkeletonCell {
10
+ var propTypes: any;
11
+ }
12
+ export { GridSkeletonCell };
@@ -0,0 +1,60 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["field", "align", "width", "contentWidth"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import Skeleton from '@mui/material/Skeleton';
7
+ import { capitalize } from '@mui/material/utils';
8
+ import { unstable_composeClasses as composeClasses } from '@mui/material';
9
+ import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
10
+ import { getDataGridUtilityClass } from '../../constants/gridClasses';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+
13
+ const useUtilityClasses = ownerState => {
14
+ const {
15
+ align,
16
+ classes
17
+ } = ownerState;
18
+ const slots = {
19
+ root: ['cell', 'cellSkeleton', `cell--text${capitalize(align)}`]
20
+ };
21
+ return composeClasses(slots, getDataGridUtilityClass, classes);
22
+ };
23
+
24
+ function GridSkeletonCell(props) {
25
+ const {
26
+ align,
27
+ width,
28
+ contentWidth
29
+ } = props,
30
+ other = _objectWithoutPropertiesLoose(props, _excluded);
31
+
32
+ const rootProps = useGridRootProps();
33
+ const ownerState = {
34
+ classes: rootProps.classes,
35
+ align
36
+ };
37
+ const classes = useUtilityClasses(ownerState);
38
+ return /*#__PURE__*/_jsx("div", _extends({
39
+ className: classes.root,
40
+ style: {
41
+ width
42
+ }
43
+ }, other, {
44
+ children: /*#__PURE__*/_jsx(Skeleton, {
45
+ width: `${contentWidth}%`
46
+ })
47
+ }));
48
+ }
49
+
50
+ process.env.NODE_ENV !== "production" ? GridSkeletonCell.propTypes = {
51
+ // ----------------------------- Warning --------------------------------
52
+ // | These PropTypes are generated from the TypeScript type definitions |
53
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
54
+ // ----------------------------------------------------------------------
55
+ align: PropTypes.string.isRequired,
56
+ contentWidth: PropTypes.number.isRequired,
57
+ field: PropTypes.string.isRequired,
58
+ width: PropTypes.number.isRequired
59
+ } : void 0;
60
+ export { GridSkeletonCell };
@@ -6,3 +6,4 @@ export * from './GridEditInputCell';
6
6
  export * from './GridEditSingleSelectCell';
7
7
  export * from './GridActionsCell';
8
8
  export * from './GridActionsCellItem';
9
+ export * from './GridSkeletonCell';
@@ -5,4 +5,5 @@ export * from './GridEditDateCell';
5
5
  export * from './GridEditInputCell';
6
6
  export * from './GridEditSingleSelectCell';
7
7
  export * from './GridActionsCell';
8
- export * from './GridActionsCellItem';
8
+ export * from './GridActionsCellItem';
9
+ export * from './GridSkeletonCell';
@@ -187,7 +187,8 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
187
187
  tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
188
188
 
189
189
  /**
190
- * The cell value, but if the column has valueGetter, use getValue.
190
+ * The cell value.
191
+ * If the column has `valueGetter`, use `params.row` to directly access the fields.
191
192
  */
192
193
  value: PropTypes.any
193
194
  } : void 0;
@@ -35,6 +35,8 @@ export const GridRootStyles = styled('div', {
35
35
  [`& .${gridClasses.cellContent}`]: styles.cellContent
36
36
  }, {
37
37
  [`& .${gridClasses.cellCheckbox}`]: styles.cellCheckbox
38
+ }, {
39
+ [`& .${gridClasses.cellSkeleton}`]: styles.cellSkeleton
38
40
  }, {
39
41
  [`& .${gridClasses.checkboxInput}`]: styles.checkboxInput
40
42
  }, {
@@ -1,5 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { GridPanelWrapperProps } from './GridPanelWrapper';
3
3
  export interface GridColumnsPanelProps extends GridPanelWrapperProps {
4
+ sort?: 'asc' | 'desc';
4
5
  }
5
- export declare function GridColumnsPanel(props: GridColumnsPanelProps): JSX.Element;
6
+ declare function GridColumnsPanel(props: GridColumnsPanelProps): JSX.Element;
7
+ declare namespace GridColumnsPanel {
8
+ var propTypes: any;
9
+ }
10
+ export { GridColumnsPanel };