@mui/x-data-grid 7.0.0-alpha.9 → 7.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/CHANGELOG.md +386 -38
  2. package/DataGrid/useDataGridComponent.js +1 -1
  3. package/README.md +2 -2
  4. package/colDef/gridBooleanColDef.js +3 -6
  5. package/colDef/gridCheckboxSelectionColDef.js +4 -3
  6. package/colDef/gridDateColDef.d.ts +3 -4
  7. package/colDef/gridDateColDef.js +10 -16
  8. package/colDef/gridNumericColDef.js +1 -3
  9. package/colDef/gridSingleSelectColDef.js +7 -12
  10. package/components/GridRow.js +1 -100
  11. package/components/cell/GridEditInputCell.js +1 -1
  12. package/components/columnsManagement/GridColumnsManagement.d.ts +43 -0
  13. package/components/columnsManagement/GridColumnsManagement.js +265 -0
  14. package/components/columnsManagement/index.d.ts +1 -0
  15. package/components/columnsManagement/index.js +1 -0
  16. package/components/columnsManagement/utils.d.ts +4 -0
  17. package/components/columnsManagement/utils.js +16 -0
  18. package/components/index.d.ts +1 -0
  19. package/components/index.js +1 -0
  20. package/components/panel/GridColumnsPanel.d.ts +0 -28
  21. package/components/panel/GridColumnsPanel.js +5 -213
  22. package/constants/defaultGridSlotsComponents.js +2 -1
  23. package/constants/gridClasses.d.ts +12 -4
  24. package/constants/gridClasses.js +1 -1
  25. package/constants/localeTextConstants.js +4 -6
  26. package/hooks/core/useGridApiInitialization.js +4 -0
  27. package/hooks/features/columns/useGridColumnSpanning.js +3 -1
  28. package/hooks/features/editing/useGridCellEditing.js +2 -5
  29. package/hooks/features/editing/useGridRowEditing.js +2 -5
  30. package/hooks/features/filter/gridFilterUtils.js +1 -1
  31. package/hooks/features/rows/gridRowsUtils.js +4 -1
  32. package/hooks/features/rows/useGridParamsApi.d.ts +1 -2
  33. package/hooks/features/rows/useGridParamsApi.js +14 -49
  34. package/index.js +1 -1
  35. package/legacy/DataGrid/useDataGridComponent.js +1 -1
  36. package/legacy/colDef/gridBooleanColDef.js +3 -5
  37. package/legacy/colDef/gridCheckboxSelectionColDef.js +4 -3
  38. package/legacy/colDef/gridDateColDef.js +10 -14
  39. package/legacy/colDef/gridNumericColDef.js +1 -2
  40. package/legacy/colDef/gridSingleSelectColDef.js +7 -10
  41. package/legacy/components/GridRow.js +1 -100
  42. package/legacy/components/cell/GridEditInputCell.js +1 -1
  43. package/legacy/components/columnsManagement/GridColumnsManagement.js +307 -0
  44. package/legacy/components/columnsManagement/index.js +1 -0
  45. package/legacy/components/columnsManagement/utils.js +22 -0
  46. package/legacy/components/index.js +1 -0
  47. package/legacy/components/panel/GridColumnsPanel.js +5 -233
  48. package/legacy/constants/defaultGridSlotsComponents.js +2 -1
  49. package/legacy/constants/gridClasses.js +1 -1
  50. package/legacy/constants/localeTextConstants.js +4 -6
  51. package/legacy/hooks/core/useGridApiInitialization.js +4 -0
  52. package/legacy/hooks/features/columns/useGridColumnSpanning.js +3 -1
  53. package/legacy/hooks/features/editing/useGridCellEditing.js +2 -5
  54. package/legacy/hooks/features/editing/useGridRowEditing.js +2 -5
  55. package/legacy/hooks/features/filter/gridFilterUtils.js +2 -2
  56. package/legacy/hooks/features/rows/gridRowsUtils.js +4 -1
  57. package/legacy/hooks/features/rows/useGridParamsApi.js +14 -47
  58. package/legacy/index.js +1 -1
  59. package/legacy/locales/arSD.js +5 -6
  60. package/legacy/locales/beBY.js +5 -6
  61. package/legacy/locales/bgBG.js +5 -6
  62. package/legacy/locales/csCZ.js +5 -6
  63. package/legacy/locales/daDK.js +5 -6
  64. package/legacy/locales/deDE.js +5 -6
  65. package/legacy/locales/elGR.js +5 -6
  66. package/legacy/locales/esES.js +5 -6
  67. package/legacy/locales/faIR.js +5 -6
  68. package/legacy/locales/fiFI.js +5 -6
  69. package/legacy/locales/frFR.js +5 -6
  70. package/legacy/locales/heIL.js +12 -14
  71. package/legacy/locales/hrHR.js +5 -6
  72. package/legacy/locales/huHU.js +5 -6
  73. package/legacy/locales/itIT.js +5 -6
  74. package/legacy/locales/jaJP.js +5 -6
  75. package/legacy/locales/koKR.js +5 -6
  76. package/legacy/locales/nbNO.js +5 -6
  77. package/legacy/locales/nlNL.js +5 -6
  78. package/legacy/locales/plPL.js +5 -6
  79. package/legacy/locales/ptBR.js +5 -6
  80. package/legacy/locales/ptPT.js +5 -6
  81. package/legacy/locales/roRO.js +5 -6
  82. package/legacy/locales/ruRU.js +5 -6
  83. package/legacy/locales/skSK.js +5 -6
  84. package/legacy/locales/svSE.js +5 -6
  85. package/legacy/locales/trTR.js +5 -6
  86. package/legacy/locales/ukUA.js +5 -6
  87. package/legacy/locales/urPK.js +5 -6
  88. package/legacy/locales/viVN.js +5 -6
  89. package/legacy/locales/zhCN.js +5 -6
  90. package/legacy/locales/zhHK.js +5 -6
  91. package/legacy/locales/zhTW.js +5 -6
  92. package/locales/arSD.js +5 -6
  93. package/locales/beBY.js +5 -6
  94. package/locales/bgBG.js +5 -6
  95. package/locales/csCZ.js +5 -6
  96. package/locales/daDK.js +5 -6
  97. package/locales/deDE.js +5 -6
  98. package/locales/elGR.js +5 -6
  99. package/locales/esES.js +5 -6
  100. package/locales/faIR.js +5 -6
  101. package/locales/fiFI.js +5 -6
  102. package/locales/frFR.js +5 -6
  103. package/locales/heIL.js +12 -14
  104. package/locales/hrHR.js +5 -6
  105. package/locales/huHU.js +5 -6
  106. package/locales/itIT.js +5 -6
  107. package/locales/jaJP.js +5 -6
  108. package/locales/koKR.js +5 -6
  109. package/locales/nbNO.js +5 -6
  110. package/locales/nlNL.js +5 -6
  111. package/locales/plPL.js +5 -6
  112. package/locales/ptBR.js +5 -6
  113. package/locales/ptPT.js +5 -6
  114. package/locales/roRO.js +5 -6
  115. package/locales/ruRU.js +5 -6
  116. package/locales/skSK.js +5 -6
  117. package/locales/svSE.js +5 -6
  118. package/locales/trTR.js +5 -6
  119. package/locales/ukUA.js +5 -6
  120. package/locales/urPK.js +5 -6
  121. package/locales/viVN.js +5 -6
  122. package/locales/zhCN.js +5 -6
  123. package/locales/zhHK.js +5 -6
  124. package/locales/zhTW.js +5 -6
  125. package/models/api/gridLocaleTextApi.d.ts +3 -5
  126. package/models/colDef/gridColDef.d.ts +11 -17
  127. package/models/colDef/gridColType.d.ts +11 -2
  128. package/models/colDef/index.d.ts +1 -1
  129. package/models/gridSlotsComponent.d.ts +5 -0
  130. package/models/gridSlotsComponentsProps.d.ts +4 -0
  131. package/models/params/gridCellParams.d.ts +0 -26
  132. package/modern/DataGrid/useDataGridComponent.js +1 -1
  133. package/modern/colDef/gridBooleanColDef.js +3 -6
  134. package/modern/colDef/gridCheckboxSelectionColDef.js +4 -3
  135. package/modern/colDef/gridDateColDef.js +10 -16
  136. package/modern/colDef/gridNumericColDef.js +1 -3
  137. package/modern/colDef/gridSingleSelectColDef.js +7 -12
  138. package/modern/components/GridRow.js +1 -100
  139. package/modern/components/cell/GridEditInputCell.js +1 -1
  140. package/modern/components/columnsManagement/GridColumnsManagement.js +261 -0
  141. package/modern/components/columnsManagement/index.js +1 -0
  142. package/modern/components/columnsManagement/utils.js +16 -0
  143. package/modern/components/index.js +1 -0
  144. package/modern/components/panel/GridColumnsPanel.js +4 -209
  145. package/modern/constants/defaultGridSlotsComponents.js +2 -1
  146. package/modern/constants/gridClasses.js +1 -1
  147. package/modern/constants/localeTextConstants.js +4 -6
  148. package/modern/hooks/core/useGridApiInitialization.js +3 -0
  149. package/modern/hooks/features/columns/useGridColumnSpanning.js +3 -1
  150. package/modern/hooks/features/editing/useGridCellEditing.js +2 -5
  151. package/modern/hooks/features/editing/useGridRowEditing.js +2 -5
  152. package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
  153. package/modern/hooks/features/rows/gridRowsUtils.js +4 -1
  154. package/modern/hooks/features/rows/useGridParamsApi.js +14 -47
  155. package/modern/index.js +1 -1
  156. package/modern/locales/arSD.js +5 -6
  157. package/modern/locales/beBY.js +5 -6
  158. package/modern/locales/bgBG.js +5 -6
  159. package/modern/locales/csCZ.js +5 -6
  160. package/modern/locales/daDK.js +5 -6
  161. package/modern/locales/deDE.js +5 -6
  162. package/modern/locales/elGR.js +5 -6
  163. package/modern/locales/esES.js +5 -6
  164. package/modern/locales/faIR.js +5 -6
  165. package/modern/locales/fiFI.js +5 -6
  166. package/modern/locales/frFR.js +5 -6
  167. package/modern/locales/heIL.js +12 -14
  168. package/modern/locales/hrHR.js +5 -6
  169. package/modern/locales/huHU.js +5 -6
  170. package/modern/locales/itIT.js +5 -6
  171. package/modern/locales/jaJP.js +5 -6
  172. package/modern/locales/koKR.js +5 -6
  173. package/modern/locales/nbNO.js +5 -6
  174. package/modern/locales/nlNL.js +5 -6
  175. package/modern/locales/plPL.js +5 -6
  176. package/modern/locales/ptBR.js +5 -6
  177. package/modern/locales/ptPT.js +5 -6
  178. package/modern/locales/roRO.js +5 -6
  179. package/modern/locales/ruRU.js +5 -6
  180. package/modern/locales/skSK.js +5 -6
  181. package/modern/locales/svSE.js +5 -6
  182. package/modern/locales/trTR.js +5 -6
  183. package/modern/locales/ukUA.js +5 -6
  184. package/modern/locales/urPK.js +5 -6
  185. package/modern/locales/viVN.js +5 -6
  186. package/modern/locales/zhCN.js +5 -6
  187. package/modern/locales/zhHK.js +5 -6
  188. package/modern/locales/zhTW.js +5 -6
  189. package/node/DataGrid/useDataGridComponent.js +1 -1
  190. package/node/colDef/gridBooleanColDef.js +3 -6
  191. package/node/colDef/gridCheckboxSelectionColDef.js +4 -3
  192. package/node/colDef/gridDateColDef.js +13 -19
  193. package/node/colDef/gridNumericColDef.js +1 -3
  194. package/node/colDef/gridSingleSelectColDef.js +7 -12
  195. package/node/components/GridRow.js +1 -100
  196. package/node/components/cell/GridEditInputCell.js +1 -1
  197. package/node/components/columnsManagement/GridColumnsManagement.js +269 -0
  198. package/node/components/columnsManagement/index.js +16 -0
  199. package/node/components/columnsManagement/utils.js +24 -0
  200. package/node/components/index.js +11 -0
  201. package/node/components/panel/GridColumnsPanel.js +4 -208
  202. package/node/constants/defaultGridSlotsComponents.js +1 -0
  203. package/node/constants/gridClasses.js +1 -1
  204. package/node/constants/localeTextConstants.js +4 -6
  205. package/node/hooks/core/useGridApiInitialization.js +3 -0
  206. package/node/hooks/features/columns/useGridColumnSpanning.js +3 -1
  207. package/node/hooks/features/editing/useGridCellEditing.js +2 -5
  208. package/node/hooks/features/editing/useGridRowEditing.js +2 -5
  209. package/node/hooks/features/filter/gridFilterUtils.js +1 -1
  210. package/node/hooks/features/rows/gridRowsUtils.js +4 -1
  211. package/node/hooks/features/rows/useGridParamsApi.js +14 -47
  212. package/node/index.js +1 -1
  213. package/node/locales/arSD.js +5 -6
  214. package/node/locales/beBY.js +5 -6
  215. package/node/locales/bgBG.js +5 -6
  216. package/node/locales/csCZ.js +5 -6
  217. package/node/locales/daDK.js +5 -6
  218. package/node/locales/deDE.js +5 -6
  219. package/node/locales/elGR.js +5 -6
  220. package/node/locales/esES.js +5 -6
  221. package/node/locales/faIR.js +5 -6
  222. package/node/locales/fiFI.js +5 -6
  223. package/node/locales/frFR.js +5 -6
  224. package/node/locales/heIL.js +12 -14
  225. package/node/locales/hrHR.js +5 -6
  226. package/node/locales/huHU.js +5 -6
  227. package/node/locales/itIT.js +5 -6
  228. package/node/locales/jaJP.js +5 -6
  229. package/node/locales/koKR.js +5 -6
  230. package/node/locales/nbNO.js +5 -6
  231. package/node/locales/nlNL.js +5 -6
  232. package/node/locales/plPL.js +5 -6
  233. package/node/locales/ptBR.js +5 -6
  234. package/node/locales/ptPT.js +5 -6
  235. package/node/locales/roRO.js +5 -6
  236. package/node/locales/ruRU.js +5 -6
  237. package/node/locales/skSK.js +5 -6
  238. package/node/locales/svSE.js +5 -6
  239. package/node/locales/trTR.js +5 -6
  240. package/node/locales/ukUA.js +5 -6
  241. package/node/locales/urPK.js +5 -6
  242. package/node/locales/viVN.js +5 -6
  243. package/node/locales/zhCN.js +5 -6
  244. package/node/locales/zhHK.js +5 -6
  245. package/node/locales/zhTW.js +5 -6
  246. package/package.json +4 -4
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.GridColumnsManagement = GridColumnsManagement;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _utils = require("@mui/utils");
12
+ var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
13
+ var _styles = require("@mui/material/styles");
14
+ var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
15
+ var _useGridSelector = require("../../hooks/utils/useGridSelector");
16
+ var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
17
+ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
18
+ var _gridClasses = require("../../constants/gridClasses");
19
+ var _useLazyRef = require("../../hooks/utils/useLazyRef");
20
+ var _utils2 = require("./utils");
21
+ var _jsxRuntime = require("react/jsx-runtime");
22
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24
+ /* eslint-disable @typescript-eslint/no-use-before-define */
25
+
26
+ const useUtilityClasses = ownerState => {
27
+ const {
28
+ classes
29
+ } = ownerState;
30
+ const slots = {
31
+ root: ['columnsManagement'],
32
+ header: ['columnsManagementHeader'],
33
+ footer: ['columnsManagementFooter'],
34
+ row: ['columnsManagementRow']
35
+ };
36
+ return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
37
+ };
38
+ const collator = new Intl.Collator();
39
+ function GridColumnsManagement(props) {
40
+ const apiRef = (0, _useGridApiContext.useGridApiContext)();
41
+ const searchInputRef = React.useRef(null);
42
+ const columns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnDefinitionsSelector);
43
+ const initialColumnVisibilityModel = (0, _useLazyRef.useLazyRef)(() => (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef)).current;
44
+ const columnVisibilityModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnVisibilityModelSelector);
45
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
46
+ const [searchValue, setSearchValue] = React.useState('');
47
+ const classes = useUtilityClasses(rootProps);
48
+ const {
49
+ sort,
50
+ searchPredicate = _utils2.defaultSearchPredicate,
51
+ autoFocusSearchField = true,
52
+ disableShowHideToggle = false,
53
+ disableResetButton = false,
54
+ toggleAllMode = 'all',
55
+ getTogglableColumns
56
+ } = props;
57
+ const isResetDisabled = React.useMemo(() => (0, _utils2.checkColumnVisibilityModelsSame)(columnVisibilityModel, initialColumnVisibilityModel), [columnVisibilityModel, initialColumnVisibilityModel]);
58
+ const sortedColumns = React.useMemo(() => {
59
+ switch (sort) {
60
+ case 'asc':
61
+ return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
62
+ case 'desc':
63
+ return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
64
+ default:
65
+ return columns;
66
+ }
67
+ }, [columns, sort]);
68
+ const toggleColumn = event => {
69
+ const {
70
+ name: field
71
+ } = event.target;
72
+ apiRef.current.setColumnVisibility(field, columnVisibilityModel[field] === false);
73
+ };
74
+ const currentColumns = React.useMemo(() => {
75
+ const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
76
+ const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
77
+ field
78
+ }) => togglableColumns.includes(field)) : sortedColumns;
79
+ if (!searchValue) {
80
+ return togglableSortedColumns;
81
+ }
82
+ return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
83
+ }, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
84
+ const toggleAllColumns = React.useCallback(isVisible => {
85
+ const currentModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
86
+ const newModel = (0, _extends2.default)({}, currentModel);
87
+ const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
88
+ (toggleAllMode === 'filteredOnly' ? currentColumns : columns).forEach(col => {
89
+ if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
90
+ if (isVisible) {
91
+ // delete the key from the model instead of setting it to `true`
92
+ delete newModel[col.field];
93
+ } else {
94
+ newModel[col.field] = false;
95
+ }
96
+ }
97
+ });
98
+ return apiRef.current.setColumnVisibilityModel(newModel);
99
+ }, [apiRef, columns, getTogglableColumns, toggleAllMode, currentColumns]);
100
+ const handleSearchValueChange = React.useCallback(event => {
101
+ setSearchValue(event.target.value);
102
+ }, []);
103
+ const hideableColumns = React.useMemo(() => currentColumns.filter(col => col.hideable), [currentColumns]);
104
+ const allHideableColumnsVisible = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] == null || columnVisibilityModel[column.field] !== false), [columnVisibilityModel, hideableColumns]);
105
+ const allHideableColumnsHidden = React.useMemo(() => hideableColumns.every(column => columnVisibilityModel[column.field] === false), [columnVisibilityModel, hideableColumns]);
106
+ const firstSwitchRef = React.useRef(null);
107
+ React.useEffect(() => {
108
+ if (autoFocusSearchField) {
109
+ searchInputRef.current.focus();
110
+ } else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
111
+ firstSwitchRef.current.focus();
112
+ }
113
+ }, [autoFocusSearchField]);
114
+ let firstHideableColumnFound = false;
115
+ const isFirstHideableColumn = column => {
116
+ if (firstHideableColumnFound === false && column.hideable !== false) {
117
+ firstHideableColumnFound = true;
118
+ return true;
119
+ }
120
+ return false;
121
+ };
122
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
123
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnsManagementHeader, {
124
+ className: classes.header,
125
+ ownerState: rootProps,
126
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTextField, (0, _extends2.default)({
127
+ placeholder: apiRef.current.getLocaleText('columnsManagementSearchTitle'),
128
+ inputRef: searchInputRef,
129
+ value: searchValue,
130
+ onChange: handleSearchValueChange,
131
+ variant: "outlined",
132
+ size: "small",
133
+ InputProps: {
134
+ startAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputAdornment, {
135
+ position: "start",
136
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.quickFilterIcon, {})
137
+ }),
138
+ sx: {
139
+ pl: 1.5
140
+ }
141
+ },
142
+ fullWidth: true
143
+ }, rootProps.slotProps?.baseTextField))
144
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsManagementBody, {
145
+ className: classes.root,
146
+ ownerState: rootProps,
147
+ children: [currentColumns.map(column => /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
148
+ className: classes.row,
149
+ control: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseCheckbox, (0, _extends2.default)({
150
+ disabled: column.hideable === false,
151
+ checked: columnVisibilityModel[column.field] !== false,
152
+ onClick: toggleColumn,
153
+ name: column.field,
154
+ sx: {
155
+ p: 0.5
156
+ },
157
+ inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
158
+ }, rootProps.slotProps?.baseCheckbox)),
159
+ label: column.headerName || column.field
160
+ }, column.field)), currentColumns.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnsManagementEmptyText, {
161
+ ownerState: rootProps,
162
+ children: apiRef.current.getLocaleText('columnsManagementNoColumns')
163
+ })]
164
+ }), !disableShowHideToggle && !disableResetButton && currentColumns.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsManagementFooter, {
165
+ ownerState: rootProps,
166
+ className: classes.footer,
167
+ children: [!disableShowHideToggle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
168
+ control: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseCheckbox, (0, _extends2.default)({
169
+ disabled: hideableColumns.length === 0,
170
+ checked: allHideableColumnsVisible,
171
+ indeterminate: !allHideableColumnsVisible && !allHideableColumnsHidden,
172
+ onClick: () => toggleAllColumns(!allHideableColumnsVisible),
173
+ name: apiRef.current.getLocaleText('columnsManagementShowHideAllText'),
174
+ sx: {
175
+ p: 0.5
176
+ }
177
+ }, rootProps.slotProps?.baseCheckbox)),
178
+ label: apiRef.current.getLocaleText('columnsManagementShowHideAllText')
179
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}), !disableResetButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
180
+ onClick: () => apiRef.current.setColumnVisibilityModel(initialColumnVisibilityModel),
181
+ disabled: isResetDisabled
182
+ }, rootProps.slotProps?.baseButton, {
183
+ children: "Reset"
184
+ })) : null]
185
+ }) : null]
186
+ });
187
+ }
188
+ process.env.NODE_ENV !== "production" ? GridColumnsManagement.propTypes = {
189
+ // ----------------------------- Warning --------------------------------
190
+ // | These PropTypes are generated from the TypeScript type definitions |
191
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
192
+ // ----------------------------------------------------------------------
193
+ /**
194
+ * If `true`, the column search field will be focused automatically.
195
+ * If `false`, the first column switch input will be focused automatically.
196
+ * This helps to avoid input keyboard panel to popup automatically on touch devices.
197
+ * @default true
198
+ */
199
+ autoFocusSearchField: _propTypes.default.bool,
200
+ /**
201
+ * If `true`, the `Reset` button will not be disabled
202
+ * @default false
203
+ */
204
+ disableResetButton: _propTypes.default.bool,
205
+ /**
206
+ * If `true`, the `Show/Hide all` toggle checkbox will not be displayed.
207
+ * @default false
208
+ */
209
+ disableShowHideToggle: _propTypes.default.bool,
210
+ /**
211
+ * Returns the list of togglable columns.
212
+ * If used, only those columns will be displayed in the panel
213
+ * which are passed as the return value of the function.
214
+ * @param {GridColDef[]} columns The `ColDef` list of all columns.
215
+ * @returns {GridColDef['field'][]} The list of togglable columns' field names.
216
+ */
217
+ getTogglableColumns: _propTypes.default.func,
218
+ searchPredicate: _propTypes.default.func,
219
+ sort: _propTypes.default.oneOf(['asc', 'desc']),
220
+ /**
221
+ * Changes the behavior of the `Show/Hide All` toggle when the search field is used:
222
+ * - `all`: Will toggle all columns.
223
+ * - `filteredOnly`: Will only toggle columns that match the search criteria.
224
+ * @default 'all'
225
+ */
226
+ toggleAllMode: _propTypes.default.oneOf(['all', 'filteredOnly'])
227
+ } : void 0;
228
+ const GridColumnsManagementBody = (0, _styles.styled)('div', {
229
+ name: 'MuiDataGrid',
230
+ slot: 'ColumnsManagement',
231
+ overridesResolver: (props, styles) => styles.columnsManagement
232
+ })(({
233
+ theme
234
+ }) => ({
235
+ padding: theme.spacing(0, 3, 1.5),
236
+ display: 'flex',
237
+ flexDirection: 'column',
238
+ overflow: 'auto',
239
+ flex: '1 1',
240
+ maxHeight: 400,
241
+ alignItems: 'flex-start'
242
+ }));
243
+ const GridColumnsManagementHeader = (0, _styles.styled)('div', {
244
+ name: 'MuiDataGrid',
245
+ slot: 'ColumnsManagementHeader',
246
+ overridesResolver: (props, styles) => styles.columnsManagementHeader
247
+ })(({
248
+ theme
249
+ }) => ({
250
+ padding: theme.spacing(1.5, 3)
251
+ }));
252
+ const GridColumnsManagementFooter = (0, _styles.styled)('div', {
253
+ name: 'MuiDataGrid',
254
+ slot: 'ColumnsManagementFooter',
255
+ overridesResolver: (props, styles) => styles.columnsManagementFooter
256
+ })(({
257
+ theme
258
+ }) => ({
259
+ padding: theme.spacing(0.5, 1, 0.5, 3),
260
+ display: 'flex',
261
+ justifyContent: 'space-between',
262
+ borderTop: `1px solid ${theme.palette.divider}`
263
+ }));
264
+ const GridColumnsManagementEmptyText = (0, _styles.styled)('div')(({
265
+ theme
266
+ }) => ({
267
+ padding: theme.spacing(0.5, 0),
268
+ color: theme.palette.grey[500]
269
+ }));
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _GridColumnsManagement = require("./GridColumnsManagement");
7
+ Object.keys(_GridColumnsManagement).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _GridColumnsManagement[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _GridColumnsManagement[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultSearchPredicate = exports.checkColumnVisibilityModelsSame = void 0;
7
+ const checkColumnVisibilityModelsSame = (a, b) => {
8
+ // Filter `false` values only, as `true` and not having a key are the same
9
+ const aFalseValues = new Set(Object.keys(a).filter(key => a[key] === false));
10
+ const bFalseValues = new Set(Object.keys(b).filter(key => b[key] === false));
11
+ if (aFalseValues.size !== bFalseValues.size) {
12
+ return false;
13
+ }
14
+ let result = true;
15
+ aFalseValues.forEach(key => {
16
+ if (!bFalseValues.has(key)) {
17
+ result = false;
18
+ }
19
+ });
20
+ return result;
21
+ };
22
+ exports.checkColumnVisibilityModelsSame = checkColumnVisibilityModelsSame;
23
+ const defaultSearchPredicate = (column, searchValue) => (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
24
+ exports.defaultSearchPredicate = defaultSearchPredicate;
@@ -91,6 +91,17 @@ Object.keys(_panel).forEach(function (key) {
91
91
  }
92
92
  });
93
93
  });
94
+ var _columnsManagement = require("./columnsManagement");
95
+ Object.keys(_columnsManagement).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _columnsManagement[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _columnsManagement[key];
102
+ }
103
+ });
104
+ });
94
105
  var _toolbar = require("./toolbar");
95
106
  Object.keys(_toolbar).forEach(function (key) {
96
107
  if (key === "default" || key === "__esModule") return;
@@ -6,195 +6,18 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.GridColumnsPanel = GridColumnsPanel;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
9
  var React = _interopRequireWildcard(require("react"));
11
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
- var _utils = require("@mui/utils");
13
- var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
14
- var _Switch = require("@mui/material/Switch");
15
- var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
16
- var _styles = require("@mui/material/styles");
17
- var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
18
- var _useGridSelector = require("../../hooks/utils/useGridSelector");
19
- var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
20
- var _GridPanelContent = require("./GridPanelContent");
21
- var _GridPanelFooter = require("./GridPanelFooter");
22
- var _GridPanelHeader = require("./GridPanelHeader");
23
11
  var _GridPanelWrapper = require("./GridPanelWrapper");
24
- var _envConstants = require("../../constants/envConstants");
12
+ var _columnsManagement = require("../columnsManagement");
25
13
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
26
- var _gridClasses = require("../../constants/gridClasses");
27
14
  var _jsxRuntime = require("react/jsx-runtime");
28
- const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
29
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
30
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
31
- const useUtilityClasses = ownerState => {
32
- const {
33
- classes
34
- } = ownerState;
35
- const slots = {
36
- root: ['columnsPanel'],
37
- columnsPanelRow: ['columnsPanelRow']
38
- };
39
- return (0, _utils.unstable_composeClasses)(slots, _gridClasses.getDataGridUtilityClass, classes);
40
- };
41
- const GridColumnsPanelRoot = (0, _styles.styled)('div', {
42
- name: 'MuiDataGrid',
43
- slot: 'ColumnsPanel',
44
- overridesResolver: (props, styles) => styles.columnsPanel
45
- })({
46
- padding: '8px 0px 8px 8px'
47
- });
48
- const GridColumnsPanelRowRoot = (0, _styles.styled)('div', {
49
- name: 'MuiDataGrid',
50
- slot: 'ColumnsPanelRow',
51
- overridesResolver: (props, styles) => styles.columnsPanelRow
52
- })(({
53
- theme
54
- }) => ({
55
- display: 'flex',
56
- justifyContent: 'space-between',
57
- padding: '1px 8px 1px 7px',
58
- [`& .${_Switch.switchClasses.root}`]: {
59
- marginRight: theme.spacing(0.5)
60
- }
61
- }));
62
- const GridIconButtonRoot = (0, _styles.styled)(_IconButton.default)({
63
- justifyContent: 'flex-end'
64
- });
65
- const collator = new Intl.Collator();
66
- const defaultSearchPredicate = (column, searchValue) => {
67
- return (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
68
- };
69
17
  function GridColumnsPanel(props) {
70
- const apiRef = (0, _useGridApiContext.useGridApiContext)();
71
- const searchInputRef = React.useRef(null);
72
- const columns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnDefinitionsSelector);
73
- const columnVisibilityModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnVisibilityModelSelector);
74
18
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
75
- const [searchValue, setSearchValue] = React.useState('');
76
- const classes = useUtilityClasses(rootProps);
77
- const {
78
- sort,
79
- searchPredicate = defaultSearchPredicate,
80
- autoFocusSearchField = true,
81
- disableHideAllButton = false,
82
- disableShowAllButton = false,
83
- getTogglableColumns
84
- } = props,
85
- other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
86
- const sortedColumns = React.useMemo(() => {
87
- switch (sort) {
88
- case 'asc':
89
- return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
90
- case 'desc':
91
- return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
92
- default:
93
- return columns;
94
- }
95
- }, [columns, sort]);
96
- const toggleColumn = event => {
97
- const {
98
- name: field
99
- } = event.target;
100
- apiRef.current.setColumnVisibility(field, columnVisibilityModel[field] === false);
101
- };
102
- const toggleAllColumns = React.useCallback(isVisible => {
103
- const currentModel = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
104
- const newModel = (0, _extends2.default)({}, currentModel);
105
- const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
106
- columns.forEach(col => {
107
- if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
108
- if (isVisible) {
109
- // delete the key from the model instead of setting it to `true`
110
- delete newModel[col.field];
111
- } else {
112
- newModel[col.field] = false;
113
- }
114
- }
115
- });
116
- return apiRef.current.setColumnVisibilityModel(newModel);
117
- }, [apiRef, columns, getTogglableColumns]);
118
- const handleSearchValueChange = React.useCallback(event => {
119
- setSearchValue(event.target.value);
120
- }, []);
121
- const currentColumns = React.useMemo(() => {
122
- const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
123
- const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
124
- field
125
- }) => togglableColumns.includes(field)) : sortedColumns;
126
- if (!searchValue) {
127
- return togglableSortedColumns;
128
- }
129
- return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
130
- }, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
131
- const firstSwitchRef = React.useRef(null);
132
- React.useEffect(() => {
133
- if (autoFocusSearchField) {
134
- searchInputRef.current.focus();
135
- } else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
136
- firstSwitchRef.current.focus();
137
- }
138
- }, [autoFocusSearchField]);
139
- let firstHideableColumnFound = false;
140
- const isFirstHideableColumn = column => {
141
- if (firstHideableColumnFound === false && column.hideable !== false) {
142
- firstHideableColumnFound = true;
143
- return true;
144
- }
145
- return false;
146
- };
147
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelWrapper.GridPanelWrapper, (0, _extends2.default)({}, other, {
148
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridPanelHeader.GridPanelHeader, {
149
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTextField, (0, _extends2.default)({
150
- label: apiRef.current.getLocaleText('columnsPanelTextFieldLabel'),
151
- placeholder: apiRef.current.getLocaleText('columnsPanelTextFieldPlaceholder'),
152
- inputRef: searchInputRef,
153
- value: searchValue,
154
- onChange: handleSearchValueChange,
155
- variant: "standard",
156
- fullWidth: true
157
- }, rootProps.slotProps?.baseTextField))
158
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridPanelContent.GridPanelContent, {
159
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnsPanelRoot, {
160
- className: classes.root,
161
- ownerState: rootProps,
162
- children: currentColumns.map(column => /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsPanelRowRoot, {
163
- className: classes.columnsPanelRow,
164
- ownerState: rootProps,
165
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
166
- control: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSwitch, (0, _extends2.default)({
167
- disabled: column.hideable === false,
168
- checked: columnVisibilityModel[column.field] !== false,
169
- onClick: toggleColumn,
170
- name: column.field,
171
- size: "small",
172
- inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
173
- }, rootProps.slotProps?.baseSwitch)),
174
- label: column.headerName || column.field
175
- }), !rootProps.disableColumnReorder && _envConstants.GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/(0, _jsxRuntime.jsx)(GridIconButtonRoot, {
176
- draggable: true,
177
- "aria-label": apiRef.current.getLocaleText('columnsPanelDragIconLabel'),
178
- title: apiRef.current.getLocaleText('columnsPanelDragIconLabel'),
179
- size: "small",
180
- disabled: true,
181
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnReorderIcon, {})
182
- })]
183
- }, column.field))
184
- })
185
- }), disableShowAllButton && disableHideAllButton ? null : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridPanelFooter.GridPanelFooter, {
186
- children: [!disableHideAllButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
187
- onClick: () => toggleAllColumns(false)
188
- }, rootProps.slotProps?.baseButton, {
189
- disabled: disableHideAllButton,
190
- children: apiRef.current.getLocaleText('columnsPanelHideAllButton')
191
- })) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {}), !disableShowAllButton ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseButton, (0, _extends2.default)({
192
- onClick: () => toggleAllColumns(true)
193
- }, rootProps.slotProps?.baseButton, {
194
- disabled: disableShowAllButton,
195
- children: apiRef.current.getLocaleText('columnsPanelShowAllButton')
196
- })) : null]
197
- })]
19
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridPanelWrapper.GridPanelWrapper, (0, _extends2.default)({}, props, {
20
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_columnsManagement.GridColumnsManagement, (0, _extends2.default)({}, rootProps.slotProps?.columnsManagement))
198
21
  }));
199
22
  }
200
23
  process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
@@ -202,32 +25,5 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
202
25
  // | These PropTypes are generated from the TypeScript type definitions |
203
26
  // | To update them edit the TypeScript types and run "yarn proptypes" |
204
27
  // ----------------------------------------------------------------------
205
- /**
206
- * If `true`, the column search field will be focused automatically.
207
- * If `false`, the first column switch input will be focused automatically.
208
- * This helps to avoid input keyboard panel to popup automatically on touch devices.
209
- * @default true
210
- */
211
- autoFocusSearchField: _propTypes.default.bool,
212
- /**
213
- * If `true`, the `Hide all` button will not be displayed.
214
- * @default false
215
- */
216
- disableHideAllButton: _propTypes.default.bool,
217
- /**
218
- * If `true`, the `Show all` button will be disabled
219
- * @default false
220
- */
221
- disableShowAllButton: _propTypes.default.bool,
222
- /**
223
- * Returns the list of togglable columns.
224
- * If used, only those columns will be displayed in the panel
225
- * which are passed as the return value of the function.
226
- * @param {GridColDef[]} columns The `ColDef` list of all columns.
227
- * @returns {GridColDef['field'][]} The list of togglable columns' field names.
228
- */
229
- getTogglableColumns: _propTypes.default.func,
230
- searchPredicate: _propTypes.default.func,
231
- slotProps: _propTypes.default.object,
232
- sort: _propTypes.default.oneOf(['asc', 'desc'])
28
+ slotProps: _propTypes.default.object
233
29
  } : void 0;
@@ -33,6 +33,7 @@ const DATA_GRID_DEFAULT_SLOTS_COMPONENTS = exports.DATA_GRID_DEFAULT_SLOTS_COMPO
33
33
  pagination: _components.GridPagination,
34
34
  filterPanel: _components.GridFilterPanel,
35
35
  columnsPanel: _components.GridColumnsPanel,
36
+ columnsManagement: _components.GridColumnsManagement,
36
37
  panel: _components.GridPanel,
37
38
  row: _components.GridRow
38
39
  });
@@ -9,4 +9,4 @@ var _utils = require("@mui/utils");
9
9
  function getDataGridUtilityClass(slot) {
10
10
  return (0, _utils.unstable_generateUtilityClass)('MuiDataGrid', slot);
11
11
  }
12
- const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellContent', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnGroupHeader', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeader--showColumnBorder', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
12
+ const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellContent', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnGroupHeader', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeader--showColumnBorder', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
@@ -33,12 +33,10 @@ const GRID_DEFAULT_LOCALE_TEXT = exports.GRID_DEFAULT_LOCALE_TEXT = {
33
33
  toolbarExportCSV: 'Download as CSV',
34
34
  toolbarExportPrint: 'Print',
35
35
  toolbarExportExcel: 'Download as Excel',
36
- // Columns panel text
37
- columnsPanelTextFieldLabel: 'Find column',
38
- columnsPanelTextFieldPlaceholder: 'Column title',
39
- columnsPanelDragIconLabel: 'Reorder column',
40
- columnsPanelShowAllButton: 'Show all',
41
- columnsPanelHideAllButton: 'Hide all',
36
+ // Columns management text
37
+ columnsManagementSearchTitle: 'Search',
38
+ columnsManagementNoColumns: 'No columns',
39
+ columnsManagementShowHideAllText: 'Show/Hide All',
42
40
  // Filter panel text
43
41
  filterPanelAddFilter: 'Add filter',
44
42
  filterPanelRemoveAll: 'Remove all',
@@ -107,6 +107,9 @@ function useGridApiInitialization(inputApiRef, props) {
107
107
  subscribeEvent,
108
108
  publishEvent
109
109
  }, 'public');
110
+ if (inputApiRef && !inputApiRef.current?.state) {
111
+ inputApiRef.current = publicApiRef.current;
112
+ }
110
113
  React.useImperativeHandle(inputApiRef, () => publicApiRef.current, [publicApiRef]);
111
114
  React.useEffect(() => {
112
115
  const api = privateApiRef.current;
@@ -68,7 +68,9 @@ function calculateCellColSpan(params) {
68
68
  } = params;
69
69
  const columnsLength = columns.length;
70
70
  const column = columns[columnIndex];
71
- const colSpan = typeof column.colSpan === 'function' ? column.colSpan(apiRef.current.getCellParams(rowId, column.field)) : column.colSpan;
71
+ const row = apiRef.current.getRow(rowId);
72
+ const value = apiRef.current.getRowValue(row, column);
73
+ const colSpan = typeof column.colSpan === 'function' ? column.colSpan(value, row, column, apiRef) : column.colSpan;
72
74
  if (!colSpan || colSpan === 1) {
73
75
  setCellColSpanInfo(lookup, rowId, columnIndex, {
74
76
  spannedByColSpan: false,
@@ -343,7 +343,7 @@ const useGridCellEditing = (apiRef, props) => {
343
343
  const row = apiRef.current.getRow(id);
344
344
  let parsedValue = value;
345
345
  if (column.valueParser && !skipValueParser) {
346
- parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
346
+ parsedValue = column.valueParser(value, row, column, apiRef);
347
347
  }
348
348
  let editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
349
349
  let newProps = (0, _extends2.default)({}, editingState[id][field], {
@@ -391,10 +391,7 @@ const useGridCellEditing = (apiRef, props) => {
391
391
  const {
392
392
  value
393
393
  } = editingState[id][field];
394
- return column.valueSetter ? column.valueSetter({
395
- value,
396
- row
397
- }) : (0, _extends2.default)({}, row, {
394
+ return column.valueSetter ? column.valueSetter(value, row, column, apiRef) : (0, _extends2.default)({}, row, {
398
395
  [field]: value
399
396
  });
400
397
  }, [apiRef]);