@mui/x-data-grid-premium 8.14.1 → 8.15.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 +107 -0
- package/DataGridPremium/DataGridPremium.js +2 -1
- package/components/prompt/GridPrompt.js +11 -1
- package/esm/DataGridPremium/DataGridPremium.js +2 -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/useGridChartsIntegration.js +2 -2
- package/esm/hooks/features/dataSource/models.d.ts +4 -2
- package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +12 -5
- 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/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/useGridChartsIntegration.js +2 -2
- package/hooks/features/dataSource/models.d.ts +4 -2
- package/hooks/features/dataSource/useGridDataSourcePremium.js +11 -4
- 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/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 +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,113 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.15.0
|
|
9
|
+
|
|
10
|
+
_Oct 23, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🖌️ Add new [`brush` charts interaction](https://mui.com/x/react-charts/brush/) for building custom behavior.
|
|
15
|
+

|
|
16
|
+
- ⚡️ Performance improvements for large bar charts
|
|
17
|
+
- 🤖 Data Grid AI assistant can now [visualize the query results](https://mui.com/x/react-data-grid/ai-assistant/#data-visualization) by controlling the chart integration settings
|
|
18
|
+
- 📦 DataGrid uses an internal MUI fork of ExcelJS that does not depend on vulnerable versions of NPM packages
|
|
19
|
+
- 🐞 Bugfixes
|
|
20
|
+
- 📚 Documentation improvements
|
|
21
|
+
|
|
22
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
23
|
+
@ZagrebaAlex
|
|
24
|
+
|
|
25
|
+
The following are all team members who have contributed to this release:
|
|
26
|
+
@alexfauquette, @bernardobelchior, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @KenanYusuf, @prakhargupta1, @rita-codes, @siriwatknp, @arminmeh, @brijeshb42, @noraleonte
|
|
27
|
+
|
|
28
|
+
### Data Grid
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid@8.15.0`
|
|
31
|
+
|
|
32
|
+
- [DataGrid] Fix `dataSource.fetchRows` API's return type (#20068) @arminmeh
|
|
33
|
+
|
|
34
|
+
#### `@mui/x-data-grid-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
35
|
+
|
|
36
|
+
Same changes as in `@mui/x-data-grid@8.15.0`, plus:
|
|
37
|
+
|
|
38
|
+
- [DataGridPro] Keep children in the tree after parent row is re-fetched with the data source (#19934) @arminmeh
|
|
39
|
+
- [DataGridPro] Support scroll shadows customization (#19982) @KenanYusuf
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-data-grid-premium@8.15.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
42
|
+
|
|
43
|
+
Same changes as in `@mui/x-data-grid-pro@8.15.0`, plus:
|
|
44
|
+
|
|
45
|
+
- [DataGridPremium] Use ExcelJS fork (#19796) @cherniavskii
|
|
46
|
+
- [DataGridPremium] Support data visualization in AI Assistant (#19831) @arminmeh
|
|
47
|
+
|
|
48
|
+
### Date and Time Pickers
|
|
49
|
+
|
|
50
|
+
#### `@mui/x-date-pickers@8.15.0`
|
|
51
|
+
|
|
52
|
+
Internal changes.
|
|
53
|
+
|
|
54
|
+
#### `@mui/x-date-pickers-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
55
|
+
|
|
56
|
+
Same changes as in `@mui/x-date-pickers@8.15.0`.
|
|
57
|
+
|
|
58
|
+
### Charts
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-charts@8.15.0`
|
|
61
|
+
|
|
62
|
+
- [charts] Add `ChartsBrushOverlay` and allow brush configuration (#19956) @JCQuintas
|
|
63
|
+
- [charts] Add `getStringSize` benchmark. Remove benchmarks from built package. (#19995) @bernardobelchior
|
|
64
|
+
- [charts] Batch string size measurement (#19994) @bernardobelchior
|
|
65
|
+
- [charts] Fix console issue (#20025) @JCQuintas
|
|
66
|
+
- [charts] Fix is[ZoomFeature]Enabled type (#20058) @alexfauquette
|
|
67
|
+
- [charts] Fix reference line middle spacing (#20004) @JCQuintas
|
|
68
|
+
- [charts] Improve `getStringSize` and `batchMeasureStrings` performance (#19996) @bernardobelchior
|
|
69
|
+
- [charts] Improve deep export script (#20007) @JCQuintas
|
|
70
|
+
- [charts] Improve string measurement benchmarks (#19999) @bernardobelchior
|
|
71
|
+
- [charts] Measure string sizes using SVG elements (#19981) @bernardobelchior
|
|
72
|
+
- [l10n] Improve Greek (gr-GR) locale (#20060) @ZagrebaAlex
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-charts-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
75
|
+
|
|
76
|
+
Same changes as in `@mui/x-charts@8.15.0`, plus:
|
|
77
|
+
|
|
78
|
+
- [charts-pro] Fix pan with `axis.reverse` (#20031) @JCQuintas
|
|
79
|
+
|
|
80
|
+
#### `@mui/x-charts-premium@8.15.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
81
|
+
|
|
82
|
+
Same changes as in `@mui/x-charts-pro@8.15.0`.
|
|
83
|
+
|
|
84
|
+
### Tree View
|
|
85
|
+
|
|
86
|
+
#### `@mui/x-tree-view@8.15.0`
|
|
87
|
+
|
|
88
|
+
- [tree view] Multi character type-ahead (#19942) @noraleonte
|
|
89
|
+
|
|
90
|
+
#### `@mui/x-tree-view-pro@8.15.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
91
|
+
|
|
92
|
+
Same changes as in `@mui/x-tree-view@8.15.0`.
|
|
93
|
+
|
|
94
|
+
### Codemod
|
|
95
|
+
|
|
96
|
+
#### `@mui/x-codemod@8.14.0`
|
|
97
|
+
|
|
98
|
+
Internal changes.
|
|
99
|
+
|
|
100
|
+
### Docs
|
|
101
|
+
|
|
102
|
+
- [docs] Add overview section for scatter chart and heatmap (#19888) @prakhargupta1
|
|
103
|
+
- [docs] Add charts bell curve example (#20003) @JCQuintas
|
|
104
|
+
- [docs] Add grouped multiple fields for Data Grid row grouping recipe (#19964) @siriwatknp
|
|
105
|
+
- [docs] Add Data Grid loading state recipe (#19958) @siriwatknp
|
|
106
|
+
|
|
107
|
+
### Core
|
|
108
|
+
|
|
109
|
+
- [code-infra] Remove @mui/monorepo usage for react versioning (#19894) @Janpot
|
|
110
|
+
- [code-infra] Remove invalid `environment: 'browser'` from vitest browser config (#19993) @bernardobelchior
|
|
111
|
+
- [code-infra] Remove unused babel aliases (#19987) @Janpot
|
|
112
|
+
- [code-infra] Turn on all testing-library eslint rules (#19946) @brijeshb42
|
|
113
|
+
- [docs-infra] Fix broken hash link (#20062) @Janpot
|
|
114
|
+
|
|
8
115
|
## 8.14.1
|
|
9
116
|
|
|
10
117
|
_Oct 16, 2025_
|
|
@@ -48,7 +48,7 @@ const configuration = {
|
|
|
48
48
|
useGridParamsOverridableMethods: _useGridParamsOverridableMethods.useGridParamsOverridableMethods
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const releaseInfo = "
|
|
51
|
+
const releaseInfo = "MTc2MTE3NzYwMDAwMA==";
|
|
52
52
|
const watermark = /*#__PURE__*/(0, _jsxRuntime.jsx)(_xLicense.Watermark, {
|
|
53
53
|
packageName: "x-data-grid-premium",
|
|
54
54
|
releaseInfo: releaseInfo
|
|
@@ -127,6 +127,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
127
127
|
helperText: _propTypes.default.string,
|
|
128
128
|
response: _propTypes.default.shape({
|
|
129
129
|
aggregation: _propTypes.default.object.isRequired,
|
|
130
|
+
chart: _propTypes.default.object,
|
|
130
131
|
conversationId: _propTypes.default.string.isRequired,
|
|
131
132
|
filterOperator: _propTypes.default.oneOf(['and', 'or']),
|
|
132
133
|
filters: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
@@ -277,6 +277,13 @@ function GridPrompt(props) {
|
|
|
277
277
|
}
|
|
278
278
|
return changes;
|
|
279
279
|
}, [apiRef, getColumnName, rootProps.slots]);
|
|
280
|
+
const getChartChanges = React.useCallback(chart => {
|
|
281
|
+
return {
|
|
282
|
+
label: apiRef.current.getLocaleText('toolbarCharts'),
|
|
283
|
+
description: apiRef.current.getLocaleText('promptChangeChartsLabel')(chart.dimensions.length, chart.values.length),
|
|
284
|
+
icon: rootProps.slots.promptChartsIcon
|
|
285
|
+
};
|
|
286
|
+
}, [apiRef, rootProps.slots.promptChartsIcon]);
|
|
280
287
|
const changeList = React.useMemo(() => {
|
|
281
288
|
if (!response) {
|
|
282
289
|
return [];
|
|
@@ -297,8 +304,11 @@ function GridPrompt(props) {
|
|
|
297
304
|
if (response.pivoting && 'columns' in response.pivoting) {
|
|
298
305
|
changes.push(...getPivotingChanges(response.pivoting));
|
|
299
306
|
}
|
|
307
|
+
if (response.chart) {
|
|
308
|
+
changes.push(getChartChanges(response.chart));
|
|
309
|
+
}
|
|
300
310
|
return changes;
|
|
301
|
-
}, [response, getGroupingChanges, getAggregationChanges, getFilterChanges, getSortingChanges, getPivotingChanges]);
|
|
311
|
+
}, [response, getGroupingChanges, getAggregationChanges, getFilterChanges, getSortingChanges, getPivotingChanges, getChartChanges]);
|
|
302
312
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PromptItem, {
|
|
303
313
|
ownerState: ownerState,
|
|
304
314
|
className: classes.root,
|
|
@@ -41,7 +41,7 @@ const configuration = {
|
|
|
41
41
|
useGridParamsOverridableMethods
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
const releaseInfo = "
|
|
44
|
+
const releaseInfo = "MTc2MTE3NzYwMDAwMA==";
|
|
45
45
|
const watermark = /*#__PURE__*/_jsx(Watermark, {
|
|
46
46
|
packageName: "x-data-grid-premium",
|
|
47
47
|
releaseInfo: releaseInfo
|
|
@@ -120,6 +120,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
120
120
|
helperText: PropTypes.string,
|
|
121
121
|
response: PropTypes.shape({
|
|
122
122
|
aggregation: PropTypes.object.isRequired,
|
|
123
|
+
chart: PropTypes.object,
|
|
123
124
|
conversationId: PropTypes.string.isRequired,
|
|
124
125
|
filterOperator: PropTypes.oneOf(['and', 'or']),
|
|
125
126
|
filters: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
@@ -270,6 +270,13 @@ function GridPrompt(props) {
|
|
|
270
270
|
}
|
|
271
271
|
return changes;
|
|
272
272
|
}, [apiRef, getColumnName, rootProps.slots]);
|
|
273
|
+
const getChartChanges = React.useCallback(chart => {
|
|
274
|
+
return {
|
|
275
|
+
label: apiRef.current.getLocaleText('toolbarCharts'),
|
|
276
|
+
description: apiRef.current.getLocaleText('promptChangeChartsLabel')(chart.dimensions.length, chart.values.length),
|
|
277
|
+
icon: rootProps.slots.promptChartsIcon
|
|
278
|
+
};
|
|
279
|
+
}, [apiRef, rootProps.slots.promptChartsIcon]);
|
|
273
280
|
const changeList = React.useMemo(() => {
|
|
274
281
|
if (!response) {
|
|
275
282
|
return [];
|
|
@@ -290,8 +297,11 @@ function GridPrompt(props) {
|
|
|
290
297
|
if (response.pivoting && 'columns' in response.pivoting) {
|
|
291
298
|
changes.push(...getPivotingChanges(response.pivoting));
|
|
292
299
|
}
|
|
300
|
+
if (response.chart) {
|
|
301
|
+
changes.push(getChartChanges(response.chart));
|
|
302
|
+
}
|
|
293
303
|
return changes;
|
|
294
|
-
}, [response, getGroupingChanges, getAggregationChanges, getFilterChanges, getSortingChanges, getPivotingChanges]);
|
|
304
|
+
}, [response, getGroupingChanges, getAggregationChanges, getFilterChanges, getSortingChanges, getPivotingChanges, getChartChanges]);
|
|
295
305
|
return /*#__PURE__*/_jsxs(PromptItem, {
|
|
296
306
|
ownerState: ownerState,
|
|
297
307
|
className: classes.root,
|
|
@@ -39,6 +39,10 @@ type Pivoting = {
|
|
|
39
39
|
rows: string[];
|
|
40
40
|
values: Aggregation[];
|
|
41
41
|
} | {};
|
|
42
|
+
type Chart = {
|
|
43
|
+
dimensions: string[];
|
|
44
|
+
values: string[];
|
|
45
|
+
};
|
|
42
46
|
export type PromptResponse = {
|
|
43
47
|
conversationId: string;
|
|
44
48
|
select: number;
|
|
@@ -48,6 +52,7 @@ export type PromptResponse = {
|
|
|
48
52
|
sorting: ColumnSort[];
|
|
49
53
|
grouping: Grouping[];
|
|
50
54
|
pivoting: Pivoting;
|
|
55
|
+
chart: Chart | null;
|
|
51
56
|
};
|
|
52
57
|
export type PromptResolverOptions = {
|
|
53
58
|
/**
|
|
@@ -3,4 +3,4 @@ import { GridStateInitializer } from '@mui/x-data-grid-pro/internals';
|
|
|
3
3
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
4
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
5
5
|
export declare const aiAssistantStateInitializer: GridStateInitializer<Pick<DataGridPremiumProcessedProps, 'initialState' | 'aiAssistantConversations' | 'aiAssistant'>>;
|
|
6
|
-
export declare const useGridAiAssistant: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aiAssistant" | "aiAssistantConversations" | "aiAssistantActiveConversationIndex" | "allowAiAssistantDataSampling" | "onAiAssistantConversationsChange" | "onAiAssistantActiveConversationIndexChange" | "onPrompt" | "slots" | "disableColumnFilter" | "disableRowGrouping" | "disableAggregation" | "disableColumnSorting" | "disablePivoting">) => void;
|
|
6
|
+
export declare const useGridAiAssistant: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aiAssistant" | "aiAssistantConversations" | "aiAssistantActiveConversationIndex" | "allowAiAssistantDataSampling" | "onAiAssistantConversationsChange" | "onAiAssistantActiveConversationIndexChange" | "onPrompt" | "slots" | "rowSelection" | "disableColumnFilter" | "disableRowGrouping" | "disableAggregation" | "disableColumnSorting" | "disablePivoting" | "chartsIntegration" | "experimentalFeatures" | "getPivotDerivedColumns">) => void;
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
6
|
+
import { gridColumnLookupSelector, GridLogicOperator, gridRowsLookupSelector, useGridApiMethod, GRID_CHECKBOX_SELECTION_FIELD, GridPreferencePanelsValue, gridColumnGroupsUnwrappedModelSelector, gridVisibleRowsSelector } from '@mui/x-data-grid-pro';
|
|
6
7
|
import { getValueOptions, getVisibleRows, useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
|
|
7
8
|
import { gridAiAssistantConversationsSelector, gridAiAssistantActiveConversationSelector, gridAiAssistantActiveConversationIndexSelector } from "./gridAiAssistantSelectors.js";
|
|
9
|
+
import { gridChartsIntegrationActiveChartIdSelector } from "../chartsIntegration/gridChartsIntegrationSelectors.js";
|
|
8
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
11
|
const DEFAULT_SAMPLE_COUNT = 5;
|
|
12
|
+
const MAX_CHART_DATA_POINTS = 1000;
|
|
10
13
|
export const aiAssistantStateInitializer = (state, props) => {
|
|
11
14
|
if (!props.aiAssistant) {
|
|
12
15
|
return _extends({}, state, {
|
|
@@ -28,12 +31,18 @@ export const useGridAiAssistant = (apiRef, props) => {
|
|
|
28
31
|
onPrompt,
|
|
29
32
|
allowAiAssistantDataSampling,
|
|
30
33
|
slots,
|
|
34
|
+
rowSelection,
|
|
31
35
|
disableColumnFilter,
|
|
32
36
|
disableRowGrouping,
|
|
33
37
|
disableAggregation,
|
|
34
38
|
disableColumnSorting,
|
|
35
|
-
disablePivoting
|
|
39
|
+
disablePivoting,
|
|
40
|
+
chartsIntegration,
|
|
41
|
+
experimentalFeatures,
|
|
42
|
+
getPivotDerivedColumns
|
|
36
43
|
} = props;
|
|
44
|
+
const previousUnwrappedGroupingModel = React.useRef([]);
|
|
45
|
+
const activeChartId = gridChartsIntegrationActiveChartIdSelector(apiRef);
|
|
37
46
|
const columnsLookup = gridColumnLookupSelector(apiRef);
|
|
38
47
|
const columns = Object.values(columnsLookup);
|
|
39
48
|
const rows = Object.values(gridRowsLookupSelector(apiRef));
|
|
@@ -78,15 +87,38 @@ export const useGridAiAssistant = (apiRef, props) => {
|
|
|
78
87
|
return '';
|
|
79
88
|
}
|
|
80
89
|
const examples = allowDataSampling ? collectSampleData() : {};
|
|
81
|
-
const columnsContext = columns.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
const columnsContext = columns.reduce((acc, column) => {
|
|
91
|
+
const columnContextWithoutExamples = {
|
|
92
|
+
field: column.field,
|
|
93
|
+
description: column.description ?? null,
|
|
94
|
+
examples: [],
|
|
95
|
+
type: column.type ?? 'string',
|
|
96
|
+
allowedOperators: column.filterOperators?.map(operator => operator.value) ?? []
|
|
97
|
+
};
|
|
98
|
+
acc.push(_extends({}, columnContextWithoutExamples, {
|
|
99
|
+
examples: examples[column.field] ?? column.examples ?? []
|
|
100
|
+
}));
|
|
101
|
+
if (disablePivoting) {
|
|
102
|
+
return acc;
|
|
103
|
+
}
|
|
104
|
+
(getPivotDerivedColumns?.(column, apiRef.current.getLocaleText) || []).forEach(col => acc.push(_extends({}, columnContextWithoutExamples, col, {
|
|
105
|
+
derivedFrom: column.field
|
|
106
|
+
})));
|
|
107
|
+
return acc;
|
|
108
|
+
}, []);
|
|
88
109
|
return JSON.stringify(columnsContext);
|
|
89
|
-
}, [columns, collectSampleData, isAiAssistantAvailable]);
|
|
110
|
+
}, [apiRef, columns, collectSampleData, getPivotDerivedColumns, isAiAssistantAvailable, disablePivoting]);
|
|
111
|
+
const updateChart = React.useCallback(result => {
|
|
112
|
+
if (!result.chart) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
apiRef.current.updateChartDimensionsData(activeChartId, result.chart.dimensions.map(item => ({
|
|
116
|
+
field: item
|
|
117
|
+
})));
|
|
118
|
+
apiRef.current.updateChartValuesData(activeChartId, result.chart.values.map(item => ({
|
|
119
|
+
field: item
|
|
120
|
+
})));
|
|
121
|
+
}, [apiRef, activeChartId]);
|
|
90
122
|
const applyPromptResult = React.useCallback(result => {
|
|
91
123
|
if (!isAiAssistantAvailable) {
|
|
92
124
|
return;
|
|
@@ -115,6 +147,8 @@ export const useGridAiAssistant = (apiRef, props) => {
|
|
|
115
147
|
quickFilterValues: []
|
|
116
148
|
});
|
|
117
149
|
interestColumns.push(...result.filters.map(f => f.column));
|
|
150
|
+
} else {
|
|
151
|
+
result.filters = [];
|
|
118
152
|
}
|
|
119
153
|
let appliedPivoting = false;
|
|
120
154
|
if (!disablePivoting && 'columns' in result.pivoting) {
|
|
@@ -138,6 +172,7 @@ export const useGridAiAssistant = (apiRef, props) => {
|
|
|
138
172
|
appliedPivoting = true;
|
|
139
173
|
} else if ('columns' in result.pivoting) {
|
|
140
174
|
// if pivoting is disabled and there are pivoting results, try to move them into grouping and aggregation
|
|
175
|
+
apiRef.current.setPivotActive(false);
|
|
141
176
|
result.pivoting.columns.forEach(c => {
|
|
142
177
|
result.grouping.push({
|
|
143
178
|
column: c.column
|
|
@@ -154,26 +189,58 @@ export const useGridAiAssistant = (apiRef, props) => {
|
|
|
154
189
|
});
|
|
155
190
|
// remove the pivoting results data
|
|
156
191
|
result.pivoting = {};
|
|
192
|
+
} else {
|
|
193
|
+
apiRef.current.setPivotActive(false);
|
|
157
194
|
}
|
|
158
195
|
if (!disableRowGrouping && !appliedPivoting) {
|
|
159
196
|
apiRef.current.setRowGroupingModel(result.grouping.map(g => g.column));
|
|
197
|
+
} else {
|
|
198
|
+
result.grouping = [];
|
|
160
199
|
}
|
|
161
200
|
if (!disableAggregation && !appliedPivoting) {
|
|
162
201
|
apiRef.current.setAggregationModel(result.aggregation);
|
|
163
202
|
interestColumns.push(...Object.keys(result.aggregation));
|
|
203
|
+
} else {
|
|
204
|
+
result.aggregation = {};
|
|
164
205
|
}
|
|
165
206
|
if (!disableColumnSorting) {
|
|
166
207
|
apiRef.current.setSortModel(result.sorting.map(s => ({
|
|
167
208
|
field: s.column,
|
|
168
209
|
sort: s.direction
|
|
169
210
|
})));
|
|
211
|
+
} else {
|
|
212
|
+
result.sorting = [];
|
|
213
|
+
}
|
|
214
|
+
if (experimentalFeatures?.charts && chartsIntegration && activeChartId && result.chart) {
|
|
215
|
+
if (appliedPivoting) {
|
|
216
|
+
const unsubscribe = apiRef.current.subscribeEvent('rowsSet', () => {
|
|
217
|
+
const unwrappedGroupingModel = Object.keys(gridColumnGroupsUnwrappedModelSelector(apiRef));
|
|
218
|
+
// wait until unwrapped grouping model changes
|
|
219
|
+
if (!result.chart || unwrappedGroupingModel.length === 0 || isDeepEqual(previousUnwrappedGroupingModel.current, unwrappedGroupingModel)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
previousUnwrappedGroupingModel.current = unwrappedGroupingModel;
|
|
223
|
+
const visibleRowsCount = gridVisibleRowsSelector(apiRef).rows.length;
|
|
224
|
+
const maxColumns = Math.floor(MAX_CHART_DATA_POINTS / visibleRowsCount);
|
|
225
|
+
|
|
226
|
+
// we assume that the pivoting was adjusted to what needs to be shown in the chart
|
|
227
|
+
// so we can just pick up all the columns that were created by pivoting
|
|
228
|
+
// to avoid rendering issues, set the limit to MAX_CHART_DATA_POINTS data points (rows * columns)
|
|
229
|
+
result.chart.values = unwrappedGroupingModel.slice(0, maxColumns);
|
|
230
|
+
updateChart(result);
|
|
231
|
+
unsubscribe();
|
|
232
|
+
});
|
|
233
|
+
} else {
|
|
234
|
+
updateChart(result);
|
|
235
|
+
}
|
|
170
236
|
}
|
|
171
237
|
const visibleRowsData = getVisibleRows(apiRef);
|
|
172
238
|
const rowSelectionModel = {
|
|
173
239
|
type: 'include',
|
|
174
240
|
ids: new Set()
|
|
175
241
|
};
|
|
176
|
-
|
|
242
|
+
const selection = rowSelection ? result.select : -1;
|
|
243
|
+
if (selection !== -1) {
|
|
177
244
|
for (let i = 0; i < result.select; i += 1) {
|
|
178
245
|
const row = visibleRowsData.rows[i];
|
|
179
246
|
const id = apiRef.current.getRowId(row);
|
|
@@ -183,7 +250,7 @@ export const useGridAiAssistant = (apiRef, props) => {
|
|
|
183
250
|
apiRef.current.setRowSelectionModel(rowSelectionModel);
|
|
184
251
|
const targetIndex = Number(columnsLookup[GRID_CHECKBOX_SELECTION_FIELD] !== undefined) + Number(result.grouping.length);
|
|
185
252
|
interestColumns.reverse().forEach(c => apiRef.current.setColumnIndex(c, targetIndex));
|
|
186
|
-
}, [apiRef, disableColumnFilter, disableRowGrouping, disableAggregation, disableColumnSorting, disablePivoting, columnsLookup, isAiAssistantAvailable]);
|
|
253
|
+
}, [apiRef, updateChart, rowSelection, disableColumnFilter, disableRowGrouping, disableAggregation, disableColumnSorting, disablePivoting, columnsLookup, isAiAssistantAvailable, activeChartId, chartsIntegration, experimentalFeatures?.charts]);
|
|
187
254
|
const setActiveConversationId = React.useCallback(id => {
|
|
188
255
|
if (!isAiAssistantAvailable) {
|
|
189
256
|
return;
|
|
@@ -62,7 +62,6 @@ export const useGridChartsIntegration = (apiRef, props) => {
|
|
|
62
62
|
const context = useGridChartsIntegrationContext(true);
|
|
63
63
|
const isChartsIntegrationAvailable = !!props.chartsIntegration && !!props.experimentalFeatures?.charts && !!context;
|
|
64
64
|
const activeChartId = gridChartsIntegrationActiveChartIdSelector(apiRef);
|
|
65
|
-
const orderedFields = gridColumnFieldsSelector(apiRef);
|
|
66
65
|
const aggregationModel = gridAggregationModelSelector(apiRef);
|
|
67
66
|
const pivotActive = gridPivotActiveSelector(apiRef);
|
|
68
67
|
const pivotModel = gridPivotModelSelector(apiRef);
|
|
@@ -170,6 +169,7 @@ export const useGridChartsIntegration = (apiRef, props) => {
|
|
|
170
169
|
if (chartIds.length === 0 || chartIds.some(chartId => !visibleDimensions.current[chartId] || !visibleValues.current[chartId])) {
|
|
171
170
|
return;
|
|
172
171
|
}
|
|
172
|
+
const orderedFields = gridColumnFieldsSelector(apiRef);
|
|
173
173
|
const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
174
174
|
const rowTree = gridRowTreeSelector(apiRef);
|
|
175
175
|
const rowsPerDepth = gridFilteredSortedDepthRowEntriesSelector(apiRef);
|
|
@@ -226,7 +226,7 @@ export const useGridChartsIntegration = (apiRef, props) => {
|
|
|
226
226
|
}))
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
|
-
}, [apiRef,
|
|
229
|
+
}, [apiRef, getColumnName, getValueDatasetLabel, setChartState]);
|
|
230
230
|
const debouncedHandleRowDataUpdate = React.useMemo(() => debounce(handleRowDataUpdate, 0), [handleRowDataUpdate]);
|
|
231
231
|
const handleColumnDataUpdate = React.useCallback((chartIds, updatedChartStateLookup) => {
|
|
232
232
|
// if there are no charts, skip the data processing
|
|
@@ -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
|
/**
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useGridEvent as addEventHandler, useGridApiMethod, GRID_ROOT_GROUP_ID, useGridEvent } from '@mui/x-data-grid-pro';
|
|
6
|
-
import { useGridDataSourceBasePro, useGridRegisterStrategyProcessor, useGridRegisterPipeProcessor, gridPivotInitialColumnsSelector, runIf, gridPivotActiveSelector } from '@mui/x-data-grid-pro/internals';
|
|
6
|
+
import { useGridDataSourceBasePro, useGridRegisterStrategyProcessor, useGridRegisterPipeProcessor, gridPivotInitialColumnsSelector, runIf, gridPivotActiveSelector, GridStrategyGroup, DataSourceRowsUpdateStrategy } from '@mui/x-data-grid-pro/internals';
|
|
7
7
|
import { gridPivotModelSelector } from "../pivoting/gridPivotingSelectors.js";
|
|
8
8
|
import { getPropsOverrides } from "./utils.js";
|
|
9
|
+
import { gridRowGroupingSanitizedModelSelector } from "../rowGrouping/gridRowGroupingSelector.js";
|
|
9
10
|
function getKeyPremium(params) {
|
|
10
11
|
return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.groupFields, params.start, params.end, params.pivotModel ? {} : params.aggregationModel, params.pivotModel]);
|
|
11
12
|
}
|
|
@@ -15,12 +16,17 @@ const options = {
|
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
export const useGridDataSourcePremium = (apiRef, props) => {
|
|
19
|
+
const groupingModelSize = gridRowGroupingSanitizedModelSelector(apiRef).length;
|
|
20
|
+
const setStrategyAvailability = React.useCallback(() => {
|
|
21
|
+
const targetStrategy = props.treeData || !props.disableRowGrouping && groupingModelSize > 0 ? DataSourceRowsUpdateStrategy.GroupedData : DataSourceRowsUpdateStrategy.Default;
|
|
22
|
+
apiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, targetStrategy, props.dataSource && !props.lazyLoading ? () => true : () => false);
|
|
23
|
+
}, [apiRef, props.dataSource, props.lazyLoading, props.treeData, props.disableRowGrouping, groupingModelSize]);
|
|
18
24
|
const {
|
|
19
25
|
api,
|
|
20
26
|
debouncedFetchRows,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
flatTreeStrategyProcessor,
|
|
28
|
+
groupedDataStrategyProcessor,
|
|
29
|
+
events
|
|
24
30
|
} = useGridDataSourceBasePro(apiRef, props, options);
|
|
25
31
|
const aggregateRowRef = React.useRef({});
|
|
26
32
|
const initialColumns = gridPivotInitialColumnsSelector(apiRef);
|
|
@@ -74,7 +80,8 @@ export const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
74
80
|
});
|
|
75
81
|
useGridApiMethod(apiRef, api.public, 'public');
|
|
76
82
|
useGridApiMethod(apiRef, privateApi, 'private');
|
|
77
|
-
useGridRegisterStrategyProcessor(apiRef,
|
|
83
|
+
useGridRegisterStrategyProcessor(apiRef, flatTreeStrategyProcessor.strategyName, flatTreeStrategyProcessor.group, flatTreeStrategyProcessor.processor);
|
|
84
|
+
useGridRegisterStrategyProcessor(apiRef, groupedDataStrategyProcessor.strategyName, groupedDataStrategyProcessor.group, groupedDataStrategyProcessor.processor);
|
|
78
85
|
useGridRegisterPipeProcessor(apiRef, 'processDataSourceRows', processDataSourceRows);
|
|
79
86
|
Object.entries(events).forEach(([event, handler]) => {
|
|
80
87
|
addEventHandler(apiRef, event, handler);
|
|
@@ -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>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
export const getExcelJs = async () => {
|
|
3
|
-
const excelJsModule = await import('exceljs');
|
|
3
|
+
const excelJsModule = await import('@mui/x-internal-exceljs-fork');
|
|
4
4
|
return excelJsModule.default ?? excelJsModule;
|
|
5
5
|
};
|
|
6
6
|
export const addColumnGroupingHeaders = (worksheet, columns, columnGroupPaths, columnGroupDetails) => {
|
package/esm/index.js
CHANGED
package/esm/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/esm/material/index.js
CHANGED
|
@@ -33,6 +33,7 @@ const iconsSlots = {
|
|
|
33
33
|
promptPivotIcon: GridPivotIcon,
|
|
34
34
|
promptAggregationIcon: GridFunctionsIcon,
|
|
35
35
|
promptGroupIcon: GridGroupWorkIcon,
|
|
36
|
+
promptChartsIcon: GridChartsIcon,
|
|
36
37
|
promptChangesToggleIcon: GridExpandMoreIcon,
|
|
37
38
|
chartsIcon: GridChartsIcon,
|
|
38
39
|
chartsSearchIcon: 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
|
|
@@ -39,6 +39,10 @@ type Pivoting = {
|
|
|
39
39
|
rows: string[];
|
|
40
40
|
values: Aggregation[];
|
|
41
41
|
} | {};
|
|
42
|
+
type Chart = {
|
|
43
|
+
dimensions: string[];
|
|
44
|
+
values: string[];
|
|
45
|
+
};
|
|
42
46
|
export type PromptResponse = {
|
|
43
47
|
conversationId: string;
|
|
44
48
|
select: number;
|
|
@@ -48,6 +52,7 @@ export type PromptResponse = {
|
|
|
48
52
|
sorting: ColumnSort[];
|
|
49
53
|
grouping: Grouping[];
|
|
50
54
|
pivoting: Pivoting;
|
|
55
|
+
chart: Chart | null;
|
|
51
56
|
};
|
|
52
57
|
export type PromptResolverOptions = {
|
|
53
58
|
/**
|
|
@@ -3,4 +3,4 @@ import { GridStateInitializer } from '@mui/x-data-grid-pro/internals';
|
|
|
3
3
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
4
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
5
5
|
export declare const aiAssistantStateInitializer: GridStateInitializer<Pick<DataGridPremiumProcessedProps, 'initialState' | 'aiAssistantConversations' | 'aiAssistant'>>;
|
|
6
|
-
export declare const useGridAiAssistant: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aiAssistant" | "aiAssistantConversations" | "aiAssistantActiveConversationIndex" | "allowAiAssistantDataSampling" | "onAiAssistantConversationsChange" | "onAiAssistantActiveConversationIndexChange" | "onPrompt" | "slots" | "disableColumnFilter" | "disableRowGrouping" | "disableAggregation" | "disableColumnSorting" | "disablePivoting">) => void;
|
|
6
|
+
export declare const useGridAiAssistant: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aiAssistant" | "aiAssistantConversations" | "aiAssistantActiveConversationIndex" | "allowAiAssistantDataSampling" | "onAiAssistantConversationsChange" | "onAiAssistantActiveConversationIndexChange" | "onPrompt" | "slots" | "rowSelection" | "disableColumnFilter" | "disableRowGrouping" | "disableAggregation" | "disableColumnSorting" | "disablePivoting" | "chartsIntegration" | "experimentalFeatures" | "getPivotDerivedColumns">) => void;
|
|
@@ -9,11 +9,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
exports.useGridAiAssistant = exports.aiAssistantStateInitializer = 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 _gridAiAssistantSelectors = require("./gridAiAssistantSelectors");
|
|
16
|
+
var _gridChartsIntegrationSelectors = require("../chartsIntegration/gridChartsIntegrationSelectors");
|
|
15
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
18
|
const DEFAULT_SAMPLE_COUNT = 5;
|
|
19
|
+
const MAX_CHART_DATA_POINTS = 1000;
|
|
17
20
|
const aiAssistantStateInitializer = (state, props) => {
|
|
18
21
|
if (!props.aiAssistant) {
|
|
19
22
|
return (0, _extends2.default)({}, state, {
|
|
@@ -36,12 +39,18 @@ const useGridAiAssistant = (apiRef, props) => {
|
|
|
36
39
|
onPrompt,
|
|
37
40
|
allowAiAssistantDataSampling,
|
|
38
41
|
slots,
|
|
42
|
+
rowSelection,
|
|
39
43
|
disableColumnFilter,
|
|
40
44
|
disableRowGrouping,
|
|
41
45
|
disableAggregation,
|
|
42
46
|
disableColumnSorting,
|
|
43
|
-
disablePivoting
|
|
47
|
+
disablePivoting,
|
|
48
|
+
chartsIntegration,
|
|
49
|
+
experimentalFeatures,
|
|
50
|
+
getPivotDerivedColumns
|
|
44
51
|
} = props;
|
|
52
|
+
const previousUnwrappedGroupingModel = React.useRef([]);
|
|
53
|
+
const activeChartId = (0, _gridChartsIntegrationSelectors.gridChartsIntegrationActiveChartIdSelector)(apiRef);
|
|
45
54
|
const columnsLookup = (0, _xDataGridPro.gridColumnLookupSelector)(apiRef);
|
|
46
55
|
const columns = Object.values(columnsLookup);
|
|
47
56
|
const rows = Object.values((0, _xDataGridPro.gridRowsLookupSelector)(apiRef));
|
|
@@ -86,15 +95,38 @@ const useGridAiAssistant = (apiRef, props) => {
|
|
|
86
95
|
return '';
|
|
87
96
|
}
|
|
88
97
|
const examples = allowDataSampling ? collectSampleData() : {};
|
|
89
|
-
const columnsContext = columns.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
const columnsContext = columns.reduce((acc, column) => {
|
|
99
|
+
const columnContextWithoutExamples = {
|
|
100
|
+
field: column.field,
|
|
101
|
+
description: column.description ?? null,
|
|
102
|
+
examples: [],
|
|
103
|
+
type: column.type ?? 'string',
|
|
104
|
+
allowedOperators: column.filterOperators?.map(operator => operator.value) ?? []
|
|
105
|
+
};
|
|
106
|
+
acc.push((0, _extends2.default)({}, columnContextWithoutExamples, {
|
|
107
|
+
examples: examples[column.field] ?? column.examples ?? []
|
|
108
|
+
}));
|
|
109
|
+
if (disablePivoting) {
|
|
110
|
+
return acc;
|
|
111
|
+
}
|
|
112
|
+
(getPivotDerivedColumns?.(column, apiRef.current.getLocaleText) || []).forEach(col => acc.push((0, _extends2.default)({}, columnContextWithoutExamples, col, {
|
|
113
|
+
derivedFrom: column.field
|
|
114
|
+
})));
|
|
115
|
+
return acc;
|
|
116
|
+
}, []);
|
|
96
117
|
return JSON.stringify(columnsContext);
|
|
97
|
-
}, [columns, collectSampleData, isAiAssistantAvailable]);
|
|
118
|
+
}, [apiRef, columns, collectSampleData, getPivotDerivedColumns, isAiAssistantAvailable, disablePivoting]);
|
|
119
|
+
const updateChart = React.useCallback(result => {
|
|
120
|
+
if (!result.chart) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
apiRef.current.updateChartDimensionsData(activeChartId, result.chart.dimensions.map(item => ({
|
|
124
|
+
field: item
|
|
125
|
+
})));
|
|
126
|
+
apiRef.current.updateChartValuesData(activeChartId, result.chart.values.map(item => ({
|
|
127
|
+
field: item
|
|
128
|
+
})));
|
|
129
|
+
}, [apiRef, activeChartId]);
|
|
98
130
|
const applyPromptResult = React.useCallback(result => {
|
|
99
131
|
if (!isAiAssistantAvailable) {
|
|
100
132
|
return;
|
|
@@ -123,6 +155,8 @@ const useGridAiAssistant = (apiRef, props) => {
|
|
|
123
155
|
quickFilterValues: []
|
|
124
156
|
});
|
|
125
157
|
interestColumns.push(...result.filters.map(f => f.column));
|
|
158
|
+
} else {
|
|
159
|
+
result.filters = [];
|
|
126
160
|
}
|
|
127
161
|
let appliedPivoting = false;
|
|
128
162
|
if (!disablePivoting && 'columns' in result.pivoting) {
|
|
@@ -146,6 +180,7 @@ const useGridAiAssistant = (apiRef, props) => {
|
|
|
146
180
|
appliedPivoting = true;
|
|
147
181
|
} else if ('columns' in result.pivoting) {
|
|
148
182
|
// if pivoting is disabled and there are pivoting results, try to move them into grouping and aggregation
|
|
183
|
+
apiRef.current.setPivotActive(false);
|
|
149
184
|
result.pivoting.columns.forEach(c => {
|
|
150
185
|
result.grouping.push({
|
|
151
186
|
column: c.column
|
|
@@ -162,26 +197,58 @@ const useGridAiAssistant = (apiRef, props) => {
|
|
|
162
197
|
});
|
|
163
198
|
// remove the pivoting results data
|
|
164
199
|
result.pivoting = {};
|
|
200
|
+
} else {
|
|
201
|
+
apiRef.current.setPivotActive(false);
|
|
165
202
|
}
|
|
166
203
|
if (!disableRowGrouping && !appliedPivoting) {
|
|
167
204
|
apiRef.current.setRowGroupingModel(result.grouping.map(g => g.column));
|
|
205
|
+
} else {
|
|
206
|
+
result.grouping = [];
|
|
168
207
|
}
|
|
169
208
|
if (!disableAggregation && !appliedPivoting) {
|
|
170
209
|
apiRef.current.setAggregationModel(result.aggregation);
|
|
171
210
|
interestColumns.push(...Object.keys(result.aggregation));
|
|
211
|
+
} else {
|
|
212
|
+
result.aggregation = {};
|
|
172
213
|
}
|
|
173
214
|
if (!disableColumnSorting) {
|
|
174
215
|
apiRef.current.setSortModel(result.sorting.map(s => ({
|
|
175
216
|
field: s.column,
|
|
176
217
|
sort: s.direction
|
|
177
218
|
})));
|
|
219
|
+
} else {
|
|
220
|
+
result.sorting = [];
|
|
221
|
+
}
|
|
222
|
+
if (experimentalFeatures?.charts && chartsIntegration && activeChartId && result.chart) {
|
|
223
|
+
if (appliedPivoting) {
|
|
224
|
+
const unsubscribe = apiRef.current.subscribeEvent('rowsSet', () => {
|
|
225
|
+
const unwrappedGroupingModel = Object.keys((0, _xDataGridPro.gridColumnGroupsUnwrappedModelSelector)(apiRef));
|
|
226
|
+
// wait until unwrapped grouping model changes
|
|
227
|
+
if (!result.chart || unwrappedGroupingModel.length === 0 || (0, _isDeepEqual.isDeepEqual)(previousUnwrappedGroupingModel.current, unwrappedGroupingModel)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
previousUnwrappedGroupingModel.current = unwrappedGroupingModel;
|
|
231
|
+
const visibleRowsCount = (0, _xDataGridPro.gridVisibleRowsSelector)(apiRef).rows.length;
|
|
232
|
+
const maxColumns = Math.floor(MAX_CHART_DATA_POINTS / visibleRowsCount);
|
|
233
|
+
|
|
234
|
+
// we assume that the pivoting was adjusted to what needs to be shown in the chart
|
|
235
|
+
// so we can just pick up all the columns that were created by pivoting
|
|
236
|
+
// to avoid rendering issues, set the limit to MAX_CHART_DATA_POINTS data points (rows * columns)
|
|
237
|
+
result.chart.values = unwrappedGroupingModel.slice(0, maxColumns);
|
|
238
|
+
updateChart(result);
|
|
239
|
+
unsubscribe();
|
|
240
|
+
});
|
|
241
|
+
} else {
|
|
242
|
+
updateChart(result);
|
|
243
|
+
}
|
|
178
244
|
}
|
|
179
245
|
const visibleRowsData = (0, _internals.getVisibleRows)(apiRef);
|
|
180
246
|
const rowSelectionModel = {
|
|
181
247
|
type: 'include',
|
|
182
248
|
ids: new Set()
|
|
183
249
|
};
|
|
184
|
-
|
|
250
|
+
const selection = rowSelection ? result.select : -1;
|
|
251
|
+
if (selection !== -1) {
|
|
185
252
|
for (let i = 0; i < result.select; i += 1) {
|
|
186
253
|
const row = visibleRowsData.rows[i];
|
|
187
254
|
const id = apiRef.current.getRowId(row);
|
|
@@ -191,7 +258,7 @@ const useGridAiAssistant = (apiRef, props) => {
|
|
|
191
258
|
apiRef.current.setRowSelectionModel(rowSelectionModel);
|
|
192
259
|
const targetIndex = Number(columnsLookup[_xDataGridPro.GRID_CHECKBOX_SELECTION_FIELD] !== undefined) + Number(result.grouping.length);
|
|
193
260
|
interestColumns.reverse().forEach(c => apiRef.current.setColumnIndex(c, targetIndex));
|
|
194
|
-
}, [apiRef, disableColumnFilter, disableRowGrouping, disableAggregation, disableColumnSorting, disablePivoting, columnsLookup, isAiAssistantAvailable]);
|
|
261
|
+
}, [apiRef, updateChart, rowSelection, disableColumnFilter, disableRowGrouping, disableAggregation, disableColumnSorting, disablePivoting, columnsLookup, isAiAssistantAvailable, activeChartId, chartsIntegration, experimentalFeatures?.charts]);
|
|
195
262
|
const setActiveConversationId = React.useCallback(id => {
|
|
196
263
|
if (!isAiAssistantAvailable) {
|
|
197
264
|
return;
|
|
@@ -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);
|
|
@@ -178,6 +177,7 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
178
177
|
if (chartIds.length === 0 || chartIds.some(chartId => !visibleDimensions.current[chartId] || !visibleValues.current[chartId])) {
|
|
179
178
|
return;
|
|
180
179
|
}
|
|
180
|
+
const orderedFields = (0, _internals.gridColumnFieldsSelector)(apiRef);
|
|
181
181
|
const rowGroupingModel = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(apiRef);
|
|
182
182
|
const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
|
|
183
183
|
const rowsPerDepth = (0, _internals.gridFilteredSortedDepthRowEntriesSelector)(apiRef);
|
|
@@ -234,7 +234,7 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
234
234
|
}))
|
|
235
235
|
});
|
|
236
236
|
});
|
|
237
|
-
}, [apiRef,
|
|
237
|
+
}, [apiRef, getColumnName, getValueDatasetLabel, setChartState]);
|
|
238
238
|
const debouncedHandleRowDataUpdate = React.useMemo(() => (0, _debounce.default)(handleRowDataUpdate, 0), [handleRowDataUpdate]);
|
|
239
239
|
const handleColumnDataUpdate = React.useCallback((chartIds, updatedChartStateLookup) => {
|
|
240
240
|
// if there are no charts, skip the data processing
|
|
@@ -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
|
/**
|
|
@@ -13,6 +13,7 @@ var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
|
13
13
|
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
14
14
|
var _gridPivotingSelectors = require("../pivoting/gridPivotingSelectors");
|
|
15
15
|
var _utils = require("./utils");
|
|
16
|
+
var _gridRowGroupingSelector = require("../rowGrouping/gridRowGroupingSelector");
|
|
16
17
|
function getKeyPremium(params) {
|
|
17
18
|
return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.groupFields, params.start, params.end, params.pivotModel ? {} : params.aggregationModel, params.pivotModel]);
|
|
18
19
|
}
|
|
@@ -22,12 +23,17 @@ const options = {
|
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
const useGridDataSourcePremium = (apiRef, props) => {
|
|
26
|
+
const groupingModelSize = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(apiRef).length;
|
|
27
|
+
const setStrategyAvailability = React.useCallback(() => {
|
|
28
|
+
const targetStrategy = props.treeData || !props.disableRowGrouping && groupingModelSize > 0 ? _internals.DataSourceRowsUpdateStrategy.GroupedData : _internals.DataSourceRowsUpdateStrategy.Default;
|
|
29
|
+
apiRef.current.setStrategyAvailability(_internals.GridStrategyGroup.DataSource, targetStrategy, props.dataSource && !props.lazyLoading ? () => true : () => false);
|
|
30
|
+
}, [apiRef, props.dataSource, props.lazyLoading, props.treeData, props.disableRowGrouping, groupingModelSize]);
|
|
25
31
|
const {
|
|
26
32
|
api,
|
|
27
33
|
debouncedFetchRows,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
flatTreeStrategyProcessor,
|
|
35
|
+
groupedDataStrategyProcessor,
|
|
36
|
+
events
|
|
31
37
|
} = (0, _internals.useGridDataSourceBasePro)(apiRef, props, options);
|
|
32
38
|
const aggregateRowRef = React.useRef({});
|
|
33
39
|
const initialColumns = (0, _internals.gridPivotInitialColumnsSelector)(apiRef);
|
|
@@ -81,7 +87,8 @@ const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
81
87
|
});
|
|
82
88
|
(0, _xDataGridPro.useGridApiMethod)(apiRef, api.public, 'public');
|
|
83
89
|
(0, _xDataGridPro.useGridApiMethod)(apiRef, privateApi, 'private');
|
|
84
|
-
(0, _internals.useGridRegisterStrategyProcessor)(apiRef,
|
|
90
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, flatTreeStrategyProcessor.strategyName, flatTreeStrategyProcessor.group, flatTreeStrategyProcessor.processor);
|
|
91
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, groupedDataStrategyProcessor.strategyName, groupedDataStrategyProcessor.group, groupedDataStrategyProcessor.processor);
|
|
85
92
|
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'processDataSourceRows', processDataSourceRows);
|
|
86
93
|
Object.entries(events).forEach(([event, handler]) => {
|
|
87
94
|
(0, _xDataGridPro.useGridEvent)(apiRef, event, handler);
|
|
@@ -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;
|
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.15.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-pro": "8.14.1",
|
|
42
|
-
"@mui/x-data-grid": "8.14.1",
|
|
43
41
|
"@mui/x-internals": "8.14.0",
|
|
44
|
-
"@mui/x-
|
|
42
|
+
"@mui/x-data-grid": "8.15.0",
|
|
43
|
+
"@mui/x-data-grid-pro": "8.15.0",
|
|
44
|
+
"@mui/x-license": "8.15.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@emotion/react": "^11.9.0",
|