@mui/x-data-grid-pro 7.0.0-beta.6 → 7.0.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 (103) hide show
  1. package/CHANGELOG.md +311 -12
  2. package/DataGridPro/DataGridPro.js +18 -18
  3. package/DataGridPro/useDataGridProComponent.js +2 -3
  4. package/README.md +1 -1
  5. package/components/GridColumnHeaders.d.ts +1 -2
  6. package/components/GridColumnHeaders.js +7 -164
  7. package/components/headerFiltering/GridHeaderFilterCell.d.ts +8 -1
  8. package/components/headerFiltering/GridHeaderFilterCell.js +26 -9
  9. package/esm/DataGridPro/DataGridPro.js +18 -18
  10. package/esm/DataGridPro/useDataGridProComponent.js +1 -2
  11. package/esm/components/GridColumnHeaders.js +9 -166
  12. package/esm/components/GridDetailPanelToggleCell.js +1 -2
  13. package/esm/components/GridTreeDataGroupingCell.js +2 -3
  14. package/esm/components/headerFiltering/GridHeaderFilterCell.js +39 -26
  15. package/esm/components/headerFiltering/GridHeaderFilterClearButton.js +1 -2
  16. package/esm/components/headerFiltering/GridHeaderFilterMenu.js +1 -2
  17. package/esm/components/headerFiltering/GridHeaderFilterMenuContainer.js +1 -2
  18. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +49 -16
  19. package/esm/hooks/features/columnPinning/useGridColumnPinning.js +7 -10
  20. package/esm/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -0
  21. package/esm/hooks/features/columnReorder/useGridColumnReorder.js +2 -4
  22. package/esm/hooks/features/detailPanel/useGridDetailPanel.js +5 -10
  23. package/esm/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -2
  24. package/esm/hooks/features/index.js +0 -1
  25. package/esm/hooks/features/infiniteLoader/useGridInfiniteLoader.js +6 -10
  26. package/esm/hooks/features/lazyLoader/useGridLazyLoader.js +3 -23
  27. package/esm/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +2 -6
  28. package/esm/hooks/features/rowPinning/useGridRowPinning.js +3 -5
  29. package/esm/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +5 -7
  30. package/esm/hooks/features/treeData/gridTreeDataGroupColDef.js +1 -1
  31. package/esm/hooks/features/treeData/gridTreeDataUtils.js +1 -2
  32. package/esm/hooks/features/treeData/useGridTreeDataPreProcessors.js +1 -2
  33. package/esm/internals/index.js +0 -1
  34. package/esm/utils/releaseInfo.js +1 -1
  35. package/esm/utils/tree/insertDataRowInTree.js +8 -9
  36. package/esm/utils/tree/removeDataRowFromTree.js +3 -3
  37. package/esm/utils/tree/sortRowTree.js +1 -1
  38. package/esm/utils/tree/updateRowTree.js +1 -1
  39. package/esm/utils/tree/utils.js +6 -9
  40. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +3 -5
  41. package/hooks/features/columnHeaders/useGridColumnHeaders.js +44 -11
  42. package/hooks/features/columnPinning/useGridColumnPinning.js +3 -3
  43. package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -0
  44. package/hooks/features/detailPanel/useGridDetailPanel.js +1 -1
  45. package/hooks/features/index.d.ts +0 -1
  46. package/hooks/features/index.js +0 -11
  47. package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
  48. package/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
  49. package/hooks/features/lazyLoader/useGridLazyLoader.js +1 -19
  50. package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +2 -5
  51. package/index.js +1 -1
  52. package/internals/index.d.ts +0 -1
  53. package/internals/index.js +0 -15
  54. package/models/dataGridProProps.d.ts +3 -36
  55. package/models/dataSource.d.ts +1 -1
  56. package/models/gridApiPro.d.ts +4 -4
  57. package/models/gridStatePro.d.ts +1 -2
  58. package/modern/DataGridPro/DataGridPro.js +18 -18
  59. package/modern/DataGridPro/useDataGridProComponent.js +1 -2
  60. package/modern/components/GridColumnHeaders.js +9 -166
  61. package/modern/components/headerFiltering/GridHeaderFilterCell.js +27 -10
  62. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +46 -12
  63. package/modern/hooks/features/columnPinning/useGridColumnPinning.js +3 -3
  64. package/modern/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +2 -0
  65. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +1 -1
  66. package/modern/hooks/features/index.js +0 -1
  67. package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
  68. package/modern/hooks/features/lazyLoader/useGridLazyLoader.js +1 -19
  69. package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +2 -5
  70. package/modern/index.js +1 -1
  71. package/modern/internals/index.js +0 -1
  72. package/modern/utils/releaseInfo.js +1 -1
  73. package/package.json +6 -6
  74. package/typeOverloads/modules.d.ts +3 -3
  75. package/utils/releaseInfo.js +1 -1
  76. package/components/GridScrollArea.d.ts +0 -10
  77. package/components/GridScrollArea.js +0 -145
  78. package/esm/components/GridScrollArea.js +0 -137
  79. package/esm/hooks/features/columnResize/columnResizeSelector.js +0 -3
  80. package/esm/hooks/features/columnResize/columnResizeState.js +0 -1
  81. package/esm/hooks/features/columnResize/gridColumnResizeApi.js +0 -10
  82. package/esm/hooks/features/columnResize/index.js +0 -3
  83. package/esm/hooks/features/columnResize/useGridColumnResize.js +0 -547
  84. package/esm/utils/domUtils.js +0 -109
  85. package/hooks/features/columnResize/columnResizeSelector.d.ts +0 -3
  86. package/hooks/features/columnResize/columnResizeSelector.js +0 -10
  87. package/hooks/features/columnResize/columnResizeState.d.ts +0 -3
  88. package/hooks/features/columnResize/columnResizeState.js +0 -5
  89. package/hooks/features/columnResize/gridColumnResizeApi.d.ts +0 -44
  90. package/hooks/features/columnResize/gridColumnResizeApi.js +0 -16
  91. package/hooks/features/columnResize/index.d.ts +0 -3
  92. package/hooks/features/columnResize/index.js +0 -38
  93. package/hooks/features/columnResize/useGridColumnResize.d.ts +0 -10
  94. package/hooks/features/columnResize/useGridColumnResize.js +0 -548
  95. package/modern/components/GridScrollArea.js +0 -137
  96. package/modern/hooks/features/columnResize/columnResizeSelector.js +0 -3
  97. package/modern/hooks/features/columnResize/columnResizeState.js +0 -1
  98. package/modern/hooks/features/columnResize/gridColumnResizeApi.js +0 -10
  99. package/modern/hooks/features/columnResize/index.js +0 -3
  100. package/modern/hooks/features/columnResize/useGridColumnResize.js +0 -537
  101. package/modern/utils/domUtils.js +0 -107
  102. package/utils/domUtils.d.ts +0 -11
  103. package/utils/domUtils.js +0 -121
@@ -1,145 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.GridScrollArea = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var React = _interopRequireWildcard(require("react"));
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
- var _clsx = _interopRequireDefault(require("clsx"));
12
- var _utils = require("@mui/utils");
13
- var _system = require("@mui/system");
14
- var _internals = require("@mui/x-data-grid/internals");
15
- var _xDataGrid = require("@mui/x-data-grid");
16
- var _useGridRootProps = require("../hooks/utils/useGridRootProps");
17
- var _jsxRuntime = require("react/jsx-runtime");
18
- 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); }
19
- 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 && Object.prototype.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; }
20
- const CLIFF = 1;
21
- const SLOP = 1.5;
22
- const useUtilityClasses = ownerState => {
23
- const {
24
- scrollDirection,
25
- classes
26
- } = ownerState;
27
- const slots = {
28
- root: ['scrollArea', `scrollArea--${scrollDirection}`]
29
- };
30
- return (0, _utils.unstable_composeClasses)(slots, _xDataGrid.getDataGridUtilityClass, classes);
31
- };
32
- const GridScrollAreaRawRoot = (0, _system.styled)('div', {
33
- name: 'MuiDataGrid',
34
- slot: 'ScrollArea',
35
- overridesResolver: (props, styles) => [{
36
- [`&.${_xDataGrid.gridClasses['scrollArea--left']}`]: styles['scrollArea--left']
37
- }, {
38
- [`&.${_xDataGrid.gridClasses['scrollArea--right']}`]: styles['scrollArea--right']
39
- }, styles.scrollArea]
40
- })(() => ({
41
- position: 'absolute',
42
- top: 0,
43
- zIndex: 101,
44
- width: 20,
45
- bottom: 0,
46
- [`&.${_xDataGrid.gridClasses['scrollArea--left']}`]: {
47
- left: 0
48
- },
49
- [`&.${_xDataGrid.gridClasses['scrollArea--right']}`]: {
50
- right: 0
51
- }
52
- }));
53
- function GridScrollAreaRaw(props) {
54
- const {
55
- scrollDirection
56
- } = props;
57
- const rootRef = React.useRef(null);
58
- const apiRef = (0, _xDataGrid.useGridApiContext)();
59
- const timeout = (0, _internals.useTimeout)();
60
- const densityFactor = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridDensityFactorSelector);
61
- const columnsTotalWidth = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridColumnsTotalWidthSelector);
62
- const scrollPosition = React.useRef({
63
- left: 0,
64
- top: 0
65
- });
66
- const getCanScrollMore = () => {
67
- if (scrollDirection === 'left') {
68
- // Only render if the user has not reached yet the start of the list
69
- return scrollPosition.current.left > 0;
70
- }
71
- if (scrollDirection === 'right') {
72
- const dimensions = apiRef.current.getRootDimensions();
73
-
74
- // Only render if the user has not reached yet the end of the list
75
- const maxScrollLeft = columnsTotalWidth - dimensions.viewportInnerSize.width;
76
- return scrollPosition.current.left < maxScrollLeft;
77
- }
78
- return false;
79
- };
80
- const [dragging, setDragging] = React.useState(false);
81
- const [canScrollMore, setCanScrollMore] = React.useState(getCanScrollMore);
82
- const rootProps = (0, _useGridRootProps.useGridRootProps)();
83
- const ownerState = (0, _extends2.default)({}, rootProps, {
84
- scrollDirection
85
- });
86
- const classes = useUtilityClasses(ownerState);
87
- const totalHeaderHeight = (0, _internals.getTotalHeaderHeight)(apiRef, rootProps.columnHeaderHeight);
88
- const headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
89
- const handleScrolling = newScrollPosition => {
90
- scrollPosition.current = newScrollPosition;
91
- setCanScrollMore(getCanScrollMore);
92
- };
93
- const handleDragOver = (0, _utils.unstable_useEventCallback)(event => {
94
- let offset;
95
-
96
- // Prevents showing the forbidden cursor
97
- event.preventDefault();
98
- if (scrollDirection === 'left') {
99
- offset = event.clientX - rootRef.current.getBoundingClientRect().right;
100
- } else if (scrollDirection === 'right') {
101
- offset = Math.max(1, event.clientX - rootRef.current.getBoundingClientRect().left);
102
- } else {
103
- throw new Error('MUI X: Wrong drag direction');
104
- }
105
- offset = (offset - CLIFF) * SLOP + CLIFF;
106
-
107
- // Avoid freeze and inertia.
108
- timeout.start(0, () => {
109
- apiRef.current.scroll({
110
- left: scrollPosition.current.left + offset,
111
- top: scrollPosition.current.top
112
- });
113
- });
114
- });
115
- const handleColumnHeaderDragStart = (0, _utils.unstable_useEventCallback)(() => {
116
- setDragging(true);
117
- });
118
- const handleColumnHeaderDragEnd = (0, _utils.unstable_useEventCallback)(() => {
119
- setDragging(false);
120
- });
121
- (0, _xDataGrid.useGridApiEventHandler)(apiRef, 'scrollPositionChange', handleScrolling);
122
- (0, _xDataGrid.useGridApiEventHandler)(apiRef, 'columnHeaderDragStart', handleColumnHeaderDragStart);
123
- (0, _xDataGrid.useGridApiEventHandler)(apiRef, 'columnHeaderDragEnd', handleColumnHeaderDragEnd);
124
- if (!dragging || !canScrollMore) {
125
- return null;
126
- }
127
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridScrollAreaRawRoot, {
128
- ref: rootRef,
129
- className: (0, _clsx.default)(classes.root),
130
- ownerState: ownerState,
131
- onDragOver: handleDragOver,
132
- style: {
133
- height: headerHeight,
134
- top: totalHeaderHeight - headerHeight
135
- }
136
- });
137
- }
138
- process.env.NODE_ENV !== "production" ? GridScrollAreaRaw.propTypes = {
139
- // ----------------------------- Warning --------------------------------
140
- // | These PropTypes are generated from the TypeScript type definitions |
141
- // | To update them edit the TypeScript types and run "yarn proptypes" |
142
- // ----------------------------------------------------------------------
143
- scrollDirection: _propTypes.default.oneOf(['left', 'right']).isRequired
144
- } : void 0;
145
- const GridScrollArea = exports.GridScrollArea = (0, _internals.fastMemo)(GridScrollAreaRaw);
@@ -1,137 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import * as React from 'react';
3
- import PropTypes from 'prop-types';
4
- import clsx from 'clsx';
5
- import { unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
6
- import { styled } from '@mui/system';
7
- import { getTotalHeaderHeight, fastMemo, useTimeout } from '@mui/x-data-grid/internals';
8
- import { getDataGridUtilityClass, gridClasses, gridDensityFactorSelector, useGridApiContext, useGridApiEventHandler, useGridSelector, gridColumnsTotalWidthSelector } from '@mui/x-data-grid';
9
- import { useGridRootProps } from '../hooks/utils/useGridRootProps';
10
- import { jsx as _jsx } from "react/jsx-runtime";
11
- const CLIFF = 1;
12
- const SLOP = 1.5;
13
- const useUtilityClasses = ownerState => {
14
- const {
15
- scrollDirection,
16
- classes
17
- } = ownerState;
18
- const slots = {
19
- root: ['scrollArea', `scrollArea--${scrollDirection}`]
20
- };
21
- return composeClasses(slots, getDataGridUtilityClass, classes);
22
- };
23
- const GridScrollAreaRawRoot = styled('div', {
24
- name: 'MuiDataGrid',
25
- slot: 'ScrollArea',
26
- overridesResolver: (props, styles) => [{
27
- [`&.${gridClasses['scrollArea--left']}`]: styles['scrollArea--left']
28
- }, {
29
- [`&.${gridClasses['scrollArea--right']}`]: styles['scrollArea--right']
30
- }, styles.scrollArea]
31
- })(() => ({
32
- position: 'absolute',
33
- top: 0,
34
- zIndex: 101,
35
- width: 20,
36
- bottom: 0,
37
- [`&.${gridClasses['scrollArea--left']}`]: {
38
- left: 0
39
- },
40
- [`&.${gridClasses['scrollArea--right']}`]: {
41
- right: 0
42
- }
43
- }));
44
- function GridScrollAreaRaw(props) {
45
- const {
46
- scrollDirection
47
- } = props;
48
- const rootRef = React.useRef(null);
49
- const apiRef = useGridApiContext();
50
- const timeout = useTimeout();
51
- const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
52
- const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
53
- const scrollPosition = React.useRef({
54
- left: 0,
55
- top: 0
56
- });
57
- const getCanScrollMore = () => {
58
- if (scrollDirection === 'left') {
59
- // Only render if the user has not reached yet the start of the list
60
- return scrollPosition.current.left > 0;
61
- }
62
- if (scrollDirection === 'right') {
63
- const dimensions = apiRef.current.getRootDimensions();
64
-
65
- // Only render if the user has not reached yet the end of the list
66
- const maxScrollLeft = columnsTotalWidth - dimensions.viewportInnerSize.width;
67
- return scrollPosition.current.left < maxScrollLeft;
68
- }
69
- return false;
70
- };
71
- const [dragging, setDragging] = React.useState(false);
72
- const [canScrollMore, setCanScrollMore] = React.useState(getCanScrollMore);
73
- const rootProps = useGridRootProps();
74
- const ownerState = _extends({}, rootProps, {
75
- scrollDirection
76
- });
77
- const classes = useUtilityClasses(ownerState);
78
- const totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps.columnHeaderHeight);
79
- const headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
80
- const handleScrolling = newScrollPosition => {
81
- scrollPosition.current = newScrollPosition;
82
- setCanScrollMore(getCanScrollMore);
83
- };
84
- const handleDragOver = useEventCallback(event => {
85
- let offset;
86
-
87
- // Prevents showing the forbidden cursor
88
- event.preventDefault();
89
- if (scrollDirection === 'left') {
90
- offset = event.clientX - rootRef.current.getBoundingClientRect().right;
91
- } else if (scrollDirection === 'right') {
92
- offset = Math.max(1, event.clientX - rootRef.current.getBoundingClientRect().left);
93
- } else {
94
- throw new Error('MUI X: Wrong drag direction');
95
- }
96
- offset = (offset - CLIFF) * SLOP + CLIFF;
97
-
98
- // Avoid freeze and inertia.
99
- timeout.start(0, () => {
100
- apiRef.current.scroll({
101
- left: scrollPosition.current.left + offset,
102
- top: scrollPosition.current.top
103
- });
104
- });
105
- });
106
- const handleColumnHeaderDragStart = useEventCallback(() => {
107
- setDragging(true);
108
- });
109
- const handleColumnHeaderDragEnd = useEventCallback(() => {
110
- setDragging(false);
111
- });
112
- useGridApiEventHandler(apiRef, 'scrollPositionChange', handleScrolling);
113
- useGridApiEventHandler(apiRef, 'columnHeaderDragStart', handleColumnHeaderDragStart);
114
- useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleColumnHeaderDragEnd);
115
- if (!dragging || !canScrollMore) {
116
- return null;
117
- }
118
- return /*#__PURE__*/_jsx(GridScrollAreaRawRoot, {
119
- ref: rootRef,
120
- className: clsx(classes.root),
121
- ownerState: ownerState,
122
- onDragOver: handleDragOver,
123
- style: {
124
- height: headerHeight,
125
- top: totalHeaderHeight - headerHeight
126
- }
127
- });
128
- }
129
- process.env.NODE_ENV !== "production" ? GridScrollAreaRaw.propTypes = {
130
- // ----------------------------- Warning --------------------------------
131
- // | These PropTypes are generated from the TypeScript type definitions |
132
- // | To update them edit the TypeScript types and run "yarn proptypes" |
133
- // ----------------------------------------------------------------------
134
- scrollDirection: PropTypes.oneOf(['left', 'right']).isRequired
135
- } : void 0;
136
- const GridScrollArea = fastMemo(GridScrollAreaRaw);
137
- export { GridScrollArea };
@@ -1,3 +0,0 @@
1
- import { createSelector } from '@mui/x-data-grid/internals';
2
- export const gridColumnResizeSelector = state => state.columnResize;
3
- export const gridResizingColumnFieldSelector = createSelector(gridColumnResizeSelector, columnResize => columnResize.resizingColumnField);
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- export const DEFAULT_GRID_AUTOSIZE_OPTIONS = {
2
- includeHeaders: true,
3
- includeOutliers: false,
4
- outliersFactor: 1.5,
5
- expand: false
6
- };
7
-
8
- /**
9
- * The Resize API interface that is available in the grid `apiRef`.
10
- */
@@ -1,3 +0,0 @@
1
- export * from './columnResizeSelector';
2
- export * from './columnResizeState';
3
- export * from './gridColumnResizeApi';