@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
@@ -1,196 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
4
2
  import * as React from 'react';
5
3
  import PropTypes from 'prop-types';
6
- import { unstable_composeClasses as composeClasses } from '@mui/utils';
7
- import IconButton from '@mui/material/IconButton';
8
- import { switchClasses } from '@mui/material/Switch';
9
- import FormControlLabel from '@mui/material/FormControlLabel';
10
- import { styled } from '@mui/material/styles';
11
- import { gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector } from '../../hooks/features/columns/gridColumnsSelector';
12
- import { useGridSelector } from '../../hooks/utils/useGridSelector';
13
- import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
14
- import { GridPanelContent } from './GridPanelContent';
15
- import { GridPanelFooter } from './GridPanelFooter';
16
- import { GridPanelHeader } from './GridPanelHeader';
17
4
  import { GridPanelWrapper } from './GridPanelWrapper';
18
- import { GRID_EXPERIMENTAL_ENABLED } from '../../constants/envConstants';
5
+ import { GridColumnsManagement } from '../columnsManagement';
19
6
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
20
- import { getDataGridUtilityClass } from '../../constants/gridClasses';
21
7
  import { jsx as _jsx } from "react/jsx-runtime";
22
- import { jsxs as _jsxs } from "react/jsx-runtime";
23
- const useUtilityClasses = ownerState => {
24
- const {
25
- classes
26
- } = ownerState;
27
- const slots = {
28
- root: ['columnsPanel'],
29
- columnsPanelRow: ['columnsPanelRow']
30
- };
31
- return composeClasses(slots, getDataGridUtilityClass, classes);
32
- };
33
- const GridColumnsPanelRoot = styled('div', {
34
- name: 'MuiDataGrid',
35
- slot: 'ColumnsPanel',
36
- overridesResolver: (props, styles) => styles.columnsPanel
37
- })({
38
- padding: '8px 0px 8px 8px'
39
- });
40
- const GridColumnsPanelRowRoot = styled('div', {
41
- name: 'MuiDataGrid',
42
- slot: 'ColumnsPanelRow',
43
- overridesResolver: (props, styles) => styles.columnsPanelRow
44
- })(({
45
- theme
46
- }) => ({
47
- display: 'flex',
48
- justifyContent: 'space-between',
49
- padding: '1px 8px 1px 7px',
50
- [`& .${switchClasses.root}`]: {
51
- marginRight: theme.spacing(0.5)
52
- }
53
- }));
54
- const GridIconButtonRoot = styled(IconButton)({
55
- justifyContent: 'flex-end'
56
- });
57
- const collator = new Intl.Collator();
58
- const defaultSearchPredicate = (column, searchValue) => {
59
- return (column.headerName || column.field).toLowerCase().indexOf(searchValue) > -1;
60
- };
61
8
  function GridColumnsPanel(props) {
62
- var _rootProps$slotProps, _rootProps$slotProps3, _rootProps$slotProps4;
63
- const apiRef = useGridApiContext();
64
- const searchInputRef = React.useRef(null);
65
- const columns = useGridSelector(apiRef, gridColumnDefinitionsSelector);
66
- const columnVisibilityModel = useGridSelector(apiRef, gridColumnVisibilityModelSelector);
9
+ var _rootProps$slotProps;
67
10
  const rootProps = useGridRootProps();
68
- const [searchValue, setSearchValue] = React.useState('');
69
- const classes = useUtilityClasses(rootProps);
70
- const {
71
- sort,
72
- searchPredicate = defaultSearchPredicate,
73
- autoFocusSearchField = true,
74
- disableHideAllButton = false,
75
- disableShowAllButton = false,
76
- getTogglableColumns
77
- } = props,
78
- other = _objectWithoutPropertiesLoose(props, _excluded);
79
- const sortedColumns = React.useMemo(() => {
80
- switch (sort) {
81
- case 'asc':
82
- return [...columns].sort((a, b) => collator.compare(a.headerName || a.field, b.headerName || b.field));
83
- case 'desc':
84
- return [...columns].sort((a, b) => -collator.compare(a.headerName || a.field, b.headerName || b.field));
85
- default:
86
- return columns;
87
- }
88
- }, [columns, sort]);
89
- const toggleColumn = event => {
90
- const {
91
- name: field
92
- } = event.target;
93
- apiRef.current.setColumnVisibility(field, columnVisibilityModel[field] === false);
94
- };
95
- const toggleAllColumns = React.useCallback(isVisible => {
96
- const currentModel = gridColumnVisibilityModelSelector(apiRef);
97
- const newModel = _extends({}, currentModel);
98
- const togglableColumns = getTogglableColumns ? getTogglableColumns(columns) : null;
99
- columns.forEach(col => {
100
- if (col.hideable && (togglableColumns == null || togglableColumns.includes(col.field))) {
101
- if (isVisible) {
102
- // delete the key from the model instead of setting it to `true`
103
- delete newModel[col.field];
104
- } else {
105
- newModel[col.field] = false;
106
- }
107
- }
108
- });
109
- return apiRef.current.setColumnVisibilityModel(newModel);
110
- }, [apiRef, columns, getTogglableColumns]);
111
- const handleSearchValueChange = React.useCallback(event => {
112
- setSearchValue(event.target.value);
113
- }, []);
114
- const currentColumns = React.useMemo(() => {
115
- const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
116
- const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
117
- field
118
- }) => togglableColumns.includes(field)) : sortedColumns;
119
- if (!searchValue) {
120
- return togglableSortedColumns;
121
- }
122
- return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
123
- }, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
124
- const firstSwitchRef = React.useRef(null);
125
- React.useEffect(() => {
126
- if (autoFocusSearchField) {
127
- searchInputRef.current.focus();
128
- } else if (firstSwitchRef.current && typeof firstSwitchRef.current.focus === 'function') {
129
- firstSwitchRef.current.focus();
130
- }
131
- }, [autoFocusSearchField]);
132
- let firstHideableColumnFound = false;
133
- const isFirstHideableColumn = column => {
134
- if (firstHideableColumnFound === false && column.hideable !== false) {
135
- firstHideableColumnFound = true;
136
- return true;
137
- }
138
- return false;
139
- };
140
- return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
141
- children: [/*#__PURE__*/_jsx(GridPanelHeader, {
142
- children: /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
143
- label: apiRef.current.getLocaleText('columnsPanelTextFieldLabel'),
144
- placeholder: apiRef.current.getLocaleText('columnsPanelTextFieldPlaceholder'),
145
- inputRef: searchInputRef,
146
- value: searchValue,
147
- onChange: handleSearchValueChange,
148
- variant: "standard",
149
- fullWidth: true
150
- }, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.baseTextField))
151
- }), /*#__PURE__*/_jsx(GridPanelContent, {
152
- children: /*#__PURE__*/_jsx(GridColumnsPanelRoot, {
153
- className: classes.root,
154
- ownerState: rootProps,
155
- children: currentColumns.map(column => {
156
- var _rootProps$slotProps2;
157
- return /*#__PURE__*/_jsxs(GridColumnsPanelRowRoot, {
158
- className: classes.columnsPanelRow,
159
- ownerState: rootProps,
160
- children: [/*#__PURE__*/_jsx(FormControlLabel, {
161
- control: /*#__PURE__*/_jsx(rootProps.slots.baseSwitch, _extends({
162
- disabled: column.hideable === false,
163
- checked: columnVisibilityModel[column.field] !== false,
164
- onClick: toggleColumn,
165
- name: column.field,
166
- size: "small",
167
- inputRef: isFirstHideableColumn(column) ? firstSwitchRef : undefined
168
- }, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseSwitch)),
169
- label: column.headerName || column.field
170
- }), !rootProps.disableColumnReorder && GRID_EXPERIMENTAL_ENABLED && /*#__PURE__*/_jsx(GridIconButtonRoot, {
171
- draggable: true,
172
- "aria-label": apiRef.current.getLocaleText('columnsPanelDragIconLabel'),
173
- title: apiRef.current.getLocaleText('columnsPanelDragIconLabel'),
174
- size: "small",
175
- disabled: true,
176
- children: /*#__PURE__*/_jsx(rootProps.slots.columnReorderIcon, {})
177
- })]
178
- }, column.field);
179
- })
180
- })
181
- }), disableShowAllButton && disableHideAllButton ? null : /*#__PURE__*/_jsxs(GridPanelFooter, {
182
- children: [!disableHideAllButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
183
- onClick: () => toggleAllColumns(false)
184
- }, (_rootProps$slotProps3 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps3.baseButton, {
185
- disabled: disableHideAllButton,
186
- children: apiRef.current.getLocaleText('columnsPanelHideAllButton')
187
- })) : /*#__PURE__*/_jsx("span", {}), !disableShowAllButton ? /*#__PURE__*/_jsx(rootProps.slots.baseButton, _extends({
188
- onClick: () => toggleAllColumns(true)
189
- }, (_rootProps$slotProps4 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps4.baseButton, {
190
- disabled: disableShowAllButton,
191
- children: apiRef.current.getLocaleText('columnsPanelShowAllButton')
192
- })) : null]
193
- })]
11
+ return /*#__PURE__*/_jsx(GridPanelWrapper, _extends({}, props, {
12
+ children: /*#__PURE__*/_jsx(GridColumnsManagement, _extends({}, (_rootProps$slotProps = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps.columnsManagement))
194
13
  }));
195
14
  }
196
15
  process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
@@ -198,33 +17,6 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
198
17
  // | These PropTypes are generated from the TypeScript type definitions |
199
18
  // | To update them edit the TypeScript types and run "yarn proptypes" |
200
19
  // ----------------------------------------------------------------------
201
- /**
202
- * If `true`, the column search field will be focused automatically.
203
- * If `false`, the first column switch input will be focused automatically.
204
- * This helps to avoid input keyboard panel to popup automatically on touch devices.
205
- * @default true
206
- */
207
- autoFocusSearchField: PropTypes.bool,
208
- /**
209
- * If `true`, the `Hide all` button will not be displayed.
210
- * @default false
211
- */
212
- disableHideAllButton: PropTypes.bool,
213
- /**
214
- * If `true`, the `Show all` button will be disabled
215
- * @default false
216
- */
217
- disableShowAllButton: PropTypes.bool,
218
- /**
219
- * Returns the list of togglable columns.
220
- * If used, only those columns will be displayed in the panel
221
- * which are passed as the return value of the function.
222
- * @param {GridColDef[]} columns The `ColDef` list of all columns.
223
- * @returns {GridColDef['field'][]} The list of togglable columns' field names.
224
- */
225
- getTogglableColumns: PropTypes.func,
226
- searchPredicate: PropTypes.func,
227
- slotProps: PropTypes.object,
228
- sort: PropTypes.oneOf(['asc', 'desc'])
20
+ slotProps: PropTypes.object
229
21
  } : void 0;
230
22
  export { GridColumnsPanel };
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { GridSkeletonCell, GridColumnsPanel, GridFilterPanel, GridFooter, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridRow, GridColumnHeaderFilterIconButton, GridRowCount } from '../components';
2
+ import { GridSkeletonCell, GridColumnsPanel, GridFilterPanel, GridFooter, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridRow, GridColumnHeaderFilterIconButton, GridRowCount, GridColumnsManagement } from '../components';
3
3
  import { GridCell } from '../components/cell/GridCell';
4
4
  import { GridColumnHeaders } from '../components/GridColumnHeaders';
5
5
  import { GridColumnMenu } from '../components/menu/columnMenu/GridColumnMenu';
@@ -27,6 +27,7 @@ export const DATA_GRID_DEFAULT_SLOTS_COMPONENTS = _extends({}, materialSlots, {
27
27
  pagination: GridPagination,
28
28
  filterPanel: GridFilterPanel,
29
29
  columnsPanel: GridColumnsPanel,
30
+ columnsManagement: GridColumnsManagement,
30
31
  panel: GridPanel,
31
32
  row: GridRow
32
33
  });
@@ -228,13 +228,21 @@ export interface GridClasses {
228
228
  */
229
229
  columnSeparator: string;
230
230
  /**
231
- * Styles applied to the columns panel element.
231
+ * Styles applied to the columns management body.
232
232
  */
233
- columnsPanel: string;
233
+ columnsManagement: string;
234
234
  /**
235
- * Styles applied to the columns panel row element.
235
+ * Styles applied to the columns management row element.
236
236
  */
237
- columnsPanelRow: string;
237
+ columnsManagementRow: string;
238
+ /**
239
+ * Styles applied to the columns management header element.
240
+ */
241
+ columnsManagementHeader: string;
242
+ /**
243
+ * Styles applied to the columns management footer element.
244
+ */
245
+ columnsManagementFooter: string;
238
246
  /**
239
247
  * Styles applied to the top container.
240
248
  */
@@ -2,4 +2,4 @@ import { unstable_generateUtilityClasses as generateUtilityClasses, unstable_gen
2
2
  export function getDataGridUtilityClass(slot) {
3
3
  return generateUtilityClass('MuiDataGrid', slot);
4
4
  }
5
- export const gridClasses = 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']);
5
+ export const gridClasses = 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']);
@@ -27,12 +27,10 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
27
27
  toolbarExportCSV: 'Download as CSV',
28
28
  toolbarExportPrint: 'Print',
29
29
  toolbarExportExcel: 'Download as Excel',
30
- // Columns panel text
31
- columnsPanelTextFieldLabel: 'Find column',
32
- columnsPanelTextFieldPlaceholder: 'Column title',
33
- columnsPanelDragIconLabel: 'Reorder column',
34
- columnsPanelShowAllButton: 'Show all',
35
- columnsPanelHideAllButton: 'Hide all',
30
+ // Columns management text
31
+ columnsManagementSearchTitle: 'Search',
32
+ columnsManagementNoColumns: 'No columns',
33
+ columnsManagementShowHideAllText: 'Show/Hide All',
36
34
  // Filter panel text
37
35
  filterPanelAddFilter: 'Add filter',
38
36
  filterPanelRemoveAll: 'Remove all',
@@ -69,6 +69,7 @@ function createPublicAPI(privateApiRef) {
69
69
  return publicApi;
70
70
  }
71
71
  export function useGridApiInitialization(inputApiRef, props) {
72
+ var _inputApiRef$current;
72
73
  const publicApiRef = React.useRef();
73
74
  const privateApiRef = React.useRef();
74
75
  if (!privateApiRef.current) {
@@ -99,6 +100,9 @@ export function useGridApiInitialization(inputApiRef, props) {
99
100
  subscribeEvent,
100
101
  publishEvent
101
102
  }, 'public');
103
+ if (inputApiRef && !((_inputApiRef$current = inputApiRef.current) != null && _inputApiRef$current.state)) {
104
+ inputApiRef.current = publicApiRef.current;
105
+ }
102
106
  React.useImperativeHandle(inputApiRef, () => publicApiRef.current, [publicApiRef]);
103
107
  React.useEffect(() => {
104
108
  const api = privateApiRef.current;
@@ -60,7 +60,9 @@ function calculateCellColSpan(params) {
60
60
  } = params;
61
61
  const columnsLength = columns.length;
62
62
  const column = columns[columnIndex];
63
- const colSpan = typeof column.colSpan === 'function' ? column.colSpan(apiRef.current.getCellParams(rowId, column.field)) : column.colSpan;
63
+ const row = apiRef.current.getRow(rowId);
64
+ const value = apiRef.current.getRowValue(row, column);
65
+ const colSpan = typeof column.colSpan === 'function' ? column.colSpan(value, row, column, apiRef) : column.colSpan;
64
66
  if (!colSpan || colSpan === 1) {
65
67
  setCellColSpanInfo(lookup, rowId, columnIndex, {
66
68
  spannedByColSpan: false,
@@ -335,7 +335,7 @@ export const useGridCellEditing = (apiRef, props) => {
335
335
  const row = apiRef.current.getRow(id);
336
336
  let parsedValue = value;
337
337
  if (column.valueParser && !skipValueParser) {
338
- parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
338
+ parsedValue = column.valueParser(value, row, column, apiRef);
339
339
  }
340
340
  let editingState = gridEditRowsStateSelector(apiRef.current.state);
341
341
  let newProps = _extends({}, editingState[id][field], {
@@ -383,10 +383,7 @@ export const useGridCellEditing = (apiRef, props) => {
383
383
  const {
384
384
  value
385
385
  } = editingState[id][field];
386
- return column.valueSetter ? column.valueSetter({
387
- value,
388
- row
389
- }) : _extends({}, row, {
386
+ return column.valueSetter ? column.valueSetter(value, row, column, apiRef) : _extends({}, row, {
390
387
  [field]: value
391
388
  });
392
389
  }, [apiRef]);
@@ -410,7 +410,7 @@ export const useGridRowEditing = (apiRef, props) => {
410
410
  const row = apiRef.current.getRow(id);
411
411
  let parsedValue = value;
412
412
  if (column.valueParser && !skipValueParser) {
413
- parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
413
+ parsedValue = column.valueParser(value, row, column, apiRef);
414
414
  }
415
415
  let editingState = gridEditRowsStateSelector(apiRef.current.state);
416
416
  let newProps = _extends({}, editingState[id][field], {
@@ -510,10 +510,7 @@ export const useGridRowEditing = (apiRef, props) => {
510
510
  Object.entries(editingState[id]).forEach(([field, fieldProps]) => {
511
511
  const column = apiRef.current.getColumn(field);
512
512
  if (column.valueSetter) {
513
- rowUpdate = column.valueSetter({
514
- value: fieldProps.value,
515
- row: rowUpdate
516
- });
513
+ rowUpdate = column.valueSetter(fieldProps.value, rowUpdate, column, apiRef);
517
514
  } else {
518
515
  rowUpdate[field] = fieldProps.value;
519
516
  }
@@ -89,7 +89,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
89
89
  if (column.valueParser) {
90
90
  var _filterItem$value;
91
91
  const parser = column.valueParser;
92
- parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(x => parser(x)) : parser(filterItem.value);
92
+ parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(x => parser(x, undefined, column, apiRef)) : parser(filterItem.value, undefined, column, apiRef);
93
93
  } else {
94
94
  parsedValue = filterItem.value;
95
95
  }
@@ -131,7 +131,10 @@ export const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) =>
131
131
  if (!skipAutoGeneratedRows || !isAutoGeneratedRow(tree[child])) {
132
132
  validDescendants.push(child);
133
133
  }
134
- validDescendants.push(...getTreeNodeDescendants(tree, child, skipAutoGeneratedRows));
134
+ const childDescendants = getTreeNodeDescendants(tree, child, skipAutoGeneratedRows);
135
+ for (let j = 0; j < childDescendants.length; j += 1) {
136
+ validDescendants.push(childDescendants[j]);
137
+ }
135
138
  }
136
139
  if (!skipAutoGeneratedRows && node.footerId != null) {
137
140
  validDescendants.push(node.footerId);
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
- import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
3
  export declare class MissingRowIdError extends Error {
5
4
  }
6
5
  /**
@@ -11,4 +10,4 @@ export declare class MissingRowIdError extends Error {
11
10
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
12
11
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
13
12
  */
14
- export declare function useGridParamsApi(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'getRowId'>): void;
13
+ export declare function useGridParamsApi(apiRef: React.MutableRefObject<GridPrivateApiCommunity>): void;
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from '../../../utils/domUtils';
3
- import { GRID_ID_AUTOGENERATED } from './gridRowsUtils';
4
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
4
  import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
6
5
  export class MissingRowIdError extends Error {}
@@ -13,10 +12,7 @@ export class MissingRowIdError extends Error {}
13
12
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
14
13
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
15
14
  */
16
- export function useGridParamsApi(apiRef, props) {
17
- const {
18
- getRowId
19
- } = props;
15
+ export function useGridParamsApi(apiRef) {
20
16
  const getColumnHeaderParams = React.useCallback(field => ({
21
17
  field,
22
18
  colDef: apiRef.current.getColumn(field)
@@ -33,28 +29,6 @@ export function useGridParamsApi(apiRef, props) {
33
29
  };
34
30
  return params;
35
31
  }, [apiRef]);
36
- const getBaseCellParams = React.useCallback((id, field) => {
37
- const row = apiRef.current.getRow(id);
38
- const rowNode = apiRef.current.getRowNode(id);
39
- if (!row || !rowNode) {
40
- throw new MissingRowIdError(`No row with id #${id} found`);
41
- }
42
- const cellFocus = gridFocusCellSelector(apiRef);
43
- const cellTabIndex = gridTabIndexCellSelector(apiRef);
44
- const params = {
45
- id,
46
- field,
47
- row,
48
- rowNode,
49
- value: row[field],
50
- colDef: apiRef.current.getColumn(field),
51
- cellMode: apiRef.current.getCellMode(id, field),
52
- api: apiRef.current,
53
- hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
54
- tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1
55
- };
56
- return params;
57
- }, [apiRef]);
58
32
  const getCellParams = React.useCallback((id, field) => {
59
33
  const colDef = apiRef.current.getColumn(field);
60
34
  const value = apiRef.current.getCellValue(id, field);
@@ -79,12 +53,7 @@ export function useGridParamsApi(apiRef, props) {
79
53
  isEditable: false
80
54
  };
81
55
  if (colDef && colDef.valueFormatter) {
82
- params.formattedValue = colDef.valueFormatter({
83
- id,
84
- field: params.field,
85
- value: params.value,
86
- api: apiRef.current
87
- });
56
+ params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
88
57
  }
89
58
  params.isEditable = colDef && apiRef.current.isCellEditable(params);
90
59
  return params;
@@ -98,32 +67,28 @@ export function useGridParamsApi(apiRef, props) {
98
67
  }
99
68
  return rowModel[field];
100
69
  }
101
- return colDef.valueGetter(getBaseCellParams(id, field));
102
- }, [apiRef, getBaseCellParams]);
70
+ const row = apiRef.current.getRow(id);
71
+ if (!row) {
72
+ throw new MissingRowIdError(`No row with id #${id} found`);
73
+ }
74
+ const value = row[colDef.field];
75
+ return colDef.valueGetter(value, row, colDef, apiRef);
76
+ }, [apiRef]);
103
77
  const getRowValue = React.useCallback((row, colDef) => {
104
- var _getRowId;
105
- const id = GRID_ID_AUTOGENERATED in row ? row[GRID_ID_AUTOGENERATED] : (_getRowId = getRowId == null ? void 0 : getRowId(row)) != null ? _getRowId : row.id;
106
78
  const field = colDef.field;
107
79
  if (!colDef || !colDef.valueGetter) {
108
80
  return row[field];
109
81
  }
110
- return colDef.valueGetter(getBaseCellParams(id, field));
111
- }, [getBaseCellParams, getRowId]);
82
+ const value = row[colDef.field];
83
+ return colDef.valueGetter(value, row, colDef, apiRef);
84
+ }, [apiRef]);
112
85
  const getRowFormattedValue = React.useCallback((row, colDef) => {
113
- var _ref;
114
86
  const value = getRowValue(row, colDef);
115
87
  if (!colDef || !colDef.valueFormatter) {
116
88
  return value;
117
89
  }
118
- const id = (_ref = getRowId ? getRowId(row) : row.id) != null ? _ref : row[GRID_ID_AUTOGENERATED];
119
- const field = colDef.field;
120
- return colDef.valueFormatter({
121
- id,
122
- field,
123
- value,
124
- api: apiRef.current
125
- });
126
- }, [apiRef, getRowId, getRowValue]);
90
+ return colDef.valueFormatter(value, row, colDef, apiRef);
91
+ }, [apiRef, getRowValue]);
127
92
  const getColumnHeaderElement = React.useCallback(field => {
128
93
  if (!apiRef.current.rootElementRef.current) {
129
94
  return null;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-alpha.9
2
+ * @mui/x-data-grid v7.0.0-beta.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -57,7 +57,7 @@ export var useDataGridComponent = function useDataGridComponent(inputApiRef, pro
57
57
  useGridRowSelection(apiRef, props);
58
58
  useGridColumns(apiRef, props);
59
59
  useGridRows(apiRef, props);
60
- useGridParamsApi(apiRef, props);
60
+ useGridParamsApi(apiRef);
61
61
  useGridColumnSpanning(apiRef);
62
62
  useGridColumnGrouping(apiRef, props);
63
63
  useGridEditing(apiRef, props);
@@ -4,11 +4,9 @@ import { renderBooleanCell } from '../components/cell/GridBooleanCell';
4
4
  import { renderEditBooleanCell } from '../components/cell/GridEditBooleanCell';
5
5
  import { gridNumberComparator } from '../hooks/features/sorting/gridSortingUtils';
6
6
  import { getGridBooleanOperators } from './gridBooleanOperators';
7
- function gridBooleanFormatter(_ref) {
8
- var value = _ref.value,
9
- api = _ref.api;
10
- return value ? api.getLocaleText('booleanCellTrueLabel') : api.getLocaleText('booleanCellFalseLabel');
11
- }
7
+ var gridBooleanFormatter = function gridBooleanFormatter(value, row, column, apiRef) {
8
+ return value ? apiRef.current.getLocaleText('booleanCellTrueLabel') : apiRef.current.getLocaleText('booleanCellFalseLabel');
9
+ };
12
10
  var stringToBoolean = function stringToBoolean(value) {
13
11
  switch (value.toLowerCase().trim()) {
14
12
  case 'true':
@@ -19,9 +19,10 @@ export var GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF,
19
19
  disableReorder: true,
20
20
  disableExport: true,
21
21
  getApplyQuickFilterFn: undefined,
22
- valueGetter: function valueGetter(params) {
23
- var selectionLookup = selectedIdsLookupSelector(params.api.state, params.api.instanceId);
24
- return selectionLookup[params.id] !== undefined;
22
+ valueGetter: function valueGetter(value, row, column, apiRef) {
23
+ var selectionLookup = selectedIdsLookupSelector(apiRef);
24
+ var rowId = apiRef.current.getRowId(row);
25
+ return selectionLookup[rowId] !== undefined;
25
26
  },
26
27
  renderHeader: function renderHeader(params) {
27
28
  return /*#__PURE__*/_jsx(GridHeaderCheckbox, _extends({}, params));
@@ -12,36 +12,32 @@ function throwIfNotDateObject(_ref) {
12
12
  throw new Error(["MUI X: `".concat(columnType, "` column type only accepts `Date` objects as values."), 'Use `valueGetter` to transform the value into a `Date` object.', "Row ID: ".concat(rowId, ", field: \"").concat(field, "\".")].join('\n'));
13
13
  }
14
14
  }
15
- export function gridDateFormatter(_ref2) {
16
- var value = _ref2.value,
17
- field = _ref2.field,
18
- id = _ref2.id;
15
+ export var gridDateFormatter = function gridDateFormatter(value, row, column, apiRef) {
19
16
  if (!value) {
20
17
  return '';
21
18
  }
19
+ var rowId = apiRef.current.getRowId(row);
22
20
  throwIfNotDateObject({
23
21
  value: value,
24
22
  columnType: 'date',
25
- rowId: id,
26
- field: field
23
+ rowId: rowId,
24
+ field: column.field
27
25
  });
28
26
  return value.toLocaleDateString();
29
- }
30
- export function gridDateTimeFormatter(_ref3) {
31
- var value = _ref3.value,
32
- field = _ref3.field,
33
- id = _ref3.id;
27
+ };
28
+ export var gridDateTimeFormatter = function gridDateTimeFormatter(value, row, column, apiRef) {
34
29
  if (!value) {
35
30
  return '';
36
31
  }
32
+ var rowId = apiRef.current.getRowId(row);
37
33
  throwIfNotDateObject({
38
34
  value: value,
39
35
  columnType: 'dateTime',
40
- rowId: id,
41
- field: field
36
+ rowId: rowId,
37
+ field: column.field
42
38
  });
43
39
  return value.toLocaleString();
44
- }
40
+ };
45
41
  export var GRID_DATE_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
46
42
  type: 'date',
47
43
  sortComparator: gridDateComparator,
@@ -11,8 +11,7 @@ export var GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
11
11
  valueParser: function valueParser(value) {
12
12
  return value === '' ? null : Number(value);
13
13
  },
14
- valueFormatter: function valueFormatter(_ref) {
15
- var value = _ref.value;
14
+ valueFormatter: function valueFormatter(value) {
16
15
  return isNumber(value) ? value.toLocaleString() : value || '';
17
16
  },
18
17
  filterOperators: getGridNumericOperators(),