@mui/x-charts-pro 8.5.3 → 8.7.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 (124) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/ChartContainerPro/index.d.ts +7 -1
  3. package/ChartContainerPro/index.js +0 -11
  4. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  5. package/ChartZoomSlider/index.d.ts +2 -1
  6. package/ChartZoomSlider/index.js +10 -2
  7. package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +4 -0
  8. package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +7 -1
  9. package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +9 -1
  10. package/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.d.ts +15 -0
  11. package/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.js +31 -0
  12. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
  13. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +77 -0
  14. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
  15. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +75 -0
  16. package/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
  17. package/ChartsToolbarPro/ChartsToolbarPro.js +118 -8
  18. package/ChartsToolbarPro/index.d.ts +3 -1
  19. package/ChartsToolbarPro/index.js +22 -0
  20. package/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
  21. package/ChartsToolbarPro/internals/ChartsMenu.js +73 -0
  22. package/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
  23. package/ChartsToolbarPro/internals/ChartsToolbarDivider.js +47 -0
  24. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +43 -33
  25. package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
  26. package/{ChartContainerPro → context}/ChartProApi.d.ts +2 -3
  27. package/context/index.d.ts +2 -1
  28. package/context/index.js +4 -4
  29. package/context/useChartProApiContext.d.ts +9 -0
  30. package/context/{useChartApiContext.js → useChartProApiContext.js} +4 -4
  31. package/esm/ChartContainerPro/index.d.ts +7 -1
  32. package/esm/ChartContainerPro/index.js +4 -1
  33. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  34. package/esm/ChartZoomSlider/index.d.ts +2 -1
  35. package/esm/ChartZoomSlider/index.js +2 -1
  36. package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +4 -0
  37. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +8 -1
  38. package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +10 -1
  39. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.d.ts +15 -0
  40. package/esm/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.js +21 -0
  41. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
  42. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +70 -0
  43. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
  44. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +68 -0
  45. package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
  46. package/esm/ChartsToolbarPro/ChartsToolbarPro.js +120 -8
  47. package/esm/ChartsToolbarPro/index.d.ts +3 -1
  48. package/esm/ChartsToolbarPro/index.js +3 -1
  49. package/esm/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
  50. package/esm/ChartsToolbarPro/internals/ChartsMenu.js +67 -0
  51. package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
  52. package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.js +40 -0
  53. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxis.js +43 -33
  54. package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +3 -3
  55. package/esm/{ChartContainerPro → context}/ChartProApi.d.ts +2 -3
  56. package/esm/context/index.d.ts +2 -1
  57. package/esm/context/index.js +2 -1
  58. package/esm/context/useChartProApiContext.d.ts +9 -0
  59. package/esm/context/{useChartApiContext.js → useChartProApiContext.js} +3 -3
  60. package/esm/hooks/index.d.ts +2 -1
  61. package/esm/hooks/index.js +2 -1
  62. package/esm/hooks/useChartProApiRef.d.ts +23 -0
  63. package/esm/hooks/useChartProApiRef.js +20 -0
  64. package/esm/index.d.ts +6 -3
  65. package/esm/index.js +3 -3
  66. package/esm/internals/material/components/BaseMenuItem.d.ts +3 -0
  67. package/esm/internals/material/components/BaseMenuItem.js +27 -0
  68. package/esm/internals/material/components/BasePopper.d.ts +3 -0
  69. package/esm/internals/material/components/BasePopper.js +122 -0
  70. package/esm/internals/material/icons.d.ts +2 -1
  71. package/esm/internals/material/icons.js +4 -1
  72. package/esm/internals/material/index.d.ts +1 -0
  73. package/esm/internals/material/index.js +12 -3
  74. package/esm/internals/plugins/allPlugins.d.ts +2 -2
  75. package/esm/internals/plugins/useChartProExport/print.js +1 -1
  76. package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
  77. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +8 -0
  78. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +58 -0
  79. package/esm/internals/plugins/useChartProZoom/{useChartProZoom.utils.d.ts → gestureHooks/useZoom.utils.d.ts} +14 -10
  80. package/esm/internals/plugins/useChartProZoom/{useChartProZoom.utils.js → gestureHooks/useZoom.utils.js} +41 -31
  81. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +8 -0
  82. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +59 -0
  83. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +8 -0
  84. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +79 -0
  85. package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +15 -227
  86. package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +4 -4
  87. package/esm/internals/slots/chartBaseSlotProps.d.ts +50 -3
  88. package/esm/internals/slots/chartsBaseSlots.d.ts +5 -1
  89. package/esm/internals/slots/chartsIconSlots.d.ts +5 -0
  90. package/hooks/index.d.ts +2 -1
  91. package/hooks/index.js +11 -0
  92. package/hooks/useChartProApiRef.d.ts +23 -0
  93. package/hooks/useChartProApiRef.js +28 -0
  94. package/index.d.ts +6 -3
  95. package/index.js +58 -22
  96. package/internals/material/components/BaseMenuItem.d.ts +3 -0
  97. package/internals/material/components/BaseMenuItem.js +35 -0
  98. package/internals/material/components/BasePopper.d.ts +3 -0
  99. package/internals/material/components/BasePopper.js +130 -0
  100. package/internals/material/icons.d.ts +2 -1
  101. package/internals/material/icons.js +5 -2
  102. package/internals/material/index.d.ts +1 -0
  103. package/internals/material/index.js +11 -2
  104. package/internals/plugins/allPlugins.d.ts +2 -2
  105. package/internals/plugins/useChartProExport/print.js +1 -1
  106. package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
  107. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +8 -0
  108. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +65 -0
  109. package/internals/plugins/useChartProZoom/{useChartProZoom.utils.d.ts → gestureHooks/useZoom.utils.d.ts} +14 -10
  110. package/internals/plugins/useChartProZoom/{useChartProZoom.utils.js → gestureHooks/useZoom.utils.js} +43 -34
  111. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +8 -0
  112. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +66 -0
  113. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +8 -0
  114. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +86 -0
  115. package/internals/plugins/useChartProZoom/useChartProZoom.js +14 -226
  116. package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +4 -4
  117. package/internals/slots/chartBaseSlotProps.d.ts +50 -3
  118. package/internals/slots/chartsBaseSlots.d.ts +5 -1
  119. package/internals/slots/chartsIconSlots.d.ts +5 -0
  120. package/package.json +5 -4
  121. package/context/useChartApiContext.d.ts +0 -9
  122. package/esm/context/useChartApiContext.d.ts +0 -9
  123. /package/{ChartContainerPro → context}/ChartProApi.js +0 -0
  124. /package/esm/{ChartContainerPro → context}/ChartProApi.js +0 -0
@@ -45,39 +45,51 @@ export const useChartFunnelAxis = ({
45
45
  }, [seriesConfig, drawingArea, xAxis, yAxis, dataset, store, gap]);
46
46
  React.useEffect(() => {
47
47
  const element = svgRef.current;
48
- if (!isInteractionEnabled || element === null || params.disableAxisListener) {
48
+ if (!isInteractionEnabled || !element || params.disableAxisListener) {
49
49
  return () => {};
50
50
  }
51
- const handleOut = () => {
52
- instance.cleanInteraction?.();
53
- };
54
- const handleMove = event => {
55
- const target = 'targetTouches' in event ? event.targetTouches[0] : event;
56
- const svgPoint = getSVGPoint(element, target);
57
- if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.target)) {
51
+
52
+ // Clean the interaction when the mouse leaves the chart.
53
+ const moveEndHandler = instance.addInteractionListener('moveEnd', event => {
54
+ if (!event.detail.activeGestures.pan) {
58
55
  instance.cleanInteraction?.();
59
- return;
60
56
  }
61
- instance.setPointerCoordinate?.(svgPoint);
62
- };
63
- const handleDown = event => {
64
- const target = event.currentTarget;
65
- if (!target) {
66
- return;
57
+ });
58
+ const panEndHandler = instance.addInteractionListener('panEnd', event => {
59
+ if (!event.detail.activeGestures.move) {
60
+ instance.cleanInteraction?.();
67
61
  }
68
- if ('hasPointerCapture' in target && target.hasPointerCapture(event.pointerId)) {
69
- target.releasePointerCapture(event.pointerId);
62
+ });
63
+ const pressEndHandler = instance.addInteractionListener('quickPressEnd', event => {
64
+ if (!event.detail.activeGestures.move && !event.detail.activeGestures.pan) {
65
+ instance.cleanInteraction?.();
66
+ }
67
+ });
68
+ const gestureHandler = event => {
69
+ const srvEvent = event.detail.srcEvent;
70
+ const target = event.detail.target;
71
+ const svgPoint = getSVGPoint(element, srvEvent);
72
+ // Release the pointer capture if we are panning, as this would cause the tooltip to
73
+ // be locked to the first "section" it touches.
74
+ if (event.detail.srcEvent.buttons >= 1 && target?.hasPointerCapture(event.detail.srcEvent.pointerId)) {
75
+ target?.releasePointerCapture(event.detail.srcEvent.pointerId);
70
76
  }
77
+ if (!instance.isPointInside(svgPoint.x, svgPoint.y, target)) {
78
+ instance.cleanInteraction?.();
79
+ return;
80
+ }
81
+ instance.setPointerCoordinate?.(svgPoint);
71
82
  };
72
- element.addEventListener('pointerdown', handleDown);
73
- element.addEventListener('pointermove', handleMove);
74
- element.addEventListener('pointercancel', handleOut);
75
- element.addEventListener('pointerleave', handleOut);
83
+ const moveHandler = instance.addInteractionListener('move', gestureHandler);
84
+ const panHandler = instance.addInteractionListener('pan', gestureHandler);
85
+ const pressHandler = instance.addInteractionListener('quickPress', gestureHandler);
76
86
  return () => {
77
- element.removeEventListener('pointerdown', handleDown);
78
- element.removeEventListener('pointermove', handleMove);
79
- element.removeEventListener('pointercancel', handleOut);
80
- element.removeEventListener('pointerleave', handleOut);
87
+ moveHandler.cleanup();
88
+ moveEndHandler.cleanup();
89
+ panHandler.cleanup();
90
+ panEndHandler.cleanup();
91
+ pressHandler.cleanup();
92
+ pressEndHandler.cleanup();
81
93
  };
82
94
  }, [svgRef, instance, params.disableAxisListener, isInteractionEnabled]);
83
95
  React.useEffect(() => {
@@ -86,8 +98,7 @@ export const useChartFunnelAxis = ({
86
98
  if (element === null || !onAxisClick) {
87
99
  return () => {};
88
100
  }
89
- const handleMouseClick = event => {
90
- event.preventDefault();
101
+ const axisClickHandler = instance.addInteractionListener('tap', event => {
91
102
  const {
92
103
  axis: xAxisWithScale,
93
104
  axisIds: xAxisIds
@@ -101,7 +112,7 @@ export const useChartFunnelAxis = ({
101
112
  const usedYAxis = yAxisIds[0];
102
113
  let dataIndex = null;
103
114
  let isXAxis = false;
104
- const svgPoint = getSVGPoint(element, event);
115
+ const svgPoint = getSVGPoint(element, event.detail.srcEvent);
105
116
  const xIndex = getCartesianAxisIndex(xAxisWithScale[usedXAxis], svgPoint.x);
106
117
  isXAxis = xIndex !== -1;
107
118
  dataIndex = isXAxis ? xIndex : getCartesianAxisIndex(yAxisWithScale[usedYAxis], svgPoint.y);
@@ -122,17 +133,16 @@ export const useChartFunnelAxis = ({
122
133
  seriesValues[seriesId] = seriesItem.data[dataIndex].value;
123
134
  }
124
135
  });
125
- onAxisClick(event, {
136
+ onAxisClick(event.detail.srcEvent, {
126
137
  dataIndex,
127
138
  axisValue,
128
139
  seriesValues
129
140
  });
130
- };
131
- element.addEventListener('click', handleMouseClick);
141
+ });
132
142
  return () => {
133
- element.removeEventListener('click', handleMouseClick);
143
+ axisClickHandler.cleanup();
134
144
  };
135
- }, [params.onAxisClick, svgRef, store]);
145
+ }, [params.onAxisClick, svgRef, store, instance]);
136
146
  return {};
137
147
  };
138
148
  useChartFunnelAxis.params = {
@@ -3,7 +3,7 @@ import { UseChartFunnelAxisSignature } from "./useChartFunnelAxis.types.js";
3
3
  export declare const selectorFunnel: (state: ChartState<[], [UseChartFunnelAxisSignature]>) => {
4
4
  gap: number;
5
5
  } | undefined;
6
- export declare const selectorFunnelGap: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & Partial<Pick<import("@mui/x-charts/internals").UseChartCartesianAxisState, "cartesianAxis"> & {
6
+ export declare const selectorFunnelGap: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<Pick<import("@mui/x-charts/internals").UseChartCartesianAxisState, "cartesianAxis"> & {
7
7
  funnel: {
8
8
  gap: number;
9
9
  };
@@ -12,7 +12,7 @@ export declare const selectorFunnelGap: import("reselect").Selector<import("@mui
12
12
  } & {
13
13
  cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
14
14
  }, number, []>;
15
- export declare const selectorChartXAxis: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & Partial<import("@mui/x-charts/internals").UseChartCartesianAxisState> & {
15
+ export declare const selectorChartXAxis: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<import("@mui/x-charts/internals").UseChartCartesianAxisState> & {
16
16
  cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
17
17
  } & Partial<{}> & {
18
18
  cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
@@ -33,7 +33,7 @@ export declare const selectorChartXAxis: import("reselect").Selector<import("@mu
33
33
  }> & {
34
34
  cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
35
35
  }, import("./computeAxisValue.js").ComputeResult<import("@mui/x-charts").ChartsXAxisProps>, []>;
36
- export declare const selectorChartYAxis: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & Partial<import("@mui/x-charts/internals").UseChartCartesianAxisState> & {
36
+ export declare const selectorChartYAxis: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<import("@mui/x-charts/internals").UseChartCartesianAxisState> & {
37
37
  cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
38
38
  } & Partial<{}> & {
39
39
  cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
@@ -7,7 +7,7 @@ import { AllPluginSignatures, DefaultPluginSignatures } from "../internals/plugi
7
7
  import { FunnelChartPluginsSignatures } from "../FunnelChart/FunnelChart.plugins.js";
8
8
  import { RadarChartProPluginsSignatures } from "../RadarChartPro/RadarChartPro.plugins.js";
9
9
  import { PieChartProPluginSignatures } from "../PieChartPro/PieChartPro.plugins.js";
10
- type PluginsPerSeriesType = {
10
+ export type ProPluginsPerSeriesType = {
11
11
  heatmap: HeatmapPluginsSignatures;
12
12
  line: LineChartProPluginsSignatures;
13
13
  scatter: ScatterChartProPluginsSignatures;
@@ -24,5 +24,4 @@ type PluginsPerSeriesType = {
24
24
  * If the chart is being created using composition, the `composition` value can be used.
25
25
  * @example ChartProApi<'composition'>
26
26
  */
27
- export type ChartProApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartPublicAPI<TSignatures>;
28
- export {};
27
+ export type ChartProApi<ChartType extends keyof ProPluginsPerSeriesType | undefined = undefined, Signatures extends readonly ChartAnyPluginSignature[] = (ChartType extends keyof ProPluginsPerSeriesType ? ProPluginsPerSeriesType[ChartType] : AllPluginSignatures)> = ChartPublicAPI<Signatures>;
@@ -1 +1,2 @@
1
- export * from "./useChartApiContext.js";
1
+ export * from "./useChartProApiContext.js";
2
+ export type { ChartProApi } from "./ChartProApi.js";
@@ -1 +1,2 @@
1
- export * from "./useChartApiContext.js";
1
+ export * from "./useChartProApiContext.js";
2
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ChartProApi } from "./ChartProApi.js";
2
+ /**
3
+ * The `useChartProApiContext` hook provides access to the chart API.
4
+ * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
5
+ * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
6
+ * @example
7
+ * const apiRef = useChartProApiContext<ChartProApi<'bar'>>();
8
+ */
9
+ export declare function useChartProApiContext<Api extends ChartProApi>(): import("react").RefObject<Api>;
@@ -1,11 +1,11 @@
1
1
  import { useChartApiContext as useChartApiContextCommunity } from '@mui/x-charts/context';
2
2
  /**
3
- * The `useChartApiContext` hook provides access to the chart API.
3
+ * The `useChartProApiContext` hook provides access to the chart API.
4
4
  * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
5
5
  * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
6
6
  * @example
7
- * const apiRef = useChartApiContext<ChartProApi<'bar'>>();
7
+ * const apiRef = useChartProApiContext<ChartProApi<'bar'>>();
8
8
  */
9
- export function useChartApiContext() {
9
+ export function useChartProApiContext() {
10
10
  return useChartApiContextCommunity();
11
11
  }
@@ -1,3 +1,4 @@
1
1
  export * from "./useHeatmapSeries.js";
2
2
  export * from "./useFunnelSeries.js";
3
- export * from "./zoom/index.js";
3
+ export * from "./zoom/index.js";
4
+ export * from "./useChartProApiRef.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./useHeatmapSeries.js";
2
2
  export * from "./useFunnelSeries.js";
3
- export * from "./zoom/index.js";
3
+ export * from "./zoom/index.js";
4
+ export * from "./useChartProApiRef.js";
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { ChartAnyPluginSignature } from '@mui/x-charts/internals';
3
+ import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
4
+ import { ProPluginsPerSeriesType, type ChartProApi } from "../context/ChartProApi.js";
5
+ /**
6
+ * Hook that instantiates a [[ChartProApiRef]].
7
+ * The chart type needs to be given as the generic parameter to narrow down the API to the specific chart type.
8
+ * @example
9
+ * ```tsx
10
+ * const barApiRef = useChartProApiRef<'bar'>();
11
+ * ```
12
+ * @example
13
+ * ```tsx
14
+ * // The API can be passed to the chart component and used to interact with the chart.
15
+ * <BarChart apiRef={barApiRef} />
16
+ * ```
17
+ * @example
18
+ * ```tsx
19
+ * // The API can be used to access chart methods and properties.
20
+ * barApiRef.current?.getSeries();
21
+ * ```
22
+ */
23
+ export declare const useChartProApiRef: <ChartType extends keyof ProPluginsPerSeriesType = never, Signatures extends readonly ChartAnyPluginSignature[] = (ChartType extends keyof ProPluginsPerSeriesType ? ProPluginsPerSeriesType[ChartType] : AllPluginSignatures)>() => React.RefObject<ChartProApi<ChartType, Signatures> | undefined>;
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Hook that instantiates a [[ChartProApiRef]].
4
+ * The chart type needs to be given as the generic parameter to narrow down the API to the specific chart type.
5
+ * @example
6
+ * ```tsx
7
+ * const barApiRef = useChartProApiRef<'bar'>();
8
+ * ```
9
+ * @example
10
+ * ```tsx
11
+ * // The API can be passed to the chart component and used to interact with the chart.
12
+ * <BarChart apiRef={barApiRef} />
13
+ * ```
14
+ * @example
15
+ * ```tsx
16
+ * // The API can be used to access chart methods and properties.
17
+ * barApiRef.current?.getSeries();
18
+ * ```
19
+ */
20
+ export const useChartProApiRef = () => React.useRef(undefined);
package/esm/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./typeOverloads/modules.js";
2
2
  export * from '@mui/x-charts/constants';
3
- export * from '@mui/x-charts/context';
3
+ export type { FadeOptions, HighlightItemData, HighlightOptions, HighlightScope } from '@mui/x-charts/context';
4
4
  export * from '@mui/x-charts/hooks';
5
5
  export * from '@mui/x-charts/colorPalettes';
6
6
  export * from '@mui/x-charts/models';
@@ -26,9 +26,11 @@ export * from '@mui/x-charts/ChartsSurface';
26
26
  export * from '@mui/x-charts/ChartDataProvider';
27
27
  export * from '@mui/x-charts/ChartsLabel';
28
28
  export type { ZoomData, ZoomFilterMode, ZoomSliderShowTooltip, ZoomOptions, ZoomSliderOptions } from '@mui/x-charts/internals';
29
+ export * from "./context/index.js";
29
30
  export * from "./hooks/index.js";
30
31
  export * from "./Heatmap/index.js";
31
- export * from "./ChartContainerPro/index.js";
32
+ export { ChartContainerPro } from "./ChartContainerPro/index.js";
33
+ export type { ChartContainerProProps } from "./ChartContainerPro/index.js";
32
34
  export * from "./ChartDataProviderPro/index.js";
33
35
  export * from "./ScatterChartPro/index.js";
34
36
  export * from "./BarChartPro/index.js";
@@ -37,4 +39,5 @@ export * from "./PieChartPro/index.js";
37
39
  export * from "./FunnelChart/index.js";
38
40
  export * from "./RadarChartPro/index.js";
39
41
  export * from "./ChartZoomSlider/index.js";
40
- export * from "./ChartsToolbarPro/index.js";
42
+ export * from "./ChartsToolbarPro/index.js";
43
+ export type { ChartImageExportOptions, ChartPrintExportOptions } from "./internals/plugins/useChartProExport/index.js";
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts-pro v8.5.3
2
+ * @mui/x-charts-pro v8.7.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -9,7 +9,6 @@ import "./typeOverloads/modules.js";
9
9
 
10
10
  // exports from MIT package
11
11
  export * from '@mui/x-charts/constants';
12
- export * from '@mui/x-charts/context';
13
12
  export * from '@mui/x-charts/hooks';
14
13
  export * from '@mui/x-charts/colorPalettes';
15
14
  export * from '@mui/x-charts/models';
@@ -35,9 +34,10 @@ export * from '@mui/x-charts/ChartsSurface';
35
34
  export * from '@mui/x-charts/ChartDataProvider';
36
35
  export * from '@mui/x-charts/ChartsLabel';
37
36
  // Pro components
37
+ export * from "./context/index.js";
38
38
  export * from "./hooks/index.js";
39
39
  export * from "./Heatmap/index.js";
40
- export * from "./ChartContainerPro/index.js";
40
+ export { ChartContainerPro } from "./ChartContainerPro/index.js";
41
41
  export * from "./ChartDataProviderPro/index.js";
42
42
  export * from "./ScatterChartPro/index.js";
43
43
  export * from "./BarChartPro/index.js";
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { ChartBaseMenuItemProps } from "../../slots/chartBaseSlotProps.js";
3
+ export declare function BaseMenuItem(props: ChartBaseMenuItemProps): React.JSX.Element;
@@ -0,0 +1,27 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["inert", "iconStart", "iconEnd", "children"];
4
+ import * as React from 'react';
5
+ import MenuItem from '@mui/material/MenuItem';
6
+ import ListItemIcon from '@mui/material/ListItemIcon';
7
+ import ListItemText from '@mui/material/ListItemText';
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ export function BaseMenuItem(props) {
10
+ const {
11
+ inert,
12
+ iconStart,
13
+ iconEnd,
14
+ children
15
+ } = props,
16
+ other = _objectWithoutPropertiesLoose(props, _excluded);
17
+ return /*#__PURE__*/_jsxs(MenuItem, _extends({}, other, {
18
+ disableRipple: inert ? true : other.disableRipple,
19
+ children: [iconStart && /*#__PURE__*/_jsx(ListItemIcon, {
20
+ children: iconStart
21
+ }, "1"), /*#__PURE__*/_jsx(ListItemText, {
22
+ children: children
23
+ }, "2"), iconEnd && /*#__PURE__*/_jsx(ListItemIcon, {
24
+ children: iconEnd
25
+ }, "3")]
26
+ }));
27
+ }
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { ChartBasePopperProps } from "../../slots/chartBaseSlotProps.js";
3
+ export declare function BasePopper(props: ChartBasePopperProps): React.JSX.Element;
@@ -0,0 +1,122 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["ref", "open", "children", "className", "clickAwayTouchEvent", "clickAwayMouseEvent", "flip", "focusTrap", "onExited", "onClickAway", "onDidShow", "onDidHide", "id", "target", "transition", "placement"];
4
+ import * as React from 'react';
5
+ import Popper from '@mui/material/Popper';
6
+ import MUIFocusTrap from '@mui/material/Unstable_TrapFocus';
7
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
8
+ import Grow from '@mui/material/Grow';
9
+ import Paper from '@mui/material/Paper';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ function clickAwayWrapper(props, content) {
12
+ if (props.onClickAway === undefined) {
13
+ return content;
14
+ }
15
+ return /*#__PURE__*/_jsx(ClickAwayListener, {
16
+ onClickAway: props.onClickAway,
17
+ touchEvent: props.clickAwayTouchEvent,
18
+ mouseEvent: props.clickAwayMouseEvent,
19
+ children: content
20
+ });
21
+ }
22
+ function focusTrapWrapper(props, content) {
23
+ if (props.focusTrap === undefined) {
24
+ return content;
25
+ }
26
+ return /*#__PURE__*/_jsx(MUIFocusTrap, {
27
+ open: true,
28
+ disableEnforceFocus: true,
29
+ disableAutoFocus: true,
30
+ children: /*#__PURE__*/_jsx("div", {
31
+ tabIndex: -1,
32
+ children: content
33
+ })
34
+ });
35
+ }
36
+ function wrappers(props, content) {
37
+ return focusTrapWrapper(props, clickAwayWrapper(props, content));
38
+ }
39
+ const transformOrigin = {
40
+ 'bottom-start': 'top left',
41
+ 'bottom-end': 'top right'
42
+ };
43
+ export function BasePopper(props) {
44
+ const {
45
+ open,
46
+ children,
47
+ className,
48
+ flip,
49
+ onExited,
50
+ onDidShow,
51
+ onDidHide,
52
+ id,
53
+ target,
54
+ transition,
55
+ placement
56
+ } = props,
57
+ rest = _objectWithoutPropertiesLoose(props, _excluded);
58
+ const modifiers = React.useMemo(() => {
59
+ const result = [{
60
+ name: 'preventOverflow',
61
+ options: {
62
+ padding: 8
63
+ }
64
+ }];
65
+ if (flip) {
66
+ result.push({
67
+ name: 'flip',
68
+ enabled: true,
69
+ options: {
70
+ rootBoundary: 'document'
71
+ }
72
+ });
73
+ }
74
+ if (onDidShow || onDidHide) {
75
+ result.push({
76
+ name: 'isPlaced',
77
+ enabled: true,
78
+ phase: 'main',
79
+ fn: () => {
80
+ onDidShow?.();
81
+ },
82
+ effect: () => () => {
83
+ onDidHide?.();
84
+ }
85
+ });
86
+ }
87
+ return result;
88
+ }, [flip, onDidShow, onDidHide]);
89
+ let content;
90
+ if (!transition) {
91
+ content = wrappers(props, children);
92
+ } else {
93
+ const handleExited = popperOnExited => node => {
94
+ if (popperOnExited) {
95
+ popperOnExited();
96
+ }
97
+ if (onExited) {
98
+ onExited(node);
99
+ }
100
+ };
101
+ content = p => wrappers(props, /*#__PURE__*/_jsx(Grow, _extends({}, p.TransitionProps, {
102
+ style: {
103
+ transformOrigin: transformOrigin[p.placement]
104
+ },
105
+ onExited: handleExited(p.TransitionProps?.onExited),
106
+ children: /*#__PURE__*/_jsx(Paper, {
107
+ children: children
108
+ })
109
+ })));
110
+ }
111
+ return /*#__PURE__*/_jsx(Popper, _extends({
112
+ id: id,
113
+ className: className,
114
+ open: open,
115
+ anchorEl: target,
116
+ transition: transition,
117
+ placement: placement,
118
+ modifiers: modifiers
119
+ }, rest, {
120
+ children: content
121
+ }));
122
+ }
@@ -1,3 +1,4 @@
1
1
  import * as React from 'react';
2
2
  export declare const ChartsZoomInIcon: (props: import("@mui/x-charts").ChartBaseIconProps) => React.ReactNode;
3
- export declare const ChartsZoomOutIcon: (props: import("@mui/x-charts").ChartBaseIconProps) => React.ReactNode;
3
+ export declare const ChartsZoomOutIcon: (props: import("@mui/x-charts").ChartBaseIconProps) => React.ReactNode;
4
+ export declare const ChartsExportIcon: (props: import("@mui/x-charts").ChartBaseIconProps) => React.ReactNode;
@@ -10,4 +10,7 @@ export const ChartsZoomInIcon = createSvgIcon(/*#__PURE__*/_jsxs(React.Fragment,
10
10
  }), 'ZoomIn');
11
11
  export const ChartsZoomOutIcon = createSvgIcon(/*#__PURE__*/_jsx("path", {
12
12
  d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14M7 9h5v1H7z"
13
- }), 'ZoomOut');
13
+ }), 'ZoomOut');
14
+ export const ChartsExportIcon = createSvgIcon(/*#__PURE__*/_jsx("path", {
15
+ d: "M19 9h-4V3H9v6H5l7 7zM5 18v2h14v-2z"
16
+ }), 'Export');
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { ChartsBaseSlotsPro } from "../slots/chartsBaseSlots.js";
2
3
  import { ChartsIconSlotsPro } from "../slots/chartsIconSlots.js";
3
4
  export type ChartsSlotsPro = ChartsBaseSlotsPro & ChartsIconSlotsPro;
@@ -1,12 +1,21 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import Tooltip from '@mui/material/Tooltip';
3
+ import MenuList from '@mui/material/MenuList';
4
+ import Divider from '@mui/material/Divider';
3
5
  import { defaultSlotsMaterial as communityDefaultSlotsMaterial } from '@mui/x-charts/internals';
4
- import { ChartsZoomInIcon, ChartsZoomOutIcon } from "./icons.js";
6
+ import { BaseMenuItem } from "./components/BaseMenuItem.js";
7
+ import { BasePopper } from "./components/BasePopper.js";
8
+ import { ChartsExportIcon, ChartsZoomInIcon, ChartsZoomOutIcon } from "./icons.js";
5
9
  const baseSlots = {
6
- baseTooltip: Tooltip
10
+ baseTooltip: Tooltip,
11
+ basePopper: BasePopper,
12
+ baseMenuList: MenuList,
13
+ baseMenuItem: BaseMenuItem,
14
+ baseDivider: Divider
7
15
  };
8
16
  const iconSlots = {
9
17
  zoomInIcon: ChartsZoomInIcon,
10
- zoomOutIcon: ChartsZoomOutIcon
18
+ zoomOutIcon: ChartsZoomOutIcon,
19
+ exportIcon: ChartsExportIcon
11
20
  };
12
21
  export const defaultSlotsMaterial = _extends({}, communityDefaultSlotsMaterial, baseSlots, iconSlots);
@@ -3,7 +3,7 @@ import { UseChartProExportSignature } from "./useChartProExport/index.js";
3
3
  import { UseChartProZoomSignature } from "./useChartProZoom/index.js";
4
4
  export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
5
  export type AllPluginsType<TSeries extends ChartSeriesType = ChartSeriesType> = ConvertSignaturesIntoPlugins<AllPluginSignatures<TSeries>>;
6
- export declare const ALL_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartPolarAxisSignature<any>>)[];
6
+ export declare const ALL_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartPolarAxisSignature<any>>)[];
7
7
  export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartProZoomSignature, UseChartProExportSignature];
8
8
  export type DefaultPluginsType<TSeries extends ChartSeriesType = ChartSeriesType> = ConvertSignaturesIntoPlugins<DefaultPluginSignatures<TSeries>>;
9
- export declare const DEFAULT_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>>)[];
9
+ export declare const DEFAULT_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature>)[];
@@ -15,7 +15,6 @@ export function printChart(element, {
15
15
  const rootCandidate = element.getRootNode();
16
16
  const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
17
17
  await Promise.all(loadStyleSheets(printDoc, root));
18
- printWindow.contentWindow.print();
19
18
  const mediaQueryList = printWindow.contentWindow.matchMedia('print');
20
19
  mediaQueryList.addEventListener('change', mql => {
21
20
  const isAfterPrint = mql.matches === false;
@@ -23,6 +22,7 @@ export function printChart(element, {
23
22
  doc.body.removeChild(printWindow);
24
23
  }
25
24
  });
25
+ printWindow.contentWindow.print();
26
26
  };
27
27
  doc.body.appendChild(printWindow);
28
28
  }
@@ -7,29 +7,30 @@ export interface UseChartProExportState {
7
7
  /**
8
8
  * The options to apply on the Print export.
9
9
  * @demos
10
- * - [Print export](/x/react-charts/export/#print-export-as-pdf)
10
+ * - [Print export](https://mui.com/x/react-charts/export/#print-export-as-pdf)
11
11
  */
12
12
  export interface ChartPrintExportOptions {
13
13
  /**
14
- * The value to be used as the print window title.
15
- * @default The title of the page.
14
+ * The name of the file without the extension.
15
+ * @default The title of the document the chart belongs to
16
16
  */
17
17
  fileName?: string;
18
18
  }
19
19
  /**
20
20
  * The options to apply on the image export.
21
21
  * @demos
22
- * - [Image export](/x/react-charts/export/#export-as-image)
22
+ * - [Image export](https://mui.com/x/react-charts/export/#export-as-image)
23
23
  */
24
24
  export interface ChartImageExportOptions {
25
25
  /**
26
- * The value to be used as the print window title.
27
- * @default The title of the page.
26
+ * The name of the file without the extension.
27
+ * @default The title of the document the chart belongs to
28
28
  */
29
29
  fileName?: string;
30
30
  /**
31
31
  * The format of the image to be exported.
32
32
  * Browsers are required to support 'image/png'. Some browsers also support 'image/jpeg' and 'image/webp'.
33
+ * If the provided `type` is not supported by the browser, it will default to 'image/png'.
33
34
  * @default 'image/png'
34
35
  */
35
36
  type?: 'image/png' | string;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { ChartPlugin, ZoomData } from '@mui/x-charts/internals';
3
+ import { UseChartProZoomSignature } from "../useChartProZoom.types.js";
4
+ export declare const usePanOnDrag: ({
5
+ store,
6
+ instance,
7
+ svgRef
8
+ }: Pick<Parameters<ChartPlugin<UseChartProZoomSignature>>[0], "store" | "instance" | "svgRef">, setZoomDataCallback: React.Dispatch<ZoomData[] | ((prev: ZoomData[]) => ZoomData[])>) => void;