@mui/x-data-grid-pro 5.6.1 → 5.9.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 (119) hide show
  1. package/CHANGELOG.md +275 -53
  2. package/DataGridPro/DataGridPro.d.ts +7 -1
  3. package/DataGridPro/DataGridPro.js +47 -18
  4. package/DataGridPro/useDataGridProComponent.js +15 -13
  5. package/DataGridPro/useDataGridProProps.d.ts +2 -1
  6. package/LICENSE +12 -0
  7. package/README.md +1 -1
  8. package/components/DataGridProColumnHeaders.js +10 -16
  9. package/components/DataGridProVirtualScroller.js +6 -9
  10. package/components/GridDetailPanelToggleCell.js +15 -4
  11. package/components/GridGroupingCriteriaCell.d.ts +2 -5
  12. package/components/GridGroupingCriteriaCell.js +2 -74
  13. package/components/GridTreeDataGroupingCell.js +15 -4
  14. package/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
  15. package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
  16. package/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  17. package/hooks/features/columnResize/useGridColumnResize.js +18 -6
  18. package/hooks/features/detailPanel/useGridDetailPanel.js +12 -4
  19. package/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  20. package/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
  21. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +6 -0
  22. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +5 -2
  23. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
  24. package/hooks/features/rowGrouping/useGridRowGrouping.js +45 -168
  25. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
  26. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +131 -4
  27. package/hooks/features/treeData/gridTreeDataUtils.d.ts +1 -0
  28. package/hooks/features/treeData/gridTreeDataUtils.js +2 -0
  29. package/hooks/features/treeData/useGridTreeData.d.ts +1 -5
  30. package/hooks/features/treeData/useGridTreeData.js +3 -84
  31. package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +1 -1
  32. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +73 -4
  33. package/index.d.ts +1 -1
  34. package/index.js +2 -2
  35. package/legacy/DataGridPro/DataGridPro.js +47 -18
  36. package/legacy/DataGridPro/useDataGridProComponent.js +15 -13
  37. package/legacy/components/DataGridProColumnHeaders.js +10 -16
  38. package/legacy/components/DataGridProVirtualScroller.js +6 -9
  39. package/legacy/components/GridDetailPanelToggleCell.js +15 -4
  40. package/legacy/components/GridGroupingCriteriaCell.js +2 -74
  41. package/legacy/components/GridTreeDataGroupingCell.js +15 -4
  42. package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
  43. package/legacy/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
  44. package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  45. package/legacy/hooks/features/columnResize/useGridColumnResize.js +18 -6
  46. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +12 -4
  47. package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  48. package/legacy/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
  49. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +19 -2
  50. package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +47 -173
  51. package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +138 -4
  52. package/legacy/hooks/features/treeData/gridTreeDataUtils.js +2 -0
  53. package/legacy/hooks/features/treeData/useGridTreeData.js +3 -92
  54. package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +85 -4
  55. package/legacy/index.js +2 -2
  56. package/legacy/utils/domUtils.js +30 -3
  57. package/legacy/utils/releaseInfo.js +15 -0
  58. package/models/dataGridProProps.d.ts +9 -8
  59. package/models/gridGroupingColDefOverride.d.ts +2 -2
  60. package/models/gridGroupingValueGetterParams.d.ts +1 -1
  61. package/modern/DataGridPro/DataGridPro.js +47 -18
  62. package/modern/DataGridPro/useDataGridProComponent.js +13 -13
  63. package/modern/components/DataGridProColumnHeaders.js +10 -16
  64. package/modern/components/DataGridProVirtualScroller.js +6 -9
  65. package/modern/components/GridDetailPanelToggleCell.js +15 -4
  66. package/modern/components/GridGroupingCriteriaCell.js +2 -74
  67. package/modern/components/GridTreeDataGroupingCell.js +15 -4
  68. package/modern/hooks/features/columnPinning/useGridColumnPinning.js +6 -6
  69. package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -2
  70. package/modern/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  71. package/modern/hooks/features/columnResize/useGridColumnResize.js +18 -6
  72. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +12 -4
  73. package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  74. package/modern/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +2 -2
  75. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +18 -3
  76. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +45 -168
  77. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +131 -4
  78. package/modern/hooks/features/treeData/gridTreeDataUtils.js +2 -0
  79. package/modern/hooks/features/treeData/useGridTreeData.js +3 -84
  80. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +73 -4
  81. package/modern/index.js +2 -2
  82. package/modern/utils/domUtils.js +30 -3
  83. package/modern/utils/releaseInfo.js +15 -0
  84. package/node/DataGridPro/DataGridPro.js +45 -17
  85. package/node/DataGridPro/useDataGridProComponent.js +15 -13
  86. package/node/components/DataGridProColumnHeaders.js +10 -16
  87. package/node/components/DataGridProVirtualScroller.js +6 -9
  88. package/node/components/GridDetailPanelToggleCell.js +15 -4
  89. package/node/components/GridGroupingCriteriaCell.js +1 -72
  90. package/node/components/GridTreeDataGroupingCell.js +15 -4
  91. package/node/hooks/features/columnPinning/useGridColumnPinning.js +5 -5
  92. package/node/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +1 -1
  93. package/node/hooks/features/columnReorder/useGridColumnReorder.js +1 -1
  94. package/node/hooks/features/columnResize/useGridColumnResize.js +18 -6
  95. package/node/hooks/features/detailPanel/useGridDetailPanel.js +11 -3
  96. package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
  97. package/node/hooks/features/detailPanel/useGridDetailPanelPreProcessors.js +1 -1
  98. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +24 -5
  99. package/node/hooks/features/rowGrouping/useGridRowGrouping.js +41 -166
  100. package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +134 -1
  101. package/node/hooks/features/treeData/gridTreeDataUtils.js +5 -2
  102. package/node/hooks/features/treeData/useGridTreeData.js +2 -93
  103. package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +75 -3
  104. package/node/index.js +9 -9
  105. package/node/utils/domUtils.js +30 -3
  106. package/node/utils/releaseInfo.js +25 -0
  107. package/package.json +7 -7
  108. package/typeOverloads/modules.d.ts +6 -6
  109. package/typeOverloads/reexports.d.ts +1 -1
  110. package/utils/domUtils.d.ts +2 -1
  111. package/utils/domUtils.js +30 -3
  112. package/utils/releaseInfo.d.ts +1 -0
  113. package/utils/releaseInfo.js +15 -0
  114. package/utils/tree/buildRowTree.d.ts +3 -3
  115. package/components/Watermark.d.ts +0 -2
  116. package/components/Watermark.js +0 -43
  117. package/legacy/components/Watermark.js +0 -43
  118. package/modern/components/Watermark.js +0 -43
  119. package/node/components/Watermark.js +0 -56
@@ -1,3 +1,9 @@
1
1
  import * as React from 'react';
2
+ import { GridValidRowModel } from '@mui/x-data-grid';
2
3
  import { DataGridProProps } from '../models';
3
- export declare const DataGridPro: React.MemoExoticComponent<React.ForwardRefExoticComponent<DataGridProProps & React.RefAttributes<HTMLDivElement>>>;
4
+ interface DataGridProComponent {
5
+ <R extends GridValidRowModel = any>(props: DataGridProProps<R> & React.RefAttributes<HTMLDivElement>): JSX.Element;
6
+ propTypes?: any;
7
+ }
8
+ export declare const DataGridPro: DataGridProComponent;
9
+ export {};
@@ -1,28 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { LicenseInfo } from '@mui/x-license-pro';
4
- import { chainPropTypes, ponyfillGlobal } from '@mui/utils';
3
+ import { useLicenseVerifier, Watermark } from '@mui/x-license-pro';
4
+ import { chainPropTypes } from '@mui/utils';
5
5
  import { GridBody, GridErrorHandler, GridFooterPlaceholder, GridHeaderPlaceholder, GridRoot, GridContextProvider } from '@mui/x-data-grid';
6
6
  import { useDataGridProComponent } from './useDataGridProComponent';
7
- import { Watermark } from '../components/Watermark';
8
7
  import { useDataGridProProps } from './useDataGridProProps';
9
8
  import { DataGridProVirtualScroller } from '../components/DataGridProVirtualScroller';
10
- import { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders'; // This is the package release date. Each package version should update this const
11
- // automatically when a new version is published on npm.
12
-
9
+ import { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders';
10
+ import { getReleaseInfo } from '../utils/releaseInfo';
13
11
  import { jsx as _jsx } from "react/jsx-runtime";
14
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- let RELEASE_INFO = "MTY0Njg2NjgwMDAwMA=="; // eslint-disable-next-line no-useless-concat
16
-
17
- if (process.env.NODE_ENV !== 'production' && RELEASE_INFO === '__RELEASE' + '_INFO__') {
18
- // eslint-disable-next-line no-underscore-dangle
19
- RELEASE_INFO = ponyfillGlobal.__MUI_RELEASE_INFO__;
20
- }
21
-
22
- LicenseInfo.setReleaseInfo(RELEASE_INFO);
13
+ const releaseInfo = getReleaseInfo();
23
14
  const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProps, ref) {
24
15
  const props = useDataGridProProps(inProps);
25
16
  const apiRef = useDataGridProComponent(props.apiRef, props);
17
+ useLicenseVerifier('x-data-grid-pro', releaseInfo);
26
18
  return /*#__PURE__*/_jsx(GridContextProvider, {
27
19
  apiRef: apiRef,
28
20
  props: props,
@@ -35,7 +27,10 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
35
27
  children: [/*#__PURE__*/_jsx(GridHeaderPlaceholder, {}), /*#__PURE__*/_jsx(GridBody, {
36
28
  ColumnHeadersComponent: DataGridProColumnHeaders,
37
29
  VirtualScrollerComponent: DataGridProVirtualScroller,
38
- children: /*#__PURE__*/_jsx(Watermark, {})
30
+ children: /*#__PURE__*/_jsx(Watermark, {
31
+ packageName: "x-data-grid-pro",
32
+ releaseInfo: releaseInfo
33
+ })
39
34
  }), /*#__PURE__*/_jsx(GridFooterPlaceholder, {})]
40
35
  })
41
36
  })
@@ -274,6 +269,7 @@ DataGridProRaw.propTypes = {
274
269
  * For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
275
270
  */
276
271
  experimentalFeatures: PropTypes.shape({
272
+ newEditingApi: PropTypes.bool,
277
273
  preventCommitWhileValidating: PropTypes.bool,
278
274
  rowGrouping: PropTypes.bool,
279
275
  warnIfFocusStateIsNotSynced: PropTypes.bool
@@ -357,7 +353,8 @@ DataGridProRaw.propTypes = {
357
353
  * Determines the path of a row in the tree data.
358
354
  * For instance, a row with the path ["A", "B"] is the child of the row with the path ["A"].
359
355
  * Note that all paths must contain at least one element.
360
- * @param {GridRowModel} row The row from which we want the path.
356
+ * @template R
357
+ * @param {R} row The row from which we want the path.
361
358
  * @returns {string[]} The path to the row.
362
359
  */
363
360
  getTreeDataPath: PropTypes.func,
@@ -621,7 +618,7 @@ DataGridProRaw.propTypes = {
621
618
  * @param {GridEditCellPropsParams} params With all properties from [[GridEditCellPropsParams]].
622
619
  * @param {MuiEvent<React.SyntheticEvent>} event The event that caused this prop to be called.
623
620
  * @param {GridCallbackDetails} details Additional details for this callback.
624
- * @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/api/data-grid/grid-col-def/)
621
+ * @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/x/api/data-grid/grid-col-def/)
625
622
  */
626
623
  onEditCellPropsChange: PropTypes.func,
627
624
 
@@ -668,6 +665,28 @@ DataGridProRaw.propTypes = {
668
665
  */
669
666
  onPinnedColumnsChange: PropTypes.func,
670
667
 
668
+ /**
669
+ * Callback fired when the preferences panel is closed.
670
+ * @param {GridPreferencePanelParams} params With all properties from [[GridPreferencePanelParams]].
671
+ * @param {MuiEvent<{}>} event The event object.
672
+ * @param {GridCallbackDetails} details Additional details for this callback.
673
+ */
674
+ onPreferencePanelClose: PropTypes.func,
675
+
676
+ /**
677
+ * Callback fired when the preferences panel is opened.
678
+ * @param {GridPreferencePanelParams} params With all properties from [[GridPreferencePanelParams]].
679
+ * @param {MuiEvent<{}>} event The event object.
680
+ * @param {GridCallbackDetails} details Additional details for this callback.
681
+ */
682
+ onPreferencePanelOpen: PropTypes.func,
683
+
684
+ /**
685
+ * Callback called when `processRowUpdate` throws an error or rejects.
686
+ * @param {any} error The error thrown.
687
+ */
688
+ onProcessRowUpdateError: PropTypes.func,
689
+
671
690
  /**
672
691
  * Callback fired when the grid is resized.
673
692
  * @param {ElementSize} containerSize With all properties from [[ElementSize]].
@@ -787,6 +806,16 @@ DataGridProRaw.propTypes = {
787
806
  right: PropTypes.arrayOf(PropTypes.string)
788
807
  }),
789
808
 
809
+ /**
810
+ * Callback called before updating a row with new values in the row and cell editing.
811
+ * Only applied if `props.experimentalFeatures.newEditingApi: true`.
812
+ * @template R
813
+ * @param {R} newRow Row object with the new values.
814
+ * @param {R} oldRow Row object with the old values.
815
+ * @returns {Promise<R> | R} The final values to update the row.
816
+ */
817
+ processRowUpdate: PropTypes.func,
818
+
790
819
  /**
791
820
  * Number of extra rows to be rendered before/after the visible slice.
792
821
  * @default 3
@@ -820,7 +849,7 @@ DataGridProRaw.propTypes = {
820
849
  /**
821
850
  * Set of rows of type [[GridRowsProp]].
822
851
  */
823
- rows: PropTypes.arrayOf(PropTypes.object).isRequired,
852
+ rows: PropTypes.array.isRequired,
824
853
 
825
854
  /**
826
855
  * Sets the type of space between rows added by `getRowSpacing`.
@@ -1,4 +1,4 @@
1
- import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboard, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, useGridRows, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, editingStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, selectionStateInitializer } from '@mui/x-data-grid/internals';
1
+ import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing_new, useGridEditing_old, editingStateInitializer_old, editingStateInitializer_new, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, useGridColumnSpanning, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, selectionStateInitializer } from '@mui/x-data-grid/internals';
2
2
  // Pro-only features
3
3
  import { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
4
4
  import { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
@@ -13,6 +13,8 @@ import { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/featur
13
13
  import { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
14
14
  import { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
15
15
  export const useDataGridProComponent = (inputApiRef, props) => {
16
+ var _props$experimentalFe, _props$experimentalFe2;
17
+
16
18
  const apiRef = useGridInitialization(inputApiRef, props);
17
19
  /**
18
20
  * Register all pre-processors called during state initialization here.
@@ -21,25 +23,22 @@ export const useDataGridProComponent = (inputApiRef, props) => {
21
23
  useGridSelectionPreProcessors(apiRef, props);
22
24
  useGridRowGroupingPreProcessors(apiRef, props);
23
25
  useGridTreeDataPreProcessors(apiRef, props);
24
- useGridDetailPanelPreProcessors(apiRef, props);
25
- useGridColumnPinningPreProcessors(apiRef, props); // Must be the last because it changes the order of the columns.
26
+ useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
27
+ // Because it changes the order of the columns.
26
28
 
29
+ useGridColumnPinningPreProcessors(apiRef, props);
30
+ useGridRowsPreProcessors(apiRef);
27
31
  /**
28
32
  * Register all state initializers here.
29
33
  */
30
34
 
35
+ useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
31
36
  useGridInitializeState(selectionStateInitializer, apiRef, props);
32
37
  useGridInitializeState(detailPanelStateInitializer, apiRef, props);
33
38
  useGridInitializeState(columnPinningStateInitializer, apiRef, props);
34
- useGridInitializeState(rowGroupingStateInitializer, apiRef, props); // FIXME Call in the same relative position that useGridRowGrouping is called
35
-
36
39
  useGridInitializeState(columnsStateInitializer, apiRef, props);
37
- useGridRowGrouping(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
38
-
39
- useGridTreeData(apiRef, props); // FIXME Needs to be called before the rows state initialization because it registers a rows group builder
40
-
41
40
  useGridInitializeState(rowsStateInitializer, apiRef, props);
42
- useGridInitializeState(editingStateInitializer, apiRef, props);
41
+ useGridInitializeState((_props$experimentalFe = props.experimentalFeatures) != null && _props$experimentalFe.newEditingApi ? editingStateInitializer_new : editingStateInitializer_old, apiRef, props);
43
42
  useGridInitializeState(focusStateInitializer, apiRef, props);
44
43
  useGridInitializeState(sortingStateInitializer, apiRef, props);
45
44
  useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
@@ -50,18 +49,23 @@ export const useDataGridProComponent = (inputApiRef, props) => {
50
49
  useGridInitializeState(paginationStateInitializer, apiRef, props);
51
50
  useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
52
51
  useGridInitializeState(columnMenuStateInitializer, apiRef, props);
52
+ useGridRowGrouping(apiRef, props);
53
+ useGridTreeData(apiRef);
54
+ useGridKeyboardNavigation(apiRef, props);
53
55
  useGridSelection(apiRef, props);
54
56
  useGridDetailPanel(apiRef, props);
55
57
  useGridColumnPinning(apiRef, props);
56
58
  useGridColumns(apiRef, props);
57
59
  useGridRows(apiRef, props);
58
60
  useGridParamsApi(apiRef);
61
+ useGridColumnSpanning(apiRef);
59
62
  useGridDetailPanelCache(apiRef, props);
63
+ const useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
60
64
  useGridEditing(apiRef, props);
61
65
  useGridFocus(apiRef, props);
62
- useGridSorting(apiRef, props);
63
66
  useGridPreferencesPanel(apiRef);
64
67
  useGridFilter(apiRef, props);
68
+ useGridSorting(apiRef, props);
65
69
  useGridDensity(apiRef, props);
66
70
  useGridColumnReorder(apiRef, props);
67
71
  useGridColumnResize(apiRef, props);
@@ -70,8 +74,6 @@ export const useDataGridProComponent = (inputApiRef, props) => {
70
74
  useGridScroll(apiRef, props);
71
75
  useGridInfiniteLoader(apiRef, props);
72
76
  useGridColumnMenu(apiRef);
73
- useGridKeyboard(apiRef);
74
- useGridKeyboardNavigation(apiRef, props);
75
77
  useGridCsvExport(apiRef);
76
78
  useGridPrintExport(apiRef, props);
77
79
  useGridClipboard(apiRef);
@@ -1,6 +1,7 @@
1
+ import { GridValidRowModel } from '@mui/x-data-grid';
1
2
  import { DataGridProProps, DataGridProProcessedProps, DataGridProPropsWithDefaultValue } from '../models/dataGridProProps';
2
3
  /**
3
4
  * The default values of `DataGridProPropsWithDefaultValue` to inject in the props of DataGridPro.
4
5
  */
5
6
  export declare const DATA_GRID_PRO_PROPS_DEFAULT_VALUES: DataGridProPropsWithDefaultValue;
6
- export declare const useDataGridProProps: (inProps: DataGridProProps) => DataGridProProcessedProps;
7
+ export declare const useDataGridProProps: <R extends GridValidRowModel>(inProps: DataGridProProps<R>) => DataGridProProcessedProps<R>;
package/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Commercial License
2
+
3
+ Copyright (c) 2020 Material-UI SAS
4
+
5
+ MUI X Pro (https://mui.com/pricing/) is commercial software. You must purchase
6
+ a license and agree to the End User License Agreement (EULA: https://mui.com/x/license/)
7
+ to be able to use the software.
8
+
9
+ Commercial licenses can be obtained at https://mui.com/store/items/material-ui-pro/.
10
+ You are free to install and try the software without a license key as long as it
11
+ is not used for the development of a feature intended for production use. You can
12
+ find more details under the "Evaluation (trial) licenses" section of the EULA.
package/README.md CHANGED
@@ -26,4 +26,4 @@ This component has three peer dependencies that you will need to install as well
26
26
 
27
27
  ## Documentation
28
28
 
29
- [The documentation](https://mui.com/components/data-grid/)
29
+ [The documentation](https://mui.com/x/react-data-grid/)
@@ -93,7 +93,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
93
93
  const {
94
94
  isDragging,
95
95
  renderContext,
96
- updateInnerPosition,
97
96
  getRootProps,
98
97
  getInnerProps,
99
98
  getColumns
@@ -107,11 +106,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
107
106
  classes: rootProps.classes
108
107
  };
109
108
  const classes = useUtilityClasses(ownerState);
110
- React.useEffect(() => {
111
- if (renderContext) {
112
- updateInnerPosition(renderContext);
113
- }
114
- }, [renderContext, updateInnerPosition]);
115
109
  const leftRenderContext = renderContext && leftPinnedColumns.length ? _extends({}, renderContext, {
116
110
  firstColumnIndex: 0,
117
111
  lastColumnIndex: leftPinnedColumns.length
@@ -136,7 +130,15 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
136
130
  }, {
137
131
  disableReorder: true
138
132
  })
139
- }), rightRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, {
133
+ }), /*#__PURE__*/_jsx(GridColumnHeadersInner, _extends({
134
+ isDragging: isDragging
135
+ }, getInnerProps(), {
136
+ children: getColumns({
137
+ renderContext,
138
+ minFirstColumn: leftPinnedColumns.length,
139
+ maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
140
+ })
141
+ })), rightRenderContext && /*#__PURE__*/_jsx(GridColumnHeadersPinnedColumnHeaders, {
140
142
  ownerState: {
141
143
  side: GridPinnedPosition.right
142
144
  },
@@ -152,14 +154,6 @@ export const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function D
152
154
  disableReorder: true,
153
155
  separatorSide: GridColumnHeaderSeparatorSides.Left
154
156
  })
155
- }), /*#__PURE__*/_jsx(GridColumnHeadersInner, _extends({
156
- isDragging: isDragging
157
- }, getInnerProps(), {
158
- children: getColumns({
159
- renderContext,
160
- minFirstColumn: leftPinnedColumns.length,
161
- maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
162
- })
163
- }))]
157
+ })]
164
158
  }));
165
159
  });
@@ -175,9 +175,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
175
175
  }, [renderContext, updateRenderZonePosition]);
176
176
  useGridApiEventHandler(apiRef, GridEvents.columnWidthChange, refreshRenderZonePosition);
177
177
  useGridApiEventHandler(apiRef, GridEvents.columnOrderChange, refreshRenderZonePosition);
178
- React.useEffect(() => {
179
- refreshRenderZonePosition();
180
- }, [refreshRenderZonePosition]);
181
178
  const leftRenderContext = renderContext && leftPinnedColumns.length > 0 ? _extends({}, renderContext, {
182
179
  firstColumnIndex: 0,
183
180
  lastColumnIndex: leftPinnedColumns.length
@@ -243,7 +240,11 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
243
240
  maxLastColumn: leftRenderContext.lastColumnIndex,
244
241
  availableSpace: 0
245
242
  })
246
- }), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
243
+ }), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
244
+ children: getRows({
245
+ renderContext
246
+ })
247
+ })), rightRenderContext && /*#__PURE__*/_jsx(VirtualScrollerPinnedColumns, {
247
248
  ref: rightColumns,
248
249
  ownerState: {
249
250
  side: GridPinnedPosition.right
@@ -256,11 +257,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
256
257
  maxLastColumn: rightRenderContext.lastColumnIndex,
257
258
  availableSpace: 0
258
259
  })
259
- }), /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
260
- children: getRows({
261
- renderContext
262
- })
263
- })), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
260
+ }), detailPanels.length > 0 && /*#__PURE__*/_jsx(VirtualScrollerDetailPanels, {
264
261
  className: classes.detailPanels,
265
262
  children: detailPanels
266
263
  })]
@@ -73,16 +73,27 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
73
73
  */
74
74
  field: PropTypes.string.isRequired,
75
75
 
76
+ /**
77
+ * A ref allowing to set imperative focus.
78
+ * It can be passed to the element that should receive focus.
79
+ * @ignore - do not document.
80
+ */
81
+ focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
82
+ current: PropTypes.shape({
83
+ focus: PropTypes.func.isRequired
84
+ })
85
+ })]),
86
+
76
87
  /**
77
88
  * The cell value formatted with the column valueFormatter.
78
89
  */
79
- formattedValue: PropTypes.any.isRequired,
90
+ formattedValue: PropTypes.any,
80
91
 
81
92
  /**
82
93
  * Get the cell value of a row and field.
83
94
  * @param {GridRowId} id The row id.
84
95
  * @param {string} field The field.
85
- * @returns {GridCellValue} The cell value.
96
+ * @returns {any} The cell value.
86
97
  * @deprecated Use `params.row` to directly access the fields you want instead.
87
98
  */
88
99
  getValue: PropTypes.func.isRequired,
@@ -105,7 +116,7 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
105
116
  /**
106
117
  * The row model of the row that the current cell belongs to.
107
118
  */
108
- row: PropTypes.any.isRequired,
119
+ row: PropTypes.object.isRequired,
109
120
 
110
121
  /**
111
122
  * The node of the row that the current cell belongs to.
@@ -120,6 +131,6 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
120
131
  /**
121
132
  * The cell value, but if the column has valueGetter, use getValue.
122
133
  */
123
- value: PropTypes.any.isRequired
134
+ value: PropTypes.any
124
135
  } : void 0;
125
136
  export { GridDetailPanelToggleCell };
@@ -3,8 +3,5 @@ import { GridRenderCellParams } from '@mui/x-data-grid';
3
3
  interface GridGroupingCriteriaCellProps extends GridRenderCellParams {
4
4
  hideDescendantCount?: boolean;
5
5
  }
6
- declare const GridGroupingCriteriaCell: {
7
- (props: GridGroupingCriteriaCellProps): JSX.Element;
8
- propTypes: any;
9
- };
10
- export { GridGroupingCriteriaCell };
6
+ export declare const GridGroupingCriteriaCell: (props: GridGroupingCriteriaCellProps) => JSX.Element;
7
+ export {};
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { unstable_composeClasses as composeClasses } from '@mui/material';
4
3
  import IconButton from '@mui/material/IconButton';
5
4
  import Box from '@mui/material/Box';
@@ -20,7 +19,7 @@ const useUtilityClasses = ownerState => {
20
19
  return composeClasses(slots, getDataGridUtilityClass, classes);
21
20
  };
22
21
 
23
- const GridGroupingCriteriaCell = props => {
22
+ export const GridGroupingCriteriaCell = props => {
24
23
  var _filteredDescendantCo;
25
24
 
26
25
  const {
@@ -76,75 +75,4 @@ const GridGroupingCriteriaCell = props => {
76
75
  children: [formattedValue === undefined ? rowNode.groupingKey : formattedValue, !hideDescendantCount && filteredDescendantCount > 0 ? ` (${filteredDescendantCount})` : '']
77
76
  })]
78
77
  });
79
- };
80
-
81
- process.env.NODE_ENV !== "production" ? GridGroupingCriteriaCell.propTypes = {
82
- // ----------------------------- Warning --------------------------------
83
- // | These PropTypes are generated from the TypeScript type definitions |
84
- // | To update them edit the TypeScript types and run "yarn proptypes" |
85
- // ----------------------------------------------------------------------
86
-
87
- /**
88
- * GridApi that let you manipulate the grid.
89
- */
90
- api: PropTypes.any.isRequired,
91
-
92
- /**
93
- * The mode of the cell.
94
- */
95
- cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
96
-
97
- /**
98
- * The column of the row that the current cell belongs to.
99
- */
100
- colDef: PropTypes.object.isRequired,
101
-
102
- /**
103
- * The column field of the cell that triggered the event.
104
- */
105
- field: PropTypes.string.isRequired,
106
-
107
- /**
108
- * The cell value formatted with the column valueFormatter.
109
- */
110
- formattedValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool]),
111
-
112
- /**
113
- * Get the cell value of a row and field.
114
- * @param {GridRowId} id The row id.
115
- * @param {string} field The field.
116
- * @returns {GridCellValue} The cell value.
117
- */
118
- getValue: PropTypes.func.isRequired,
119
-
120
- /**
121
- * If true, the cell is the active element.
122
- */
123
- hasFocus: PropTypes.bool.isRequired,
124
-
125
- /**
126
- * The grid row id.
127
- */
128
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
129
-
130
- /**
131
- * If true, the cell is editable.
132
- */
133
- isEditable: PropTypes.bool,
134
-
135
- /**
136
- * The row model of the row that the current cell belongs to.
137
- */
138
- row: PropTypes.object.isRequired,
139
-
140
- /**
141
- * the tabIndex value.
142
- */
143
- tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
144
-
145
- /**
146
- * The cell value, but if the column has valueGetter, use getValue.
147
- */
148
- value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool])
149
- } : void 0;
150
- export { GridGroupingCriteriaCell };
78
+ };
@@ -107,16 +107,27 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
107
107
  */
108
108
  field: PropTypes.string.isRequired,
109
109
 
110
+ /**
111
+ * A ref allowing to set imperative focus.
112
+ * It can be passed to the element that should receive focus.
113
+ * @ignore - do not document.
114
+ */
115
+ focusElementRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
116
+ current: PropTypes.shape({
117
+ focus: PropTypes.func.isRequired
118
+ })
119
+ })]),
120
+
110
121
  /**
111
122
  * The cell value formatted with the column valueFormatter.
112
123
  */
113
- formattedValue: PropTypes.any.isRequired,
124
+ formattedValue: PropTypes.any,
114
125
 
115
126
  /**
116
127
  * Get the cell value of a row and field.
117
128
  * @param {GridRowId} id The row id.
118
129
  * @param {string} field The field.
119
- * @returns {GridCellValue} The cell value.
130
+ * @returns {any} The cell value.
120
131
  * @deprecated Use `params.row` to directly access the fields you want instead.
121
132
  */
122
133
  getValue: PropTypes.func.isRequired,
@@ -140,7 +151,7 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
140
151
  /**
141
152
  * The row model of the row that the current cell belongs to.
142
153
  */
143
- row: PropTypes.any.isRequired,
154
+ row: PropTypes.object.isRequired,
144
155
 
145
156
  /**
146
157
  * The node of the row that the current cell belongs to.
@@ -155,6 +166,6 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
155
166
  /**
156
167
  * The cell value, but if the column has valueGetter, use getValue.
157
168
  */
158
- value: PropTypes.any.isRequired
169
+ value: PropTypes.any
159
170
  } : void 0;
160
171
  export { GridTreeDataGroupingCell };
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import MuiDivider from '@mui/material/Divider';
4
4
  import { useGridSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector, gridVisibleColumnFieldsSelector, gridClasses, GridEvents, useGridApiMethod, useGridApiEventHandler } from '@mui/x-data-grid';
5
- import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
5
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
6
6
  import { GridColumnPinningMenuItems } from '../../../components/GridColumnPinningMenuItems';
7
7
  import { GridPinnedPosition } from './gridColumnPinningInterface';
8
8
  import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
@@ -181,11 +181,11 @@ export const useGridColumnPinning = (apiRef, props) => {
181
181
 
182
182
  return params;
183
183
  }, [apiRef]);
184
- useGridRegisterPreProcessor(apiRef, 'scrollToIndexes', calculateScrollLeft);
185
- useGridRegisterPreProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
186
- useGridRegisterPreProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
187
- useGridRegisterPreProcessor(apiRef, 'exportState', stateExportPreProcessing);
188
- useGridRegisterPreProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
184
+ useGridRegisterPipeProcessor(apiRef, 'scrollToIndexes', calculateScrollLeft);
185
+ useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
186
+ useGridRegisterPipeProcessor(apiRef, 'canBeReordered', checkIfCanBeReordered);
187
+ useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
188
+ useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
189
189
  apiRef.current.unstable_updateControlState({
190
190
  stateId: 'pinnedColumns',
191
191
  propModel: props.pinnedColumns,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { useGridRegisterPreProcessor } from '@mui/x-data-grid/internals';
3
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
4
4
  import { gridPinnedColumnsSelector } from './gridColumnPinningSelector';
5
5
  import { columnPinningStateInitializer } from './useGridColumnPinning';
6
6
  import { filterColumns } from '../../../components/DataGridProVirtualScroller';
@@ -41,5 +41,5 @@ export const useGridColumnPinningPreProcessors = (apiRef, props) => {
41
41
  all: [...leftPinnedColumns, ...centerColumns, ...rightPinnedColumns]
42
42
  });
43
43
  }, [disableColumnPinning, pinnedColumns]);
44
- useGridRegisterPreProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
44
+ useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', reorderPinnedColumns);
45
45
  };
@@ -116,7 +116,7 @@ export const useGridColumnReorder = (apiRef, props) => {
116
116
  canBeReordered = targetColIndex < visibleColumns.length - 1 && !visibleColumns[targetColIndex + 1].disableReorder;
117
117
  }
118
118
 
119
- const canBeReorderedProcessed = apiRef.current.unstable_applyPreProcessors('canBeReordered', canBeReordered, {
119
+ const canBeReorderedProcessed = apiRef.current.unstable_applyPipeProcessors('canBeReordered', canBeReordered, {
120
120
  targetIndex: targetColVisibleIndex
121
121
  });
122
122
 
@@ -100,17 +100,29 @@ export const useGridColumnResize = (apiRef, props) => {
100
100
 
101
101
  const updateWidth = newWidth => {
102
102
  logger.debug(`Updating width to ${newWidth} for col ${colDefRef.current.field}`);
103
+ const prevWidth = colElementRef.current.offsetWidth;
104
+ const widthDiff = newWidth - prevWidth;
103
105
  colDefRef.current.computedWidth = newWidth;
104
106
  colDefRef.current.width = newWidth;
105
- colDefRef.current.flex = undefined;
107
+ colDefRef.current.flex = 0;
106
108
  colElementRef.current.style.width = `${newWidth}px`;
107
109
  colElementRef.current.style.minWidth = `${newWidth}px`;
108
110
  colElementRef.current.style.maxWidth = `${newWidth}px`;
109
111
  colCellElementsRef.current.forEach(element => {
110
112
  const div = element;
111
- div.style.width = `${newWidth}px`;
112
- div.style.minWidth = `${newWidth}px`;
113
- div.style.maxWidth = `${newWidth}px`;
113
+ let finalWidth;
114
+
115
+ if (div.getAttribute('aria-colspan') === '1') {
116
+ finalWidth = `${newWidth}px`;
117
+ } else {
118
+ // Cell with colspan > 1 cannot be just updated width new width.
119
+ // Instead, we add width diff to the current width.
120
+ finalWidth = `${div.offsetWidth + widthDiff}px`;
121
+ }
122
+
123
+ div.style.width = finalWidth;
124
+ div.style.minWidth = finalWidth;
125
+ div.style.maxWidth = finalWidth;
114
126
  });
115
127
  };
116
128
 
@@ -174,7 +186,7 @@ export const useGridColumnResize = (apiRef, props) => {
174
186
  }, event);
175
187
  colDefRef.current = colDef;
176
188
  colElementRef.current = (_apiRef$current$colum = apiRef.current.columnHeadersContainerElementRef) == null ? void 0 : _apiRef$current$colum.current.querySelector(`[data-field="${colDef.field}"]`);
177
- colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
189
+ colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
178
190
  const doc = ownerDocument(apiRef.current.rootElementRef.current);
179
191
  doc.body.style.cursor = 'col-resize';
180
192
  separatorSide.current = getSeparatorSide(event.currentTarget);
@@ -251,7 +263,7 @@ export const useGridColumnResize = (apiRef, props) => {
251
263
  }, event);
252
264
  colDefRef.current = colDef;
253
265
  colElementRef.current = findHeaderElementFromField((_apiRef$current$colum2 = apiRef.current.columnHeadersElementRef) == null ? void 0 : _apiRef$current$colum2.current, colDef.field);
254
- colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
266
+ colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
255
267
  separatorSide.current = getSeparatorSide(event.target);
256
268
  initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
257
269
  const doc = ownerDocument(event.currentTarget);