@mui/x-data-grid-premium 8.9.1 → 8.9.2

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 (94) hide show
  1. package/CHANGELOG.md +96 -2
  2. package/DataGridPremium/DataGridPremium.js +27 -10
  3. package/DataGridPremium/useDataGridPremiumComponent.js +4 -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 +5 -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/rowGrouping/createGroupingColDef.d.ts +1 -2
  31. package/esm/hooks/features/rowGrouping/createGroupingColDef.js +10 -3
  32. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +1 -5
  33. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +1 -6
  34. package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +2 -2
  35. package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +2 -2
  36. package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +2 -2
  37. package/esm/hooks/features/rows/useGridRowAriaAttributes.d.ts +1 -1
  38. package/esm/hooks/features/rows/useGridRowAriaAttributes.js +2 -2
  39. package/esm/hooks/features/sidebar/gridSidebarInterfaces.d.ts +16 -0
  40. package/esm/hooks/features/sidebar/gridSidebarInterfaces.js +4 -0
  41. package/esm/hooks/features/sidebar/gridSidebarSelector.d.ts +12 -0
  42. package/esm/hooks/features/sidebar/gridSidebarSelector.js +12 -0
  43. package/esm/hooks/features/sidebar/gridSidebarState.d.ts +8 -0
  44. package/esm/hooks/features/sidebar/gridSidebarState.js +1 -0
  45. package/esm/hooks/features/sidebar/index.d.ts +3 -0
  46. package/esm/hooks/features/sidebar/index.js +3 -0
  47. package/esm/hooks/features/sidebar/useGridSidebar.d.ts +6 -0
  48. package/esm/hooks/features/sidebar/useGridSidebar.js +72 -0
  49. package/esm/hooks/utils/useGridAriaAttributes.d.ts +1 -1
  50. package/esm/hooks/utils/useGridAriaAttributes.js +2 -2
  51. package/esm/index.js +1 -1
  52. package/esm/models/dataGridPremiumProps.d.ts +16 -0
  53. package/esm/models/gridApiPremium.d.ts +2 -1
  54. package/esm/models/gridStatePremium.d.ts +3 -0
  55. package/esm/typeOverloads/modules.d.ts +28 -1
  56. package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +1 -1
  57. package/hooks/features/aiAssistant/api.d.ts +3 -3
  58. package/hooks/features/aiAssistant/api.js +8 -4
  59. package/hooks/features/aiAssistant/gridAiAssistantInterfaces.d.ts +11 -0
  60. package/hooks/features/export/serializer/excelSerializer.js +1 -6
  61. package/hooks/features/index.d.ts +2 -1
  62. package/hooks/features/index.js +11 -0
  63. package/hooks/features/pivoting/gridPivotingInterfaces.d.ts +5 -0
  64. package/hooks/features/pivoting/gridPivotingSelectors.d.ts +4 -1
  65. package/hooks/features/pivoting/gridPivotingSelectors.js +3 -8
  66. package/hooks/features/pivoting/useGridPivoting.d.ts +1 -1
  67. package/hooks/features/pivoting/useGridPivoting.js +28 -9
  68. package/hooks/features/rowGrouping/createGroupingColDef.d.ts +1 -2
  69. package/hooks/features/rowGrouping/createGroupingColDef.js +13 -6
  70. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +1 -5
  71. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +3 -8
  72. package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +6 -6
  73. package/hooks/features/rowGrouping/useGridRowGrouping.js +1 -1
  74. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +7 -7
  75. package/hooks/features/rows/useGridRowAriaAttributes.d.ts +1 -1
  76. package/hooks/features/rows/useGridRowAriaAttributes.js +4 -4
  77. package/hooks/features/sidebar/gridSidebarInterfaces.d.ts +16 -0
  78. package/hooks/features/sidebar/gridSidebarInterfaces.js +10 -0
  79. package/hooks/features/sidebar/gridSidebarSelector.d.ts +12 -0
  80. package/hooks/features/sidebar/gridSidebarSelector.js +18 -0
  81. package/hooks/features/sidebar/gridSidebarState.d.ts +8 -0
  82. package/hooks/features/sidebar/gridSidebarState.js +5 -0
  83. package/hooks/features/sidebar/index.d.ts +3 -0
  84. package/hooks/features/sidebar/index.js +38 -0
  85. package/hooks/features/sidebar/useGridSidebar.d.ts +6 -0
  86. package/hooks/features/sidebar/useGridSidebar.js +82 -0
  87. package/hooks/utils/useGridAriaAttributes.d.ts +1 -1
  88. package/hooks/utils/useGridAriaAttributes.js +4 -4
  89. package/index.js +1 -1
  90. package/models/dataGridPremiumProps.d.ts +16 -0
  91. package/models/gridApiPremium.d.ts +2 -1
  92. package/models/gridStatePremium.d.ts +3 -0
  93. package/package.json +7 -8
  94. package/typeOverloads/modules.d.ts +28 -1
@@ -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>;
@@ -5,10 +5,14 @@
5
5
  * @param {string} context The prompt context containing necessary information about the current columns definition.
6
6
  * Either use the `context` parameter of the `onPrompt` callback or the return value of the `unstable_getPromptContext()` API method.
7
7
  * @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.
8
- * @param {string} additionalContext Optional, additional context to make the processing results more accurate.
8
+ * @param {string | PromptResolverOptions} optionsOrAdditionalContext Optional, includes settings to extend and customize the prompt resolver's behaviour, or additional context string for backward compatibility.
9
9
  * @returns {Promise<PromptResponse>} The grid state updates to be applied.
10
10
  */
11
- export function gridDefaultPromptResolver(url, query, context, conversationId, additionalContext = '') {
11
+ export function gridDefaultPromptResolver(url, query, context, conversationId, optionsOrAdditionalContext = '') {
12
+ // Handle backward compatibility: if string is passed, treat it as additionalContext
13
+ const options = typeof optionsOrAdditionalContext === 'string' ? {
14
+ additionalContext: optionsOrAdditionalContext
15
+ } : optionsOrAdditionalContext;
12
16
  return fetch(url, {
13
17
  mode: 'cors',
14
18
  method: 'POST',
@@ -19,8 +23,8 @@ export function gridDefaultPromptResolver(url, query, context, conversationId, a
19
23
  body: JSON.stringify({
20
24
  context,
21
25
  query,
22
- additionalContext,
23
- conversationId
26
+ conversationId,
27
+ options
24
28
  })
25
29
  }).then(result => result.json()).then(result => {
26
30
  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
  */
@@ -47,12 +47,7 @@ export const serializeRowUnsafe = (id, columns, apiRef, defaultValueOptionsFormu
47
47
  const hasColSpan = gridHasColSpanSelector(apiRef);
48
48
  if (hasColSpan) {
49
49
  // `colSpan` is only calculated for rendered rows, so we need to calculate it during export for every row
50
- apiRef.current.calculateColSpan({
51
- rowId: id,
52
- minFirstColumn: 0,
53
- maxLastColumn: columns.length,
54
- columns
55
- });
50
+ apiRef.current.calculateColSpan(id, 0, columns.length, columns);
56
51
  }
57
52
  columns.forEach((column, colIndex) => {
58
53
  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";
@@ -3,4 +3,5 @@ export * from "./aggregation/index.js";
3
3
  export * from "./rowGrouping/index.js";
4
4
  export * from "./export/index.js";
5
5
  export * from "./cellSelection/index.js";
6
- export * from "./aiAssistant/index.js";
6
+ export * from "./aiAssistant/index.js";
7
+ export * from "./sidebar/index.js";
@@ -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';
@@ -1,5 +1,7 @@
1
1
  import { createSelector, createRootSelector } from '@mui/x-data-grid-pro/internals';
2
+ import { gridSidebarStateSelector, GridSidebarValue } from "../sidebar/index.js";
2
3
  const gridPivotingStateSelector = createRootSelector(state => state.pivoting);
4
+ export const gridPivotPanelOpenSelector = createSelector(gridSidebarStateSelector, sidebar => sidebar.value === GridSidebarValue.Pivot && sidebar.open);
3
5
  export const gridPivotModelSelector = createSelector(gridPivotingStateSelector, pivoting => pivoting?.model);
4
6
  export const gridPivotPropsOverridesSelector = createSelector(gridPivotingStateSelector, pivoting => pivoting?.active ? pivoting.propsOverrides : undefined);
5
- export { gridPivotActiveSelector, gridPivotInitialColumnsSelector, gridPivotPanelOpenSelector } from '@mui/x-data-grid/internals';
7
+ export { gridPivotActiveSelector, gridPivotInitialColumnsSelector } from '@mui/x-data-grid/internals';
@@ -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;
@@ -4,9 +4,12 @@ import { gridDataRowIdsSelector, gridRowIdSelector, gridRowsLoadingSelector, gri
4
4
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
5
  import useOnMount from '@mui/utils/useOnMount';
6
6
  import { useGridApiMethod, useGridRegisterPipeProcessor, useGridSelector, gridPivotInitialColumnsSelector } from '@mui/x-data-grid-pro/internals';
7
+ import { GridPivotPanel } from "../../../components/pivotPanel/index.js";
7
8
  import { gridPivotModelSelector, gridPivotActiveSelector, gridPivotPanelOpenSelector } from "./gridPivotingSelectors.js";
8
9
  import { getInitialColumns, getPivotedData, isPivotingAvailable as isPivotingAvailableFn } from "./utils.js";
9
10
  import { getAvailableAggregationFunctions } from "../aggregation/gridAggregationUtils.js";
11
+ import { GridSidebarValue } from "../sidebar/index.js";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
10
13
  const emptyPivotModel = {
11
14
  rows: [],
12
15
  columns: [],
@@ -25,19 +28,23 @@ export const pivotingStateInitializer = (state, props, apiRef) => {
25
28
  return _extends({}, state, {
26
29
  pivoting: {
27
30
  active: false,
28
- model: emptyPivotModel,
29
- panelOpen: false
31
+ model: emptyPivotModel
30
32
  }
31
33
  });
32
34
  }
33
35
  const initialColumns = getInitialColumns(props.columns ?? [], props.getPivotDerivedColumns, apiRef.current.getLocaleText);
36
+ const open = props.pivotPanelOpen ?? props.initialState?.pivoting?.panelOpen ?? false;
37
+ const sidebarStateUpdate = open ? {
38
+ open,
39
+ value: GridSidebarValue.Pivot
40
+ } : {};
34
41
  return _extends({}, state, {
35
42
  pivoting: {
36
43
  active: props.pivotActive ?? props.initialState?.pivoting?.enabled ?? false,
37
44
  model: props.pivotModel ?? props.initialState?.pivoting?.model ?? emptyPivotModel,
38
- panelOpen: props.pivotPanelOpen ?? props.initialState?.pivoting?.panelOpen ?? false,
39
45
  initialColumns
40
- }
46
+ },
47
+ sidebar: _extends({}, state.sidebar, sidebarStateUpdate)
41
48
  });
42
49
  };
43
50
  export const useGridPivoting = (apiRef, props, originalColumnsProp, originalRowsProp) => {
@@ -249,11 +256,16 @@ export const useGridPivoting = (apiRef, props, originalColumnsProp, originalRows
249
256
  if (!isPivotingAvailable) {
250
257
  return;
251
258
  }
252
- apiRef.current.setState(state => _extends({}, state, {
253
- pivoting: _extends({}, state.pivoting, {
254
- panelOpen: typeof callback === 'function' ? callback(state.pivoting?.panelOpen) : callback
255
- })
256
- }));
259
+ const panelOpen = gridPivotPanelOpenSelector(apiRef);
260
+ const newPanelOpen = typeof callback === 'function' ? callback(panelOpen) : callback;
261
+ if (panelOpen === newPanelOpen) {
262
+ return;
263
+ }
264
+ if (newPanelOpen) {
265
+ apiRef.current.showSidebar(GridSidebarValue.Pivot);
266
+ } else {
267
+ apiRef.current.hideSidebar();
268
+ }
257
269
  }, [apiRef, isPivotingAvailable]);
258
270
  const addColumnMenuButton = React.useCallback(menuItems => {
259
271
  if (isPivotingAvailable) {
@@ -309,6 +321,13 @@ export const useGridPivoting = (apiRef, props, originalColumnsProp, originalRows
309
321
  });
310
322
  });
311
323
  }, [apiRef, computePivotingState, isPivotingAvailable, nonPivotDataRef]);
324
+ const addPivotingPanel = React.useCallback((initialValue, value) => {
325
+ if (isPivotingAvailable && value === GridSidebarValue.Pivot) {
326
+ return /*#__PURE__*/_jsx(GridPivotPanel, {});
327
+ }
328
+ return initialValue;
329
+ }, [isPivotingAvailable]);
330
+ useGridRegisterPipeProcessor(apiRef, 'sidebar', addPivotingPanel);
312
331
  useGridApiMethod(apiRef, {
313
332
  setPivotModel,
314
333
  setPivotActive,
@@ -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
  /**
@@ -4,12 +4,12 @@ const _excluded = ["leafField", "mainGroupingCriteria", "hideDescendantCount"],
4
4
  _excluded2 = ["leafField", "mainGroupingCriteria", "hideDescendantCount"];
5
5
  import * as React from 'react';
6
6
  import { GRID_STRING_COL_DEF, gridRowIdSelector, gridRowNodeSelector } from '@mui/x-data-grid-pro';
7
- import { isSingleSelectColDef } from '@mui/x-data-grid-pro/internals';
7
+ import { isSingleSelectColDef, RowGroupingStrategy } from '@mui/x-data-grid-pro/internals';
8
8
  import { GridGroupingColumnFooterCell } from "../../../components/GridGroupingColumnFooterCell.js";
9
9
  import { GridGroupingCriteriaCell } from "../../../components/GridGroupingCriteriaCell.js";
10
10
  import { GridDataSourceGroupingCriteriaCell } from "../../../components/GridDataSourceGroupingCriteriaCell.js";
11
11
  import { GridGroupingColumnLeafCell } from "../../../components/GridGroupingColumnLeafCell.js";
12
- import { getRowGroupingFieldFromGroupingCriteria, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, RowGroupingStrategy } from "./gridRowGroupingUtils.js";
12
+ import { getRowGroupingFieldFromGroupingCriteria, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "./gridRowGroupingUtils.js";
13
13
  import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  const GROUPING_COL_DEF_DEFAULT_PROPERTIES = _extends({}, GRID_STRING_COL_DEF, {
@@ -65,7 +65,14 @@ const getLeafProperties = leafColDef => ({
65
65
  return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
66
66
  }
67
67
  });
68
- const groupedByColValueFormatter = groupedByColDef => (value, row, _, apiRef) => groupedByColDef.valueFormatter(value, row, groupedByColDef, apiRef);
68
+ const groupedByColValueFormatter = groupedByColDef => (value, row, _, apiRef) => {
69
+ const rowId = gridRowIdSelector(apiRef, row);
70
+ const rowNode = gridRowNodeSelector(apiRef, rowId);
71
+ if (rowNode.type === 'group' && rowNode.groupingField === groupedByColDef.field) {
72
+ return groupedByColDef.valueFormatter(value, row, groupedByColDef, apiRef);
73
+ }
74
+ return value;
75
+ };
69
76
  const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
70
77
  const properties = {
71
78
  sortable: groupedByColDef.sortable,
@@ -1,15 +1,11 @@
1
1
  import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridRowTreeConfig, GridFilterState, GridFilterModel, GridRowModel, GridColDef, GridKeyValue, GridDataSource } from '@mui/x-data-grid-pro';
3
- import { GridAggregatedFilterItemApplier, GridColumnRawLookup, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn } from '@mui/x-data-grid-pro/internals';
3
+ import { GridAggregatedFilterItemApplier, GridColumnRawLookup, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn, RowGroupingStrategy } from '@mui/x-data-grid-pro/internals';
4
4
  import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
5
5
  import { GridGroupingRule, GridGroupingRules, GridRowGroupingModel } from "./gridRowGroupingInterfaces.js";
6
6
  import { GridStatePremium } from "../../../models/gridStatePremium.js";
7
7
  import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
8
8
  export { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn };
9
- export declare enum RowGroupingStrategy {
10
- Default = "grouping-columns",
11
- DataSource = "grouping-columns-data-source",
12
- }
13
9
  export declare const getRowGroupingFieldFromGroupingCriteria: (groupingCriteria: string | null) => string;
14
10
  interface FilterRowTreeFromTreeDataParams {
15
11
  rowTree: GridRowTreeConfig;
@@ -1,12 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { passFilterLogic, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn, GridStrategyGroup, getRowValue } from '@mui/x-data-grid-pro/internals';
2
+ import { passFilterLogic, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn, GridStrategyGroup, getRowValue, RowGroupingStrategy } from '@mui/x-data-grid-pro/internals';
3
3
  import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
4
4
  export { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn };
5
- export let RowGroupingStrategy = /*#__PURE__*/function (RowGroupingStrategy) {
6
- RowGroupingStrategy["Default"] = "grouping-columns";
7
- RowGroupingStrategy["DataSource"] = "grouping-columns-data-source";
8
- return RowGroupingStrategy;
9
- }({});
10
5
  export const getRowGroupingFieldFromGroupingCriteria = groupingCriteria => {
11
6
  if (groupingCriteria === null) {
12
7
  return GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { gridRowTreeSelector, gridColumnLookupSelector } from '@mui/x-data-grid-pro';
3
- import { useGridRegisterStrategyProcessor, createRowTree, updateRowTree, getVisibleRowsLookup, skipSorting, skipFiltering, getParentPath } from '@mui/x-data-grid-pro/internals';
4
- import { getGroupingRules, RowGroupingStrategy } from "./gridRowGroupingUtils.js";
3
+ import { useGridRegisterStrategyProcessor, createRowTree, updateRowTree, getVisibleRowsLookup, skipSorting, skipFiltering, getParentPath, RowGroupingStrategy } from '@mui/x-data-grid-pro/internals';
4
+ import { getGroupingRules } from "./gridRowGroupingUtils.js";
5
5
  import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
6
6
  export const useGridDataSourceRowGroupingPreProcessors = (apiRef, props) => {
7
7
  const createRowTreeForRowGrouping = React.useCallback(params => {
@@ -3,9 +3,9 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import { useGridEvent, useGridApiMethod, gridColumnLookupSelector } from '@mui/x-data-grid-pro';
6
- import { useGridRegisterPipeProcessor, GridStrategyGroup } from '@mui/x-data-grid-pro/internals';
6
+ import { useGridRegisterPipeProcessor, GridStrategyGroup, RowGroupingStrategy } from '@mui/x-data-grid-pro/internals';
7
7
  import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
8
- import { getRowGroupingFieldFromGroupingCriteria, RowGroupingStrategy, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability, getGroupingRules, areGroupingRulesEqual } from "./gridRowGroupingUtils.js";
8
+ import { getRowGroupingFieldFromGroupingCriteria, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability, getGroupingRules, areGroupingRulesEqual } from "./gridRowGroupingUtils.js";
9
9
  export const rowGroupingStateInitializer = (state, props, apiRef) => {
10
10
  apiRef.current.caches.rowGrouping = {
11
11
  rulesOnLastRowTreeCreation: []
@@ -2,10 +2,10 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import { gridColumnLookupSelector, gridRowTreeSelector, useFirstRender } from '@mui/x-data-grid-pro';
5
- import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor, sortRowTree, createRowTree, updateRowTree, getVisibleRowsLookup } from '@mui/x-data-grid-pro/internals';
5
+ import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor, sortRowTree, createRowTree, updateRowTree, getVisibleRowsLookup, RowGroupingStrategy } from '@mui/x-data-grid-pro/internals';
6
6
  import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
7
7
  import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from "./createGroupingColDef.js";
8
- import { filterRowTreeFromGroupingColumns, getColDefOverrides, RowGroupingStrategy, isGroupingColumn, setStrategyAvailability, getCellGroupingCriteria, getGroupingRules } from "./gridRowGroupingUtils.js";
8
+ import { filterRowTreeFromGroupingColumns, getColDefOverrides, isGroupingColumn, setStrategyAvailability, getCellGroupingCriteria, getGroupingRules } from "./gridRowGroupingUtils.js";
9
9
  export const useGridRowGroupingPreProcessors = (apiRef, props) => {
10
10
  const getGroupingColDefs = React.useCallback(columnsState => {
11
11
  if (props.disableRowGrouping) {
@@ -1 +1 @@
1
- export declare const useGridRowAriaAttributes: () => (rowNode: import("@mui/x-data-grid").GridTreeNode, index: number) => React.HTMLAttributes<HTMLElement>;
1
+ export declare const useGridRowAriaAttributesPremium: () => (rowNode: import("@mui/x-data-grid").GridTreeNode, index: number) => React.HTMLAttributes<HTMLElement>;
@@ -1,7 +1,7 @@
1
- import { useGridRowAriaAttributes as useGridRowAriaAttributesPro, useGridSelector } from '@mui/x-data-grid-pro/internals';
1
+ import { useGridRowAriaAttributesPro, useGridSelector } from '@mui/x-data-grid-pro/internals';
2
2
  import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
3
3
  import { gridRowGroupingSanitizedModelSelector } from "../rowGrouping/gridRowGroupingSelector.js";
4
- export const useGridRowAriaAttributes = () => {
4
+ export const useGridRowAriaAttributesPremium = () => {
5
5
  const apiRef = useGridPrivateApiContext();
6
6
  const gridRowGroupingModel = useGridSelector(apiRef, gridRowGroupingSanitizedModelSelector);
7
7
  return useGridRowAriaAttributesPro(gridRowGroupingModel.length > 0);
@@ -0,0 +1,16 @@
1
+ export declare enum GridSidebarValue {
2
+ Pivot = "pivot",
3
+ }
4
+ export interface GridSidebarApi {
5
+ /**
6
+ * Displays the sidebar. The `newValue` argument controls the content of the sidebar.
7
+ * @param {GridSidebarValue} newValue The sidebar to open.
8
+ * @param {string} sidebarId The unique sidebar id
9
+ * @param {string} labelId The unique button id
10
+ */
11
+ showSidebar: (newValue: GridSidebarValue, sidebarId?: string, labelId?: string) => void;
12
+ /**
13
+ * Hides the sidebar.
14
+ */
15
+ hideSidebar: () => void;
16
+ }
@@ -0,0 +1,4 @@
1
+ export let GridSidebarValue = /*#__PURE__*/function (GridSidebarValue) {
2
+ GridSidebarValue["Pivot"] = "pivot";
3
+ return GridSidebarValue;
4
+ }({});
@@ -0,0 +1,12 @@
1
+ import { GridStatePremium } from "../../../models/gridStatePremium.js";
2
+ export declare const gridSidebarStateSelector: import("@mui/x-data-grid").OutputSelector<GridStatePremium, unknown, import("./gridSidebarState.js").GridSidebarState>;
3
+ export declare const gridSidebarOpenSelector: (args_0: import("react").RefObject<{
4
+ state: GridStatePremium;
5
+ } | null>) => boolean;
6
+ export declare const gridSidebarContentSelector: (args_0: import("react").RefObject<{
7
+ state: GridStatePremium;
8
+ } | null>) => {
9
+ sidebarId: string | undefined;
10
+ labelId: string | undefined;
11
+ value: import("./gridSidebarInterfaces.js").GridSidebarValue | undefined;
12
+ };
@@ -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.9.2
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
  }
@@ -8,9 +8,10 @@ import type { GridDataSourcePremiumPrivateApi, GridDataSourceApiPremium } from "
8
8
  import type { GridAggregationPrivateApi } from "../hooks/features/aggregation/gridAggregationInterfaces.js";
9
9
  import type { GridPivotingApi, GridPivotingPrivateApi } from "../hooks/features/pivoting/gridPivotingInterfaces.js";
10
10
  import { GridAiAssistantApi } from "../hooks/features/aiAssistant/gridAiAssistantInterfaces.js";
11
+ import { GridSidebarApi } from "../hooks/features/sidebar/gridSidebarInterfaces.js";
11
12
  /**
12
13
  * The api of Data Grid Premium.
13
14
  * TODO: Do not redefine manually the pro features
14
15
  */
15
- export interface GridApiPremium extends GridApiCommon<GridStatePremium, GridInitialStatePremium>, GridRowProApi, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi, GridAggregationApi, GridRowPinningApi, GridDataSourceApiPremium, GridCellSelectionApi, GridPivotingApi, GridAiAssistantApi, GridRowMultiSelectionApi, GridColumnReorderApi {}
16
+ export interface GridApiPremium extends GridApiCommon<GridStatePremium, GridInitialStatePremium>, GridRowProApi, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi, GridAggregationApi, GridRowPinningApi, GridDataSourceApiPremium, GridCellSelectionApi, GridPivotingApi, GridAiAssistantApi, GridSidebarApi, GridRowMultiSelectionApi, GridColumnReorderApi {}
16
17
  export interface GridPrivateApiPremium extends GridApiPremium, GridPrivateOnlyApiCommon<GridApiPremium, GridPrivateApiPremium, DataGridPremiumProcessedProps>, GridDataSourcePremiumPrivateApi, GridAggregationPrivateApi, GridDetailPanelPrivateApi, 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
  }