@mui/x-charts 7.7.0 → 7.7.1

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 (137) hide show
  1. package/BarChart/BarChart.js +21 -104
  2. package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -3
  3. package/BarChart/BarLabel/BarLabelPlot.js +1 -24
  4. package/BarChart/BarPlot.js +2 -2
  5. package/BarChart/checkScaleErrors.d.ts +5 -9
  6. package/BarChart/types.d.ts +2 -2
  7. package/BarChart/useBarChartProps.d.ts +102 -0
  8. package/BarChart/useBarChartProps.js +143 -0
  9. package/CHANGELOG.md +82 -0
  10. package/ChartContainer/ChartContainer.d.ts +1 -1
  11. package/ChartContainer/ChartContainer.js +6 -10
  12. package/ChartContainer/useChartContainerHooks.d.ts +11 -0
  13. package/ChartContainer/useChartContainerHooks.js +34 -0
  14. package/ChartContainer/usePluginsMerge.d.ts +1 -2
  15. package/ChartsAxis/ChartsAxis.js +2 -2
  16. package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  17. package/ChartsGrid/ChartsGrid.js +2 -2
  18. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  19. package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  20. package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  21. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  22. package/ChartsXAxis/ChartsXAxis.js +2 -2
  23. package/ChartsYAxis/ChartsYAxis.js +2 -2
  24. package/LineChart/AreaPlot.js +2 -2
  25. package/LineChart/LineChart.js +24 -106
  26. package/LineChart/LineHighlightPlot.js +2 -2
  27. package/LineChart/LinePlot.js +2 -2
  28. package/LineChart/MarkPlot.js +2 -2
  29. package/LineChart/useLineChartProps.d.ts +117 -0
  30. package/LineChart/useLineChartProps.js +152 -0
  31. package/ScatterChart/ScatterChart.js +20 -75
  32. package/ScatterChart/ScatterPlot.js +2 -2
  33. package/ScatterChart/useScatterChartProps.d.ts +86 -0
  34. package/ScatterChart/useScatterChartProps.js +116 -0
  35. package/context/CartesianProvider/CartesianContext.d.ts +25 -0
  36. package/context/CartesianProvider/CartesianContext.js +21 -0
  37. package/context/CartesianProvider/CartesianProvider.d.ts +34 -0
  38. package/context/CartesianProvider/CartesianProvider.js +44 -0
  39. package/context/CartesianProvider/computeValue.d.ts +19 -0
  40. package/context/CartesianProvider/computeValue.js +89 -0
  41. package/context/CartesianProvider/getAxisExtremum.d.ts +4 -0
  42. package/context/CartesianProvider/getAxisExtremum.js +28 -0
  43. package/context/CartesianProvider/index.d.ts +9 -0
  44. package/context/CartesianProvider/index.js +51 -0
  45. package/context/CartesianProvider/normalizeAxis.d.ts +5 -0
  46. package/context/CartesianProvider/normalizeAxis.js +23 -0
  47. package/context/CartesianProvider/useCartesianContext.d.ts +2 -0
  48. package/context/CartesianProvider/useCartesianContext.js +17 -0
  49. package/context/ColorProvider.d.ts +2 -2
  50. package/esm/BarChart/BarChart.js +21 -104
  51. package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -23
  52. package/esm/BarChart/BarPlot.js +2 -2
  53. package/esm/BarChart/useBarChartProps.js +136 -0
  54. package/esm/ChartContainer/ChartContainer.js +5 -9
  55. package/esm/ChartContainer/useChartContainerHooks.js +24 -0
  56. package/esm/ChartsAxis/ChartsAxis.js +2 -2
  57. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  58. package/esm/ChartsGrid/ChartsGrid.js +2 -2
  59. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  60. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  61. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  62. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  63. package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
  64. package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
  65. package/esm/LineChart/AreaPlot.js +2 -2
  66. package/esm/LineChart/LineChart.js +24 -106
  67. package/esm/LineChart/LineHighlightPlot.js +2 -2
  68. package/esm/LineChart/LinePlot.js +2 -2
  69. package/esm/LineChart/MarkPlot.js +2 -2
  70. package/esm/LineChart/useLineChartProps.js +144 -0
  71. package/esm/ScatterChart/ScatterChart.js +20 -75
  72. package/esm/ScatterChart/ScatterPlot.js +2 -2
  73. package/esm/ScatterChart/useScatterChartProps.js +108 -0
  74. package/esm/context/CartesianProvider/CartesianContext.js +13 -0
  75. package/esm/context/CartesianProvider/CartesianProvider.js +37 -0
  76. package/esm/context/CartesianProvider/computeValue.js +82 -0
  77. package/esm/context/CartesianProvider/getAxisExtremum.js +21 -0
  78. package/esm/context/CartesianProvider/index.js +10 -0
  79. package/esm/context/CartesianProvider/normalizeAxis.js +15 -0
  80. package/esm/context/CartesianProvider/useCartesianContext.js +8 -0
  81. package/esm/hooks/useAxisEvents.js +2 -2
  82. package/esm/hooks/useColorScale.js +3 -3
  83. package/esm/hooks/useScale.js +3 -4
  84. package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  85. package/esm/internals/index.js +6 -2
  86. package/hooks/useAxisEvents.js +2 -2
  87. package/hooks/useColorScale.js +3 -3
  88. package/hooks/useDrawingArea.d.ts +2 -8
  89. package/hooks/useScale.js +3 -6
  90. package/index.js +1 -1
  91. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
  92. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  93. package/internals/index.d.ts +7 -1
  94. package/internals/index.js +49 -5
  95. package/models/plugin.d.ts +4 -1
  96. package/modern/BarChart/BarChart.js +21 -104
  97. package/modern/BarChart/BarLabel/BarLabelPlot.js +0 -23
  98. package/modern/BarChart/BarPlot.js +2 -2
  99. package/modern/BarChart/useBarChartProps.js +136 -0
  100. package/modern/ChartContainer/ChartContainer.js +5 -9
  101. package/modern/ChartContainer/useChartContainerHooks.js +24 -0
  102. package/modern/ChartsAxis/ChartsAxis.js +2 -2
  103. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
  104. package/modern/ChartsGrid/ChartsGrid.js +2 -2
  105. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
  106. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
  107. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
  108. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
  109. package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
  110. package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
  111. package/modern/LineChart/AreaPlot.js +2 -2
  112. package/modern/LineChart/LineChart.js +24 -106
  113. package/modern/LineChart/LineHighlightPlot.js +2 -2
  114. package/modern/LineChart/LinePlot.js +2 -2
  115. package/modern/LineChart/MarkPlot.js +2 -2
  116. package/modern/LineChart/useLineChartProps.js +144 -0
  117. package/modern/ScatterChart/ScatterChart.js +20 -75
  118. package/modern/ScatterChart/ScatterPlot.js +2 -2
  119. package/modern/ScatterChart/useScatterChartProps.js +108 -0
  120. package/modern/context/CartesianProvider/CartesianContext.js +13 -0
  121. package/modern/context/CartesianProvider/CartesianProvider.js +37 -0
  122. package/modern/context/CartesianProvider/computeValue.js +82 -0
  123. package/modern/context/CartesianProvider/getAxisExtremum.js +21 -0
  124. package/modern/context/CartesianProvider/index.js +10 -0
  125. package/modern/context/CartesianProvider/normalizeAxis.js +15 -0
  126. package/modern/context/CartesianProvider/useCartesianContext.js +8 -0
  127. package/modern/hooks/useAxisEvents.js +2 -2
  128. package/modern/hooks/useColorScale.js +3 -3
  129. package/modern/hooks/useScale.js +3 -4
  130. package/modern/index.js +1 -1
  131. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +2 -2
  132. package/modern/internals/index.js +6 -2
  133. package/package.json +3 -3
  134. package/context/CartesianContextProvider.d.ts +0 -61
  135. package/context/CartesianContextProvider.js +0 -220
  136. package/esm/context/CartesianContextProvider.js +0 -211
  137. package/modern/context/CartesianContextProvider.js +0 -211
@@ -7,12 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.BarChart = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var React = _interopRequireWildcard(require("react"));
10
- var _useId = _interopRequireDefault(require("@mui/utils/useId"));
11
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
11
  var _BarPlot = require("./BarPlot");
13
12
  var _ResponsiveChartContainer = require("../ResponsiveChartContainer");
14
13
  var _ChartsAxis = require("../ChartsAxis");
15
- var _constants = require("../constants");
16
14
  var _ChartsTooltip = require("../ChartsTooltip");
17
15
  var _ChartsLegend = require("../ChartsLegend");
18
16
  var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
@@ -20,6 +18,7 @@ var _ChartsClipPath = require("../ChartsClipPath");
20
18
  var _ChartsGrid = require("../ChartsGrid");
21
19
  var _ChartsOnAxisClickHandler = require("../ChartsOnAxisClickHandler");
22
20
  var _ChartsOverlay = require("../ChartsOverlay/ChartsOverlay");
21
+ var _useBarChartProps = require("./useBarChartProps");
23
22
  var _jsxRuntime = require("react/jsx-runtime");
24
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
25
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -36,108 +35,26 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
36
35
  */
37
36
  const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
38
37
  const {
39
- xAxis,
40
- yAxis,
41
- series,
42
- width,
43
- height,
44
- margin,
45
- colors,
46
- dataset,
47
- sx,
48
- layout,
49
- tooltip,
50
- axisHighlight,
51
- legend,
52
- grid,
53
- topAxis,
54
- leftAxis,
55
- rightAxis,
56
- bottomAxis,
57
- skipAnimation,
58
- borderRadius,
59
- onItemClick,
60
- onAxisClick,
61
- children,
62
- slots,
63
- slotProps,
64
- loading,
65
- barLabel,
66
- highlightedItem,
67
- onHighlightChange
68
- } = props;
69
- const id = (0, _useId.default)();
70
- const clipPathId = `${id}-clip-path`;
71
- const hasHorizontalSeries = layout === 'horizontal' || layout === undefined && series.some(item => item.layout === 'horizontal');
72
- const defaultAxisConfig = {
73
- scaleType: 'band',
74
- data: Array.from({
75
- length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
76
- }, (_, index) => index)
77
- };
78
- const defaultizedAxisHighlight = (0, _extends2.default)({}, hasHorizontalSeries ? {
79
- y: 'band'
80
- } : {
81
- x: 'band'
82
- }, axisHighlight);
83
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveChartContainer.ResponsiveChartContainer, {
84
- ref: ref,
85
- series: series.map(s => (0, _extends2.default)({
86
- type: 'bar'
87
- }, s, {
88
- layout: hasHorizontalSeries ? 'horizontal' : 'vertical'
89
- })),
90
- width: width,
91
- height: height,
92
- margin: margin,
93
- xAxis: xAxis ?? (hasHorizontalSeries ? undefined : [(0, _extends2.default)({
94
- id: _constants.DEFAULT_X_AXIS_KEY
95
- }, defaultAxisConfig)]),
96
- yAxis: yAxis ?? (hasHorizontalSeries ? [(0, _extends2.default)({
97
- id: _constants.DEFAULT_Y_AXIS_KEY
98
- }, defaultAxisConfig)] : undefined),
99
- colors: colors,
100
- dataset: dataset,
101
- sx: sx,
102
- disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
103
- highlightedItem: highlightedItem,
104
- onHighlightChange: onHighlightChange,
105
- children: [onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, {
106
- onAxisClick: onAxisClick
107
- }), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
108
- vertical: grid.vertical,
109
- horizontal: grid.horizontal
110
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
111
- clipPath: `url(#${clipPathId})`,
112
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_BarPlot.BarPlot, {
113
- slots: slots,
114
- slotProps: slotProps,
115
- skipAnimation: skipAnimation,
116
- onItemClick: onItemClick,
117
- borderRadius: borderRadius,
118
- barLabel: barLabel
119
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, {
120
- loading: loading,
121
- slots: slots,
122
- slotProps: slotProps
123
- })]
124
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, {
125
- topAxis: topAxis,
126
- leftAxis: leftAxis,
127
- rightAxis: rightAxis,
128
- bottomAxis: bottomAxis,
129
- slots: slots,
130
- slotProps: slotProps
131
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, {
132
- slots: slots,
133
- slotProps: slotProps
134
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, defaultizedAxisHighlight)), !loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltip, {
135
- slots: slots,
136
- slotProps: slotProps
137
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, {
138
- id: clipPathId
139
- }), children]
140
- });
38
+ chartContainerProps,
39
+ barPlotProps,
40
+ axisClickHandlerProps,
41
+ gridProps,
42
+ clipPathProps,
43
+ clipPathGroupProps,
44
+ overlayProps,
45
+ chartsAxisProps,
46
+ axisHighlightProps,
47
+ legendProps,
48
+ tooltipProps,
49
+ children
50
+ } = (0, _useBarChartProps.useBarChartProps)(props);
51
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveChartContainer.ResponsiveChartContainer, (0, _extends2.default)({
52
+ ref: ref
53
+ }, chartContainerProps, {
54
+ children: [props.onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, (0, _extends2.default)({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
55
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_BarPlot.BarPlot, (0, _extends2.default)({}, barPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps))]
56
+ })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, (0, _extends2.default)({}, clipPathProps)), children]
57
+ }));
141
58
  });
142
59
  process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
143
60
  // ----------------------------- Warning --------------------------------
@@ -10,7 +10,4 @@ type BarLabelPlotProps = {
10
10
  * @ignore - internal component.
11
11
  */
12
12
  declare function BarLabelPlot(props: BarLabelPlotProps): React.JSX.Element;
13
- declare namespace BarLabelPlot {
14
- var propTypes: any;
15
- }
16
13
  export { BarLabelPlot };
@@ -8,7 +8,6 @@ exports.BarLabelPlot = BarLabelPlot;
8
8
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
- var _propTypes = _interopRequireDefault(require("prop-types"));
12
11
  var _web = require("@react-spring/web");
13
12
  var _BarLabelItem = require("./BarLabelItem");
14
13
  var _jsxRuntime = require("react/jsx-runtime");
@@ -81,26 +80,4 @@ function BarLabelPlot(props) {
81
80
  style: style
82
81
  })))
83
82
  });
84
- }
85
- process.env.NODE_ENV !== "production" ? BarLabelPlot.propTypes = {
86
- // ----------------------------- Warning --------------------------------
87
- // | These PropTypes are generated from the TypeScript type definitions |
88
- // | To update them edit the TypeScript types and run "pnpm proptypes" |
89
- // ----------------------------------------------------------------------
90
- barLabel: _propTypes.default.oneOfType([_propTypes.default.oneOf(['value']), _propTypes.default.func]),
91
- bars: _propTypes.default.arrayOf(_propTypes.default.shape({
92
- color: _propTypes.default.string.isRequired,
93
- dataIndex: _propTypes.default.number.isRequired,
94
- height: _propTypes.default.number.isRequired,
95
- layout: _propTypes.default.oneOf(['horizontal', 'vertical']),
96
- maskId: _propTypes.default.string.isRequired,
97
- seriesId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
98
- value: _propTypes.default.number,
99
- width: _propTypes.default.number.isRequired,
100
- x: _propTypes.default.number.isRequired,
101
- xOrigin: _propTypes.default.number.isRequired,
102
- y: _propTypes.default.number.isRequired,
103
- yOrigin: _propTypes.default.number.isRequired
104
- })).isRequired,
105
- skipAnimation: _propTypes.default.bool
106
- } : void 0;
83
+ }
@@ -10,7 +10,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _web = require("@react-spring/web");
13
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
13
+ var _CartesianProvider = require("../context/CartesianProvider");
14
14
  var _BarElement = require("./BarElement");
15
15
  var _getColor = _interopRequireDefault(require("./getColor"));
16
16
  var _hooks = require("../hooks");
@@ -55,7 +55,7 @@ const useAggregatedData = () => {
55
55
  stackingGroups: [],
56
56
  seriesOrder: []
57
57
  };
58
- const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
58
+ const axisData = (0, _CartesianProvider.useCartesianContext)();
59
59
  const chartId = (0, _hooks.useChartId)();
60
60
  const {
61
61
  series,
@@ -1,11 +1,7 @@
1
- import { AxisDefaultized } from '../models/axis';
1
+ import { AxisDefaultized, AxisId } from '../models/axis';
2
2
  import { SeriesId } from '../models/seriesType/common';
3
- export declare function checkScaleErrors(verticalLayout: boolean, seriesId: SeriesId, xAxisKey: string, xAxis: {
4
- DEFAULT_X_AXIS_KEY: AxisDefaultized;
5
- } & {
6
- [axisKey: string]: AxisDefaultized;
7
- }, yAxisKey: string, yAxis: {
8
- DEFAULT_X_AXIS_KEY: AxisDefaultized;
9
- } & {
10
- [axisKey: string]: AxisDefaultized;
3
+ export declare function checkScaleErrors(verticalLayout: boolean, seriesId: SeriesId, xAxisKey: AxisId, xAxis: {
4
+ [axisKey: AxisId]: AxisDefaultized;
5
+ }, yAxisKey: AxisId, yAxis: {
6
+ [axisKey: AxisId]: AxisDefaultized;
11
7
  }): void;
@@ -5,8 +5,8 @@ export type AnimationData = {
5
5
  y: number;
6
6
  width: number;
7
7
  height: number;
8
- yOrigin: number;
9
- xOrigin: number;
8
+ yOrigin?: number;
9
+ xOrigin?: number;
10
10
  layout: BarSeriesType['layout'];
11
11
  };
12
12
  export interface CompletedBarData extends AnimationData {
@@ -0,0 +1,102 @@
1
+ /// <reference types="react" />
2
+ import type { BarChartProps } from './BarChart';
3
+ /**
4
+ * A helper function that extracts BarChartProps from the input props
5
+ * and returns an object with props for the children components of BarChart.
6
+ *
7
+ * @param props The input props for BarChart
8
+ * @returns An object with props for the children components of BarChart
9
+ */
10
+ export declare const useBarChartProps: (props: BarChartProps) => {
11
+ chartContainerProps: {
12
+ series: {
13
+ layout: "horizontal" | "vertical";
14
+ color?: string | undefined;
15
+ data?: (number | null)[] | undefined;
16
+ label?: string | ((location: "tooltip" | "legend") => string) | undefined;
17
+ id?: import("../internals").SeriesId | undefined;
18
+ dataKey?: string | undefined;
19
+ stackOffset?: import("..").StackOffsetType | undefined;
20
+ valueFormatter?: import("../internals").SeriesValueFormatter<number | null> | undefined;
21
+ highlightScope?: Partial<import("..").HighlightScope> | undefined;
22
+ xAxisKey?: string | undefined;
23
+ yAxisKey?: string | undefined;
24
+ stack?: string | undefined;
25
+ stackOrder?: import("..").StackOrderType | undefined;
26
+ type: "bar";
27
+ }[];
28
+ width: number | undefined;
29
+ height: number | undefined;
30
+ margin: Partial<import("..").CardinalDirections<number>> | undefined;
31
+ colors: import("..").ChartsColorPalette | undefined;
32
+ dataset: import("../internals").DatasetType | undefined;
33
+ xAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsXAxisProps>, "id">[] | undefined;
34
+ yAxis: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsYAxisProps>, "id">[] | undefined;
35
+ sx: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
36
+ highlightedItem: import("..").HighlightItemData | null | undefined;
37
+ onHighlightChange: ((highlightedItem: import("..").HighlightItemData | null) => void) | undefined;
38
+ disableAxisListener: boolean;
39
+ };
40
+ barPlotProps: {
41
+ onItemClick: ((event: import("react").MouseEvent<SVGElement, MouseEvent>, barItemIdentifier: import("..").BarItemIdentifier) => void) | undefined;
42
+ slots: import("./BarChart").BarChartSlots | undefined;
43
+ slotProps: import("./BarChart").BarChartSlotProps | undefined;
44
+ skipAnimation: boolean | undefined;
45
+ borderRadius: number | undefined;
46
+ barLabel: "value" | ((item: import("./BarLabel").BarItem, context: import("./BarLabel").BarLabelContext) => string | null | undefined) | undefined;
47
+ };
48
+ axisClickHandlerProps: {
49
+ onAxisClick: ((event: MouseEvent, data: {
50
+ dataIndex: number;
51
+ axisValue?: string | number | Date | undefined;
52
+ seriesValues: Record<string, number | null | undefined>;
53
+ } | null) => void) | undefined;
54
+ };
55
+ gridProps: {
56
+ vertical: boolean | undefined;
57
+ horizontal: boolean | undefined;
58
+ };
59
+ clipPathProps: {
60
+ id: string;
61
+ };
62
+ clipPathGroupProps: {
63
+ clipPath: string;
64
+ };
65
+ overlayProps: {
66
+ slots: import("./BarChart").BarChartSlots | undefined;
67
+ slotProps: import("./BarChart").BarChartSlotProps | undefined;
68
+ loading: boolean | undefined;
69
+ };
70
+ chartsAxisProps: {
71
+ topAxis: string | import("..").ChartsXAxisProps | null | undefined;
72
+ leftAxis: string | import("..").ChartsYAxisProps | null | undefined;
73
+ rightAxis: string | import("..").ChartsYAxisProps | null | undefined;
74
+ bottomAxis: string | import("..").ChartsXAxisProps | null | undefined;
75
+ slots: import("./BarChart").BarChartSlots | undefined;
76
+ slotProps: import("./BarChart").BarChartSlotProps | undefined;
77
+ };
78
+ axisHighlightProps: {
79
+ x?: ("none" | "line" | "band") | undefined;
80
+ y: "none" | "line" | "band";
81
+ } | {
82
+ x: "none" | "line" | "band";
83
+ y?: ("none" | "line" | "band") | undefined;
84
+ };
85
+ legendProps: {
86
+ slots: import("./BarChart").BarChartSlots | undefined;
87
+ slotProps: import("./BarChart").BarChartSlotProps | undefined;
88
+ position?: import("..").AnchorPosition | undefined;
89
+ classes?: Partial<import("..").ChartsLegendClasses> | undefined;
90
+ hidden?: boolean | undefined;
91
+ direction?: import("..").Direction | undefined;
92
+ };
93
+ tooltipProps: {
94
+ slots: import("./BarChart").BarChartSlots | undefined;
95
+ slotProps: import("./BarChart").BarChartSlotProps | undefined;
96
+ trigger?: import("../ChartsTooltip/utils").TriggerOptions | undefined;
97
+ itemContent?: import("react").ElementType<import("..").ChartsItemContentProps<any>, keyof import("react").JSX.IntrinsicElements> | undefined;
98
+ axisContent?: import("react").ElementType<import("..").ChartsAxisContentProps, keyof import("react").JSX.IntrinsicElements> | undefined;
99
+ classes?: Partial<import("..").ChartsTooltipClasses> | undefined;
100
+ };
101
+ children: import("react").ReactNode;
102
+ };
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useBarChartProps = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _useId = _interopRequireDefault(require("@mui/utils/useId"));
10
+ var _constants = require("../constants");
11
+ /**
12
+ * A helper function that extracts BarChartProps from the input props
13
+ * and returns an object with props for the children components of BarChart.
14
+ *
15
+ * @param props The input props for BarChart
16
+ * @returns An object with props for the children components of BarChart
17
+ */
18
+ const useBarChartProps = props => {
19
+ const {
20
+ xAxis,
21
+ yAxis,
22
+ series,
23
+ width,
24
+ height,
25
+ margin,
26
+ colors,
27
+ dataset,
28
+ sx,
29
+ tooltip,
30
+ onAxisClick,
31
+ axisHighlight,
32
+ legend,
33
+ grid,
34
+ topAxis,
35
+ leftAxis,
36
+ rightAxis,
37
+ bottomAxis,
38
+ children,
39
+ slots,
40
+ slotProps,
41
+ skipAnimation,
42
+ loading,
43
+ layout,
44
+ onItemClick,
45
+ highlightedItem,
46
+ onHighlightChange,
47
+ borderRadius,
48
+ barLabel
49
+ } = props;
50
+ const id = (0, _useId.default)();
51
+ const clipPathId = `${id}-clip-path`;
52
+ const hasHorizontalSeries = layout === 'horizontal' || layout === undefined && series.some(item => item.layout === 'horizontal');
53
+ const defaultAxisConfig = {
54
+ scaleType: 'band',
55
+ data: Array.from({
56
+ length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
57
+ }, (_, index) => index)
58
+ };
59
+ const chartContainerProps = {
60
+ series: series.map(s => (0, _extends2.default)({
61
+ type: 'bar'
62
+ }, s, {
63
+ layout: hasHorizontalSeries ? 'horizontal' : 'vertical'
64
+ })),
65
+ width,
66
+ height,
67
+ margin,
68
+ colors,
69
+ dataset,
70
+ xAxis: xAxis ?? (hasHorizontalSeries ? undefined : [(0, _extends2.default)({
71
+ id: _constants.DEFAULT_X_AXIS_KEY
72
+ }, defaultAxisConfig)]),
73
+ yAxis: yAxis ?? (hasHorizontalSeries ? [(0, _extends2.default)({
74
+ id: _constants.DEFAULT_Y_AXIS_KEY
75
+ }, defaultAxisConfig)] : undefined),
76
+ sx,
77
+ highlightedItem,
78
+ onHighlightChange,
79
+ disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
80
+ };
81
+ const barPlotProps = {
82
+ onItemClick,
83
+ slots,
84
+ slotProps,
85
+ skipAnimation,
86
+ borderRadius,
87
+ barLabel
88
+ };
89
+ const axisClickHandlerProps = {
90
+ onAxisClick
91
+ };
92
+ const gridProps = {
93
+ vertical: grid?.vertical,
94
+ horizontal: grid?.horizontal
95
+ };
96
+ const clipPathGroupProps = {
97
+ clipPath: `url(#${clipPathId})`
98
+ };
99
+ const clipPathProps = {
100
+ id: clipPathId
101
+ };
102
+ const overlayProps = {
103
+ slots,
104
+ slotProps,
105
+ loading
106
+ };
107
+ const chartsAxisProps = {
108
+ topAxis,
109
+ leftAxis,
110
+ rightAxis,
111
+ bottomAxis,
112
+ slots,
113
+ slotProps
114
+ };
115
+ const axisHighlightProps = (0, _extends2.default)({}, hasHorizontalSeries ? {
116
+ y: 'band'
117
+ } : {
118
+ x: 'band'
119
+ }, axisHighlight);
120
+ const legendProps = (0, _extends2.default)({}, legend, {
121
+ slots,
122
+ slotProps
123
+ });
124
+ const tooltipProps = (0, _extends2.default)({}, tooltip, {
125
+ slots,
126
+ slotProps
127
+ });
128
+ return {
129
+ chartContainerProps,
130
+ barPlotProps,
131
+ axisClickHandlerProps,
132
+ gridProps,
133
+ clipPathProps,
134
+ clipPathGroupProps,
135
+ overlayProps,
136
+ chartsAxisProps,
137
+ axisHighlightProps,
138
+ legendProps,
139
+ tooltipProps,
140
+ children
141
+ };
142
+ };
143
+ exports.useBarChartProps = useBarChartProps;
package/CHANGELOG.md CHANGED
@@ -3,6 +3,88 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.7.1
7
+
8
+ _Jun 21, 2024_
9
+
10
+ We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🌍 Improve Portuguese (pt-PT) locale on the Data Grid
13
+ - 🌍 Improve Danish (da-DK) locale on the Date and Time Pickers
14
+ - 🐞 Bugfixes
15
+ - 📚 Documentation improvements
16
+
17
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
18
+
19
+ ### Data Grid
20
+
21
+ #### `@mui/x-data-grid@7.7.1`
22
+
23
+ - [DataGrid][docs] Clarify enabling pagination (#13350) @oliviertassinari
24
+ - [DataGrid] Fix CSV export escaping for non-string values (#13560) @joeycumines-scw
25
+ - [l10n] Improve Portuguese (pt-PT) locale (#13348) @joaosreis
26
+
27
+ #### `@mui/x-data-grid-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
28
+
29
+ Same changes as in `@mui/x-data-grid@7.7.1`, plus:
30
+
31
+ - [DataGrid] Warn about `getTreeDataPath` reference (#13519) @cherniavskii
32
+
33
+ #### `@mui/x-data-grid-premium@7.7.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
34
+
35
+ Same changes as in `@mui/x-data-grid-pro@7.7.1`.
36
+
37
+ ### Date and Time Pickers
38
+
39
+ #### `@mui/x-date-pickers@7.7.1`
40
+
41
+ - [fields] Prevent digit editing on the `Space` key down (#13510) @flaviendelangle
42
+ - [l10n] Improve Danish (da-DK) locale (#13375) @jacrowland1
43
+ - [pickers] Add context to `onAccept` callback (#13511) @flaviendelangle
44
+ - [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
45
+ - [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
46
+ - [pickers] Fix controlled `view` behavior (#13552) @LukasTy
47
+ - [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
48
+
49
+ #### `@mui/x-date-pickers-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
+
51
+ Same changes as in `@mui/x-date-pickers@7.7.1`, plus:
52
+
53
+ - [DateRangePicker] Add accessible name to calendar grid (#13538) @LukasTy
54
+
55
+ ### Charts
56
+
57
+ #### `@mui/x-charts@7.7.1`
58
+
59
+ - [charts] Divide `CartesianProvider` to use logic in Pro package (#13531) @JCQuintas
60
+ - [charts] Do not publish the pro package (#13539) @alexfauquette
61
+ - [charts] Export `Pro` versions of regular charts (#13547) @JCQuintas
62
+ - [charts] Prepare `ChartContainerPro` for future Zoom changes (#13532) @JCQuintas
63
+ - [charts] Remove unnecessary proptypes from internal component (#13518) @JCQuintas
64
+
65
+ ### Tree View
66
+
67
+ #### `@mui/x-tree-view@7.7.1`
68
+
69
+ - [TreeView] Improve typing to support optional dependencies in plugins and in the item (#13523) @flaviendelangle
70
+ - [TreeView] Move `useTreeViewId` to the core plugins (#13566) @flaviendelangle
71
+ - [TreeView] Remove unused state from `useTreeViewId` (#13579) @flaviendelangle
72
+ - [TreeView] Support `itemId` with escaping characters when using `SimpleTreeView` (#13487) @oukunan
73
+
74
+ ### Docs
75
+
76
+ - [docs] Add section about the new uncovered product watermark (#13568) @michelengelen
77
+ - [docs] Document the `PickerValidDate` type override (#13476) @flaviendelangle
78
+ - [docs] Fix typo (#13507) @anshtiwatne
79
+ - [docs] Remove "-" in heat-map and tree-map urls (#13569) @alexfauquette
80
+ - [docs] Use dedicated tab for weather dataset (#13513) @alexfauquette
81
+ - [x-license] license update proposal (#13459) @michelengelen
82
+
83
+ ### Core
84
+
85
+ - [core] Fix failing CI test (#13574) @alexfauquette
86
+ - [infra] Remove explicit `@testing-library/react` dependency (#13478) @LukasTy
87
+
6
88
  ## 7.7.0
7
89
 
8
90
  _Jun 13, 2024_
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { DrawingProviderProps } from '../context/DrawingProvider';
3
3
  import { SeriesContextProviderProps } from '../context/SeriesContextProvider';
4
4
  import { ChartsSurfaceProps } from '../ChartsSurface';
5
- import { CartesianContextProviderProps } from '../context/CartesianContextProvider';
5
+ import { CartesianContextProviderProps } from '../context/CartesianProvider';
6
6
  import { HighlightedProviderProps, ZAxisContextProviderProps } from '../context';
7
7
  import { ChartsPluginType } from '../models/plugin';
8
8
  import { ChartSeriesType } from '../models/seriesType/config';
@@ -7,17 +7,15 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ChartContainer = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
11
10
  var _DrawingProvider = require("../context/DrawingProvider");
12
11
  var _SeriesContextProvider = require("../context/SeriesContextProvider");
13
12
  var _InteractionProvider = require("../context/InteractionProvider");
14
13
  var _ColorProvider = require("../context/ColorProvider");
15
- var _useReducedMotion = require("../hooks/useReducedMotion");
16
14
  var _ChartsSurface = require("../ChartsSurface");
17
- var _CartesianContextProvider = require("../context/CartesianContextProvider");
15
+ var _CartesianProvider = require("../context/CartesianProvider");
18
16
  var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
19
17
  var _context = require("../context");
20
- var _usePluginsMerge = require("./usePluginsMerge");
18
+ var _useChartContainerHooks = require("./useChartContainerHooks");
21
19
  var _jsxRuntime = require("react/jsx-runtime");
22
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
23
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -41,16 +39,14 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
41
39
  plugins,
42
40
  children
43
41
  } = props;
44
- const svgRef = React.useRef(null);
45
- const handleRef = (0, _useForkRef.default)(ref, svgRef);
46
42
  const {
43
+ svgRef,
44
+ handleRef,
47
45
  xExtremumGetters,
48
46
  yExtremumGetters,
49
47
  seriesFormatters,
50
48
  colorProcessors
51
- } = (0, _usePluginsMerge.usePluginsMerge)(plugins);
52
- (0, _useReducedMotion.useReducedMotion)(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
53
-
49
+ } = (0, _useChartContainerHooks.useChartContainerHooks)(ref, plugins);
54
50
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DrawingProvider.DrawingProvider, {
55
51
  width: width,
56
52
  height: height,
@@ -63,7 +59,7 @@ const ChartContainer = exports.ChartContainer = /*#__PURE__*/React.forwardRef(fu
63
59
  colors: colors,
64
60
  dataset: dataset,
65
61
  seriesFormatters: seriesFormatters,
66
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CartesianContextProvider.CartesianContextProvider, {
62
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CartesianProvider.CartesianContextProvider, {
67
63
  xAxis: xAxis,
68
64
  yAxis: yAxis,
69
65
  dataset: dataset,
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { ChartsPluginType } from '../models';
3
+ import { ChartSeriesType } from '../models/seriesType/config';
4
+ export declare const useChartContainerHooks: (ref: React.ForwardedRef<unknown> | null, plugins?: ChartsPluginType<ChartSeriesType>[]) => {
5
+ svgRef: React.RefObject<SVGSVGElement>;
6
+ handleRef: ((instance: unknown) => void) | null;
7
+ xExtremumGetters: import("../models").ExtremumGettersConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
8
+ yExtremumGetters: import("../models").ExtremumGettersConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
9
+ seriesFormatters: import("../internals").SeriesFormatterConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
10
+ colorProcessors: import("../models").ColorProcessorsConfig<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
11
+ };