@mui/x-data-grid-premium 7.25.0 → 7.27.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 +133 -0
- package/DataGridPremium/DataGridPremium.js +11 -4
- package/DataGridPremium/useDataGridPremiumComponent.js +3 -3
- package/esm/DataGridPremium/DataGridPremium.js +11 -4
- package/esm/DataGridPremium/useDataGridPremiumComponent.js +3 -3
- package/esm/hooks/features/aggregation/gridAggregationUtils.js +1 -1
- package/esm/hooks/features/aggregation/useGridAggregation.js +0 -2
- package/esm/hooks/features/cellSelection/useGridCellSelection.js +13 -10
- package/esm/hooks/features/clipboard/useGridClipboardImport.js +2 -2
- package/esm/hooks/features/export/index.js +1 -1
- package/esm/hooks/features/export/serializer/excelSerializer.js +69 -180
- package/esm/hooks/features/export/serializer/setupExcelExportWebWorker.js +53 -0
- package/esm/hooks/features/export/serializer/utils.js +93 -0
- package/esm/hooks/features/export/useGridExcelExport.js +11 -5
- package/esm/setupExcelExportWebWorker.js +1 -0
- package/esm/utils/releaseInfo.js +1 -1
- package/hooks/features/aggregation/gridAggregationUtils.js +1 -1
- package/hooks/features/aggregation/useGridAggregation.js +0 -2
- package/hooks/features/cellSelection/useGridCellSelection.js +11 -8
- package/hooks/features/clipboard/useGridClipboardImport.js +2 -2
- package/hooks/features/export/index.d.ts +1 -1
- package/hooks/features/export/index.js +2 -2
- package/hooks/features/export/serializer/excelSerializer.d.ts +3 -31
- package/hooks/features/export/serializer/excelSerializer.js +74 -187
- package/hooks/features/export/serializer/setupExcelExportWebWorker.d.ts +2 -0
- package/hooks/features/export/serializer/setupExcelExportWebWorker.js +59 -0
- package/hooks/features/export/serializer/utils.d.ts +36 -0
- package/hooks/features/export/serializer/utils.js +106 -0
- package/hooks/features/export/useGridExcelExport.js +10 -3
- package/hooks/utils/useGridApiContext.d.ts +3 -1
- package/index.js +1 -1
- package/modern/DataGridPremium/DataGridPremium.js +11 -4
- package/modern/DataGridPremium/useDataGridPremiumComponent.js +3 -3
- package/modern/hooks/features/aggregation/gridAggregationUtils.js +1 -1
- package/modern/hooks/features/aggregation/useGridAggregation.js +0 -2
- package/modern/hooks/features/cellSelection/useGridCellSelection.js +13 -10
- package/modern/hooks/features/clipboard/useGridClipboardImport.js +2 -2
- package/modern/hooks/features/export/index.js +1 -1
- package/modern/hooks/features/export/serializer/excelSerializer.js +69 -180
- package/modern/hooks/features/export/serializer/setupExcelExportWebWorker.js +53 -0
- package/modern/hooks/features/export/serializer/utils.js +93 -0
- package/modern/hooks/features/export/useGridExcelExport.js +11 -5
- package/modern/index.js +1 -1
- package/modern/setupExcelExportWebWorker.js +1 -0
- package/modern/utils/releaseInfo.js +1 -1
- package/package.json +5 -5
- package/setupExcelExportWebWorker.d.ts +1 -0
- package/setupExcelExportWebWorker.js +12 -0
- package/utils/releaseInfo.js +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type * as Excel from 'exceljs';
|
|
2
|
+
import type { GridColumnGroupLookup } from '@mui/x-data-grid/internals';
|
|
3
|
+
import type { GridExcelExportOptions } from '../gridExcelExportInterface';
|
|
4
|
+
export declare const getExcelJs: () => Promise<typeof Excel>;
|
|
5
|
+
export interface SerializedRow {
|
|
6
|
+
row: Record<string, undefined | number | boolean | string | Date>;
|
|
7
|
+
dataValidation: Record<string, Excel.DataValidation>;
|
|
8
|
+
outlineLevel: number;
|
|
9
|
+
mergedCells: {
|
|
10
|
+
leftIndex: number;
|
|
11
|
+
rightIndex: number;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export declare const addColumnGroupingHeaders: (worksheet: Excel.Worksheet, columns: SerializedColumns, columnGroupPaths: Record<string, string[]>, columnGroupDetails: GridColumnGroupLookup) => void;
|
|
15
|
+
export type SerializedColumns = Array<{
|
|
16
|
+
key: string;
|
|
17
|
+
width: number;
|
|
18
|
+
style: Partial<Excel.Style>;
|
|
19
|
+
headerText: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type ValueOptionsData = Record<string, {
|
|
22
|
+
values: (string | number)[];
|
|
23
|
+
address: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function addSerializedRowToWorksheet(serializedRow: SerializedRow, worksheet: Excel.Worksheet): void;
|
|
26
|
+
export declare function createValueOptionsSheetIfNeeded(valueOptionsData: ValueOptionsData, sheetName: string, workbook: Excel.Workbook): Promise<void>;
|
|
27
|
+
export interface ExcelExportInitEvent {
|
|
28
|
+
namespace?: string;
|
|
29
|
+
serializedColumns: SerializedColumns;
|
|
30
|
+
serializedRows: SerializedRow[];
|
|
31
|
+
valueOptionsSheetName: string;
|
|
32
|
+
columnGroupPaths: Record<string, string[]>;
|
|
33
|
+
columnGroupDetails: GridColumnGroupLookup;
|
|
34
|
+
valueOptionsData: ValueOptionsData;
|
|
35
|
+
options: Omit<GridExcelExportOptions, 'exceljsPreProcess' | 'exceljsPostProcess' | 'columnsStyles' | 'valueOptionsSheetName'>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.addColumnGroupingHeaders = void 0;
|
|
8
|
+
exports.addSerializedRowToWorksheet = addSerializedRowToWorksheet;
|
|
9
|
+
exports.createValueOptionsSheetIfNeeded = createValueOptionsSheetIfNeeded;
|
|
10
|
+
exports.getExcelJs = void 0;
|
|
11
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
|
|
13
|
+
const getExcelJs = async () => {
|
|
14
|
+
const excelJsModule = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('exceljs')));
|
|
15
|
+
return excelJsModule.default ?? excelJsModule;
|
|
16
|
+
};
|
|
17
|
+
exports.getExcelJs = getExcelJs;
|
|
18
|
+
const addColumnGroupingHeaders = (worksheet, columns, columnGroupPaths, columnGroupDetails) => {
|
|
19
|
+
const maxDepth = Math.max(...columns.map(({
|
|
20
|
+
key
|
|
21
|
+
}) => columnGroupPaths[key]?.length ?? 0));
|
|
22
|
+
if (maxDepth === 0) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
for (let rowIndex = 0; rowIndex < maxDepth; rowIndex += 1) {
|
|
26
|
+
const row = columns.map(({
|
|
27
|
+
key
|
|
28
|
+
}) => {
|
|
29
|
+
const groupingPath = columnGroupPaths[key];
|
|
30
|
+
if (groupingPath.length <= rowIndex) {
|
|
31
|
+
return {
|
|
32
|
+
groupId: null,
|
|
33
|
+
parents: groupingPath
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return (0, _extends2.default)({}, columnGroupDetails[groupingPath[rowIndex]], {
|
|
37
|
+
parents: groupingPath.slice(0, rowIndex)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
const newRow = worksheet.addRow(row.map(group => group.groupId === null ? null : group?.headerName ?? group.groupId));
|
|
41
|
+
|
|
42
|
+
// use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
|
|
43
|
+
const lastRowIndex = newRow.worksheet.rowCount;
|
|
44
|
+
let leftIndex = 0;
|
|
45
|
+
let rightIndex = 1;
|
|
46
|
+
while (rightIndex < columns.length) {
|
|
47
|
+
const {
|
|
48
|
+
groupId: leftGroupId,
|
|
49
|
+
parents: leftParents
|
|
50
|
+
} = row[leftIndex];
|
|
51
|
+
const {
|
|
52
|
+
groupId: rightGroupId,
|
|
53
|
+
parents: rightParents
|
|
54
|
+
} = row[rightIndex];
|
|
55
|
+
const areInSameGroup = leftGroupId === rightGroupId && leftParents.length === rightParents.length && leftParents.every((leftParent, index) => rightParents[index] === leftParent);
|
|
56
|
+
if (areInSameGroup) {
|
|
57
|
+
rightIndex += 1;
|
|
58
|
+
} else {
|
|
59
|
+
if (rightIndex - leftIndex > 1) {
|
|
60
|
+
worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
|
|
61
|
+
}
|
|
62
|
+
leftIndex = rightIndex;
|
|
63
|
+
rightIndex += 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (rightIndex - leftIndex > 1) {
|
|
67
|
+
worksheet.mergeCells(lastRowIndex, leftIndex + 1, lastRowIndex, rightIndex);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.addColumnGroupingHeaders = addColumnGroupingHeaders;
|
|
72
|
+
function addSerializedRowToWorksheet(serializedRow, worksheet) {
|
|
73
|
+
const {
|
|
74
|
+
row,
|
|
75
|
+
dataValidation,
|
|
76
|
+
outlineLevel,
|
|
77
|
+
mergedCells
|
|
78
|
+
} = serializedRow;
|
|
79
|
+
const newRow = worksheet.addRow(row);
|
|
80
|
+
Object.keys(dataValidation).forEach(field => {
|
|
81
|
+
newRow.getCell(field).dataValidation = (0, _extends2.default)({}, dataValidation[field]);
|
|
82
|
+
});
|
|
83
|
+
if (outlineLevel) {
|
|
84
|
+
newRow.outlineLevel = outlineLevel;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// use `rowCount`, since worksheet can have additional rows added in `exceljsPreProcess`
|
|
88
|
+
const lastRowIndex = newRow.worksheet.rowCount;
|
|
89
|
+
mergedCells.forEach(mergedCell => {
|
|
90
|
+
worksheet.mergeCells(lastRowIndex, mergedCell.leftIndex, lastRowIndex, mergedCell.rightIndex);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function createValueOptionsSheetIfNeeded(valueOptionsData, sheetName, workbook) {
|
|
94
|
+
if (Object.keys(valueOptionsData).length === 0) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const valueOptionsWorksheet = workbook.addWorksheet(sheetName);
|
|
98
|
+
valueOptionsWorksheet.columns = Object.keys(valueOptionsData).map(key => ({
|
|
99
|
+
key
|
|
100
|
+
}));
|
|
101
|
+
Object.entries(valueOptionsData).forEach(([field, {
|
|
102
|
+
values
|
|
103
|
+
}]) => {
|
|
104
|
+
valueOptionsWorksheet.getColumn(field).values = values;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -96,15 +96,22 @@ const useGridExcelExport = (apiRef, props) => {
|
|
|
96
96
|
const valueOptionsData = await (0, _excelSerializer.getDataForValueOptionsSheet)(exportedColumns, valueOptionsSheetName, apiRef.current);
|
|
97
97
|
const serializedColumns = (0, _excelSerializer.serializeColumns)(exportedColumns, options.columnsStyles || {});
|
|
98
98
|
apiRef.current.resetColSpan();
|
|
99
|
-
const serializedRows =
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const serializedRows = [];
|
|
100
|
+
for (let i = 0; i < exportedRowIds.length; i += 1) {
|
|
101
|
+
const id = exportedRowIds[i];
|
|
102
|
+
const serializedRow = (0, _excelSerializer.serializeRowUnsafe)(id, exportedColumns, apiRef, valueOptionsData, {
|
|
103
|
+
escapeFormulas: options.escapeFormulas ?? true
|
|
104
|
+
});
|
|
105
|
+
serializedRows.push(serializedRow);
|
|
106
|
+
}
|
|
102
107
|
apiRef.current.resetColSpan();
|
|
103
108
|
const columnGroupPaths = exportedColumns.reduce((acc, column) => {
|
|
104
109
|
acc[column.field] = apiRef.current.getColumnGroupPath(column.field);
|
|
105
110
|
return acc;
|
|
106
111
|
}, {});
|
|
107
112
|
const message = {
|
|
113
|
+
// workers share the pub-sub channel namespace. Use this property to filter out messages.
|
|
114
|
+
namespace: 'mui-x-data-grid-export',
|
|
108
115
|
serializedColumns,
|
|
109
116
|
serializedRows,
|
|
110
117
|
valueOptionsData,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridApiCommon } from '@mui/x-data-grid';
|
|
1
3
|
import { GridApiPremium } from '../../models/gridApiPremium';
|
|
2
|
-
export declare const useGridApiContext: () =>
|
|
4
|
+
export declare const useGridApiContext: <Api extends GridApiCommon = GridApiPremium>() => RefObject<Api>;
|
package/index.js
CHANGED
|
@@ -20,6 +20,10 @@ const configuration = {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
const releaseInfo = getReleaseInfo();
|
|
23
|
+
const watermark = /*#__PURE__*/_jsx(Watermark, {
|
|
24
|
+
packageName: "x-data-grid-premium",
|
|
25
|
+
releaseInfo: releaseInfo
|
|
26
|
+
});
|
|
23
27
|
let dataGridPremiumPropValidators;
|
|
24
28
|
if (process.env.NODE_ENV !== 'production') {
|
|
25
29
|
dataGridPremiumPropValidators = [...propValidatorsDataGrid, ...propValidatorsDataGridPro];
|
|
@@ -41,10 +45,7 @@ const DataGridPremiumRaw = forwardRef(function DataGridPremium(inProps, ref) {
|
|
|
41
45
|
sx: props.sx
|
|
42
46
|
}, props.forwardedProps, props.slotProps?.root, {
|
|
43
47
|
ref: ref,
|
|
44
|
-
children:
|
|
45
|
-
packageName: "x-data-grid-premium",
|
|
46
|
-
releaseInfo: releaseInfo
|
|
47
|
-
})
|
|
48
|
+
children: watermark
|
|
48
49
|
}))
|
|
49
50
|
});
|
|
50
51
|
});
|
|
@@ -893,6 +894,12 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
893
894
|
* @returns {Promise<R> | R} The final values to update the row.
|
|
894
895
|
*/
|
|
895
896
|
processRowUpdate: PropTypes.func,
|
|
897
|
+
/**
|
|
898
|
+
* If `true`, the page is set to 0 after each sorting or filtering.
|
|
899
|
+
* This prop will be removed in the next major version and resetting the page will become the default behavior.
|
|
900
|
+
* @default false
|
|
901
|
+
*/
|
|
902
|
+
resetPageOnSortFilter: PropTypes.bool,
|
|
896
903
|
/**
|
|
897
904
|
* The milliseconds throttle delay for resizing the grid.
|
|
898
905
|
* @default 60
|
|
@@ -32,7 +32,6 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
|
|
|
32
32
|
/**
|
|
33
33
|
* Register all state initializers here.
|
|
34
34
|
*/
|
|
35
|
-
useGridInitializeState(dimensionsStateInitializer, apiRef, props);
|
|
36
35
|
useGridInitializeState(headerFilteringStateInitializer, apiRef, props);
|
|
37
36
|
useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
|
|
38
37
|
useGridInitializeState(aggregationStateInitializer, apiRef, props);
|
|
@@ -42,8 +41,8 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
|
|
|
42
41
|
useGridInitializeState(columnPinningStateInitializer, apiRef, props);
|
|
43
42
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
44
43
|
useGridInitializeState(rowPinningStateInitializer, apiRef, props);
|
|
45
|
-
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
46
44
|
useGridInitializeState(rowsStateInitializer, apiRef, props);
|
|
45
|
+
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
47
46
|
useGridInitializeState(editingStateInitializer, apiRef, props);
|
|
48
47
|
useGridInitializeState(focusStateInitializer, apiRef, props);
|
|
49
48
|
useGridInitializeState(sortingStateInitializer, apiRef, props);
|
|
@@ -53,11 +52,12 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
|
|
|
53
52
|
useGridInitializeState(densityStateInitializer, apiRef, props);
|
|
54
53
|
useGridInitializeState(columnReorderStateInitializer, apiRef, props);
|
|
55
54
|
useGridInitializeState(columnResizeStateInitializer, apiRef, props);
|
|
56
|
-
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
57
55
|
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
58
56
|
useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
|
|
59
57
|
useGridInitializeState(virtualizationStateInitializer, apiRef, props);
|
|
60
58
|
useGridInitializeState(dataSourceStateInitializer, apiRef, props);
|
|
59
|
+
useGridInitializeState(dimensionsStateInitializer, apiRef, props);
|
|
60
|
+
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
61
61
|
useGridInitializeState(listViewStateInitializer, apiRef, props);
|
|
62
62
|
useGridRowGrouping(apiRef, props);
|
|
63
63
|
useGridHeaderFiltering(apiRef, props);
|
|
@@ -107,7 +107,7 @@ export const addFooterRows = ({
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
const updateRootGroupFooter = groupNode => {
|
|
110
|
-
const shouldHaveFooter = hasAggregationRule && getAggregationPosition(groupNode) === 'footer';
|
|
110
|
+
const shouldHaveFooter = hasAggregationRule && getAggregationPosition(groupNode) === 'footer' && groupNode.children.length > 0;
|
|
111
111
|
if (shouldHaveFooter) {
|
|
112
112
|
const rowId = getAggregationFooterRowIdFromGroupId(null);
|
|
113
113
|
newGroupingParams = addPinnedRow({
|
|
@@ -31,7 +31,6 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
31
31
|
const currentModel = gridAggregationModelSelector(apiRef);
|
|
32
32
|
if (currentModel !== model) {
|
|
33
33
|
apiRef.current.setState(mergeStateWithAggregationModel(model));
|
|
34
|
-
apiRef.current.forceUpdate();
|
|
35
34
|
}
|
|
36
35
|
}, [apiRef]);
|
|
37
36
|
const applyAggregation = React.useCallback(() => {
|
|
@@ -74,7 +73,6 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
74
73
|
|
|
75
74
|
// Re-apply the column hydration to wrap / unwrap the aggregated columns
|
|
76
75
|
if (!areAggregationRulesEqual(rulesOnLastColumnHydration, aggregationRules)) {
|
|
77
|
-
apiRef.current.caches.aggregation.rulesOnLastColumnHydration = aggregationRules;
|
|
78
76
|
apiRef.current.requestPipeProcessorsApplication('hydrateColumns');
|
|
79
77
|
}
|
|
80
78
|
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation]);
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { getTotalHeaderHeight, getVisibleRows, isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor
|
|
5
|
-
import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector, GRID_REORDER_COL_DEF,
|
|
4
|
+
import { getTotalHeaderHeight, getVisibleRows, isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
|
|
5
|
+
import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector, GRID_REORDER_COL_DEF, gridSortedRowIdsSelector, gridDimensionsSelector } from '@mui/x-data-grid-pro';
|
|
6
6
|
import { gridCellSelectionStateSelector } from "./gridCellSelectionSelector.js";
|
|
7
7
|
export const cellSelectionStateInitializer = (state, props) => _extends({}, state, {
|
|
8
8
|
cellSelection: _extends({}, props.cellSelectionModel ?? props.initialState?.cellSelection)
|
|
@@ -15,13 +15,10 @@ const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the s
|
|
|
15
15
|
|
|
16
16
|
export const useGridCellSelection = (apiRef, props) => {
|
|
17
17
|
const hasRootReference = apiRef.current.rootElementRef.current !== null;
|
|
18
|
-
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
19
18
|
const cellWithVirtualFocus = React.useRef(null);
|
|
20
19
|
const lastMouseDownCell = React.useRef(null);
|
|
21
20
|
const mousePosition = React.useRef(null);
|
|
22
21
|
const autoScrollRAF = React.useRef(null);
|
|
23
|
-
const sortedRowIds = useGridSelector(apiRef, gridSortedRowIdsSelector);
|
|
24
|
-
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
25
22
|
const totalHeaderHeight = getTotalHeaderHeight(apiRef, props);
|
|
26
23
|
const ignoreValueFormatterProp = props.ignoreValueFormatterDuringExport;
|
|
27
24
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
|
|
@@ -75,6 +72,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
75
72
|
finalEndColumnIndex = startColumnIndex;
|
|
76
73
|
}
|
|
77
74
|
const visibleColumns = apiRef.current.getVisibleColumns();
|
|
75
|
+
const visibleRows = getVisibleRows(apiRef);
|
|
78
76
|
const rowsInRange = visibleRows.rows.slice(finalStartRowIndex, finalEndRowIndex + 1);
|
|
79
77
|
const columnsInRange = visibleColumns.slice(finalStartColumnIndex, finalEndColumnIndex + 1);
|
|
80
78
|
const newModel = keepOtherSelected ? _extends({}, apiRef.current.getCellSelectionModel()) : {};
|
|
@@ -87,7 +85,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
87
85
|
}, {});
|
|
88
86
|
});
|
|
89
87
|
apiRef.current.setCellSelectionModel(newModel);
|
|
90
|
-
}, [apiRef
|
|
88
|
+
}, [apiRef]);
|
|
91
89
|
const getSelectedCellsAsArray = React.useCallback(() => {
|
|
92
90
|
const selectionModel = apiRef.current.getCellSelectionModel();
|
|
93
91
|
const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
|
|
@@ -186,6 +184,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
186
184
|
if (!mousePosition.current || !apiRef.current.virtualScrollerRef?.current) {
|
|
187
185
|
return;
|
|
188
186
|
}
|
|
187
|
+
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
189
188
|
const {
|
|
190
189
|
x: mouseX,
|
|
191
190
|
y: mouseY
|
|
@@ -228,7 +227,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
228
227
|
autoScrollRAF.current = requestAnimationFrame(autoScroll);
|
|
229
228
|
}
|
|
230
229
|
autoScroll();
|
|
231
|
-
}, [apiRef,
|
|
230
|
+
}, [apiRef, totalHeaderHeight]);
|
|
232
231
|
const handleCellMouseOver = React.useCallback((params, event) => {
|
|
233
232
|
if (!lastMouseDownCell.current) {
|
|
234
233
|
return;
|
|
@@ -245,6 +244,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
245
244
|
if (!virtualScrollerRect) {
|
|
246
245
|
return;
|
|
247
246
|
}
|
|
247
|
+
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
248
248
|
const {
|
|
249
249
|
x,
|
|
250
250
|
y
|
|
@@ -270,7 +270,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
270
270
|
// Mouse has left the sensitivity area while auto scroll is on
|
|
271
271
|
stopAutoScroll();
|
|
272
272
|
}
|
|
273
|
-
}, [apiRef, startAutoScroll, stopAutoScroll, totalHeaderHeight
|
|
273
|
+
}, [apiRef, startAutoScroll, stopAutoScroll, totalHeaderHeight]);
|
|
274
274
|
const handleCellClick = useEventCallback((params, event) => {
|
|
275
275
|
const {
|
|
276
276
|
id,
|
|
@@ -330,6 +330,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
330
330
|
} else if (event.key === 'ArrowLeft') {
|
|
331
331
|
endColumnIndex -= 1;
|
|
332
332
|
}
|
|
333
|
+
const visibleRows = getVisibleRows(apiRef);
|
|
333
334
|
if (endRowIndex < 0 || endRowIndex >= visibleRows.rows.length) {
|
|
334
335
|
return;
|
|
335
336
|
}
|
|
@@ -382,6 +383,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
382
383
|
id,
|
|
383
384
|
field
|
|
384
385
|
}) => {
|
|
386
|
+
const visibleRows = getVisibleRows(apiRef);
|
|
385
387
|
if (!visibleRows.range || !apiRef.current.isCellSelected(id, field)) {
|
|
386
388
|
return classes;
|
|
387
389
|
}
|
|
@@ -430,7 +432,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
430
432
|
newClasses.push(gridClasses['cell--rangeRight']);
|
|
431
433
|
}
|
|
432
434
|
return newClasses;
|
|
433
|
-
}, [apiRef
|
|
435
|
+
}, [apiRef]);
|
|
434
436
|
const canUpdateFocus = React.useCallback((initialValue, {
|
|
435
437
|
event,
|
|
436
438
|
cell
|
|
@@ -451,6 +453,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
451
453
|
if (apiRef.current.getSelectedCellsAsArray().length <= 1) {
|
|
452
454
|
return value;
|
|
453
455
|
}
|
|
456
|
+
const sortedRowIds = gridSortedRowIdsSelector(apiRef);
|
|
454
457
|
const cellSelectionModel = apiRef.current.getCellSelectionModel();
|
|
455
458
|
const unsortedSelectedRowIds = Object.keys(cellSelectionModel);
|
|
456
459
|
const sortedSelectedRowIds = sortedRowIds.filter(id => unsortedSelectedRowIds.includes(`${id}`));
|
|
@@ -476,7 +479,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
476
479
|
return acc === '' ? rowString : [acc, rowString].join('\r\n');
|
|
477
480
|
}, '');
|
|
478
481
|
return copyData;
|
|
479
|
-
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter
|
|
482
|
+
}, [apiRef, ignoreValueFormatter, clipboardCopyCellDelimiter]);
|
|
480
483
|
useGridRegisterPipeProcessor(apiRef, 'isCellSelected', checkIfCellIsSelected);
|
|
481
484
|
useGridRegisterPipeProcessor(apiRef, 'cellClassName', addClassesToCells);
|
|
482
485
|
useGridRegisterPipeProcessor(apiRef, 'canUpdateFocus', canUpdateFocus);
|
|
@@ -255,7 +255,6 @@ export const useGridClipboardImport = (apiRef, props) => {
|
|
|
255
255
|
const onProcessRowUpdateError = props.onProcessRowUpdateError;
|
|
256
256
|
const getRowId = props.getRowId;
|
|
257
257
|
const enableClipboardPaste = !props.disableClipboardPaste;
|
|
258
|
-
const rootEl = apiRef.current.rootElementRef?.current;
|
|
259
258
|
const logger = useGridLogger(apiRef, 'useGridClipboardImport');
|
|
260
259
|
const splitClipboardPastedText = props.splitClipboardPastedText;
|
|
261
260
|
const {
|
|
@@ -278,6 +277,7 @@ export const useGridClipboardImport = (apiRef, props) => {
|
|
|
278
277
|
return;
|
|
279
278
|
}
|
|
280
279
|
}
|
|
280
|
+
const rootEl = apiRef.current.rootElementRef?.current;
|
|
281
281
|
if (!rootEl) {
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
@@ -318,7 +318,7 @@ export const useGridClipboardImport = (apiRef, props) => {
|
|
|
318
318
|
paginationMode
|
|
319
319
|
});
|
|
320
320
|
cellUpdater.applyUpdates();
|
|
321
|
-
}, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste,
|
|
321
|
+
}, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, splitClipboardPastedText, pagination, paginationMode, onBeforeClipboardPasteStart, logger]);
|
|
322
322
|
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
323
323
|
event
|
|
324
324
|
}) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./gridExcelExportInterface.js";
|
|
2
|
-
export { setupExcelExportWebWorker } from "./serializer/
|
|
2
|
+
export { setupExcelExportWebWorker } from "./serializer/setupExcelExportWebWorker.js";
|