@mui/x-charts-pro 8.5.3 → 8.6.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 (58) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  3. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
  4. package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +77 -0
  5. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
  6. package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +75 -0
  7. package/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
  8. package/ChartsToolbarPro/ChartsToolbarPro.js +118 -8
  9. package/ChartsToolbarPro/index.d.ts +3 -1
  10. package/ChartsToolbarPro/index.js +22 -0
  11. package/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
  12. package/ChartsToolbarPro/internals/ChartsMenu.js +73 -0
  13. package/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
  14. package/ChartsToolbarPro/internals/ChartsToolbarDivider.js +47 -0
  15. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  16. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
  17. package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +70 -0
  18. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
  19. package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +68 -0
  20. package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
  21. package/esm/ChartsToolbarPro/ChartsToolbarPro.js +120 -8
  22. package/esm/ChartsToolbarPro/index.d.ts +3 -1
  23. package/esm/ChartsToolbarPro/index.js +3 -1
  24. package/esm/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
  25. package/esm/ChartsToolbarPro/internals/ChartsMenu.js +67 -0
  26. package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
  27. package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.js +40 -0
  28. package/esm/index.d.ts +2 -1
  29. package/esm/index.js +1 -1
  30. package/esm/internals/material/components/BaseMenuItem.d.ts +3 -0
  31. package/esm/internals/material/components/BaseMenuItem.js +27 -0
  32. package/esm/internals/material/components/BasePopper.d.ts +3 -0
  33. package/esm/internals/material/components/BasePopper.js +122 -0
  34. package/esm/internals/material/icons.d.ts +2 -1
  35. package/esm/internals/material/icons.js +4 -1
  36. package/esm/internals/material/index.d.ts +1 -0
  37. package/esm/internals/material/index.js +12 -3
  38. package/esm/internals/plugins/useChartProExport/print.js +1 -1
  39. package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
  40. package/esm/internals/slots/chartBaseSlotProps.d.ts +50 -3
  41. package/esm/internals/slots/chartsBaseSlots.d.ts +5 -1
  42. package/esm/internals/slots/chartsIconSlots.d.ts +5 -0
  43. package/index.d.ts +2 -1
  44. package/index.js +1 -1
  45. package/internals/material/components/BaseMenuItem.d.ts +3 -0
  46. package/internals/material/components/BaseMenuItem.js +35 -0
  47. package/internals/material/components/BasePopper.d.ts +3 -0
  48. package/internals/material/components/BasePopper.js +130 -0
  49. package/internals/material/icons.d.ts +2 -1
  50. package/internals/material/icons.js +5 -2
  51. package/internals/material/index.d.ts +1 -0
  52. package/internals/material/index.js +11 -2
  53. package/internals/plugins/useChartProExport/print.js +1 -1
  54. package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
  55. package/internals/slots/chartBaseSlotProps.d.ts +50 -3
  56. package/internals/slots/chartsBaseSlots.d.ts +5 -1
  57. package/internals/slots/chartsIconSlots.d.ts +5 -0
  58. package/package.json +4 -4
@@ -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);
@@ -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;
@@ -4,7 +4,54 @@ export type ChartBaseTooltipProps = ChartBaseCommonProps & {
4
4
  children: React.ReactElement<any, any>;
5
5
  enterDelay?: number;
6
6
  title: React.ReactNode;
7
+ disableInteractive?: boolean;
7
8
  };
8
- export type ChartBaseIconButtonProps = ChartBaseCommonProps & {
9
- ref?: React.Ref<HTMLButtonElement>;
10
- };
9
+ type BasePlacement = 'top' | 'bottom' | 'left' | 'right';
10
+ type VariationPlacement = 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
11
+ type AutoPlacement = 'auto' | 'auto-start' | 'auto-end';
12
+ export type Placement = AutoPlacement | BasePlacement | VariationPlacement;
13
+ type ClickAwayMouseEventHandler = 'onClick' | 'onMouseDown' | 'onMouseUp' | 'onPointerDown' | 'onPointerUp';
14
+ type ClickAwayTouchEventHandler = 'onTouchStart' | 'onTouchEnd';
15
+ export type ChartBasePopperProps = ChartBaseCommonProps & {
16
+ ref?: React.Ref<HTMLDivElement>;
17
+ open: boolean;
18
+ children?: React.ReactNode;
19
+ clickAwayTouchEvent?: false | ClickAwayTouchEventHandler;
20
+ clickAwayMouseEvent?: false | ClickAwayMouseEventHandler;
21
+ flip?: boolean;
22
+ focusTrap?: boolean;
23
+ onExited?: (node: HTMLElement | null) => void;
24
+ onClickAway?: (event: MouseEvent | TouchEvent) => void;
25
+ onDidShow?: () => void;
26
+ onDidHide?: () => void;
27
+ id?: string;
28
+ target?: Element | null;
29
+ transition?: boolean;
30
+ /** @default 'bottom' */
31
+ placement?: Placement;
32
+ };
33
+ export type ChartBaseMenuListProps = ChartBaseCommonProps & {
34
+ ref?: React.Ref<HTMLUListElement>;
35
+ id?: string;
36
+ children?: React.ReactNode;
37
+ autoFocus?: boolean;
38
+ autoFocusItem?: boolean;
39
+ };
40
+ export type ChartBaseMenuItemProps = ChartBaseCommonProps & {
41
+ autoFocus?: boolean;
42
+ children?: React.ReactNode;
43
+ /** For items that aren't interactive themselves (but may contain an interactive widget) */
44
+ inert?: boolean;
45
+ dense?: boolean;
46
+ disabled?: boolean;
47
+ iconStart?: React.ReactNode;
48
+ iconEnd?: React.ReactNode;
49
+ selected?: boolean;
50
+ value?: number | string | readonly string[];
51
+ style?: React.CSSProperties;
52
+ };
53
+ export type ChartBaseDividerProps = ChartBaseCommonProps & {
54
+ ref?: React.Ref<HTMLHRElement>;
55
+ orientation?: 'horizontal' | 'vertical';
56
+ };
57
+ export {};
@@ -1,6 +1,10 @@
1
1
  import { ChartsBaseSlots } from '@mui/x-charts/models';
2
2
  import * as React from 'react';
3
- import { ChartBaseTooltipProps } from "./chartBaseSlotProps.js";
3
+ import { ChartBaseDividerProps, ChartBaseMenuItemProps, ChartBaseMenuListProps, ChartBasePopperProps, ChartBaseTooltipProps } from "./chartBaseSlotProps.js";
4
4
  export interface ChartsBaseSlotsPro extends ChartsBaseSlots {
5
+ baseDivider: React.ComponentType<ChartBaseDividerProps>;
6
+ baseMenuItem: React.ComponentType<ChartBaseMenuItemProps>;
7
+ baseMenuList: React.ComponentType<ChartBaseMenuListProps>;
8
+ basePopper: React.ComponentType<ChartBasePopperProps>;
5
9
  baseTooltip: React.ComponentType<ChartBaseTooltipProps>;
6
10
  }
@@ -11,4 +11,9 @@ export interface ChartsIconSlotsPro extends ChartsIconSlots {
11
11
  * @default ChartsZoomOutIcon
12
12
  */
13
13
  zoomOutIcon: React.ComponentType<ChartBaseIconProps>;
14
+ /**
15
+ * Icon displayed on the toolbar's export button.
16
+ * @default ChartsExportIcon
17
+ */
18
+ exportIcon: React.ComponentType<ChartBaseIconProps>;
14
19
  }
package/index.d.ts CHANGED
@@ -37,4 +37,5 @@ export * from "./PieChartPro/index.js";
37
37
  export * from "./FunnelChart/index.js";
38
38
  export * from "./RadarChartPro/index.js";
39
39
  export * from "./ChartZoomSlider/index.js";
40
- export * from "./ChartsToolbarPro/index.js";
40
+ export * from "./ChartsToolbarPro/index.js";
41
+ export type { ChartImageExportOptions, ChartPrintExportOptions } from "./internals/plugins/useChartProExport/index.js";
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts-pro v8.5.3
2
+ * @mui/x-charts-pro v8.6.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -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,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.BaseMenuItem = BaseMenuItem;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
13
+ var _ListItemIcon = _interopRequireDefault(require("@mui/material/ListItemIcon"));
14
+ var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ const _excluded = ["inert", "iconStart", "iconEnd", "children"];
17
+ function BaseMenuItem(props) {
18
+ const {
19
+ inert,
20
+ iconStart,
21
+ iconEnd,
22
+ children
23
+ } = props,
24
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
25
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_MenuItem.default, (0, _extends2.default)({}, other, {
26
+ disableRipple: inert ? true : other.disableRipple,
27
+ children: [iconStart && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemIcon.default, {
28
+ children: iconStart
29
+ }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemText.default, {
30
+ children: children
31
+ }, "2"), iconEnd && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemIcon.default, {
32
+ children: iconEnd
33
+ }, "3")]
34
+ }));
35
+ }
@@ -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,130 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.BasePopper = BasePopper;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
13
+ var _Unstable_TrapFocus = _interopRequireDefault(require("@mui/material/Unstable_TrapFocus"));
14
+ var _ClickAwayListener = _interopRequireDefault(require("@mui/material/ClickAwayListener"));
15
+ var _Grow = _interopRequireDefault(require("@mui/material/Grow"));
16
+ var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ const _excluded = ["ref", "open", "children", "className", "clickAwayTouchEvent", "clickAwayMouseEvent", "flip", "focusTrap", "onExited", "onClickAway", "onDidShow", "onDidHide", "id", "target", "transition", "placement"];
19
+ function clickAwayWrapper(props, content) {
20
+ if (props.onClickAway === undefined) {
21
+ return content;
22
+ }
23
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayListener.default, {
24
+ onClickAway: props.onClickAway,
25
+ touchEvent: props.clickAwayTouchEvent,
26
+ mouseEvent: props.clickAwayMouseEvent,
27
+ children: content
28
+ });
29
+ }
30
+ function focusTrapWrapper(props, content) {
31
+ if (props.focusTrap === undefined) {
32
+ return content;
33
+ }
34
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Unstable_TrapFocus.default, {
35
+ open: true,
36
+ disableEnforceFocus: true,
37
+ disableAutoFocus: true,
38
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
39
+ tabIndex: -1,
40
+ children: content
41
+ })
42
+ });
43
+ }
44
+ function wrappers(props, content) {
45
+ return focusTrapWrapper(props, clickAwayWrapper(props, content));
46
+ }
47
+ const transformOrigin = {
48
+ 'bottom-start': 'top left',
49
+ 'bottom-end': 'top right'
50
+ };
51
+ function BasePopper(props) {
52
+ const {
53
+ open,
54
+ children,
55
+ className,
56
+ flip,
57
+ onExited,
58
+ onDidShow,
59
+ onDidHide,
60
+ id,
61
+ target,
62
+ transition,
63
+ placement
64
+ } = props,
65
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
66
+ const modifiers = React.useMemo(() => {
67
+ const result = [{
68
+ name: 'preventOverflow',
69
+ options: {
70
+ padding: 8
71
+ }
72
+ }];
73
+ if (flip) {
74
+ result.push({
75
+ name: 'flip',
76
+ enabled: true,
77
+ options: {
78
+ rootBoundary: 'document'
79
+ }
80
+ });
81
+ }
82
+ if (onDidShow || onDidHide) {
83
+ result.push({
84
+ name: 'isPlaced',
85
+ enabled: true,
86
+ phase: 'main',
87
+ fn: () => {
88
+ onDidShow?.();
89
+ },
90
+ effect: () => () => {
91
+ onDidHide?.();
92
+ }
93
+ });
94
+ }
95
+ return result;
96
+ }, [flip, onDidShow, onDidHide]);
97
+ let content;
98
+ if (!transition) {
99
+ content = wrappers(props, children);
100
+ } else {
101
+ const handleExited = popperOnExited => node => {
102
+ if (popperOnExited) {
103
+ popperOnExited();
104
+ }
105
+ if (onExited) {
106
+ onExited(node);
107
+ }
108
+ };
109
+ content = p => wrappers(props, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grow.default, (0, _extends2.default)({}, p.TransitionProps, {
110
+ style: {
111
+ transformOrigin: transformOrigin[p.placement]
112
+ },
113
+ onExited: handleExited(p.TransitionProps?.onExited),
114
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Paper.default, {
115
+ children: children
116
+ })
117
+ })));
118
+ }
119
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popper.default, (0, _extends2.default)({
120
+ id: id,
121
+ className: className,
122
+ open: open,
123
+ anchorEl: target,
124
+ transition: transition,
125
+ placement: placement,
126
+ modifiers: modifiers
127
+ }, rest, {
128
+ children: content
129
+ }));
130
+ }
@@ -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;
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.ChartsZoomOutIcon = exports.ChartsZoomInIcon = void 0;
7
+ exports.ChartsZoomOutIcon = exports.ChartsZoomInIcon = exports.ChartsExportIcon = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _internals = require("@mui/x-charts/internals");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
@@ -17,4 +17,7 @@ const ChartsZoomInIcon = exports.ChartsZoomInIcon = (0, _internals.createSvgIcon
17
17
  }), 'ZoomIn');
18
18
  const ChartsZoomOutIcon = exports.ChartsZoomOutIcon = (0, _internals.createSvgIcon)(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
19
19
  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"
20
- }), 'ZoomOut');
20
+ }), 'ZoomOut');
21
+ const ChartsExportIcon = exports.ChartsExportIcon = (0, _internals.createSvgIcon)(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
22
+ d: "M19 9h-4V3H9v6H5l7 7zM5 18v2h14v-2z"
23
+ }), '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;
@@ -7,13 +7,22 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.defaultSlotsMaterial = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
10
+ var _MenuList = _interopRequireDefault(require("@mui/material/MenuList"));
11
+ var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
10
12
  var _internals = require("@mui/x-charts/internals");
13
+ var _BaseMenuItem = require("./components/BaseMenuItem");
14
+ var _BasePopper = require("./components/BasePopper");
11
15
  var _icons = require("./icons");
12
16
  const baseSlots = {
13
- baseTooltip: _Tooltip.default
17
+ baseTooltip: _Tooltip.default,
18
+ basePopper: _BasePopper.BasePopper,
19
+ baseMenuList: _MenuList.default,
20
+ baseMenuItem: _BaseMenuItem.BaseMenuItem,
21
+ baseDivider: _Divider.default
14
22
  };
15
23
  const iconSlots = {
16
24
  zoomInIcon: _icons.ChartsZoomInIcon,
17
- zoomOutIcon: _icons.ChartsZoomOutIcon
25
+ zoomOutIcon: _icons.ChartsZoomOutIcon,
26
+ exportIcon: _icons.ChartsExportIcon
18
27
  };
19
28
  const defaultSlotsMaterial = exports.defaultSlotsMaterial = (0, _extends2.default)({}, _internals.defaultSlotsMaterial, baseSlots, iconSlots);
@@ -22,7 +22,6 @@ function printChart(element, {
22
22
  const rootCandidate = element.getRootNode();
23
23
  const root = rootCandidate.constructor.name === 'ShadowRoot' ? rootCandidate : doc;
24
24
  await Promise.all((0, _export.loadStyleSheets)(printDoc, root));
25
- printWindow.contentWindow.print();
26
25
  const mediaQueryList = printWindow.contentWindow.matchMedia('print');
27
26
  mediaQueryList.addEventListener('change', mql => {
28
27
  const isAfterPrint = mql.matches === false;
@@ -30,6 +29,7 @@ function printChart(element, {
30
29
  doc.body.removeChild(printWindow);
31
30
  }
32
31
  });
32
+ printWindow.contentWindow.print();
33
33
  };
34
34
  doc.body.appendChild(printWindow);
35
35
  }
@@ -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;