@mui/x-data-grid 7.12.1 → 7.14.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 (157) hide show
  1. package/CHANGELOG.md +162 -1
  2. package/DataGrid/DataGrid.js +10 -1
  3. package/components/GridColumnHeaders.js +1 -1
  4. package/components/GridConfigurationContext.d.ts +2 -0
  5. package/components/GridConfigurationContext.js +5 -0
  6. package/components/GridHeaders.js +1 -1
  7. package/components/GridRow.js +6 -8
  8. package/components/GridScrollArea.js +1 -1
  9. package/components/GridSkeletonLoadingOverlay.js +1 -1
  10. package/components/cell/GridCell.js +12 -13
  11. package/components/cell/GridEditSingleSelectCell.js +2 -3
  12. package/components/cell/GridSkeletonCell.js +2 -2
  13. package/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  14. package/components/containers/GridRootStyles.js +9 -2
  15. package/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  16. package/components/panel/GridPanel.js +1 -2
  17. package/components/panel/filterPanel/GridFilterForm.js +9 -4
  18. package/components/toolbar/GridToolbarDensitySelector.js +2 -2
  19. package/components/toolbar/GridToolbarExportContainer.js +2 -2
  20. package/components/toolbar/GridToolbarQuickFilter.js +5 -3
  21. package/components/virtualization/GridMainContainer.js +3 -2
  22. package/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  23. package/context/GridContextProvider.d.ts +3 -1
  24. package/context/GridContextProvider.js +12 -7
  25. package/hooks/core/useGridStateInitialization.js +1 -3
  26. package/hooks/features/dimensions/useGridDimensions.js +1 -1
  27. package/hooks/features/export/serializers/csvSerializer.js +4 -3
  28. package/hooks/features/filter/gridFilterSelector.d.ts +20 -7
  29. package/hooks/features/filter/gridFilterSelector.js +34 -0
  30. package/hooks/features/filter/gridFilterState.d.ts +6 -0
  31. package/hooks/features/filter/index.d.ts +2 -1
  32. package/hooks/features/filter/index.js +1 -1
  33. package/hooks/features/filter/useGridFilter.js +3 -0
  34. package/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  35. package/hooks/features/rows/useGridParamsApi.js +2 -1
  36. package/hooks/features/rows/useGridRowAriaAttributes.d.ts +2 -0
  37. package/hooks/features/rows/useGridRowAriaAttributes.js +19 -0
  38. package/hooks/utils/useGridAriaAttributes.d.ts +2 -6
  39. package/hooks/utils/useGridAriaAttributes.js +5 -8
  40. package/hooks/utils/useGridConfiguration.d.ts +2 -0
  41. package/hooks/utils/useGridConfiguration.js +9 -0
  42. package/hooks/utils/useGridSelector.d.ts +5 -2
  43. package/hooks/utils/useGridSelector.js +39 -1
  44. package/index.js +1 -1
  45. package/internals/index.d.ts +5 -2
  46. package/internals/index.js +5 -2
  47. package/locales/csCZ.js +4 -5
  48. package/locales/heIL.js +4 -5
  49. package/locales/viVN.js +4 -5
  50. package/models/configuration/gridConfiguration.d.ts +10 -0
  51. package/models/configuration/gridConfiguration.js +1 -0
  52. package/models/configuration/gridRowConfiguration.d.ts +12 -0
  53. package/models/configuration/gridRowConfiguration.js +1 -0
  54. package/models/gridDataSource.d.ts +8 -7
  55. package/models/gridRows.d.ts +2 -2
  56. package/models/params/gridCellParams.d.ts +4 -0
  57. package/models/props/DataGridProps.d.ts +1 -1
  58. package/modern/DataGrid/DataGrid.js +10 -1
  59. package/modern/components/GridColumnHeaders.js +1 -1
  60. package/modern/components/GridConfigurationContext.js +5 -0
  61. package/modern/components/GridHeaders.js +1 -1
  62. package/modern/components/GridRow.js +6 -8
  63. package/modern/components/GridScrollArea.js +1 -1
  64. package/modern/components/GridSkeletonLoadingOverlay.js +1 -1
  65. package/modern/components/cell/GridCell.js +12 -13
  66. package/modern/components/cell/GridEditSingleSelectCell.js +2 -3
  67. package/modern/components/cell/GridSkeletonCell.js +2 -2
  68. package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  69. package/modern/components/containers/GridRootStyles.js +9 -2
  70. package/modern/components/menu/columnMenu/GridColumnMenuContainer.js +2 -2
  71. package/modern/components/panel/GridPanel.js +1 -2
  72. package/modern/components/panel/filterPanel/GridFilterForm.js +9 -4
  73. package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
  74. package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
  75. package/modern/components/toolbar/GridToolbarQuickFilter.js +5 -3
  76. package/modern/components/virtualization/GridMainContainer.js +3 -2
  77. package/modern/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  78. package/modern/context/GridContextProvider.js +12 -7
  79. package/modern/hooks/core/useGridStateInitialization.js +1 -3
  80. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -1
  81. package/modern/hooks/features/export/serializers/csvSerializer.js +4 -3
  82. package/modern/hooks/features/filter/gridFilterSelector.js +34 -0
  83. package/modern/hooks/features/filter/index.js +1 -1
  84. package/modern/hooks/features/filter/useGridFilter.js +3 -0
  85. package/modern/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  86. package/modern/hooks/features/rows/useGridParamsApi.js +2 -1
  87. package/modern/hooks/features/rows/useGridRowAriaAttributes.js +19 -0
  88. package/modern/hooks/utils/useGridAriaAttributes.js +5 -8
  89. package/modern/hooks/utils/useGridConfiguration.js +9 -0
  90. package/modern/hooks/utils/useGridSelector.js +39 -1
  91. package/modern/index.js +1 -1
  92. package/modern/internals/index.js +5 -2
  93. package/modern/locales/csCZ.js +4 -5
  94. package/modern/locales/heIL.js +4 -5
  95. package/modern/locales/viVN.js +4 -5
  96. package/modern/models/configuration/gridConfiguration.js +1 -0
  97. package/modern/models/configuration/gridRowConfiguration.js +1 -0
  98. package/modern/utils/createSelector.js +116 -0
  99. package/modern/utils/keyboardUtils.js +1 -11
  100. package/node/DataGrid/DataGrid.js +10 -1
  101. package/node/components/GridColumnHeaders.js +1 -1
  102. package/node/{utils/fastMemo.js → components/GridConfigurationContext.js} +4 -4
  103. package/node/components/GridHeaders.js +1 -1
  104. package/node/components/GridRow.js +6 -8
  105. package/node/components/GridScrollArea.js +1 -1
  106. package/node/components/GridSkeletonLoadingOverlay.js +1 -1
  107. package/node/components/cell/GridCell.js +12 -13
  108. package/node/components/cell/GridEditSingleSelectCell.js +2 -3
  109. package/node/components/cell/GridSkeletonCell.js +2 -2
  110. package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -1
  111. package/node/components/containers/GridRootStyles.js +9 -2
  112. package/node/components/menu/columnMenu/GridColumnMenuContainer.js +1 -1
  113. package/node/components/panel/GridPanel.js +1 -2
  114. package/node/components/panel/filterPanel/GridFilterForm.js +9 -4
  115. package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
  116. package/node/components/toolbar/GridToolbarExportContainer.js +1 -1
  117. package/node/components/toolbar/GridToolbarQuickFilter.js +5 -3
  118. package/node/components/virtualization/GridMainContainer.js +3 -2
  119. package/node/components/virtualization/GridVirtualScrollerFiller.js +1 -1
  120. package/node/context/GridContextProvider.js +12 -7
  121. package/node/hooks/core/useGridStateInitialization.js +1 -3
  122. package/node/hooks/features/dimensions/useGridDimensions.js +1 -1
  123. package/node/hooks/features/export/serializers/csvSerializer.js +4 -3
  124. package/node/hooks/features/filter/gridFilterSelector.js +35 -1
  125. package/node/hooks/features/filter/index.js +97 -15
  126. package/node/hooks/features/filter/useGridFilter.js +3 -0
  127. package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -1
  128. package/node/hooks/features/rows/useGridParamsApi.js +2 -1
  129. package/node/hooks/features/rows/useGridRowAriaAttributes.js +28 -0
  130. package/node/hooks/utils/useGridAriaAttributes.js +4 -7
  131. package/node/hooks/utils/useGridConfiguration.js +18 -0
  132. package/node/hooks/utils/useGridSelector.js +42 -3
  133. package/node/index.js +1 -1
  134. package/node/internals/index.js +53 -12
  135. package/node/locales/csCZ.js +4 -5
  136. package/node/locales/heIL.js +4 -5
  137. package/node/locales/viVN.js +4 -5
  138. package/node/models/configuration/gridConfiguration.js +5 -0
  139. package/node/models/configuration/gridRowConfiguration.js +5 -0
  140. package/node/utils/createSelector.js +119 -2
  141. package/node/utils/keyboardUtils.js +2 -15
  142. package/package.json +4 -4
  143. package/utils/createSelector.d.ts +19 -0
  144. package/utils/createSelector.js +116 -0
  145. package/utils/keyboardUtils.d.ts +1 -9
  146. package/utils/keyboardUtils.js +1 -11
  147. package/modern/utils/fastMemo.js +0 -5
  148. package/modern/utils/fastObjectShallowCompare.js +0 -28
  149. package/modern/utils/throttle.js +0 -19
  150. package/node/utils/fastObjectShallowCompare.js +0 -34
  151. package/node/utils/throttle.js +0 -25
  152. package/utils/fastMemo.d.ts +0 -1
  153. package/utils/fastMemo.js +0 -5
  154. package/utils/fastObjectShallowCompare.d.ts +0 -1
  155. package/utils/fastObjectShallowCompare.js +0 -28
  156. package/utils/throttle.d.ts +0 -4
  157. package/utils/throttle.js +0 -19
@@ -32,6 +32,7 @@ const filterStateInitializer = (state, props, apiRef) => {
32
32
  filter: {
33
33
  filterModel: (0, _gridFilterUtils.sanitizeFilterModel)(filterModel, props.disableMultipleColumnsFiltering, apiRef),
34
34
  filteredRowsLookup: {},
35
+ filteredChildrenCountLookup: {},
35
36
  filteredDescendantCountLookup: {}
36
37
  },
37
38
  visibleRowsLookup: {}
@@ -283,6 +284,7 @@ const useGridFilter = (apiRef, props) => {
283
284
  if (props.filterMode !== 'client' || !params.isRowMatchingFilters) {
284
285
  return {
285
286
  filteredRowsLookup: {},
287
+ filteredChildrenCountLookup: {},
286
288
  filteredDescendantCountLookup: {}
287
289
  };
288
290
  }
@@ -311,6 +313,7 @@ const useGridFilter = (apiRef, props) => {
311
313
  }
312
314
  return {
313
315
  filteredRowsLookup,
316
+ filteredChildrenCountLookup: {},
314
317
  filteredDescendantCountLookup: {}
315
318
  };
316
319
  }, [apiRef, props.filterMode, getRowId, getRowsRef]);
@@ -115,6 +115,9 @@ const useGridRowSelection = (apiRef, props) => {
115
115
  }, [apiRef, logger, props.rowSelection, props.signature, canHaveMultipleSelection]);
116
116
  const isRowSelected = React.useCallback(id => (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state).includes(id), [apiRef]);
117
117
  const isRowSelectable = React.useCallback(id => {
118
+ if (props.rowSelection === false) {
119
+ return false;
120
+ }
118
121
  if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
119
122
  return false;
120
123
  }
@@ -123,7 +126,7 @@ const useGridRowSelection = (apiRef, props) => {
123
126
  return false;
124
127
  }
125
128
  return true;
126
- }, [apiRef, propIsRowSelectable]);
129
+ }, [apiRef, props.rowSelection, propIsRowSelectable]);
127
130
  const getSelectedRows = React.useCallback(() => (0, _gridRowSelectionSelector.selectedGridRowsSelector)(apiRef), [apiRef]);
128
131
  const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
129
132
  if (!apiRef.current.isRowSelectable(id)) {
@@ -61,7 +61,8 @@ function useGridParamsApi(apiRef) {
61
61
  tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
62
62
  value,
63
63
  formattedValue: value,
64
- isEditable: false
64
+ isEditable: false,
65
+ api: {}
65
66
  };
66
67
  if (colDef && colDef.valueFormatter) {
67
68
  params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useGridRowAriaAttributes = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _rowSelection = require("../rowSelection");
9
+ var _useGridSelector = require("../../utils/useGridSelector");
10
+ var _gridColumnGroupsSelector = require("../columnGrouping/gridColumnGroupsSelector");
11
+ var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
12
+ 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); }
13
+ 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; }
14
+ const useGridRowAriaAttributes = () => {
15
+ const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
16
+ const selectedIdsLookup = (0, _useGridSelector.useGridSelector)(apiRef, _rowSelection.selectedIdsLookupSelector);
17
+ const headerGroupingMaxDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector);
18
+ return React.useCallback((rowNode, index) => {
19
+ const ariaAttributes = {};
20
+ const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
21
+ ariaAttributes['aria-rowindex'] = ariaRowIndex;
22
+ if (apiRef.current.isRowSelectable(rowNode.id)) {
23
+ ariaAttributes['aria-selected'] = selectedIdsLookup[rowNode.id] !== undefined;
24
+ }
25
+ return ariaAttributes;
26
+ }, [apiRef, selectedIdsLookup, headerGroupingMaxDepth]);
27
+ };
28
+ exports.useGridRowAriaAttributes = useGridRowAriaAttributes;
@@ -11,21 +11,18 @@ var _gridColumnGroupsSelector = require("../features/columnGrouping/gridColumnGr
11
11
  var _gridRowsSelector = require("../features/rows/gridRowsSelector");
12
12
  var _useGridPrivateApiContext = require("./useGridPrivateApiContext");
13
13
  var _utils = require("../features/rowSelection/utils");
14
+ var _gridFilterSelector = require("../features/filter/gridFilterSelector");
14
15
  const useGridAriaAttributes = () => {
15
16
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
16
17
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
17
18
  const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector);
18
- const totalRowCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowCountSelector);
19
+ const accessibleRowCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridExpandedRowCountSelector);
19
20
  const headerGroupingMaxDepth = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnGroupsSelector.gridColumnGroupsHeaderMaxDepthSelector);
20
21
  const pinnedRowsCount = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsCountSelector);
21
- let role = 'grid';
22
- if (rootProps.treeData) {
23
- role = 'treegrid';
24
- }
25
22
  return {
26
- role,
23
+ role: 'grid',
27
24
  'aria-colcount': visibleColumns.length,
28
- 'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
25
+ 'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + accessibleRowCount,
29
26
  'aria-multiselectable': (0, _utils.isMultipleRowSelectionEnabled)(rootProps)
30
27
  };
31
28
  };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useGridConfiguration = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _GridConfigurationContext = require("../../components/GridConfigurationContext");
9
+ 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); }
10
+ 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; }
11
+ const useGridConfiguration = () => {
12
+ const configuration = React.useContext(_GridConfigurationContext.GridConfigurationContext);
13
+ if (configuration === undefined) {
14
+ throw new Error(['MUI X: Could not find the data grid configuration context.', 'It looks like you rendered your component outside of a DataGrid, DataGridPro or DataGridPremium parent component.', 'This can also happen if you are bundling multiple versions of the data grid.'].join('\n'));
15
+ }
16
+ return configuration;
17
+ };
18
+ exports.useGridConfiguration = useGridConfiguration;
@@ -3,23 +3,32 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useGridSelector = exports.objectShallowCompare = void 0;
6
+ exports.useGridSelectorV8 = exports.useGridSelector = exports.objectShallowCompare = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
+ var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
8
9
  var _useLazyRef = require("./useLazyRef");
9
10
  var _useOnMount = require("./useOnMount");
10
11
  var _warning = require("../../internals/utils/warning");
11
- var _fastObjectShallowCompare = require("../../utils/fastObjectShallowCompare");
12
12
  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); }
13
13
  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; }
14
14
  function isOutputSelector(selector) {
15
15
  return selector.acceptsApiRef;
16
16
  }
17
+ // TODO v8: Remove this function
17
18
  function applySelector(apiRef, selector) {
18
19
  if (isOutputSelector(selector)) {
19
20
  return selector(apiRef);
20
21
  }
21
22
  return selector(apiRef.current.state);
22
23
  }
24
+
25
+ // TODO v8: Rename this function to `applySelector`
26
+ function applySelectorV8(apiRef, selector, args, instanceId) {
27
+ if (isOutputSelector(selector)) {
28
+ return selector(apiRef, args);
29
+ }
30
+ return selector(apiRef.current.state, instanceId);
31
+ }
23
32
  const defaultCompare = Object.is;
24
33
  const objectShallowCompare = exports.objectShallowCompare = _fastObjectShallowCompare.fastObjectShallowCompare;
25
34
  const createRefs = () => ({
@@ -27,6 +36,8 @@ const createRefs = () => ({
27
36
  equals: null,
28
37
  selector: null
29
38
  });
39
+
40
+ // TODO v8: Remove this function
30
41
  const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
31
42
  if (process.env.NODE_ENV !== 'production') {
32
43
  if (!apiRef.current.state) {
@@ -52,4 +63,32 @@ const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
52
63
  });
53
64
  return state;
54
65
  };
55
- exports.useGridSelector = useGridSelector;
66
+
67
+ // TODO v8: Rename this function to `useGridSelector`
68
+ exports.useGridSelector = useGridSelector;
69
+ const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultCompare) => {
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ if (!apiRef.current.state) {
72
+ (0, _warning.warnOnce)(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
73
+ }
74
+ }
75
+ const refs = (0, _useLazyRef.useLazyRef)(createRefs);
76
+ const didInit = refs.current.selector !== null;
77
+ const [state, setState] = React.useState(
78
+ // We don't use an initialization function to avoid allocations
79
+ didInit ? null : applySelectorV8(apiRef, selector, args, apiRef.current.instanceId));
80
+ refs.current.state = state;
81
+ refs.current.equals = equals;
82
+ refs.current.selector = selector;
83
+ (0, _useOnMount.useOnMount)(() => {
84
+ return apiRef.current.store.subscribe(() => {
85
+ const newState = applySelectorV8(apiRef, refs.current.selector, args, apiRef.current.instanceId);
86
+ if (!refs.current.equals(refs.current.state, newState)) {
87
+ refs.current.state = newState;
88
+ setState(newState);
89
+ }
90
+ });
91
+ });
92
+ return state;
93
+ };
94
+ exports.useGridSelectorV8 = useGridSelectorV8;
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.12.1
2
+ * @mui/x-data-grid v7.14.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -33,6 +33,8 @@ var _exportNames = {
33
33
  useGridFilter: true,
34
34
  filterStateInitializer: true,
35
35
  passFilterLogic: true,
36
+ gridFilteredChildrenCountLookupSelector: true,
37
+ gridExpandedSortedRowTreeLevelPositionLookupSelector: true,
36
38
  isSingleSelectColDef: true,
37
39
  useGridFocus: true,
38
40
  focusStateInitializer: true,
@@ -46,6 +48,8 @@ var _exportNames = {
46
48
  gridEditRowsStateSelector: true,
47
49
  useGridRows: true,
48
50
  rowsStateInitializer: true,
51
+ useGridAriaAttributes: true,
52
+ useGridRowAriaAttributes: true,
49
53
  useGridRowsPreProcessors: true,
50
54
  getTreeNodeDescendants: true,
51
55
  buildRootGroup: true,
@@ -81,7 +85,10 @@ var _exportNames = {
81
85
  getColumnsToExport: true,
82
86
  defaultGetRowsToExport: true,
83
87
  createSelector: true,
88
+ createSelectorV8: true,
84
89
  createSelectorMemoized: true,
90
+ createSelectorMemoizedV8: true,
91
+ useGridSelectorV8: true,
85
92
  findParentElementFromClassName: true,
86
93
  getActiveElement: true,
87
94
  isEventTargetInPortal: true,
@@ -193,6 +200,18 @@ Object.defineProperty(exports, "createSelectorMemoized", {
193
200
  return _createSelector.createSelectorMemoized;
194
201
  }
195
202
  });
203
+ Object.defineProperty(exports, "createSelectorMemoizedV8", {
204
+ enumerable: true,
205
+ get: function () {
206
+ return _createSelector.createSelectorMemoizedV8;
207
+ }
208
+ });
209
+ Object.defineProperty(exports, "createSelectorV8", {
210
+ enumerable: true,
211
+ get: function () {
212
+ return _createSelector.createSelectorV8;
213
+ }
214
+ });
196
215
  Object.defineProperty(exports, "defaultGetRowsToExport", {
197
216
  enumerable: true,
198
217
  get: function () {
@@ -289,6 +308,18 @@ Object.defineProperty(exports, "gridEditRowsStateSelector", {
289
308
  return _gridEditingSelectors.gridEditRowsStateSelector;
290
309
  }
291
310
  });
311
+ Object.defineProperty(exports, "gridExpandedSortedRowTreeLevelPositionLookupSelector", {
312
+ enumerable: true,
313
+ get: function () {
314
+ return _gridFilterSelector.gridExpandedSortedRowTreeLevelPositionLookupSelector;
315
+ }
316
+ });
317
+ Object.defineProperty(exports, "gridFilteredChildrenCountLookupSelector", {
318
+ enumerable: true,
319
+ get: function () {
320
+ return _gridFilterSelector.gridFilteredChildrenCountLookupSelector;
321
+ }
322
+ });
292
323
  Object.defineProperty(exports, "gridHeaderFilteringEditFieldSelector", {
293
324
  enumerable: true,
294
325
  get: function () {
@@ -397,6 +428,12 @@ Object.defineProperty(exports, "unwrapPrivateAPI", {
397
428
  return _useGridApiInitialization.unwrapPrivateAPI;
398
429
  }
399
430
  });
431
+ Object.defineProperty(exports, "useGridAriaAttributes", {
432
+ enumerable: true,
433
+ get: function () {
434
+ return _useGridAriaAttributes.useGridAriaAttributes;
435
+ }
436
+ });
400
437
  Object.defineProperty(exports, "useGridClipboard", {
401
438
  enumerable: true,
402
439
  get: function () {
@@ -541,6 +578,12 @@ Object.defineProperty(exports, "useGridRegisterStrategyProcessor", {
541
578
  return _strategyProcessing.useGridRegisterStrategyProcessor;
542
579
  }
543
580
  });
581
+ Object.defineProperty(exports, "useGridRowAriaAttributes", {
582
+ enumerable: true,
583
+ get: function () {
584
+ return _useGridRowAriaAttributes.useGridRowAriaAttributes;
585
+ }
586
+ });
544
587
  Object.defineProperty(exports, "useGridRowSelection", {
545
588
  enumerable: true,
546
589
  get: function () {
@@ -577,6 +620,12 @@ Object.defineProperty(exports, "useGridScroll", {
577
620
  return _useGridScroll.useGridScroll;
578
621
  }
579
622
  });
623
+ Object.defineProperty(exports, "useGridSelectorV8", {
624
+ enumerable: true,
625
+ get: function () {
626
+ return _useGridSelector.useGridSelectorV8;
627
+ }
628
+ });
580
629
  Object.defineProperty(exports, "useGridSorting", {
581
630
  enumerable: true,
582
631
  get: function () {
@@ -665,6 +714,7 @@ var _useGridCsvExport = require("../hooks/features/export/useGridCsvExport");
665
714
  var _useGridPrintExport = require("../hooks/features/export/useGridPrintExport");
666
715
  var _useGridFilter = require("../hooks/features/filter/useGridFilter");
667
716
  var _gridFilterUtils = require("../hooks/features/filter/gridFilterUtils");
717
+ var _gridFilterSelector = require("../hooks/features/filter/gridFilterSelector");
668
718
  var _filterPanelUtils = require("../components/panel/filterPanel/filterPanelUtils");
669
719
  var _useGridFocus = require("../hooks/features/focus/useGridFocus");
670
720
  var _useGridKeyboardNavigation = require("../hooks/features/keyboardNavigation/useGridKeyboardNavigation");
@@ -673,6 +723,8 @@ var _useGridPreferencesPanel = require("../hooks/features/preferencesPanel/useGr
673
723
  var _useGridEditing = require("../hooks/features/editing/useGridEditing");
674
724
  var _gridEditingSelectors = require("../hooks/features/editing/gridEditingSelectors");
675
725
  var _useGridRows = require("../hooks/features/rows/useGridRows");
726
+ var _useGridAriaAttributes = require("../hooks/utils/useGridAriaAttributes");
727
+ var _useGridRowAriaAttributes = require("../hooks/features/rows/useGridRowAriaAttributes");
676
728
  var _useGridRowsPreProcessors = require("../hooks/features/rows/useGridRowsPreProcessors");
677
729
  var _gridRowsUtils = require("../hooks/features/rows/gridRowsUtils");
678
730
  var _useGridRowsMeta = require("../hooks/features/rows/useGridRowsMeta");
@@ -717,6 +769,7 @@ Object.keys(_createControllablePromise).forEach(function (key) {
717
769
  });
718
770
  });
719
771
  var _createSelector = require("../utils/createSelector");
772
+ var _useGridSelector = require("../hooks/utils/useGridSelector");
720
773
  var _domUtils = require("../utils/domUtils");
721
774
  var _keyboardUtils = require("../utils/keyboardUtils");
722
775
  var _utils2 = require("../utils/utils");
@@ -731,18 +784,6 @@ Object.keys(_utils2).forEach(function (key) {
731
784
  }
732
785
  });
733
786
  });
734
- var _fastMemo = require("../utils/fastMemo");
735
- Object.keys(_fastMemo).forEach(function (key) {
736
- if (key === "default" || key === "__esModule") return;
737
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
738
- if (key in exports && exports[key] === _fastMemo[key]) return;
739
- Object.defineProperty(exports, key, {
740
- enumerable: true,
741
- get: function () {
742
- return _fastMemo[key];
743
- }
744
- });
745
- });
746
787
  var _exportAs = require("../utils/exportAs");
747
788
  var _getPublicApiRef = require("../utils/getPublicApiRef");
748
789
  Object.keys(_getPublicApiRef).forEach(function (key) {
@@ -44,11 +44,10 @@ const csCZGrid = {
44
44
  toolbarExportPrint: 'Vytisknout',
45
45
  toolbarExportExcel: 'Stáhnout jako Excel',
46
46
  // Columns management text
47
- // columnsManagementSearchTitle: 'Search',
48
- // columnsManagementNoColumns: 'No columns',
49
- // columnsManagementShowHideAllText: 'Show/Hide All',
50
- // columnsManagementReset: 'Reset',
51
-
47
+ columnsManagementSearchTitle: 'Hledat sloupce',
48
+ columnsManagementNoColumns: 'Žádné sloupce',
49
+ columnsManagementShowHideAllText: 'Zobrazit/skrýt vše',
50
+ columnsManagementReset: 'Resetovat',
52
51
  // Filter panel text
53
52
  filterPanelAddFilter: 'Přidat filtr',
54
53
  filterPanelRemoveAll: 'Odstranit vše',
@@ -36,11 +36,10 @@ const heILGrid = {
36
36
  toolbarExportPrint: 'הדפסה',
37
37
  toolbarExportExcel: 'ייצוא ל- Excel',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
- // columnsManagementReset: 'Reset',
43
-
39
+ columnsManagementSearchTitle: 'חיפוש',
40
+ columnsManagementNoColumns: 'אין עמודות',
41
+ columnsManagementShowHideAllText: 'הצג/הסתר הכל',
42
+ columnsManagementReset: 'אתחול',
44
43
  // Filter panel text
45
44
  filterPanelAddFilter: 'הוסף מסנן',
46
45
  filterPanelRemoveAll: 'מחק הכל',
@@ -36,11 +36,10 @@ const viVNGrid = {
36
36
  toolbarExportPrint: 'In',
37
37
  toolbarExportExcel: 'Xuất Excel',
38
38
  // Columns management text
39
- // columnsManagementSearchTitle: 'Search',
40
- // columnsManagementNoColumns: 'No columns',
41
- // columnsManagementShowHideAllText: 'Show/Hide All',
42
- // columnsManagementReset: 'Reset',
43
-
39
+ columnsManagementSearchTitle: 'Tìm kiếm',
40
+ columnsManagementNoColumns: 'Không có cột',
41
+ columnsManagementShowHideAllText: 'Hiện/Ẩn Tất cả',
42
+ columnsManagementReset: 'Đặt lại',
44
43
  // Filter panel text
45
44
  filterPanelAddFilter: 'Thêm bộ lọc',
46
45
  filterPanelRemoveAll: 'Xóa tất cả',
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -3,9 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createSelectorMemoized = exports.createSelector = void 0;
6
+ exports.createSelectorV8 = exports.createSelectorMemoizedV8 = exports.createSelectorMemoized = exports.createSelector = void 0;
7
7
  var _reselect = require("reselect");
8
8
  var _warning = require("../internals/utils/warning");
9
+ // TODO v8: Remove this type
10
+
11
+ // TODO v8: Rename this type to `OutputSelector`
12
+
13
+ // TODO v8: Remove this type
14
+
15
+ // TODO v8: Rename this type to `SelectorArgs`
16
+
17
+ // TODO v8: Remove this type
18
+
19
+ // TODO v8: Rename this type to `CreateSelectorFunction`
20
+
9
21
  const cache = new WeakMap();
10
22
  function checkIsAPIRef(value) {
11
23
  return 'current' in value && 'instanceId' in value.current;
@@ -13,6 +25,8 @@ function checkIsAPIRef(value) {
13
25
  const DEFAULT_INSTANCE_ID = {
14
26
  id: 'default'
15
27
  };
28
+
29
+ // TODO v8: Remove this function
16
30
  const createSelector = (a, b, c, d, e, f, ...other) => {
17
31
  if (other.length > 0) {
18
32
  throw new Error('Unsupported number of selectors');
@@ -77,7 +91,76 @@ const createSelector = (a, b, c, d, e, f, ...other) => {
77
91
  selector.acceptsApiRef = true;
78
92
  return selector;
79
93
  };
94
+
95
+ // TODO v8: Rename this function to `createSelector`
80
96
  exports.createSelector = createSelector;
97
+ const createSelectorV8 = (a, b, c, d, e, f, ...other) => {
98
+ if (other.length > 0) {
99
+ throw new Error('Unsupported number of selectors');
100
+ }
101
+ let selector;
102
+ if (a && b && c && d && e && f) {
103
+ selector = (stateOrApiRef, args, instanceIdParam) => {
104
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
105
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
106
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
107
+ const va = a(state, args, instanceId);
108
+ const vb = b(state, args, instanceId);
109
+ const vc = c(state, args, instanceId);
110
+ const vd = d(state, args, instanceId);
111
+ const ve = e(state, args, instanceId);
112
+ return f(va, vb, vc, vd, ve, args);
113
+ };
114
+ } else if (a && b && c && d && e) {
115
+ selector = (stateOrApiRef, args, instanceIdParam) => {
116
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
117
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
118
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
119
+ const va = a(state, args, instanceId);
120
+ const vb = b(state, args, instanceId);
121
+ const vc = c(state, args, instanceId);
122
+ const vd = d(state, args, instanceId);
123
+ return e(va, vb, vc, vd, args);
124
+ };
125
+ } else if (a && b && c && d) {
126
+ selector = (stateOrApiRef, args, instanceIdParam) => {
127
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
128
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
129
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
130
+ const va = a(state, args, instanceId);
131
+ const vb = b(state, args, instanceId);
132
+ const vc = c(state, args, instanceId);
133
+ return d(va, vb, vc, args);
134
+ };
135
+ } else if (a && b && c) {
136
+ selector = (stateOrApiRef, args, instanceIdParam) => {
137
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
138
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
139
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
140
+ const va = a(state, args, instanceId);
141
+ const vb = b(state, args, instanceId);
142
+ return c(va, vb, args);
143
+ };
144
+ } else if (a && b) {
145
+ selector = (stateOrApiRef, args, instanceIdParam) => {
146
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
147
+ const instanceId = instanceIdParam ?? (isAPIRef ? stateOrApiRef.current.instanceId : DEFAULT_INSTANCE_ID);
148
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
149
+ const va = a(state, args, instanceId);
150
+ return b(va, args);
151
+ };
152
+ } else {
153
+ throw new Error('Missing arguments');
154
+ }
155
+
156
+ // We use this property to detect if the selector was created with createSelector
157
+ // or it's only a simple function the receives the state and returns part of it.
158
+ selector.acceptsApiRef = true;
159
+ return selector;
160
+ };
161
+
162
+ // TODO v8: Remove this function
163
+ exports.createSelectorV8 = createSelectorV8;
81
164
  const createSelectorMemoized = (...args) => {
82
165
  const selector = (stateOrApiRef, instanceId) => {
83
166
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
@@ -109,4 +192,38 @@ const createSelectorMemoized = (...args) => {
109
192
  selector.acceptsApiRef = true;
110
193
  return selector;
111
194
  };
112
- exports.createSelectorMemoized = createSelectorMemoized;
195
+
196
+ // TODO v8: Rename this function to `createSelectorMemoized`
197
+ exports.createSelectorMemoized = createSelectorMemoized;
198
+ const createSelectorMemoizedV8 = (...args) => {
199
+ const selector = (stateOrApiRef, selectorArgs, instanceId) => {
200
+ const isAPIRef = checkIsAPIRef(stateOrApiRef);
201
+ const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
202
+ const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
203
+ if (process.env.NODE_ENV !== 'production') {
204
+ if (cacheKey.id === 'default') {
205
+ (0, _warning.warnOnce)(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, for example `mySelector(apiRef)`, or pass the instance ID explicitly, for example `mySelector(state, apiRef.current.instanceId)`.']);
206
+ }
207
+ }
208
+ const cacheArgsInit = cache.get(cacheKey);
209
+ const cacheArgs = cacheArgsInit ?? new Map();
210
+ const cacheFn = cacheArgs?.get(args);
211
+ if (cacheArgs && cacheFn) {
212
+ // We pass the cache key because the called selector might have as
213
+ // dependency another selector created with this `createSelector`.
214
+ return cacheFn(state, selectorArgs, cacheKey);
215
+ }
216
+ const fn = (0, _reselect.createSelector)(...args);
217
+ if (!cacheArgsInit) {
218
+ cache.set(cacheKey, cacheArgs);
219
+ }
220
+ cacheArgs.set(args, fn);
221
+ return fn(state, selectorArgs, cacheKey);
222
+ };
223
+
224
+ // We use this property to detect if the selector was created with createSelector
225
+ // or it's only a simple function the receives the state and returns part of it.
226
+ selector.acceptsApiRef = true;
227
+ return selector;
228
+ };
229
+ exports.createSelectorMemoizedV8 = createSelectorMemoizedV8;
@@ -3,21 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHideMenuKey = exports.isEscapeKey = exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
6
+ exports.isNavigationKey = exports.isMultipleKey = exports.isKeyboardEvent = exports.isHideMenuKey = exports.isCellExitEditModeKeys = exports.isCellEnterEditModeKeys = exports.isCellEditCommitKeys = exports.GRID_MULTIPLE_SELECTION_KEYS = exports.GRID_CELL_EXIT_EDIT_MODE_KEYS = exports.GRID_CELL_EDIT_COMMIT_KEYS = void 0;
7
7
  exports.isPasteShortcut = isPasteShortcut;
8
8
  exports.isPrintableKey = isPrintableKey;
9
- exports.isTabKey = void 0;
10
- /**
11
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
12
- */
13
- const isEscapeKey = key => key === 'Escape';
14
-
15
- /**
16
- * @deprecated there is no meaninfuly logic abstracted, use event.key directly.
17
- */
18
- exports.isEscapeKey = isEscapeKey;
19
- const isTabKey = key => key === 'Tab';
20
-
21
9
  // Non printable keys have a name, for example "ArrowRight", see the whole list:
22
10
  // https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
23
11
  // So event.key.length === 1 is often enough.
@@ -25,7 +13,6 @@ const isTabKey = key => key === 'Tab';
25
13
  // However, we also need to ignore shortcuts, for example: select all:
26
14
  // - Windows: Ctrl+A, event.ctrlKey is true
27
15
  // - macOS: ⌘ Command+A, event.metaKey is true
28
- exports.isTabKey = isTabKey;
29
16
  function isPrintableKey(event) {
30
17
  return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
31
18
  }
@@ -44,7 +31,7 @@ const isNavigationKey = key => key.indexOf('Arrow') === 0 || key.indexOf('Page')
44
31
  exports.isNavigationKey = isNavigationKey;
45
32
  const isKeyboardEvent = event => !!event.key;
46
33
  exports.isKeyboardEvent = isKeyboardEvent;
47
- const isHideMenuKey = key => isTabKey(key) || isEscapeKey(key);
34
+ const isHideMenuKey = key => key === 'Tab' || key === 'Escape';
48
35
 
49
36
  // In theory, on macOS, ctrl + v doesn't trigger a paste, so the function should return false.
50
37
  // However, maybe it's overkill to fix, so let's be lazy.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.12.1",
3
+ "version": "7.14.0",
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",
@@ -38,12 +38,12 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@babel/runtime": "^7.25.0",
41
- "@mui/system": "^5.16.5",
42
- "@mui/utils": "^5.16.5",
41
+ "@mui/system": "^5.16.7",
42
+ "@mui/utils": "^5.16.6",
43
43
  "clsx": "^2.1.1",
44
44
  "prop-types": "^15.8.1",
45
45
  "reselect": "^4.1.8",
46
- "@mui/x-internals": "7.12.0"
46
+ "@mui/x-internals": "7.14.0"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@emotion/react": "^11.9.0",