@mui/x-charts 8.0.0-beta.2 → 8.0.0-beta.3

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 (345) hide show
  1. package/BarChart/AnimatedBarElement.d.ts +38 -8
  2. package/BarChart/AnimatedBarElement.js +5 -5
  3. package/BarChart/BarChart.js +2 -0
  4. package/BarChart/BarClipPath.d.ts +19 -1
  5. package/BarChart/BarClipPath.js +84 -17
  6. package/BarChart/BarElement.d.ts +9 -20
  7. package/BarChart/BarElement.js +29 -26
  8. package/BarChart/BarLabel/BarLabel.d.ts +27 -854
  9. package/BarChart/BarLabel/BarLabel.js +32 -5
  10. package/BarChart/BarLabel/BarLabel.types.d.ts +2 -0
  11. package/BarChart/BarLabel/BarLabelItem.d.ts +24 -0
  12. package/BarChart/BarLabel/BarLabelItem.js +18 -6
  13. package/BarChart/BarLabel/BarLabelPlot.js +16 -46
  14. package/BarChart/BarLabel/barLabelClasses.d.ts +3 -1
  15. package/BarChart/BarLabel/barLabelClasses.js +4 -3
  16. package/BarChart/BarPlot.js +37 -61
  17. package/BarChart/barElementClasses.d.ts +21 -0
  18. package/BarChart/barElementClasses.js +29 -0
  19. package/BarChart/getRadius.d.ts +1 -1
  20. package/BarChart/index.d.ts +2 -1
  21. package/BarChart/index.js +11 -0
  22. package/BarChart/seriesConfig/index.js +3 -1
  23. package/BarChart/seriesConfig/tooltip.d.ts +2 -1
  24. package/BarChart/seriesConfig/tooltip.js +14 -1
  25. package/BarChart/types.d.ts +2 -2
  26. package/CHANGELOG.md +141 -0
  27. package/ChartContainer/ChartContainer.js +4 -0
  28. package/ChartsLabel/ChartsLabelMark.js +0 -4
  29. package/ChartsLabel/index.d.ts +1 -0
  30. package/ChartsLabel/index.js +7 -0
  31. package/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
  32. package/ChartsTooltip/ChartsAxisTooltipContent.js +47 -55
  33. package/ChartsTooltip/ChartsItemTooltipContent.js +11 -9
  34. package/ChartsTooltip/ChartsTooltip.js +2 -2
  35. package/ChartsTooltip/ChartsTooltipContainer.js +3 -8
  36. package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -1
  37. package/ChartsTooltip/ChartsTooltipTable.js +24 -9
  38. package/ChartsTooltip/chartsTooltipClasses.d.ts +4 -4
  39. package/ChartsTooltip/chartsTooltipClasses.js +2 -2
  40. package/ChartsTooltip/index.d.ts +1 -0
  41. package/ChartsTooltip/index.js +12 -0
  42. package/ChartsTooltip/useAxesTooltip.d.ts +7 -0
  43. package/ChartsTooltip/useAxesTooltip.js +18 -0
  44. package/ChartsTooltip/useAxisTooltip.d.ts +24 -3
  45. package/ChartsTooltip/useAxisTooltip.js +71 -37
  46. package/ChartsTooltip/useItemTooltip.js +4 -1
  47. package/ChartsXAxis/ChartsXAxis.js +5 -2
  48. package/ChartsYAxis/ChartsYAxis.js +69 -17
  49. package/LineChart/AnimatedArea.js +5 -22
  50. package/LineChart/AnimatedLine.d.ts +1 -4
  51. package/LineChart/AnimatedLine.js +10 -25
  52. package/LineChart/AppearingMask.d.ts +5 -0
  53. package/LineChart/AppearingMask.js +25 -18
  54. package/LineChart/CircleMarkElement.js +16 -22
  55. package/LineChart/LineChart.js +2 -0
  56. package/LineChart/LineHighlightPlot.js +2 -3
  57. package/LineChart/MarkElement.js +16 -27
  58. package/LineChart/MarkPlot.js +0 -1
  59. package/LineChart/markElementClasses.d.ts +3 -0
  60. package/LineChart/markElementClasses.js +4 -3
  61. package/LineChart/seriesConfig/index.js +3 -1
  62. package/LineChart/seriesConfig/tooltip.d.ts +2 -1
  63. package/LineChart/seriesConfig/tooltip.js +8 -1
  64. package/PieChart/PieArc.d.ts +19 -11
  65. package/PieChart/PieArc.js +37 -24
  66. package/PieChart/PieArcLabel.d.ts +22 -13
  67. package/PieChart/PieArcLabel.js +52 -48
  68. package/PieChart/PieArcLabelPlot.js +16 -34
  69. package/PieChart/PieArcPlot.js +21 -34
  70. package/PieChart/seriesConfig/tooltip.js +3 -0
  71. package/ScatterChart/ScatterChart.js +2 -0
  72. package/SparkLineChart/SparkLineChart.js +2 -0
  73. package/colorPalettes/colorPalettes.js +2 -2
  74. package/constants/index.d.ts +1 -1
  75. package/constants/index.js +1 -1
  76. package/context/AnimationProvider/AnimationProvider.js +4 -6
  77. package/esm/BarChart/AnimatedBarElement.d.ts +38 -8
  78. package/esm/BarChart/AnimatedBarElement.js +5 -5
  79. package/esm/BarChart/BarChart.js +2 -0
  80. package/esm/BarChart/BarClipPath.d.ts +19 -1
  81. package/esm/BarChart/BarClipPath.js +84 -17
  82. package/esm/BarChart/BarElement.d.ts +9 -20
  83. package/esm/BarChart/BarElement.js +28 -23
  84. package/esm/BarChart/BarLabel/BarLabel.d.ts +27 -854
  85. package/esm/BarChart/BarLabel/BarLabel.js +32 -5
  86. package/esm/BarChart/BarLabel/BarLabel.types.d.ts +2 -0
  87. package/esm/BarChart/BarLabel/BarLabelItem.d.ts +24 -0
  88. package/esm/BarChart/BarLabel/BarLabelItem.js +18 -6
  89. package/esm/BarChart/BarLabel/BarLabelPlot.js +16 -46
  90. package/esm/BarChart/BarLabel/barLabelClasses.d.ts +3 -1
  91. package/esm/BarChart/BarLabel/barLabelClasses.js +4 -3
  92. package/esm/BarChart/BarPlot.js +37 -61
  93. package/esm/BarChart/barElementClasses.d.ts +21 -0
  94. package/esm/BarChart/barElementClasses.js +19 -0
  95. package/esm/BarChart/getRadius.d.ts +1 -1
  96. package/esm/BarChart/index.d.ts +2 -1
  97. package/esm/BarChart/index.js +2 -1
  98. package/esm/BarChart/seriesConfig/index.js +2 -1
  99. package/esm/BarChart/seriesConfig/tooltip.d.ts +2 -1
  100. package/esm/BarChart/seriesConfig/tooltip.js +12 -0
  101. package/esm/BarChart/types.d.ts +2 -2
  102. package/esm/ChartContainer/ChartContainer.js +4 -0
  103. package/esm/ChartsLabel/ChartsLabelMark.js +0 -4
  104. package/esm/ChartsLabel/index.d.ts +1 -0
  105. package/esm/ChartsLabel/index.js +1 -0
  106. package/esm/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
  107. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +47 -55
  108. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +11 -9
  109. package/esm/ChartsTooltip/ChartsTooltip.js +2 -2
  110. package/esm/ChartsTooltip/ChartsTooltipContainer.js +4 -9
  111. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +3 -1
  112. package/esm/ChartsTooltip/ChartsTooltipTable.js +23 -9
  113. package/esm/ChartsTooltip/chartsTooltipClasses.d.ts +4 -4
  114. package/esm/ChartsTooltip/chartsTooltipClasses.js +2 -2
  115. package/esm/ChartsTooltip/index.d.ts +1 -0
  116. package/esm/ChartsTooltip/index.js +1 -0
  117. package/esm/ChartsTooltip/useAxesTooltip.d.ts +7 -0
  118. package/esm/ChartsTooltip/useAxesTooltip.js +12 -0
  119. package/esm/ChartsTooltip/useAxisTooltip.d.ts +24 -3
  120. package/esm/ChartsTooltip/useAxisTooltip.js +72 -38
  121. package/esm/ChartsTooltip/useItemTooltip.js +4 -1
  122. package/esm/ChartsXAxis/ChartsXAxis.js +5 -2
  123. package/esm/ChartsYAxis/ChartsYAxis.js +69 -17
  124. package/esm/LineChart/AnimatedArea.js +5 -22
  125. package/esm/LineChart/AnimatedLine.d.ts +1 -4
  126. package/esm/LineChart/AnimatedLine.js +9 -24
  127. package/esm/LineChart/AppearingMask.d.ts +5 -0
  128. package/esm/LineChart/AppearingMask.js +23 -18
  129. package/esm/LineChart/CircleMarkElement.js +19 -25
  130. package/esm/LineChart/LineChart.js +2 -0
  131. package/esm/LineChart/LineHighlightPlot.js +3 -4
  132. package/esm/LineChart/MarkElement.js +17 -28
  133. package/esm/LineChart/MarkPlot.js +0 -1
  134. package/esm/LineChart/markElementClasses.d.ts +3 -0
  135. package/esm/LineChart/markElementClasses.js +4 -3
  136. package/esm/LineChart/seriesConfig/index.js +2 -1
  137. package/esm/LineChart/seriesConfig/tooltip.d.ts +2 -1
  138. package/esm/LineChart/seriesConfig/tooltip.js +6 -0
  139. package/esm/PieChart/PieArc.d.ts +19 -11
  140. package/esm/PieChart/PieArc.js +36 -23
  141. package/esm/PieChart/PieArcLabel.d.ts +22 -13
  142. package/esm/PieChart/PieArcLabel.js +51 -47
  143. package/esm/PieChart/PieArcLabelPlot.js +16 -34
  144. package/esm/PieChart/PieArcPlot.js +21 -34
  145. package/esm/PieChart/seriesConfig/tooltip.js +3 -0
  146. package/esm/ScatterChart/ScatterChart.js +2 -0
  147. package/esm/SparkLineChart/SparkLineChart.js +2 -0
  148. package/esm/colorPalettes/colorPalettes.js +2 -2
  149. package/esm/constants/index.d.ts +1 -1
  150. package/esm/constants/index.js +1 -1
  151. package/esm/context/AnimationProvider/AnimationProvider.js +3 -6
  152. package/esm/hooks/animation/index.d.ts +6 -0
  153. package/esm/hooks/animation/index.js +6 -0
  154. package/esm/hooks/animation/useAnimateArea.d.ts +15 -0
  155. package/esm/hooks/animation/useAnimateArea.js +27 -0
  156. package/esm/hooks/animation/useAnimateBar.d.ts +17 -0
  157. package/esm/hooks/animation/useAnimateBar.js +56 -0
  158. package/esm/hooks/animation/useAnimateBarLabel.d.ts +19 -0
  159. package/esm/hooks/animation/useAnimateBarLabel.js +59 -0
  160. package/esm/hooks/animation/useAnimateLine.d.ts +14 -0
  161. package/esm/hooks/animation/useAnimateLine.js +26 -0
  162. package/esm/hooks/animation/useAnimatePieArc.d.ts +15 -0
  163. package/esm/hooks/animation/useAnimatePieArc.js +70 -0
  164. package/esm/hooks/animation/useAnimatePieArcLabel.d.ts +15 -0
  165. package/esm/hooks/animation/useAnimatePieArcLabel.js +72 -0
  166. package/esm/hooks/index.d.ts +2 -1
  167. package/esm/hooks/index.js +2 -1
  168. package/esm/hooks/useInteractionItemProps.js +11 -0
  169. package/esm/index.js +1 -1
  170. package/esm/internals/animation/Transition.d.ts +37 -0
  171. package/esm/internals/animation/Transition.js +83 -0
  172. package/esm/internals/animation/animation.d.ts +4 -0
  173. package/esm/internals/animation/animation.js +4 -0
  174. package/esm/internals/animation/useAnimate.d.ts +19 -0
  175. package/esm/internals/animation/useAnimate.js +74 -0
  176. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
  177. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +9 -3
  178. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.ts +5 -0
  179. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js +21 -0
  180. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +8 -32
  181. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +9 -1
  182. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +60 -26
  183. package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +3 -1
  184. package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +10 -4
  185. package/esm/internals/shallowEqual.d.ts +8 -0
  186. package/esm/internals/shallowEqual.js +31 -0
  187. package/esm/models/axis.d.ts +8 -0
  188. package/esm/themeAugmentation/overrides.d.ts +1 -1
  189. package/hooks/animation/index.d.ts +6 -0
  190. package/hooks/animation/index.js +71 -0
  191. package/hooks/animation/useAnimateArea.d.ts +15 -0
  192. package/hooks/animation/useAnimateArea.js +34 -0
  193. package/hooks/animation/useAnimateBar.d.ts +17 -0
  194. package/hooks/animation/useAnimateBar.js +62 -0
  195. package/hooks/animation/useAnimateBarLabel.d.ts +19 -0
  196. package/hooks/animation/useAnimateBarLabel.js +65 -0
  197. package/hooks/animation/useAnimateLine.d.ts +14 -0
  198. package/hooks/animation/useAnimateLine.js +33 -0
  199. package/hooks/animation/useAnimatePieArc.d.ts +15 -0
  200. package/hooks/animation/useAnimatePieArc.js +77 -0
  201. package/hooks/animation/useAnimatePieArcLabel.d.ts +15 -0
  202. package/hooks/animation/useAnimatePieArcLabel.js +79 -0
  203. package/hooks/index.d.ts +2 -1
  204. package/hooks/index.js +13 -1
  205. package/hooks/useInteractionItemProps.js +11 -0
  206. package/index.js +1 -1
  207. package/internals/animation/Transition.d.ts +37 -0
  208. package/internals/animation/Transition.js +89 -0
  209. package/internals/animation/animation.d.ts +4 -0
  210. package/internals/animation/animation.js +11 -0
  211. package/internals/animation/useAnimate.d.ts +19 -0
  212. package/internals/animation/useAnimate.js +80 -0
  213. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
  214. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +9 -3
  215. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.ts +5 -0
  216. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js +28 -0
  217. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +8 -32
  218. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +9 -1
  219. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +61 -27
  220. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +3 -1
  221. package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +10 -4
  222. package/internals/shallowEqual.d.ts +8 -0
  223. package/internals/shallowEqual.js +37 -0
  224. package/models/axis.d.ts +8 -0
  225. package/modern/BarChart/AnimatedBarElement.d.ts +38 -8
  226. package/modern/BarChart/AnimatedBarElement.js +5 -5
  227. package/modern/BarChart/BarChart.js +2 -0
  228. package/modern/BarChart/BarClipPath.d.ts +19 -1
  229. package/modern/BarChart/BarClipPath.js +84 -17
  230. package/modern/BarChart/BarElement.d.ts +9 -20
  231. package/modern/BarChart/BarElement.js +28 -23
  232. package/modern/BarChart/BarLabel/BarLabel.d.ts +27 -854
  233. package/modern/BarChart/BarLabel/BarLabel.js +32 -5
  234. package/modern/BarChart/BarLabel/BarLabel.types.d.ts +2 -0
  235. package/modern/BarChart/BarLabel/BarLabelItem.d.ts +24 -0
  236. package/modern/BarChart/BarLabel/BarLabelItem.js +18 -6
  237. package/modern/BarChart/BarLabel/BarLabelPlot.js +16 -46
  238. package/modern/BarChart/BarLabel/barLabelClasses.d.ts +3 -1
  239. package/modern/BarChart/BarLabel/barLabelClasses.js +4 -3
  240. package/modern/BarChart/BarPlot.js +37 -61
  241. package/modern/BarChart/barElementClasses.d.ts +21 -0
  242. package/modern/BarChart/barElementClasses.js +19 -0
  243. package/modern/BarChart/getRadius.d.ts +1 -1
  244. package/modern/BarChart/index.d.ts +2 -1
  245. package/modern/BarChart/index.js +2 -1
  246. package/modern/BarChart/seriesConfig/index.js +2 -1
  247. package/modern/BarChart/seriesConfig/tooltip.d.ts +2 -1
  248. package/modern/BarChart/seriesConfig/tooltip.js +12 -0
  249. package/modern/BarChart/types.d.ts +2 -2
  250. package/modern/ChartContainer/ChartContainer.js +4 -0
  251. package/modern/ChartsLabel/ChartsLabelMark.js +0 -4
  252. package/modern/ChartsLabel/index.d.ts +1 -0
  253. package/modern/ChartsLabel/index.js +1 -0
  254. package/modern/ChartsLegend/continuousColorLegendClasses.d.ts +1 -1
  255. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +47 -55
  256. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +11 -9
  257. package/modern/ChartsTooltip/ChartsTooltip.js +2 -2
  258. package/modern/ChartsTooltip/ChartsTooltipContainer.js +4 -9
  259. package/modern/ChartsTooltip/ChartsTooltipTable.d.ts +3 -1
  260. package/modern/ChartsTooltip/ChartsTooltipTable.js +23 -9
  261. package/modern/ChartsTooltip/chartsTooltipClasses.d.ts +4 -4
  262. package/modern/ChartsTooltip/chartsTooltipClasses.js +2 -2
  263. package/modern/ChartsTooltip/index.d.ts +1 -0
  264. package/modern/ChartsTooltip/index.js +1 -0
  265. package/modern/ChartsTooltip/useAxesTooltip.d.ts +7 -0
  266. package/modern/ChartsTooltip/useAxesTooltip.js +12 -0
  267. package/modern/ChartsTooltip/useAxisTooltip.d.ts +24 -3
  268. package/modern/ChartsTooltip/useAxisTooltip.js +72 -38
  269. package/modern/ChartsTooltip/useItemTooltip.js +4 -1
  270. package/modern/ChartsXAxis/ChartsXAxis.js +5 -2
  271. package/modern/ChartsYAxis/ChartsYAxis.js +69 -17
  272. package/modern/LineChart/AnimatedArea.js +5 -22
  273. package/modern/LineChart/AnimatedLine.d.ts +1 -4
  274. package/modern/LineChart/AnimatedLine.js +9 -24
  275. package/modern/LineChart/AppearingMask.d.ts +5 -0
  276. package/modern/LineChart/AppearingMask.js +23 -18
  277. package/modern/LineChart/CircleMarkElement.js +19 -25
  278. package/modern/LineChart/LineChart.js +2 -0
  279. package/modern/LineChart/LineHighlightPlot.js +3 -4
  280. package/modern/LineChart/MarkElement.js +17 -28
  281. package/modern/LineChart/MarkPlot.js +0 -1
  282. package/modern/LineChart/markElementClasses.d.ts +3 -0
  283. package/modern/LineChart/markElementClasses.js +4 -3
  284. package/modern/LineChart/seriesConfig/index.js +2 -1
  285. package/modern/LineChart/seriesConfig/tooltip.d.ts +2 -1
  286. package/modern/LineChart/seriesConfig/tooltip.js +6 -0
  287. package/modern/PieChart/PieArc.d.ts +19 -11
  288. package/modern/PieChart/PieArc.js +36 -23
  289. package/modern/PieChart/PieArcLabel.d.ts +22 -13
  290. package/modern/PieChart/PieArcLabel.js +51 -47
  291. package/modern/PieChart/PieArcLabelPlot.js +16 -34
  292. package/modern/PieChart/PieArcPlot.js +21 -34
  293. package/modern/PieChart/seriesConfig/tooltip.js +3 -0
  294. package/modern/ScatterChart/ScatterChart.js +2 -0
  295. package/modern/SparkLineChart/SparkLineChart.js +2 -0
  296. package/modern/colorPalettes/colorPalettes.js +2 -2
  297. package/modern/constants/index.d.ts +1 -1
  298. package/modern/constants/index.js +1 -1
  299. package/modern/context/AnimationProvider/AnimationProvider.js +3 -6
  300. package/modern/hooks/animation/index.d.ts +6 -0
  301. package/modern/hooks/animation/index.js +6 -0
  302. package/modern/hooks/animation/useAnimateArea.d.ts +15 -0
  303. package/modern/hooks/animation/useAnimateArea.js +27 -0
  304. package/modern/hooks/animation/useAnimateBar.d.ts +17 -0
  305. package/modern/hooks/animation/useAnimateBar.js +56 -0
  306. package/modern/hooks/animation/useAnimateBarLabel.d.ts +19 -0
  307. package/modern/hooks/animation/useAnimateBarLabel.js +59 -0
  308. package/modern/hooks/animation/useAnimateLine.d.ts +14 -0
  309. package/modern/hooks/animation/useAnimateLine.js +26 -0
  310. package/modern/hooks/animation/useAnimatePieArc.d.ts +15 -0
  311. package/modern/hooks/animation/useAnimatePieArc.js +70 -0
  312. package/modern/hooks/animation/useAnimatePieArcLabel.d.ts +15 -0
  313. package/modern/hooks/animation/useAnimatePieArcLabel.js +72 -0
  314. package/modern/hooks/index.d.ts +2 -1
  315. package/modern/hooks/index.js +2 -1
  316. package/modern/hooks/useInteractionItemProps.js +11 -0
  317. package/modern/index.js +1 -1
  318. package/modern/internals/animation/Transition.d.ts +37 -0
  319. package/modern/internals/animation/Transition.js +83 -0
  320. package/modern/internals/animation/animation.d.ts +4 -0
  321. package/modern/internals/animation/animation.js +4 -0
  322. package/modern/internals/animation/useAnimate.d.ts +19 -0
  323. package/modern/internals/animation/useAnimate.js +74 -0
  324. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +1 -1
  325. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +9 -3
  326. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.d.ts +5 -0
  327. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js +21 -0
  328. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +8 -32
  329. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +9 -1
  330. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +60 -26
  331. package/modern/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +3 -1
  332. package/modern/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +10 -4
  333. package/modern/internals/shallowEqual.d.ts +8 -0
  334. package/modern/internals/shallowEqual.js +31 -0
  335. package/modern/models/axis.d.ts +8 -0
  336. package/modern/themeAugmentation/overrides.d.ts +1 -1
  337. package/package.json +8 -9
  338. package/themeAugmentation/overrides.d.ts +1 -1
  339. package/tsconfig.build.tsbuildinfo +1 -1
  340. package/PieChart/dataTransform/transition.d.ts +0 -4
  341. package/PieChart/dataTransform/transition.js +0 -145
  342. package/esm/PieChart/dataTransform/transition.d.ts +0 -4
  343. package/esm/PieChart/dataTransform/transition.js +0 -137
  344. package/modern/PieChart/dataTransform/transition.d.ts +0 -4
  345. package/modern/PieChart/dataTransform/transition.js +0 -137
@@ -3,45 +3,79 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorChartsInteractionYAxisValue = exports.selectorChartsInteractionYAxisIsDefined = exports.selectorChartsInteractionYAxisIndex = exports.selectorChartsInteractionYAxis = exports.selectorChartsInteractionXAxisValue = exports.selectorChartsInteractionXAxisIsDefined = exports.selectorChartsInteractionXAxisIndex = exports.selectorChartsInteractionXAxis = void 0;
6
+ exports.selectorChartsInteractionYAxisValues = exports.selectorChartsInteractionYAxisValue = exports.selectorChartsInteractionYAxisIndexes = exports.selectorChartsInteractionYAxisIndex = exports.selectorChartsInteractionXAxisValues = exports.selectorChartsInteractionXAxisValue = exports.selectorChartsInteractionXAxisIndexes = exports.selectorChartsInteractionXAxisIndex = exports.selectorChartsInteractionTooltipYAxes = exports.selectorChartsInteractionTooltipXAxes = exports.selectorChartsInteractionAxisTooltip = void 0;
7
7
  var _selectors = require("../../utils/selectors");
8
8
  var _useChartInteraction = require("../useChartInteraction/useChartInteraction.selectors");
9
9
  var _getAxisValue = require("./getAxisValue");
10
10
  var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.selectors");
11
- const selectorChartsInteractionXAxisIndex = exports.selectorChartsInteractionXAxisIndex = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis], (x, xAxes) => {
12
- if (x === null || !xAxes.axis[xAxes.axisIds[0]]) {
11
+ const optionalGetAxisId = (_, id) => id;
12
+ const optionalGetAxisIds = (_, ids) => ids;
13
+
14
+ /**
15
+ * Get interaction indexes
16
+ */
17
+
18
+ function indexGetter(value, axes, ids = axes.axisIds[0]) {
19
+ return Array.isArray(ids) ? ids.map(id => (0, _getAxisValue.getAxisIndex)(axes.axis[id], value)) : (0, _getAxisValue.getAxisIndex)(axes.axis[ids], value);
20
+ }
21
+ const selectorChartsInteractionXAxisIndex = exports.selectorChartsInteractionXAxisIndex = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis, optionalGetAxisId], (value, axes, id) => value === null ? null : indexGetter(value, axes, id));
22
+ const selectorChartsInteractionXAxisIndexes = exports.selectorChartsInteractionXAxisIndexes = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis, optionalGetAxisIds], (value, axes, ids) => value === null ? null : indexGetter(value, axes, ids));
23
+ const selectorChartsInteractionYAxisIndex = exports.selectorChartsInteractionYAxisIndex = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerY, _useChartCartesianAxisRendering.selectorChartYAxis, optionalGetAxisId], (value, axes, id) => value === null ? null : indexGetter(value, axes, id));
24
+ const selectorChartsInteractionYAxisIndexes = exports.selectorChartsInteractionYAxisIndexes = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerY, _useChartCartesianAxisRendering.selectorChartYAxis, optionalGetAxisIds], (value, axes, ids) => value === null ? null : indexGetter(value, axes, ids));
25
+
26
+ /**
27
+ * Get interaction values
28
+ */
29
+
30
+ function valueGetter(value, axes, indexes, ids = axes.axisIds[0]) {
31
+ return Array.isArray(ids) ? ids.map((id, axisIndex) => (0, _getAxisValue.getAxisValue)(axes.axis[id], value, indexes[axisIndex])) : (0, _getAxisValue.getAxisValue)(axes.axis[ids], value, indexes);
32
+ }
33
+ const selectorChartsInteractionXAxisValues = exports.selectorChartsInteractionXAxisValues = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartsInteractionXAxisIndexes, optionalGetAxisIds], (value, axes, indexes, ids) => value === null ? null : valueGetter(value, axes, indexes, ids));
34
+ const selectorChartsInteractionXAxisValue = exports.selectorChartsInteractionXAxisValue = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartsInteractionXAxisIndex, optionalGetAxisId], (x, xAxes, xIndex, id) => {
35
+ if (x === null || xIndex === null || xAxes.axisIds.length === 0) {
13
36
  return null;
14
37
  }
15
- return (0, _getAxisValue.getAxisIndex)(xAxes.axis[xAxes.axisIds[0]], x);
38
+ return valueGetter(x, xAxes, xIndex, id);
16
39
  });
17
- const selectorChartsInteractionXAxisValue = exports.selectorChartsInteractionXAxisValue = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartsInteractionXAxisIndex], (x, xAxes, xIndex) => {
18
- if (x === null || xIndex === null || !xAxes.axis[xAxes.axisIds[0]]) {
40
+ const selectorChartsInteractionYAxisValues = exports.selectorChartsInteractionYAxisValues = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerY, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartsInteractionYAxisIndexes, optionalGetAxisIds], (value, axes, indexes, ids) => value === null ? null : valueGetter(value, axes, indexes, ids));
41
+ const selectorChartsInteractionYAxisValue = exports.selectorChartsInteractionYAxisValue = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerY, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartsInteractionYAxisIndex, optionalGetAxisId], (y, yAxes, yIndex, id) => {
42
+ if (y === null || yIndex === null || yAxes.axisIds.length === 0) {
19
43
  return null;
20
44
  }
21
- return (0, _getAxisValue.getAxisValue)(xAxes.axis[xAxes.axisIds[0]], x, xIndex);
45
+ return valueGetter(y, yAxes, yIndex, id);
22
46
  });
23
- const selectorChartsInteractionYAxisIndex = exports.selectorChartsInteractionYAxisIndex = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerY, _useChartCartesianAxisRendering.selectorChartYAxis], (y, yAxes) => {
24
- if (y === null || !yAxes.axis[yAxes.axisIds[0]]) {
25
- return null;
47
+
48
+ /**
49
+ * Get x-axis ids and corresponding data index that should be display in the tooltip.
50
+ */
51
+ const selectorChartsInteractionTooltipXAxes = exports.selectorChartsInteractionTooltipXAxes = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerX, _useChartCartesianAxisRendering.selectorChartXAxis], (value, axes) => {
52
+ if (value === null) {
53
+ return [];
26
54
  }
27
- return (0, _getAxisValue.getAxisIndex)(yAxes.axis[yAxes.axisIds[0]], y);
55
+ return axes.axisIds.filter(id => axes.axis[id].triggerTooltip).map(axisId => ({
56
+ axisId,
57
+ dataIndex: (0, _getAxisValue.getAxisIndex)(axes.axis[axisId], value)
58
+ })).filter(({
59
+ dataIndex
60
+ }) => dataIndex >= 0);
28
61
  });
29
- const selectorChartsInteractionYAxisValue = exports.selectorChartsInteractionYAxisValue = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerY, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartsInteractionYAxisIndex], (y, yAxes, yIndex) => {
30
- if (y === null || yIndex === null || !yAxes.axis[yAxes.axisIds[0]]) {
31
- return null;
62
+
63
+ /**
64
+ * Get y-axis ids and corresponding data index that should be display in the tooltip.
65
+ */
66
+ const selectorChartsInteractionTooltipYAxes = exports.selectorChartsInteractionTooltipYAxes = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsInteractionPointerY, _useChartCartesianAxisRendering.selectorChartYAxis], (value, axes) => {
67
+ if (value === null) {
68
+ return [];
32
69
  }
33
- return (0, _getAxisValue.getAxisValue)(yAxes.axis[yAxes.axisIds[0]], y, yIndex);
34
- });
35
- // TODO: probably remove in favor of the two more specific.
36
- const selectorChartsInteractionXAxis = exports.selectorChartsInteractionXAxis = (0, _selectors.createSelector)([selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue], (index, value) => index === null || value === null ? null : {
37
- index,
38
- value
39
- });
40
- const selectorChartsInteractionYAxis = exports.selectorChartsInteractionYAxis = (0, _selectors.createSelector)([selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue], (index, value) => index === null || value === null ? null : {
41
- index,
42
- value
70
+ return axes.axisIds.filter(id => axes.axis[id].triggerTooltip).map(axisId => ({
71
+ axisId,
72
+ dataIndex: (0, _getAxisValue.getAxisIndex)(axes.axis[axisId], value)
73
+ })).filter(({
74
+ dataIndex
75
+ }) => dataIndex >= 0);
43
76
  });
44
77
 
45
- // TODO: probably remove in favor of the two more specific.
46
- const selectorChartsInteractionXAxisIsDefined = exports.selectorChartsInteractionXAxisIsDefined = (0, _selectors.createSelector)([selectorChartsInteractionXAxisIndex], index => index !== null && index >= 0);
47
- const selectorChartsInteractionYAxisIsDefined = exports.selectorChartsInteractionYAxisIsDefined = (0, _selectors.createSelector)([selectorChartsInteractionYAxisIndex], index => index !== null && index >= 0);
78
+ /**
79
+ * Return `true` if the axis tooltip has something to display.
80
+ */
81
+ const selectorChartsInteractionAxisTooltip = exports.selectorChartsInteractionAxisTooltip = (0, _selectors.createSelector)([selectorChartsInteractionTooltipXAxes, selectorChartsInteractionTooltipYAxes], (xTooltip, yTooltip) => xTooltip.length > 0 || yTooltip.length > 0);
@@ -3,7 +3,7 @@ import type { CartesianChartSeriesType, ChartSeriesType, PolarChartSeriesType }
3
3
  import type { ColorProcessor } from './colorProcessor.types';
4
4
  import type { CartesianExtremumGetter } from './cartesianExtremumGetter.types';
5
5
  import type { LegendGetter } from './legendGetter.types';
6
- import type { TooltipGetter } from './tooltipGetter.types';
6
+ import type { AxisTooltipGetter, TooltipGetter } from './tooltipGetter.types';
7
7
  import { PolarExtremumGetter } from "./polarExtremumGetter.types.js";
8
8
  import { GetSeriesWithDefaultValues } from "./getSeriesWithDefaultValues.types.js";
9
9
  export type ChartSeriesTypeConfig<TSeriesType extends ChartSeriesType> = {
@@ -15,8 +15,10 @@ export type ChartSeriesTypeConfig<TSeriesType extends ChartSeriesType> = {
15
15
  } & (TSeriesType extends CartesianChartSeriesType ? {
16
16
  xExtremumGetter: CartesianExtremumGetter<TSeriesType>;
17
17
  yExtremumGetter: CartesianExtremumGetter<TSeriesType>;
18
+ axisTooltipGetter?: AxisTooltipGetter<TSeriesType, 'x' | 'y'>;
18
19
  } : {}) & (TSeriesType extends PolarChartSeriesType ? {
19
20
  rotationExtremumGetter: PolarExtremumGetter<TSeriesType>;
20
21
  radiusExtremumGetter: PolarExtremumGetter<TSeriesType>;
22
+ axisTooltipGetter?: AxisTooltipGetter<TSeriesType, 'rotation' | 'radius'>;
21
23
  } : {});
22
24
  export type ChartSeriesConfig<TSeriesType extends ChartSeriesType> = { [Key in TSeriesType]: ChartSeriesTypeConfig<Key> };
@@ -1,7 +1,13 @@
1
1
  import type { ItemTooltip } from '../../../../ChartsTooltip';
2
2
  import type { ChartItemIdentifier, ChartSeriesDefaultized, ChartSeriesType } from '../../../../models/seriesType/config';
3
- export type TooltipGetter<T extends ChartSeriesType> = (params: {
4
- series: ChartSeriesDefaultized<T>;
3
+ import { SeriesId } from "../../../../models/seriesType/common.js";
4
+ import { AxisId } from "../../../../models/axis.js";
5
+ export type TooltipGetter<TSeriesType extends ChartSeriesType> = (params: {
6
+ series: ChartSeriesDefaultized<TSeriesType>;
5
7
  getColor: (dataIndex: number) => string;
6
- identifier: ChartItemIdentifier<T> | null;
7
- }) => ItemTooltip<T> | null;
8
+ identifier: ChartItemIdentifier<TSeriesType> | null;
9
+ }) => ItemTooltip<TSeriesType> | null;
10
+ export type AxisTooltipGetter<TSeriesType extends ChartSeriesType, Directions extends 'x' | 'y' | 'rotation' | 'radius' = 'x' | 'y'> = (series: Record<SeriesId, ChartSeriesDefaultized<TSeriesType>>) => {
11
+ direction: Directions;
12
+ axisId: AxisId | undefined;
13
+ }[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Performs equality by iterating through keys on an object and returning false
3
+ * when any key has values which are not strictly equal between the arguments.
4
+ * Returns true when the values of all keys are strictly equal.
5
+ *
6
+ * Source: https://github.com/facebook/react/blob/c2a196174763e0b4f16ed1c512ed4442b062395e/packages/shared/shallowEqual.js#L18
7
+ */
8
+ export declare function shallowEqual(objA: unknown, objB: unknown): boolean;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shallowEqual = shallowEqual;
7
+ /**
8
+ * Performs equality by iterating through keys on an object and returning false
9
+ * when any key has values which are not strictly equal between the arguments.
10
+ * Returns true when the values of all keys are strictly equal.
11
+ *
12
+ * Source: https://github.com/facebook/react/blob/c2a196174763e0b4f16ed1c512ed4442b062395e/packages/shared/shallowEqual.js#L18
13
+ */
14
+ function shallowEqual(objA, objB) {
15
+ if (Object.is(objA, objB)) {
16
+ return true;
17
+ }
18
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
19
+ return false;
20
+ }
21
+ const keysA = Object.keys(objA);
22
+ const keysB = Object.keys(objB);
23
+ if (keysA.length !== keysB.length) {
24
+ return false;
25
+ }
26
+
27
+ // Test for A's keys different from B.
28
+ for (let i = 0; i < keysA.length; i += 1) {
29
+ const currentKey = keysA[i];
30
+ if (!Object.prototype.hasOwnProperty.call(objB, currentKey) ||
31
+ // @ts-ignore
32
+ !Object.is(objA[currentKey], objB[currentKey])) {
33
+ return false;
34
+ }
35
+ }
36
+ return true;
37
+ }
package/models/axis.d.ts CHANGED
@@ -335,6 +335,10 @@ type CommonAxisConfig<S extends ScaleName = ScaleName, V = any> = {
335
335
  min: number;
336
336
  max: number;
337
337
  });
338
+ /**
339
+ * If `true`, the axis will be ignored by the tooltip with `trigger='axis'`.
340
+ */
341
+ ignoreTooltip?: boolean;
338
342
  };
339
343
  export type PolarAxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps extends ChartsAxisProps = ChartsRotationAxisProps | ChartsRadiusAxisProps> = {
340
344
  /**
@@ -361,6 +365,10 @@ export type AxisDefaultized<S extends ScaleName = ScaleName, V = any, AxisProps
361
365
  * An indication of the expected number of ticks.
362
366
  */
363
367
  tickNumber: number;
368
+ /**
369
+ * Indicate if the axis should be consider by a tooltip with `trigger='axis'`.
370
+ */
371
+ triggerTooltip?: boolean;
364
372
  } & (AxisProps extends ChartsXAxisProps ? MakeRequired<AxisSideConfig<AxisProps>, 'height'> : AxisProps extends ChartsYAxisProps ? MakeRequired<AxisSideConfig<AxisProps>, 'width'> : AxisSideConfig<AxisProps>);
365
373
  export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'band'> & {
366
374
  scaleType: 'band';
@@ -1,12 +1,42 @@
1
1
  import * as React from 'react';
2
- import { AnimatedProps } from '@react-spring/web';
3
- import type { BarElementOwnerState } from './BarElement';
4
- export interface BarProps extends Omit<React.SVGProps<SVGRectElement>, 'id' | 'color' | 'ref' | 'x' | 'y' | 'height' | 'width'>, AnimatedProps<{
5
- x?: string | number | undefined;
6
- y?: string | number | undefined;
7
- height?: string | number | undefined;
8
- width?: string | number | undefined;
9
- }> {
2
+ import { SeriesId } from "../models/seriesType/common.js";
3
+ import { BarElementOwnerState } from "./barElementClasses.js";
4
+ export interface BarProps extends Omit<React.SVGProps<SVGRectElement>, 'id' | 'color' | 'ref' | 'x' | 'y' | 'height' | 'width'> {
5
+ id: SeriesId;
6
+ dataIndex: number;
7
+ color: string;
10
8
  ownerState: BarElementOwnerState;
9
+ /**
10
+ * The position in the x-axis of the stack this bar belongs to.
11
+ */
12
+ xOrigin: number;
13
+ /**
14
+ * The position in the y-axis of the stack this bar belongs to.
15
+ */
16
+ yOrigin: number;
17
+ /**
18
+ * The position of the bar in the x-axis.
19
+ */
20
+ x: number;
21
+ /**
22
+ * The position of the bar in the y-axis.
23
+ */
24
+ y: number;
25
+ /**
26
+ * The height of the bar.
27
+ */
28
+ height: number;
29
+ /**
30
+ * The width of the bar.
31
+ */
32
+ width: number;
33
+ /**
34
+ * The orientation of the bar.
35
+ */
36
+ layout: 'vertical' | 'horizontal';
37
+ /**
38
+ * If true, no animations should be applied.
39
+ */
40
+ skipAnimation: boolean;
11
41
  }
12
42
  export declare function AnimatedBarElement(props: BarProps): React.JSX.Element;
@@ -2,18 +2,18 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["ownerState"];
5
+ const _excluded = ["ownerState", "skipAnimation", "id", "dataIndex", "xOrigin", "yOrigin"];
6
6
  import * as React from 'react';
7
- import { animated } from '@react-spring/web';
7
+ import { useAnimateBar } from "../hooks/animation/useAnimateBar.js";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export function AnimatedBarElement(props) {
10
10
  const {
11
11
  ownerState
12
12
  } = props,
13
13
  other = _objectWithoutPropertiesLoose(props, _excluded);
14
- return /*#__PURE__*/_jsx(animated.rect, _extends({}, other, {
15
- // @ts-expect-error
14
+ const animatedProps = useAnimateBar(props);
15
+ return /*#__PURE__*/_jsx("rect", _extends({}, other, {
16
16
  filter: ownerState.isHighlighted ? 'brightness(120%)' : undefined,
17
17
  opacity: ownerState.isFaded ? 0.3 : 1
18
- }));
18
+ }, animatedProps));
19
19
  }
@@ -238,6 +238,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
238
238
  height: PropTypes.number,
239
239
  hideTooltip: PropTypes.bool,
240
240
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
241
+ ignoreTooltip: PropTypes.bool,
241
242
  label: PropTypes.string,
242
243
  labelStyle: PropTypes.object,
243
244
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
@@ -293,6 +294,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
293
294
  fill: PropTypes.string,
294
295
  hideTooltip: PropTypes.bool,
295
296
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
297
+ ignoreTooltip: PropTypes.bool,
296
298
  label: PropTypes.string,
297
299
  labelStyle: PropTypes.object,
298
300
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
@@ -1,11 +1,29 @@
1
1
  import * as React from 'react';
2
+ import { GetRadiusData } from "./getRadius.js";
3
+ type UseAnimateBarClipRectParams = Pick<BarClipRectProps, 'x' | 'y' | 'width' | 'height' | 'skipAnimation'> & {
4
+ ref?: React.Ref<SVGRectElement>;
5
+ borderRadius: number;
6
+ ownerState: Omit<GetRadiusData, 'borderRadius'>;
7
+ };
8
+ type UseAnimateBarClipRectReturn = {
9
+ ref: React.Ref<SVGRectElement>;
10
+ style: React.CSSProperties;
11
+ } & Pick<BarClipRectProps, 'x' | 'y' | 'width' | 'height'>;
12
+ export declare function useAnimateBarClipRect(props: UseAnimateBarClipRectParams): UseAnimateBarClipRectReturn;
13
+ interface BarClipRectProps extends Pick<BarClipPathProps, 'x' | 'y' | 'width' | 'height' | 'skipAnimation'> {
14
+ ownerState: GetRadiusData;
15
+ }
2
16
  export interface BarClipPathProps {
3
17
  maskId: string;
4
18
  borderRadius?: number;
5
19
  hasNegative: boolean;
6
20
  hasPositive: boolean;
7
21
  layout?: 'vertical' | 'horizontal';
8
- style: {};
22
+ x: number;
23
+ y: number;
24
+ width: number;
25
+ height: number;
26
+ skipAnimation: boolean;
9
27
  }
10
28
  /**
11
29
  * @ignore - internal component.
@@ -1,31 +1,94 @@
1
+ 'use client';
2
+
1
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
4
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["style", "maskId"];
5
+ const _excluded = ["maskId", "x", "y", "width", "height", "skipAnimation"];
4
6
  import * as React from 'react';
5
- import { animated } from '@react-spring/web';
7
+ import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
8
+ import { useAnimate } from "../internals/animation/useAnimate.js";
6
9
  import { getRadius } from "./getRadius.js";
7
10
  import { jsx as _jsx } from "react/jsx-runtime";
8
- const buildInset = corners => `inset(0px round ${corners.topLeft}px ${corners.topRight}px ${corners.bottomRight}px ${corners.bottomLeft}px)`;
9
- function BarClipRect(props) {
10
- const radiusData = props.ownerState;
11
- return /*#__PURE__*/_jsx(animated.rect, {
12
- style: _extends({}, props.style, {
13
- clipPath: (props.ownerState.layout === 'vertical' ? props.style?.height : props.style?.width).to(value => buildInset({
14
- topLeft: Math.min(value, getRadius('top-left', radiusData)),
15
- topRight: Math.min(value, getRadius('top-right', radiusData)),
16
- bottomRight: Math.min(value, getRadius('bottom-right', radiusData)),
17
- bottomLeft: Math.min(value, getRadius('bottom-left', radiusData))
18
- }))
19
- })
11
+ function buildClipPath(size, borderRadius, ownerState) {
12
+ const radiusData = _extends({}, ownerState, {
13
+ borderRadius
20
14
  });
15
+ const topLeft = Math.min(size, getRadius('top-left', radiusData));
16
+ const topRight = Math.min(size, getRadius('top-right', radiusData));
17
+ const bottomRight = Math.min(size, getRadius('bottom-right', radiusData));
18
+ const bottomLeft = Math.min(size, getRadius('bottom-left', radiusData));
19
+ return `inset(0px round ${topLeft}px ${topRight}px ${bottomRight}px ${bottomLeft}px)`;
20
+ }
21
+ function barClipRectPropsInterpolator(from, to) {
22
+ const interpolateX = interpolateNumber(from.x, to.x);
23
+ const interpolateY = interpolateNumber(from.y, to.y);
24
+ const interpolateWidth = interpolateNumber(from.width, to.width);
25
+ const interpolateHeight = interpolateNumber(from.height, to.height);
26
+ const interpolateBorderRadius = interpolateNumber(from.borderRadius, to.borderRadius);
27
+ return t => {
28
+ return {
29
+ x: interpolateX(t),
30
+ y: interpolateY(t),
31
+ width: interpolateWidth(t),
32
+ height: interpolateHeight(t),
33
+ borderRadius: interpolateBorderRadius(t)
34
+ };
35
+ };
36
+ }
37
+ export function useAnimateBarClipRect(props) {
38
+ const initialProps = {
39
+ x: props.x,
40
+ y: props.y + (props.ownerState.layout === 'vertical' ? props.height : 0),
41
+ width: props.ownerState.layout === 'vertical' ? props.width : 0,
42
+ height: props.ownerState.layout === 'vertical' ? 0 : props.height,
43
+ borderRadius: props.borderRadius
44
+ };
45
+ const ref = useAnimate({
46
+ x: props.x,
47
+ y: props.y,
48
+ width: props.width,
49
+ height: props.height,
50
+ borderRadius: props.borderRadius
51
+ }, {
52
+ createInterpolator: barClipRectPropsInterpolator,
53
+ applyProps(element, animatedProps) {
54
+ element.setAttribute('x', animatedProps.x.toString());
55
+ element.setAttribute('y', animatedProps.y.toString());
56
+ element.setAttribute('width', animatedProps.width.toString());
57
+ element.setAttribute('height', animatedProps.height.toString());
58
+ element.style.clipPath = buildClipPath(props.ownerState.layout === 'vertical' ? animatedProps.height : animatedProps.width, animatedProps.borderRadius, props.ownerState);
59
+ },
60
+ initialProps,
61
+ skip: props.skipAnimation
62
+ });
63
+ const usedProps = props.skipAnimation ? props : initialProps;
64
+ return {
65
+ ref,
66
+ x: usedProps.x,
67
+ y: usedProps.y,
68
+ width: usedProps.width,
69
+ height: usedProps.height,
70
+ style: {
71
+ clipPath: buildClipPath(props.ownerState.layout === 'vertical' ? usedProps.height : usedProps.width, usedProps.borderRadius, props.ownerState)
72
+ }
73
+ };
74
+ }
75
+ function BarClipRect(props) {
76
+ const animatedProps = useAnimateBarClipRect(_extends({}, props, {
77
+ borderRadius: props.ownerState.borderRadius ?? 0
78
+ }));
79
+ return /*#__PURE__*/_jsx("rect", _extends({}, animatedProps));
21
80
  }
22
81
  /**
23
82
  * @ignore - internal component.
24
83
  */
25
84
  function BarClipPath(props) {
26
85
  const {
27
- style,
28
- maskId
86
+ maskId,
87
+ x,
88
+ y,
89
+ width,
90
+ height,
91
+ skipAnimation
29
92
  } = props,
30
93
  rest = _objectWithoutPropertiesLoose(props, _excluded);
31
94
  if (!props.borderRadius || props.borderRadius <= 0) {
@@ -35,7 +98,11 @@ function BarClipPath(props) {
35
98
  id: maskId,
36
99
  children: /*#__PURE__*/_jsx(BarClipRect, {
37
100
  ownerState: rest,
38
- style: style
101
+ x: x,
102
+ y: y,
103
+ width: width,
104
+ height: height,
105
+ skipAnimation: skipAnimation
39
106
  })
40
107
  });
41
108
  }
@@ -1,26 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
3
- import { SeriesId } from "../models/seriesType/common.js";
3
+ import { BarElementOwnerState } from "./barElementClasses.js";
4
4
  import { BarProps } from "./AnimatedBarElement.js";
5
- export interface BarElementClasses {
6
- /** Styles applied to the root element. */
7
- root: string;
8
- /** Styles applied to the root element if it is highlighted. */
9
- highlighted: string;
10
- /** Styles applied to the root element if it is faded. */
11
- faded: string;
12
- }
13
- export type BarElementClassKey = keyof BarElementClasses;
14
- export interface BarElementOwnerState {
15
- id: SeriesId;
16
- dataIndex: number;
17
- color: string;
18
- isFaded: boolean;
19
- isHighlighted: boolean;
20
- classes?: Partial<BarElementClasses>;
21
- }
22
- export declare function getBarElementUtilityClass(slot: string): string;
23
- export declare const barElementClasses: BarElementClasses;
24
5
  export interface BarElementSlots {
25
6
  /**
26
7
  * The component that renders the bar.
@@ -42,6 +23,14 @@ export type BarElementProps = Omit<BarElementOwnerState, 'isFaded' | 'isHighligh
42
23
  * @default {}
43
24
  */
44
25
  slots?: BarElementSlots;
26
+ x: number;
27
+ xOrigin: number;
28
+ y: number;
29
+ yOrigin: number;
30
+ width: number;
31
+ height: number;
32
+ layout: 'horizontal' | 'vertical';
33
+ skipAnimation: boolean;
45
34
  };
46
35
  declare function BarElement(props: BarElementProps): React.JSX.Element;
47
36
  declare namespace BarElement {
@@ -2,33 +2,15 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["id", "dataIndex", "classes", "color", "slots", "slotProps", "style", "onClick"];
5
+ const _excluded = ["id", "dataIndex", "classes", "color", "slots", "slotProps", "style", "onClick", "skipAnimation", "layout", "x", "xOrigin", "y", "yOrigin", "width", "height"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import composeClasses from '@mui/utils/composeClasses';
9
8
  import useSlotProps from '@mui/utils/useSlotProps';
10
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
11
- import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
9
+ import { useUtilityClasses } from "./barElementClasses.js";
12
10
  import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
13
11
  import { useItemHighlighted } from "../hooks/useItemHighlighted.js";
14
12
  import { AnimatedBarElement } from "./AnimatedBarElement.js";
15
13
  import { jsx as _jsx } from "react/jsx-runtime";
16
- export function getBarElementUtilityClass(slot) {
17
- return generateUtilityClass('MuiBarElement', slot);
18
- }
19
- export const barElementClasses = generateUtilityClasses('MuiBarElement', ['root', 'highlighted', 'faded']);
20
- const useUtilityClasses = ownerState => {
21
- const {
22
- classes,
23
- id,
24
- isHighlighted,
25
- isFaded
26
- } = ownerState;
27
- const slots = {
28
- root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
29
- };
30
- return composeClasses(slots, getBarElementUtilityClass, classes);
31
- };
32
14
  function BarElement(props) {
33
15
  const {
34
16
  id,
@@ -38,7 +20,15 @@ function BarElement(props) {
38
20
  slots,
39
21
  slotProps,
40
22
  style,
41
- onClick
23
+ onClick,
24
+ skipAnimation,
25
+ layout,
26
+ x,
27
+ xOrigin,
28
+ y,
29
+ yOrigin,
30
+ width,
31
+ height
42
32
  } = props,
43
33
  other = _objectWithoutPropertiesLoose(props, _excluded);
44
34
  const interactionProps = useInteractionItemProps({
@@ -68,11 +58,22 @@ function BarElement(props) {
68
58
  externalSlotProps: slotProps?.bar,
69
59
  externalForwardedProps: other,
70
60
  additionalProps: _extends({}, interactionProps, {
61
+ id,
62
+ dataIndex,
63
+ color,
64
+ x,
65
+ xOrigin,
66
+ y,
67
+ yOrigin,
68
+ width,
69
+ height,
71
70
  style,
72
71
  onClick,
73
72
  cursor: onClick ? 'pointer' : 'unset',
74
73
  stroke: 'none',
75
- fill: color
74
+ fill: color,
75
+ skipAnimation,
76
+ layout
76
77
  }),
77
78
  className: classes.root,
78
79
  ownerState
@@ -87,6 +88,8 @@ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
87
88
  classes: PropTypes.object,
88
89
  dataIndex: PropTypes.number.isRequired,
89
90
  id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
91
+ layout: PropTypes.oneOf(['horizontal', 'vertical']).isRequired,
92
+ skipAnimation: PropTypes.bool.isRequired,
90
93
  /**
91
94
  * The props used for each component slot.
92
95
  * @default {}
@@ -96,6 +99,8 @@ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
96
99
  * Overridable component slots.
97
100
  * @default {}
98
101
  */
99
- slots: PropTypes.object
102
+ slots: PropTypes.object,
103
+ xOrigin: PropTypes.number.isRequired,
104
+ yOrigin: PropTypes.number.isRequired
100
105
  } : void 0;
101
106
  export { BarElement };