@mui/x-data-grid 7.5.1 → 7.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +112 -1
  2. package/DataGrid/DataGrid.js +1 -1
  3. package/components/cell/GridCell.js +1 -1
  4. package/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
  5. package/hooks/features/columnResize/useGridColumnResize.js +7 -28
  6. package/hooks/features/columns/gridColumnsUtils.js +18 -13
  7. package/hooks/features/columns/useGridColumnSpanning.js +5 -5
  8. package/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
  9. package/index.d.ts +1 -0
  10. package/index.js +1 -2
  11. package/locales/faIR.js +4 -4
  12. package/locales/fiFI.js +4 -5
  13. package/models/api/gridColumnSpanning.d.ts +2 -0
  14. package/models/gridSlotsComponent.d.ts +1 -1
  15. package/models/props/DataGridProps.d.ts +1 -1
  16. package/modern/DataGrid/DataGrid.js +1 -1
  17. package/modern/components/cell/GridCell.js +1 -1
  18. package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
  19. package/modern/hooks/features/columnResize/useGridColumnResize.js +7 -28
  20. package/modern/hooks/features/columns/gridColumnsUtils.js +18 -13
  21. package/modern/hooks/features/columns/useGridColumnSpanning.js +5 -5
  22. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
  23. package/modern/index.js +1 -2
  24. package/modern/locales/faIR.js +4 -4
  25. package/modern/locales/fiFI.js +4 -5
  26. package/modern/utils/domUtils.js +6 -7
  27. package/node/DataGrid/DataGrid.js +1 -1
  28. package/node/components/cell/GridCell.js +1 -1
  29. package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +0 -7
  30. package/node/hooks/features/columnResize/useGridColumnResize.js +6 -27
  31. package/node/hooks/features/columns/gridColumnsUtils.js +18 -13
  32. package/node/hooks/features/columns/useGridColumnSpanning.js +5 -5
  33. package/node/hooks/features/virtualization/useGridVirtualScroller.js +8 -1
  34. package/node/index.js +1 -1
  35. package/node/locales/faIR.js +4 -4
  36. package/node/locales/fiFI.js +4 -5
  37. package/node/utils/domUtils.js +6 -6
  38. package/package.json +3 -3
  39. package/utils/domUtils.d.ts +1 -0
  40. package/utils/domUtils.js +6 -7
package/CHANGELOG.md CHANGED
@@ -3,6 +3,117 @@
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
+ ## 7.6.1
7
+
8
+ _May 31, 2024_
9
+
10
+ We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ 🐞 Address the `@mui/internal-test-utils` added as a direct dependency to `@mui/x-data-grid` by mistake.
13
+
14
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
15
+
16
+ ### Data Grid
17
+
18
+ #### `@mui/x-data-grid@7.6.1`
19
+
20
+ - [DataGrid] Fix column resize not working with special character (#13069) @oukunan
21
+ - [DataGrid] Move `@mui/internal-test-utils` to dev dependency (#13318) @LukasTy
22
+
23
+ #### `@mui/x-data-grid-pro@7.6.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
24
+
25
+ Same changes as in `@mui/x-data-grid@7.6.1`.
26
+
27
+ #### `@mui/x-data-grid-premium@7.6.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
28
+
29
+ Same changes as in `@mui/x-data-grid-pro@7.6.1`.
30
+
31
+ ## 7.6.0
32
+
33
+ _May 30, 2024_
34
+
35
+ We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
36
+
37
+ - 🎁 Allow to define and customize the indentation of nested items in the Tree View
38
+ - ✨ Allow charts highlights to be controlled
39
+ - 🌍 Improve Persian (fa-IR) locale on the Data Grid
40
+ - 🐞 Bugfixes
41
+ - 📚 Documentation improvements
42
+
43
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
44
+
45
+ ### Data Grid
46
+
47
+ #### `@mui/x-data-grid@7.6.0`
48
+
49
+ - [DataGrid] Avoid re-rendering all cells on column change (#12980) @romgrk
50
+ - [DataGrid] Export `GridColumnHeadersProps` (#13229) @cherniavskii
51
+ - [DataGrid] Fix header filters' issue with custom filters (#13255) @MBilalShafi
52
+ - [DataGrid] Remove dead logic to support Safari < 13 (#13249) @oliviertassinari
53
+ - [l10n] Improve Persian (fa-IR) locale (#12994) @amiryxe
54
+
55
+ #### `@mui/x-data-grid-pro@7.6.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
56
+
57
+ Same changes as in `@mui/x-data-grid@7.6.0`.
58
+
59
+ #### `@mui/x-data-grid-premium@7.6.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
60
+
61
+ Same changes as in `@mui/x-data-grid-pro@7.6.0`, plus:
62
+
63
+ - [DataGridPremium] Fix excel export causing column with wrong width (#13191) @romgrk
64
+
65
+ ### Date and Time Pickers
66
+
67
+ #### `@mui/x-date-pickers@7.6.0`
68
+
69
+ - [pickers] Fix `DateBuilderReturnType` when the date is `undefined` (#13244) @alexey-kozlenkov
70
+
71
+ #### `@mui/x-date-pickers-pro@7.6.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
72
+
73
+ Same changes as in `@mui/x-date-pickers@7.6.0`.
74
+
75
+ ### Charts
76
+
77
+ #### `@mui/x-charts@7.6.0`
78
+
79
+ - [charts] Allow charts highlights to be controlled (#12828) @JCQuintas
80
+ - [charts] Refactor axis band scaleType check (#13295) @JCQuintas
81
+ - [charts] Refactor checkScaleErrors to improve readability and simplify axis message logic (#13305) @JCQuintas
82
+
83
+ ### Tree View
84
+
85
+ #### `@mui/x-tree-view@7.6.0`
86
+
87
+ - [TreeView] Add JSDoc to every instance method (#13219) @flaviendelangle
88
+ - [TreeView] Allow to customize the indentation of nested items (#13225) @flaviendelangle
89
+ - [TreeView] Allow to define indentation at the item level (#13126) @flaviendelangle
90
+
91
+ ### Docs
92
+
93
+ - [docs] Add Bulk editing demo for the Community plan (#12800) @cherniavskii
94
+ - [docs] Add conditional label formatting on tooltip page and link to label page (#13235) @JCQuintas
95
+ - [docs] Add information about key combinations on a11y sections (#13234) @arthurbalduini
96
+ - [docs] Cleanup of the Tree View demos (#13237) @flaviendelangle
97
+ - [docs] Document how to customize a subsection of a line chart (#13210) @alexfauquette
98
+ - [docs] Fix Pickers FAQ callout (#13238) @LukasTy
99
+ - [docs] Fix Vale errors @oliviertassinari
100
+ - [docs] Fix a small typo in property comment (#13245) @Janpot
101
+ - [docs] Improve the Data Grid FAQ page (#13258) @MBilalShafi
102
+ - [docs] Removes unused lines in TreeItem2 styling (#13264) @arthurbalduini
103
+ - [docs] Small improvements on accessibility data grid doc (#13233) @arthurbalduini
104
+ - [docs] Update Pickers demo configurations (#13303) @LukasTy
105
+
106
+ ### Core
107
+
108
+ - [core] Add comment on why logic to sync column header (#13248) @oliviertassinari
109
+ - [core] Fix `l10n` script execution with arguments (#13297) @LukasTy
110
+ - [core] Prevent "Add reviewers" workflow from triggering since it doesn't work (#13236) @JCQuintas
111
+ - [docs-infra] Fix `@mui/material` version used in sandboxes (#13260) @LukasTy
112
+ - [test] Use `describeTreeView` for keyboard navigation tests on disabled items (#13184) @flaviendelangle
113
+ - [test] Use `describeTreeView` for remaining items tests (#13262) @flaviendelangle
114
+ - [test] Use test-utils from npm (#12880) @michaldudak
115
+ - [typescript] Remove duplicate `DateRangePosition` type in favor of `RangePosition` (#13288) @LukasTy
116
+
6
117
  ## v7.5.1
7
118
 
8
119
  _May 23, 2024_
@@ -339,7 +450,7 @@ Same changes as in `@mui/x-date-pickers@7.3.1`.
339
450
  ### Core
340
451
 
341
452
  - [core] Fix `l10n` GH workflow (#12895) @LukasTy
342
- - [core] Match Base UI and Toolpad @oliviertassinari
453
+ - [core] Match Base UI and Toolpad @oliviertassinari
343
454
  - [core] Remove redundant `setupFiles` entries in `package.json` (#12899) @LukasTy
344
455
  - [core] Use `describeTreeView` for focus tests (#12698) @flaviendelangle
345
456
  - [core] Use `describeTreeView` for type-ahead tests (#12811) @flaviendelangle
@@ -62,7 +62,7 @@ DataGridRaw.propTypes = {
62
62
  */
63
63
  'aria-labelledby': PropTypes.string,
64
64
  /**
65
- * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
65
+ * If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
66
66
  * @default false
67
67
  */
68
68
  autoHeight: PropTypes.bool,
@@ -75,7 +75,7 @@ let warnedOnce = false;
75
75
 
76
76
  // TODO(v7): Removing the wrapper will break the docs performance visualization demo.
77
77
 
78
- const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
78
+ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
79
79
  const {
80
80
  column,
81
81
  rowId,
@@ -12,7 +12,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridGenericColumnHeaderItem(props, ref) {
13
13
  const {
14
14
  classes,
15
- columnMenuOpen,
16
15
  colIndex,
17
16
  height,
18
17
  isResizing,
@@ -38,17 +37,11 @@ const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridG
38
37
  const apiRef = useGridPrivateApiContext();
39
38
  const rootProps = useGridRootProps();
40
39
  const headerCellRef = React.useRef(null);
41
- const [showColumnMenuIcon, setShowColumnMenuIcon] = React.useState(columnMenuOpen);
42
40
  const handleRef = useForkRef(headerCellRef, ref);
43
41
  let ariaSort = 'none';
44
42
  if (sortDirection != null) {
45
43
  ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
46
44
  }
47
- React.useEffect(() => {
48
- if (!showColumnMenuIcon) {
49
- setShowColumnMenuIcon(columnMenuOpen);
50
- }
51
- }, [showColumnMenuIcon, columnMenuOpen]);
52
45
  React.useLayoutEffect(() => {
53
46
  const columnMenuState = apiRef.current.state.columnMenu;
54
47
  if (hasFocus && !columnMenuState.open) {
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { unstable_ownerDocument as ownerDocument, unstable_useEventCallback as useEventCallback } from '@mui/utils';
4
4
  import useLazyRef from '@mui/utils/useLazyRef';
5
5
  import { useTheme } from '@mui/material/styles';
6
- import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol } from '../../../utils/domUtils';
6
+ import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol, escapeOperandAttributeSelector } from '../../../utils/domUtils';
7
7
  import { DEFAULT_GRID_AUTOSIZE_OPTIONS } from './gridColumnResizeApi';
8
8
  import { gridClasses } from '../../../constants/gridClasses';
9
9
  import { useGridApiEventHandler, useGridApiMethod, useGridApiOptionHandler, useGridLogger, useGridNativeEventListener, useGridSelector, useOnMount } from '../../utils';
@@ -13,27 +13,6 @@ import { clamp } from '../../../utils/utils';
13
13
  import { useTimeout } from '../../utils/useTimeout';
14
14
  import { GridPinnedColumnPosition } from '../columns/gridColumnsInterfaces';
15
15
  import { gridColumnsStateSelector } from '../columns';
16
- // TODO: remove support for Safari < 13.
17
- // https://caniuse.com/#search=touch-action
18
- //
19
- // Safari, on iOS, supports touch action since v13.
20
- // Over 80% of the iOS phones are compatible
21
- // in August 2020.
22
- // Utilizing the CSS.supports method to check if touch-action is supported.
23
- // Since CSS.supports is supported on all but Edge@12 and IE and touch-action
24
- // is supported on both Edge@12 and IE if CSS.supports is not available that means that
25
- // touch-action will be supported
26
- let cachedSupportsTouchActionNone = false;
27
- function doesSupportTouchActionNone() {
28
- if (cachedSupportsTouchActionNone === undefined) {
29
- if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
30
- cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
31
- } else {
32
- cachedSupportsTouchActionNone = true;
33
- }
34
- }
35
- return cachedSupportsTouchActionNone;
36
- }
37
16
  function trackFinger(event, currentTouchId) {
38
17
  if (currentTouchId !== undefined && event.changedTouches) {
39
18
  for (let i = 0; i < event.changedTouches.length; i += 1) {
@@ -294,6 +273,10 @@ export const useGridColumnResize = (apiRef, props) => {
294
273
  if (refs.colDef) {
295
274
  apiRef.current.setColumnWidth(refs.colDef.field, refs.colDef.width);
296
275
  logger.debug(`Updating col ${refs.colDef.field} with new width: ${refs.colDef.width}`);
276
+
277
+ // Since during resizing we update the columns width outside of React, React is unable to
278
+ // reapply the right style properties. We need to sync the state manually.
279
+ // So we reapply the same logic as in https://github.com/mui/mui-x/blob/0511bf65543ca05d2602a5a3e0a6156f2fc8e759/packages/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx#L405
297
280
  const columnsState = gridColumnsStateSelector(apiRef.current.state);
298
281
  refs.groupHeaderElements.forEach(element => {
299
282
  const fields = getFieldsFromGroupHeaderElem(element);
@@ -320,7 +303,7 @@ export const useGridColumnResize = (apiRef, props) => {
320
303
  refs.initialTotalWidth = apiRef.current.getRootDimensions().rowWidth;
321
304
  refs.colDef = colDef;
322
305
  refs.columnHeaderElement = findHeaderElementFromField(apiRef.current.columnHeadersContainerRef.current, colDef.field);
323
- const headerFilterElement = root.querySelector(`.${gridClasses.headerFilterRow} [data-field="${colDef.field}"]`);
306
+ const headerFilterElement = root.querySelector(`.${gridClasses.headerFilterRow} [data-field="${escapeOperandAttributeSelector(colDef.field)}"]`);
324
307
  if (headerFilterElement) {
325
308
  refs.headerFilterElement = headerFilterElement;
326
309
  }
@@ -387,10 +370,6 @@ export const useGridColumnResize = (apiRef, props) => {
387
370
  if (!cellSeparator) {
388
371
  return;
389
372
  }
390
- // If touch-action: none; is not supported we need to prevent the scroll manually.
391
- if (!doesSupportTouchActionNone()) {
392
- event.preventDefault();
393
- }
394
373
  const touch = event.changedTouches[0];
395
374
  if (touch != null) {
396
375
  // A number that uniquely identifies the current finger in the touch session.
@@ -562,7 +541,7 @@ export const useGridColumnResize = (apiRef, props) => {
562
541
  }
563
542
  });
564
543
  useGridNativeEventListener(apiRef, () => apiRef.current.columnHeadersContainerRef?.current, 'touchstart', handleTouchStart, {
565
- passive: doesSupportTouchActionNone()
544
+ passive: true
566
545
  });
567
546
  useGridApiMethod(apiRef, {
568
547
  autosizeColumns
@@ -117,24 +117,29 @@ export const hydrateColumnsWidth = (rawState, dimensions) => {
117
117
  const flexColumns = [];
118
118
 
119
119
  // For the non-flex columns, compute their width
120
- // For the flex columns, compute there minimum width and how much width must be allocated during the flex allocation
120
+ // For the flex columns, compute their minimum width and how much width must be allocated during the flex allocation
121
121
  rawState.orderedFields.forEach(columnField => {
122
- const newColumn = _extends({}, rawState.lookup[columnField]);
123
- if (rawState.columnVisibilityModel[columnField] === false) {
124
- newColumn.computedWidth = 0;
125
- } else {
126
- let computedWidth;
127
- if (newColumn.flex && newColumn.flex > 0) {
128
- totalFlexUnits += newColumn.flex;
129
- computedWidth = 0;
130
- flexColumns.push(newColumn);
122
+ let column = rawState.lookup[columnField];
123
+ let computedWidth = 0;
124
+ let isFlex = false;
125
+ if (rawState.columnVisibilityModel[columnField] !== false) {
126
+ if (column.flex && column.flex > 0) {
127
+ totalFlexUnits += column.flex;
128
+ isFlex = true;
131
129
  } else {
132
- computedWidth = clamp(newColumn.width || GRID_STRING_COL_DEF.width, newColumn.minWidth || GRID_STRING_COL_DEF.minWidth, newColumn.maxWidth || GRID_STRING_COL_DEF.maxWidth);
130
+ computedWidth = clamp(column.width || GRID_STRING_COL_DEF.width, column.minWidth || GRID_STRING_COL_DEF.minWidth, column.maxWidth || GRID_STRING_COL_DEF.maxWidth);
133
131
  }
134
132
  widthAllocatedBeforeFlex += computedWidth;
135
- newColumn.computedWidth = computedWidth;
136
133
  }
137
- columnsLookup[columnField] = newColumn;
134
+ if (column.computedWidth !== computedWidth) {
135
+ column = _extends({}, column, {
136
+ computedWidth
137
+ });
138
+ }
139
+ if (isFlex) {
140
+ flexColumns.push(column);
141
+ }
142
+ columnsLookup[columnField] = column;
138
143
  });
139
144
  const availableWidth = dimensions === undefined ? 0 : dimensions.viewportOuterSize.width - (dimensions.hasScrollY ? dimensions.scrollbarSize : 0);
140
145
  const initialFreeSpace = Math.max(availableWidth - widthAllocatedBeforeFlex, 0);
@@ -10,6 +10,9 @@ export const useGridColumnSpanning = apiRef => {
10
10
  const getCellColSpanInfo = (rowId, columnIndex) => {
11
11
  return lookup.current[rowId]?.[columnIndex];
12
12
  };
13
+ const resetColSpan = () => {
14
+ lookup.current = {};
15
+ };
13
16
 
14
17
  // Calculate `colSpan` for each cell in the row
15
18
  const calculateColSpan = React.useCallback(({
@@ -37,15 +40,12 @@ export const useGridColumnSpanning = apiRef => {
37
40
  unstable_getCellColSpanInfo: getCellColSpanInfo
38
41
  };
39
42
  const columnSpanningPrivateApi = {
43
+ resetColSpan,
40
44
  calculateColSpan
41
45
  };
42
46
  useGridApiMethod(apiRef, columnSpanningPublicApi, 'public');
43
47
  useGridApiMethod(apiRef, columnSpanningPrivateApi, 'private');
44
- const handleColumnReorderChange = React.useCallback(() => {
45
- // `colSpan` needs to be recalculated after column reordering
46
- lookup.current = {};
47
- }, []);
48
- useGridApiEventHandler(apiRef, 'columnOrderChange', handleColumnReorderChange);
48
+ useGridApiEventHandler(apiRef, 'columnOrderChange', resetColSpan);
49
49
  };
50
50
  function calculateCellColSpan(params) {
51
51
  const {
@@ -42,7 +42,14 @@ const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, ho
42
42
  direction: ScrollDirection.NONE,
43
43
  buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
44
44
  });
45
- const isJSDOM = typeof window !== 'undefined' ? /jsdom/.test(window.navigator.userAgent) : false;
45
+ let isJSDOM = false;
46
+ try {
47
+ if (typeof window !== 'undefined') {
48
+ isJSDOM = /jsdom/.test(window.navigator.userAgent);
49
+ }
50
+ } catch (_) {
51
+ /* ignore */
52
+ }
46
53
  export const useGridVirtualScroller = () => {
47
54
  const apiRef = useGridPrivateApiContext();
48
55
  const rootProps = useGridRootProps();
package/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export type { DataGridProps, GridExperimentalFeatures } from './models/props/Dat
15
15
  export type { GridToolbarExportProps } from './components/toolbar/GridToolbarExport';
16
16
  export type { GridExportFormat, GridExportExtension } from './models/gridExport';
17
17
  export { GridColumnHeaders } from './components/GridColumnHeaders';
18
+ export type { GridColumnHeadersProps } from './components/GridColumnHeaders';
18
19
  /**
19
20
  * Reexportable components.
20
21
  */
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.5.1
2
+ * @mui/x-data-grid v7.6.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -17,7 +17,6 @@ export * from './context';
17
17
  export * from './colDef';
18
18
  export * from './utils';
19
19
  export { GridColumnHeaders } from './components/GridColumnHeaders';
20
-
21
20
  /**
22
21
  * Reexportable components.
23
22
  */
package/locales/faIR.js CHANGED
@@ -3,7 +3,7 @@ import { getGridLocalization } from '../utils/getGridLocalization';
3
3
  const faIRGrid = {
4
4
  // Root
5
5
  noRowsLabel: 'بدون سطر',
6
- noResultsOverlayLabel: 'نتیجه ای پیدا نشد.',
6
+ noResultsOverlayLabel: 'نتیجه‌ای پیدا نشد.',
7
7
  // Density selector toolbar button text
8
8
  toolbarDensity: 'تراکم',
9
9
  toolbarDensityLabel: 'تراکم',
@@ -97,12 +97,12 @@ const faIRGrid = {
97
97
  columnMenuFilter: 'فیلتر',
98
98
  columnMenuHideColumn: 'مخفی',
99
99
  columnMenuUnsort: 'نامرتب‌کردن',
100
- columnMenuSortAsc: 'مرتب‌کردن صعودی',
101
- columnMenuSortDesc: 'مرتب‌کردن نزولی',
100
+ columnMenuSortAsc: 'مرتب‌سازی صعودی',
101
+ columnMenuSortDesc: 'مرتب‌سازی نزولی',
102
102
  // Column header text
103
103
  columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} فیلتر‌های فعال` : `${count} فیلتر فعال`,
104
104
  columnHeaderFiltersLabel: 'نمایش فیلترها',
105
- columnHeaderSortIconLabel: 'مرتب‌کردن',
105
+ columnHeaderSortIconLabel: 'مرتب‌سازی',
106
106
  // Rows selected footer text
107
107
  footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} سطرهای انتخاب شده` : `${count.toLocaleString()} سطر انتخاب شده`,
108
108
  // Total row amount footer text
package/locales/fiFI.js CHANGED
@@ -30,11 +30,10 @@ const fiFIGrid = {
30
30
  toolbarExportPrint: 'Tulosta',
31
31
  toolbarExportExcel: 'Lataa Excel-muodossa',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
- // columnsManagementReset: 'Reset',
37
-
33
+ columnsManagementSearchTitle: 'Hae',
34
+ columnsManagementNoColumns: 'Ei sarakkeita näytettäväksi',
35
+ columnsManagementShowHideAllText: 'Näytä/Piilota kaikki',
36
+ columnsManagementReset: 'Palauta',
38
37
  // Filter panel text
39
38
  filterPanelAddFilter: 'Lisää suodatin',
40
39
  filterPanelRemoveAll: 'Poista kaikki',
@@ -15,6 +15,8 @@ export interface GridColumnSpanningApi {
15
15
  unstable_getCellColSpanInfo: (rowId: GridRowId, columnIndex: GridColumnIndex) => GridCellColSpanInfo | undefined;
16
16
  }
17
17
  export interface GridColumnSpanningPrivateApi {
18
+ /** Reset the colspan cache */
19
+ resetColSpan: () => void;
18
20
  /**
19
21
  * Calculate column spanning for each cell in the row
20
22
  * @param {Object} options The options to apply on the calculation.
@@ -95,7 +95,7 @@ export interface GridSlotsComponent extends GridBaseSlots, GridIconSlotsComponen
95
95
  columnMenu: React.JSXElementConstructor<GridSlotProps['columnMenu']>;
96
96
  /**
97
97
  * Component responsible for rendering the column headers.
98
- * @default DataGridColumnHeaders
98
+ * @default GridColumnHeaders
99
99
  */
100
100
  columnHeaders: React.JSXElementConstructor<GridSlotProps['columnHeaders']>;
101
101
  /**
@@ -72,7 +72,7 @@ export interface DataGridPropsWithComplexDefaultValueBeforeProcessing {
72
72
  */
73
73
  export interface DataGridPropsWithDefaultValues<R extends GridValidRowModel = any> {
74
74
  /**
75
- * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
75
+ * If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
76
76
  * @default false
77
77
  */
78
78
  autoHeight: boolean;
@@ -62,7 +62,7 @@ DataGridRaw.propTypes = {
62
62
  */
63
63
  'aria-labelledby': PropTypes.string,
64
64
  /**
65
- * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
65
+ * If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
66
66
  * @default false
67
67
  */
68
68
  autoHeight: PropTypes.bool,
@@ -75,7 +75,7 @@ let warnedOnce = false;
75
75
 
76
76
  // TODO(v7): Removing the wrapper will break the docs performance visualization demo.
77
77
 
78
- const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
78
+ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
79
79
  const {
80
80
  column,
81
81
  rowId,
@@ -12,7 +12,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridGenericColumnHeaderItem(props, ref) {
13
13
  const {
14
14
  classes,
15
- columnMenuOpen,
16
15
  colIndex,
17
16
  height,
18
17
  isResizing,
@@ -38,17 +37,11 @@ const GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridG
38
37
  const apiRef = useGridPrivateApiContext();
39
38
  const rootProps = useGridRootProps();
40
39
  const headerCellRef = React.useRef(null);
41
- const [showColumnMenuIcon, setShowColumnMenuIcon] = React.useState(columnMenuOpen);
42
40
  const handleRef = useForkRef(headerCellRef, ref);
43
41
  let ariaSort = 'none';
44
42
  if (sortDirection != null) {
45
43
  ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
46
44
  }
47
- React.useEffect(() => {
48
- if (!showColumnMenuIcon) {
49
- setShowColumnMenuIcon(columnMenuOpen);
50
- }
51
- }, [showColumnMenuIcon, columnMenuOpen]);
52
45
  React.useLayoutEffect(() => {
53
46
  const columnMenuState = apiRef.current.state.columnMenu;
54
47
  if (hasFocus && !columnMenuState.open) {
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { unstable_ownerDocument as ownerDocument, unstable_useEventCallback as useEventCallback } from '@mui/utils';
4
4
  import useLazyRef from '@mui/utils/useLazyRef';
5
5
  import { useTheme } from '@mui/material/styles';
6
- import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol } from '../../../utils/domUtils';
6
+ import { findGridCellElementsFromCol, findGridElement, findLeftPinnedCellsAfterCol, findRightPinnedCellsBeforeCol, getFieldFromHeaderElem, findHeaderElementFromField, getFieldsFromGroupHeaderElem, findGroupHeaderElementsFromField, findGridHeader, findGridCells, findParentElementFromClassName, findLeftPinnedHeadersAfterCol, findRightPinnedHeadersBeforeCol, escapeOperandAttributeSelector } from '../../../utils/domUtils';
7
7
  import { DEFAULT_GRID_AUTOSIZE_OPTIONS } from './gridColumnResizeApi';
8
8
  import { gridClasses } from '../../../constants/gridClasses';
9
9
  import { useGridApiEventHandler, useGridApiMethod, useGridApiOptionHandler, useGridLogger, useGridNativeEventListener, useGridSelector, useOnMount } from '../../utils';
@@ -13,27 +13,6 @@ import { clamp } from '../../../utils/utils';
13
13
  import { useTimeout } from '../../utils/useTimeout';
14
14
  import { GridPinnedColumnPosition } from '../columns/gridColumnsInterfaces';
15
15
  import { gridColumnsStateSelector } from '../columns';
16
- // TODO: remove support for Safari < 13.
17
- // https://caniuse.com/#search=touch-action
18
- //
19
- // Safari, on iOS, supports touch action since v13.
20
- // Over 80% of the iOS phones are compatible
21
- // in August 2020.
22
- // Utilizing the CSS.supports method to check if touch-action is supported.
23
- // Since CSS.supports is supported on all but Edge@12 and IE and touch-action
24
- // is supported on both Edge@12 and IE if CSS.supports is not available that means that
25
- // touch-action will be supported
26
- let cachedSupportsTouchActionNone = false;
27
- function doesSupportTouchActionNone() {
28
- if (cachedSupportsTouchActionNone === undefined) {
29
- if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
30
- cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
31
- } else {
32
- cachedSupportsTouchActionNone = true;
33
- }
34
- }
35
- return cachedSupportsTouchActionNone;
36
- }
37
16
  function trackFinger(event, currentTouchId) {
38
17
  if (currentTouchId !== undefined && event.changedTouches) {
39
18
  for (let i = 0; i < event.changedTouches.length; i += 1) {
@@ -294,6 +273,10 @@ export const useGridColumnResize = (apiRef, props) => {
294
273
  if (refs.colDef) {
295
274
  apiRef.current.setColumnWidth(refs.colDef.field, refs.colDef.width);
296
275
  logger.debug(`Updating col ${refs.colDef.field} with new width: ${refs.colDef.width}`);
276
+
277
+ // Since during resizing we update the columns width outside of React, React is unable to
278
+ // reapply the right style properties. We need to sync the state manually.
279
+ // So we reapply the same logic as in https://github.com/mui/mui-x/blob/0511bf65543ca05d2602a5a3e0a6156f2fc8e759/packages/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx#L405
297
280
  const columnsState = gridColumnsStateSelector(apiRef.current.state);
298
281
  refs.groupHeaderElements.forEach(element => {
299
282
  const fields = getFieldsFromGroupHeaderElem(element);
@@ -320,7 +303,7 @@ export const useGridColumnResize = (apiRef, props) => {
320
303
  refs.initialTotalWidth = apiRef.current.getRootDimensions().rowWidth;
321
304
  refs.colDef = colDef;
322
305
  refs.columnHeaderElement = findHeaderElementFromField(apiRef.current.columnHeadersContainerRef.current, colDef.field);
323
- const headerFilterElement = root.querySelector(`.${gridClasses.headerFilterRow} [data-field="${colDef.field}"]`);
306
+ const headerFilterElement = root.querySelector(`.${gridClasses.headerFilterRow} [data-field="${escapeOperandAttributeSelector(colDef.field)}"]`);
324
307
  if (headerFilterElement) {
325
308
  refs.headerFilterElement = headerFilterElement;
326
309
  }
@@ -387,10 +370,6 @@ export const useGridColumnResize = (apiRef, props) => {
387
370
  if (!cellSeparator) {
388
371
  return;
389
372
  }
390
- // If touch-action: none; is not supported we need to prevent the scroll manually.
391
- if (!doesSupportTouchActionNone()) {
392
- event.preventDefault();
393
- }
394
373
  const touch = event.changedTouches[0];
395
374
  if (touch != null) {
396
375
  // A number that uniquely identifies the current finger in the touch session.
@@ -562,7 +541,7 @@ export const useGridColumnResize = (apiRef, props) => {
562
541
  }
563
542
  });
564
543
  useGridNativeEventListener(apiRef, () => apiRef.current.columnHeadersContainerRef?.current, 'touchstart', handleTouchStart, {
565
- passive: doesSupportTouchActionNone()
544
+ passive: true
566
545
  });
567
546
  useGridApiMethod(apiRef, {
568
547
  autosizeColumns
@@ -117,24 +117,29 @@ export const hydrateColumnsWidth = (rawState, dimensions) => {
117
117
  const flexColumns = [];
118
118
 
119
119
  // For the non-flex columns, compute their width
120
- // For the flex columns, compute there minimum width and how much width must be allocated during the flex allocation
120
+ // For the flex columns, compute their minimum width and how much width must be allocated during the flex allocation
121
121
  rawState.orderedFields.forEach(columnField => {
122
- const newColumn = _extends({}, rawState.lookup[columnField]);
123
- if (rawState.columnVisibilityModel[columnField] === false) {
124
- newColumn.computedWidth = 0;
125
- } else {
126
- let computedWidth;
127
- if (newColumn.flex && newColumn.flex > 0) {
128
- totalFlexUnits += newColumn.flex;
129
- computedWidth = 0;
130
- flexColumns.push(newColumn);
122
+ let column = rawState.lookup[columnField];
123
+ let computedWidth = 0;
124
+ let isFlex = false;
125
+ if (rawState.columnVisibilityModel[columnField] !== false) {
126
+ if (column.flex && column.flex > 0) {
127
+ totalFlexUnits += column.flex;
128
+ isFlex = true;
131
129
  } else {
132
- computedWidth = clamp(newColumn.width || GRID_STRING_COL_DEF.width, newColumn.minWidth || GRID_STRING_COL_DEF.minWidth, newColumn.maxWidth || GRID_STRING_COL_DEF.maxWidth);
130
+ computedWidth = clamp(column.width || GRID_STRING_COL_DEF.width, column.minWidth || GRID_STRING_COL_DEF.minWidth, column.maxWidth || GRID_STRING_COL_DEF.maxWidth);
133
131
  }
134
132
  widthAllocatedBeforeFlex += computedWidth;
135
- newColumn.computedWidth = computedWidth;
136
133
  }
137
- columnsLookup[columnField] = newColumn;
134
+ if (column.computedWidth !== computedWidth) {
135
+ column = _extends({}, column, {
136
+ computedWidth
137
+ });
138
+ }
139
+ if (isFlex) {
140
+ flexColumns.push(column);
141
+ }
142
+ columnsLookup[columnField] = column;
138
143
  });
139
144
  const availableWidth = dimensions === undefined ? 0 : dimensions.viewportOuterSize.width - (dimensions.hasScrollY ? dimensions.scrollbarSize : 0);
140
145
  const initialFreeSpace = Math.max(availableWidth - widthAllocatedBeforeFlex, 0);
@@ -10,6 +10,9 @@ export const useGridColumnSpanning = apiRef => {
10
10
  const getCellColSpanInfo = (rowId, columnIndex) => {
11
11
  return lookup.current[rowId]?.[columnIndex];
12
12
  };
13
+ const resetColSpan = () => {
14
+ lookup.current = {};
15
+ };
13
16
 
14
17
  // Calculate `colSpan` for each cell in the row
15
18
  const calculateColSpan = React.useCallback(({
@@ -37,15 +40,12 @@ export const useGridColumnSpanning = apiRef => {
37
40
  unstable_getCellColSpanInfo: getCellColSpanInfo
38
41
  };
39
42
  const columnSpanningPrivateApi = {
43
+ resetColSpan,
40
44
  calculateColSpan
41
45
  };
42
46
  useGridApiMethod(apiRef, columnSpanningPublicApi, 'public');
43
47
  useGridApiMethod(apiRef, columnSpanningPrivateApi, 'private');
44
- const handleColumnReorderChange = React.useCallback(() => {
45
- // `colSpan` needs to be recalculated after column reordering
46
- lookup.current = {};
47
- }, []);
48
- useGridApiEventHandler(apiRef, 'columnOrderChange', handleColumnReorderChange);
48
+ useGridApiEventHandler(apiRef, 'columnOrderChange', resetColSpan);
49
49
  };
50
50
  function calculateCellColSpan(params) {
51
51
  const {
@@ -42,7 +42,14 @@ const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, ho
42
42
  direction: ScrollDirection.NONE,
43
43
  buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
44
44
  });
45
- const isJSDOM = typeof window !== 'undefined' ? /jsdom/.test(window.navigator.userAgent) : false;
45
+ let isJSDOM = false;
46
+ try {
47
+ if (typeof window !== 'undefined') {
48
+ isJSDOM = /jsdom/.test(window.navigator.userAgent);
49
+ }
50
+ } catch (_) {
51
+ /* ignore */
52
+ }
46
53
  export const useGridVirtualScroller = () => {
47
54
  const apiRef = useGridPrivateApiContext();
48
55
  const rootProps = useGridRootProps();
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.5.1
2
+ * @mui/x-data-grid v7.6.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -17,7 +17,6 @@ export * from './context';
17
17
  export * from './colDef';
18
18
  export * from './utils';
19
19
  export { GridColumnHeaders } from './components/GridColumnHeaders';
20
-
21
20
  /**
22
21
  * Reexportable components.
23
22
  */
@@ -3,7 +3,7 @@ import { getGridLocalization } from '../utils/getGridLocalization';
3
3
  const faIRGrid = {
4
4
  // Root
5
5
  noRowsLabel: 'بدون سطر',
6
- noResultsOverlayLabel: 'نتیجه ای پیدا نشد.',
6
+ noResultsOverlayLabel: 'نتیجه‌ای پیدا نشد.',
7
7
  // Density selector toolbar button text
8
8
  toolbarDensity: 'تراکم',
9
9
  toolbarDensityLabel: 'تراکم',
@@ -97,12 +97,12 @@ const faIRGrid = {
97
97
  columnMenuFilter: 'فیلتر',
98
98
  columnMenuHideColumn: 'مخفی',
99
99
  columnMenuUnsort: 'نامرتب‌کردن',
100
- columnMenuSortAsc: 'مرتب‌کردن صعودی',
101
- columnMenuSortDesc: 'مرتب‌کردن نزولی',
100
+ columnMenuSortAsc: 'مرتب‌سازی صعودی',
101
+ columnMenuSortDesc: 'مرتب‌سازی نزولی',
102
102
  // Column header text
103
103
  columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} فیلتر‌های فعال` : `${count} فیلتر فعال`,
104
104
  columnHeaderFiltersLabel: 'نمایش فیلترها',
105
- columnHeaderSortIconLabel: 'مرتب‌کردن',
105
+ columnHeaderSortIconLabel: 'مرتب‌سازی',
106
106
  // Rows selected footer text
107
107
  footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} سطرهای انتخاب شده` : `${count.toLocaleString()} سطر انتخاب شده`,
108
108
  // Total row amount footer text
@@ -30,11 +30,10 @@ const fiFIGrid = {
30
30
  toolbarExportPrint: 'Tulosta',
31
31
  toolbarExportExcel: 'Lataa Excel-muodossa',
32
32
  // Columns management text
33
- // columnsManagementSearchTitle: 'Search',
34
- // columnsManagementNoColumns: 'No columns',
35
- // columnsManagementShowHideAllText: 'Show/Hide All',
36
- // columnsManagementReset: 'Reset',
37
-
33
+ columnsManagementSearchTitle: 'Hae',
34
+ columnsManagementNoColumns: 'Ei sarakkeita näytettäväksi',
35
+ columnsManagementShowHideAllText: 'Näytä/Piilota kaikki',
36
+ columnsManagementReset: 'Palauta',
38
37
  // Filter panel text
39
38
  filterPanelAddFilter: 'Lisää suodatin',
40
39
  filterPanelRemoveAll: 'Poista kaikki',
@@ -5,7 +5,7 @@ export function isOverflown(element) {
5
5
  export function findParentElementFromClassName(elem, className) {
6
6
  return elem.closest(`.${className}`);
7
7
  }
8
- function escapeOperandAttributeSelector(operand) {
8
+ export function escapeOperandAttributeSelector(operand) {
9
9
  return operand.replace(/["\\]/g, '\\$&');
10
10
  }
11
11
  export function getGridColumnHeaderElement(root, field) {
@@ -51,14 +51,13 @@ export function getFieldFromHeaderElem(colCellEl) {
51
51
  return colCellEl.getAttribute('data-field');
52
52
  }
53
53
  export function findHeaderElementFromField(elem, field) {
54
- return elem.querySelector(`[data-field="${field}"]`);
54
+ return elem.querySelector(`[data-field="${escapeOperandAttributeSelector(field)}"]`);
55
55
  }
56
56
  export function getFieldsFromGroupHeaderElem(colCellEl) {
57
- const fieldsString = colCellEl.getAttribute('data-fields');
58
- return fieldsString?.startsWith('|-') ? fieldsString.slice(2, -2).split('-|-') : [];
57
+ return colCellEl.getAttribute('data-fields').slice(2, -2).split('-|-');
59
58
  }
60
59
  export function findGroupHeaderElementsFromField(elem, field) {
61
- return Array.from(elem.querySelectorAll(`[data-fields*="|-${field}-|"]`) ?? []);
60
+ return Array.from(elem.querySelectorAll(`[data-fields*="|-${escapeOperandAttributeSelector(field)}-|"]`) ?? []);
62
61
  }
63
62
  export function findGridCellElementsFromCol(col, api) {
64
63
  const root = findParentElementFromClassName(col, gridClasses.root);
@@ -177,11 +176,11 @@ export function findRightPinnedHeadersBeforeCol(api, col) {
177
176
  }
178
177
  export function findGridHeader(api, field) {
179
178
  const headers = api.columnHeadersContainerRef.current;
180
- return headers.querySelector(`:scope > div > [data-field="${field}"][role="columnheader"]`);
179
+ return headers.querySelector(`:scope > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="columnheader"]`);
181
180
  }
182
181
  export function findGridCells(api, field) {
183
182
  const container = api.virtualScrollerRef.current;
184
- return Array.from(container.querySelectorAll(`:scope > div > div > div > [data-field="${field}"][role="gridcell"]`));
183
+ return Array.from(container.querySelectorAll(`:scope > div > div > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="gridcell"]`));
185
184
  }
186
185
  function queryRows(api) {
187
186
  return api.virtualScrollerRef.current.querySelectorAll(
@@ -70,7 +70,7 @@ DataGridRaw.propTypes = {
70
70
  */
71
71
  'aria-labelledby': _propTypes.default.string,
72
72
  /**
73
- * If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
73
+ * If `true`, the Data Grid height is dynamic and follows the number of rows in the Data Grid.
74
74
  * @default false
75
75
  */
76
76
  autoHeight: _propTypes.default.bool,
@@ -84,7 +84,7 @@ let warnedOnce = false;
84
84
 
85
85
  // TODO(v7): Removing the wrapper will break the docs performance visualization demo.
86
86
 
87
- const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
87
+ const GridCell = /*#__PURE__*/React.forwardRef(function GridCell(props, ref) {
88
88
  const {
89
89
  column,
90
90
  rowId,
@@ -21,7 +21,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
21
21
  const GridGenericColumnHeaderItem = exports.GridGenericColumnHeaderItem = /*#__PURE__*/React.forwardRef(function GridGenericColumnHeaderItem(props, ref) {
22
22
  const {
23
23
  classes,
24
- columnMenuOpen,
25
24
  colIndex,
26
25
  height,
27
26
  isResizing,
@@ -47,17 +46,11 @@ const GridGenericColumnHeaderItem = exports.GridGenericColumnHeaderItem = /*#__P
47
46
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
48
47
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
49
48
  const headerCellRef = React.useRef(null);
50
- const [showColumnMenuIcon, setShowColumnMenuIcon] = React.useState(columnMenuOpen);
51
49
  const handleRef = (0, _utils.unstable_useForkRef)(headerCellRef, ref);
52
50
  let ariaSort = 'none';
53
51
  if (sortDirection != null) {
54
52
  ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
55
53
  }
56
- React.useEffect(() => {
57
- if (!showColumnMenuIcon) {
58
- setShowColumnMenuIcon(columnMenuOpen);
59
- }
60
- }, [showColumnMenuIcon, columnMenuOpen]);
61
54
  React.useLayoutEffect(() => {
62
55
  const columnMenuState = apiRef.current.state.columnMenu;
63
56
  if (hasFocus && !columnMenuState.open) {
@@ -22,27 +22,6 @@ var _gridColumnsInterfaces = require("../columns/gridColumnsInterfaces");
22
22
  var _columns = require("../columns");
23
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
- // TODO: remove support for Safari < 13.
26
- // https://caniuse.com/#search=touch-action
27
- //
28
- // Safari, on iOS, supports touch action since v13.
29
- // Over 80% of the iOS phones are compatible
30
- // in August 2020.
31
- // Utilizing the CSS.supports method to check if touch-action is supported.
32
- // Since CSS.supports is supported on all but Edge@12 and IE and touch-action
33
- // is supported on both Edge@12 and IE if CSS.supports is not available that means that
34
- // touch-action will be supported
35
- let cachedSupportsTouchActionNone = false;
36
- function doesSupportTouchActionNone() {
37
- if (cachedSupportsTouchActionNone === undefined) {
38
- if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
39
- cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
40
- } else {
41
- cachedSupportsTouchActionNone = true;
42
- }
43
- }
44
- return cachedSupportsTouchActionNone;
45
- }
46
25
  function trackFinger(event, currentTouchId) {
47
26
  if (currentTouchId !== undefined && event.changedTouches) {
48
27
  for (let i = 0; i < event.changedTouches.length; i += 1) {
@@ -304,6 +283,10 @@ const useGridColumnResize = (apiRef, props) => {
304
283
  if (refs.colDef) {
305
284
  apiRef.current.setColumnWidth(refs.colDef.field, refs.colDef.width);
306
285
  logger.debug(`Updating col ${refs.colDef.field} with new width: ${refs.colDef.width}`);
286
+
287
+ // Since during resizing we update the columns width outside of React, React is unable to
288
+ // reapply the right style properties. We need to sync the state manually.
289
+ // So we reapply the same logic as in https://github.com/mui/mui-x/blob/0511bf65543ca05d2602a5a3e0a6156f2fc8e759/packages/x-data-grid/src/hooks/features/columnHeaders/useGridColumnHeaders.tsx#L405
307
290
  const columnsState = (0, _columns.gridColumnsStateSelector)(apiRef.current.state);
308
291
  refs.groupHeaderElements.forEach(element => {
309
292
  const fields = (0, _domUtils.getFieldsFromGroupHeaderElem)(element);
@@ -330,7 +313,7 @@ const useGridColumnResize = (apiRef, props) => {
330
313
  refs.initialTotalWidth = apiRef.current.getRootDimensions().rowWidth;
331
314
  refs.colDef = colDef;
332
315
  refs.columnHeaderElement = (0, _domUtils.findHeaderElementFromField)(apiRef.current.columnHeadersContainerRef.current, colDef.field);
333
- const headerFilterElement = root.querySelector(`.${_gridClasses.gridClasses.headerFilterRow} [data-field="${colDef.field}"]`);
316
+ const headerFilterElement = root.querySelector(`.${_gridClasses.gridClasses.headerFilterRow} [data-field="${(0, _domUtils.escapeOperandAttributeSelector)(colDef.field)}"]`);
334
317
  if (headerFilterElement) {
335
318
  refs.headerFilterElement = headerFilterElement;
336
319
  }
@@ -397,10 +380,6 @@ const useGridColumnResize = (apiRef, props) => {
397
380
  if (!cellSeparator) {
398
381
  return;
399
382
  }
400
- // If touch-action: none; is not supported we need to prevent the scroll manually.
401
- if (!doesSupportTouchActionNone()) {
402
- event.preventDefault();
403
- }
404
383
  const touch = event.changedTouches[0];
405
384
  if (touch != null) {
406
385
  // A number that uniquely identifies the current finger in the touch session.
@@ -572,7 +551,7 @@ const useGridColumnResize = (apiRef, props) => {
572
551
  }
573
552
  });
574
553
  (0, _utils2.useGridNativeEventListener)(apiRef, () => apiRef.current.columnHeadersContainerRef?.current, 'touchstart', handleTouchStart, {
575
- passive: doesSupportTouchActionNone()
554
+ passive: true
576
555
  });
577
556
  (0, _utils2.useGridApiMethod)(apiRef, {
578
557
  autosizeColumns
@@ -129,24 +129,29 @@ const hydrateColumnsWidth = (rawState, dimensions) => {
129
129
  const flexColumns = [];
130
130
 
131
131
  // For the non-flex columns, compute their width
132
- // For the flex columns, compute there minimum width and how much width must be allocated during the flex allocation
132
+ // For the flex columns, compute their minimum width and how much width must be allocated during the flex allocation
133
133
  rawState.orderedFields.forEach(columnField => {
134
- const newColumn = (0, _extends2.default)({}, rawState.lookup[columnField]);
135
- if (rawState.columnVisibilityModel[columnField] === false) {
136
- newColumn.computedWidth = 0;
137
- } else {
138
- let computedWidth;
139
- if (newColumn.flex && newColumn.flex > 0) {
140
- totalFlexUnits += newColumn.flex;
141
- computedWidth = 0;
142
- flexColumns.push(newColumn);
134
+ let column = rawState.lookup[columnField];
135
+ let computedWidth = 0;
136
+ let isFlex = false;
137
+ if (rawState.columnVisibilityModel[columnField] !== false) {
138
+ if (column.flex && column.flex > 0) {
139
+ totalFlexUnits += column.flex;
140
+ isFlex = true;
143
141
  } else {
144
- computedWidth = (0, _utils.clamp)(newColumn.width || _colDef.GRID_STRING_COL_DEF.width, newColumn.minWidth || _colDef.GRID_STRING_COL_DEF.minWidth, newColumn.maxWidth || _colDef.GRID_STRING_COL_DEF.maxWidth);
142
+ computedWidth = (0, _utils.clamp)(column.width || _colDef.GRID_STRING_COL_DEF.width, column.minWidth || _colDef.GRID_STRING_COL_DEF.minWidth, column.maxWidth || _colDef.GRID_STRING_COL_DEF.maxWidth);
145
143
  }
146
144
  widthAllocatedBeforeFlex += computedWidth;
147
- newColumn.computedWidth = computedWidth;
148
145
  }
149
- columnsLookup[columnField] = newColumn;
146
+ if (column.computedWidth !== computedWidth) {
147
+ column = (0, _extends2.default)({}, column, {
148
+ computedWidth
149
+ });
150
+ }
151
+ if (isFlex) {
152
+ flexColumns.push(column);
153
+ }
154
+ columnsLookup[columnField] = column;
150
155
  });
151
156
  const availableWidth = dimensions === undefined ? 0 : dimensions.viewportOuterSize.width - (dimensions.hasScrollY ? dimensions.scrollbarSize : 0);
152
157
  const initialFreeSpace = Math.max(availableWidth - widthAllocatedBeforeFlex, 0);
@@ -18,6 +18,9 @@ const useGridColumnSpanning = apiRef => {
18
18
  const getCellColSpanInfo = (rowId, columnIndex) => {
19
19
  return lookup.current[rowId]?.[columnIndex];
20
20
  };
21
+ const resetColSpan = () => {
22
+ lookup.current = {};
23
+ };
21
24
 
22
25
  // Calculate `colSpan` for each cell in the row
23
26
  const calculateColSpan = React.useCallback(({
@@ -45,15 +48,12 @@ const useGridColumnSpanning = apiRef => {
45
48
  unstable_getCellColSpanInfo: getCellColSpanInfo
46
49
  };
47
50
  const columnSpanningPrivateApi = {
51
+ resetColSpan,
48
52
  calculateColSpan
49
53
  };
50
54
  (0, _useGridApiMethod.useGridApiMethod)(apiRef, columnSpanningPublicApi, 'public');
51
55
  (0, _useGridApiMethod.useGridApiMethod)(apiRef, columnSpanningPrivateApi, 'private');
52
- const handleColumnReorderChange = React.useCallback(() => {
53
- // `colSpan` needs to be recalculated after column reordering
54
- lookup.current = {};
55
- }, []);
56
- (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnOrderChange', handleColumnReorderChange);
56
+ (0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnOrderChange', resetColSpan);
57
57
  };
58
58
  exports.useGridColumnSpanning = useGridColumnSpanning;
59
59
  function calculateCellColSpan(params) {
@@ -54,7 +54,14 @@ const createScrollCache = (mode, rowBufferPx, columnBufferPx, verticalBuffer, ho
54
54
  direction: ScrollDirection.NONE,
55
55
  buffer: bufferForDirection(mode, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
56
56
  });
57
- const isJSDOM = typeof window !== 'undefined' ? /jsdom/.test(window.navigator.userAgent) : false;
57
+ let isJSDOM = false;
58
+ try {
59
+ if (typeof window !== 'undefined') {
60
+ isJSDOM = /jsdom/.test(window.navigator.userAgent);
61
+ }
62
+ } catch (_) {
63
+ /* ignore */
64
+ }
58
65
  const useGridVirtualScroller = () => {
59
66
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
60
67
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.5.1
2
+ * @mui/x-data-grid v7.6.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -9,7 +9,7 @@ var _getGridLocalization = require("../utils/getGridLocalization");
9
9
  const faIRGrid = {
10
10
  // Root
11
11
  noRowsLabel: 'بدون سطر',
12
- noResultsOverlayLabel: 'نتیجه ای پیدا نشد.',
12
+ noResultsOverlayLabel: 'نتیجه‌ای پیدا نشد.',
13
13
  // Density selector toolbar button text
14
14
  toolbarDensity: 'تراکم',
15
15
  toolbarDensityLabel: 'تراکم',
@@ -103,12 +103,12 @@ const faIRGrid = {
103
103
  columnMenuFilter: 'فیلتر',
104
104
  columnMenuHideColumn: 'مخفی',
105
105
  columnMenuUnsort: 'نامرتب‌کردن',
106
- columnMenuSortAsc: 'مرتب‌کردن صعودی',
107
- columnMenuSortDesc: 'مرتب‌کردن نزولی',
106
+ columnMenuSortAsc: 'مرتب‌سازی صعودی',
107
+ columnMenuSortDesc: 'مرتب‌سازی نزولی',
108
108
  // Column header text
109
109
  columnHeaderFiltersTooltipActive: count => count !== 1 ? `${count} فیلتر‌های فعال` : `${count} فیلتر فعال`,
110
110
  columnHeaderFiltersLabel: 'نمایش فیلترها',
111
- columnHeaderSortIconLabel: 'مرتب‌کردن',
111
+ columnHeaderSortIconLabel: 'مرتب‌سازی',
112
112
  // Rows selected footer text
113
113
  footerRowSelected: count => count !== 1 ? `${count.toLocaleString()} سطرهای انتخاب شده` : `${count.toLocaleString()} سطر انتخاب شده`,
114
114
  // Total row amount footer text
@@ -36,11 +36,10 @@ const fiFIGrid = {
36
36
  toolbarExportPrint: 'Tulosta',
37
37
  toolbarExportExcel: 'Lataa Excel-muodossa',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
- // columnsManagementReset: 'Reset',
43
-
39
+ columnsManagementSearchTitle: 'Hae',
40
+ columnsManagementNoColumns: 'Ei sarakkeita näytettäväksi',
41
+ columnsManagementShowHideAllText: 'Näytä/Piilota kaikki',
42
+ columnsManagementReset: 'Palauta',
44
43
  // Filter panel text
45
44
  filterPanelAddFilter: 'Lisää suodatin',
46
45
  filterPanelRemoveAll: 'Poista kaikki',
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.escapeOperandAttributeSelector = escapeOperandAttributeSelector;
6
7
  exports.findGridCellElementsFromCol = findGridCellElementsFromCol;
7
8
  exports.findGridCells = findGridCells;
8
9
  exports.findGridElement = findGridElement;
@@ -76,14 +77,13 @@ function getFieldFromHeaderElem(colCellEl) {
76
77
  return colCellEl.getAttribute('data-field');
77
78
  }
78
79
  function findHeaderElementFromField(elem, field) {
79
- return elem.querySelector(`[data-field="${field}"]`);
80
+ return elem.querySelector(`[data-field="${escapeOperandAttributeSelector(field)}"]`);
80
81
  }
81
82
  function getFieldsFromGroupHeaderElem(colCellEl) {
82
- const fieldsString = colCellEl.getAttribute('data-fields');
83
- return fieldsString?.startsWith('|-') ? fieldsString.slice(2, -2).split('-|-') : [];
83
+ return colCellEl.getAttribute('data-fields').slice(2, -2).split('-|-');
84
84
  }
85
85
  function findGroupHeaderElementsFromField(elem, field) {
86
- return Array.from(elem.querySelectorAll(`[data-fields*="|-${field}-|"]`) ?? []);
86
+ return Array.from(elem.querySelectorAll(`[data-fields*="|-${escapeOperandAttributeSelector(field)}-|"]`) ?? []);
87
87
  }
88
88
  function findGridCellElementsFromCol(col, api) {
89
89
  const root = findParentElementFromClassName(col, _gridClasses.gridClasses.root);
@@ -202,11 +202,11 @@ function findRightPinnedHeadersBeforeCol(api, col) {
202
202
  }
203
203
  function findGridHeader(api, field) {
204
204
  const headers = api.columnHeadersContainerRef.current;
205
- return headers.querySelector(`:scope > div > [data-field="${field}"][role="columnheader"]`);
205
+ return headers.querySelector(`:scope > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="columnheader"]`);
206
206
  }
207
207
  function findGridCells(api, field) {
208
208
  const container = api.virtualScrollerRef.current;
209
- return Array.from(container.querySelectorAll(`:scope > div > div > div > [data-field="${field}"][role="gridcell"]`));
209
+ return Array.from(container.querySelectorAll(`:scope > div > div > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="gridcell"]`));
210
210
  }
211
211
  function queryRows(api) {
212
212
  return api.virtualScrollerRef.current.querySelectorAll(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.5.1",
3
+ "version": "7.6.1",
4
4
  "description": "The Community plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -37,8 +37,8 @@
37
37
  "directory": "packages/x-data-grid"
38
38
  },
39
39
  "dependencies": {
40
- "@babel/runtime": "^7.24.5",
41
- "@mui/system": "^5.15.14",
40
+ "@babel/runtime": "^7.24.6",
41
+ "@mui/system": "^5.15.15",
42
42
  "@mui/utils": "^5.15.14",
43
43
  "clsx": "^2.1.1",
44
44
  "prop-types": "^15.8.1",
@@ -4,6 +4,7 @@ import type { GridPrivateApiCommunity } from '../models/api/gridApiCommunity';
4
4
  import type { GridRowId } from '../models/gridRows';
5
5
  export declare function isOverflown(element: Element): boolean;
6
6
  export declare function findParentElementFromClassName(elem: Element, className: string): Element | null;
7
+ export declare function escapeOperandAttributeSelector(operand: string): string;
7
8
  export declare function getGridColumnHeaderElement(root: Element, field: string): HTMLDivElement | null;
8
9
  export declare function getGridRowElement(root: Element, id: GridRowId): HTMLDivElement | null;
9
10
  export declare function getGridCellElement(root: Element, { id, field }: {
package/utils/domUtils.js CHANGED
@@ -5,7 +5,7 @@ export function isOverflown(element) {
5
5
  export function findParentElementFromClassName(elem, className) {
6
6
  return elem.closest(`.${className}`);
7
7
  }
8
- function escapeOperandAttributeSelector(operand) {
8
+ export function escapeOperandAttributeSelector(operand) {
9
9
  return operand.replace(/["\\]/g, '\\$&');
10
10
  }
11
11
  export function getGridColumnHeaderElement(root, field) {
@@ -51,14 +51,13 @@ export function getFieldFromHeaderElem(colCellEl) {
51
51
  return colCellEl.getAttribute('data-field');
52
52
  }
53
53
  export function findHeaderElementFromField(elem, field) {
54
- return elem.querySelector(`[data-field="${field}"]`);
54
+ return elem.querySelector(`[data-field="${escapeOperandAttributeSelector(field)}"]`);
55
55
  }
56
56
  export function getFieldsFromGroupHeaderElem(colCellEl) {
57
- const fieldsString = colCellEl.getAttribute('data-fields');
58
- return fieldsString?.startsWith('|-') ? fieldsString.slice(2, -2).split('-|-') : [];
57
+ return colCellEl.getAttribute('data-fields').slice(2, -2).split('-|-');
59
58
  }
60
59
  export function findGroupHeaderElementsFromField(elem, field) {
61
- return Array.from(elem.querySelectorAll(`[data-fields*="|-${field}-|"]`) ?? []);
60
+ return Array.from(elem.querySelectorAll(`[data-fields*="|-${escapeOperandAttributeSelector(field)}-|"]`) ?? []);
62
61
  }
63
62
  export function findGridCellElementsFromCol(col, api) {
64
63
  const root = findParentElementFromClassName(col, gridClasses.root);
@@ -177,11 +176,11 @@ export function findRightPinnedHeadersBeforeCol(api, col) {
177
176
  }
178
177
  export function findGridHeader(api, field) {
179
178
  const headers = api.columnHeadersContainerRef.current;
180
- return headers.querySelector(`:scope > div > [data-field="${field}"][role="columnheader"]`);
179
+ return headers.querySelector(`:scope > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="columnheader"]`);
181
180
  }
182
181
  export function findGridCells(api, field) {
183
182
  const container = api.virtualScrollerRef.current;
184
- return Array.from(container.querySelectorAll(`:scope > div > div > div > [data-field="${field}"][role="gridcell"]`));
183
+ return Array.from(container.querySelectorAll(`:scope > div > div > div > [data-field="${escapeOperandAttributeSelector(field)}"][role="gridcell"]`));
185
184
  }
186
185
  function queryRows(api) {
187
186
  return api.virtualScrollerRef.current.querySelectorAll(