@mui/x-data-grid 8.19.0 → 8.21.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.
- package/CHANGELOG.md +174 -0
- package/components/GridRow.js +4 -1
- package/components/GridRowDragAndDropOverlay.d.ts +7 -0
- package/components/GridRowDragAndDropOverlay.js +73 -0
- package/components/containers/GridRootStyles.js +16 -39
- package/components/virtualization/GridVirtualScroller.js +5 -3
- package/components/virtualization/GridVirtualScrollerRenderZone.js +4 -16
- package/constants/gridClasses.d.ts +0 -8
- package/constants/gridClasses.js +1 -1
- package/esm/components/GridRow.js +4 -1
- package/esm/components/GridRowDragAndDropOverlay.d.ts +7 -0
- package/esm/components/GridRowDragAndDropOverlay.js +66 -0
- package/esm/components/containers/GridRootStyles.js +16 -39
- package/esm/components/virtualization/GridVirtualScroller.js +5 -3
- package/esm/components/virtualization/GridVirtualScrollerRenderZone.js +3 -15
- package/esm/constants/gridClasses.d.ts +0 -8
- package/esm/constants/gridClasses.js +1 -1
- package/esm/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
- package/esm/hooks/core/useGridVirtualizer.d.ts +6 -50
- package/esm/hooks/core/useGridVirtualizer.js +10 -9
- package/esm/hooks/features/columnResize/useGridColumnResize.js +17 -8
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
- package/esm/hooks/features/dimensions/useGridDimensions.js +3 -1
- package/esm/hooks/features/editing/useGridCellEditing.js +1 -1
- package/esm/hooks/features/editing/useGridRowEditing.js +1 -1
- package/esm/hooks/features/export/serializers/csvSerializer.js +2 -4
- package/esm/hooks/features/filter/gridFilterUtils.js +5 -11
- package/esm/hooks/features/filter/index.d.ts +1 -1
- package/esm/hooks/features/filter/index.js +1 -1
- package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
- package/esm/hooks/features/rowReorder/gridRowReorderSelector.js +19 -1
- package/esm/hooks/features/rowSelection/useGridRowSelection.js +9 -1
- package/esm/hooks/features/rows/useGridRows.js +3 -1
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
- package/esm/hooks/features/sorting/gridSortingUtils.js +1 -3
- package/esm/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
- package/esm/hooks/utils/useGridSelector.js +2 -4
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +5 -4
- package/esm/internals/index.js +3 -3
- package/esm/material/index.js +1 -4
- package/esm/models/api/gridRowApi.d.ts +14 -1
- package/esm/models/api/index.d.ts +1 -1
- package/esm/models/api/index.js +0 -1
- package/esm/models/configuration/gridConfiguration.d.ts +2 -2
- package/esm/models/configuration/gridRowConfiguration.d.ts +6 -5
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
- package/hooks/core/useGridVirtualizer.d.ts +6 -50
- package/hooks/core/useGridVirtualizer.js +9 -8
- package/hooks/features/columnResize/useGridColumnResize.js +17 -8
- package/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
- package/hooks/features/dimensions/useGridDimensions.js +3 -1
- package/hooks/features/editing/useGridCellEditing.js +1 -1
- package/hooks/features/editing/useGridRowEditing.js +1 -1
- package/hooks/features/export/serializers/csvSerializer.js +2 -4
- package/hooks/features/filter/gridFilterUtils.js +5 -11
- package/hooks/features/filter/index.d.ts +1 -1
- package/hooks/features/filter/index.js +6 -0
- package/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
- package/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
- package/hooks/features/rowReorder/gridRowReorderSelector.js +20 -2
- package/hooks/features/rowSelection/useGridRowSelection.js +9 -1
- package/hooks/features/rows/useGridRows.js +3 -1
- package/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
- package/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
- package/hooks/features/sorting/gridSortingUtils.js +1 -3
- package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
- package/hooks/utils/useGridSelector.js +2 -4
- package/index.js +1 -1
- package/internals/index.d.ts +5 -4
- package/internals/index.js +16 -9
- package/material/index.js +1 -4
- package/models/api/gridRowApi.d.ts +14 -1
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -11
- package/models/configuration/gridConfiguration.d.ts +2 -2
- package/models/configuration/gridRowConfiguration.d.ts +6 -5
- package/package.json +3 -3
|
@@ -233,10 +233,6 @@ export const GridRootStyles = styled('div', {
|
|
|
233
233
|
[`& .${c.treeDataGroupingCellToggle}`]: styles.treeDataGroupingCellToggle
|
|
234
234
|
}, {
|
|
235
235
|
[`& .${c.withBorderColor}`]: styles.withBorderColor
|
|
236
|
-
}, {
|
|
237
|
-
[`& .${c['row--dropAbove']}`]: styles['row--dropAbove']
|
|
238
|
-
}, {
|
|
239
|
-
[`& .${c['row--dropBelow']}`]: styles['row--dropBelow']
|
|
240
236
|
}, {
|
|
241
237
|
[`& .${c['row--beingDragged']}`]: styles['row--beingDragged']
|
|
242
238
|
}]
|
|
@@ -414,6 +410,9 @@ export const GridRootStyles = styled('div', {
|
|
|
414
410
|
alignItems: 'center',
|
|
415
411
|
backgroundColor: headerBackground
|
|
416
412
|
},
|
|
413
|
+
[`& .${c.columnHeader} .${c.sortButton}`]: {
|
|
414
|
+
backgroundColor: vars.header.background.base
|
|
415
|
+
},
|
|
417
416
|
[`& .${c['columnHeader--filter']}`]: {
|
|
418
417
|
paddingTop: 8,
|
|
419
418
|
paddingBottom: 8,
|
|
@@ -513,7 +512,16 @@ export const GridRootStyles = styled('div', {
|
|
|
513
512
|
[`& .${c.columnHeader}:not(.${c['columnHeader--sorted']}):hover .${c.sortButton},
|
|
514
513
|
& .${c.pivotPanelField}:not(.${c['pivotPanelField--sorted']}):hover .${c.sortButton},
|
|
515
514
|
& .${c.pivotPanelField}:not(.${c['pivotPanelField--sorted']}) .${c.sortButton}:focus-visible`]: {
|
|
516
|
-
opacity:
|
|
515
|
+
opacity: 1
|
|
516
|
+
},
|
|
517
|
+
// Add opacity only to the button content to avoid affecting the background color
|
|
518
|
+
[`& .${c.columnHeader}:not(.${c['columnHeader--sorted']}):hover .${c.sortButton} > *,
|
|
519
|
+
& .${c.pivotPanelField}:not(.${c['pivotPanelField--sorted']}):hover .${c.sortButton} > *,
|
|
520
|
+
& .${c.pivotPanelField}:not(.${c['pivotPanelField--sorted']}) .${c.sortButton}:focus-visible > *`]: {
|
|
521
|
+
opacity: 0.78
|
|
522
|
+
},
|
|
523
|
+
[`& .${c.pivotPanelFieldActionContainer} button:hover`]: {
|
|
524
|
+
backgroundColor: vars.colors.background.base
|
|
517
525
|
}
|
|
518
526
|
},
|
|
519
527
|
'@media (hover: none)': {
|
|
@@ -528,7 +536,7 @@ export const GridRootStyles = styled('div', {
|
|
|
528
536
|
}
|
|
529
537
|
},
|
|
530
538
|
[`& .${c.pivotPanelField}:not(.${c['pivotPanelField--sorted']}) .${c.sortButton}`]: {
|
|
531
|
-
opacity: 0.
|
|
539
|
+
opacity: 0.78
|
|
532
540
|
}
|
|
533
541
|
},
|
|
534
542
|
// Hide the column separator when the column has border and it is not resizable
|
|
@@ -622,7 +630,8 @@ export const GridRootStyles = styled('div', {
|
|
|
622
630
|
[`&.${c.rowSkeleton}:hover`]: {
|
|
623
631
|
backgroundColor: 'transparent'
|
|
624
632
|
},
|
|
625
|
-
'&.Mui-selected': selectedStyles
|
|
633
|
+
'&.Mui-selected': selectedStyles,
|
|
634
|
+
position: 'relative'
|
|
626
635
|
},
|
|
627
636
|
/* Cell styles */
|
|
628
637
|
[`& .${c.cell}`]: {
|
|
@@ -867,38 +876,6 @@ export const GridRootStyles = styled('div', {
|
|
|
867
876
|
display: 'none'
|
|
868
877
|
}
|
|
869
878
|
},
|
|
870
|
-
[`& .${c['row--dropAbove']}`]: {
|
|
871
|
-
position: 'relative',
|
|
872
|
-
'&::before': {
|
|
873
|
-
pointerEvents: 'none',
|
|
874
|
-
content: '""',
|
|
875
|
-
position: 'absolute',
|
|
876
|
-
top: 0,
|
|
877
|
-
left: 0,
|
|
878
|
-
width: '100%',
|
|
879
|
-
height: '2px',
|
|
880
|
-
backgroundColor: vars.colors.interactive.selected
|
|
881
|
-
}
|
|
882
|
-
},
|
|
883
|
-
[`& .${c['row--dropBelow']}`]: {
|
|
884
|
-
position: 'relative',
|
|
885
|
-
'&::after': {
|
|
886
|
-
zIndex: 100,
|
|
887
|
-
pointerEvents: 'none',
|
|
888
|
-
content: '""',
|
|
889
|
-
position: 'absolute',
|
|
890
|
-
bottom: '-2px',
|
|
891
|
-
left: 0,
|
|
892
|
-
width: '100%',
|
|
893
|
-
height: '2px',
|
|
894
|
-
backgroundColor: vars.colors.interactive.selected
|
|
895
|
-
},
|
|
896
|
-
[`&.${c['row--lastVisible']}`]: {
|
|
897
|
-
'&::after': {
|
|
898
|
-
bottom: 'calc(var(--DataGrid-hasScrollY) * 0px + (1 - var(--DataGrid-hasScrollY)) * -2px)'
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
},
|
|
902
879
|
[`& .${c['row--beingDragged']}`]: {
|
|
903
880
|
color: vars.colors.foreground.disabled,
|
|
904
881
|
'&:hover': {
|
|
@@ -88,6 +88,7 @@ function GridVirtualScroller(props) {
|
|
|
88
88
|
getContainerProps,
|
|
89
89
|
getScrollerProps,
|
|
90
90
|
getContentProps,
|
|
91
|
+
getPositionerProps,
|
|
91
92
|
getScrollbarVerticalProps,
|
|
92
93
|
getScrollbarHorizontalProps,
|
|
93
94
|
getRows,
|
|
@@ -120,12 +121,13 @@ function GridVirtualScroller(props) {
|
|
|
120
121
|
loadingOverlayVariant: loadingOverlayVariant,
|
|
121
122
|
children: /*#__PURE__*/_jsx(Overlay, _extends({}, rootProps.slotProps?.[overlayType]))
|
|
122
123
|
}), /*#__PURE__*/_jsx(Content, _extends({}, getContentProps(), {
|
|
123
|
-
children: /*#__PURE__*/_jsxs(RenderZone, {
|
|
124
|
-
role: "rowgroup"
|
|
124
|
+
children: /*#__PURE__*/_jsxs(RenderZone, _extends({
|
|
125
|
+
role: "rowgroup"
|
|
126
|
+
}, getPositionerProps(), {
|
|
125
127
|
children: [rows, /*#__PURE__*/_jsx(rootProps.slots.detailPanels, {
|
|
126
128
|
virtualScroller: virtualScroller
|
|
127
129
|
})]
|
|
128
|
-
})
|
|
130
|
+
}))
|
|
129
131
|
})), hasBottomFiller && /*#__PURE__*/_jsx(SpaceFiller, {
|
|
130
132
|
rowsLength: rows.length
|
|
131
133
|
}), /*#__PURE__*/_jsx(rootProps.slots.bottomContainer, {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className"];
|
|
4
2
|
import * as React from 'react';
|
|
5
3
|
import clsx from 'clsx';
|
|
6
4
|
import { styled } from '@mui/system';
|
|
7
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
6
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
9
|
-
import { useGridPrivateApiContext } from "../../hooks/utils/useGridPrivateApiContext.js";
|
|
10
7
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
11
8
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
12
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -29,21 +26,12 @@ const VirtualScrollerRenderZoneRoot = styled('div', {
|
|
|
29
26
|
flexDirection: 'column'
|
|
30
27
|
});
|
|
31
28
|
const GridVirtualScrollerRenderZone = forwardRef(function GridVirtualScrollerRenderZone(props, ref) {
|
|
32
|
-
const {
|
|
33
|
-
className
|
|
34
|
-
} = props,
|
|
35
|
-
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
36
|
-
const apiRef = useGridPrivateApiContext();
|
|
37
29
|
const rootProps = useGridRootProps();
|
|
38
30
|
const classes = useUtilityClasses(rootProps);
|
|
39
|
-
const offsetTop = apiRef.current.virtualizer.api.getters.getOffsetTop();
|
|
40
31
|
return /*#__PURE__*/_jsx(VirtualScrollerRenderZoneRoot, _extends({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
transform: `translate3d(0, ${offsetTop}px, 0)`
|
|
45
|
-
}
|
|
46
|
-
}, other, {
|
|
32
|
+
ownerState: rootProps
|
|
33
|
+
}, props, {
|
|
34
|
+
className: clsx(classes.root, props.className),
|
|
47
35
|
ref: ref
|
|
48
36
|
}));
|
|
49
37
|
});
|
|
@@ -572,14 +572,6 @@ export interface GridClasses {
|
|
|
572
572
|
* Styles applied to the floating special row reorder cell element when it is dragged.
|
|
573
573
|
*/
|
|
574
574
|
'row--dragging': string;
|
|
575
|
-
/**
|
|
576
|
-
* Styles applied to the row element when it is a drop target above.
|
|
577
|
-
*/
|
|
578
|
-
'row--dropAbove': string;
|
|
579
|
-
/**
|
|
580
|
-
* Styles applied to the row element when it is a drop target below.
|
|
581
|
-
*/
|
|
582
|
-
'row--dropBelow': string;
|
|
583
575
|
/**
|
|
584
576
|
* Styles applied to the row element when it is being dragged (entire row).
|
|
585
577
|
*/
|
|
@@ -5,4 +5,4 @@ export function getDataGridUtilityClass(slot) {
|
|
|
5
5
|
}
|
|
6
6
|
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['aiAssistantPanel', 'aiAssistantPanelHeader', 'aiAssistantPanelTitleContainer', 'aiAssistantPanelTitle', 'aiAssistantPanelBody', 'aiAssistantPanelEmptyText', 'aiAssistantPanelFooter', 'aiAssistantPanelConversation', 'aiAssistantPanelConversationList', 'aiAssistantPanelConversationTitle', 'aiAssistantPanelSuggestions', 'aiAssistantPanelSuggestionsList', 'aiAssistantPanelSuggestionsItem', 'aiAssistantPanelSuggestionsLabel', 'actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'aggregationRowOverlayWrapper', 'autoHeight', 'autosizing', 'mainContent', 'withSidePanel', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'collapsible', 'collapsibleTrigger', 'collapsibleIcon', 'collapsiblePanel', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--siblingFocused', 'columnHeader--filter', 'columnHeaderFilterInput', 'columnHeaderFilterOperatorLabel', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementSearchInput', 'columnsManagementFooter', 'columnsManagementScrollArea', 'columnsManagementEmptyText', 'container--top', 'container--bottom', 'detailPanel', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hiddenContent', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible',
|
|
7
7
|
// TODO v9: Rename to `cell--dragging`
|
|
8
|
-
'row--dragging', 'row--
|
|
8
|
+
'row--dragging', 'row--beingDragged', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowReorderIcon', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea--up', 'scrollArea--down', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--pinnedRight', 'scrollShadow', 'scrollShadow--vertical', 'scrollShadow--horizontal', 'selectedRowCount', 'sortButton', 'sortIcon', 'shadowScrollArea', 'sidebar', 'sidebarHeader', 'toolbarContainer', 'toolbar', 'toolbarLabel', 'toolbarDivider', 'toolbarFilterList', 'toolbarQuickFilter', 'toolbarQuickFilterTrigger', 'toolbarQuickFilterControl', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'groupingCriteriaCellLoadingContainer', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pivotPanelAvailableFields', 'pivotPanelField', 'pivotPanelField--sorted', 'pivotPanelFieldActionContainer', 'pivotPanelFieldCheckbox', 'pivotPanelFieldDragIcon', 'pivotPanelFieldList', 'pivotPanelFieldName', 'pivotPanelHeader', 'pivotPanelPlaceholder', 'pivotPanelScrollArea', 'pivotPanelSearchContainer', 'pivotPanelSection', 'pivotPanelSectionTitle', 'pivotPanelSections', 'pivotPanelSwitch', 'pivotPanelSwitchLabel', 'prompt', 'promptContent', 'promptText', 'promptFeedback', 'promptChangeList', 'promptChangesToggle', 'promptChangesToggleIcon', 'promptIcon', 'promptIconContainer', 'promptError', 'promptAction']);
|
|
@@ -8,6 +8,7 @@ import { GridHydrateRowsValue } from "../../features/rows/gridRowsInterfaces.js"
|
|
|
8
8
|
import { GridPreferencePanelsValue } from "../../features/preferencesPanel/index.js";
|
|
9
9
|
import { GridGetRowsParams, GridGetRowsResponse } from "../../../models/gridDataSource.js";
|
|
10
10
|
import { HeightEntry } from "../../features/rows/gridRowsMetaInterfaces.js";
|
|
11
|
+
import type { RowReorderDropPosition } from "../../../models/api/gridRowApi.js";
|
|
11
12
|
export type GridPipeProcessorGroup = keyof GridPipeProcessingLookup;
|
|
12
13
|
export interface GridPipeProcessingLookup {
|
|
13
14
|
columnMenu: {
|
|
@@ -97,12 +98,12 @@ export interface GridPipeProcessingLookup {
|
|
|
97
98
|
* - For example before first row is `0` and after the last row is `rows.length`.
|
|
98
99
|
* If the reorder is invalid, it returns `-1`.
|
|
99
100
|
*/
|
|
100
|
-
|
|
101
|
-
value:
|
|
101
|
+
isRowReorderValid: {
|
|
102
|
+
value: boolean;
|
|
102
103
|
context: {
|
|
103
104
|
sourceRowId: GridRowId;
|
|
104
105
|
targetRowId: GridRowId;
|
|
105
|
-
dropPosition:
|
|
106
|
+
dropPosition: RowReorderDropPosition;
|
|
106
107
|
dragDirection: 'up' | 'down';
|
|
107
108
|
};
|
|
108
109
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Dimensions, Virtualization } from '@mui/x-virtualizer';
|
|
2
|
+
import { Dimensions, LayoutDataGridLegacy, Virtualization } from '@mui/x-virtualizer';
|
|
3
3
|
/**
|
|
4
4
|
* Virtualizer setup
|
|
5
5
|
*/
|
|
6
6
|
export declare function useGridVirtualizer(): {
|
|
7
|
-
store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
|
|
7
|
+
store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State<LayoutDataGridLegacy> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
|
|
8
8
|
api: {
|
|
9
9
|
updateDimensions: (firstUpdate?: boolean) => void;
|
|
10
10
|
debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
|
|
@@ -20,57 +20,13 @@ export declare function useGridVirtualizer(): {
|
|
|
20
20
|
resetRowHeights: () => void;
|
|
21
21
|
};
|
|
22
22
|
} & {
|
|
23
|
-
getters: {
|
|
24
|
-
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
25
|
-
getOffsetTop: () => number;
|
|
26
|
-
getRows: (rowParams?: {
|
|
27
|
-
rows?: import("@mui/x-virtualizer/models").RowEntry[];
|
|
28
|
-
position?: import("@mui/x-virtualizer/models").PinnedRowPosition;
|
|
29
|
-
renderContext?: import("@mui/x-virtualizer/models").RenderContext;
|
|
30
|
-
}, unstable_rowTree?: Record<import("@mui/x-virtualizer/models").RowId, any>) => React.ReactNode[];
|
|
31
|
-
rows: import("@mui/x-virtualizer/models").RowEntry[];
|
|
32
|
-
getContainerProps: () => {
|
|
33
|
-
ref: (node: HTMLDivElement | null) => (() => void | undefined) | undefined;
|
|
34
|
-
};
|
|
35
|
-
getScrollerProps: () => {
|
|
36
|
-
ref: (node: HTMLDivElement | null) => (() => void | undefined) | undefined;
|
|
37
|
-
style: React.CSSProperties;
|
|
38
|
-
role: string;
|
|
39
|
-
tabIndex: number | undefined;
|
|
40
|
-
};
|
|
41
|
-
getContentProps: () => {
|
|
42
|
-
ref: (node: HTMLDivElement | null) => void;
|
|
43
|
-
style: React.CSSProperties;
|
|
44
|
-
role: string;
|
|
45
|
-
};
|
|
46
|
-
getScrollbarVerticalProps: () => {
|
|
47
|
-
ref: (node: HTMLDivElement | null) => void;
|
|
48
|
-
scrollPosition: React.RefObject<{
|
|
49
|
-
top: number;
|
|
50
|
-
left: number;
|
|
51
|
-
}>;
|
|
52
|
-
};
|
|
53
|
-
getScrollbarHorizontalProps: () => {
|
|
54
|
-
ref: (node: HTMLDivElement | null) => void;
|
|
55
|
-
scrollPosition: React.RefObject<{
|
|
56
|
-
top: number;
|
|
57
|
-
left: number;
|
|
58
|
-
}>;
|
|
59
|
-
};
|
|
60
|
-
getScrollAreaProps: () => {
|
|
61
|
-
scrollPosition: React.RefObject<{
|
|
62
|
-
top: number;
|
|
63
|
-
left: number;
|
|
64
|
-
}>;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
useVirtualization: () => import("@mui/x-virtualizer").BaseState;
|
|
68
|
-
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
69
|
-
forceUpdateRenderContext: () => void;
|
|
70
|
-
scheduleUpdateRenderContext: () => void;
|
|
71
23
|
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer/models").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer/models").CellColSpanInfo;
|
|
72
24
|
calculateColSpan: (rowId: import("@mui/x-virtualizer/models").RowId, minFirstColumn: import("@mui/x-internals/types").integer, maxLastColumn: import("@mui/x-internals/types").integer, columns: import("@mui/x-virtualizer/models").ColumnWithWidth[]) => void;
|
|
73
25
|
getHiddenCellsOrigin: () => Record<import("@mui/x-virtualizer/models").RowId, Record<number, number>>;
|
|
26
|
+
getters: any;
|
|
27
|
+
setPanels: React.Dispatch<React.SetStateAction<Readonly<Map<any, React.ReactNode>>>>;
|
|
28
|
+
forceUpdateRenderContext: () => void;
|
|
29
|
+
scheduleUpdateRenderContext: () => void;
|
|
74
30
|
} & {
|
|
75
31
|
resetColSpan: () => void;
|
|
76
32
|
getCellColSpanInfo: (rowId: import("@mui/x-virtualizer/models").RowId, columnIndex: import("@mui/x-internals/types").integer) => import("@mui/x-virtualizer/models").CellColSpanInfo | undefined;
|
|
@@ -6,7 +6,7 @@ import { useRtl } from '@mui/system/RtlProvider';
|
|
|
6
6
|
import { roundToDecimalPlaces } from '@mui/x-internals/math';
|
|
7
7
|
import { lruMemoize } from '@mui/x-internals/lruMemoize';
|
|
8
8
|
import { useStoreEffect } from '@mui/x-internals/store';
|
|
9
|
-
import { useVirtualizer, Dimensions, Virtualization, EMPTY_RENDER_CONTEXT } from '@mui/x-virtualizer';
|
|
9
|
+
import { useVirtualizer, Dimensions, LayoutDataGridLegacy, Virtualization, EMPTY_RENDER_CONTEXT } from '@mui/x-virtualizer';
|
|
10
10
|
import { useFirstRender } from "../utils/useFirstRender.js";
|
|
11
11
|
import { createSelector } from "../../utils/createSelector.js";
|
|
12
12
|
import { useGridSelector } from "../utils/useGridSelector.js";
|
|
@@ -91,6 +91,8 @@ export function useGridVirtualizer() {
|
|
|
91
91
|
rightPinnedWidth,
|
|
92
92
|
topPinnedHeight: headersTotalHeight,
|
|
93
93
|
bottomPinnedHeight: 0,
|
|
94
|
+
autoHeight,
|
|
95
|
+
minimalContentHeight,
|
|
94
96
|
scrollbarSize: rootProps.scrollbarSize
|
|
95
97
|
};
|
|
96
98
|
const addGridDimensions = useLazyRef(addGridDimensionsCreator).current;
|
|
@@ -113,13 +115,14 @@ export function useGridVirtualizer() {
|
|
|
113
115
|
const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
|
|
114
116
|
// We need it to trigger a new render, but rowsMeta needs access to the latest value, hence we cannot pass it to the focusedVirtualCell callback in the virtualizer params
|
|
115
117
|
eslintUseValue(focusedVirtualCell);
|
|
118
|
+
const layout = useLazyRef(() => new LayoutDataGridLegacy({
|
|
119
|
+
container: apiRef.current.mainElementRef,
|
|
120
|
+
scroller: apiRef.current.virtualScrollerRef,
|
|
121
|
+
scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
|
|
122
|
+
scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
|
|
123
|
+
})).current;
|
|
116
124
|
const virtualizer = useVirtualizer({
|
|
117
|
-
|
|
118
|
-
container: apiRef.current.mainElementRef,
|
|
119
|
-
scroller: apiRef.current.virtualScrollerRef,
|
|
120
|
-
scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
|
|
121
|
-
scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
|
|
122
|
-
},
|
|
125
|
+
layout,
|
|
123
126
|
dimensions: dimensionsParams,
|
|
124
127
|
virtualization: {
|
|
125
128
|
isRtl,
|
|
@@ -148,10 +151,8 @@ export function useGridVirtualizer() {
|
|
|
148
151
|
columns: visibleColumns,
|
|
149
152
|
pinnedRows,
|
|
150
153
|
pinnedColumns,
|
|
151
|
-
autoHeight,
|
|
152
154
|
disableHorizontalScroll: listView,
|
|
153
155
|
disableVerticalScroll: overlayState.overlayType === 'noColumnsOverlay' || overlayState.loadingOverlayVariant === 'skeleton',
|
|
154
|
-
minimalContentHeight,
|
|
155
156
|
getRowHeight: React.useMemo(() => {
|
|
156
157
|
if (!getRowHeight) {
|
|
157
158
|
return undefined;
|
|
@@ -142,15 +142,24 @@ function extractColumnWidths(apiRef, options, columns) {
|
|
|
142
142
|
if (options.includeHeaders) {
|
|
143
143
|
const header = findGridHeader(apiRef.current, column.field);
|
|
144
144
|
if (header) {
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const iconContainer = header.querySelector(`.${gridClasses.iconButtonContainer}`);
|
|
145
|
+
const titleContainer = header.querySelector(`.${gridClasses.columnHeaderTitleContainer}`);
|
|
146
|
+
const children = Array.from(titleContainer.children);
|
|
148
147
|
const menuContainer = header.querySelector(`.${gridClasses.menuIcon}`);
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
148
|
+
const titleContainerStyle = window.getComputedStyle(titleContainer, null);
|
|
149
|
+
const gap = parseInt(titleContainerStyle.gap, 10) || 0;
|
|
150
|
+
const headerStyle = window.getComputedStyle(header, null);
|
|
151
|
+
const paddingWidth = parseInt(headerStyle.paddingLeft, 10) + parseInt(headerStyle.paddingRight, 10);
|
|
152
|
+
let totalChildren = 0;
|
|
153
|
+
let childrenWidth = 0;
|
|
154
|
+
for (let i = 0; i < children.length; i += 1) {
|
|
155
|
+
const child = children[i];
|
|
156
|
+
if (child.clientWidth > 0) {
|
|
157
|
+
totalChildren += 1;
|
|
158
|
+
childrenWidth += child.scrollWidth;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
childrenWidth += 1;
|
|
162
|
+
const width = childrenWidth + gap * (totalChildren - 1) + paddingWidth + (menuContainer?.clientWidth ?? 0);
|
|
154
163
|
filteredWidths.push(width);
|
|
155
164
|
}
|
|
156
165
|
}
|
|
@@ -115,7 +115,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
115
115
|
params: fetchParams,
|
|
116
116
|
cause: originalError
|
|
117
117
|
}));
|
|
118
|
-
} else
|
|
118
|
+
} else {
|
|
119
119
|
warnOnce(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -170,7 +170,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
|
|
|
170
170
|
params,
|
|
171
171
|
cause: errorThrown
|
|
172
172
|
}));
|
|
173
|
-
} else
|
|
173
|
+
} else {
|
|
174
174
|
warnOnce(['MUI X: A call to `dataSource.updateRow()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
175
175
|
}
|
|
176
176
|
throw errorThrown; // Let the caller handle the error further
|
|
@@ -39,7 +39,9 @@ const EMPTY_DIMENSIONS = {
|
|
|
39
39
|
rightPinnedWidth: 0,
|
|
40
40
|
headersTotalHeight: 0,
|
|
41
41
|
topContainerHeight: 0,
|
|
42
|
-
bottomContainerHeight: 0
|
|
42
|
+
bottomContainerHeight: 0,
|
|
43
|
+
autoHeight: false,
|
|
44
|
+
minimalContentHeight: undefined
|
|
43
45
|
};
|
|
44
46
|
export const dimensionsStateInitializer = (state, props, apiRef) => {
|
|
45
47
|
const dimensions = EMPTY_DIMENSIONS;
|
|
@@ -364,7 +364,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
364
364
|
});
|
|
365
365
|
if (onProcessRowUpdateError) {
|
|
366
366
|
onProcessRowUpdateError(errorThrown);
|
|
367
|
-
} else
|
|
367
|
+
} else {
|
|
368
368
|
warnOnce(['MUI X: A call to `processRowUpdate()` threw an error which was not handled because `onProcessRowUpdateError()` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError()` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
|
|
369
369
|
}
|
|
370
370
|
};
|
|
@@ -448,7 +448,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
448
448
|
}
|
|
449
449
|
if (onProcessRowUpdateError) {
|
|
450
450
|
onProcessRowUpdateError(errorThrown);
|
|
451
|
-
} else
|
|
451
|
+
} else {
|
|
452
452
|
warnOnce(['MUI X: A call to `processRowUpdate()` threw an error which was not handled because `onProcessRowUpdateError()` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError()` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
|
|
453
453
|
}
|
|
454
454
|
};
|
|
@@ -76,10 +76,8 @@ const serializeRow = ({
|
|
|
76
76
|
});
|
|
77
77
|
columns.forEach(column => {
|
|
78
78
|
const cellParams = getCellParams(id, column.field);
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
warnOnce(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
82
|
-
}
|
|
79
|
+
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
80
|
+
warnOnce(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
83
81
|
}
|
|
84
82
|
row.addValue(serializeCellValue(cellParams, {
|
|
85
83
|
ignoreValueFormatter,
|
|
@@ -41,24 +41,18 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
|
|
|
41
41
|
const hasSeveralItems = model.items.length > 1;
|
|
42
42
|
let items;
|
|
43
43
|
if (hasSeveralItems && disableMultipleColumnsFiltering) {
|
|
44
|
-
|
|
45
|
-
warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
|
|
46
|
-
}
|
|
44
|
+
warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
|
|
47
45
|
items = [model.items[0]];
|
|
48
46
|
} else {
|
|
49
47
|
items = model.items;
|
|
50
48
|
}
|
|
51
49
|
const hasItemsWithoutIds = hasSeveralItems && items.some(item => item.id == null);
|
|
52
50
|
const hasItemWithoutOperator = items.some(item => item.operator == null);
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
warnOnce('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
|
|
56
|
-
}
|
|
51
|
+
if (hasItemsWithoutIds) {
|
|
52
|
+
warnOnce('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
|
|
57
53
|
}
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
warnOnce('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
|
|
61
|
-
}
|
|
54
|
+
if (hasItemWithoutOperator) {
|
|
55
|
+
warnOnce('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
|
|
62
56
|
}
|
|
63
57
|
if (hasItemWithoutOperator || hasItemsWithoutIds) {
|
|
64
58
|
return _extends({}, model, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { GridFilterState, GridFilterInitialState } from "./gridFilterState.js";
|
|
2
2
|
export { getDefaultGridFilterModel } from "./gridFilterState.js";
|
|
3
|
-
export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from "./gridFilterSelector.js";
|
|
3
|
+
export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector, gridExpandedSortedRowIndexLookupSelector } from "./gridFilterSelector.js";
|
|
4
4
|
export type { GridFilterActiveItemsLookup } from "./gridFilterSelector.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { getDefaultGridFilterModel } from "./gridFilterState.js";
|
|
2
|
-
export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from "./gridFilterSelector.js";
|
|
2
|
+
export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector, gridExpandedSortedRowIndexLookupSelector } from "./gridFilterSelector.js";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { GridRowId } from "../../../models/gridRows.js";
|
|
2
|
+
import type { RowReorderDropPosition } from "../../../models/api/gridRowApi.js";
|
|
1
3
|
/**
|
|
2
4
|
* The row reorder state.
|
|
3
5
|
*/
|
|
@@ -6,4 +8,21 @@ export interface GridRowReorderState {
|
|
|
6
8
|
* Whether a row drag operation is currently active.
|
|
7
9
|
*/
|
|
8
10
|
isActive: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The row ID being dragged.
|
|
13
|
+
*/
|
|
14
|
+
draggedRowId: GridRowId | null;
|
|
15
|
+
/**
|
|
16
|
+
* The current drop target information.
|
|
17
|
+
*/
|
|
18
|
+
dropTarget?: {
|
|
19
|
+
/**
|
|
20
|
+
* The row ID where the drop indicator should be shown.
|
|
21
|
+
*/
|
|
22
|
+
rowId: GridRowId;
|
|
23
|
+
/**
|
|
24
|
+
* The position of the drop indicator relative to the target row.
|
|
25
|
+
*/
|
|
26
|
+
position: RowReorderDropPosition;
|
|
27
|
+
};
|
|
9
28
|
}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
|
|
2
|
+
import type { GridRowId } from "../../../models/gridRows.js";
|
|
2
3
|
export declare const gridRowReorderStateSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, import("./gridRowReorderInterfaces.js").GridRowReorderState>;
|
|
3
4
|
export declare const gridIsRowDragActiveSelector: (args_0: import("react").RefObject<{
|
|
4
5
|
state: GridStateCommunity;
|
|
5
|
-
} | null>) => boolean;
|
|
6
|
+
} | null>) => boolean;
|
|
7
|
+
export declare const gridRowDropTargetSelector: (args_0: import("react").RefObject<{
|
|
8
|
+
state: GridStateCommunity;
|
|
9
|
+
} | null>) => {
|
|
10
|
+
rowId: GridRowId;
|
|
11
|
+
position: import("../../../internals/index.js").RowReorderDropPosition;
|
|
12
|
+
} | {
|
|
13
|
+
rowId: null;
|
|
14
|
+
position: null;
|
|
15
|
+
};
|
|
16
|
+
export declare const gridRowDropTargetRowIdSelector: (args_0: import("react").RefObject<{
|
|
17
|
+
state: GridStateCommunity;
|
|
18
|
+
} | null>) => GridRowId | null;
|
|
19
|
+
export declare const gridRowDropPositionSelector: (args_0: import("react").RefObject<{
|
|
20
|
+
state: GridStateCommunity;
|
|
21
|
+
} | null>, rowId: GridRowId) => import("../../../internals/index.js").RowReorderDropPosition | null;
|
|
22
|
+
export declare const gridDraggedRowIdSelector: (args_0: import("react").RefObject<{
|
|
23
|
+
state: GridStateCommunity;
|
|
24
|
+
} | null>) => GridRowId | null;
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
import { createRootSelector, createSelector } from "../../../utils/createSelector.js";
|
|
2
2
|
export const gridRowReorderStateSelector = createRootSelector(state => state.rowReorder);
|
|
3
|
-
export const gridIsRowDragActiveSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.isActive ?? false);
|
|
3
|
+
export const gridIsRowDragActiveSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.isActive ?? false);
|
|
4
|
+
|
|
5
|
+
// Selector for the entire drop target state
|
|
6
|
+
export const gridRowDropTargetSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.dropTarget ?? {
|
|
7
|
+
rowId: null,
|
|
8
|
+
position: null
|
|
9
|
+
});
|
|
10
|
+
export const gridRowDropTargetRowIdSelector = createSelector(gridRowDropTargetSelector, dropTarget => dropTarget.rowId ?? null);
|
|
11
|
+
|
|
12
|
+
// Selector for a specific row's drop position
|
|
13
|
+
export const gridRowDropPositionSelector = createSelector(gridRowDropTargetSelector, (dropTarget, rowId) => {
|
|
14
|
+
if (dropTarget.rowId === rowId) {
|
|
15
|
+
return dropTarget.position;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Selector for the dragged row ID
|
|
21
|
+
export const gridDraggedRowIdSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.draggedRowId ?? null);
|
|
@@ -100,6 +100,14 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
100
100
|
const currentModel = gridRowSelectionStateSelector(apiRef);
|
|
101
101
|
if (currentModel !== model) {
|
|
102
102
|
logger.debug(`Setting selection model`);
|
|
103
|
+
|
|
104
|
+
// clear the reference to the last selected row if that row is not in the model anymore
|
|
105
|
+
if (lastRowToggled.current !== null) {
|
|
106
|
+
const isInModel = model.ids.has(lastRowToggled.current);
|
|
107
|
+
if (model.type === 'include' && !isInModel || model.type === 'exclude' && isInModel) {
|
|
108
|
+
lastRowToggled.current = null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
103
111
|
apiRef.current.setState(state => _extends({}, state, {
|
|
104
112
|
rowSelection: props.rowSelection ? model : emptyModel
|
|
105
113
|
}), reason);
|
|
@@ -128,7 +136,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
128
136
|
return;
|
|
129
137
|
}
|
|
130
138
|
const tree = gridRowTreeSelector(apiRef);
|
|
131
|
-
lastRowToggled.current = id;
|
|
139
|
+
lastRowToggled.current = isSelected ? id : null;
|
|
132
140
|
if (resetSelection) {
|
|
133
141
|
logger.debug(`Setting selection for row ${id}`);
|
|
134
142
|
const newSelectionModel = {
|
|
@@ -52,7 +52,8 @@ export const useGridRows = (apiRef, props, configuration) => {
|
|
|
52
52
|
|
|
53
53
|
// Get overridable methods from configuration
|
|
54
54
|
const {
|
|
55
|
-
setRowIndex
|
|
55
|
+
setRowIndex,
|
|
56
|
+
setRowPosition
|
|
56
57
|
} = configuration.hooks.useGridRowsOverridableMethods(apiRef, props);
|
|
57
58
|
const getRow = React.useCallback(id => {
|
|
58
59
|
const model = gridRowsLookupSelector(apiRef)[id];
|
|
@@ -337,6 +338,7 @@ export const useGridRows = (apiRef, props, configuration) => {
|
|
|
337
338
|
};
|
|
338
339
|
const rowProApi = {
|
|
339
340
|
setRowIndex,
|
|
341
|
+
setRowPosition,
|
|
340
342
|
setRowChildrenExpansion,
|
|
341
343
|
getRowGroupChildren,
|
|
342
344
|
expandAllRows,
|
|
@@ -3,4 +3,5 @@ import { GridRowId } from "../../../models/gridRows.js";
|
|
|
3
3
|
import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
4
4
|
export declare const useGridRowsOverridableMethods: (apiRef: RefObject<GridPrivateApiCommunity>) => {
|
|
5
5
|
setRowIndex: (rowId: GridRowId, targetIndex: number) => void;
|
|
6
|
+
setRowPosition: (sourceRowId: GridRowId, targetRowId: GridRowId, position: import("../../../internals/index.js").RowReorderDropPosition) => void | Promise<void>;
|
|
6
7
|
};
|