@mui/x-data-grid 6.9.1 → 6.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/DataGrid/DataGrid.js +4 -1
  3. package/README.md +1 -1
  4. package/components/GridPagination.js +16 -3
  5. package/components/cell/GridEditDateCell.js +1 -1
  6. package/components/cell/GridEditInputCell.js +3 -3
  7. package/hooks/features/columns/gridColumnsUtils.js +2 -1
  8. package/hooks/features/dimensions/useGridDimensions.js +3 -3
  9. package/hooks/features/editing/useGridEditing.js +2 -1
  10. package/hooks/features/filter/useGridFilter.js +6 -2
  11. package/hooks/features/rows/useGridParamsApi.js +4 -4
  12. package/index.js +1 -1
  13. package/joy/joySlots.js +17 -5
  14. package/legacy/DataGrid/DataGrid.js +4 -1
  15. package/legacy/components/GridPagination.js +16 -3
  16. package/legacy/components/cell/GridEditDateCell.js +1 -1
  17. package/legacy/components/cell/GridEditInputCell.js +3 -3
  18. package/legacy/hooks/features/columns/gridColumnsUtils.js +4 -1
  19. package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -3
  20. package/legacy/hooks/features/editing/useGridEditing.js +2 -1
  21. package/legacy/hooks/features/filter/useGridFilter.js +4 -2
  22. package/legacy/hooks/features/rows/useGridParamsApi.js +4 -4
  23. package/legacy/index.js +1 -1
  24. package/legacy/joy/joySlots.js +17 -5
  25. package/legacy/locales/esES.js +3 -3
  26. package/locales/esES.js +3 -3
  27. package/models/api/gridEditingApi.d.ts +1 -1
  28. package/models/props/DataGridProps.d.ts +4 -1
  29. package/modern/DataGrid/DataGrid.js +4 -1
  30. package/modern/components/GridPagination.js +16 -2
  31. package/modern/components/cell/GridEditDateCell.js +1 -1
  32. package/modern/components/cell/GridEditInputCell.js +3 -3
  33. package/modern/hooks/features/columns/gridColumnsUtils.js +2 -1
  34. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -3
  35. package/modern/hooks/features/editing/useGridEditing.js +1 -1
  36. package/modern/hooks/features/filter/useGridFilter.js +6 -2
  37. package/modern/hooks/features/rows/useGridParamsApi.js +1 -1
  38. package/modern/index.js +1 -1
  39. package/modern/joy/joySlots.js +17 -4
  40. package/modern/locales/esES.js +3 -3
  41. package/node/DataGrid/DataGrid.js +4 -1
  42. package/node/components/GridPagination.js +16 -2
  43. package/node/components/cell/GridEditDateCell.js +1 -1
  44. package/node/components/cell/GridEditInputCell.js +3 -3
  45. package/node/hooks/features/columns/gridColumnsUtils.js +2 -1
  46. package/node/hooks/features/dimensions/useGridDimensions.js +3 -3
  47. package/node/hooks/features/editing/useGridEditing.js +1 -1
  48. package/node/hooks/features/filter/useGridFilter.js +6 -2
  49. package/node/hooks/features/rows/useGridParamsApi.js +1 -1
  50. package/node/index.js +1 -1
  51. package/node/joy/joySlots.js +17 -4
  52. package/node/locales/esES.js +3 -3
  53. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,68 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.9.2
7
+
8
+ _Jul 6, 2023_
9
+
10
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🚀 Auto-scroll when making range selection (#8661) @m4theushw
13
+
14
+ - 📚 New page: Components lifecycle (#8372) @flaviendelangle
15
+
16
+ Clarify pickers events and value updates in a [single docs page](https://mui.com/x/react-date-pickers/lifecycle/).
17
+
18
+ - 🥧 Add pie chart component
19
+
20
+ They are fresh from the code editor. You can visit [pie charts docs](https://mui.com/x/react-charts/pie/) or their [demo page](https://mui.com/x/react-charts/pie-demo/).
21
+
22
+ <img width="380" alt="pie-charts" src="https://github.com/mui/mui-x/assets/13808724/fe908c45-803c-4316-b913-dbd2f9f0551e">
23
+
24
+ - 🐞 Bugfixes
25
+
26
+ - 📚 Documentation improvements
27
+
28
+ ### `@mui/x-data-grid@v6.9.2` / `@mui/x-data-grid-pro@v6.9.2` / `@mui/x-data-grid-premium@v6.9.2`
29
+
30
+ #### Changes
31
+
32
+ - [DataGrid] Fix `RangeError` when using flex columns (#9554) @cherniavskii
33
+ - [DataGrid] Fix React 17 editing bug (#9530) @romgrk
34
+ - [DataGrid] Use `getRowId` in filtering (#9564) @romgrk
35
+ - [DataGrid] Correctly reflect `TablePagination`'s `rowsPerPageOptions` shape to `pageSizeOptions` (#9438) @burakkgunduzz
36
+ - [DataGridPremium] Auto-scroll when making range selection (#8661) @m4theushw
37
+ - [l10n] Improve Spanish (es-ES) locale (#9500) @fufex
38
+
39
+ ### `@mui/x-date-pickers@v6.9.2` / `@mui/x-date-pickers-pro@v6.9.2`
40
+
41
+ #### Changes
42
+
43
+ - [pickers] Forward digital clock classes (#9555) @YoonjiJang
44
+ - [pickers] Rename `internal` folder to `internals` on `@mui/x-date-picker-pro` (#9571) @flaviendelangle
45
+
46
+ ### `@mui/x-charts@6.0.0-alpha.2`
47
+
48
+ #### Changes
49
+
50
+ - [charts] Add pie chart component (#9395) @alexfauquette
51
+
52
+ ### Docs
53
+
54
+ - [docs] Add pickers playground (#9164) @LukasTy
55
+ - [docs] Fix API links for pickers (#9573) @alexfauquette
56
+ - [docs] Fix demos with `ToggleButtonGroup` (#9548) @flaviendelangle
57
+ - [docs] Fix typos in pagination documentation page (#9332) @RatherBeLunar
58
+ - [docs] Hide ads on paid content @oliviertassinari
59
+ - [docs] Move the charts in the sidebar (#9437) @flaviendelangle
60
+ - [docs] New page: Components lifecycle (#8372) @flaviendelangle
61
+ - [docs] Remove outdated header tag @oliviertassinari
62
+
63
+ ### Core
64
+
65
+ - [core] Fix typo in priority support @oliviertassinari
66
+ - [core] Remove mention of Crowdin @oliviertassinari
67
+
6
68
  ## 6.9.1
7
69
 
8
70
  _Jun 30, 2023_
@@ -513,7 +513,10 @@ DataGridRaw.propTypes = {
513
513
  * Select the pageSize dynamically using the component UI.
514
514
  * @default [25, 50, 100]
515
515
  */
516
- pageSizeOptions: PropTypes.arrayOf(PropTypes.number),
516
+ pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
517
+ label: PropTypes.string.isRequired,
518
+ value: PropTypes.number.isRequired
519
+ })]).isRequired),
517
520
  pagination: props => {
518
521
  if (props.pagination === false) {
519
522
  return new Error(['MUI: `<DataGrid pagination={false} />` is not a valid prop.', 'Infinite scrolling is not available in the MIT version.', '', 'You need to upgrade to DataGridPro or DataGridPremium component to disable the pagination.'].join('\n'));
package/README.md CHANGED
@@ -7,7 +7,7 @@ It's part of MUI X, an open core extension of MUI, with advanced components.
7
7
 
8
8
  Install the package in your project directory with:
9
9
 
10
- ```sh
10
+ ```bash
11
11
  // with npm
12
12
  npm install @mui/x-data-grid
13
13
 
@@ -25,7 +25,6 @@ const GridPaginationRoot = styled(TablePagination)(({
25
25
  }
26
26
  }));
27
27
  export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(props, ref) {
28
- var _rootProps$pageSizeOp;
29
28
  const apiRef = useGridApiContext();
30
29
  const rootProps = useGridRootProps();
31
30
  const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
@@ -42,22 +41,36 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
42
41
  const handlePageChange = React.useCallback((_, page) => {
43
42
  apiRef.current.setPage(page);
44
43
  }, [apiRef]);
44
+ const isPageSizeIncludedInPageSizeOptions = pageSize => {
45
+ for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
46
+ const option = rootProps.pageSizeOptions[i];
47
+ if (typeof option === 'number') {
48
+ if (option === pageSize) {
49
+ return true;
50
+ }
51
+ } else if (option.value === pageSize) {
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ };
45
57
  if (process.env.NODE_ENV !== 'production') {
46
58
  var _rootProps$pagination, _rootProps$pagination2;
47
59
  // eslint-disable-next-line react-hooks/rules-of-hooks
48
60
  const warnedOnceMissingInPageSizeOptions = React.useRef(false);
49
61
  const pageSize = (_rootProps$pagination = (_rootProps$pagination2 = rootProps.paginationModel) == null ? void 0 : _rootProps$pagination2.pageSize) != null ? _rootProps$pagination : paginationModel.pageSize;
50
- if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(pageSize)) {
62
+ if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
51
63
  console.warn([`MUI: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\``, `Add it to show the pagination select.`].join('\n'));
52
64
  warnedOnceMissingInPageSizeOptions.current = true;
53
65
  }
54
66
  }
67
+ const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
55
68
  return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
56
69
  ref: ref,
57
70
  component: "div",
58
71
  count: rowCount,
59
72
  page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
60
- rowsPerPageOptions: (_rootProps$pageSizeOp = rootProps.pageSizeOptions) != null && _rootProps$pageSizeOp.includes(paginationModel.pageSize) ? rootProps.pageSizeOptions : [],
73
+ rowsPerPageOptions: pageSizeOptions,
61
74
  rowsPerPage: paginationModel.pageSize,
62
75
  onPageChange: handlePageChange,
63
76
  onRowsPerPageChange: handlePageSizeChange
@@ -112,7 +112,7 @@ function GridEditDateCell(props) {
112
112
  const meta = apiRef.current.unstable_getEditCellMeta(id, field);
113
113
  const handleInputRef = el => {
114
114
  inputRef.current = el;
115
- if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
115
+ if (meta != null && meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
116
116
  const inputValue = inputRef.current.value;
117
117
  const parsedDate = parseValueToDate(inputValue);
118
118
  setValueState({
@@ -68,12 +68,12 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
68
68
  unstable_skipValueParser: true
69
69
  }, event);
70
70
  }, [apiRef, debounceMs, field, id, onValueChange]);
71
- const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
71
+ const meta = apiRef.current.unstable_getEditCellMeta(id, field);
72
72
  React.useEffect(() => {
73
- if (meta.changeReason !== 'debouncedSetEditCellValue') {
73
+ if ((meta == null ? void 0 : meta.changeReason) !== 'debouncedSetEditCellValue') {
74
74
  setValueState(value);
75
75
  }
76
- }, [meta.changeReason, value]);
76
+ }, [meta, value]);
77
77
  useEnhancedEffect(() => {
78
78
  if (hasFocus) {
79
79
  inputRef.current.focus();
@@ -15,6 +15,7 @@ export function computeFlexColumnsWidth({
15
15
  totalFlexUnits,
16
16
  flexColumns
17
17
  }) {
18
+ const uniqueFlexColumns = new Set(flexColumns.map(col => col.field));
18
19
  const flexColumnsLookup = {
19
20
  all: {},
20
21
  frozenFields: [],
@@ -30,7 +31,7 @@ export function computeFlexColumnsWidth({
30
31
  // Step 5 of https://drafts.csswg.org/css-flexbox-1/#resolve-flexible-lengths
31
32
  function loopOverFlexItems() {
32
33
  // 5a: If all the flex items on the line are frozen, free space has been distributed.
33
- if (flexColumnsLookup.frozenFields.length === flexColumns.length) {
34
+ if (flexColumnsLookup.frozenFields.length === uniqueFlexColumns.size) {
34
35
  return;
35
36
  }
36
37
  const violationsLookup = {
@@ -73,7 +73,7 @@ export function useGridDimensions(apiRef, props) {
73
73
  let hasScrollY;
74
74
  if (props.autoHeight) {
75
75
  hasScrollY = false;
76
- hasScrollX = columnsTotalWidth > rootDimensionsRef.current.width;
76
+ hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
77
77
  viewportOuterSize = {
78
78
  width: rootDimensionsRef.current.width,
79
79
  height: rowsMeta.currentPageTotalHeight + (hasScrollX ? scrollBarSize : 0)
@@ -85,11 +85,11 @@ export function useGridDimensions(apiRef, props) {
85
85
  };
86
86
  const scrollInformation = hasScroll({
87
87
  content: {
88
- width: columnsTotalWidth,
88
+ width: Math.round(columnsTotalWidth),
89
89
  height: rowsMeta.currentPageTotalHeight
90
90
  },
91
91
  container: {
92
- width: viewportOuterSize.width,
92
+ width: Math.round(viewportOuterSize.width),
93
93
  height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
94
94
  },
95
95
  scrollBarSize
@@ -106,8 +106,9 @@ export const useGridEditing = (apiRef, props) => {
106
106
  return props.editMode === GridEditModes.Cell ? apiRef.current.getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.getRowWithUpdatedValuesFromRowEditing(id);
107
107
  }, [apiRef, props.editMode]);
108
108
  const getEditCellMeta = React.useCallback((id, field) => {
109
+ var _editingState$id$fiel, _editingState$id;
109
110
  const editingState = gridEditRowsStateSelector(apiRef.current.state);
110
- return editingState[id][field];
111
+ return (_editingState$id$fiel = (_editingState$id = editingState[id]) == null ? void 0 : _editingState$id[field]) != null ? _editingState$id$fiel : null;
111
112
  }, [apiRef]);
112
113
  const editingSharedApi = {
113
114
  isCellEditable,
@@ -258,6 +258,9 @@ export const useGridFilter = (apiRef, props) => {
258
258
  }, [props.slots.filterPanel, (_props$slotProps2 = props.slotProps) == null ? void 0 : _props$slotProps2.filterPanel]);
259
259
  const dataRowIdToIdLookup = apiRef.current.state.rows.dataRowIdToModelLookup;
260
260
  const rows = React.useMemo(() => Object.values(dataRowIdToIdLookup), [dataRowIdToIdLookup]);
261
+ const {
262
+ getRowId
263
+ } = props;
261
264
  const flatFilteringMethod = React.useCallback(params => {
262
265
  if (props.filterMode !== 'client' || !params.isRowMatchingFilters) {
263
266
  return {
@@ -277,9 +280,10 @@ export const useGridFilter = (apiRef, props) => {
277
280
  };
278
281
  for (let i = 0; i < rows.length; i += 1) {
279
282
  const row = rows[i];
283
+ const id = getRowId ? getRowId(row) : row.id;
280
284
  isRowMatchingFilters(row, undefined, result);
281
285
  const isRowPassing = passFilterLogic([result.passingFilterItems], [result.passingQuickFilterValues], params.filterModel, apiRef, filterCache);
282
- filteredRowsLookup[row.id] = isRowPassing;
286
+ filteredRowsLookup[id] = isRowPassing;
283
287
  }
284
288
  const footerId = 'auto-generated-group-footer-root';
285
289
  const footer = dataRowIdToModelLookup[footerId];
@@ -290,7 +294,7 @@ export const useGridFilter = (apiRef, props) => {
290
294
  filteredRowsLookup,
291
295
  filteredDescendantCountLookup: {}
292
296
  };
293
- }, [apiRef, props.filterMode, rows]);
297
+ }, [apiRef, rows, props.filterMode, getRowId]);
294
298
  useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuItem);
295
299
  useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
296
300
  useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
@@ -101,8 +101,8 @@ export function useGridParamsApi(apiRef, props) {
101
101
  return colDef.valueGetter(getBaseCellParams(id, field));
102
102
  }, [apiRef, getBaseCellParams]);
103
103
  const getRowValue = React.useCallback((row, colDef) => {
104
- var _ref;
105
- const id = (_ref = getRowId ? getRowId(row) : row.id) != null ? _ref : row[GRID_ID_AUTOGENERATED];
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
106
  const field = colDef.field;
107
107
  if (!colDef || !colDef.valueGetter) {
108
108
  return row[field];
@@ -110,12 +110,12 @@ export function useGridParamsApi(apiRef, props) {
110
110
  return colDef.valueGetter(getBaseCellParams(id, field));
111
111
  }, [getBaseCellParams, getRowId]);
112
112
  const getRowFormattedValue = React.useCallback((row, colDef) => {
113
- var _ref2;
113
+ var _ref;
114
114
  const value = getRowValue(row, colDef);
115
115
  if (!colDef || !colDef.valueFormatter) {
116
116
  return value;
117
117
  }
118
- const id = (_ref2 = getRowId ? getRowId(row) : row.id) != null ? _ref2 : row[GRID_ID_AUTOGENERATED];
118
+ const id = (_ref = getRowId ? getRowId(row) : row.id) != null ? _ref : row[GRID_ID_AUTOGENERATED];
119
119
  const field = colDef.field;
120
120
  return colDef.valueFormatter({
121
121
  id,
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.9.1
2
+ * @mui/x-data-grid v6.9.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/joy/joySlots.js CHANGED
@@ -291,7 +291,6 @@ const getLabelDisplayedRowsTo = ({
291
291
  return pageSize === -1 ? rowCount : Math.min(rowCount, (page + 1) * pageSize);
292
292
  };
293
293
  const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
294
- var _rootProps$pageSizeOp;
295
294
  const apiRef = useGridApiContext();
296
295
  const rootProps = useGridRootProps();
297
296
  const paginationModel = gridPaginationModelSelector(apiRef);
@@ -306,7 +305,20 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
306
305
  }, [apiRef]);
307
306
  const page = paginationModel.page <= lastPage ? paginationModel.page : lastPage;
308
307
  const pageSize = paginationModel.pageSize;
309
- const pageSizeOptions = (_rootProps$pageSizeOp = rootProps.pageSizeOptions) != null && _rootProps$pageSizeOp.includes(pageSize) ? rootProps.pageSizeOptions : [];
308
+ const isPageSizeIncludedInPageSizeOptions = () => {
309
+ for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
310
+ const option = rootProps.pageSizeOptions[i];
311
+ if (typeof option === 'number') {
312
+ if (option === pageSize) {
313
+ return true;
314
+ }
315
+ } else if (option.value === pageSize) {
316
+ return true;
317
+ }
318
+ }
319
+ return false;
320
+ };
321
+ const pageSizeOptions = isPageSizeIncludedInPageSizeOptions() ? rootProps.pageSizeOptions : [];
310
322
  const handleChangeRowsPerPage = (event, newValue) => {
311
323
  const newPageSize = Number(newValue);
312
324
  apiRef.current.setPageSize(newPageSize);
@@ -330,9 +342,9 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
330
342
  value: pageSize,
331
343
  children: pageSizeOptions.map(option => {
332
344
  return /*#__PURE__*/_jsx(Option, {
333
- value: option,
334
- children: option
335
- }, option);
345
+ value: typeof option !== 'number' && option.value ? option.value : option,
346
+ children: typeof option !== 'number' && option.label ? option.label : `${option}`
347
+ }, typeof option !== 'number' && option.label ? option.label : `${option}`);
336
348
  })
337
349
  })]
338
350
  }), /*#__PURE__*/_jsx(JoyTypography, {
@@ -515,7 +515,10 @@ DataGridRaw.propTypes = {
515
515
  * Select the pageSize dynamically using the component UI.
516
516
  * @default [25, 50, 100]
517
517
  */
518
- pageSizeOptions: PropTypes.arrayOf(PropTypes.number),
518
+ pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
519
+ label: PropTypes.string.isRequired,
520
+ value: PropTypes.number.isRequired
521
+ })]).isRequired),
519
522
  pagination: function pagination(props) {
520
523
  if (props.pagination === false) {
521
524
  return new Error(['MUI: `<DataGrid pagination={false} />` is not a valid prop.', 'Infinite scrolling is not available in the MIT version.', '', 'You need to upgrade to DataGridPro or DataGridPremium component to disable the pagination.'].join('\n'));
@@ -23,7 +23,6 @@ var GridPaginationRoot = styled(TablePagination)(function (_ref) {
23
23
  })), _ref2;
24
24
  });
25
25
  export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(props, ref) {
26
- var _rootProps$pageSizeOp;
27
26
  var apiRef = useGridApiContext();
28
27
  var rootProps = useGridRootProps();
29
28
  var paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
@@ -42,22 +41,36 @@ export var GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginatio
42
41
  var handlePageChange = React.useCallback(function (_, page) {
43
42
  apiRef.current.setPage(page);
44
43
  }, [apiRef]);
44
+ var isPageSizeIncludedInPageSizeOptions = function isPageSizeIncludedInPageSizeOptions(pageSize) {
45
+ for (var i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
46
+ var option = rootProps.pageSizeOptions[i];
47
+ if (typeof option === 'number') {
48
+ if (option === pageSize) {
49
+ return true;
50
+ }
51
+ } else if (option.value === pageSize) {
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ };
45
57
  if (process.env.NODE_ENV !== 'production') {
46
58
  var _rootProps$pagination, _rootProps$pagination2;
47
59
  // eslint-disable-next-line react-hooks/rules-of-hooks
48
60
  var warnedOnceMissingInPageSizeOptions = React.useRef(false);
49
61
  var pageSize = (_rootProps$pagination = (_rootProps$pagination2 = rootProps.paginationModel) == null ? void 0 : _rootProps$pagination2.pageSize) != null ? _rootProps$pagination : paginationModel.pageSize;
50
- if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(pageSize)) {
62
+ if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
51
63
  console.warn(["MUI: The page size `".concat(paginationModel.pageSize, "` is not preset in the `pageSizeOptions`"), "Add it to show the pagination select."].join('\n'));
52
64
  warnedOnceMissingInPageSizeOptions.current = true;
53
65
  }
54
66
  }
67
+ var pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
55
68
  return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
56
69
  ref: ref,
57
70
  component: "div",
58
71
  count: rowCount,
59
72
  page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
60
- rowsPerPageOptions: (_rootProps$pageSizeOp = rootProps.pageSizeOptions) != null && _rootProps$pageSizeOp.includes(paginationModel.pageSize) ? rootProps.pageSizeOptions : [],
73
+ rowsPerPageOptions: pageSizeOptions,
61
74
  rowsPerPage: paginationModel.pageSize,
62
75
  onPageChange: handlePageChange,
63
76
  onRowsPerPageChange: handlePageSizeChange
@@ -151,7 +151,7 @@ function GridEditDateCell(props) {
151
151
  var meta = apiRef.current.unstable_getEditCellMeta(id, field);
152
152
  var handleInputRef = function handleInputRef(el) {
153
153
  inputRef.current = el;
154
- if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
154
+ if (meta != null && meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
155
155
  var inputValue = inputRef.current.value;
156
156
  var parsedDate = parseValueToDate(inputValue);
157
157
  setValueState({
@@ -100,12 +100,12 @@ var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
100
100
  return _ref2.apply(this, arguments);
101
101
  };
102
102
  }(), [apiRef, debounceMs, field, id, onValueChange]);
103
- var meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
103
+ var meta = apiRef.current.unstable_getEditCellMeta(id, field);
104
104
  React.useEffect(function () {
105
- if (meta.changeReason !== 'debouncedSetEditCellValue') {
105
+ if ((meta == null ? void 0 : meta.changeReason) !== 'debouncedSetEditCellValue') {
106
106
  setValueState(value);
107
107
  }
108
- }, [meta.changeReason, value]);
108
+ }, [meta, value]);
109
109
  useEnhancedEffect(function () {
110
110
  if (hasFocus) {
111
111
  inputRef.current.focus();
@@ -17,6 +17,9 @@ export function computeFlexColumnsWidth(_ref) {
17
17
  var initialFreeSpace = _ref.initialFreeSpace,
18
18
  totalFlexUnits = _ref.totalFlexUnits,
19
19
  flexColumns = _ref.flexColumns;
20
+ var uniqueFlexColumns = new Set(flexColumns.map(function (col) {
21
+ return col.field;
22
+ }));
20
23
  var flexColumnsLookup = {
21
24
  all: {},
22
25
  frozenFields: [],
@@ -32,7 +35,7 @@ export function computeFlexColumnsWidth(_ref) {
32
35
  // Step 5 of https://drafts.csswg.org/css-flexbox-1/#resolve-flexible-lengths
33
36
  function loopOverFlexItems() {
34
37
  // 5a: If all the flex items on the line are frozen, free space has been distributed.
35
- if (flexColumnsLookup.frozenFields.length === flexColumns.length) {
38
+ if (flexColumnsLookup.frozenFields.length === uniqueFlexColumns.size) {
36
39
  return;
37
40
  }
38
41
  var violationsLookup = {
@@ -73,7 +73,7 @@ export function useGridDimensions(apiRef, props) {
73
73
  var hasScrollY;
74
74
  if (props.autoHeight) {
75
75
  hasScrollY = false;
76
- hasScrollX = columnsTotalWidth > rootDimensionsRef.current.width;
76
+ hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
77
77
  viewportOuterSize = {
78
78
  width: rootDimensionsRef.current.width,
79
79
  height: rowsMeta.currentPageTotalHeight + (hasScrollX ? scrollBarSize : 0)
@@ -85,11 +85,11 @@ export function useGridDimensions(apiRef, props) {
85
85
  };
86
86
  var scrollInformation = hasScroll({
87
87
  content: {
88
- width: columnsTotalWidth,
88
+ width: Math.round(columnsTotalWidth),
89
89
  height: rowsMeta.currentPageTotalHeight
90
90
  },
91
91
  container: {
92
- width: viewportOuterSize.width,
92
+ width: Math.round(viewportOuterSize.width),
93
93
  height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
94
94
  },
95
95
  scrollBarSize: scrollBarSize
@@ -127,8 +127,9 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
127
127
  return props.editMode === GridEditModes.Cell ? apiRef.current.getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.getRowWithUpdatedValuesFromRowEditing(id);
128
128
  }, [apiRef, props.editMode]);
129
129
  var getEditCellMeta = React.useCallback(function (id, field) {
130
+ var _editingState$id$fiel, _editingState$id;
130
131
  var editingState = gridEditRowsStateSelector(apiRef.current.state);
131
- return editingState[id][field];
132
+ return (_editingState$id$fiel = (_editingState$id = editingState[id]) == null ? void 0 : _editingState$id[field]) != null ? _editingState$id$fiel : null;
132
133
  }, [apiRef]);
133
134
  var editingSharedApi = {
134
135
  isCellEditable: isCellEditable,
@@ -271,6 +271,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
271
271
  var rows = React.useMemo(function () {
272
272
  return Object.values(dataRowIdToIdLookup);
273
273
  }, [dataRowIdToIdLookup]);
274
+ var getRowId = props.getRowId;
274
275
  var flatFilteringMethod = React.useCallback(function (params) {
275
276
  if (props.filterMode !== 'client' || !params.isRowMatchingFilters) {
276
277
  return {
@@ -288,9 +289,10 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
288
289
  };
289
290
  for (var i = 0; i < rows.length; i += 1) {
290
291
  var row = rows[i];
292
+ var id = getRowId ? getRowId(row) : row.id;
291
293
  isRowMatchingFilters(row, undefined, result);
292
294
  var isRowPassing = passFilterLogic([result.passingFilterItems], [result.passingQuickFilterValues], params.filterModel, apiRef, filterCache);
293
- filteredRowsLookup[row.id] = isRowPassing;
295
+ filteredRowsLookup[id] = isRowPassing;
294
296
  }
295
297
  var footerId = 'auto-generated-group-footer-root';
296
298
  var footer = dataRowIdToModelLookup[footerId];
@@ -301,7 +303,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
301
303
  filteredRowsLookup: filteredRowsLookup,
302
304
  filteredDescendantCountLookup: {}
303
305
  };
304
- }, [apiRef, props.filterMode, rows]);
306
+ }, [apiRef, rows, props.filterMode, getRowId]);
305
307
  useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuItem);
306
308
  useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
307
309
  useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
@@ -117,8 +117,8 @@ export function useGridParamsApi(apiRef, props) {
117
117
  return colDef.valueGetter(getBaseCellParams(id, field));
118
118
  }, [apiRef, getBaseCellParams]);
119
119
  var getRowValue = React.useCallback(function (row, colDef) {
120
- var _ref;
121
- var id = (_ref = getRowId ? getRowId(row) : row.id) != null ? _ref : row[GRID_ID_AUTOGENERATED];
120
+ var _getRowId;
121
+ var id = GRID_ID_AUTOGENERATED in row ? row[GRID_ID_AUTOGENERATED] : (_getRowId = getRowId == null ? void 0 : getRowId(row)) != null ? _getRowId : row.id;
122
122
  var field = colDef.field;
123
123
  if (!colDef || !colDef.valueGetter) {
124
124
  return row[field];
@@ -126,12 +126,12 @@ export function useGridParamsApi(apiRef, props) {
126
126
  return colDef.valueGetter(getBaseCellParams(id, field));
127
127
  }, [getBaseCellParams, getRowId]);
128
128
  var getRowFormattedValue = React.useCallback(function (row, colDef) {
129
- var _ref2;
129
+ var _ref;
130
130
  var value = getRowValue(row, colDef);
131
131
  if (!colDef || !colDef.valueFormatter) {
132
132
  return value;
133
133
  }
134
- var id = (_ref2 = getRowId ? getRowId(row) : row.id) != null ? _ref2 : row[GRID_ID_AUTOGENERATED];
134
+ var id = (_ref = getRowId ? getRowId(row) : row.id) != null ? _ref : row[GRID_ID_AUTOGENERATED];
135
135
  var field = colDef.field;
136
136
  return colDef.valueFormatter({
137
137
  id: id,
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.9.1
2
+ * @mui/x-data-grid v6.9.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -293,7 +293,6 @@ var getLabelDisplayedRowsTo = function getLabelDisplayedRowsTo(_ref11) {
293
293
  return pageSize === -1 ? rowCount : Math.min(rowCount, (page + 1) * pageSize);
294
294
  };
295
295
  var Pagination = /*#__PURE__*/React.forwardRef(function (props, ref) {
296
- var _rootProps$pageSizeOp;
297
296
  var apiRef = useGridApiContext();
298
297
  var rootProps = useGridRootProps();
299
298
  var paginationModel = gridPaginationModelSelector(apiRef);
@@ -310,7 +309,20 @@ var Pagination = /*#__PURE__*/React.forwardRef(function (props, ref) {
310
309
  }, [apiRef]);
311
310
  var page = paginationModel.page <= lastPage ? paginationModel.page : lastPage;
312
311
  var pageSize = paginationModel.pageSize;
313
- var pageSizeOptions = (_rootProps$pageSizeOp = rootProps.pageSizeOptions) != null && _rootProps$pageSizeOp.includes(pageSize) ? rootProps.pageSizeOptions : [];
312
+ var isPageSizeIncludedInPageSizeOptions = function isPageSizeIncludedInPageSizeOptions() {
313
+ for (var i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
314
+ var option = rootProps.pageSizeOptions[i];
315
+ if (typeof option === 'number') {
316
+ if (option === pageSize) {
317
+ return true;
318
+ }
319
+ } else if (option.value === pageSize) {
320
+ return true;
321
+ }
322
+ }
323
+ return false;
324
+ };
325
+ var pageSizeOptions = isPageSizeIncludedInPageSizeOptions() ? rootProps.pageSizeOptions : [];
314
326
  var handleChangeRowsPerPage = function handleChangeRowsPerPage(event, newValue) {
315
327
  var newPageSize = Number(newValue);
316
328
  apiRef.current.setPageSize(newPageSize);
@@ -334,9 +346,9 @@ var Pagination = /*#__PURE__*/React.forwardRef(function (props, ref) {
334
346
  value: pageSize,
335
347
  children: pageSizeOptions.map(function (option) {
336
348
  return /*#__PURE__*/_jsx(Option, {
337
- value: option,
338
- children: option
339
- }, option);
349
+ value: typeof option !== 'number' && option.value ? option.value : option,
350
+ children: typeof option !== 'number' && option.label ? option.label : "".concat(option)
351
+ }, typeof option !== 'number' && option.label ? option.label : "".concat(option));
340
352
  })
341
353
  })]
342
354
  }), /*#__PURE__*/_jsx(JoyTypography, {
@@ -8,8 +8,8 @@ var esESGrid = {
8
8
  toolbarDensity: 'Densidad',
9
9
  toolbarDensityLabel: 'Densidad',
10
10
  toolbarDensityCompact: 'Compacta',
11
- toolbarDensityStandard: 'Standard',
12
- toolbarDensityComfortable: 'Comoda',
11
+ toolbarDensityStandard: 'Estándar',
12
+ toolbarDensityComfortable: 'Cómoda',
13
13
  // Columns selector toolbar button text
14
14
  toolbarColumns: 'Columnas',
15
15
  toolbarColumnsLabel: 'Seleccionar columnas',
@@ -39,7 +39,7 @@ var esESGrid = {
39
39
  columnsPanelHideAllButton: 'Ocultar todo',
40
40
  // Filter panel text
41
41
  filterPanelAddFilter: 'Agregar filtro',
42
- // filterPanelRemoveAll: 'Remove all',
42
+ filterPanelRemoveAll: 'Remover todos',
43
43
  filterPanelDeleteIconLabel: 'Borrar',
44
44
  filterPanelLogicOperator: 'Operador lógico',
45
45
  filterPanelOperator: 'Operadores',
package/locales/esES.js CHANGED
@@ -8,8 +8,8 @@ const esESGrid = {
8
8
  toolbarDensity: 'Densidad',
9
9
  toolbarDensityLabel: 'Densidad',
10
10
  toolbarDensityCompact: 'Compacta',
11
- toolbarDensityStandard: 'Standard',
12
- toolbarDensityComfortable: 'Comoda',
11
+ toolbarDensityStandard: 'Estándar',
12
+ toolbarDensityComfortable: 'Cómoda',
13
13
  // Columns selector toolbar button text
14
14
  toolbarColumns: 'Columnas',
15
15
  toolbarColumnsLabel: 'Seleccionar columnas',
@@ -37,7 +37,7 @@ const esESGrid = {
37
37
  columnsPanelHideAllButton: 'Ocultar todo',
38
38
  // Filter panel text
39
39
  filterPanelAddFilter: 'Agregar filtro',
40
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'Remover todos',
41
41
  filterPanelDeleteIconLabel: 'Borrar',
42
42
  filterPanelLogicOperator: 'Operador lógico',
43
43
  filterPanelOperator: 'Operadores',
@@ -52,7 +52,7 @@ export interface GridEditingSharedApi {
52
52
  * @param {string} field The field being edited.
53
53
  * @ignore - do not document.
54
54
  */
55
- unstable_getEditCellMeta: (id: GridRowId, field: string) => GridEditCellMeta;
55
+ unstable_getEditCellMeta: (id: GridRowId, field: string) => GridEditCellMeta | null;
56
56
  }
57
57
  export interface GridEditingSharedPrivateApi {
58
58
  /**
@@ -256,7 +256,10 @@ export interface DataGridPropsWithDefaultValues {
256
256
  * Select the pageSize dynamically using the component UI.
257
257
  * @default [25, 50, 100]
258
258
  */
259
- pageSizeOptions: number[];
259
+ pageSizeOptions: Array<number | {
260
+ value: number;
261
+ label: string;
262
+ }>;
260
263
  /**
261
264
  * Sets the type of space between rows added by `getRowSpacing`.
262
265
  * @default "margin"
@@ -513,7 +513,10 @@ DataGridRaw.propTypes = {
513
513
  * Select the pageSize dynamically using the component UI.
514
514
  * @default [25, 50, 100]
515
515
  */
516
- pageSizeOptions: PropTypes.arrayOf(PropTypes.number),
516
+ pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
517
+ label: PropTypes.string.isRequired,
518
+ value: PropTypes.number.isRequired
519
+ })]).isRequired),
517
520
  pagination: props => {
518
521
  if (props.pagination === false) {
519
522
  return new Error(['MUI: `<DataGrid pagination={false} />` is not a valid prop.', 'Infinite scrolling is not available in the MIT version.', '', 'You need to upgrade to DataGridPro or DataGridPremium component to disable the pagination.'].join('\n'));
@@ -38,21 +38,35 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
38
38
  const handlePageChange = React.useCallback((_, page) => {
39
39
  apiRef.current.setPage(page);
40
40
  }, [apiRef]);
41
+ const isPageSizeIncludedInPageSizeOptions = pageSize => {
42
+ for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
43
+ const option = rootProps.pageSizeOptions[i];
44
+ if (typeof option === 'number') {
45
+ if (option === pageSize) {
46
+ return true;
47
+ }
48
+ } else if (option.value === pageSize) {
49
+ return true;
50
+ }
51
+ }
52
+ return false;
53
+ };
41
54
  if (process.env.NODE_ENV !== 'production') {
42
55
  // eslint-disable-next-line react-hooks/rules-of-hooks
43
56
  const warnedOnceMissingInPageSizeOptions = React.useRef(false);
44
57
  const pageSize = rootProps.paginationModel?.pageSize ?? paginationModel.pageSize;
45
- if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(pageSize)) {
58
+ if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
46
59
  console.warn([`MUI: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\``, `Add it to show the pagination select.`].join('\n'));
47
60
  warnedOnceMissingInPageSizeOptions.current = true;
48
61
  }
49
62
  }
63
+ const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
50
64
  return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
51
65
  ref: ref,
52
66
  component: "div",
53
67
  count: rowCount,
54
68
  page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
55
- rowsPerPageOptions: rootProps.pageSizeOptions?.includes(paginationModel.pageSize) ? rootProps.pageSizeOptions : [],
69
+ rowsPerPageOptions: pageSizeOptions,
56
70
  rowsPerPage: paginationModel.pageSize,
57
71
  onPageChange: handlePageChange,
58
72
  onRowsPerPageChange: handlePageSizeChange
@@ -111,7 +111,7 @@ function GridEditDateCell(props) {
111
111
  const meta = apiRef.current.unstable_getEditCellMeta(id, field);
112
112
  const handleInputRef = el => {
113
113
  inputRef.current = el;
114
- if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
114
+ if (meta?.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
115
115
  const inputValue = inputRef.current.value;
116
116
  const parsedDate = parseValueToDate(inputValue);
117
117
  setValueState({
@@ -68,12 +68,12 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
68
68
  unstable_skipValueParser: true
69
69
  }, event);
70
70
  }, [apiRef, debounceMs, field, id, onValueChange]);
71
- const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
71
+ const meta = apiRef.current.unstable_getEditCellMeta(id, field);
72
72
  React.useEffect(() => {
73
- if (meta.changeReason !== 'debouncedSetEditCellValue') {
73
+ if (meta?.changeReason !== 'debouncedSetEditCellValue') {
74
74
  setValueState(value);
75
75
  }
76
- }, [meta.changeReason, value]);
76
+ }, [meta, value]);
77
77
  useEnhancedEffect(() => {
78
78
  if (hasFocus) {
79
79
  inputRef.current.focus();
@@ -15,6 +15,7 @@ export function computeFlexColumnsWidth({
15
15
  totalFlexUnits,
16
16
  flexColumns
17
17
  }) {
18
+ const uniqueFlexColumns = new Set(flexColumns.map(col => col.field));
18
19
  const flexColumnsLookup = {
19
20
  all: {},
20
21
  frozenFields: [],
@@ -30,7 +31,7 @@ export function computeFlexColumnsWidth({
30
31
  // Step 5 of https://drafts.csswg.org/css-flexbox-1/#resolve-flexible-lengths
31
32
  function loopOverFlexItems() {
32
33
  // 5a: If all the flex items on the line are frozen, free space has been distributed.
33
- if (flexColumnsLookup.frozenFields.length === flexColumns.length) {
34
+ if (flexColumnsLookup.frozenFields.length === uniqueFlexColumns.size) {
34
35
  return;
35
36
  }
36
37
  const violationsLookup = {
@@ -72,7 +72,7 @@ export function useGridDimensions(apiRef, props) {
72
72
  let hasScrollY;
73
73
  if (props.autoHeight) {
74
74
  hasScrollY = false;
75
- hasScrollX = columnsTotalWidth > rootDimensionsRef.current.width;
75
+ hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
76
76
  viewportOuterSize = {
77
77
  width: rootDimensionsRef.current.width,
78
78
  height: rowsMeta.currentPageTotalHeight + (hasScrollX ? scrollBarSize : 0)
@@ -84,11 +84,11 @@ export function useGridDimensions(apiRef, props) {
84
84
  };
85
85
  const scrollInformation = hasScroll({
86
86
  content: {
87
- width: columnsTotalWidth,
87
+ width: Math.round(columnsTotalWidth),
88
88
  height: rowsMeta.currentPageTotalHeight
89
89
  },
90
90
  container: {
91
- width: viewportOuterSize.width,
91
+ width: Math.round(viewportOuterSize.width),
92
92
  height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
93
93
  },
94
94
  scrollBarSize
@@ -107,7 +107,7 @@ export const useGridEditing = (apiRef, props) => {
107
107
  }, [apiRef, props.editMode]);
108
108
  const getEditCellMeta = React.useCallback((id, field) => {
109
109
  const editingState = gridEditRowsStateSelector(apiRef.current.state);
110
- return editingState[id][field];
110
+ return editingState[id]?.[field] ?? null;
111
111
  }, [apiRef]);
112
112
  const editingSharedApi = {
113
113
  isCellEditable,
@@ -252,6 +252,9 @@ export const useGridFilter = (apiRef, props) => {
252
252
  }, [props.slots.filterPanel, props.slotProps?.filterPanel]);
253
253
  const dataRowIdToIdLookup = apiRef.current.state.rows.dataRowIdToModelLookup;
254
254
  const rows = React.useMemo(() => Object.values(dataRowIdToIdLookup), [dataRowIdToIdLookup]);
255
+ const {
256
+ getRowId
257
+ } = props;
255
258
  const flatFilteringMethod = React.useCallback(params => {
256
259
  if (props.filterMode !== 'client' || !params.isRowMatchingFilters) {
257
260
  return {
@@ -271,9 +274,10 @@ export const useGridFilter = (apiRef, props) => {
271
274
  };
272
275
  for (let i = 0; i < rows.length; i += 1) {
273
276
  const row = rows[i];
277
+ const id = getRowId ? getRowId(row) : row.id;
274
278
  isRowMatchingFilters(row, undefined, result);
275
279
  const isRowPassing = passFilterLogic([result.passingFilterItems], [result.passingQuickFilterValues], params.filterModel, apiRef, filterCache);
276
- filteredRowsLookup[row.id] = isRowPassing;
280
+ filteredRowsLookup[id] = isRowPassing;
277
281
  }
278
282
  const footerId = 'auto-generated-group-footer-root';
279
283
  const footer = dataRowIdToModelLookup[footerId];
@@ -284,7 +288,7 @@ export const useGridFilter = (apiRef, props) => {
284
288
  filteredRowsLookup,
285
289
  filteredDescendantCountLookup: {}
286
290
  };
287
- }, [apiRef, props.filterMode, rows]);
291
+ }, [apiRef, rows, props.filterMode, getRowId]);
288
292
  useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuItem);
289
293
  useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
290
294
  useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
@@ -101,7 +101,7 @@ export function useGridParamsApi(apiRef, props) {
101
101
  return colDef.valueGetter(getBaseCellParams(id, field));
102
102
  }, [apiRef, getBaseCellParams]);
103
103
  const getRowValue = React.useCallback((row, colDef) => {
104
- const id = (getRowId ? getRowId(row) : row.id) ?? row[GRID_ID_AUTOGENERATED];
104
+ const id = GRID_ID_AUTOGENERATED in row ? row[GRID_ID_AUTOGENERATED] : getRowId?.(row) ?? row.id;
105
105
  const field = colDef.field;
106
106
  if (!colDef || !colDef.valueGetter) {
107
107
  return row[field];
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.9.1
2
+ * @mui/x-data-grid v6.9.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -299,7 +299,20 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
299
299
  }, [apiRef]);
300
300
  const page = paginationModel.page <= lastPage ? paginationModel.page : lastPage;
301
301
  const pageSize = paginationModel.pageSize;
302
- const pageSizeOptions = rootProps.pageSizeOptions?.includes(pageSize) ? rootProps.pageSizeOptions : [];
302
+ const isPageSizeIncludedInPageSizeOptions = () => {
303
+ for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
304
+ const option = rootProps.pageSizeOptions[i];
305
+ if (typeof option === 'number') {
306
+ if (option === pageSize) {
307
+ return true;
308
+ }
309
+ } else if (option.value === pageSize) {
310
+ return true;
311
+ }
312
+ }
313
+ return false;
314
+ };
315
+ const pageSizeOptions = isPageSizeIncludedInPageSizeOptions() ? rootProps.pageSizeOptions : [];
303
316
  const handleChangeRowsPerPage = (event, newValue) => {
304
317
  const newPageSize = Number(newValue);
305
318
  apiRef.current.setPageSize(newPageSize);
@@ -323,9 +336,9 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
323
336
  value: pageSize,
324
337
  children: pageSizeOptions.map(option => {
325
338
  return /*#__PURE__*/_jsx(Option, {
326
- value: option,
327
- children: option
328
- }, option);
339
+ value: typeof option !== 'number' && option.value ? option.value : option,
340
+ children: typeof option !== 'number' && option.label ? option.label : `${option}`
341
+ }, typeof option !== 'number' && option.label ? option.label : `${option}`);
329
342
  })
330
343
  })]
331
344
  }), /*#__PURE__*/_jsx(JoyTypography, {
@@ -8,8 +8,8 @@ const esESGrid = {
8
8
  toolbarDensity: 'Densidad',
9
9
  toolbarDensityLabel: 'Densidad',
10
10
  toolbarDensityCompact: 'Compacta',
11
- toolbarDensityStandard: 'Standard',
12
- toolbarDensityComfortable: 'Comoda',
11
+ toolbarDensityStandard: 'Estándar',
12
+ toolbarDensityComfortable: 'Cómoda',
13
13
  // Columns selector toolbar button text
14
14
  toolbarColumns: 'Columnas',
15
15
  toolbarColumnsLabel: 'Seleccionar columnas',
@@ -37,7 +37,7 @@ const esESGrid = {
37
37
  columnsPanelHideAllButton: 'Ocultar todo',
38
38
  // Filter panel text
39
39
  filterPanelAddFilter: 'Agregar filtro',
40
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'Remover todos',
41
41
  filterPanelDeleteIconLabel: 'Borrar',
42
42
  filterPanelLogicOperator: 'Operador lógico',
43
43
  filterPanelOperator: 'Operadores',
@@ -522,7 +522,10 @@ DataGridRaw.propTypes = {
522
522
  * Select the pageSize dynamically using the component UI.
523
523
  * @default [25, 50, 100]
524
524
  */
525
- pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.number),
525
+ pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
526
+ label: _propTypes.default.string.isRequired,
527
+ value: _propTypes.default.number.isRequired
528
+ })]).isRequired),
526
529
  pagination: props => {
527
530
  if (props.pagination === false) {
528
531
  return new Error(['MUI: `<DataGrid pagination={false} />` is not a valid prop.', 'Infinite scrolling is not available in the MIT version.', '', 'You need to upgrade to DataGridPro or DataGridPremium component to disable the pagination.'].join('\n'));
@@ -47,21 +47,35 @@ const GridPagination = /*#__PURE__*/React.forwardRef(function GridPagination(pro
47
47
  const handlePageChange = React.useCallback((_, page) => {
48
48
  apiRef.current.setPage(page);
49
49
  }, [apiRef]);
50
+ const isPageSizeIncludedInPageSizeOptions = pageSize => {
51
+ for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
52
+ const option = rootProps.pageSizeOptions[i];
53
+ if (typeof option === 'number') {
54
+ if (option === pageSize) {
55
+ return true;
56
+ }
57
+ } else if (option.value === pageSize) {
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ };
50
63
  if (process.env.NODE_ENV !== 'production') {
51
64
  // eslint-disable-next-line react-hooks/rules-of-hooks
52
65
  const warnedOnceMissingInPageSizeOptions = React.useRef(false);
53
66
  const pageSize = rootProps.paginationModel?.pageSize ?? paginationModel.pageSize;
54
- if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !rootProps.pageSizeOptions.includes(pageSize)) {
67
+ if (!warnedOnceMissingInPageSizeOptions.current && !rootProps.autoPageSize && !isPageSizeIncludedInPageSizeOptions(pageSize)) {
55
68
  console.warn([`MUI: The page size \`${paginationModel.pageSize}\` is not preset in the \`pageSizeOptions\``, `Add it to show the pagination select.`].join('\n'));
56
69
  warnedOnceMissingInPageSizeOptions.current = true;
57
70
  }
58
71
  }
72
+ const pageSizeOptions = isPageSizeIncludedInPageSizeOptions(paginationModel.pageSize) ? rootProps.pageSizeOptions : [];
59
73
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridPaginationRoot, (0, _extends2.default)({
60
74
  ref: ref,
61
75
  component: "div",
62
76
  count: rowCount,
63
77
  page: paginationModel.page <= lastPage ? paginationModel.page : lastPage,
64
- rowsPerPageOptions: rootProps.pageSizeOptions?.includes(paginationModel.pageSize) ? rootProps.pageSizeOptions : [],
78
+ rowsPerPageOptions: pageSizeOptions,
65
79
  rowsPerPage: paginationModel.pageSize,
66
80
  onPageChange: handlePageChange,
67
81
  onRowsPerPageChange: handlePageSizeChange
@@ -121,7 +121,7 @@ function GridEditDateCell(props) {
121
121
  const meta = apiRef.current.unstable_getEditCellMeta(id, field);
122
122
  const handleInputRef = el => {
123
123
  inputRef.current = el;
124
- if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
124
+ if (meta?.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
125
125
  const inputValue = inputRef.current.value;
126
126
  const parsedDate = parseValueToDate(inputValue);
127
127
  setValueState({
@@ -77,12 +77,12 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
77
77
  unstable_skipValueParser: true
78
78
  }, event);
79
79
  }, [apiRef, debounceMs, field, id, onValueChange]);
80
- const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
80
+ const meta = apiRef.current.unstable_getEditCellMeta(id, field);
81
81
  React.useEffect(() => {
82
- if (meta.changeReason !== 'debouncedSetEditCellValue') {
82
+ if (meta?.changeReason !== 'debouncedSetEditCellValue') {
83
83
  setValueState(value);
84
84
  }
85
- }, [meta.changeReason, value]);
85
+ }, [meta, value]);
86
86
  (0, _utils.unstable_useEnhancedEffect)(() => {
87
87
  if (hasFocus) {
88
88
  inputRef.current.focus();
@@ -29,6 +29,7 @@ function computeFlexColumnsWidth({
29
29
  totalFlexUnits,
30
30
  flexColumns
31
31
  }) {
32
+ const uniqueFlexColumns = new Set(flexColumns.map(col => col.field));
32
33
  const flexColumnsLookup = {
33
34
  all: {},
34
35
  frozenFields: [],
@@ -44,7 +45,7 @@ function computeFlexColumnsWidth({
44
45
  // Step 5 of https://drafts.csswg.org/css-flexbox-1/#resolve-flexible-lengths
45
46
  function loopOverFlexItems() {
46
47
  // 5a: If all the flex items on the line are frozen, free space has been distributed.
47
- if (flexColumnsLookup.frozenFields.length === flexColumns.length) {
48
+ if (flexColumnsLookup.frozenFields.length === uniqueFlexColumns.size) {
48
49
  return;
49
50
  }
50
51
  const violationsLookup = {
@@ -80,7 +80,7 @@ function useGridDimensions(apiRef, props) {
80
80
  let hasScrollY;
81
81
  if (props.autoHeight) {
82
82
  hasScrollY = false;
83
- hasScrollX = columnsTotalWidth > rootDimensionsRef.current.width;
83
+ hasScrollX = Math.round(columnsTotalWidth) > Math.round(rootDimensionsRef.current.width);
84
84
  viewportOuterSize = {
85
85
  width: rootDimensionsRef.current.width,
86
86
  height: rowsMeta.currentPageTotalHeight + (hasScrollX ? scrollBarSize : 0)
@@ -92,11 +92,11 @@ function useGridDimensions(apiRef, props) {
92
92
  };
93
93
  const scrollInformation = hasScroll({
94
94
  content: {
95
- width: columnsTotalWidth,
95
+ width: Math.round(columnsTotalWidth),
96
96
  height: rowsMeta.currentPageTotalHeight
97
97
  },
98
98
  container: {
99
- width: viewportOuterSize.width,
99
+ width: Math.round(viewportOuterSize.width),
100
100
  height: viewportOuterSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom
101
101
  },
102
102
  scrollBarSize
@@ -117,7 +117,7 @@ const useGridEditing = (apiRef, props) => {
117
117
  }, [apiRef, props.editMode]);
118
118
  const getEditCellMeta = React.useCallback((id, field) => {
119
119
  const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
120
- return editingState[id][field];
120
+ return editingState[id]?.[field] ?? null;
121
121
  }, [apiRef]);
122
122
  const editingSharedApi = {
123
123
  isCellEditable,
@@ -262,6 +262,9 @@ const useGridFilter = (apiRef, props) => {
262
262
  }, [props.slots.filterPanel, props.slotProps?.filterPanel]);
263
263
  const dataRowIdToIdLookup = apiRef.current.state.rows.dataRowIdToModelLookup;
264
264
  const rows = React.useMemo(() => Object.values(dataRowIdToIdLookup), [dataRowIdToIdLookup]);
265
+ const {
266
+ getRowId
267
+ } = props;
265
268
  const flatFilteringMethod = React.useCallback(params => {
266
269
  if (props.filterMode !== 'client' || !params.isRowMatchingFilters) {
267
270
  return {
@@ -281,9 +284,10 @@ const useGridFilter = (apiRef, props) => {
281
284
  };
282
285
  for (let i = 0; i < rows.length; i += 1) {
283
286
  const row = rows[i];
287
+ const id = getRowId ? getRowId(row) : row.id;
284
288
  isRowMatchingFilters(row, undefined, result);
285
289
  const isRowPassing = (0, _gridFilterUtils.passFilterLogic)([result.passingFilterItems], [result.passingQuickFilterValues], params.filterModel, apiRef, filterCache);
286
- filteredRowsLookup[row.id] = isRowPassing;
290
+ filteredRowsLookup[id] = isRowPassing;
287
291
  }
288
292
  const footerId = 'auto-generated-group-footer-root';
289
293
  const footer = dataRowIdToModelLookup[footerId];
@@ -294,7 +298,7 @@ const useGridFilter = (apiRef, props) => {
294
298
  filteredRowsLookup,
295
299
  filteredDescendantCountLookup: {}
296
300
  };
297
- }, [apiRef, props.filterMode, rows]);
301
+ }, [apiRef, rows, props.filterMode, getRowId]);
298
302
  (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'columnMenu', addColumnMenuItem);
299
303
  (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'exportState', stateExportPreProcessing);
300
304
  (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'restoreState', stateRestorePreProcessing);
@@ -111,7 +111,7 @@ function useGridParamsApi(apiRef, props) {
111
111
  return colDef.valueGetter(getBaseCellParams(id, field));
112
112
  }, [apiRef, getBaseCellParams]);
113
113
  const getRowValue = React.useCallback((row, colDef) => {
114
- const id = (getRowId ? getRowId(row) : row.id) ?? row[_gridRowsUtils.GRID_ID_AUTOGENERATED];
114
+ const id = _gridRowsUtils.GRID_ID_AUTOGENERATED in row ? row[_gridRowsUtils.GRID_ID_AUTOGENERATED] : getRowId?.(row) ?? row.id;
115
115
  const field = colDef.field;
116
116
  if (!colDef || !colDef.valueGetter) {
117
117
  return row[field];
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.9.1
2
+ * @mui/x-data-grid v6.9.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -307,7 +307,20 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
307
307
  }, [apiRef]);
308
308
  const page = paginationModel.page <= lastPage ? paginationModel.page : lastPage;
309
309
  const pageSize = paginationModel.pageSize;
310
- const pageSizeOptions = rootProps.pageSizeOptions?.includes(pageSize) ? rootProps.pageSizeOptions : [];
310
+ const isPageSizeIncludedInPageSizeOptions = () => {
311
+ for (let i = 0; i < rootProps.pageSizeOptions.length; i += 1) {
312
+ const option = rootProps.pageSizeOptions[i];
313
+ if (typeof option === 'number') {
314
+ if (option === pageSize) {
315
+ return true;
316
+ }
317
+ } else if (option.value === pageSize) {
318
+ return true;
319
+ }
320
+ }
321
+ return false;
322
+ };
323
+ const pageSizeOptions = isPageSizeIncludedInPageSizeOptions() ? rootProps.pageSizeOptions : [];
311
324
  const handleChangeRowsPerPage = (event, newValue) => {
312
325
  const newPageSize = Number(newValue);
313
326
  apiRef.current.setPageSize(newPageSize);
@@ -331,9 +344,9 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
331
344
  value: pageSize,
332
345
  children: pageSizeOptions.map(option => {
333
346
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Option, {
334
- value: option,
335
- children: option
336
- }, option);
347
+ value: typeof option !== 'number' && option.value ? option.value : option,
348
+ children: typeof option !== 'number' && option.label ? option.label : `${option}`
349
+ }, typeof option !== 'number' && option.label ? option.label : `${option}`);
337
350
  })
338
351
  })]
339
352
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
@@ -14,8 +14,8 @@ const esESGrid = {
14
14
  toolbarDensity: 'Densidad',
15
15
  toolbarDensityLabel: 'Densidad',
16
16
  toolbarDensityCompact: 'Compacta',
17
- toolbarDensityStandard: 'Standard',
18
- toolbarDensityComfortable: 'Comoda',
17
+ toolbarDensityStandard: 'Estándar',
18
+ toolbarDensityComfortable: 'Cómoda',
19
19
  // Columns selector toolbar button text
20
20
  toolbarColumns: 'Columnas',
21
21
  toolbarColumnsLabel: 'Seleccionar columnas',
@@ -43,7 +43,7 @@ const esESGrid = {
43
43
  columnsPanelHideAllButton: 'Ocultar todo',
44
44
  // Filter panel text
45
45
  filterPanelAddFilter: 'Agregar filtro',
46
- // filterPanelRemoveAll: 'Remove all',
46
+ filterPanelRemoveAll: 'Remover todos',
47
47
  filterPanelDeleteIconLabel: 'Borrar',
48
48
  filterPanelLogicOperator: 'Operador lógico',
49
49
  filterPanelOperator: 'Operadores',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "6.9.1",
3
+ "version": "6.9.2",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",