@mui/x-data-grid-premium 8.14.1 → 8.16.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 +207 -0
- package/DataGridPremium/DataGridPremium.js +4 -1
- package/DataGridPremium/useDataGridPremiumComponent.js +1 -1
- package/components/prompt/GridPrompt.js +11 -1
- package/esm/DataGridPremium/DataGridPremium.js +4 -1
- package/esm/DataGridPremium/useDataGridPremiumComponent.js +1 -1
- package/esm/components/prompt/GridPrompt.js +11 -1
- package/esm/hooks/features/aiAssistant/gridAiAssistantInterfaces.d.ts +5 -0
- package/esm/hooks/features/aiAssistant/useGridAiAssistant.d.ts +1 -1
- package/esm/hooks/features/aiAssistant/useGridAiAssistant.js +79 -12
- package/esm/hooks/features/chartsIntegration/gridChartsIntegrationSelectors.d.ts +6 -0
- package/esm/hooks/features/chartsIntegration/gridChartsIntegrationSelectors.js +1 -0
- package/esm/hooks/features/chartsIntegration/useGridChartsIntegration.d.ts +1 -1
- package/esm/hooks/features/chartsIntegration/useGridChartsIntegration.js +76 -13
- package/esm/hooks/features/dataSource/models.d.ts +4 -2
- package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +31 -8
- package/esm/hooks/features/dataSource/utils.d.ts +3 -2
- package/esm/hooks/features/dataSource/utils.js +13 -1
- package/esm/hooks/features/editing/useGridCellEditable.d.ts +8 -0
- package/esm/hooks/features/editing/useGridCellEditable.js +35 -0
- package/esm/hooks/features/export/gridExcelExportInterface.d.ts +1 -1
- package/esm/hooks/features/export/serializer/excelSerializer.d.ts +1 -1
- package/esm/hooks/features/export/serializer/utils.d.ts +1 -1
- package/esm/hooks/features/export/serializer/utils.js +1 -1
- package/esm/hooks/features/rowGrouping/createGroupingColDef.js +3 -3
- package/esm/index.js +1 -1
- package/esm/material/index.d.ts +1 -0
- package/esm/material/index.js +1 -0
- package/esm/models/gridPremiumIconSlotsComponent.d.ts +5 -0
- package/hooks/features/aiAssistant/gridAiAssistantInterfaces.d.ts +5 -0
- package/hooks/features/aiAssistant/useGridAiAssistant.d.ts +1 -1
- package/hooks/features/aiAssistant/useGridAiAssistant.js +78 -11
- package/hooks/features/chartsIntegration/gridChartsIntegrationSelectors.d.ts +6 -0
- package/hooks/features/chartsIntegration/gridChartsIntegrationSelectors.js +2 -1
- package/hooks/features/chartsIntegration/useGridChartsIntegration.d.ts +1 -1
- package/hooks/features/chartsIntegration/useGridChartsIntegration.js +75 -12
- package/hooks/features/dataSource/models.d.ts +4 -2
- package/hooks/features/dataSource/useGridDataSourcePremium.js +28 -5
- package/hooks/features/dataSource/utils.d.ts +3 -2
- package/hooks/features/dataSource/utils.js +15 -2
- package/hooks/features/editing/useGridCellEditable.d.ts +8 -0
- package/hooks/features/editing/useGridCellEditable.js +41 -0
- package/hooks/features/export/gridExcelExportInterface.d.ts +1 -1
- package/hooks/features/export/serializer/excelSerializer.d.ts +1 -1
- package/hooks/features/export/serializer/utils.d.ts +1 -1
- package/hooks/features/export/serializer/utils.js +1 -1
- package/hooks/features/rowGrouping/createGroupingColDef.js +3 -3
- package/index.js +1 -1
- package/material/index.d.ts +1 -0
- package/material/index.js +1 -0
- package/models/gridPremiumIconSlotsComponent.d.ts +5 -0
- package/package.json +6 -6
|
@@ -70,7 +70,6 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
70
70
|
const context = (0, _useGridChartIntegration.useGridChartsIntegrationContext)(true);
|
|
71
71
|
const isChartsIntegrationAvailable = !!props.chartsIntegration && !!props.experimentalFeatures?.charts && !!context;
|
|
72
72
|
const activeChartId = (0, _gridChartsIntegrationSelectors.gridChartsIntegrationActiveChartIdSelector)(apiRef);
|
|
73
|
-
const orderedFields = (0, _internals.gridColumnFieldsSelector)(apiRef);
|
|
74
73
|
const aggregationModel = (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef);
|
|
75
74
|
const pivotActive = (0, _internals.gridPivotActiveSelector)(apiRef);
|
|
76
75
|
const pivotModel = (0, _gridPivotingSelectors.gridPivotModelSelector)(apiRef);
|
|
@@ -159,25 +158,28 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
159
158
|
if (!pivotActive && visibleValues.current[activeChartId] && rowGroupingModel.length > 0) {
|
|
160
159
|
// with row grouping add the aggregation model to the newly added value dataset
|
|
161
160
|
const aggregatedFields = Object.keys(aggregationModel);
|
|
161
|
+
const aggregationsToAdd = {};
|
|
162
162
|
visibleValues.current[activeChartId].forEach(item => {
|
|
163
163
|
const hasAggregation = aggregatedFields.includes(item.field);
|
|
164
164
|
if (!hasAggregation) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
})[0]
|
|
172
|
-
}));
|
|
165
|
+
// use the first available aggregation function
|
|
166
|
+
aggregationsToAdd[item.field] = (0, _gridAggregationUtils.getAvailableAggregationFunctions)({
|
|
167
|
+
aggregationFunctions: props.aggregationFunctions,
|
|
168
|
+
colDef: item,
|
|
169
|
+
isDataSource: !!props.dataSource
|
|
170
|
+
})[0];
|
|
173
171
|
}
|
|
174
172
|
});
|
|
173
|
+
if (Object.keys(aggregationsToAdd).length > 0) {
|
|
174
|
+
apiRef.current.setAggregationModel((0, _extends2.default)({}, aggregationModel, aggregationsToAdd));
|
|
175
|
+
}
|
|
175
176
|
}
|
|
176
177
|
}, [apiRef, props.aggregationFunctions, props.dataSource, activeChartId, pivotActive, aggregationModel]);
|
|
177
178
|
const handleRowDataUpdate = React.useCallback(chartIds => {
|
|
178
179
|
if (chartIds.length === 0 || chartIds.some(chartId => !visibleDimensions.current[chartId] || !visibleValues.current[chartId])) {
|
|
179
180
|
return;
|
|
180
181
|
}
|
|
182
|
+
const orderedFields = (0, _internals.gridColumnFieldsSelector)(apiRef);
|
|
181
183
|
const rowGroupingModel = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(apiRef);
|
|
182
184
|
const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
|
|
183
185
|
const rowsPerDepth = (0, _internals.gridFilteredSortedDepthRowEntriesSelector)(apiRef);
|
|
@@ -234,7 +236,7 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
234
236
|
}))
|
|
235
237
|
});
|
|
236
238
|
});
|
|
237
|
-
}, [apiRef,
|
|
239
|
+
}, [apiRef, getColumnName, getValueDatasetLabel, setChartState]);
|
|
238
240
|
const debouncedHandleRowDataUpdate = React.useMemo(() => (0, _debounce.default)(handleRowDataUpdate, 0), [handleRowDataUpdate]);
|
|
239
241
|
const handleColumnDataUpdate = React.useCallback((chartIds, updatedChartStateLookup) => {
|
|
240
242
|
// if there are no charts, skip the data processing
|
|
@@ -304,8 +306,8 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
304
306
|
}
|
|
305
307
|
});
|
|
306
308
|
updateOtherModels();
|
|
307
|
-
|
|
308
|
-
}, [apiRef, chartStateLookup, pivotActive, pivotModel,
|
|
309
|
+
debouncedHandleRowDataUpdate(chartIds);
|
|
310
|
+
}, [apiRef, chartStateLookup, pivotActive, pivotModel, debouncedHandleRowDataUpdate, updateOtherModels]);
|
|
309
311
|
const debouncedHandleColumnDataUpdate = React.useMemo(() => (0, _debounce.default)(handleColumnDataUpdate, 0), [handleColumnDataUpdate]);
|
|
310
312
|
const setChartsPanelOpen = React.useCallback(callback => {
|
|
311
313
|
if (!isChartsIntegrationAvailable) {
|
|
@@ -504,6 +506,67 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
504
506
|
(0, _internals.useGridEvent)(apiRef, 'pivotModeChange', (0, _internals.runIf)(isChartsIntegrationAvailable, () => debouncedHandleColumnDataUpdate(syncedChartIds)));
|
|
505
507
|
(0, _internals.useGridEvent)(apiRef, 'filteredRowsSet', (0, _internals.runIf)(isChartsIntegrationAvailable, () => debouncedHandleRowDataUpdate(syncedChartIds)));
|
|
506
508
|
(0, _internals.useGridEvent)(apiRef, 'sortedRowsSet', (0, _internals.runIf)(isChartsIntegrationAvailable, () => debouncedHandleRowDataUpdate(syncedChartIds)));
|
|
509
|
+
const stateExportPreProcessing = React.useCallback((prevState, exportContext) => {
|
|
510
|
+
if (!props.chartsIntegration || !props.experimentalFeatures?.charts) {
|
|
511
|
+
return prevState;
|
|
512
|
+
}
|
|
513
|
+
const currentActiveChartId = (0, _gridChartsIntegrationSelectors.gridChartsIntegrationActiveChartIdSelector)(apiRef);
|
|
514
|
+
const chartsLookup = (0, _gridChartsIntegrationSelectors.gridChartsIntegrationChartsLookupSelector)(apiRef);
|
|
515
|
+
const integrationContextToExport = Object.fromEntries(Object.entries(chartStateLookup).map(([chartId, chartState]) => [chartId,
|
|
516
|
+
// keep only the state that is controlled by the user, drop the data and labels
|
|
517
|
+
{
|
|
518
|
+
synced: chartState.synced,
|
|
519
|
+
type: chartState.type,
|
|
520
|
+
configuration: chartState.configuration
|
|
521
|
+
}]));
|
|
522
|
+
const shouldExportChartState =
|
|
523
|
+
// Always export if the `exportOnlyDirtyModels` property is not activated
|
|
524
|
+
!exportContext.exportOnlyDirtyModels ||
|
|
525
|
+
// Always export if the chart state has been initialized
|
|
526
|
+
props.initialState?.chartsIntegration != null ||
|
|
527
|
+
// Export if the chart model or context is not empty
|
|
528
|
+
Object.keys(chartsLookup).length > 0 || Object.keys(integrationContextToExport).length > 0;
|
|
529
|
+
if (!shouldExportChartState) {
|
|
530
|
+
return prevState;
|
|
531
|
+
}
|
|
532
|
+
const chartStateToExport = {
|
|
533
|
+
activeChartId: currentActiveChartId,
|
|
534
|
+
charts: chartsLookup,
|
|
535
|
+
// add a custom prop to keep the integration context in the exported state
|
|
536
|
+
integrationContext: integrationContextToExport
|
|
537
|
+
};
|
|
538
|
+
return (0, _extends2.default)({}, prevState, {
|
|
539
|
+
chartsIntegration: chartStateToExport
|
|
540
|
+
});
|
|
541
|
+
}, [apiRef, chartStateLookup, props.chartsIntegration, props.experimentalFeatures?.charts, props.initialState?.chartsIntegration]);
|
|
542
|
+
const stateRestorePreProcessing = React.useCallback((params, restoreContext) => {
|
|
543
|
+
const chartsRestoreState = restoreContext.stateToRestore.chartsIntegration;
|
|
544
|
+
if (!chartsRestoreState) {
|
|
545
|
+
return params;
|
|
546
|
+
}
|
|
547
|
+
const {
|
|
548
|
+
activeChartId: activeChartIdToRestore,
|
|
549
|
+
charts: chartsToRestore,
|
|
550
|
+
integrationContext
|
|
551
|
+
} = chartsRestoreState;
|
|
552
|
+
if (activeChartIdToRestore === undefined || chartsToRestore === undefined || Object.keys(chartsToRestore).length === 0) {
|
|
553
|
+
return params;
|
|
554
|
+
}
|
|
555
|
+
apiRef.current.setState((0, _extends2.default)({}, apiRef.current.state, {
|
|
556
|
+
chartsIntegration: {
|
|
557
|
+
activeChartId: activeChartIdToRestore,
|
|
558
|
+
charts: chartsToRestore
|
|
559
|
+
}
|
|
560
|
+
}));
|
|
561
|
+
|
|
562
|
+
// restore the integration context for each chart
|
|
563
|
+
Object.entries(integrationContext).forEach(([chartId, chartContextState]) => {
|
|
564
|
+
setChartState(chartId, chartContextState);
|
|
565
|
+
});
|
|
566
|
+
return params;
|
|
567
|
+
}, [apiRef, setChartState]);
|
|
568
|
+
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'exportState', stateExportPreProcessing);
|
|
569
|
+
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
507
570
|
React.useEffect(() => {
|
|
508
571
|
if (!activeChartId && availableChartIds.length > 0) {
|
|
509
572
|
setActiveChartId(availableChartIds[0]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GridColDef, GridRowId, GridValidRowModel, GridDataSource, GridGetRowsResponse, GridGetRowsParams, GridDataSourceApiBase, GridDataSourcePrivateApi, GridRowModel } from '@mui/x-data-grid-pro';
|
|
2
|
+
import type { GridDataSourceFetchRowsParams } from '@mui/x-data-grid-pro/internals';
|
|
2
3
|
import type { GridAggregationModel } from "../aggregation/gridAggregationInterfaces.js";
|
|
3
4
|
import type { GridPivotModel } from "../pivoting/gridPivotingInterfaces.js";
|
|
4
5
|
export interface GridGetRowsResponsePivotColumn {
|
|
@@ -90,9 +91,10 @@ export interface GridDataSourceApiBasePremium extends Omit<GridDataSourceApiBase
|
|
|
90
91
|
* If no `parentId` option is provided, it fetches the root rows.
|
|
91
92
|
* Any missing parameter from `params` will be filled from the state (sorting, filtering, etc.).
|
|
92
93
|
* @param {GridRowId} parentId The id of the parent node (default: `GRID_ROOT_GROUP_ID`).
|
|
93
|
-
* @param {
|
|
94
|
+
* @param {GridDataSourceFetchRowsParams<GridGetRowsParamsPremium>} params Request parameters override.
|
|
95
|
+
* @returns {Promise<void>} A promise that resolves when the rows are fetched.
|
|
94
96
|
*/
|
|
95
|
-
fetchRows: (parentId?: GridRowId, params?:
|
|
97
|
+
fetchRows: (parentId?: GridRowId, params?: GridDataSourceFetchRowsParams<GridGetRowsParamsPremium>) => Promise<void>;
|
|
96
98
|
}
|
|
97
99
|
export interface GridDataSourceApiPremium {
|
|
98
100
|
/**
|
|
@@ -9,10 +9,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
exports.useGridDataSourcePremium = void 0;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
12
13
|
var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
13
14
|
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
14
15
|
var _gridPivotingSelectors = require("../pivoting/gridPivotingSelectors");
|
|
15
16
|
var _utils = require("./utils");
|
|
17
|
+
var _gridRowGroupingSelector = require("../rowGrouping/gridRowGroupingSelector");
|
|
18
|
+
var _gridAggregationSelectors = require("../aggregation/gridAggregationSelectors");
|
|
16
19
|
function getKeyPremium(params) {
|
|
17
20
|
return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.groupFields, params.start, params.end, params.pivotModel ? {} : params.aggregationModel, params.pivotModel]);
|
|
18
21
|
}
|
|
@@ -22,13 +25,32 @@ const options = {
|
|
|
22
25
|
}
|
|
23
26
|
};
|
|
24
27
|
const useGridDataSourcePremium = (apiRef, props) => {
|
|
28
|
+
const aggregationModel = (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef);
|
|
29
|
+
const groupingModelSize = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(apiRef).length;
|
|
30
|
+
const setStrategyAvailability = React.useCallback(() => {
|
|
31
|
+
const targetStrategy = props.treeData || !props.disableRowGrouping && groupingModelSize > 0 ? _internals.DataSourceRowsUpdateStrategy.GroupedData : _internals.DataSourceRowsUpdateStrategy.Default;
|
|
32
|
+
apiRef.current.setStrategyAvailability(_internals.GridStrategyGroup.DataSource, targetStrategy, props.dataSource && !props.lazyLoading ? () => true : () => false);
|
|
33
|
+
}, [apiRef, props.dataSource, props.lazyLoading, props.treeData, props.disableRowGrouping, groupingModelSize]);
|
|
34
|
+
const handleEditRowWithAggregation = React.useCallback((params, updatedRow) => {
|
|
35
|
+
const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
|
|
36
|
+
if (updatedRow && !(0, _isDeepEqual.isDeepEqual)(updatedRow, params.previousRow)) {
|
|
37
|
+
// Reset the outdated cache, only if the row is _actually_ updated
|
|
38
|
+
apiRef.current.dataSource.cache.clear();
|
|
39
|
+
}
|
|
40
|
+
const groupKeys = (0, _internals.getGroupKeys)(rowTree, params.rowId);
|
|
41
|
+
apiRef.current.updateNestedRows([updatedRow], groupKeys);
|
|
42
|
+
// To refresh the aggregation values of all parent rows and the footer row, recursively re-fetch all parent levels
|
|
43
|
+
(0, _utils.fetchParents)(rowTree, params.rowId, apiRef.current.dataSource.fetchRows);
|
|
44
|
+
}, [apiRef]);
|
|
25
45
|
const {
|
|
26
46
|
api,
|
|
27
47
|
debouncedFetchRows,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} = (0, _internals.useGridDataSourceBasePro)(apiRef, props,
|
|
48
|
+
flatTreeStrategyProcessor,
|
|
49
|
+
groupedDataStrategyProcessor,
|
|
50
|
+
events
|
|
51
|
+
} = (0, _internals.useGridDataSourceBasePro)(apiRef, props, (0, _extends2.default)({}, !props.disableAggregation && Object.keys(aggregationModel).length > 0 ? {
|
|
52
|
+
handleEditRow: handleEditRowWithAggregation
|
|
53
|
+
} : {}, options));
|
|
32
54
|
const aggregateRowRef = React.useRef({});
|
|
33
55
|
const initialColumns = (0, _internals.gridPivotInitialColumnsSelector)(apiRef);
|
|
34
56
|
const pivotActive = (0, _internals.gridPivotActiveSelector)(apiRef);
|
|
@@ -81,7 +103,8 @@ const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
81
103
|
});
|
|
82
104
|
(0, _xDataGridPro.useGridApiMethod)(apiRef, api.public, 'public');
|
|
83
105
|
(0, _xDataGridPro.useGridApiMethod)(apiRef, privateApi, 'private');
|
|
84
|
-
(0, _internals.useGridRegisterStrategyProcessor)(apiRef,
|
|
106
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, flatTreeStrategyProcessor.strategyName, flatTreeStrategyProcessor.group, flatTreeStrategyProcessor.processor);
|
|
107
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, groupedDataStrategyProcessor.strategyName, groupedDataStrategyProcessor.group, groupedDataStrategyProcessor.processor);
|
|
85
108
|
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'processDataSourceRows', processDataSourceRows);
|
|
86
109
|
Object.entries(events).forEach(([event, handler]) => {
|
|
87
110
|
(0, _xDataGridPro.useGridEvent)(apiRef, event, handler);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridColDef } from '@mui/x-data-grid-pro';
|
|
2
|
+
import { GridColDef, GridRowId, GridRowTreeConfig } from '@mui/x-data-grid-pro';
|
|
3
3
|
import type { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
4
|
import type { GridPivotingDynamicPropsOverrides, PivotingColDefCallback, GridPivotModel } from "../pivoting/gridPivotingInterfaces.js";
|
|
5
5
|
import type { GridGetRowsResponsePivotColumn } from "./models.js";
|
|
6
|
-
export declare const getPropsOverrides: (pivotColumns: GridGetRowsResponsePivotColumn[], pivotingColDef: PivotingColDefCallback, pivotModel: GridPivotModel, initialColumns: Map<string, GridColDef>, apiRef: RefObject<GridPrivateApiPremium>) => GridPivotingDynamicPropsOverrides;
|
|
6
|
+
export declare const getPropsOverrides: (pivotColumns: GridGetRowsResponsePivotColumn[], pivotingColDef: PivotingColDefCallback, pivotModel: GridPivotModel, initialColumns: Map<string, GridColDef>, apiRef: RefObject<GridPrivateApiPremium>) => GridPivotingDynamicPropsOverrides;
|
|
7
|
+
export declare const fetchParents: (rowTree: GridRowTreeConfig, rowId: GridRowId, fetchHandler: (id?: GridRowId) => Promise<void>) => Promise<void[]>;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getPropsOverrides = void 0;
|
|
7
|
+
exports.getPropsOverrides = exports.fetchParents = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
10
10
|
const getPropsOverrides = (pivotColumns, pivotingColDef, pivotModel, initialColumns, apiRef) => {
|
|
@@ -145,4 +145,17 @@ const getPropsOverrides = (pivotColumns, pivotingColDef, pivotModel, initialColu
|
|
|
145
145
|
aggregationModel
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
|
-
exports.getPropsOverrides = getPropsOverrides;
|
|
148
|
+
exports.getPropsOverrides = getPropsOverrides;
|
|
149
|
+
const fetchParents = (rowTree, rowId, fetchHandler) => {
|
|
150
|
+
const parents = [];
|
|
151
|
+
|
|
152
|
+
// collect all parents ids
|
|
153
|
+
let currentId = rowId;
|
|
154
|
+
while (currentId !== undefined && currentId !== _xDataGridPro.GRID_ROOT_GROUP_ID) {
|
|
155
|
+
const parentId = rowTree[currentId].parent;
|
|
156
|
+
parents.push(parentId);
|
|
157
|
+
currentId = parentId;
|
|
158
|
+
}
|
|
159
|
+
return Promise.all(parents.reverse().map(fetchHandler));
|
|
160
|
+
};
|
|
161
|
+
exports.fetchParents = fetchParents;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { CellEditableConditionFn } from '@mui/x-data-grid-pro/internals';
|
|
3
|
+
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
|
+
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
5
|
+
/**
|
|
6
|
+
* Implementation of the cell editable condition hook of the Data Grid Premium
|
|
7
|
+
*/
|
|
8
|
+
export declare const useIsCellEditable: (apiRef: RefObject<GridPrivateApiPremium>, props: DataGridPremiumProcessedProps) => CellEditableConditionFn;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useIsCellEditable = void 0;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
11
|
+
var _gridAggregationSelectors = require("../aggregation/gridAggregationSelectors");
|
|
12
|
+
/**
|
|
13
|
+
* Implementation of the cell editable condition hook of the Data Grid Premium
|
|
14
|
+
*/
|
|
15
|
+
const useIsCellEditable = (apiRef, props) => {
|
|
16
|
+
const isCellEditableCommunity = (0, _internals.useIsCellEditable)();
|
|
17
|
+
return React.useCallback(params => {
|
|
18
|
+
const isCellEditable = isCellEditableCommunity(params);
|
|
19
|
+
|
|
20
|
+
// If the cell is not editable by the community hook, return false immediately
|
|
21
|
+
if (!isCellEditable) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// If the data source is not used or aggregation is disabled or both tree data and row grouping are disabled, return the community hook result
|
|
26
|
+
if (!props.dataSource || props.disableAggregation || !props.treeData && props.disableRowGrouping) {
|
|
27
|
+
return isCellEditable;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// If the cell is not a part of the aggregation model, return the community hook result
|
|
31
|
+
const aggregationModelFields = Object.keys((0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef));
|
|
32
|
+
if (!aggregationModelFields.includes(params.field)) {
|
|
33
|
+
return isCellEditable;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The cell is a part of the aggregation model and it is retrieved from the server-side data.
|
|
37
|
+
// Allow editing only for the non-grouped rows.
|
|
38
|
+
return params.rowNode.type !== 'group';
|
|
39
|
+
}, [apiRef, props.dataSource, props.treeData, props.disableAggregation, props.disableRowGrouping, isCellEditableCommunity]);
|
|
40
|
+
};
|
|
41
|
+
exports.useIsCellEditable = useIsCellEditable;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as Excel from 'exceljs';
|
|
1
|
+
import type * as Excel from '@mui/x-internal-exceljs-fork';
|
|
2
2
|
import { GridFileExportOptions, GridExportFormat as GridExportFormatCommunity, GridExportExtension as GridExportExtensionCommunity } from '@mui/x-data-grid-pro';
|
|
3
3
|
export type GridExportFormat = GridExportFormatCommunity | 'excel';
|
|
4
4
|
export type GridExportExtension = GridExportExtensionCommunity | 'xlsx';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as Excel from 'exceljs';
|
|
1
|
+
import type * as Excel from '@mui/x-internal-exceljs-fork';
|
|
2
2
|
import { RefObject } from '@mui/x-internals/types';
|
|
3
3
|
import { GridRowId, GridColDef } from '@mui/x-data-grid-pro';
|
|
4
4
|
import { GridStateColDef } from '@mui/x-data-grid/internals';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as Excel from 'exceljs';
|
|
1
|
+
import type * as Excel from '@mui/x-internal-exceljs-fork';
|
|
2
2
|
import type { GridColumnGroupLookup } from '@mui/x-data-grid/internals';
|
|
3
3
|
import type { GridExcelExportOptions } from "../gridExcelExportInterface.js";
|
|
4
4
|
export declare const getExcelJs: () => Promise<typeof Excel>;
|
|
@@ -11,7 +11,7 @@ exports.getExcelJs = void 0;
|
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime/helpers/interopRequireWildcard"));
|
|
13
13
|
const getExcelJs = async () => {
|
|
14
|
-
const excelJsModule = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('exceljs')));
|
|
14
|
+
const excelJsModule = await Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('@mui/x-internal-exceljs-fork')));
|
|
15
15
|
return excelJsModule.default ?? excelJsModule;
|
|
16
16
|
};
|
|
17
17
|
exports.getExcelJs = getExcelJs;
|
|
@@ -92,12 +92,12 @@ function getGroupingCriteriaProperties(groupedByColDef, rowGroupingColumnMode, r
|
|
|
92
92
|
const rowId = (0, _xDataGridPro.gridRowIdSelector)(apiRef, row);
|
|
93
93
|
const rowNode = (0, _xDataGridPro.gridRowNodeSelector)(apiRef, rowId);
|
|
94
94
|
if (rowNode?.type === 'group') {
|
|
95
|
-
const originalColDef = columnsLookup[rowNode.groupingField];
|
|
96
|
-
if (originalColDef
|
|
95
|
+
const originalColDef = rowNode.groupingField ? columnsLookup[rowNode.groupingField] : null;
|
|
96
|
+
if (originalColDef?.type === 'singleSelect') {
|
|
97
97
|
// the default valueFormatter of a singleSelect colDef won't work with the grouping column values
|
|
98
98
|
return value;
|
|
99
99
|
}
|
|
100
|
-
const columnValueFormatter = originalColDef
|
|
100
|
+
const columnValueFormatter = originalColDef?.valueFormatter;
|
|
101
101
|
if (typeof columnValueFormatter === 'function') {
|
|
102
102
|
return columnValueFormatter(value, row, column, apiRef);
|
|
103
103
|
}
|
package/index.js
CHANGED
package/material/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare const materialSlots: {
|
|
|
25
25
|
promptRerunIcon: React.JSXElementConstructor<import("@mui/x-data-grid/models/gridBaseSlots").IconProps>;
|
|
26
26
|
promptSortAscIcon: React.JSXElementConstructor<import("@mui/x-data-grid/models/gridBaseSlots").IconProps>;
|
|
27
27
|
promptSortDescIcon: React.JSXElementConstructor<import("@mui/x-data-grid/models/gridBaseSlots").IconProps>;
|
|
28
|
+
promptChartsIcon: React.JSXElementConstructor<import("@mui/x-data-grid/models/gridBaseSlots").IconProps>;
|
|
28
29
|
promptGroupIcon: React.JSXElementConstructor<import("@mui/x-data-grid/models/gridBaseSlots").IconProps>;
|
|
29
30
|
promptFilterIcon: React.JSXElementConstructor<import("@mui/x-data-grid/models/gridBaseSlots").IconProps>;
|
|
30
31
|
promptPivotIcon: React.JSXElementConstructor<import("@mui/x-data-grid/models/gridBaseSlots").IconProps>;
|
package/material/index.js
CHANGED
|
@@ -40,6 +40,7 @@ const iconsSlots = {
|
|
|
40
40
|
promptPivotIcon: _icons.GridPivotIcon,
|
|
41
41
|
promptAggregationIcon: _icons.GridFunctionsIcon,
|
|
42
42
|
promptGroupIcon: _icons.GridGroupWorkIcon,
|
|
43
|
+
promptChartsIcon: _icons.GridChartsIcon,
|
|
43
44
|
promptChangesToggleIcon: _xDataGrid.GridExpandMoreIcon,
|
|
44
45
|
chartsIcon: _icons.GridChartsIcon,
|
|
45
46
|
chartsSearchIcon: _xDataGrid.GridSearchIcon,
|
|
@@ -132,6 +132,11 @@ export interface GridPremiumIconSlotsComponent {
|
|
|
132
132
|
* @default GridArrowDownwardIcon
|
|
133
133
|
*/
|
|
134
134
|
promptSortDescIcon: React.JSXElementConstructor<IconProps>;
|
|
135
|
+
/**
|
|
136
|
+
* Icon used to mark the request to visalize the data
|
|
137
|
+
* @default GridChartsIcon
|
|
138
|
+
*/
|
|
139
|
+
promptChartsIcon: React.JSXElementConstructor<IconProps>;
|
|
135
140
|
/**
|
|
136
141
|
* Icon used to display group changes
|
|
137
142
|
* @default GridGroupWorkIcon
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-premium",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.16.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The Premium plan edition of the MUI X Data Grid Components.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.28.4",
|
|
37
37
|
"@mui/utils": "^7.3.3",
|
|
38
|
+
"@mui/x-internal-exceljs-fork": "^4.4.1",
|
|
38
39
|
"clsx": "^2.1.1",
|
|
39
|
-
"exceljs": "^4.4.0",
|
|
40
40
|
"prop-types": "^15.8.1",
|
|
41
|
-
"@mui/x-data-grid
|
|
42
|
-
"@mui/x-data-grid": "8.
|
|
43
|
-
"@mui/x-
|
|
44
|
-
"@mui/x-
|
|
41
|
+
"@mui/x-data-grid": "8.16.0",
|
|
42
|
+
"@mui/x-data-grid-pro": "8.16.0",
|
|
43
|
+
"@mui/x-license": "8.16.0",
|
|
44
|
+
"@mui/x-internals": "8.16.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@emotion/react": "^11.9.0",
|