@mui/x-data-grid-premium 8.9.1 → 8.10.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +217 -8
  2. package/DataGridPremium/DataGridPremium.js +27 -10
  3. package/DataGridPremium/useDataGridPremiumComponent.js +5 -0
  4. package/components/GridColumnMenuPivotItem.js +4 -3
  5. package/components/GridDataSourceGroupingCriteriaCell.js +3 -1
  6. package/components/pivotPanel/GridPivotPanelHeader.js +1 -1
  7. package/components/pivotPanel/PivotPanelTrigger.js +6 -1
  8. package/components/sidebar/Sidebar.d.ts +1 -1
  9. package/components/sidebar/Sidebar.js +20 -4
  10. package/esm/DataGridPremium/DataGridPremium.js +29 -12
  11. package/esm/DataGridPremium/useDataGridPremiumComponent.js +6 -1
  12. package/esm/components/GridColumnMenuPivotItem.js +3 -2
  13. package/esm/components/GridDataSourceGroupingCriteriaCell.js +3 -1
  14. package/esm/components/pivotPanel/GridPivotPanelHeader.js +1 -1
  15. package/esm/components/pivotPanel/PivotPanelTrigger.js +6 -1
  16. package/esm/components/sidebar/Sidebar.d.ts +1 -1
  17. package/esm/components/sidebar/Sidebar.js +21 -5
  18. package/esm/hooks/features/aggregation/gridAggregationInterfaces.d.ts +1 -1
  19. package/esm/hooks/features/aiAssistant/api.d.ts +3 -3
  20. package/esm/hooks/features/aiAssistant/api.js +8 -4
  21. package/esm/hooks/features/aiAssistant/gridAiAssistantInterfaces.d.ts +11 -0
  22. package/esm/hooks/features/export/serializer/excelSerializer.js +1 -6
  23. package/esm/hooks/features/index.d.ts +2 -1
  24. package/esm/hooks/features/index.js +2 -1
  25. package/esm/hooks/features/pivoting/gridPivotingInterfaces.d.ts +5 -0
  26. package/esm/hooks/features/pivoting/gridPivotingSelectors.d.ts +4 -1
  27. package/esm/hooks/features/pivoting/gridPivotingSelectors.js +3 -1
  28. package/esm/hooks/features/pivoting/useGridPivoting.d.ts +1 -1
  29. package/esm/hooks/features/pivoting/useGridPivoting.js +28 -9
  30. package/esm/hooks/features/pivoting/utils.js +7 -5
  31. package/esm/hooks/features/rowGrouping/createGroupingColDef.d.ts +1 -2
  32. package/esm/hooks/features/rowGrouping/createGroupingColDef.js +10 -3
  33. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +1 -5
  34. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +1 -6
  35. package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +2 -2
  36. package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +2 -2
  37. package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
  38. package/esm/hooks/features/rows/useGridRowAriaAttributes.d.ts +1 -1
  39. package/esm/hooks/features/rows/useGridRowAriaAttributes.js +2 -2
  40. package/esm/hooks/features/sidebar/gridSidebarInterfaces.d.ts +16 -0
  41. package/esm/hooks/features/sidebar/gridSidebarInterfaces.js +4 -0
  42. package/esm/hooks/features/sidebar/gridSidebarSelector.d.ts +12 -0
  43. package/esm/hooks/features/sidebar/gridSidebarSelector.js +12 -0
  44. package/esm/hooks/features/sidebar/gridSidebarState.d.ts +8 -0
  45. package/esm/hooks/features/sidebar/gridSidebarState.js +1 -0
  46. package/esm/hooks/features/sidebar/index.d.ts +3 -0
  47. package/esm/hooks/features/sidebar/index.js +3 -0
  48. package/esm/hooks/features/sidebar/useGridSidebar.d.ts +6 -0
  49. package/esm/hooks/features/sidebar/useGridSidebar.js +72 -0
  50. package/esm/hooks/utils/useGridAriaAttributes.d.ts +1 -1
  51. package/esm/hooks/utils/useGridAriaAttributes.js +2 -2
  52. package/esm/index.js +1 -1
  53. package/esm/models/dataGridPremiumProps.d.ts +16 -0
  54. package/esm/models/gridApiPremium.d.ts +4 -2
  55. package/esm/models/gridStatePremium.d.ts +3 -0
  56. package/esm/typeOverloads/modules.d.ts +28 -1
  57. package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +1 -1
  58. package/hooks/features/aiAssistant/api.d.ts +3 -3
  59. package/hooks/features/aiAssistant/api.js +8 -4
  60. package/hooks/features/aiAssistant/gridAiAssistantInterfaces.d.ts +11 -0
  61. package/hooks/features/export/serializer/excelSerializer.js +1 -6
  62. package/hooks/features/index.d.ts +2 -1
  63. package/hooks/features/index.js +11 -0
  64. package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +5 -0
  65. package/hooks/features/pivoting/gridPivotingSelectors.d.ts +4 -1
  66. package/hooks/features/pivoting/gridPivotingSelectors.js +3 -8
  67. package/hooks/features/pivoting/useGridPivoting.d.ts +1 -1
  68. package/hooks/features/pivoting/useGridPivoting.js +28 -9
  69. package/hooks/features/pivoting/utils.js +7 -5
  70. package/hooks/features/rowGrouping/createGroupingColDef.d.ts +1 -2
  71. package/hooks/features/rowGrouping/createGroupingColDef.js +13 -6
  72. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +1 -5
  73. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +3 -8
  74. package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +6 -6
  75. package/hooks/features/rowGrouping/useGridRowGrouping.js +1 -1
  76. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +7 -7
  77. package/hooks/features/rows/useGridRowAriaAttributes.d.ts +1 -1
  78. package/hooks/features/rows/useGridRowAriaAttributes.js +4 -4
  79. package/hooks/features/sidebar/gridSidebarInterfaces.d.ts +16 -0
  80. package/hooks/features/sidebar/gridSidebarInterfaces.js +10 -0
  81. package/hooks/features/sidebar/gridSidebarSelector.d.ts +12 -0
  82. package/hooks/features/sidebar/gridSidebarSelector.js +18 -0
  83. package/hooks/features/sidebar/gridSidebarState.d.ts +8 -0
  84. package/hooks/features/sidebar/gridSidebarState.js +5 -0
  85. package/hooks/features/sidebar/index.d.ts +3 -0
  86. package/hooks/features/sidebar/index.js +38 -0
  87. package/hooks/features/sidebar/useGridSidebar.d.ts +6 -0
  88. package/hooks/features/sidebar/useGridSidebar.js +82 -0
  89. package/hooks/utils/useGridAriaAttributes.d.ts +1 -1
  90. package/hooks/utils/useGridAriaAttributes.js +4 -4
  91. package/index.js +1 -1
  92. package/models/dataGridPremiumProps.d.ts +16 -0
  93. package/models/gridApiPremium.d.ts +4 -2
  94. package/models/gridStatePremium.d.ts +3 -0
  95. package/package.json +7 -9
  96. package/typeOverloads/modules.d.ts +28 -1
@@ -0,0 +1,12 @@
1
+ import { createRootSelector, createSelector } from '@mui/x-data-grid-pro/internals';
2
+ export const gridSidebarStateSelector = createRootSelector(state => state.sidebar);
3
+ export const gridSidebarOpenSelector = createSelector(gridSidebarStateSelector, state => state.open);
4
+ export const gridSidebarContentSelector = createSelector(gridSidebarStateSelector, ({
5
+ sidebarId,
6
+ labelId,
7
+ value
8
+ }) => ({
9
+ sidebarId,
10
+ labelId,
11
+ value
12
+ }));
@@ -0,0 +1,8 @@
1
+ import { GridSidebarValue } from "./gridSidebarInterfaces.js";
2
+ export interface GridSidebarState {
3
+ open: boolean;
4
+ sidebarId?: string;
5
+ labelId?: string;
6
+ value?: GridSidebarValue;
7
+ }
8
+ export type GridSidebarInitialState = GridSidebarState;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from "./gridSidebarInterfaces.js";
2
+ export * from "./gridSidebarSelector.js";
3
+ export * from "./gridSidebarState.js";
@@ -0,0 +1,3 @@
1
+ export * from "./gridSidebarInterfaces.js";
2
+ export * from "./gridSidebarSelector.js";
3
+ export * from "./gridSidebarState.js";
@@ -0,0 +1,6 @@
1
+ import { RefObject } from '@mui/x-internals/types';
2
+ import { GridStateInitializer } from '@mui/x-data-grid-pro/internals';
3
+ import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
4
+ import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
5
+ export declare const sidebarStateInitializer: GridStateInitializer<Pick<DataGridPremiumProcessedProps, 'initialState'>>;
6
+ export declare const useGridSidebar: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "onSidebarClose" | "onSidebarOpen">) => void;
@@ -0,0 +1,72 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { useGridApiMethod, useGridRegisterPipeProcessor, useGridEventPriority } from '@mui/x-data-grid-pro/internals';
4
+ import { gridSidebarStateSelector } from "./gridSidebarSelector.js";
5
+ export const sidebarStateInitializer = (state, props) => _extends({}, state, {
6
+ sidebar: props.initialState?.sidebar ?? {
7
+ open: false
8
+ }
9
+ });
10
+ export const useGridSidebar = (apiRef, props) => {
11
+ const hideSidebar = React.useCallback(() => {
12
+ apiRef.current.setState(state => {
13
+ if (!state.sidebar.open || !state.sidebar.value) {
14
+ return state;
15
+ }
16
+ apiRef.current.publishEvent('sidebarClose', {
17
+ value: state.sidebar.value
18
+ });
19
+ return _extends({}, state, {
20
+ sidebar: {
21
+ open: false
22
+ }
23
+ });
24
+ });
25
+ }, [apiRef]);
26
+ const showSidebar = React.useCallback((newValue, sidebarId, labelId) => {
27
+ apiRef.current.setState(state => _extends({}, state, {
28
+ sidebar: _extends({}, state.sidebar, {
29
+ open: true,
30
+ value: newValue,
31
+ sidebarId,
32
+ labelId
33
+ })
34
+ }));
35
+ apiRef.current.publishEvent('sidebarOpen', {
36
+ value: newValue
37
+ });
38
+ }, [apiRef]);
39
+ useGridApiMethod(apiRef, {
40
+ showSidebar,
41
+ hideSidebar
42
+ }, 'public');
43
+ const stateExportPreProcessing = React.useCallback((prevState, context) => {
44
+ const sidebarToExport = gridSidebarStateSelector(apiRef);
45
+ const shouldExportSidebar =
46
+ // Always export if the `exportOnlyDirtyModels` property is not activated
47
+ !context.exportOnlyDirtyModels ||
48
+ // Always export if the sidebar was initialized
49
+ props.initialState?.sidebar != null ||
50
+ // Always export if the sidebar is opened
51
+ sidebarToExport.open;
52
+ if (!shouldExportSidebar) {
53
+ return prevState;
54
+ }
55
+ return _extends({}, prevState, {
56
+ sidebar: sidebarToExport
57
+ });
58
+ }, [apiRef, props.initialState?.sidebar]);
59
+ const stateRestorePreProcessing = React.useCallback((params, context) => {
60
+ const sidebar = context.stateToRestore.sidebar;
61
+ if (sidebar != null) {
62
+ apiRef.current.setState(state => _extends({}, state, {
63
+ sidebar
64
+ }));
65
+ }
66
+ return params;
67
+ }, [apiRef]);
68
+ useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
69
+ useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
70
+ useGridEventPriority(apiRef, 'sidebarClose', props.onSidebarClose);
71
+ useGridEventPriority(apiRef, 'sidebarOpen', props.onSidebarOpen);
72
+ };
@@ -1,2 +1,2 @@
1
1
  import * as React from 'react';
2
- export declare const useGridAriaAttributes: () => React.HTMLAttributes<HTMLElement>;
2
+ export declare const useGridAriaAttributesPremium: () => React.HTMLAttributes<HTMLElement>;
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { useGridAriaAttributes as useGridAriaAttributesPro, useGridSelector } from '@mui/x-data-grid-pro/internals';
2
+ import { useGridAriaAttributesPro, useGridSelector } from '@mui/x-data-grid-pro/internals';
3
3
  import { gridRowGroupingSanitizedModelSelector } from "../features/rowGrouping/gridRowGroupingSelector.js";
4
4
  import { useGridPrivateApiContext } from "./useGridPrivateApiContext.js";
5
- export const useGridAriaAttributes = () => {
5
+ export const useGridAriaAttributesPremium = () => {
6
6
  const ariaAttributesPro = useGridAriaAttributesPro();
7
7
  const apiRef = useGridPrivateApiContext();
8
8
  const gridRowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector);
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v8.9.1
2
+ * @mui/x-data-grid-premium v8.10.0
3
3
  *
4
4
  * @license SEE LICENSE IN LICENSE
5
5
  * This source code is licensed under the SEE LICENSE IN LICENSE license found in the
@@ -205,11 +205,13 @@ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowM
205
205
  /**
206
206
  * If `true`, the pivot side panel is visible.
207
207
  * @default false
208
+ * @deprecated Use `initialState.sidebar.open` instead.
208
209
  */
209
210
  pivotPanelOpen?: boolean;
210
211
  /**
211
212
  * Callback fired when the pivot side panel open state changes.
212
213
  * @param {boolean} pivotPanelOpen Whether the pivot side panel is visible.
214
+ * @deprecated Use the `sidebarOpen` and `sidebarClose` events or corresponding event handlers `onSidebarOpen()` and `onSidebarClose()` instead.
213
215
  */
214
216
  onPivotPanelOpenChange?: (pivotPanelOpen: boolean) => void;
215
217
  /**
@@ -254,4 +256,18 @@ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowM
254
256
  * @returns {Promise<PromptResponse>} The prompt response.
255
257
  */
256
258
  onPrompt?: (prompt: string, promptContext: string, conversationId?: string) => Promise<PromptResponse>;
259
+ /**
260
+ * Callback fired when the sidebar is closed.
261
+ * @param {GridSidebarParams} params With all properties from [[GridSidebarParams]].
262
+ * @param {MuiEvent<{}>} event The event object.
263
+ * @param {GridCallbackDetails} details Additional details for this callback.
264
+ */
265
+ onSidebarClose?: GridEventListener<'sidebarClose'>;
266
+ /**
267
+ * Callback fired when the sidebar is opened.
268
+ * @param {GridSidebarParams} params With all properties from [[GridSidebarParams]].
269
+ * @param {MuiEvent<{}>} event The event object.
270
+ * @param {GridCallbackDetails} details Additional details for this callback.
271
+ */
272
+ onSidebarOpen?: GridEventListener<'sidebarOpen'>;
257
273
  }
@@ -1,5 +1,6 @@
1
1
  import { GridPrivateOnlyApiCommon } from '@mui/x-data-grid/internals';
2
2
  import { GridApiCommon, GridColumnPinningApi, GridDetailPanelApi, GridDetailPanelPrivateApi, GridRowPinningApi, GridRowMultiSelectionApi, GridColumnReorderApi, GridRowProApi } from '@mui/x-data-grid-pro';
3
+ import { GridRowReorderPrivateApi } from '@mui/x-data-grid-pro/internals';
3
4
  import { GridInitialStatePremium, GridStatePremium } from "./gridStatePremium.js";
4
5
  import type { GridRowGroupingApi, GridExcelExportApi, GridAggregationApi } from "../hooks/index.js";
5
6
  import { GridCellSelectionApi } from "../hooks/features/cellSelection/gridCellSelectionInterfaces.js";
@@ -8,9 +9,10 @@ import type { GridDataSourcePremiumPrivateApi, GridDataSourceApiPremium } from "
8
9
  import type { GridAggregationPrivateApi } from "../hooks/features/aggregation/gridAggregationInterfaces.js";
9
10
  import type { GridPivotingApi, GridPivotingPrivateApi } from "../hooks/features/pivoting/gridPivotingInterfaces.js";
10
11
  import { GridAiAssistantApi } from "../hooks/features/aiAssistant/gridAiAssistantInterfaces.js";
12
+ import { GridSidebarApi } from "../hooks/features/sidebar/gridSidebarInterfaces.js";
11
13
  /**
12
14
  * The api of Data Grid Premium.
13
15
  * TODO: Do not redefine manually the pro features
14
16
  */
15
- export interface GridApiPremium extends GridApiCommon<GridStatePremium, GridInitialStatePremium>, GridRowProApi, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi, GridAggregationApi, GridRowPinningApi, GridDataSourceApiPremium, GridCellSelectionApi, GridPivotingApi, GridAiAssistantApi, GridRowMultiSelectionApi, GridColumnReorderApi {}
16
- export interface GridPrivateApiPremium extends GridApiPremium, GridPrivateOnlyApiCommon<GridApiPremium, GridPrivateApiPremium, DataGridPremiumProcessedProps>, GridDataSourcePremiumPrivateApi, GridAggregationPrivateApi, GridDetailPanelPrivateApi, GridPivotingPrivateApi {}
17
+ export interface GridApiPremium extends GridApiCommon<GridStatePremium, GridInitialStatePremium>, GridRowProApi, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi, GridAggregationApi, GridRowPinningApi, GridDataSourceApiPremium, GridCellSelectionApi, GridPivotingApi, GridAiAssistantApi, GridSidebarApi, GridRowMultiSelectionApi, GridColumnReorderApi {}
18
+ export interface GridPrivateApiPremium extends GridApiPremium, GridPrivateOnlyApiCommon<GridApiPremium, GridPrivateApiPremium, DataGridPremiumProcessedProps>, GridDataSourcePremiumPrivateApi, GridAggregationPrivateApi, GridDetailPanelPrivateApi, GridRowReorderPrivateApi, GridPivotingPrivateApi {}
@@ -2,6 +2,7 @@ import { GridInitialState as GridInitialStatePro, GridState as GridStatePro } fr
2
2
  import type { GridRowGroupingState, GridRowGroupingInitialState, GridAggregationState, GridAggregationInitialState, GridCellSelectionModel } from "../hooks/index.js";
3
3
  import type { GridPivotingInitialState, GridPivotingState } from "../hooks/features/pivoting/gridPivotingInterfaces.js";
4
4
  import { GridAiAssistantInitialState, GridAiAssistantState } from "../hooks/features/aiAssistant/gridAiAssistantInterfaces.js";
5
+ import { GridSidebarInitialState, GridSidebarState } from "../hooks/features/sidebar/gridSidebarState.js";
5
6
  /**
6
7
  * The state of Data Grid Premium.
7
8
  */
@@ -11,6 +12,7 @@ export interface GridStatePremium extends GridStatePro {
11
12
  cellSelection: GridCellSelectionModel;
12
13
  pivoting: GridPivotingState;
13
14
  aiAssistant: GridAiAssistantState;
15
+ sidebar: GridSidebarState;
14
16
  }
15
17
  /**
16
18
  * The initial state of Data Grid Premium.
@@ -21,4 +23,5 @@ export interface GridInitialStatePremium extends GridInitialStatePro {
21
23
  cellSelection?: GridCellSelectionModel;
22
24
  pivoting?: GridPivotingInitialState;
23
25
  aiAssistant?: GridAiAssistantInitialState;
26
+ sidebar?: GridSidebarInitialState;
24
27
  }
@@ -1,11 +1,12 @@
1
1
  import { GridExportDisplayOptions, GridValidRowModel } from '@mui/x-data-grid-pro';
2
- import type { GridControlledStateEventLookupPro, GridApiCachesPro, GridEventLookupPro } from '@mui/x-data-grid-pro/typeOverloads';
2
+ import type { GridPipeProcessingLookupPro, GridControlledStateEventLookupPro, GridApiCachesPro, GridEventLookupPro } from '@mui/x-data-grid-pro/typeOverloads';
3
3
  import type { GridGroupingValueGetter, GridPastedValueParser } from "../models/index.js";
4
4
  import type { GridRowGroupingModel, GridAggregationModel, GridAggregationCellMeta, GridAggregationHeaderMeta, GridCellSelectionModel, Conversation } from "../hooks/index.js";
5
5
  import { GridRowGroupingInternalCache } from "../hooks/features/rowGrouping/gridRowGroupingInterfaces.js";
6
6
  import { GridAggregationInternalCache } from "../hooks/features/aggregation/gridAggregationInterfaces.js";
7
7
  import type { GridExcelExportOptions } from "../hooks/features/export/gridExcelExportInterface.js";
8
8
  import type { GridPivotingInternalCache, GridPivotModel } from "../hooks/features/pivoting/gridPivotingInterfaces.js";
9
+ import { GridSidebarValue } from "../hooks/features/sidebar/gridSidebarInterfaces.js";
9
10
  export interface GridControlledStateEventLookupPremium {
10
11
  /**
11
12
  * Fired when the aggregation model changes.
@@ -40,6 +41,9 @@ export interface GridControlledStateEventLookupPremium {
40
41
  pivotModeChange: {
41
42
  params: boolean;
42
43
  };
44
+ /**
45
+ * @deprecated Use the `sidebarOpen` and `sidebarClose` events instead.
46
+ */
43
47
  pivotPanelOpenChange: {
44
48
  params: boolean;
45
49
  };
@@ -69,6 +73,22 @@ interface GridEventLookupPremium extends GridEventLookupPro {
69
73
  * Fired when the clipboard paste operation ends.
70
74
  */
71
75
  clipboardPasteEnd: {};
76
+ /**
77
+ * Fired when the sidebar is opened.
78
+ */
79
+ sidebarOpen: {
80
+ params: {
81
+ value: GridSidebarValue;
82
+ };
83
+ };
84
+ /**
85
+ * Fired when the sidebar is closed.
86
+ */
87
+ sidebarClose: {
88
+ params: {
89
+ value: GridSidebarValue;
90
+ };
91
+ };
72
92
  }
73
93
  export interface GridColDefPremium<R extends GridValidRowModel = any, V = any, F = V> {
74
94
  /**
@@ -109,8 +129,15 @@ export interface GridApiCachesPremium extends GridApiCachesPro {
109
129
  rowGrouping: GridRowGroupingInternalCache;
110
130
  aggregation: GridAggregationInternalCache;
111
131
  }
132
+ export interface GridPipeProcessingLookupPremium {
133
+ sidebar: {
134
+ value: React.ReactNode;
135
+ context: GridSidebarValue;
136
+ };
137
+ }
112
138
  declare module '@mui/x-data-grid-pro' {
113
139
  interface GridEventLookup extends GridEventLookupPremium {}
140
+ interface GridPipeProcessingLookup extends GridPipeProcessingLookupPro, GridPipeProcessingLookupPremium {}
114
141
  interface GridControlledStateEventLookup extends GridControlledStateEventLookupPro, GridControlledStateEventLookupPremium {}
115
142
  interface GridRenderCellParams<R, V, F> extends GridRenderCellParamsPremium<R, V, F> {}
116
143
  interface GridColumnHeaderParams<R, V, F> extends GridColumnHeaderParamsPremium<R, V, F> {}
@@ -47,7 +47,7 @@ export interface GridAggregationFunction<V = any, AV = V> {
47
47
  * @param {GridApiPremium} api The grid API.
48
48
  * @returns {AV} The aggregated value.
49
49
  */
50
- apply: (params: GridAggregationParams<V>, api: GridApiPremium) => AV | null | undefined;
50
+ apply: (params: GridAggregationParams<V>, api?: GridApiPremium) => AV | null | undefined;
51
51
  /**
52
52
  * Label of the aggregation function.
53
53
  * Used for adding a label to the footer of the grouping column when this aggregation function is the only one being used.
@@ -1,4 +1,4 @@
1
- import { PromptResponse } from "./gridAiAssistantInterfaces.js";
1
+ import { PromptResponse, PromptResolverOptions } from "./gridAiAssistantInterfaces.js";
2
2
  /**
3
3
  * Prompt resolver for the <DataGridPremium /> component.
4
4
  * @param {string} url The URL to send the request to.
@@ -6,7 +6,7 @@ import { PromptResponse } from "./gridAiAssistantInterfaces.js";
6
6
  * @param {string} context The prompt context containing necessary information about the current columns definition.
7
7
  * Either use the `context` parameter of the `onPrompt` callback or the return value of the `unstable_getPromptContext()` API method.
8
8
  * @param {string} conversationId The id of the conversation the prompt is part of. If not passed, prompt response will return a new conversation id that can be used to continue the newly started conversation.
9
- * @param {string} additionalContext Optional, additional context to make the processing results more accurate.
9
+ * @param {string | PromptResolverOptions} optionsOrAdditionalContext Optional, includes settings to extend and customize the prompt resolver's behaviour, or additional context string for backward compatibility.
10
10
  * @returns {Promise<PromptResponse>} The grid state updates to be applied.
11
11
  */
12
- export declare function gridDefaultPromptResolver(url: string, query: string, context: string, conversationId?: string, additionalContext?: string): Promise<PromptResponse>;
12
+ export declare function gridDefaultPromptResolver(url: string, query: string, context: string, conversationId?: string, optionsOrAdditionalContext?: string | PromptResolverOptions): Promise<PromptResponse>;
@@ -11,10 +11,14 @@ exports.gridDefaultPromptResolver = gridDefaultPromptResolver;
11
11
  * @param {string} context The prompt context containing necessary information about the current columns definition.
12
12
  * Either use the `context` parameter of the `onPrompt` callback or the return value of the `unstable_getPromptContext()` API method.
13
13
  * @param {string} conversationId The id of the conversation the prompt is part of. If not passed, prompt response will return a new conversation id that can be used to continue the newly started conversation.
14
- * @param {string} additionalContext Optional, additional context to make the processing results more accurate.
14
+ * @param {string | PromptResolverOptions} optionsOrAdditionalContext Optional, includes settings to extend and customize the prompt resolver's behaviour, or additional context string for backward compatibility.
15
15
  * @returns {Promise<PromptResponse>} The grid state updates to be applied.
16
16
  */
17
- function gridDefaultPromptResolver(url, query, context, conversationId, additionalContext = '') {
17
+ function gridDefaultPromptResolver(url, query, context, conversationId, optionsOrAdditionalContext = '') {
18
+ // Handle backward compatibility: if string is passed, treat it as additionalContext
19
+ const options = typeof optionsOrAdditionalContext === 'string' ? {
20
+ additionalContext: optionsOrAdditionalContext
21
+ } : optionsOrAdditionalContext;
18
22
  return fetch(url, {
19
23
  mode: 'cors',
20
24
  method: 'POST',
@@ -25,8 +29,8 @@ function gridDefaultPromptResolver(url, query, context, conversationId, addition
25
29
  body: JSON.stringify({
26
30
  context,
27
31
  query,
28
- additionalContext,
29
- conversationId
32
+ conversationId,
33
+ options
30
34
  })
31
35
  }).then(result => result.json()).then(result => {
32
36
  if (result.ok === false) {
@@ -49,6 +49,17 @@ export type PromptResponse = {
49
49
  grouping: Grouping[];
50
50
  pivoting: Pivoting;
51
51
  };
52
+ export type PromptResolverOptions = {
53
+ /**
54
+ * By default, MUI's prompt resolver service stores the queries made to the service to analyze potential errors and improve the service (data is never stored). Enable private mode to make the service only keep track of the token count, without any query related data.
55
+ * @default false
56
+ */
57
+ privateMode?: boolean;
58
+ /**
59
+ * Additional context to make the processing results more accurate.
60
+ */
61
+ additionalContext?: string;
62
+ };
52
63
  /**
53
64
  * The prompt API interface that is available in the grid [[apiRef]].
54
65
  */
@@ -58,12 +58,7 @@ const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormulae, op
58
58
  const hasColSpan = (0, _internals.gridHasColSpanSelector)(apiRef);
59
59
  if (hasColSpan) {
60
60
  // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
61
- apiRef.current.calculateColSpan({
62
- rowId: id,
63
- minFirstColumn: 0,
64
- maxLastColumn: columns.length,
65
- columns
66
- });
61
+ apiRef.current.calculateColSpan(id, 0, columns.length, columns);
67
62
  }
68
63
  columns.forEach((column, colIndex) => {
69
64
  const colSpanInfo = hasColSpan ? apiRef.current.unstable_getCellColSpanInfo(id, colIndex) : undefined;
@@ -2,4 +2,5 @@ export * from "./aggregation/index.js";
2
2
  export * from "./rowGrouping/index.js";
3
3
  export * from "./export/index.js";
4
4
  export * from "./cellSelection/index.js";
5
- export * from "./aiAssistant/index.js";
5
+ export * from "./aiAssistant/index.js";
6
+ export * from "./sidebar/index.js";
@@ -57,4 +57,15 @@ Object.keys(_aiAssistant).forEach(function (key) {
57
57
  return _aiAssistant[key];
58
58
  }
59
59
  });
60
+ });
61
+ var _sidebar = require("./sidebar");
62
+ Object.keys(_sidebar).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _sidebar[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _sidebar[key];
69
+ }
70
+ });
60
71
  });
@@ -23,6 +23,10 @@ export interface GridPivotingState extends GridPivotingStatePartial {
23
23
  export interface GridPivotingInitialState {
24
24
  model?: GridPivotModel;
25
25
  enabled?: boolean;
26
+ /**
27
+ * To open the pivot sidebar on init, set sidebar's `openValue` to `GridSidebarValue.Pivot`.
28
+ * @deprecated Use sidebar state instead.
29
+ */
26
30
  panelOpen?: boolean;
27
31
  }
28
32
  export interface GridPivotModel {
@@ -55,6 +59,7 @@ export interface GridPivotingApi {
55
59
  setPivotActive: (active: boolean | ((prev: boolean) => boolean)) => void;
56
60
  /**
57
61
  * Sets whether the pivot panel is open.
62
+ * @deprecated Use the `showSidebar` method instead. Using this method will not trigger the `sidebarOpen` and `sidebarClose` events.
58
63
  * @param {boolean | ((prev: boolean) => boolean)} open - The new value of the pivot panel open state.
59
64
  */
60
65
  setPivotPanelOpen: (open: boolean | ((prev: boolean) => boolean)) => void;
@@ -1,8 +1,11 @@
1
1
  import type { GridStatePremium } from "../../../models/gridStatePremium.js";
2
+ export declare const gridPivotPanelOpenSelector: (args_0: import("react").RefObject<{
3
+ state: GridStatePremium;
4
+ } | null>) => boolean;
2
5
  export declare const gridPivotModelSelector: (args_0: import("react").RefObject<{
3
6
  state: GridStatePremium;
4
7
  } | null>) => import("./gridPivotingInterfaces.js").GridPivotModel;
5
8
  export declare const gridPivotPropsOverridesSelector: (args_0: import("react").RefObject<{
6
9
  state: GridStatePremium;
7
10
  } | null>) => import("./gridPivotingInterfaces.js").GridPivotingPropsOverrides | undefined;
8
- export { gridPivotActiveSelector, gridPivotInitialColumnsSelector, gridPivotPanelOpenSelector } from '@mui/x-data-grid/internals';
11
+ export { gridPivotActiveSelector, gridPivotInitialColumnsSelector } from '@mui/x-data-grid/internals';
@@ -15,16 +15,11 @@ Object.defineProperty(exports, "gridPivotInitialColumnsSelector", {
15
15
  return _internals2.gridPivotInitialColumnsSelector;
16
16
  }
17
17
  });
18
- exports.gridPivotModelSelector = void 0;
19
- Object.defineProperty(exports, "gridPivotPanelOpenSelector", {
20
- enumerable: true,
21
- get: function () {
22
- return _internals2.gridPivotPanelOpenSelector;
23
- }
24
- });
25
- exports.gridPivotPropsOverridesSelector = void 0;
18
+ exports.gridPivotPropsOverridesSelector = exports.gridPivotPanelOpenSelector = exports.gridPivotModelSelector = void 0;
26
19
  var _internals = require("@mui/x-data-grid-pro/internals");
20
+ var _sidebar = require("../sidebar");
27
21
  var _internals2 = require("@mui/x-data-grid/internals");
28
22
  const gridPivotingStateSelector = (0, _internals.createRootSelector)(state => state.pivoting);
23
+ const gridPivotPanelOpenSelector = exports.gridPivotPanelOpenSelector = (0, _internals.createSelector)(_sidebar.gridSidebarStateSelector, sidebar => sidebar.value === _sidebar.GridSidebarValue.Pivot && sidebar.open);
29
24
  const gridPivotModelSelector = exports.gridPivotModelSelector = (0, _internals.createSelector)(gridPivotingStateSelector, pivoting => pivoting?.model);
30
25
  const gridPivotPropsOverridesSelector = exports.gridPivotPropsOverridesSelector = (0, _internals.createSelector)(gridPivotingStateSelector, pivoting => pivoting?.active ? pivoting.propsOverrides : undefined);
@@ -3,6 +3,6 @@ import { RefObject } from '@mui/x-internals/types';
3
3
  import { GridStateInitializer } from '@mui/x-data-grid-pro/internals';
4
4
  import type { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
5
5
  import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
6
- export declare const pivotingStateInitializer: GridStateInitializer<Pick<DataGridPremiumProcessedProps, 'pivotActive' | 'pivotModel' | 'pivotPanelOpen' | 'initialState' | 'disablePivoting' | 'getPivotDerivedColumns' | 'columns'>>;
6
+ export declare const pivotingStateInitializer: GridStateInitializer<Pick<DataGridPremiumProcessedProps, 'pivotActive' | 'pivotModel' | 'pivotPanelOpen' | 'initialState' | 'disablePivoting' | 'getPivotDerivedColumns' | 'columns'>, GridPrivateApiPremium>;
7
7
  export declare const useGridPivoting: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "pivotActive" | "onPivotActiveChange" | "pivotModel" | "onPivotModelChange" | "pivotPanelOpen" | "onPivotPanelOpenChange" | "disablePivoting" | "getPivotDerivedColumns" | "pivotingColDef" | "groupingColDef" | "aggregationFunctions">, originalColumnsProp: readonly GridColDef[], originalRowsProp: readonly GridRowModel[]) => void;
8
8
  export declare const useGridPivotingExportState: (apiRef: RefObject<GridPrivateApiPremium>) => void;
@@ -12,9 +12,12 @@ var _xDataGridPro = require("@mui/x-data-grid-pro");
12
12
  var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
13
13
  var _useOnMount = _interopRequireDefault(require("@mui/utils/useOnMount"));
14
14
  var _internals = require("@mui/x-data-grid-pro/internals");
15
+ var _pivotPanel = require("../../../components/pivotPanel");
15
16
  var _gridPivotingSelectors = require("./gridPivotingSelectors");
16
17
  var _utils = require("./utils");
17
18
  var _gridAggregationUtils = require("../aggregation/gridAggregationUtils");
19
+ var _sidebar = require("../sidebar");
20
+ var _jsxRuntime = require("react/jsx-runtime");
18
21
  const emptyPivotModel = {
19
22
  rows: [],
20
23
  columns: [],
@@ -33,19 +36,23 @@ const pivotingStateInitializer = (state, props, apiRef) => {
33
36
  return (0, _extends2.default)({}, state, {
34
37
  pivoting: {
35
38
  active: false,
36
- model: emptyPivotModel,
37
- panelOpen: false
39
+ model: emptyPivotModel
38
40
  }
39
41
  });
40
42
  }
41
43
  const initialColumns = (0, _utils.getInitialColumns)(props.columns ?? [], props.getPivotDerivedColumns, apiRef.current.getLocaleText);
44
+ const open = props.pivotPanelOpen ?? props.initialState?.pivoting?.panelOpen ?? false;
45
+ const sidebarStateUpdate = open ? {
46
+ open,
47
+ value: _sidebar.GridSidebarValue.Pivot
48
+ } : {};
42
49
  return (0, _extends2.default)({}, state, {
43
50
  pivoting: {
44
51
  active: props.pivotActive ?? props.initialState?.pivoting?.enabled ?? false,
45
52
  model: props.pivotModel ?? props.initialState?.pivoting?.model ?? emptyPivotModel,
46
- panelOpen: props.pivotPanelOpen ?? props.initialState?.pivoting?.panelOpen ?? false,
47
53
  initialColumns
48
- }
54
+ },
55
+ sidebar: (0, _extends2.default)({}, state.sidebar, sidebarStateUpdate)
49
56
  });
50
57
  };
51
58
  exports.pivotingStateInitializer = pivotingStateInitializer;
@@ -258,11 +265,16 @@ const useGridPivoting = (apiRef, props, originalColumnsProp, originalRowsProp) =
258
265
  if (!isPivotingAvailable) {
259
266
  return;
260
267
  }
261
- apiRef.current.setState(state => (0, _extends2.default)({}, state, {
262
- pivoting: (0, _extends2.default)({}, state.pivoting, {
263
- panelOpen: typeof callback === 'function' ? callback(state.pivoting?.panelOpen) : callback
264
- })
265
- }));
268
+ const panelOpen = (0, _gridPivotingSelectors.gridPivotPanelOpenSelector)(apiRef);
269
+ const newPanelOpen = typeof callback === 'function' ? callback(panelOpen) : callback;
270
+ if (panelOpen === newPanelOpen) {
271
+ return;
272
+ }
273
+ if (newPanelOpen) {
274
+ apiRef.current.showSidebar(_sidebar.GridSidebarValue.Pivot);
275
+ } else {
276
+ apiRef.current.hideSidebar();
277
+ }
266
278
  }, [apiRef, isPivotingAvailable]);
267
279
  const addColumnMenuButton = React.useCallback(menuItems => {
268
280
  if (isPivotingAvailable) {
@@ -318,6 +330,13 @@ const useGridPivoting = (apiRef, props, originalColumnsProp, originalRowsProp) =
318
330
  });
319
331
  });
320
332
  }, [apiRef, computePivotingState, isPivotingAvailable, nonPivotDataRef]);
333
+ const addPivotingPanel = React.useCallback((initialValue, value) => {
334
+ if (isPivotingAvailable && value === _sidebar.GridSidebarValue.Pivot) {
335
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_pivotPanel.GridPivotPanel, {});
336
+ }
337
+ return initialValue;
338
+ }, [isPivotingAvailable]);
339
+ (0, _internals.useGridRegisterPipeProcessor)(apiRef, 'sidebar', addPivotingPanel);
321
340
  (0, _internals.useGridApiMethod)(apiRef, {
322
341
  setPivotModel,
323
342
  setPivotActive,
@@ -67,7 +67,7 @@ function sortColumnGroups(columnGroups, pivotModelColumns, depth = 0) {
67
67
  if (sort === undefined) {
68
68
  return 0;
69
69
  }
70
- return (sort === 'asc' ? 1 : -1) * (0, _xDataGridPro.gridStringOrNumberComparator)(a.headerName, b.headerName, {}, {});
70
+ return (sort === 'asc' ? 1 : -1) * (0, _xDataGridPro.gridStringOrNumberComparator)(a.rawHeaderName, b.rawHeaderName, {}, {});
71
71
  });
72
72
  }
73
73
  const getPivotedData = ({
@@ -151,21 +151,23 @@ const getPivotedData = ({
151
151
  continue;
152
152
  }
153
153
  let colValue = apiRef.current.getRowValue(row, column) ?? '(No value)';
154
- if (column.type !== 'number') {
155
- colValue = String(colValue);
156
- }
157
154
  if (column.type === 'singleSelect') {
158
155
  const singleSelectColumn = column;
159
156
  if (singleSelectColumn.getOptionLabel) {
160
157
  colValue = singleSelectColumn.getOptionLabel(colValue);
161
158
  }
162
159
  }
160
+ if (column.type !== 'number') {
161
+ colValue = String(colValue);
162
+ }
163
+ const formattedHeaderName = apiRef.current.getRowFormattedValue(row, column) || colValue;
163
164
  columnGroupPath.push(colValue);
164
165
  const groupId = columnGroupPath.join(columnGroupIdSeparator);
165
166
  if (!columnGroupingModelLookup.has(groupId)) {
166
167
  const columnGroup = {
167
168
  groupId,
168
- headerName: colValue,
169
+ headerName: formattedHeaderName,
170
+ rawHeaderName: colValue,
169
171
  children: []
170
172
  };
171
173
  columnGroupingModelLookup.set(groupId, columnGroup);
@@ -1,8 +1,7 @@
1
1
  import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridColDef, GridGroupingColDefOverride } from '@mui/x-data-grid-pro';
3
- import { GridColumnRawLookup } from '@mui/x-data-grid-pro/internals';
3
+ import { GridColumnRawLookup, RowGroupingStrategy } from '@mui/x-data-grid-pro/internals';
4
4
  import { GridApiPremium } from "../../../models/gridApiPremium.js";
5
- import { RowGroupingStrategy } from "./gridRowGroupingUtils.js";
6
5
  interface CreateGroupingColDefMonoCriteriaParams {
7
6
  columnsLookup: GridColumnRawLookup;
8
7
  /**