@mui/x-data-grid 6.9.1 → 6.10.0

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 (100) hide show
  1. package/CHANGELOG.md +287 -107
  2. package/DataGrid/DataGrid.js +5 -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/components/toolbar/GridToolbarQuickFilter.d.ts +1 -1
  8. package/components/toolbar/GridToolbarQuickFilter.js +12 -9
  9. package/hooks/core/pipeProcessing/useGridPipeProcessing.js +4 -1
  10. package/hooks/core/useGridApiInitialization.d.ts +1 -0
  11. package/hooks/core/useGridApiInitialization.js +59 -36
  12. package/hooks/features/columns/gridColumnsUtils.js +2 -1
  13. package/hooks/features/dimensions/useGridDimensions.js +3 -3
  14. package/hooks/features/editing/useGridEditing.js +2 -1
  15. package/hooks/features/export/serializers/csvSerializer.d.ts +9 -6
  16. package/hooks/features/export/serializers/csvSerializer.js +78 -15
  17. package/hooks/features/export/useGridCsvExport.js +4 -3
  18. package/hooks/features/filter/gridFilterUtils.js +6 -5
  19. package/hooks/features/filter/useGridFilter.js +14 -2
  20. package/hooks/features/rows/gridRowsUtils.js +1 -1
  21. package/hooks/features/rows/useGridParamsApi.js +4 -4
  22. package/hooks/utils/useGridApiMethod.js +7 -23
  23. package/index.js +1 -1
  24. package/internals/index.d.ts +1 -0
  25. package/internals/index.js +1 -0
  26. package/joy/joySlots.js +17 -5
  27. package/legacy/DataGrid/DataGrid.js +5 -1
  28. package/legacy/components/GridPagination.js +16 -3
  29. package/legacy/components/cell/GridEditDateCell.js +1 -1
  30. package/legacy/components/cell/GridEditInputCell.js +3 -3
  31. package/legacy/components/toolbar/GridToolbarQuickFilter.js +12 -12
  32. package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +4 -1
  33. package/legacy/hooks/core/useGridApiInitialization.js +62 -39
  34. package/legacy/hooks/features/columns/gridColumnsUtils.js +4 -1
  35. package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -3
  36. package/legacy/hooks/features/editing/useGridEditing.js +2 -1
  37. package/legacy/hooks/features/export/serializers/csvSerializer.js +84 -11
  38. package/legacy/hooks/features/export/useGridCsvExport.js +4 -3
  39. package/legacy/hooks/features/filter/gridFilterUtils.js +6 -5
  40. package/legacy/hooks/features/filter/useGridFilter.js +12 -2
  41. package/legacy/hooks/features/rows/gridRowsUtils.js +1 -1
  42. package/legacy/hooks/features/rows/useGridParamsApi.js +4 -4
  43. package/legacy/hooks/utils/useGridApiMethod.js +7 -25
  44. package/legacy/index.js +1 -1
  45. package/legacy/internals/index.js +1 -0
  46. package/legacy/joy/joySlots.js +17 -5
  47. package/legacy/locales/esES.js +3 -3
  48. package/legacy/locales/plPL.js +7 -7
  49. package/locales/esES.js +3 -3
  50. package/locales/plPL.js +7 -7
  51. package/models/api/gridEditingApi.d.ts +1 -1
  52. package/models/events/gridEventLookup.d.ts +0 -1
  53. package/models/gridExport.d.ts +8 -1
  54. package/models/gridFilterModel.d.ts +5 -0
  55. package/models/props/DataGridProps.d.ts +4 -1
  56. package/modern/DataGrid/DataGrid.js +5 -1
  57. package/modern/components/GridPagination.js +16 -2
  58. package/modern/components/cell/GridEditDateCell.js +1 -1
  59. package/modern/components/cell/GridEditInputCell.js +3 -3
  60. package/modern/components/toolbar/GridToolbarQuickFilter.js +12 -9
  61. package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +4 -1
  62. package/modern/hooks/core/useGridApiInitialization.js +58 -36
  63. package/modern/hooks/features/columns/gridColumnsUtils.js +2 -1
  64. package/modern/hooks/features/dimensions/useGridDimensions.js +3 -3
  65. package/modern/hooks/features/editing/useGridEditing.js +1 -1
  66. package/modern/hooks/features/export/serializers/csvSerializer.js +78 -15
  67. package/modern/hooks/features/export/useGridCsvExport.js +3 -2
  68. package/modern/hooks/features/filter/gridFilterUtils.js +3 -2
  69. package/modern/hooks/features/filter/useGridFilter.js +14 -2
  70. package/modern/hooks/features/rows/gridRowsUtils.js +1 -1
  71. package/modern/hooks/features/rows/useGridParamsApi.js +1 -1
  72. package/modern/hooks/utils/useGridApiMethod.js +7 -23
  73. package/modern/index.js +1 -1
  74. package/modern/internals/index.js +1 -0
  75. package/modern/joy/joySlots.js +17 -4
  76. package/modern/locales/esES.js +3 -3
  77. package/modern/locales/plPL.js +7 -7
  78. package/node/DataGrid/DataGrid.js +5 -1
  79. package/node/components/GridPagination.js +16 -2
  80. package/node/components/cell/GridEditDateCell.js +1 -1
  81. package/node/components/cell/GridEditInputCell.js +3 -3
  82. package/node/components/toolbar/GridToolbarQuickFilter.js +12 -9
  83. package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +4 -1
  84. package/node/hooks/core/useGridApiInitialization.js +59 -36
  85. package/node/hooks/features/columns/gridColumnsUtils.js +2 -1
  86. package/node/hooks/features/dimensions/useGridDimensions.js +3 -3
  87. package/node/hooks/features/editing/useGridEditing.js +1 -1
  88. package/node/hooks/features/export/serializers/csvSerializer.js +78 -15
  89. package/node/hooks/features/export/useGridCsvExport.js +3 -2
  90. package/node/hooks/features/filter/gridFilterUtils.js +2 -1
  91. package/node/hooks/features/filter/useGridFilter.js +14 -2
  92. package/node/hooks/features/rows/gridRowsUtils.js +1 -1
  93. package/node/hooks/features/rows/useGridParamsApi.js +1 -1
  94. package/node/hooks/utils/useGridApiMethod.js +7 -23
  95. package/node/index.js +1 -1
  96. package/node/internals/index.js +8 -0
  97. package/node/joy/joySlots.js +17 -4
  98. package/node/locales/esES.js +3 -3
  99. package/node/locales/plPL.js +7 -7
  100. package/package.json +1 -1
@@ -64,18 +64,20 @@ function GridToolbarQuickFilter(props) {
64
64
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
65
65
  const quickFilterValues = (0, _useGridSelector.useGridSelector)(apiRef, _filter.gridQuickFilterValuesSelector);
66
66
  const [searchValue, setSearchValue] = React.useState(() => quickFilterFormatter(quickFilterValues ?? []));
67
- const [prevQuickFilterValues, setPrevQuickFilterValues] = React.useState(quickFilterValues);
67
+ const prevQuickFilterValuesRef = React.useRef(quickFilterValues);
68
68
  React.useEffect(() => {
69
- if (!(0, _utils2.isDeepEqual)(prevQuickFilterValues, quickFilterValues)) {
69
+ if (!(0, _utils2.isDeepEqual)(prevQuickFilterValuesRef.current, quickFilterValues)) {
70
70
  // The model of quick filter value has been updated
71
- setPrevQuickFilterValues(quickFilterValues);
71
+ prevQuickFilterValuesRef.current = quickFilterValues;
72
72
 
73
73
  // Update the input value if needed to match the new model
74
74
  setSearchValue(prevSearchValue => (0, _utils2.isDeepEqual)(quickFilterParser(prevSearchValue), quickFilterValues) ? prevSearchValue : quickFilterFormatter(quickFilterValues ?? []));
75
75
  }
76
- }, [prevQuickFilterValues, quickFilterValues, quickFilterFormatter, quickFilterParser]);
76
+ }, [quickFilterValues, quickFilterFormatter, quickFilterParser]);
77
77
  const updateSearchValue = React.useCallback(newSearchValue => {
78
- apiRef.current.setQuickFilterValues(quickFilterParser(newSearchValue));
78
+ const newQuickFilterValues = quickFilterParser(newSearchValue);
79
+ prevQuickFilterValuesRef.current = newQuickFilterValues;
80
+ apiRef.current.setQuickFilterValues(newQuickFilterValues);
79
81
  }, [apiRef, quickFilterParser]);
80
82
  const debouncedUpdateSearchValue = React.useMemo(() => (0, _utils.unstable_debounce)(updateSearchValue, debounceMs), [updateSearchValue, debounceMs]);
81
83
  const handleSearchValueChange = React.useCallback(event => {
@@ -95,8 +97,9 @@ function GridToolbarQuickFilter(props) {
95
97
  onChange: handleSearchValueChange,
96
98
  placeholder: apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder'),
97
99
  "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterLabel'),
98
- type: "search",
99
- InputProps: {
100
+ type: "search"
101
+ }, other, {
102
+ InputProps: (0, _extends2.default)({
100
103
  startAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.quickFilterIcon, {
101
104
  fontSize: "small"
102
105
  }),
@@ -112,8 +115,8 @@ function GridToolbarQuickFilter(props) {
112
115
  fontSize: "small"
113
116
  })
114
117
  }))
115
- }
116
- }, other, rootProps.slotProps?.baseTextField));
118
+ }, other.InputProps)
119
+ }, rootProps.slotProps?.baseTextField));
117
120
  }
118
121
  process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
119
122
  // ----------------------------- Warning --------------------------------
@@ -42,13 +42,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
42
42
  */
43
43
  const useGridPipeProcessing = apiRef => {
44
44
  const processorsCache = React.useRef({});
45
+ const isRunning = React.useRef(false);
45
46
  const runAppliers = React.useCallback(groupCache => {
46
- if (!groupCache) {
47
+ if (isRunning.current || !groupCache) {
47
48
  return;
48
49
  }
50
+ isRunning.current = true;
49
51
  Object.values(groupCache.appliers).forEach(callback => {
50
52
  callback();
51
53
  });
54
+ isRunning.current = false;
52
55
  }, []);
53
56
  const registerPipeProcessor = React.useCallback((group, id, processor) => {
54
57
  if (!processorsCache.current[group]) {
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.unwrapPrivateAPI = unwrapPrivateAPI;
6
7
  exports.useGridApiInitialization = useGridApiInitialization;
7
8
  var React = _interopRequireWildcard(require("react"));
8
9
  var _Store = require("../../utils/Store");
@@ -11,58 +12,79 @@ var _useGridApiEventHandler = require("../utils/useGridApiEventHandler");
11
12
  var _EventManager = require("../../utils/EventManager");
12
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+ const SYMBOL_API_PRIVATE = Symbol('mui.api_private');
14
16
  const isSyntheticEvent = event => {
15
17
  return event.isPropagationStopped !== undefined;
16
18
  };
19
+ function unwrapPrivateAPI(publicApi) {
20
+ return publicApi[SYMBOL_API_PRIVATE];
21
+ }
17
22
  let globalId = 0;
18
- const wrapPublicApi = publicApi => {
19
- const privateOnlyApi = {};
20
- privateOnlyApi.getPublicApi = () => publicApi;
21
- privateOnlyApi.register = (visibility, methods) => {
23
+ function createPrivateAPI(publicApiRef) {
24
+ const existingPrivateApi = publicApiRef.current?.[SYMBOL_API_PRIVATE];
25
+ if (existingPrivateApi) {
26
+ return existingPrivateApi;
27
+ }
28
+ const state = {};
29
+ const privateApi = {
30
+ state,
31
+ store: _Store.Store.create(state),
32
+ instanceId: {
33
+ id: globalId
34
+ }
35
+ };
36
+ globalId += 1;
37
+ privateApi.getPublicApi = () => publicApiRef.current;
38
+ privateApi.register = (visibility, methods) => {
22
39
  Object.keys(methods).forEach(methodName => {
23
- if (visibility === 'public') {
24
- publicApi[methodName] = methods[methodName];
40
+ const method = methods[methodName];
41
+ const currentPrivateMethod = privateApi[methodName];
42
+ if (currentPrivateMethod?.spying === true) {
43
+ currentPrivateMethod.target = method;
25
44
  } else {
26
- privateOnlyApi[methodName] = methods[methodName];
45
+ privateApi[methodName] = method;
46
+ }
47
+ if (visibility === 'public') {
48
+ const publicApi = publicApiRef.current;
49
+ const currentPublicMethod = publicApi[methodName];
50
+ if (currentPublicMethod?.spying === true) {
51
+ currentPublicMethod.target = method;
52
+ } else {
53
+ publicApi[methodName] = method;
54
+ }
27
55
  }
28
56
  });
29
57
  };
30
- const handler = {
31
- get: (obj, prop) => {
32
- if (prop in obj) {
33
- return obj[prop];
34
- }
35
- return privateOnlyApi[prop];
58
+ privateApi.register('private', {
59
+ caches: {},
60
+ eventManager: new _EventManager.EventManager()
61
+ });
62
+ return privateApi;
63
+ }
64
+ function createPublicAPI(privateApiRef) {
65
+ const publicApi = {
66
+ get state() {
67
+ return privateApiRef.current.state;
36
68
  },
37
- set: (obj, prop, value) => {
38
- obj[prop] = value;
39
- return true;
40
- }
69
+ get store() {
70
+ return privateApiRef.current.store;
71
+ },
72
+ get instanceId() {
73
+ return privateApiRef.current.instanceId;
74
+ },
75
+ [SYMBOL_API_PRIVATE]: privateApiRef.current
41
76
  };
42
- return new Proxy(publicApi, handler);
43
- };
77
+ return publicApi;
78
+ }
44
79
  function useGridApiInitialization(inputApiRef, props) {
45
80
  const publicApiRef = React.useRef();
46
- if (!publicApiRef.current) {
47
- const state = {};
48
- publicApiRef.current = {
49
- state,
50
- store: _Store.Store.create(state),
51
- instanceId: {
52
- id: globalId
53
- }
54
- };
55
- globalId += 1;
56
- }
57
81
  const privateApiRef = React.useRef();
58
82
  if (!privateApiRef.current) {
59
- privateApiRef.current = wrapPublicApi(publicApiRef.current);
60
- privateApiRef.current.register('private', {
61
- caches: {},
62
- eventManager: new _EventManager.EventManager()
63
- });
83
+ privateApiRef.current = createPrivateAPI(publicApiRef);
84
+ }
85
+ if (!publicApiRef.current) {
86
+ publicApiRef.current = createPublicAPI(privateApiRef);
64
87
  }
65
- React.useImperativeHandle(inputApiRef, () => publicApiRef.current, [publicApiRef]);
66
88
  const publishEvent = React.useCallback((...args) => {
67
89
  const [name, params, event = {}] = args;
68
90
  event.defaultMuiPrevented = false;
@@ -85,6 +107,7 @@ function useGridApiInitialization(inputApiRef, props) {
85
107
  subscribeEvent,
86
108
  publishEvent
87
109
  }, 'public');
110
+ React.useImperativeHandle(inputApiRef, () => publicApiRef.current, [publicApiRef]);
88
111
  React.useEffect(() => {
89
112
  const api = privateApiRef.current;
90
113
  return () => {
@@ -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,
@@ -43,43 +43,106 @@ const serializeCellValue = (cellParams, options) => {
43
43
  };
44
44
  exports.serializeCellValue = serializeCellValue;
45
45
  const objectFormattedValueWarning = (0, _warning.buildWarning)(['MUI: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
46
+ class CSVRow {
47
+ constructor(options) {
48
+ this.options = void 0;
49
+ this.rowString = '';
50
+ this.isEmpty = true;
51
+ this.options = options;
52
+ }
53
+ addValue(value) {
54
+ if (!this.isEmpty) {
55
+ this.rowString += this.options.delimiterCharacter;
56
+ }
57
+ if (value === null || value === undefined) {
58
+ this.rowString += '';
59
+ } else if (typeof this.options.sanitizeCellValue === 'function') {
60
+ this.rowString += this.options.sanitizeCellValue(value, this.options.delimiterCharacter);
61
+ } else {
62
+ this.rowString += value;
63
+ }
64
+ this.isEmpty = false;
65
+ }
66
+ getRowString() {
67
+ return this.rowString;
68
+ }
69
+ }
46
70
  const serializeRow = ({
47
71
  id,
48
72
  columns,
49
73
  getCellParams,
50
74
  delimiterCharacter,
51
75
  ignoreValueFormatter
52
- }) => columns.map(column => {
53
- const cellParams = getCellParams(id, column.field);
54
- if (process.env.NODE_ENV !== 'production') {
55
- if (String(cellParams.formattedValue) === '[object Object]') {
56
- objectFormattedValueWarning();
76
+ }) => {
77
+ const row = new CSVRow({
78
+ delimiterCharacter
79
+ });
80
+ columns.forEach(column => {
81
+ const cellParams = getCellParams(id, column.field);
82
+ if (process.env.NODE_ENV !== 'production') {
83
+ if (String(cellParams.formattedValue) === '[object Object]') {
84
+ objectFormattedValueWarning();
85
+ }
57
86
  }
58
- }
59
- return serializeCellValue(cellParams, {
60
- delimiterCharacter,
61
- ignoreValueFormatter
87
+ row.addValue(serializeCellValue(cellParams, {
88
+ delimiterCharacter,
89
+ ignoreValueFormatter
90
+ }));
62
91
  });
63
- });
92
+ return row.getRowString();
93
+ };
64
94
  function buildCSV(options) {
65
95
  const {
66
96
  columns,
67
97
  rowIds,
68
- getCellParams,
69
98
  delimiterCharacter,
70
99
  includeHeaders,
71
- ignoreValueFormatter
100
+ includeColumnGroupsHeaders,
101
+ ignoreValueFormatter,
102
+ apiRef
72
103
  } = options;
73
104
  const CSVBody = rowIds.reduce((acc, id) => `${acc}${serializeRow({
74
105
  id,
75
106
  columns,
76
- getCellParams,
107
+ getCellParams: apiRef.current.getCellParams,
77
108
  delimiterCharacter,
78
109
  ignoreValueFormatter
79
- }).join(delimiterCharacter)}\r\n`, '').trim();
110
+ })}\r\n`, '').trim();
80
111
  if (!includeHeaders) {
81
112
  return CSVBody;
82
113
  }
83
- const CSVHead = `${columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field).map(column => sanitizeCellValue(column.headerName || column.field, delimiterCharacter)).join(delimiterCharacter)}\r\n`;
114
+ const filteredColumns = columns.filter(column => column.field !== _colDef.GRID_CHECKBOX_SELECTION_COL_DEF.field);
115
+ const headerRows = [];
116
+ if (includeColumnGroupsHeaders) {
117
+ const columnGroupLookup = apiRef.current.unstable_getAllGroupDetails();
118
+ let maxColumnGroupsDepth = 0;
119
+ const columnGroupPathsLookup = filteredColumns.reduce((acc, column) => {
120
+ const columnGroupPath = apiRef.current.unstable_getColumnGroupPath(column.field);
121
+ acc[column.field] = columnGroupPath;
122
+ maxColumnGroupsDepth = Math.max(maxColumnGroupsDepth, columnGroupPath.length);
123
+ return acc;
124
+ }, {});
125
+ for (let i = 0; i < maxColumnGroupsDepth; i += 1) {
126
+ const headerGroupRow = new CSVRow({
127
+ delimiterCharacter,
128
+ sanitizeCellValue
129
+ });
130
+ headerRows.push(headerGroupRow);
131
+ filteredColumns.forEach(column => {
132
+ const columnGroupId = (columnGroupPathsLookup[column.field] || [])[i];
133
+ const columnGroup = columnGroupLookup[columnGroupId];
134
+ headerGroupRow.addValue(columnGroup ? columnGroup.headerName || columnGroup.groupId : '');
135
+ });
136
+ }
137
+ }
138
+ const mainHeaderRow = new CSVRow({
139
+ delimiterCharacter,
140
+ sanitizeCellValue
141
+ });
142
+ filteredColumns.forEach(column => {
143
+ mainHeaderRow.addValue(column.headerName || column.field);
144
+ });
145
+ headerRows.push(mainHeaderRow);
146
+ const CSVHead = `${headerRows.map(row => row.getRowString()).join('\r\n')}\r\n`;
84
147
  return `${CSVHead}${CSVBody}`.trim();
85
148
  }
@@ -39,10 +39,11 @@ const useGridCsvExport = (apiRef, props) => {
39
39
  return (0, _csvSerializer.buildCSV)({
40
40
  columns: exportedColumns,
41
41
  rowIds: exportedRowIds,
42
- getCellParams: apiRef.current.getCellParams,
43
42
  delimiterCharacter: options.delimiter || ',',
44
43
  includeHeaders: options.includeHeaders ?? true,
45
- ignoreValueFormatter
44
+ includeColumnGroupsHeaders: options.includeColumnGroupsHeaders ?? true,
45
+ ignoreValueFormatter,
46
+ apiRef
46
47
  });
47
48
  }, [logger, apiRef, ignoreValueFormatter]);
48
49
  const exportDataAsCsv = React.useCallback(options => {
@@ -168,7 +168,8 @@ const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef) => {
168
168
  if (quickFilterValues.length === 0) {
169
169
  return null;
170
170
  }
171
- const columnFields = (0, _columns.gridColumnFieldsSelector)(apiRef);
171
+ const quickFilterExcludeHiddenColumns = filterModel.quickFilterExcludeHiddenColumns ?? false;
172
+ const columnFields = quickFilterExcludeHiddenColumns ? (0, _columns.gridVisibleColumnFieldsSelector)(apiRef) : (0, _columns.gridColumnFieldsSelector)(apiRef);
172
173
  const appliersPerField = [];
173
174
  columnFields.forEach(field => {
174
175
  const column = apiRef.current.getColumn(field);
@@ -29,6 +29,7 @@ const filterStateInitializer = (state, props, apiRef) => {
29
29
  return (0, _extends2.default)({}, state, {
30
30
  filter: {
31
31
  filterModel: (0, _gridFilterUtils.sanitizeFilterModel)(filterModel, props.disableMultipleColumnsFiltering, apiRef),
32
+ filteredRowsLookup: {},
32
33
  filteredDescendantCountLookup: {}
33
34
  },
34
35
  visibleRowsLookup: {}
@@ -262,6 +263,9 @@ const useGridFilter = (apiRef, props) => {
262
263
  }, [props.slots.filterPanel, props.slotProps?.filterPanel]);
263
264
  const dataRowIdToIdLookup = apiRef.current.state.rows.dataRowIdToModelLookup;
264
265
  const rows = React.useMemo(() => Object.values(dataRowIdToIdLookup), [dataRowIdToIdLookup]);
266
+ const {
267
+ getRowId
268
+ } = props;
265
269
  const flatFilteringMethod = React.useCallback(params => {
266
270
  if (props.filterMode !== 'client' || !params.isRowMatchingFilters) {
267
271
  return {
@@ -281,9 +285,10 @@ const useGridFilter = (apiRef, props) => {
281
285
  };
282
286
  for (let i = 0; i < rows.length; i += 1) {
283
287
  const row = rows[i];
288
+ const id = getRowId ? getRowId(row) : row.id;
284
289
  isRowMatchingFilters(row, undefined, result);
285
290
  const isRowPassing = (0, _gridFilterUtils.passFilterLogic)([result.passingFilterItems], [result.passingQuickFilterValues], params.filterModel, apiRef, filterCache);
286
- filteredRowsLookup[row.id] = isRowPassing;
291
+ filteredRowsLookup[id] = isRowPassing;
287
292
  }
288
293
  const footerId = 'auto-generated-group-footer-root';
289
294
  const footer = dataRowIdToModelLookup[footerId];
@@ -294,7 +299,7 @@ const useGridFilter = (apiRef, props) => {
294
299
  filteredRowsLookup,
295
300
  filteredDescendantCountLookup: {}
296
301
  };
297
- }, [apiRef, props.filterMode, rows]);
302
+ }, [apiRef, rows, props.filterMode, getRowId]);
298
303
  (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'columnMenu', addColumnMenuItem);
299
304
  (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'exportState', stateExportPreProcessing);
300
305
  (0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'restoreState', stateRestorePreProcessing);
@@ -336,6 +341,13 @@ const useGridFilter = (apiRef, props) => {
336
341
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnsChange', handleColumnsChange);
337
342
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'activeStrategyProcessorChange', handleStrategyProcessorChange);
338
343
  (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowExpansionChange', updateVisibleRowsLookupState);
344
+ (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnVisibilityModelChange', () => {
345
+ const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
346
+ if (filterModel.quickFilterValues && filterModel.quickFilterExcludeHiddenColumns) {
347
+ // re-apply filters because the quick filter results may have changed
348
+ apiRef.current.unstable_applyFilters();
349
+ }
350
+ });
339
351
 
340
352
  /**
341
353
  * 1ST RENDER
@@ -15,7 +15,7 @@ var _gridRowsSelector = require("./gridRowsSelector");
15
15
  var _densitySelector = require("../density/densitySelector");
16
16
  const GRID_ROOT_GROUP_ID = `auto-generated-group-node-root`;
17
17
  exports.GRID_ROOT_GROUP_ID = GRID_ROOT_GROUP_ID;
18
- const GRID_ID_AUTOGENERATED = Symbol('mui-autogenerated-id');
18
+ const GRID_ID_AUTOGENERATED = Symbol('mui.id_autogenerated');
19
19
  exports.GRID_ID_AUTOGENERATED = GRID_ID_AUTOGENERATED;
20
20
  const buildRootGroup = () => ({
21
21
  type: 'group',
@@ -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];
@@ -8,28 +8,12 @@ var React = _interopRequireWildcard(require("react"));
8
8
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
10
  function useGridApiMethod(privateApiRef, apiMethods, visibility) {
11
- const apiMethodsRef = React.useRef(apiMethods);
12
- const [apiMethodsNames] = React.useState(Object.keys(apiMethods));
13
- const installMethods = React.useCallback(() => {
14
- if (!privateApiRef.current) {
15
- return;
16
- }
17
- apiMethodsNames.forEach(methodName => {
18
- if (!privateApiRef.current.hasOwnProperty(methodName)) {
19
- privateApiRef.current.register(visibility, {
20
- [methodName]: (...args) => {
21
- const fn = apiMethodsRef.current[methodName];
22
- return fn(...args);
23
- }
24
- });
25
- }
26
- });
27
- }, [apiMethodsNames, privateApiRef, visibility]);
11
+ const isFirstRender = React.useRef(true);
28
12
  React.useEffect(() => {
29
- apiMethodsRef.current = apiMethods;
30
- }, [apiMethods]);
31
- React.useEffect(() => {
32
- installMethods();
33
- }, [installMethods]);
34
- installMethods();
13
+ isFirstRender.current = false;
14
+ privateApiRef.current.register(visibility, apiMethods);
15
+ }, [privateApiRef, visibility, apiMethods]);
16
+ if (isFirstRender.current) {
17
+ privateApiRef.current.register(visibility, apiMethods);
18
+ }
35
19
  }
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.10.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -15,6 +15,7 @@ var _exportNames = {
15
15
  useGridRegisterStrategyProcessor: true,
16
16
  GRID_DEFAULT_STRATEGY: true,
17
17
  useGridInitialization: true,
18
+ unwrapPrivateAPI: true,
18
19
  useGridClipboard: true,
19
20
  useGridColumnHeaders: true,
20
21
  unstable_gridHeaderFilteringEditFieldSelector: true,
@@ -403,6 +404,12 @@ Object.defineProperty(exports, "unstable_resetCreateSelectorCache", {
403
404
  return _createSelector.unstable_resetCreateSelectorCache;
404
405
  }
405
406
  });
407
+ Object.defineProperty(exports, "unwrapPrivateAPI", {
408
+ enumerable: true,
409
+ get: function () {
410
+ return _useGridApiInitialization.unwrapPrivateAPI;
411
+ }
412
+ });
406
413
  Object.defineProperty(exports, "useGridClipboard", {
407
414
  enumerable: true,
408
415
  get: function () {
@@ -617,6 +624,7 @@ var _GridFilterPanel = require("../components/panel/filterPanel/GridFilterPanel"
617
624
  var _pipeProcessing = require("../hooks/core/pipeProcessing");
618
625
  var _strategyProcessing = require("../hooks/core/strategyProcessing");
619
626
  var _useGridInitialization = require("../hooks/core/useGridInitialization");
627
+ var _useGridApiInitialization = require("../hooks/core/useGridApiInitialization");
620
628
  var _useGridClipboard = require("../hooks/features/clipboard/useGridClipboard");
621
629
  var _useGridColumnHeaders = require("../hooks/features/columnHeaders/useGridColumnHeaders");
622
630
  var _gridHeaderFilteringSelectors = require("../hooks/features/headerFiltering/gridHeaderFilteringSelectors");
@@ -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',
@@ -43,7 +43,7 @@ const plPLGrid = {
43
43
  columnsPanelHideAllButton: 'Ukryj wszystko',
44
44
  // Filter panel text
45
45
  filterPanelAddFilter: 'Dodaj filtr',
46
- // filterPanelRemoveAll: 'Remove all',
46
+ filterPanelRemoveAll: 'Usuń wszystkie',
47
47
  filterPanelDeleteIconLabel: 'Usuń',
48
48
  filterPanelLogicOperator: 'Operator logiczny',
49
49
  filterPanelOperator: 'Operator',
@@ -74,12 +74,12 @@ const plPLGrid = {
74
74
  // 'filterOperator<=': '<=',
75
75
 
76
76
  // Header filter operators text
77
- // headerFilterOperatorContains: 'Contains',
78
- // headerFilterOperatorEquals: 'Equals',
79
- // headerFilterOperatorStartsWith: 'Starts with',
80
- // headerFilterOperatorEndsWith: 'Ends with',
77
+ headerFilterOperatorContains: 'Zawiera',
78
+ headerFilterOperatorEquals: 'Równa się',
79
+ headerFilterOperatorStartsWith: 'Zaczyna się od',
80
+ headerFilterOperatorEndsWith: 'Kończy się na',
81
81
  // headerFilterOperatorIs: 'Is',
82
- // headerFilterOperatorNot: 'Is not',
82
+ headerFilterOperatorNot: 'Niepuste',
83
83
  // headerFilterOperatorAfter: 'Is after',
84
84
  // headerFilterOperatorOnOrAfter: 'Is on or after',
85
85
  // headerFilterOperatorBefore: 'Is before',
@@ -101,7 +101,7 @@ const plPLGrid = {
101
101
  // Column menu text
102
102
  columnMenuLabel: 'Menu',
103
103
  columnMenuShowColumns: 'Pokaż wszystkie kolumny',
104
- // columnMenuManageColumns: 'Manage columns',
104
+ columnMenuManageColumns: 'Zarządzaj kolumnami',
105
105
  columnMenuFilter: 'Filtr',
106
106
  columnMenuHideColumn: 'Ukryj',
107
107
  columnMenuUnsort: 'Anuluj sortowanie',
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.10.0",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",