@mui/x-data-grid 8.12.0 → 8.13.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 +145 -0
- package/DataGrid/DataGrid.js +2 -1
- package/DataGrid/useDataGridComponent.js +2 -2
- package/components/GridLoadingOverlay.d.ts +1 -1
- package/components/GridRow.js +3 -7
- package/components/GridScrollShadows.d.ts +6 -0
- package/components/GridScrollShadows.js +108 -0
- package/components/GridScrollbarFillerCell.d.ts +0 -6
- package/components/GridScrollbarFillerCell.js +1 -7
- package/components/GridSkeletonLoadingOverlay.js +3 -10
- package/components/base/GridOverlays.d.ts +1 -3
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +0 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +1 -3
- package/components/containers/GridRootStyles.js +6 -21
- package/components/toolbarV8/GridToolbar.js +12 -10
- package/components/virtualization/GridMainContainer.d.ts +1 -2
- package/components/virtualization/GridVirtualScrollbar.d.ts +1 -0
- package/components/virtualization/GridVirtualScrollbar.js +21 -25
- package/components/virtualization/GridVirtualScroller.js +31 -12
- package/components/virtualization/GridVirtualScrollerFiller.js +2 -4
- package/constants/gridClasses.d.ts +0 -20
- package/constants/gridClasses.js +2 -2
- package/esm/DataGrid/DataGrid.js +2 -1
- package/esm/DataGrid/useDataGridComponent.js +2 -2
- package/esm/components/GridLoadingOverlay.d.ts +1 -1
- package/esm/components/GridRow.js +3 -7
- package/esm/components/GridScrollShadows.d.ts +6 -0
- package/esm/components/GridScrollShadows.js +103 -0
- package/esm/components/GridScrollbarFillerCell.d.ts +0 -6
- package/esm/components/GridScrollbarFillerCell.js +1 -7
- package/esm/components/GridSkeletonLoadingOverlay.js +3 -10
- package/esm/components/base/GridOverlays.d.ts +1 -3
- package/esm/components/columnHeaders/GridColumnHeaderItem.d.ts +0 -1
- package/esm/components/columnHeaders/GridColumnHeaderItem.js +1 -3
- package/esm/components/containers/GridRootStyles.js +6 -21
- package/esm/components/toolbarV8/GridToolbar.js +12 -10
- package/esm/components/virtualization/GridMainContainer.d.ts +1 -2
- package/esm/components/virtualization/GridVirtualScrollbar.d.ts +1 -0
- package/esm/components/virtualization/GridVirtualScrollbar.js +20 -24
- package/esm/components/virtualization/GridVirtualScroller.js +32 -13
- package/esm/components/virtualization/GridVirtualScrollerFiller.js +2 -4
- package/esm/constants/gridClasses.d.ts +0 -20
- package/esm/constants/gridClasses.js +2 -2
- package/esm/hooks/core/useGridVirtualizer.js +4 -0
- package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -10
- package/esm/hooks/features/columnResize/useGridColumnResize.js +16 -0
- package/esm/hooks/features/dataSource/useGridDataSourceBase.js +6 -0
- package/esm/hooks/features/index.d.ts +2 -1
- package/esm/hooks/features/index.js +2 -1
- package/esm/hooks/features/overlays/gridOverlaysInterfaces.d.ts +3 -0
- package/esm/hooks/features/overlays/gridOverlaysInterfaces.js +1 -0
- package/esm/hooks/features/overlays/index.d.ts +1 -0
- package/esm/hooks/features/overlays/index.js +1 -0
- package/esm/hooks/features/overlays/useGridOverlays.d.ts +6 -8
- package/esm/hooks/features/overlays/useGridOverlays.js +3 -27
- package/esm/hooks/features/rows/useGridParamsApi.d.ts +2 -1
- package/esm/hooks/features/rows/useGridParamsApi.js +5 -24
- package/esm/hooks/features/rows/useGridParamsOverridableMethods.d.ts +7 -0
- package/esm/hooks/features/rows/useGridParamsOverridableMethods.js +28 -0
- package/esm/hooks/features/rows/useGridRowSpanning.js +4 -1
- package/esm/hooks/features/rows/useGridRows.js +41 -1
- package/esm/hooks/features/sorting/gridSortingUtils.d.ts +1 -3
- package/esm/hooks/features/sorting/gridSortingUtils.js +4 -6
- package/esm/hooks/features/sorting/useGridSorting.d.ts +1 -2
- package/esm/hooks/features/sorting/useGridSorting.js +3 -4
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/material/variables.js +2 -2
- package/esm/models/api/gridRowApi.d.ts +10 -0
- package/esm/models/configuration/gridAggregationConfiguration.d.ts +0 -6
- package/esm/models/configuration/gridConfiguration.d.ts +2 -1
- package/esm/models/configuration/gridParamsConfiguration.d.ts +12 -0
- package/esm/models/configuration/gridParamsConfiguration.js +1 -0
- package/esm/models/props/DataGridProps.d.ts +10 -0
- package/esm/utils/cellBorderUtils.d.ts +3 -2
- package/esm/utils/cellBorderUtils.js +7 -4
- package/hooks/core/useGridVirtualizer.js +4 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -10
- package/hooks/features/columnResize/useGridColumnResize.js +16 -0
- package/hooks/features/dataSource/useGridDataSourceBase.js +6 -0
- package/hooks/features/index.d.ts +2 -1
- package/hooks/features/index.js +11 -0
- package/hooks/features/overlays/gridOverlaysInterfaces.d.ts +3 -0
- package/hooks/features/overlays/gridOverlaysInterfaces.js +5 -0
- package/hooks/features/overlays/index.d.ts +1 -0
- package/hooks/features/overlays/index.js +5 -0
- package/hooks/features/overlays/useGridOverlays.d.ts +6 -8
- package/hooks/features/overlays/useGridOverlays.js +3 -28
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
- package/hooks/features/rows/useGridParamsApi.js +5 -24
- package/hooks/features/rows/useGridParamsOverridableMethods.d.ts +7 -0
- package/hooks/features/rows/useGridParamsOverridableMethods.js +36 -0
- package/hooks/features/rows/useGridRowSpanning.js +4 -1
- package/hooks/features/rows/useGridRows.js +41 -1
- package/hooks/features/sorting/gridSortingUtils.d.ts +1 -3
- package/hooks/features/sorting/gridSortingUtils.js +4 -6
- package/hooks/features/sorting/useGridSorting.d.ts +1 -2
- package/hooks/features/sorting/useGridSorting.js +3 -4
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +8 -0
- package/material/variables.js +2 -2
- package/models/api/gridRowApi.d.ts +10 -0
- package/models/configuration/gridAggregationConfiguration.d.ts +0 -6
- package/models/configuration/gridConfiguration.d.ts +2 -1
- package/models/configuration/gridParamsConfiguration.d.ts +12 -0
- package/models/configuration/gridParamsConfiguration.js +5 -0
- package/models/props/DataGridProps.d.ts +10 -0
- package/package.json +3 -3
- package/utils/cellBorderUtils.d.ts +3 -2
- package/utils/cellBorderUtils.js +7 -4
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import * as React from 'react';
|
|
3
1
|
import { useGridSelector } from "../../utils/index.js";
|
|
4
|
-
import { useGridApiContext } from "../../utils/useGridApiContext.js";
|
|
5
|
-
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
6
2
|
import { gridExpandedRowCountSelector } from "../filter/index.js";
|
|
7
3
|
import { gridRowCountSelector, gridRowsLoadingSelector } from "../rows/index.js";
|
|
8
4
|
import { gridPinnedRowsCountSelector } from "../rows/gridRowsSelector.js";
|
|
9
|
-
import { GridOverlayWrapper } from "../../../components/base/GridOverlays.js";
|
|
10
5
|
import { gridVisibleColumnDefinitionsSelector } from "../columns/index.js";
|
|
11
6
|
import { gridPivotActiveSelector } from "../pivoting/index.js";
|
|
12
|
-
|
|
13
7
|
/**
|
|
14
8
|
* Uses the grid state to determine which overlay to display.
|
|
15
9
|
* Returns the active overlay type and the active loading overlay variant.
|
|
16
10
|
*/
|
|
17
|
-
|
|
18
|
-
export const useGridOverlays = () => {
|
|
19
|
-
const apiRef = useGridApiContext();
|
|
20
|
-
const rootProps = useGridRootProps();
|
|
11
|
+
export const useGridOverlays = (apiRef, props) => {
|
|
21
12
|
const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
|
|
22
13
|
const visibleRowCount = useGridSelector(apiRef, gridExpandedRowCountSelector);
|
|
23
14
|
const pinnedRowsCount = useGridSelector(apiRef, gridPinnedRowsCountSelector);
|
|
@@ -45,25 +36,10 @@ export const useGridOverlays = () => {
|
|
|
45
36
|
}
|
|
46
37
|
if (loading) {
|
|
47
38
|
overlayType = 'loadingOverlay';
|
|
48
|
-
loadingOverlayVariant =
|
|
39
|
+
loadingOverlayVariant = props.slotProps?.loadingOverlay?.[noRows ? 'noRowsVariant' : 'variant'] ?? (noRows ? 'skeleton' : 'linear-progress');
|
|
49
40
|
}
|
|
50
|
-
|
|
41
|
+
return {
|
|
51
42
|
overlayType: overlayType,
|
|
52
43
|
loadingOverlayVariant
|
|
53
44
|
};
|
|
54
|
-
const getOverlay = () => {
|
|
55
|
-
if (!overlayType) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const Overlay = rootProps.slots?.[overlayType];
|
|
59
|
-
const overlayProps = rootProps.slotProps?.[overlayType];
|
|
60
|
-
return /*#__PURE__*/_jsx(GridOverlayWrapper, _extends({}, overlaysProps, {
|
|
61
|
-
children: /*#__PURE__*/_jsx(Overlay, _extends({}, overlayProps))
|
|
62
|
-
}));
|
|
63
|
-
};
|
|
64
|
-
if (process.env.NODE_ENV !== "production") getOverlay.displayName = "getOverlay";
|
|
65
|
-
return {
|
|
66
|
-
getOverlay,
|
|
67
|
-
overlaysProps
|
|
68
|
-
};
|
|
69
45
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
3
3
|
import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
4
|
+
import type { GridConfiguration } from "../../../models/configuration/gridConfiguration.js";
|
|
4
5
|
export declare class MissingRowIdError extends Error {}
|
|
5
6
|
/**
|
|
6
7
|
* @requires useGridColumns (method)
|
|
@@ -10,4 +11,4 @@ export declare class MissingRowIdError extends Error {}
|
|
|
10
11
|
* TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
|
|
11
12
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
12
13
|
*/
|
|
13
|
-
export declare function useGridParamsApi(apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps): void;
|
|
14
|
+
export declare function useGridParamsApi(apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps, configuration: GridConfiguration): void;
|
|
@@ -4,7 +4,6 @@ import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
|
4
4
|
import { gridFocusCellSelector, gridTabIndexCellSelector } from "../focus/gridFocusStateSelector.js";
|
|
5
5
|
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
6
6
|
import { gridRowNodeSelector } from "./gridRowsSelector.js";
|
|
7
|
-
import { getRowValue as getRowValueFn } from "./gridRowsUtils.js";
|
|
8
7
|
export class MissingRowIdError extends Error {}
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -15,7 +14,7 @@ export class MissingRowIdError extends Error {}
|
|
|
15
14
|
* TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
|
|
16
15
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
17
16
|
*/
|
|
18
|
-
export function useGridParamsApi(apiRef, props) {
|
|
17
|
+
export function useGridParamsApi(apiRef, props, configuration) {
|
|
19
18
|
const getColumnHeaderParams = React.useCallback(field => ({
|
|
20
19
|
field,
|
|
21
20
|
colDef: apiRef.current.getColumn(field)
|
|
@@ -87,25 +86,6 @@ export function useGridParamsApi(apiRef, props) {
|
|
|
87
86
|
cellMode
|
|
88
87
|
});
|
|
89
88
|
}, [apiRef, props.listView, props.listViewColumn?.field]);
|
|
90
|
-
const getCellValue = React.useCallback((id, field) => {
|
|
91
|
-
const colDef = apiRef.current.getColumn(field);
|
|
92
|
-
const row = apiRef.current.getRow(id);
|
|
93
|
-
if (!row) {
|
|
94
|
-
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
95
|
-
}
|
|
96
|
-
if (!colDef || !colDef.valueGetter) {
|
|
97
|
-
return row[field];
|
|
98
|
-
}
|
|
99
|
-
return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
|
|
100
|
-
}, [apiRef]);
|
|
101
|
-
const getRowValue = React.useCallback((row, colDef) => getRowValueFn(row, colDef, apiRef), [apiRef]);
|
|
102
|
-
const getRowFormattedValue = React.useCallback((row, colDef) => {
|
|
103
|
-
const value = getRowValue(row, colDef);
|
|
104
|
-
if (!colDef || !colDef.valueFormatter) {
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
return colDef.valueFormatter(value, row, colDef, apiRef);
|
|
108
|
-
}, [apiRef, getRowValue]);
|
|
109
89
|
const getColumnHeaderElement = React.useCallback(field => {
|
|
110
90
|
if (!apiRef.current.rootElementRef.current) {
|
|
111
91
|
return null;
|
|
@@ -127,12 +107,13 @@ export function useGridParamsApi(apiRef, props) {
|
|
|
127
107
|
field
|
|
128
108
|
});
|
|
129
109
|
}, [apiRef]);
|
|
110
|
+
const overridableParamsMethods = configuration.hooks.useGridParamsOverridableMethods(apiRef);
|
|
130
111
|
const paramsApi = {
|
|
131
|
-
getCellValue,
|
|
112
|
+
getCellValue: overridableParamsMethods.getCellValue,
|
|
132
113
|
getCellParams,
|
|
133
114
|
getCellElement,
|
|
134
|
-
getRowValue,
|
|
135
|
-
getRowFormattedValue,
|
|
115
|
+
getRowValue: overridableParamsMethods.getRowValue,
|
|
116
|
+
getRowFormattedValue: overridableParamsMethods.getRowFormattedValue,
|
|
136
117
|
getRowParams,
|
|
137
118
|
getRowElement,
|
|
138
119
|
getColumnHeaderParams,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
3
|
+
export declare const useGridParamsOverridableMethods: (apiRef: RefObject<GridPrivateApiCommunity>) => {
|
|
4
|
+
getCellValue: <V = any>(id: import("@mui/x-data-grid").GridRowId, field: string) => V;
|
|
5
|
+
getRowValue: <V = any>(row: import("@mui/x-data-grid").GridRowModel, colDef: import("@mui/x-data-grid").GridColDef) => V;
|
|
6
|
+
getRowFormattedValue: <V = any>(row: import("@mui/x-data-grid").GridRowModel, colDef: import("@mui/x-data-grid").GridColDef) => V;
|
|
7
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getRowValue as getRowValueFn } from "./gridRowsUtils.js";
|
|
3
|
+
export const useGridParamsOverridableMethods = apiRef => {
|
|
4
|
+
const getCellValue = React.useCallback((id, field) => {
|
|
5
|
+
const colDef = apiRef.current.getColumn(field);
|
|
6
|
+
const row = apiRef.current.getRow(id);
|
|
7
|
+
if (!row) {
|
|
8
|
+
throw new Error(`No row with id #${id} found`);
|
|
9
|
+
}
|
|
10
|
+
if (!colDef || !colDef.valueGetter) {
|
|
11
|
+
return row[field];
|
|
12
|
+
}
|
|
13
|
+
return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
|
|
14
|
+
}, [apiRef]);
|
|
15
|
+
const getRowValue = React.useCallback((row, colDef) => getRowValueFn(row, colDef, apiRef), [apiRef]);
|
|
16
|
+
const getRowFormattedValue = React.useCallback((row, colDef) => {
|
|
17
|
+
const value = getRowValue(row, colDef);
|
|
18
|
+
if (!colDef || !colDef.valueFormatter) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
return colDef.valueFormatter(value, row, colDef, apiRef);
|
|
22
|
+
}, [apiRef, getRowValue]);
|
|
23
|
+
return {
|
|
24
|
+
getCellValue,
|
|
25
|
+
getRowValue,
|
|
26
|
+
getRowFormattedValue
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -186,6 +186,9 @@ export const useGridRowSpanning = (apiRef, props) => {
|
|
|
186
186
|
range,
|
|
187
187
|
rows: visibleRows
|
|
188
188
|
} = getVisibleRows(apiRef);
|
|
189
|
+
if (resetState && store.getSnapshot().rowSpanning !== EMPTY_STATE) {
|
|
190
|
+
store.set('rowSpanning', EMPTY_STATE);
|
|
191
|
+
}
|
|
189
192
|
if (range === null || !isRowContextInitialized(renderContext)) {
|
|
190
193
|
return;
|
|
191
194
|
}
|
|
@@ -212,7 +215,7 @@ export const useGridRowSpanning = (apiRef, props) => {
|
|
|
212
215
|
}, [apiRef, store]);
|
|
213
216
|
|
|
214
217
|
// Reset events trigger a full re-computation of the row spanning state:
|
|
215
|
-
// - The `
|
|
218
|
+
// - The `rowSpanning` prop is updated (feature flag)
|
|
216
219
|
// - The filtering is applied
|
|
217
220
|
// - The sorting is applied
|
|
218
221
|
// - The `paginationModel` is updated
|
|
@@ -198,6 +198,44 @@ export const useGridRows = (apiRef, props, configuration) => {
|
|
|
198
198
|
});
|
|
199
199
|
apiRef.current.publishEvent('rowExpansionChange', newNode);
|
|
200
200
|
}, [apiRef]);
|
|
201
|
+
const expandAllRows = React.useCallback(() => {
|
|
202
|
+
const tree = _extends({}, gridRowTreeSelector(apiRef));
|
|
203
|
+
const traverse = nodeId => {
|
|
204
|
+
const node = tree[nodeId];
|
|
205
|
+
if (node?.type === 'group') {
|
|
206
|
+
tree[nodeId] = _extends({}, node, {
|
|
207
|
+
childrenExpanded: true
|
|
208
|
+
});
|
|
209
|
+
node.children.forEach(traverse);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
traverse(GRID_ROOT_GROUP_ID);
|
|
213
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
214
|
+
rows: _extends({}, state.rows, {
|
|
215
|
+
tree
|
|
216
|
+
})
|
|
217
|
+
}));
|
|
218
|
+
apiRef.current.publishEvent('rowExpansionChange', tree[GRID_ROOT_GROUP_ID]);
|
|
219
|
+
}, [apiRef]);
|
|
220
|
+
const collapseAllRows = React.useCallback(() => {
|
|
221
|
+
const tree = _extends({}, gridRowTreeSelector(apiRef));
|
|
222
|
+
const traverse = nodeId => {
|
|
223
|
+
const node = tree[nodeId];
|
|
224
|
+
if (node?.type === 'group') {
|
|
225
|
+
tree[nodeId] = _extends({}, node, {
|
|
226
|
+
childrenExpanded: false
|
|
227
|
+
});
|
|
228
|
+
node.children.forEach(traverse);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
traverse(GRID_ROOT_GROUP_ID);
|
|
232
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
233
|
+
rows: _extends({}, state.rows, {
|
|
234
|
+
tree
|
|
235
|
+
})
|
|
236
|
+
}));
|
|
237
|
+
apiRef.current.publishEvent('rowExpansionChange', tree[GRID_ROOT_GROUP_ID]);
|
|
238
|
+
}, [apiRef]);
|
|
201
239
|
const getRowNode = React.useCallback(id => gridRowNodeSelector(apiRef, id) ?? null, [apiRef]);
|
|
202
240
|
const getRowGroupChildren = React.useCallback(({
|
|
203
241
|
skipAutoGeneratedRows = true,
|
|
@@ -300,7 +338,9 @@ export const useGridRows = (apiRef, props, configuration) => {
|
|
|
300
338
|
const rowProApi = {
|
|
301
339
|
setRowIndex,
|
|
302
340
|
setRowChildrenExpansion,
|
|
303
|
-
getRowGroupChildren
|
|
341
|
+
getRowGroupChildren,
|
|
342
|
+
expandAllRows,
|
|
343
|
+
collapseAllRows
|
|
304
344
|
};
|
|
305
345
|
const rowProPrivateApi = {
|
|
306
346
|
updateNestedRows
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridSortingModelApplier } from "./gridSortingState.js";
|
|
3
|
-
import type { GridRowId } from "../../../models/index.js";
|
|
4
3
|
import { GridApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
5
4
|
import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
|
|
6
5
|
import { GridComparatorFn, GridSortDirection, GridSortModel } from "../../../models/gridSortModel.js";
|
|
@@ -9,11 +8,10 @@ export declare const mergeStateWithSortModel: (sortModel: GridSortModel, disable
|
|
|
9
8
|
/**
|
|
10
9
|
* Generates a method to easily sort a list of rows according to the current sort model.
|
|
11
10
|
* @param {GridSortModel} sortModel The model with which we want to sort the rows.
|
|
12
|
-
* @param {Function} sortValueGetter A function to get the value to sort by.
|
|
13
11
|
* @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
14
12
|
* @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
|
|
15
13
|
*/
|
|
16
|
-
export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel,
|
|
14
|
+
export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, apiRef: RefObject<GridApiCommunity>) => GridSortingModelApplier | null;
|
|
17
15
|
export declare const getNextGridSortDirection: (sortingOrder: readonly GridSortDirection[], current?: GridSortDirection) => GridSortDirection;
|
|
18
16
|
export declare const gridStringOrNumberComparator: GridComparatorFn;
|
|
19
17
|
export declare const gridNumberComparator: GridComparatorFn;
|
|
@@ -24,11 +24,10 @@ const isDesc = direction => direction === 'desc';
|
|
|
24
24
|
*
|
|
25
25
|
* Transform an item of the sorting model into a method comparing two rows.
|
|
26
26
|
* @param {GridSortItem} sortItem The sort item we want to apply.
|
|
27
|
-
* @param {Function} sortValueGetter A function to get the value to sort by.
|
|
28
27
|
* @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
29
28
|
* @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
|
|
30
29
|
*/
|
|
31
|
-
const parseSortItem = (sortItem,
|
|
30
|
+
const parseSortItem = (sortItem, apiRef) => {
|
|
32
31
|
const column = apiRef.current.getColumn(sortItem.field);
|
|
33
32
|
if (!column || sortItem.sort === null) {
|
|
34
33
|
return null;
|
|
@@ -46,7 +45,7 @@ const parseSortItem = (sortItem, sortValueGetter, apiRef) => {
|
|
|
46
45
|
id,
|
|
47
46
|
field: column.field,
|
|
48
47
|
rowNode: gridRowNodeSelector(apiRef, id),
|
|
49
|
-
value:
|
|
48
|
+
value: apiRef.current.getCellValue(id, column.field),
|
|
50
49
|
api: apiRef.current
|
|
51
50
|
});
|
|
52
51
|
return {
|
|
@@ -78,12 +77,11 @@ const compareRows = (parsedSortItems, row1, row2) => {
|
|
|
78
77
|
/**
|
|
79
78
|
* Generates a method to easily sort a list of rows according to the current sort model.
|
|
80
79
|
* @param {GridSortModel} sortModel The model with which we want to sort the rows.
|
|
81
|
-
* @param {Function} sortValueGetter A function to get the value to sort by.
|
|
82
80
|
* @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
83
81
|
* @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
|
|
84
82
|
*/
|
|
85
|
-
export const buildAggregatedSortingApplier = (sortModel,
|
|
86
|
-
const comparatorList = sortModel.map(item => parseSortItem(item,
|
|
83
|
+
export const buildAggregatedSortingApplier = (sortModel, apiRef) => {
|
|
84
|
+
const comparatorList = sortModel.map(item => parseSortItem(item, apiRef)).filter(comparator => !!comparator);
|
|
87
85
|
if (comparatorList.length === 0) {
|
|
88
86
|
return null;
|
|
89
87
|
}
|
|
@@ -2,10 +2,9 @@ import { RefObject } from '@mui/x-internals/types';
|
|
|
2
2
|
import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
|
|
3
3
|
import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
|
|
4
4
|
import { GridStateInitializer } from "../../utils/useGridInitializeState.js";
|
|
5
|
-
import type { GridConfiguration } from "../../../models/configuration/gridConfiguration.js";
|
|
6
5
|
export declare const sortingStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'sortModel' | 'initialState' | 'disableMultipleColumnsSorting'>>;
|
|
7
6
|
/**
|
|
8
7
|
* @requires useGridRows (event)
|
|
9
8
|
* @requires useGridColumns (event)
|
|
10
9
|
*/
|
|
11
|
-
export declare const useGridSorting: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState" | "sortModel" | "onSortModelChange" | "sortingOrder" | "sortingMode" | "disableColumnSorting" | "disableMultipleColumnsSorting" | "multipleColumnsSortingMode"
|
|
10
|
+
export declare const useGridSorting: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState" | "sortModel" | "onSortModelChange" | "sortingOrder" | "sortingMode" | "disableColumnSorting" | "disableMultipleColumnsSorting" | "multipleColumnsSortingMode">) => void;
|
|
@@ -26,7 +26,7 @@ export const sortingStateInitializer = (state, props) => {
|
|
|
26
26
|
* @requires useGridRows (event)
|
|
27
27
|
* @requires useGridColumns (event)
|
|
28
28
|
*/
|
|
29
|
-
export const useGridSorting = (apiRef, props
|
|
29
|
+
export const useGridSorting = (apiRef, props) => {
|
|
30
30
|
const logger = useGridLogger(apiRef, 'useGridSorting');
|
|
31
31
|
apiRef.current.registerControlState({
|
|
32
32
|
stateId: 'sortModel',
|
|
@@ -79,7 +79,6 @@ export const useGridSorting = (apiRef, props, configuration) => {
|
|
|
79
79
|
* API METHODS
|
|
80
80
|
*/
|
|
81
81
|
const applySorting = React.useCallback(() => {
|
|
82
|
-
const sortValueGetter = configuration.hooks.useSortValueGetter(apiRef);
|
|
83
82
|
apiRef.current.setState(state => {
|
|
84
83
|
if (props.sortingMode === 'server') {
|
|
85
84
|
logger.debug('Skipping sorting rows as sortingMode = server');
|
|
@@ -90,7 +89,7 @@ export const useGridSorting = (apiRef, props, configuration) => {
|
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
const sortModel = gridSortModelSelector(apiRef);
|
|
93
|
-
const sortRowList = buildAggregatedSortingApplier(sortModel,
|
|
92
|
+
const sortRowList = buildAggregatedSortingApplier(sortModel, apiRef);
|
|
94
93
|
const sortedRows = apiRef.current.applyStrategyProcessor('sorting', {
|
|
95
94
|
sortRowList
|
|
96
95
|
});
|
|
@@ -101,7 +100,7 @@ export const useGridSorting = (apiRef, props, configuration) => {
|
|
|
101
100
|
});
|
|
102
101
|
});
|
|
103
102
|
apiRef.current.publishEvent('sortedRowsSet');
|
|
104
|
-
}, [apiRef, logger,
|
|
103
|
+
}, [apiRef, logger, props.sortingMode]);
|
|
105
104
|
const setSortModel = React.useCallback(model => {
|
|
106
105
|
const currentModel = gridSortModelSelector(apiRef);
|
|
107
106
|
if (currentModel !== model) {
|
package/esm/index.js
CHANGED
package/esm/internals/index.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export { useGridRowSpanning, rowSpanningStateInitializer } from "../hooks/featur
|
|
|
55
55
|
export { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
|
|
56
56
|
export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
|
|
57
57
|
export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
|
|
58
|
+
export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
|
|
58
59
|
export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
|
|
59
60
|
export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRowsValue, GridRowsPartialUpdates, GridRowsPartialUpdateAction, GridTreeDepths, GridRowTreeUpdatedGroupsManager, GridRowTreeUpdateGroupAction, GridPinnedRowsState } from "../hooks/features/rows/gridRowsInterfaces.js";
|
|
60
61
|
export { getTreeNodeDescendants, buildRootGroup } from "../hooks/features/rows/gridRowsUtils.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -44,6 +44,7 @@ export { useGridRowSpanning, rowSpanningStateInitializer } from "../hooks/featur
|
|
|
44
44
|
export { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
|
|
45
45
|
export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
|
|
46
46
|
export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
|
|
47
|
+
export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
|
|
47
48
|
export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
|
|
48
49
|
export { getTreeNodeDescendants, buildRootGroup } from "../hooks/features/rows/gridRowsUtils.js";
|
|
49
50
|
export { useGridRowsMeta, rowsMetaStateInitializer } from "../hooks/features/rows/useGridRowsMeta.js";
|
|
@@ -17,11 +17,11 @@ export function useMaterialCSSVariables() {
|
|
|
17
17
|
function transformTheme(t) {
|
|
18
18
|
const borderColor = getBorderColor(t);
|
|
19
19
|
const dataGridPalette = (t.vars || t).palette.DataGrid;
|
|
20
|
-
const backgroundBase = dataGridPalette?.bg ?? (t.vars || t).palette.background.
|
|
20
|
+
const backgroundBase = dataGridPalette?.bg ?? (t.palette.mode === 'dark' ? `color-mix(in srgb, ${(t.vars || t).palette.background.paper} 95%, #fff)` : (t.vars || t).palette.background.paper);
|
|
21
21
|
const backgroundHeader = dataGridPalette?.headerBg ?? backgroundBase;
|
|
22
22
|
const backgroundPinned = dataGridPalette?.pinnedBg ?? backgroundBase;
|
|
23
23
|
const backgroundBackdrop = t.vars ? `rgba(${t.vars.palette.background.defaultChannel} / ${t.vars.palette.action.disabledOpacity})` : alpha(t.palette.background.default, t.palette.action.disabledOpacity);
|
|
24
|
-
const backgroundOverlay = t.palette.mode === 'dark' ? `color-mix(in srgb, ${(t.vars || t).palette.background.paper}
|
|
24
|
+
const backgroundOverlay = t.palette.mode === 'dark' ? `color-mix(in srgb, ${(t.vars || t).palette.background.paper} 90%, #fff)` : (t.vars || t).palette.background.paper;
|
|
25
25
|
const selectedColor = t.vars ? `rgb(${t.vars.palette.primary.mainChannel})` : t.palette.primary.main;
|
|
26
26
|
const radius = getRadius(t);
|
|
27
27
|
const fontBody = t.vars?.font?.body2 ?? formatFont(t.typography.body2);
|
|
@@ -109,10 +109,20 @@ export interface GridRowProApi {
|
|
|
109
109
|
getRowGroupChildren: (params: GridRowGroupChildrenGetterParams) => GridRowId[];
|
|
110
110
|
/**
|
|
111
111
|
* Expand or collapse a row children.
|
|
112
|
+
* Only works for the client side data or to collapse already fetched server side rows.
|
|
113
|
+
* For server-side data, use `dataSource.fetchRows(childId)` to fetch and expand the children.
|
|
112
114
|
* @param {GridRowId} id the ID of the row to expand or collapse.
|
|
113
115
|
* @param {boolean} isExpanded A boolean indicating if the row must be expanded or collapsed.
|
|
114
116
|
*/
|
|
115
117
|
setRowChildrenExpansion: (id: GridRowId, isExpanded: boolean) => void;
|
|
118
|
+
/**
|
|
119
|
+
* Expand all rows. Works for the client side data only.
|
|
120
|
+
*/
|
|
121
|
+
expandAllRows: () => void;
|
|
122
|
+
/**
|
|
123
|
+
* Collapse all rows. Works for the client side data only.
|
|
124
|
+
*/
|
|
125
|
+
collapseAllRows: () => void;
|
|
116
126
|
}
|
|
117
127
|
export interface GridRowProPrivateApi {
|
|
118
128
|
/**
|
|
@@ -12,14 +12,8 @@ export type GetCellAggregationResultFn = (id: GridRowId, field: string) => {
|
|
|
12
12
|
value: any;
|
|
13
13
|
formattedValue?: any;
|
|
14
14
|
} | null;
|
|
15
|
-
export type SortValueGetterFn = (id: GridRowId, field: string) => any;
|
|
16
15
|
export type FilterValueGetterFn = (row: GridRowModel, colDef: GridColDef) => any;
|
|
17
16
|
export interface GridAggregationInternalHooks<Api, Props> {
|
|
18
17
|
useCellAggregationResult: GetCellAggregationResultFn;
|
|
19
|
-
/**
|
|
20
|
-
* @param {RefObject<Api>} apiRef The API reference
|
|
21
|
-
* @returns {SortValueGetterFn} The function to get the value to sort by
|
|
22
|
-
*/
|
|
23
|
-
useSortValueGetter: (apiRef: RefObject<Api>) => SortValueGetterFn;
|
|
24
18
|
useFilterValueGetter: (apiRef: RefObject<Api>, props: Props) => FilterValueGetterFn;
|
|
25
19
|
}
|
|
@@ -5,10 +5,11 @@ import type { GridCSSVariablesInterface } from "../../constants/cssVariables.js"
|
|
|
5
5
|
import { DataGridProcessedProps } from "../props/DataGridProps.js";
|
|
6
6
|
import type { GridPrivateApiCommon } from "../api/gridApiCommon.js";
|
|
7
7
|
import type { GridPrivateApiCommunity } from "../api/gridApiCommunity.js";
|
|
8
|
+
import type { GridParamsOverridableMethodsInternalHook } from "./gridParamsConfiguration.js";
|
|
8
9
|
export interface GridAriaAttributesInternalHook {
|
|
9
10
|
useGridAriaAttributes: () => React.HTMLAttributes<HTMLElement>;
|
|
10
11
|
}
|
|
11
|
-
export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api> {
|
|
12
|
+
export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api>, GridParamsOverridableMethodsInternalHook<Api> {
|
|
12
13
|
useCSSVariables: () => {
|
|
13
14
|
id: string;
|
|
14
15
|
variables: GridCSSVariablesInterface;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridParamsApi } from "../api/gridParamsApi.js";
|
|
3
|
+
/**
|
|
4
|
+
* Overridable params methods interface, these methods could be overriden in a higher plan package.
|
|
5
|
+
*/
|
|
6
|
+
export interface GridParamsOverridableMethodsInternalHook<Api> {
|
|
7
|
+
useGridParamsOverridableMethods: (apiRef: RefObject<Api>) => {
|
|
8
|
+
getCellValue: GridParamsApi['getCellValue'];
|
|
9
|
+
getRowValue: GridParamsApi['getRowValue'];
|
|
10
|
+
getRowFormattedValue: GridParamsApi['getRowFormattedValue'];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -858,6 +858,16 @@ export interface DataGridProSharedPropsWithDefaultValue {
|
|
|
858
858
|
* @default "withModifierKey"
|
|
859
859
|
*/
|
|
860
860
|
multipleColumnsSortingMode: 'withModifierKey' | 'always';
|
|
861
|
+
/**
|
|
862
|
+
* Sets the type of separator between pinned columns and non-pinned columns.
|
|
863
|
+
* @default 'border-and-shadow'
|
|
864
|
+
*/
|
|
865
|
+
pinnedColumnsSectionSeparator: 'border' | 'shadow' | 'border-and-shadow';
|
|
866
|
+
/**
|
|
867
|
+
* Sets the type of separator between pinned rows and non-pinned rows.
|
|
868
|
+
* @default 'border-and-shadow'
|
|
869
|
+
*/
|
|
870
|
+
pinnedRowsSectionSeparator: 'border' | 'border-and-shadow';
|
|
861
871
|
}
|
|
862
872
|
export interface DataGridProSharedPropsWithoutDefaultValue<R extends GridValidRowModel = any> {
|
|
863
873
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataGridProcessedProps } from "../models/props/DataGridProps.js";
|
|
1
2
|
import { PinnedColumnPosition } from "../internals/constants.js";
|
|
2
|
-
export declare const shouldCellShowRightBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number, sectionLength: number, showCellVerticalBorderRootProp:
|
|
3
|
-
export declare const shouldCellShowLeftBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number) => boolean;
|
|
3
|
+
export declare const shouldCellShowRightBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number, sectionLength: number, showCellVerticalBorderRootProp: DataGridProcessedProps["showCellVerticalBorder"], gridHasFiller: boolean, pinnedColumnsSectionSeparatorRootProp: DataGridProcessedProps["pinnedColumnsSectionSeparator"]) => boolean;
|
|
4
|
+
export declare const shouldCellShowLeftBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number, showCellVerticalBorderRootProp: DataGridProcessedProps["showCellVerticalBorder"], pinnedColumnsSectionSeparatorRootProp: DataGridProcessedProps["pinnedColumnsSectionSeparator"]) => boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PinnedColumnPosition } from "../internals/constants.js";
|
|
2
|
-
export const shouldCellShowRightBorder = (pinnedPosition, indexInSection, sectionLength, showCellVerticalBorderRootProp, gridHasFiller) => {
|
|
2
|
+
export const shouldCellShowRightBorder = (pinnedPosition, indexInSection, sectionLength, showCellVerticalBorderRootProp, gridHasFiller, pinnedColumnsSectionSeparatorRootProp) => {
|
|
3
3
|
const isSectionLastCell = indexInSection === sectionLength - 1;
|
|
4
|
-
if (pinnedPosition === PinnedColumnPosition.LEFT && isSectionLastCell) {
|
|
4
|
+
if (pinnedColumnsSectionSeparatorRootProp?.startsWith('border') && pinnedPosition === PinnedColumnPosition.LEFT && isSectionLastCell) {
|
|
5
5
|
return true;
|
|
6
6
|
}
|
|
7
7
|
if (showCellVerticalBorderRootProp) {
|
|
@@ -16,6 +16,9 @@ export const shouldCellShowRightBorder = (pinnedPosition, indexInSection, sectio
|
|
|
16
16
|
}
|
|
17
17
|
return false;
|
|
18
18
|
};
|
|
19
|
-
export const shouldCellShowLeftBorder = (pinnedPosition, indexInSection) => {
|
|
20
|
-
|
|
19
|
+
export const shouldCellShowLeftBorder = (pinnedPosition, indexInSection, showCellVerticalBorderRootProp, pinnedColumnsSectionSeparatorRootProp) => {
|
|
20
|
+
if (pinnedColumnsSectionSeparatorRootProp?.startsWith('border')) {
|
|
21
|
+
return pinnedPosition === PinnedColumnPosition.RIGHT && indexInSection === 0;
|
|
22
|
+
}
|
|
23
|
+
return showCellVerticalBorderRootProp && pinnedPosition === PinnedColumnPosition.RIGHT && indexInSection === 0;
|
|
21
24
|
};
|
|
@@ -29,6 +29,7 @@ var _rowSelection = require("../features/rowSelection");
|
|
|
29
29
|
var _dataGridPropsDefaultValues = require("../../constants/dataGridPropsDefaultValues");
|
|
30
30
|
var _gridRowsUtils = require("../features/rows/gridRowsUtils");
|
|
31
31
|
var _gridColumnsUtils = require("../features/columns/gridColumnsUtils");
|
|
32
|
+
var _useGridOverlays = require("../features/overlays/useGridOverlays");
|
|
32
33
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
34
|
function identity(x) {
|
|
34
35
|
return x;
|
|
@@ -86,6 +87,7 @@ function useGridVirtualizer(apiRef, rootProps) {
|
|
|
86
87
|
const headersTotalHeight = (0, _gridColumnsUtils.getTotalHeaderHeight)(apiRef, rootProps);
|
|
87
88
|
const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
|
|
88
89
|
const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
|
|
90
|
+
const overlayState = (0, _useGridOverlays.useGridOverlays)(apiRef, rootProps);
|
|
89
91
|
const dimensionsParams = {
|
|
90
92
|
rowHeight,
|
|
91
93
|
headerHeight,
|
|
@@ -148,6 +150,8 @@ function useGridVirtualizer(apiRef, rootProps) {
|
|
|
148
150
|
pinnedRows,
|
|
149
151
|
pinnedColumns,
|
|
150
152
|
autoHeight,
|
|
153
|
+
disableHorizontalScroll: listView,
|
|
154
|
+
disableVerticalScroll: overlayState.overlayType === 'noColumnsOverlay' || overlayState.loadingOverlayVariant === 'skeleton',
|
|
151
155
|
minimalContentHeight: _gridRowsUtils.minimalContentHeight,
|
|
152
156
|
getRowHeight: React.useMemo(() => {
|
|
153
157
|
if (!getRowHeight) {
|
|
@@ -116,10 +116,7 @@ const useGridColumnHeaders = props => {
|
|
|
116
116
|
role: "presentation",
|
|
117
117
|
className: (0, _clsx.default)(_gridClasses.gridClasses.filler, borderBottom && _gridClasses.gridClasses['filler--borderBottom'])
|
|
118
118
|
}), hasScrollbarFiller && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridScrollbarFillerCell.GridScrollbarFillerCell, {
|
|
119
|
-
|
|
120
|
-
pinnedRight: isPinnedRight,
|
|
121
|
-
borderBottom: borderBottom,
|
|
122
|
-
borderTop: false
|
|
119
|
+
pinnedRight: isPinnedRight
|
|
123
120
|
})]
|
|
124
121
|
});
|
|
125
122
|
};
|
|
@@ -141,11 +138,10 @@ const useGridColumnHeaders = props => {
|
|
|
141
138
|
const pinnedOffset = (0, _getPinnedCellOffset.getPinnedCellOffset)(pinnedPosition, colDef.computedWidth, columnIndex, columnPositions, columnsTotalWidth, scrollbarWidth);
|
|
142
139
|
const siblingWithBorderingSeparator = pinnedPosition === _constants.PinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
143
140
|
const isSiblingFocused = siblingWithBorderingSeparator ? columnHeaderFocus !== null && columnHeaderFocus.field === siblingWithBorderingSeparator.field : false;
|
|
144
|
-
const isLastUnpinned = columnIndex + 1 === columnPositions.length - pinnedColumns.right.length;
|
|
145
141
|
const indexInSection = i;
|
|
146
142
|
const sectionLength = renderedColumns.length;
|
|
147
|
-
const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection);
|
|
148
|
-
const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showColumnVerticalBorder, gridHasFiller);
|
|
143
|
+
const showLeftBorder = (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection, rootProps.showColumnVerticalBorder, rootProps.pinnedColumnsSectionSeparator);
|
|
144
|
+
const showRightBorder = (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, sectionLength, rootProps.showColumnVerticalBorder, gridHasFiller, rootProps.pinnedColumnsSectionSeparator);
|
|
149
145
|
columns.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridColumnHeaderItem.GridColumnHeaderItem, (0, _extends2.default)({}, sortColumnLookup[colDef.field], {
|
|
150
146
|
columnMenuOpen: open,
|
|
151
147
|
filterItemsCounter: filterColumnLookup[colDef.field] && filterColumnLookup[colDef.field].length,
|
|
@@ -159,7 +155,6 @@ const useGridColumnHeaders = props => {
|
|
|
159
155
|
tabIndex: tabIndex,
|
|
160
156
|
pinnedPosition: pinnedPosition,
|
|
161
157
|
pinnedOffset: pinnedOffset,
|
|
162
|
-
isLastUnpinned: isLastUnpinned,
|
|
163
158
|
isSiblingFocused: isSiblingFocused,
|
|
164
159
|
showLeftBorder: showLeftBorder,
|
|
165
160
|
showRightBorder: showRightBorder
|
|
@@ -265,8 +260,8 @@ const useGridColumnHeaders = props => {
|
|
|
265
260
|
tabIndex: tabIndex,
|
|
266
261
|
pinnedPosition: pinnedPosition,
|
|
267
262
|
pinnedOffset: pinnedOffset,
|
|
268
|
-
showLeftBorder: (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection),
|
|
269
|
-
showRightBorder: (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, visibleColumnGroupHeader.length, rootProps.showColumnVerticalBorder, gridHasFiller)
|
|
263
|
+
showLeftBorder: (0, _cellBorderUtils.shouldCellShowLeftBorder)(pinnedPosition, indexInSection, rootProps.showColumnVerticalBorder, rootProps.pinnedColumnsSectionSeparator),
|
|
264
|
+
showRightBorder: (0, _cellBorderUtils.shouldCellShowRightBorder)(pinnedPosition, indexInSection, visibleColumnGroupHeader.length, rootProps.showColumnVerticalBorder, gridHasFiller, rootProps.pinnedColumnsSectionSeparator)
|
|
270
265
|
}, index);
|
|
271
266
|
});
|
|
272
267
|
return getFillers(params, children, leftOverflow);
|
|
@@ -23,6 +23,7 @@ var _utils2 = require("../../../utils/utils");
|
|
|
23
23
|
var _useTimeout = require("../../utils/useTimeout");
|
|
24
24
|
var _gridColumnsInterfaces = require("../columns/gridColumnsInterfaces");
|
|
25
25
|
var _columns = require("../columns");
|
|
26
|
+
var _dimensions = require("../dimensions");
|
|
26
27
|
function trackFinger(event, currentTouchId) {
|
|
27
28
|
if (currentTouchId !== undefined && event.changedTouches) {
|
|
28
29
|
for (let i = 0; i < event.changedTouches.length; i += 1) {
|
|
@@ -70,6 +71,18 @@ function getResizeDirection(separator, isRtl) {
|
|
|
70
71
|
}
|
|
71
72
|
return side;
|
|
72
73
|
}
|
|
74
|
+
function getPinnedWidthProperty(isRtl, pinnedPosition) {
|
|
75
|
+
if (pinnedPosition === _gridColumnsInterfaces.GridPinnedColumnPosition.LEFT) {
|
|
76
|
+
return isRtl ? '--DataGrid-rightPinnedWidth' : '--DataGrid-leftPinnedWidth';
|
|
77
|
+
}
|
|
78
|
+
return isRtl ? '--DataGrid-leftPinnedWidth' : '--DataGrid-rightPinnedWidth';
|
|
79
|
+
}
|
|
80
|
+
function getPinnedWidth(dimensions, isRtl, pinnedPosition) {
|
|
81
|
+
if (pinnedPosition === _gridColumnsInterfaces.GridPinnedColumnPosition.LEFT) {
|
|
82
|
+
return isRtl ? dimensions.rightPinnedWidth : dimensions.leftPinnedWidth;
|
|
83
|
+
}
|
|
84
|
+
return isRtl ? dimensions.leftPinnedWidth : dimensions.rightPinnedWidth;
|
|
85
|
+
}
|
|
73
86
|
function preventClick(event) {
|
|
74
87
|
event.preventDefault();
|
|
75
88
|
event.stopImmediatePropagation();
|
|
@@ -240,6 +253,7 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
240
253
|
}
|
|
241
254
|
div.style.setProperty('--width', finalWidth);
|
|
242
255
|
});
|
|
256
|
+
const dimensions = (0, _dimensions.gridDimensionsSelector)(apiRef);
|
|
243
257
|
const pinnedPosition = apiRef.current.unstable_applyPipeProcessors('isColumnPinned', false, refs.colDef.field);
|
|
244
258
|
if (pinnedPosition === _gridColumnsInterfaces.GridPinnedColumnPosition.LEFT) {
|
|
245
259
|
updateProperty(refs.fillerLeft, 'width', widthDiff);
|
|
@@ -249,6 +263,7 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
249
263
|
refs.leftPinnedHeadersAfter.forEach(header => {
|
|
250
264
|
updateProperty(header, 'left', widthDiff);
|
|
251
265
|
});
|
|
266
|
+
apiRef.current.rootElementRef?.current?.style.setProperty(getPinnedWidthProperty(isRtl, pinnedPosition), `${getPinnedWidth(dimensions, isRtl, pinnedPosition) + columnWidthDiff}px`);
|
|
252
267
|
}
|
|
253
268
|
if (pinnedPosition === _gridColumnsInterfaces.GridPinnedColumnPosition.RIGHT) {
|
|
254
269
|
updateProperty(refs.fillerRight, 'width', widthDiff);
|
|
@@ -258,6 +273,7 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
258
273
|
refs.rightPinnedHeadersBefore.forEach(header => {
|
|
259
274
|
updateProperty(header, 'right', widthDiff);
|
|
260
275
|
});
|
|
276
|
+
apiRef.current.rootElementRef?.current?.style.setProperty(getPinnedWidthProperty(isRtl, pinnedPosition), `${getPinnedWidth(dimensions, isRtl, pinnedPosition) + columnWidthDiff}px`);
|
|
261
277
|
}
|
|
262
278
|
};
|
|
263
279
|
const finishResize = nativeEvent => {
|