@mui/x-data-grid-premium 7.0.0-beta.7 → 7.1.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 +266 -12
- package/DataGridPremium/DataGridPremium.js +26 -17
- package/README.md +1 -1
- package/esm/DataGridPremium/DataGridPremium.js +26 -17
- package/esm/components/GridAggregationHeader.js +1 -2
- package/esm/components/GridColumnMenuAggregationItem.js +2 -3
- package/esm/components/GridColumnMenuRowGroupItem.js +1 -2
- package/esm/components/GridColumnMenuRowUngroupItem.js +1 -2
- package/esm/components/GridExcelExportMenuItem.js +1 -1
- package/esm/components/GridGroupingColumnLeafCell.js +1 -2
- package/esm/components/GridGroupingCriteriaCell.js +2 -3
- package/esm/hooks/features/aggregation/gridAggregationUtils.js +4 -4
- package/esm/hooks/features/aggregation/useGridAggregation.js +1 -2
- package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.js +1 -2
- package/esm/hooks/features/aggregation/wrapColumnWithAggregation.js +5 -9
- package/esm/hooks/features/cellSelection/useGridCellSelection.js +13 -21
- package/esm/hooks/features/clipboard/useGridClipboardImport.js +21 -8
- package/esm/hooks/features/export/serializer/excelSerializer.js +9 -22
- package/esm/hooks/features/export/useGridExcelExport.js +9 -11
- package/esm/hooks/features/rowGrouping/createGroupingColDef.js +23 -32
- package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +4 -7
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +5 -9
- package/esm/hooks/utils/useKeepGroupedColumnsHidden.js +7 -9
- package/esm/utils/releaseInfo.js +1 -1
- package/hooks/features/cellSelection/useGridCellSelection.js +2 -1
- package/hooks/features/clipboard/useGridClipboardImport.d.ts +1 -1
- package/hooks/features/clipboard/useGridClipboardImport.js +18 -3
- package/hooks/features/rowGrouping/createGroupingColDef.js +3 -2
- package/index.js +1 -1
- package/models/dataGridPremiumProps.d.ts +12 -2
- package/modern/DataGridPremium/DataGridPremium.js +26 -17
- package/modern/hooks/features/cellSelection/useGridCellSelection.js +2 -1
- package/modern/hooks/features/clipboard/useGridClipboardImport.js +19 -4
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +3 -2
- package/modern/index.js +1 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/package.json +7 -7
- package/utils/releaseInfo.js +1 -1
|
@@ -5,13 +5,12 @@ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
|
|
|
5
5
|
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
6
6
|
import { getRowGroupingFieldFromGroupingCriteria, ROW_GROUPING_STRATEGY, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability, getGroupingRules, areGroupingRulesEqual } from './gridRowGroupingUtils';
|
|
7
7
|
export const rowGroupingStateInitializer = (state, props, apiRef) => {
|
|
8
|
-
var _ref, _props$rowGroupingMod, _props$initialState;
|
|
9
8
|
apiRef.current.caches.rowGrouping = {
|
|
10
9
|
rulesOnLastRowTreeCreation: []
|
|
11
10
|
};
|
|
12
11
|
return _extends({}, state, {
|
|
13
12
|
rowGrouping: {
|
|
14
|
-
model:
|
|
13
|
+
model: props.rowGroupingModel ?? props.initialState?.rowGrouping?.model ?? []
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
16
|
};
|
|
@@ -22,7 +21,6 @@ export const rowGroupingStateInitializer = (state, props, apiRef) => {
|
|
|
22
21
|
* @requires useGridParamsApi (method) - can be after, async only
|
|
23
22
|
*/
|
|
24
23
|
export const useGridRowGrouping = (apiRef, props) => {
|
|
25
|
-
var _props$initialState3;
|
|
26
24
|
apiRef.current.registerControlState({
|
|
27
25
|
stateId: 'rowGrouping',
|
|
28
26
|
propModel: props.rowGroupingModel,
|
|
@@ -47,7 +45,7 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
47
45
|
if (currentModel.includes(field)) {
|
|
48
46
|
return;
|
|
49
47
|
}
|
|
50
|
-
const cleanGroupingIndex = groupingIndex
|
|
48
|
+
const cleanGroupingIndex = groupingIndex ?? currentModel.length;
|
|
51
49
|
const updatedModel = [...currentModel.slice(0, cleanGroupingIndex), field, ...currentModel.slice(cleanGroupingIndex)];
|
|
52
50
|
apiRef.current.setRowGroupingModel(updatedModel);
|
|
53
51
|
}, [apiRef]);
|
|
@@ -89,7 +87,6 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
89
87
|
return columnMenuItems;
|
|
90
88
|
}, [props.disableRowGrouping]);
|
|
91
89
|
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
92
|
-
var _props$initialState2;
|
|
93
90
|
const rowGroupingModelToExport = gridRowGroupingModelSelector(apiRef);
|
|
94
91
|
const shouldExportRowGroupingModel =
|
|
95
92
|
// Always export if the `exportOnlyDirtyModels` property is not activated
|
|
@@ -97,7 +94,7 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
97
94
|
// Always export if the model is controlled
|
|
98
95
|
props.rowGroupingModel != null ||
|
|
99
96
|
// Always export if the model has been initialized
|
|
100
|
-
|
|
97
|
+
props.initialState?.rowGrouping?.model != null ||
|
|
101
98
|
// Export if the model is not empty
|
|
102
99
|
Object.keys(rowGroupingModelToExport).length > 0;
|
|
103
100
|
if (!shouldExportRowGroupingModel) {
|
|
@@ -108,13 +105,12 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
108
105
|
model: rowGroupingModelToExport
|
|
109
106
|
}
|
|
110
107
|
});
|
|
111
|
-
}, [apiRef, props.rowGroupingModel,
|
|
108
|
+
}, [apiRef, props.rowGroupingModel, props.initialState?.rowGrouping?.model]);
|
|
112
109
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
113
|
-
var _context$stateToResto;
|
|
114
110
|
if (props.disableRowGrouping) {
|
|
115
111
|
return params;
|
|
116
112
|
}
|
|
117
|
-
const rowGroupingModel =
|
|
113
|
+
const rowGroupingModel = context.stateToRestore.rowGrouping?.model;
|
|
118
114
|
if (rowGroupingModel != null) {
|
|
119
115
|
apiRef.current.setState(mergeStateWithRowGroupingModel(rowGroupingModel));
|
|
120
116
|
}
|
|
@@ -3,13 +3,13 @@ import * as React from 'react';
|
|
|
3
3
|
import { gridColumnVisibilityModelSelector } from '@mui/x-data-grid-pro';
|
|
4
4
|
const updateColumnVisibilityModel = (columnVisibilityModel, rowGroupingModel, prevRowGroupingModel) => {
|
|
5
5
|
const newColumnVisibilityModel = _extends({}, columnVisibilityModel);
|
|
6
|
-
rowGroupingModel
|
|
7
|
-
if (!
|
|
6
|
+
rowGroupingModel?.forEach(field => {
|
|
7
|
+
if (!prevRowGroupingModel?.includes(field)) {
|
|
8
8
|
newColumnVisibilityModel[field] = false;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
prevRowGroupingModel
|
|
12
|
-
if (!
|
|
11
|
+
prevRowGroupingModel?.forEach(field => {
|
|
12
|
+
if (!rowGroupingModel?.includes(field)) {
|
|
13
13
|
newColumnVisibilityModel[field] = true;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -22,9 +22,8 @@ const updateColumnVisibilityModel = (columnVisibilityModel, rowGroupingModel, pr
|
|
|
22
22
|
* Does not work when used with the `hide` property of `GridColDef`
|
|
23
23
|
*/
|
|
24
24
|
export const useKeepGroupedColumnsHidden = props => {
|
|
25
|
-
var _props$rowGroupingMod, _props$initialState;
|
|
26
25
|
const initialProps = React.useRef(props);
|
|
27
|
-
const rowGroupingModel = React.useRef(
|
|
26
|
+
const rowGroupingModel = React.useRef(props.rowGroupingModel ?? props.initialState?.rowGrouping?.model);
|
|
28
27
|
React.useEffect(() => {
|
|
29
28
|
props.apiRef.current.subscribeEvent('rowGroupingModelChange', newModel => {
|
|
30
29
|
const columnVisibilityModel = updateColumnVisibilityModel(gridColumnVisibilityModelSelector(props.apiRef), newModel, rowGroupingModel.current);
|
|
@@ -33,11 +32,10 @@ export const useKeepGroupedColumnsHidden = props => {
|
|
|
33
32
|
});
|
|
34
33
|
}, [props.apiRef]);
|
|
35
34
|
return React.useMemo(() => {
|
|
36
|
-
var _invariantInitialStat;
|
|
37
35
|
const invariantInitialState = initialProps.current.initialState;
|
|
38
|
-
const columnVisibilityModel = updateColumnVisibilityModel(invariantInitialState
|
|
36
|
+
const columnVisibilityModel = updateColumnVisibilityModel(invariantInitialState?.columns?.columnVisibilityModel, rowGroupingModel.current, undefined);
|
|
39
37
|
return _extends({}, invariantInitialState, {
|
|
40
|
-
columns: _extends({}, invariantInitialState
|
|
38
|
+
columns: _extends({}, invariantInitialState?.columns, {
|
|
41
39
|
columnVisibilityModel
|
|
42
40
|
})
|
|
43
41
|
});
|
package/esm/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTcxMTU4MDQwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -456,7 +456,8 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
456
456
|
const cellParams = apiRef.current.getCellParams(rowId, field);
|
|
457
457
|
cellData = (0, _internals.serializeCellValue)(cellParams, {
|
|
458
458
|
delimiterCharacter: clipboardCopyCellDelimiter,
|
|
459
|
-
ignoreValueFormatter
|
|
459
|
+
ignoreValueFormatter,
|
|
460
|
+
shouldAppendQuotes: true
|
|
460
461
|
});
|
|
461
462
|
} else {
|
|
462
463
|
cellData = '';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
3
3
|
import type { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
4
|
-
export declare const useGridClipboardImport: (apiRef: React.MutableRefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, 'pagination' | 'paginationMode' | 'processRowUpdate' | 'onProcessRowUpdateError' | 'getRowId' | 'onClipboardPasteStart' | 'onClipboardPasteEnd' | 'splitClipboardPastedText' | 'disableClipboardPaste'>) => void;
|
|
4
|
+
export declare const useGridClipboardImport: (apiRef: React.MutableRefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, 'pagination' | 'paginationMode' | 'processRowUpdate' | 'onProcessRowUpdateError' | 'getRowId' | 'onClipboardPasteStart' | 'onClipboardPasteEnd' | 'splitClipboardPastedText' | 'disableClipboardPaste' | 'onBeforeClipboardPasteStart'>) => void;
|
|
@@ -13,7 +13,7 @@ var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
|
13
13
|
var _utils = require("@mui/utils");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
-
const missingOnProcessRowUpdateErrorWarning = (0, _internals.buildWarning)(['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,
|
|
16
|
+
const missingOnProcessRowUpdateErrorWarning = (0, _internals.buildWarning)(['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/#server-side-persistence.'], 'error');
|
|
17
17
|
const columnFieldsToExcludeFromPaste = [_xDataGrid.GRID_CHECKBOX_SELECTION_FIELD, _xDataGridPro.GRID_REORDER_COL_DEF.field, _xDataGridPro.GRID_DETAIL_PANEL_TOGGLE_FIELD];
|
|
18
18
|
|
|
19
19
|
// Batches rows that are updated during clipboard paste to reduce `updateRows` calls
|
|
@@ -249,7 +249,12 @@ const useGridClipboardImport = (apiRef, props) => {
|
|
|
249
249
|
const getRowId = props.getRowId;
|
|
250
250
|
const enableClipboardPaste = !props.disableClipboardPaste;
|
|
251
251
|
const rootEl = apiRef.current.rootElementRef?.current;
|
|
252
|
+
const logger = (0, _internals.useGridLogger)(apiRef, 'useGridClipboardImport');
|
|
252
253
|
const splitClipboardPastedText = props.splitClipboardPastedText;
|
|
254
|
+
const {
|
|
255
|
+
pagination,
|
|
256
|
+
onBeforeClipboardPasteStart
|
|
257
|
+
} = props;
|
|
253
258
|
const handlePaste = React.useCallback(async (params, event) => {
|
|
254
259
|
if (!enableClipboardPaste) {
|
|
255
260
|
return;
|
|
@@ -276,6 +281,16 @@ const useGridClipboardImport = (apiRef, props) => {
|
|
|
276
281
|
if (!pastedData) {
|
|
277
282
|
return;
|
|
278
283
|
}
|
|
284
|
+
if (onBeforeClipboardPasteStart) {
|
|
285
|
+
try {
|
|
286
|
+
await onBeforeClipboardPasteStart({
|
|
287
|
+
data: pastedData
|
|
288
|
+
});
|
|
289
|
+
} catch (error) {
|
|
290
|
+
logger.debug('Clipboard paste operation cancelled');
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
279
294
|
const cellUpdater = new CellValueUpdater({
|
|
280
295
|
apiRef,
|
|
281
296
|
processRowUpdate,
|
|
@@ -291,10 +306,10 @@ const useGridClipboardImport = (apiRef, props) => {
|
|
|
291
306
|
updateCell: (...args) => {
|
|
292
307
|
cellUpdater.updateCell(...args);
|
|
293
308
|
},
|
|
294
|
-
pagination
|
|
309
|
+
pagination
|
|
295
310
|
});
|
|
296
311
|
cellUpdater.applyUpdates();
|
|
297
|
-
}, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText,
|
|
312
|
+
}, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, pagination, onBeforeClipboardPasteStart, logger]);
|
|
298
313
|
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
299
314
|
event
|
|
300
315
|
}) => {
|
|
@@ -73,8 +73,9 @@ const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
|
|
|
73
73
|
valueOptions: (0, _internals.isSingleSelectColDef)(groupedByColDef) ? groupedByColDef.valueOptions : undefined,
|
|
74
74
|
sortComparator: (v1, v2, cellParams1, cellParams2) => {
|
|
75
75
|
// We only want to sort the groups of the current grouping criteria
|
|
76
|
-
if (cellParams1.rowNode.type === 'group' &&
|
|
77
|
-
|
|
76
|
+
if (cellParams1.rowNode.type === 'group' && cellParams2.rowNode.type === 'group' && cellParams1.rowNode.groupingField === cellParams2.rowNode.groupingField) {
|
|
77
|
+
const colDef = cellParams1.api.getColumn(cellParams1.rowNode.groupingField);
|
|
78
|
+
return colDef.sortComparator(v1, v2, cellParams1, cellParams2);
|
|
78
79
|
}
|
|
79
80
|
return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
|
|
80
81
|
},
|
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export interface DataGridPremiumPropsWithComplexDefaultValueBeforeProcessing ext
|
|
|
18
18
|
/**
|
|
19
19
|
* The props users can give to the `DataGridPremiumProps` component.
|
|
20
20
|
*/
|
|
21
|
-
export interface DataGridPremiumProps<R extends GridValidRowModel = any> extends Omit<Partial<DataGridPremiumPropsWithDefaultValue
|
|
21
|
+
export interface DataGridPremiumProps<R extends GridValidRowModel = any> extends Omit<Partial<DataGridPremiumPropsWithDefaultValue<R>> & DataGridPremiumPropsWithComplexDefaultValueBeforeProcessing & DataGridPremiumPropsWithoutDefaultValue<R>, DataGridPremiumForcedPropsKey> {
|
|
22
22
|
}
|
|
23
23
|
export interface DataGridPremiumPropsWithComplexDefaultValueAfterProcessing extends Pick<DataGridPropsWithComplexDefaultValueAfterProcessing, 'localeText'> {
|
|
24
24
|
slots: GridPremiumSlotsComponent;
|
|
@@ -34,7 +34,7 @@ export type DataGridPremiumForcedPropsKey = 'signature';
|
|
|
34
34
|
* None of the entry of this interface should be optional, they all have default values and `DataGridProps` already applies a `Partial<DataGridSimpleOptions>` for the public interface.
|
|
35
35
|
* The controlled model do not have a default value at the prop processing level, so they must be defined in `DataGridOtherProps`.
|
|
36
36
|
*/
|
|
37
|
-
export interface DataGridPremiumPropsWithDefaultValue extends DataGridProPropsWithDefaultValue {
|
|
37
|
+
export interface DataGridPremiumPropsWithDefaultValue<R extends GridValidRowModel = any> extends DataGridProPropsWithDefaultValue<R> {
|
|
38
38
|
/**
|
|
39
39
|
* If `true`, the cell selection mode is enabled.
|
|
40
40
|
* @default false
|
|
@@ -134,6 +134,16 @@ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowM
|
|
|
134
134
|
* @param {string} inProgress Indicates if the task is in progress.
|
|
135
135
|
*/
|
|
136
136
|
onExcelExportStateChange?: (inProgress: 'pending' | 'finished') => void;
|
|
137
|
+
/**
|
|
138
|
+
* Callback fired before the clipboard paste operation starts.
|
|
139
|
+
* Use it to confirm or cancel the paste operation.
|
|
140
|
+
* @param {object} params Params passed to the callback.
|
|
141
|
+
* @param {string[][]} params.data The raw pasted data split by rows and cells.
|
|
142
|
+
* @returns {Promise<any>} A promise that resolves to confirm the paste operation, and rejects to cancel it.
|
|
143
|
+
*/
|
|
144
|
+
onBeforeClipboardPasteStart?: (params: {
|
|
145
|
+
data: string[][];
|
|
146
|
+
}) => Promise<any>;
|
|
137
147
|
/**
|
|
138
148
|
* Callback fired when the clipboard paste operation starts.
|
|
139
149
|
*/
|
|
@@ -138,10 +138,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
138
138
|
*/
|
|
139
139
|
clipboardCopyCellDelimiter: PropTypes.string,
|
|
140
140
|
/**
|
|
141
|
-
*
|
|
142
|
-
* @default
|
|
141
|
+
* Column region in pixels to render before/after the viewport
|
|
142
|
+
* @default 150
|
|
143
143
|
*/
|
|
144
|
-
|
|
144
|
+
columnBufferPx: PropTypes.number,
|
|
145
145
|
columnGroupingModel: PropTypes.arrayOf(PropTypes.object),
|
|
146
146
|
/**
|
|
147
147
|
* Sets the height in pixel of the column headers in the Data Grid.
|
|
@@ -152,11 +152,6 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
152
152
|
* Set of columns of type [[GridColDef]][].
|
|
153
153
|
*/
|
|
154
154
|
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
155
|
-
/**
|
|
156
|
-
* Number of rows from the `columnBuffer` that can be visible before a new slice is rendered.
|
|
157
|
-
* @default 3
|
|
158
|
-
*/
|
|
159
|
-
columnThreshold: PropTypes.number,
|
|
160
155
|
/**
|
|
161
156
|
* Set the column visibility model of the Data Grid.
|
|
162
157
|
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
@@ -503,6 +498,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
503
498
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
504
499
|
*/
|
|
505
500
|
onAggregationModelChange: PropTypes.func,
|
|
501
|
+
/**
|
|
502
|
+
* Callback fired before the clipboard paste operation starts.
|
|
503
|
+
* Use it to confirm or cancel the paste operation.
|
|
504
|
+
* @param {object} params Params passed to the callback.
|
|
505
|
+
* @param {string[][]} params.data The raw pasted data split by rows and cells.
|
|
506
|
+
* @returns {Promise<any>} A promise that resolves to confirm the paste operation, and rejects to cancel it.
|
|
507
|
+
*/
|
|
508
|
+
onBeforeClipboardPasteStart: PropTypes.func,
|
|
506
509
|
/**
|
|
507
510
|
* Callback fired when any cell is clicked.
|
|
508
511
|
* @param {GridCellParams} params With all properties from [[GridCellParams]].
|
|
@@ -630,6 +633,11 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
630
633
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
631
634
|
*/
|
|
632
635
|
onColumnWidthChange: PropTypes.func,
|
|
636
|
+
/**
|
|
637
|
+
* Callback fired when the density changes.
|
|
638
|
+
* @param {GridDensity} density New density value.
|
|
639
|
+
*/
|
|
640
|
+
onDensityChange: PropTypes.func,
|
|
633
641
|
/**
|
|
634
642
|
* Callback fired when the detail panel of a row is opened or closed.
|
|
635
643
|
* @param {GridRowId[]} ids The ids of the rows which have the detail panel open.
|
|
@@ -831,10 +839,15 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
831
839
|
*/
|
|
832
840
|
processRowUpdate: PropTypes.func,
|
|
833
841
|
/**
|
|
834
|
-
*
|
|
835
|
-
* @default
|
|
842
|
+
* The milliseconds throttle delay for resizing the grid.
|
|
843
|
+
* @default 60
|
|
844
|
+
*/
|
|
845
|
+
resizeThrottleMs: PropTypes.number,
|
|
846
|
+
/**
|
|
847
|
+
* Row region in pixels to render before/after the viewport
|
|
848
|
+
* @default 150
|
|
836
849
|
*/
|
|
837
|
-
|
|
850
|
+
rowBufferPx: PropTypes.number,
|
|
838
851
|
/**
|
|
839
852
|
* Set the total number of rows, if it is different from the length of the value `rows` prop.
|
|
840
853
|
* If some rows have children (for instance in the tree data), this number represents the amount of top level rows.
|
|
@@ -873,8 +886,9 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
873
886
|
rowReordering: PropTypes.bool,
|
|
874
887
|
/**
|
|
875
888
|
* Set of rows of type [[GridRowsProp]].
|
|
889
|
+
* @default []
|
|
876
890
|
*/
|
|
877
|
-
rows: PropTypes.arrayOf(PropTypes.object)
|
|
891
|
+
rows: PropTypes.arrayOf(PropTypes.object),
|
|
878
892
|
/**
|
|
879
893
|
* If `false`, the row selection mode is disabled.
|
|
880
894
|
* @default true
|
|
@@ -896,11 +910,6 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
896
910
|
* @default "margin"
|
|
897
911
|
*/
|
|
898
912
|
rowSpacingType: PropTypes.oneOf(['border', 'margin']),
|
|
899
|
-
/**
|
|
900
|
-
* Number of rows from the `rowBuffer` that can be visible before a new slice is rendered.
|
|
901
|
-
* @default 3
|
|
902
|
-
*/
|
|
903
|
-
rowThreshold: PropTypes.number,
|
|
904
913
|
/**
|
|
905
914
|
* Override the height/width of the Data Grid inner scrollbar.
|
|
906
915
|
*/
|
|
@@ -446,7 +446,8 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
446
446
|
const cellParams = apiRef.current.getCellParams(rowId, field);
|
|
447
447
|
cellData = serializeCellValue(cellParams, {
|
|
448
448
|
delimiterCharacter: clipboardCopyCellDelimiter,
|
|
449
|
-
ignoreValueFormatter
|
|
449
|
+
ignoreValueFormatter,
|
|
450
|
+
shouldAppendQuotes: true
|
|
450
451
|
});
|
|
451
452
|
} else {
|
|
452
453
|
cellData = '';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector } from '@mui/x-data-grid';
|
|
4
|
-
import { buildWarning, getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef, isPasteShortcut } from '@mui/x-data-grid/internals';
|
|
4
|
+
import { buildWarning, getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef, isPasteShortcut, useGridLogger } from '@mui/x-data-grid/internals';
|
|
5
5
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_REORDER_COL_DEF } from '@mui/x-data-grid-pro';
|
|
6
6
|
import { unstable_debounce as debounce } from '@mui/utils';
|
|
7
|
-
const missingOnProcessRowUpdateErrorWarning = buildWarning(['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,
|
|
7
|
+
const missingOnProcessRowUpdateErrorWarning = buildWarning(['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/#server-side-persistence.'], 'error');
|
|
8
8
|
const columnFieldsToExcludeFromPaste = [GRID_CHECKBOX_SELECTION_FIELD, GRID_REORDER_COL_DEF.field, GRID_DETAIL_PANEL_TOGGLE_FIELD];
|
|
9
9
|
|
|
10
10
|
// Batches rows that are updated during clipboard paste to reduce `updateRows` calls
|
|
@@ -240,7 +240,12 @@ export const useGridClipboardImport = (apiRef, props) => {
|
|
|
240
240
|
const getRowId = props.getRowId;
|
|
241
241
|
const enableClipboardPaste = !props.disableClipboardPaste;
|
|
242
242
|
const rootEl = apiRef.current.rootElementRef?.current;
|
|
243
|
+
const logger = useGridLogger(apiRef, 'useGridClipboardImport');
|
|
243
244
|
const splitClipboardPastedText = props.splitClipboardPastedText;
|
|
245
|
+
const {
|
|
246
|
+
pagination,
|
|
247
|
+
onBeforeClipboardPasteStart
|
|
248
|
+
} = props;
|
|
244
249
|
const handlePaste = React.useCallback(async (params, event) => {
|
|
245
250
|
if (!enableClipboardPaste) {
|
|
246
251
|
return;
|
|
@@ -267,6 +272,16 @@ export const useGridClipboardImport = (apiRef, props) => {
|
|
|
267
272
|
if (!pastedData) {
|
|
268
273
|
return;
|
|
269
274
|
}
|
|
275
|
+
if (onBeforeClipboardPasteStart) {
|
|
276
|
+
try {
|
|
277
|
+
await onBeforeClipboardPasteStart({
|
|
278
|
+
data: pastedData
|
|
279
|
+
});
|
|
280
|
+
} catch (error) {
|
|
281
|
+
logger.debug('Clipboard paste operation cancelled');
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
270
285
|
const cellUpdater = new CellValueUpdater({
|
|
271
286
|
apiRef,
|
|
272
287
|
processRowUpdate,
|
|
@@ -282,10 +297,10 @@ export const useGridClipboardImport = (apiRef, props) => {
|
|
|
282
297
|
updateCell: (...args) => {
|
|
283
298
|
cellUpdater.updateCell(...args);
|
|
284
299
|
},
|
|
285
|
-
pagination
|
|
300
|
+
pagination
|
|
286
301
|
});
|
|
287
302
|
cellUpdater.applyUpdates();
|
|
288
|
-
}, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText,
|
|
303
|
+
}, [apiRef, processRowUpdate, onProcessRowUpdateError, getRowId, enableClipboardPaste, rootEl, splitClipboardPastedText, pagination, onBeforeClipboardPasteStart, logger]);
|
|
289
304
|
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
290
305
|
event
|
|
291
306
|
}) => {
|
|
@@ -64,8 +64,9 @@ const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
|
|
|
64
64
|
valueOptions: isSingleSelectColDef(groupedByColDef) ? groupedByColDef.valueOptions : undefined,
|
|
65
65
|
sortComparator: (v1, v2, cellParams1, cellParams2) => {
|
|
66
66
|
// We only want to sort the groups of the current grouping criteria
|
|
67
|
-
if (cellParams1.rowNode.type === 'group' &&
|
|
68
|
-
|
|
67
|
+
if (cellParams1.rowNode.type === 'group' && cellParams2.rowNode.type === 'group' && cellParams1.rowNode.groupingField === cellParams2.rowNode.groupingField) {
|
|
68
|
+
const colDef = cellParams1.api.getColumn(cellParams1.rowNode.groupingField);
|
|
69
|
+
return colDef.sortComparator(v1, v2, cellParams1, cellParams2);
|
|
69
70
|
}
|
|
70
71
|
return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
|
|
71
72
|
},
|
package/modern/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTcxMTU4MDQwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-premium",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "The Premium plan edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/runtime": "^7.24.0",
|
|
36
|
-
"@mui/system": "^5.15.
|
|
37
|
-
"@mui/utils": "^5.15.
|
|
38
|
-
"@mui/x-data-grid": "7.
|
|
39
|
-
"@mui/x-data-grid-pro": "7.
|
|
40
|
-
"@mui/x-license": "7.0.0
|
|
36
|
+
"@mui/system": "^5.15.14",
|
|
37
|
+
"@mui/utils": "^5.15.14",
|
|
38
|
+
"@mui/x-data-grid": "7.1.0",
|
|
39
|
+
"@mui/x-data-grid-pro": "7.1.0",
|
|
40
|
+
"@mui/x-license": "7.0.0",
|
|
41
41
|
"@types/format-util": "^1.0.4",
|
|
42
42
|
"clsx": "^2.1.0",
|
|
43
43
|
"exceljs": "^4.4.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"reselect": "^4.1.8"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@mui/material": "^5.15.
|
|
48
|
+
"@mui/material": "^5.15.14",
|
|
49
49
|
"react": "^17.0.0 || ^18.0.0",
|
|
50
50
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
51
51
|
},
|
package/utils/releaseInfo.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReleaseInfo = void 0;
|
|
7
7
|
var _utils = require("@mui/utils");
|
|
8
8
|
const getReleaseInfo = () => {
|
|
9
|
-
const releaseInfo = "
|
|
9
|
+
const releaseInfo = "MTcxMTU4MDQwMDAwMA==";
|
|
10
10
|
if (process.env.NODE_ENV !== 'production') {
|
|
11
11
|
// A simple hack to set the value in the test environment (has no build step).
|
|
12
12
|
// eslint-disable-next-line no-useless-concat
|