@mui/x-data-grid-pro 5.9.0 → 5.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +284 -10
- package/DataGridPro/DataGridPro.d.ts +1 -1
- package/DataGridPro/DataGridPro.js +50 -2
- package/DataGridPro/useDataGridProComponent.js +6 -2
- package/DataGridPro/useDataGridProProps.js +20 -5
- package/LICENSE +4 -4
- package/README.md +5 -4
- package/components/DataGridProColumnHeaders.js +2 -2
- package/components/DataGridProVirtualScroller.js +7 -4
- package/components/GridGroupingCriteriaCell.js +2 -2
- package/components/GridRowReorderCell.d.ts +5 -0
- package/components/GridRowReorderCell.js +72 -0
- package/components/GridTreeDataGroupingCell.js +2 -2
- package/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
- package/hooks/features/columnReorder/useGridColumnReorder.d.ts +0 -1
- package/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
- package/hooks/features/columnResize/useGridColumnResize.d.ts +0 -1
- package/hooks/features/columnResize/useGridColumnResize.js +13 -14
- package/hooks/features/detailPanel/useGridDetailPanel.js +4 -4
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
- package/hooks/features/index.d.ts +1 -1
- package/hooks/features/index.js +1 -1
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +0 -1
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +1 -1
- package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +1 -1
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +0 -2
- package/hooks/features/rowGrouping/useGridRowGrouping.js +6 -8
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
- package/hooks/features/rowReorder/gridRowReorderColDef.d.ts +2 -0
- package/hooks/features/rowReorder/gridRowReorderColDef.js +18 -0
- package/hooks/features/rowReorder/index.d.ts +1 -0
- package/hooks/features/rowReorder/index.js +1 -0
- package/hooks/features/rowReorder/useGridRowReorder.d.ts +8 -0
- package/hooks/features/rowReorder/useGridRowReorder.js +111 -0
- package/hooks/features/rowReorder/useGridRowReorderPreProcessors.d.ts +4 -0
- package/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +51 -0
- package/hooks/features/treeData/useGridTreeData.d.ts +0 -3
- package/hooks/features/treeData/useGridTreeData.js +2 -6
- package/index.d.ts +6 -1
- package/index.js +7 -3
- package/internals/index.d.ts +19 -0
- package/internals/index.js +17 -0
- package/internals/package.json +6 -0
- package/legacy/DataGridPro/DataGridPro.js +50 -2
- package/legacy/DataGridPro/useDataGridProComponent.js +6 -2
- package/legacy/DataGridPro/useDataGridProProps.js +20 -5
- package/legacy/components/DataGridProColumnHeaders.js +2 -2
- package/legacy/components/DataGridProVirtualScroller.js +7 -4
- package/legacy/components/GridGroupingCriteriaCell.js +2 -2
- package/legacy/components/GridRowReorderCell.js +74 -0
- package/legacy/components/GridTreeDataGroupingCell.js +2 -2
- package/legacy/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
- package/legacy/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +13 -14
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +4 -4
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
- package/legacy/hooks/features/index.js +1 -1
- package/legacy/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -5
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +6 -8
- package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
- package/legacy/hooks/features/rowReorder/gridRowReorderColDef.js +20 -0
- package/legacy/hooks/features/rowReorder/index.js +1 -0
- package/legacy/hooks/features/rowReorder/useGridRowReorder.js +115 -0
- package/legacy/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +52 -0
- package/legacy/hooks/features/treeData/useGridTreeData.js +2 -6
- package/legacy/index.js +7 -3
- package/legacy/internals/index.js +17 -0
- package/legacy/models/gridRowOrderChangeParams.js +1 -0
- package/legacy/models/index.js +1 -2
- package/legacy/typeOverloads/index.js +1 -0
- package/legacy/utils/index.js +1 -0
- package/legacy/utils/releaseInfo.js +1 -1
- package/legacy/utils/tree/buildRowTree.js +11 -4
- package/legacy/utils/tree/index.js +1 -0
- package/models/dataGridProProps.d.ts +36 -24
- package/models/gridApiPro.d.ts +3 -2
- package/models/gridRowOrderChangeParams.d.ts +18 -0
- package/models/gridRowOrderChangeParams.js +1 -0
- package/models/gridStatePro.d.ts +4 -3
- package/models/index.d.ts +1 -2
- package/models/index.js +1 -2
- package/modern/DataGridPro/DataGridPro.js +50 -2
- package/modern/DataGridPro/useDataGridProComponent.js +6 -2
- package/modern/DataGridPro/useDataGridProProps.js +16 -3
- package/modern/components/DataGridProColumnHeaders.js +2 -2
- package/modern/components/DataGridProVirtualScroller.js +7 -4
- package/modern/components/GridGroupingCriteriaCell.js +2 -2
- package/modern/components/GridRowReorderCell.js +72 -0
- package/modern/components/GridTreeDataGroupingCell.js +2 -2
- package/modern/hooks/features/columnPinning/useGridColumnPinning.js +4 -4
- package/modern/hooks/features/columnReorder/useGridColumnReorder.js +8 -9
- package/modern/hooks/features/columnResize/useGridColumnResize.js +13 -14
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +4 -4
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +2 -2
- package/modern/hooks/features/index.js +1 -1
- package/modern/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -5
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +6 -8
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
- package/modern/hooks/features/rowReorder/gridRowReorderColDef.js +18 -0
- package/modern/hooks/features/rowReorder/index.js +1 -0
- package/modern/hooks/features/rowReorder/useGridRowReorder.js +111 -0
- package/modern/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +51 -0
- package/modern/hooks/features/treeData/useGridTreeData.js +2 -6
- package/modern/index.js +7 -3
- package/modern/internals/index.js +17 -0
- package/modern/models/gridRowOrderChangeParams.js +1 -0
- package/modern/models/index.js +1 -2
- package/modern/typeOverloads/index.js +1 -0
- package/modern/utils/index.js +1 -0
- package/modern/utils/releaseInfo.js +1 -1
- package/modern/utils/tree/buildRowTree.js +9 -2
- package/modern/utils/tree/index.js +1 -0
- package/node/DataGridPro/DataGridPro.js +50 -2
- package/node/DataGridPro/useDataGridProComponent.js +10 -4
- package/node/DataGridPro/useDataGridProProps.js +21 -5
- package/node/components/DataGridProColumnHeaders.js +1 -1
- package/node/components/DataGridProVirtualScroller.js +6 -3
- package/node/components/GridGroupingCriteriaCell.js +1 -1
- package/node/components/GridRowReorderCell.js +92 -0
- package/node/components/GridTreeDataGroupingCell.js +1 -1
- package/node/hooks/features/columnPinning/useGridColumnPinning.js +3 -3
- package/node/hooks/features/columnReorder/useGridColumnReorder.js +7 -8
- package/node/hooks/features/columnResize/useGridColumnResize.js +12 -13
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +3 -3
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
- package/node/hooks/features/index.js +4 -4
- package/node/hooks/features/infiniteLoader/useGridInfiniteLoader.js +3 -4
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -4
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +5 -7
- package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +4 -4
- package/node/hooks/features/rowReorder/gridRowReorderColDef.js +31 -0
- package/node/hooks/features/rowReorder/index.js +18 -0
- package/node/hooks/features/rowReorder/useGridRowReorder.js +126 -0
- package/node/hooks/features/rowReorder/useGridRowReorderPreProcessors.js +70 -0
- package/node/hooks/features/treeData/useGridTreeData.js +1 -4
- package/node/index.js +45 -3
- package/node/internals/index.js +193 -0
- package/node/models/gridRowOrderChangeParams.js +5 -0
- package/node/models/index.js +4 -4
- package/node/typeOverloads/index.js +18 -0
- package/node/utils/index.js +18 -0
- package/node/utils/releaseInfo.js +1 -1
- package/node/utils/tree/buildRowTree.js +12 -2
- package/node/utils/tree/index.js +13 -0
- package/package.json +6 -5
- package/typeOverloads/index.d.ts +1 -0
- package/typeOverloads/index.js +1 -0
- package/typeOverloads/modules.d.ts +41 -15
- package/typeOverloads/package.json +6 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/package.json +6 -0
- package/utils/releaseInfo.js +1 -1
- package/utils/tree/buildRowTree.d.ts +1 -0
- package/utils/tree/buildRowTree.js +9 -2
- package/utils/tree/index.d.ts +1 -0
- package/utils/tree/index.js +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
|
-
import { useGridApiEventHandler, getDataGridUtilityClass,
|
|
4
|
+
import { useGridApiEventHandler, getDataGridUtilityClass, useGridLogger } from '@mui/x-data-grid';
|
|
5
5
|
import { gridColumnReorderDragColSelector } from './columnReorderSelector';
|
|
6
6
|
const CURSOR_MOVE_DIRECTION_LEFT = 'left';
|
|
7
7
|
const CURSOR_MOVE_DIRECTION_RIGHT = 'right';
|
|
@@ -28,7 +28,6 @@ export const columnReorderStateInitializer = state => _extends({}, state, {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
/**
|
|
31
|
-
* Only available in DataGridPro
|
|
32
31
|
* @requires useGridColumns (method)
|
|
33
32
|
*/
|
|
34
33
|
|
|
@@ -50,7 +49,7 @@ export const useGridColumnReorder = (apiRef, props) => {
|
|
|
50
49
|
clearTimeout(removeDnDStylesTimeout.current);
|
|
51
50
|
};
|
|
52
51
|
}, []);
|
|
53
|
-
const
|
|
52
|
+
const handleDragStart = React.useCallback((params, event) => {
|
|
54
53
|
if (props.disableColumnReorder || params.colDef.disableReorder) {
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
@@ -156,10 +155,10 @@ export const useGridColumnReorder = (apiRef, props) => {
|
|
|
156
155
|
}));
|
|
157
156
|
apiRef.current.forceUpdate();
|
|
158
157
|
}, [props.disableColumnReorder, logger, apiRef]);
|
|
159
|
-
useGridApiEventHandler(apiRef,
|
|
160
|
-
useGridApiEventHandler(apiRef,
|
|
161
|
-
useGridApiEventHandler(apiRef,
|
|
162
|
-
useGridApiEventHandler(apiRef,
|
|
163
|
-
useGridApiEventHandler(apiRef,
|
|
164
|
-
useGridApiEventHandler(apiRef,
|
|
158
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragStart', handleDragStart);
|
|
159
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragEnter', handleDragEnter);
|
|
160
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragOver', handleDragOver);
|
|
161
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleDragEnd);
|
|
162
|
+
useGridApiEventHandler(apiRef, 'cellDragEnter', handleDragEnter);
|
|
163
|
+
useGridApiEventHandler(apiRef, 'cellDragOver', handleDragOver);
|
|
165
164
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ownerDocument, useEventCallback } from '@mui/material/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { gridClasses, GridColumnHeaderSeparatorSides, useGridApiEventHandler, useGridApiOptionHandler, useGridNativeEventListener, useGridLogger } from '@mui/x-data-grid';
|
|
5
5
|
import { clamp, findParentElementFromClassName } from '@mui/x-data-grid/internals';
|
|
6
6
|
import { findGridCellElementsFromCol, getFieldFromHeaderElem, findHeaderElementFromField } from '../../../utils/domUtils';
|
|
7
7
|
// TODO: remove support for Safari < 13.
|
|
@@ -80,7 +80,6 @@ export const columnResizeStateInitializer = state => _extends({}, state, {
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
/**
|
|
83
|
-
* Only available in DataGridPro
|
|
84
83
|
* @requires useGridColumns (method, event)
|
|
85
84
|
* TODO: improve experience for last column
|
|
86
85
|
*/
|
|
@@ -132,10 +131,10 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
132
131
|
apiRef.current.updateColumn(colDefRef.current);
|
|
133
132
|
clearTimeout(stopResizeEventTimeout.current);
|
|
134
133
|
stopResizeEventTimeout.current = setTimeout(() => {
|
|
135
|
-
apiRef.current.publishEvent(
|
|
134
|
+
apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
|
|
136
135
|
|
|
137
136
|
if (colDefRef.current) {
|
|
138
|
-
apiRef.current.publishEvent(
|
|
137
|
+
apiRef.current.publishEvent('columnWidthChange', {
|
|
139
138
|
element: colElementRef.current,
|
|
140
139
|
colDef: colDefRef.current,
|
|
141
140
|
width: colDefRef.current?.computedWidth
|
|
@@ -159,7 +158,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
159
158
|
colDef: colDefRef.current,
|
|
160
159
|
width: newWidth
|
|
161
160
|
};
|
|
162
|
-
apiRef.current.publishEvent(
|
|
161
|
+
apiRef.current.publishEvent('columnResize', params, nativeEvent);
|
|
163
162
|
});
|
|
164
163
|
const handleColumnResizeMouseDown = useEventCallback(({
|
|
165
164
|
colDef
|
|
@@ -177,7 +176,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
177
176
|
|
|
178
177
|
event.preventDefault();
|
|
179
178
|
logger.debug(`Start Resize on col ${colDef.field}`);
|
|
180
|
-
apiRef.current.publishEvent(
|
|
179
|
+
apiRef.current.publishEvent('columnResizeStart', {
|
|
181
180
|
field: colDef.field
|
|
182
181
|
}, event);
|
|
183
182
|
colDefRef.current = colDef;
|
|
@@ -202,7 +201,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
202
201
|
apiRef.current.updateColumn(colDefRef.current);
|
|
203
202
|
clearTimeout(stopResizeEventTimeout.current);
|
|
204
203
|
stopResizeEventTimeout.current = setTimeout(() => {
|
|
205
|
-
apiRef.current.publishEvent(
|
|
204
|
+
apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
|
|
206
205
|
});
|
|
207
206
|
logger.debug(`Updating col ${colDefRef.current.field} with new width: ${colDefRef.current.width}`);
|
|
208
207
|
});
|
|
@@ -227,7 +226,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
227
226
|
colDef: colDefRef.current,
|
|
228
227
|
width: newWidth
|
|
229
228
|
};
|
|
230
|
-
apiRef.current.publishEvent(
|
|
229
|
+
apiRef.current.publishEvent('columnResize', params, nativeEvent);
|
|
231
230
|
});
|
|
232
231
|
const handleTouchStart = useEventCallback(event => {
|
|
233
232
|
const cellSeparator = findParentElementFromClassName(event.target, gridClasses['columnSeparator--resizable']); // Let the event bubble if the target is not a col separator
|
|
@@ -252,7 +251,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
252
251
|
const field = getFieldFromHeaderElem(colElementRef.current);
|
|
253
252
|
const colDef = apiRef.current.getColumn(field);
|
|
254
253
|
logger.debug(`Start Resize on col ${colDef.field}`);
|
|
255
|
-
apiRef.current.publishEvent(
|
|
254
|
+
apiRef.current.publishEvent('columnResizeStart', {
|
|
256
255
|
field
|
|
257
256
|
}, event);
|
|
258
257
|
colDefRef.current = colDef;
|
|
@@ -299,9 +298,9 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
299
298
|
useGridNativeEventListener(apiRef, () => apiRef.current.columnHeadersElementRef?.current, 'touchstart', handleTouchStart, {
|
|
300
299
|
passive: doesSupportTouchActionNone()
|
|
301
300
|
});
|
|
302
|
-
useGridApiEventHandler(apiRef,
|
|
303
|
-
useGridApiEventHandler(apiRef,
|
|
304
|
-
useGridApiEventHandler(apiRef,
|
|
305
|
-
useGridApiOptionHandler(apiRef,
|
|
306
|
-
useGridApiOptionHandler(apiRef,
|
|
301
|
+
useGridApiEventHandler(apiRef, 'columnSeparatorMouseDown', handleColumnResizeMouseDown);
|
|
302
|
+
useGridApiEventHandler(apiRef, 'columnResizeStart', handleResizeStart);
|
|
303
|
+
useGridApiEventHandler(apiRef, 'columnResizeStop', handleResizeStop);
|
|
304
|
+
useGridApiOptionHandler(apiRef, 'columnResize', props.onColumnResize);
|
|
305
|
+
useGridApiOptionHandler(apiRef, 'columnWidthChange', props.onColumnWidthChange);
|
|
307
306
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useGridSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid';
|
|
4
4
|
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
5
5
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from './gridDetailPanelToggleColDef';
|
|
6
6
|
import { gridDetailPanelExpandedRowIdsSelector, gridDetailPanelExpandedRowsContentCacheSelector, gridDetailPanelExpandedRowsHeightCacheSelector } from './gridDetailPanelSelector';
|
|
@@ -47,8 +47,8 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
47
47
|
apiRef.current.toggleDetailPanel(params.id);
|
|
48
48
|
}
|
|
49
49
|
}, [apiRef, props.getDetailPanelContent]);
|
|
50
|
-
useGridApiEventHandler(apiRef,
|
|
51
|
-
useGridApiEventHandler(apiRef,
|
|
50
|
+
useGridApiEventHandler(apiRef, 'cellClick', handleCellClick);
|
|
51
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
52
52
|
const addDetailHeight = React.useCallback((initialValue, row) => {
|
|
53
53
|
if (expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
|
|
54
54
|
return _extends({}, initialValue, {
|
|
@@ -68,7 +68,7 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
68
68
|
propModel: props.detailPanelExpandedRowIds,
|
|
69
69
|
propOnChange: props.onDetailPanelExpandedRowIdsChange,
|
|
70
70
|
stateSelector: gridDetailPanelExpandedRowIdsSelector,
|
|
71
|
-
changeEvent:
|
|
71
|
+
changeEvent: 'detailPanelsExpandedRowIdsChange'
|
|
72
72
|
});
|
|
73
73
|
const toggleDetailPanel = React.useCallback(id => {
|
|
74
74
|
if (props.getDetailPanelContent == null) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useGridApiEventHandler, gridRowIdsSelector
|
|
3
|
+
import { useGridApiEventHandler, gridRowIdsSelector } from '@mui/x-data-grid';
|
|
4
4
|
|
|
5
5
|
function cacheContentAndHeight(apiRef, getDetailPanelContent, getDetailPanelHeight) {
|
|
6
6
|
if (typeof getDetailPanelContent !== 'function') {
|
|
@@ -39,7 +39,7 @@ export const useGridDetailPanelCache = (apiRef, props) => {
|
|
|
39
39
|
});
|
|
40
40
|
apiRef.current.forceUpdate();
|
|
41
41
|
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
42
|
-
useGridApiEventHandler(apiRef,
|
|
42
|
+
useGridApiEventHandler(apiRef, 'sortedRowsSet', updateCaches);
|
|
43
43
|
const isFirstRender = React.useRef(true);
|
|
44
44
|
|
|
45
45
|
if (isFirstRender.current) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useGridSelector,
|
|
2
|
+
import { useGridSelector, useGridApiEventHandler, useGridApiOptionHandler, gridVisibleColumnDefinitionsSelector, gridRowsMetaSelector } from '@mui/x-data-grid';
|
|
3
3
|
import { useGridVisibleRows } from '@mui/x-data-grid/internals';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Only available in DataGridPro
|
|
7
6
|
* @requires useGridColumns (state)
|
|
8
7
|
* @requires useGridDimensions (method) - can be after
|
|
9
8
|
* @requires useGridScroll (method
|
|
@@ -34,7 +33,7 @@ export const useGridInfiniteLoader = (apiRef, props) => {
|
|
|
34
33
|
viewportPageSize,
|
|
35
34
|
virtualRowsCount: currentPage.rows.length
|
|
36
35
|
};
|
|
37
|
-
apiRef.current.publishEvent(
|
|
36
|
+
apiRef.current.publishEvent('rowsScrollEnd', rowScrollEndParam);
|
|
38
37
|
isInScrollBottomArea.current = true;
|
|
39
38
|
}
|
|
40
39
|
}, [contentHeight, props.scrollEndThreshold, visibleColumns, apiRef, currentPage.rows.length]);
|
|
@@ -47,6 +46,6 @@ export const useGridInfiniteLoader = (apiRef, props) => {
|
|
|
47
46
|
top
|
|
48
47
|
});
|
|
49
48
|
}, [handleRowsScrollEnd]);
|
|
50
|
-
useGridApiEventHandler(apiRef,
|
|
51
|
-
useGridApiOptionHandler(apiRef,
|
|
49
|
+
useGridApiEventHandler(apiRef, 'rowsScroll', handleGridScroll);
|
|
50
|
+
useGridApiOptionHandler(apiRef, 'rowsScrollEnd', props.onRowsScrollEnd);
|
|
52
51
|
};
|
|
@@ -23,12 +23,12 @@ export const isGroupingColumn = field => field === GRID_ROW_GROUPING_SINGLE_GROU
|
|
|
23
23
|
/**
|
|
24
24
|
* When filtering a group, we only want to filter according to the items related to this grouping column.
|
|
25
25
|
*/
|
|
26
|
-
const shouldApplyFilterItemOnGroup = (
|
|
27
|
-
if (
|
|
26
|
+
const shouldApplyFilterItemOnGroup = (columnField, node) => {
|
|
27
|
+
if (columnField === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD) {
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const groupingCriteriaField = getRowGroupingCriteriaFromGroupingField(
|
|
31
|
+
const groupingCriteriaField = getRowGroupingCriteriaFromGroupingField(columnField);
|
|
32
32
|
return groupingCriteriaField === node.groupingField;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
@@ -54,7 +54,7 @@ export const filterRowTreeFromGroupingColumns = params => {
|
|
|
54
54
|
if (!isRowMatchingFilters) {
|
|
55
55
|
isMatchingFilters = true;
|
|
56
56
|
} else {
|
|
57
|
-
const shouldApplyItem = node.isAutoGenerated ?
|
|
57
|
+
const shouldApplyItem = node.isAutoGenerated ? columnField => shouldApplyFilterItemOnGroup(columnField, node) : undefined;
|
|
58
58
|
isMatchingFilters = isRowMatchingFilters(node.id, shouldApplyItem);
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import Divider from '@mui/material/Divider';
|
|
4
|
-
import {
|
|
4
|
+
import { useGridApiEventHandler, useGridApiMethod, gridFilteredDescendantCountLookupSelector } from '@mui/x-data-grid';
|
|
5
5
|
import { useGridRegisterPipeProcessor, isDeepEqual } from '@mui/x-data-grid/internals';
|
|
6
6
|
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector, gridRowGroupingStateSelector } from './gridRowGroupingSelector';
|
|
7
7
|
import { getRowGroupingFieldFromGroupingCriteria, ROW_GROUPING_STRATEGY, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability } from './gridRowGroupingUtils';
|
|
@@ -15,11 +15,9 @@ export const rowGroupingStateInitializer = (state, props) => _extends({}, state,
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
/**
|
|
18
|
-
* Only available in DataGridPro
|
|
19
18
|
* @requires useGridColumns (state, method) - can be after, async only
|
|
20
19
|
* @requires useGridRows (state, method) - can be after, async only
|
|
21
20
|
* @requires useGridParamsApi (method) - can be after, async only
|
|
22
|
-
* TODO: Move the the Premium plan once available and remove the `experimentalFeatures.rowGrouping` flag
|
|
23
21
|
*/
|
|
24
22
|
|
|
25
23
|
export const useGridRowGrouping = (apiRef, props) => {
|
|
@@ -28,7 +26,7 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
28
26
|
propModel: props.rowGroupingModel,
|
|
29
27
|
propOnChange: props.onRowGroupingModelChange,
|
|
30
28
|
stateSelector: gridRowGroupingModelSelector,
|
|
31
|
-
changeEvent:
|
|
29
|
+
changeEvent: 'rowGroupingModelChange'
|
|
32
30
|
});
|
|
33
31
|
/**
|
|
34
32
|
* API METHODS
|
|
@@ -175,13 +173,13 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
175
173
|
// TODO: Add a clean way to re-run a strategy processing without publishing a private event
|
|
176
174
|
|
|
177
175
|
if (apiRef.current.unstable_getActiveStrategy('rowTree') === ROW_GROUPING_STRATEGY) {
|
|
178
|
-
apiRef.current.publishEvent(
|
|
176
|
+
apiRef.current.publishEvent('activeStrategyProcessorChange', 'rowTreeCreation');
|
|
179
177
|
}
|
|
180
178
|
}
|
|
181
179
|
}, [apiRef, props.disableRowGrouping]);
|
|
182
|
-
useGridApiEventHandler(apiRef,
|
|
183
|
-
useGridApiEventHandler(apiRef,
|
|
184
|
-
useGridApiEventHandler(apiRef,
|
|
180
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
181
|
+
useGridApiEventHandler(apiRef, 'columnsChange', checkGroupingColumnsModelDiff);
|
|
182
|
+
useGridApiEventHandler(apiRef, 'rowGroupingModelChange', checkGroupingColumnsModelDiff);
|
|
185
183
|
/**
|
|
186
184
|
* EFFECTS
|
|
187
185
|
*/
|
|
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { gridColumnLookupSelector, gridRowIdsSelector, gridRowTreeSelector, useFirstRender } from '@mui/x-data-grid';
|
|
4
4
|
import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor } from '@mui/x-data-grid/internals';
|
|
5
|
+
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
6
|
+
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
5
7
|
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
6
8
|
import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from './createGroupingColDef';
|
|
7
9
|
import { filterRowTreeFromGroupingColumns, getColDefOverrides, ROW_GROUPING_STRATEGY, isGroupingColumn, setStrategyAvailability } from './gridRowGroupingUtils';
|
|
8
|
-
import { buildRowTree } from '../../../utils/tree/buildRowTree';
|
|
9
|
-
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
10
10
|
export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
11
11
|
const getGroupingColDefs = React.useCallback(columnsState => {
|
|
12
12
|
if (props.disableRowGrouping) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { GRID_STRING_COL_DEF } from '@mui/x-data-grid';
|
|
3
|
+
import { renderRowReorderCell } from '../../../components/GridRowReorderCell';
|
|
4
|
+
export const GRID_REORDER_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
|
|
5
|
+
field: '__reorder__',
|
|
6
|
+
type: 'reorder',
|
|
7
|
+
sortable: false,
|
|
8
|
+
filterable: false,
|
|
9
|
+
width: 50,
|
|
10
|
+
align: 'center',
|
|
11
|
+
headerAlign: 'center',
|
|
12
|
+
disableColumnMenu: true,
|
|
13
|
+
disableExport: true,
|
|
14
|
+
disableReorder: true,
|
|
15
|
+
resizable: false,
|
|
16
|
+
renderHeader: () => ' ',
|
|
17
|
+
renderCell: renderRowReorderCell
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gridRowReorderColDef';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
3
|
+
import { useGridLogger, useGridApiEventHandler, getDataGridUtilityClass, useGridSelector, gridSortModelSelector, gridRowTreeDepthSelector, useGridApiOptionHandler, gridEditRowsStateSelector } from '@mui/x-data-grid';
|
|
4
|
+
|
|
5
|
+
const useUtilityClasses = ownerState => {
|
|
6
|
+
const {
|
|
7
|
+
classes
|
|
8
|
+
} = ownerState;
|
|
9
|
+
const slots = {
|
|
10
|
+
rowDragging: ['row--dragging']
|
|
11
|
+
};
|
|
12
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Only available in DataGridPro
|
|
16
|
+
* @requires useGridRows (method)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export const useGridRowReorder = (apiRef, props) => {
|
|
21
|
+
const logger = useGridLogger(apiRef, 'useGridRowReorder');
|
|
22
|
+
const sortModel = useGridSelector(apiRef, gridSortModelSelector);
|
|
23
|
+
const treeDepth = useGridSelector(apiRef, gridRowTreeDepthSelector);
|
|
24
|
+
const dragRowNode = React.useRef(null);
|
|
25
|
+
const originRowIndex = React.useRef(null);
|
|
26
|
+
const removeDnDStylesTimeout = React.useRef();
|
|
27
|
+
const ownerState = {
|
|
28
|
+
classes: props.classes
|
|
29
|
+
};
|
|
30
|
+
const classes = useUtilityClasses(ownerState);
|
|
31
|
+
const [dragRowId, setDragRowId] = React.useState('');
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
return () => {
|
|
34
|
+
clearTimeout(removeDnDStylesTimeout.current);
|
|
35
|
+
};
|
|
36
|
+
}, []); // TODO: remove sortModel check once row reorder is sorting compatible
|
|
37
|
+
// remove treeDepth once row reorder is tree compatible
|
|
38
|
+
|
|
39
|
+
const isRowReorderDisabled = React.useMemo(() => {
|
|
40
|
+
return !props.rowReordering || !!sortModel.length || treeDepth !== 1;
|
|
41
|
+
}, [props.rowReordering, sortModel, treeDepth]);
|
|
42
|
+
const handleDragStart = React.useCallback((params, event) => {
|
|
43
|
+
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
44
|
+
const editRowsState = gridEditRowsStateSelector(apiRef.current.state);
|
|
45
|
+
|
|
46
|
+
if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
logger.debug(`Start dragging row ${params.id}`); // Prevent drag events propagation.
|
|
51
|
+
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
52
|
+
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
dragRowNode.current = event.currentTarget;
|
|
55
|
+
dragRowNode.current.classList.add(classes.rowDragging);
|
|
56
|
+
setDragRowId(params.id);
|
|
57
|
+
removeDnDStylesTimeout.current = setTimeout(() => {
|
|
58
|
+
dragRowNode.current.classList.remove(classes.rowDragging);
|
|
59
|
+
});
|
|
60
|
+
originRowIndex.current = apiRef.current.getRowIndex(params.id);
|
|
61
|
+
}, [isRowReorderDisabled, classes.rowDragging, logger, apiRef]);
|
|
62
|
+
const handleDragOver = React.useCallback((params, event) => {
|
|
63
|
+
logger.debug(`Dragging over row ${params.id}`);
|
|
64
|
+
event.preventDefault(); // Prevent drag events propagation.
|
|
65
|
+
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
66
|
+
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
|
|
69
|
+
if (params.id !== dragRowId) {
|
|
70
|
+
const targetRowIndex = apiRef.current.getRowIndex(params.id);
|
|
71
|
+
apiRef.current.setRowIndex(dragRowId, targetRowIndex);
|
|
72
|
+
}
|
|
73
|
+
}, [apiRef, logger, dragRowId]);
|
|
74
|
+
const handleDragEnd = React.useCallback((params, event) => {
|
|
75
|
+
// Call the gridEditRowsStateSelector directly to avoid infnite loop
|
|
76
|
+
const editRowsState = gridEditRowsStateSelector(apiRef.current.state);
|
|
77
|
+
|
|
78
|
+
if (isRowReorderDisabled || Object.keys(editRowsState).length !== 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
logger.debug('End dragging row');
|
|
83
|
+
event.preventDefault(); // Prevent drag events propagation.
|
|
84
|
+
// For more information check here https://github.com/mui/mui-x/issues/2680.
|
|
85
|
+
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
clearTimeout(removeDnDStylesTimeout.current);
|
|
88
|
+
dragRowNode.current = null; // Check if the row was dropped outside the grid.
|
|
89
|
+
|
|
90
|
+
if (event.dataTransfer.dropEffect === 'none') {
|
|
91
|
+
// Accessing params.field may contain the wrong field as header elements are reused
|
|
92
|
+
apiRef.current.setRowIndex(dragRowId, originRowIndex.current);
|
|
93
|
+
originRowIndex.current = null;
|
|
94
|
+
} else {
|
|
95
|
+
// Emit the rowOrderChange event only once when the reordering stops.
|
|
96
|
+
const rowOrderChangeParams = {
|
|
97
|
+
row: apiRef.current.getRow(dragRowId),
|
|
98
|
+
targetIndex: apiRef.current.getRowIndex(params.id),
|
|
99
|
+
oldIndex: originRowIndex.current
|
|
100
|
+
};
|
|
101
|
+
apiRef.current.publishEvent('rowOrderChange', rowOrderChangeParams);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setDragRowId('');
|
|
105
|
+
}, [isRowReorderDisabled, logger, apiRef, dragRowId]);
|
|
106
|
+
useGridApiEventHandler(apiRef, 'rowDragStart', handleDragStart);
|
|
107
|
+
useGridApiEventHandler(apiRef, 'rowDragOver', handleDragOver);
|
|
108
|
+
useGridApiEventHandler(apiRef, 'rowDragEnd', handleDragEnd);
|
|
109
|
+
useGridApiEventHandler(apiRef, 'cellDragOver', handleDragOver);
|
|
110
|
+
useGridApiOptionHandler(apiRef, 'rowOrderChange', props.onRowOrderChange);
|
|
111
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
4
|
+
import { getDataGridUtilityClass } from '@mui/x-data-grid';
|
|
5
|
+
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid/internals';
|
|
6
|
+
import { GRID_REORDER_COL_DEF } from './gridRowReorderColDef';
|
|
7
|
+
|
|
8
|
+
const useUtilityClasses = ownerState => {
|
|
9
|
+
const {
|
|
10
|
+
classes
|
|
11
|
+
} = ownerState;
|
|
12
|
+
return React.useMemo(() => {
|
|
13
|
+
const slots = {
|
|
14
|
+
rowReorderCellContainer: ['rowReorderCellContainer'],
|
|
15
|
+
columnHeaderReorder: ['columnHeaderReorder']
|
|
16
|
+
};
|
|
17
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
18
|
+
}, [classes]);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const useGridRowReorderPreProcessors = (apiRef, props) => {
|
|
22
|
+
const ownerState = {
|
|
23
|
+
classes: props.classes
|
|
24
|
+
};
|
|
25
|
+
const classes = useUtilityClasses(ownerState);
|
|
26
|
+
const updateReorderColumn = React.useCallback(columnsState => {
|
|
27
|
+
const reorderColumn = _extends({}, GRID_REORDER_COL_DEF, {
|
|
28
|
+
cellClassName: classes.rowReorderCellContainer,
|
|
29
|
+
headerClassName: classes.columnHeaderReorder,
|
|
30
|
+
headerName: apiRef.current.getLocaleText('rowReorderingHeaderName')
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const shouldHaveReorderColumn = props.rowReordering;
|
|
34
|
+
const haveReorderColumn = columnsState.lookup[reorderColumn.field] != null;
|
|
35
|
+
|
|
36
|
+
if (shouldHaveReorderColumn && haveReorderColumn) {
|
|
37
|
+
return columnsState;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (shouldHaveReorderColumn && !haveReorderColumn) {
|
|
41
|
+
columnsState.lookup[reorderColumn.field] = reorderColumn;
|
|
42
|
+
columnsState.all = [reorderColumn.field, ...columnsState.all];
|
|
43
|
+
} else if (!shouldHaveReorderColumn && haveReorderColumn) {
|
|
44
|
+
delete columnsState.lookup[reorderColumn.field];
|
|
45
|
+
columnsState.all = columnsState.all.filter(field => field !== reorderColumn.field);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return columnsState;
|
|
49
|
+
}, [apiRef, classes, props.rowReordering]);
|
|
50
|
+
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', updateReorderColumn);
|
|
51
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { useGridApiEventHandler,
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Only available in DataGridPro
|
|
6
|
-
*/
|
|
2
|
+
import { useGridApiEventHandler, gridFilteredDescendantCountLookupSelector } from '@mui/x-data-grid';
|
|
7
3
|
export const useGridTreeData = apiRef => {
|
|
8
4
|
/**
|
|
9
5
|
* EVENTS
|
|
@@ -21,5 +17,5 @@ export const useGridTreeData = apiRef => {
|
|
|
21
17
|
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
22
18
|
}
|
|
23
19
|
}, [apiRef]);
|
|
24
|
-
useGridApiEventHandler(apiRef,
|
|
20
|
+
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
25
21
|
};
|
package/modern/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.11.1
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
5
5
|
*/
|
|
6
|
-
import './typeOverloads
|
|
6
|
+
import './typeOverloads';
|
|
7
7
|
export { LicenseInfo } from '@mui/x-license-pro';
|
|
8
8
|
export * from '@mui/x-data-grid/components';
|
|
9
9
|
export * from '@mui/x-data-grid/constants';
|
|
@@ -17,4 +17,8 @@ export * from './DataGridPro';
|
|
|
17
17
|
export * from './hooks';
|
|
18
18
|
export * from './models';
|
|
19
19
|
export * from './components';
|
|
20
|
-
export
|
|
20
|
+
export * from './utils';
|
|
21
|
+
export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
|
|
22
|
+
// We export them from here to avoid export duplication between pro and premium
|
|
23
|
+
export * from './hooks/features/rowGrouping';
|
|
24
|
+
export * from './models/gridGroupingValueGetterParams';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from '@mui/x-data-grid/internals';
|
|
2
|
+
export { DataGridProVirtualScroller } from '../components/DataGridProVirtualScroller';
|
|
3
|
+
export { DataGridProColumnHeaders } from '../components/DataGridProColumnHeaders';
|
|
4
|
+
export { useGridColumnResize, columnResizeStateInitializer } from '../hooks/features/columnResize/useGridColumnResize';
|
|
5
|
+
export { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
|
|
6
|
+
export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
|
|
7
|
+
export { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
|
|
8
|
+
export { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
|
|
9
|
+
export { useGridDetailPanelCache } from '../hooks/features/detailPanel/useGridDetailPanelCache';
|
|
10
|
+
export { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
|
|
11
|
+
export { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
|
|
12
|
+
export { useGridRowReorder } from '../hooks/features/rowReorder/useGridRowReorder';
|
|
13
|
+
export { useGridRowReorderPreProcessors } from '../hooks/features/rowReorder/useGridRowReorderPreProcessors';
|
|
14
|
+
export { useGridTreeData } from '../hooks/features/treeData/useGridTreeData';
|
|
15
|
+
export { useGridTreeDataPreProcessors } from '../hooks/features/treeData/useGridTreeDataPreProcessors';
|
|
16
|
+
export { buildRowTree } from '../utils/tree/buildRowTree';
|
|
17
|
+
export { sortRowTree } from '../utils/tree/sortRowTree';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/modern/models/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './modules';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tree';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY1Mjk5NzYwMDAwMA==";
|
|
4
4
|
|
|
5
5
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
6
|
// A simple hack to set the value in the test environment (has no build step).
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
|
|
2
|
+
export const getGroupRowIdFromPath = path => {
|
|
3
|
+
const pathStr = path.map(groupingCriteria => `${groupingCriteria.field}/${groupingCriteria.key}`).join('-');
|
|
4
|
+
return `auto-generated-row-${pathStr}`;
|
|
5
|
+
};
|
|
3
6
|
/**
|
|
4
7
|
* Transform a list of rows into a tree structure where each row references its parent and children.
|
|
5
8
|
* If a row have a parent which does not exist in the input rows, creates an auto generated row
|
|
@@ -29,6 +32,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
29
32
|
}
|
|
30
33
|
```
|
|
31
34
|
*/
|
|
35
|
+
|
|
32
36
|
export const buildRowTree = params => {
|
|
33
37
|
// During the build, we store the children as a Record to avoid linear complexity when checking if a children is already defined.
|
|
34
38
|
const tempTree = {};
|
|
@@ -37,6 +41,8 @@ export const buildRowTree = params => {
|
|
|
37
41
|
|
|
38
42
|
const idRowsLookup = _extends({}, params.idRowsLookup);
|
|
39
43
|
|
|
44
|
+
const idToIdLookup = _extends({}, params.idToIdLookup);
|
|
45
|
+
|
|
40
46
|
const groupingCriteriaToIdTree = {};
|
|
41
47
|
|
|
42
48
|
const isGroupExpandedByDefault = node => {
|
|
@@ -88,7 +94,7 @@ export const buildRowTree = params => {
|
|
|
88
94
|
if (depth === row.path.length - 1) {
|
|
89
95
|
nodeId = row.id;
|
|
90
96
|
} else {
|
|
91
|
-
nodeId =
|
|
97
|
+
nodeId = getGroupRowIdFromPath(row.path.slice(0, depth + 1));
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
keyConfig = {
|
|
@@ -162,6 +168,7 @@ export const buildRowTree = params => {
|
|
|
162
168
|
treeDepth,
|
|
163
169
|
ids,
|
|
164
170
|
idRowsLookup,
|
|
171
|
+
idToIdLookup,
|
|
165
172
|
groupingName: params.groupingName
|
|
166
173
|
};
|
|
167
174
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getGroupRowIdFromPath } from './buildRowTree';
|