vccs 0.1.0 → 0.3.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 (273) hide show
  1. package/README.md +151 -0
  2. package/dist/animation/Animate.d.ts +1 -1
  3. package/dist/cartesian/area/type.d.ts +3 -3
  4. package/dist/cartesian/bar/type.d.ts +1 -13
  5. package/dist/cartesian/brush/components/Slide.d.ts +1 -1
  6. package/dist/cartesian/brush/components/TravellerLayer.d.ts +1 -1
  7. package/dist/cartesian/brush/type.d.ts +2 -1
  8. package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +2 -1
  9. package/dist/cartesian/funnel/Funnel.d.ts +2 -0
  10. package/dist/cartesian/funnel/index.d.ts +2 -0
  11. package/dist/cartesian/funnel/type.d.ts +74 -6
  12. package/dist/cartesian/index.d.ts +2 -0
  13. package/dist/cartesian/line/Line.d.ts +7 -13
  14. package/dist/cartesian/line/type.d.ts +4 -17
  15. package/dist/cartesian/reference-area/ReferenceArea.d.ts +16 -16
  16. package/dist/cartesian/reference-dot/ReferenceDot.d.ts +143 -0
  17. package/dist/cartesian/reference-dot/index.d.ts +2 -0
  18. package/dist/cartesian/reference-line/ReferenceLine.d.ts +8 -8
  19. package/dist/cartesian/scatter/Scatter.d.ts +1 -1
  20. package/dist/chart/FunnelChart.d.ts +1 -0
  21. package/dist/chart/RechartsWrapper.d.ts +7 -3
  22. package/dist/chart/Surface.d.ts +2 -1
  23. package/dist/chart/Treemap.d.ts +237 -0
  24. package/dist/chart/generateCategoricalChart.d.ts +2 -1
  25. package/dist/chart/index.d.ts +2 -0
  26. package/dist/chart/treemapUtils.d.ts +22 -0
  27. package/dist/components/Customized.d.ts +23 -0
  28. package/dist/components/Text.d.ts +4 -4
  29. package/dist/components/Tooltip.d.ts +1 -1
  30. package/dist/components/index.d.ts +2 -0
  31. package/dist/components/label/Label.d.ts +3 -3
  32. package/dist/components/label/types.d.ts +1 -1
  33. package/dist/container/Surface.d.ts +3 -2
  34. package/dist/es/animation/Animate.mjs +48 -22
  35. package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
  36. package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
  37. package/dist/es/cartesian/area/Area.mjs +42 -31
  38. package/dist/es/cartesian/area/ClipRect.mjs +79 -58
  39. package/dist/es/cartesian/area/RenderArea.mjs +142 -108
  40. package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
  41. package/dist/es/cartesian/area/type.mjs +13 -15
  42. package/dist/es/cartesian/area/utils.mjs +69 -49
  43. package/dist/es/cartesian/axis/XAxis.mjs +87 -73
  44. package/dist/es/cartesian/axis/YAxis.mjs +67 -56
  45. package/dist/es/cartesian/bar/Bar.mjs +78 -71
  46. package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
  47. package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
  48. package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
  49. package/dist/es/cartesian/bar/type.mjs +11 -25
  50. package/dist/es/cartesian/bar/utils.mjs +97 -70
  51. package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
  52. package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
  53. package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
  54. package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
  55. package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
  56. package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
  57. package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
  58. package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
  59. package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
  60. package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
  61. package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
  62. package/dist/es/cartesian/funnel/Funnel.mjs +162 -0
  63. package/dist/es/cartesian/funnel/type.mjs +78 -0
  64. package/dist/es/cartesian/funnel/utils.mjs +102 -0
  65. package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
  66. package/dist/es/cartesian/line/Line.mjs +41 -37
  67. package/dist/es/cartesian/line/StaticLine.mjs +191 -122
  68. package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
  69. package/dist/es/cartesian/line/type.mjs +13 -18
  70. package/dist/es/cartesian/line/utils.mjs +27 -26
  71. package/dist/es/cartesian/reference-area/ReferenceArea.mjs +79 -78
  72. package/dist/es/cartesian/reference-dot/ReferenceDot.mjs +134 -0
  73. package/dist/es/cartesian/reference-line/ReferenceLine.mjs +93 -84
  74. package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
  75. package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
  76. package/dist/es/cartesian/useNeedsClip.mjs +18 -9
  77. package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
  78. package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
  79. package/dist/es/chart/AreaChart.mjs +5 -5
  80. package/dist/es/chart/BarChart.mjs +5 -5
  81. package/dist/es/chart/ComposedChart.mjs +5 -5
  82. package/dist/es/chart/FunnelChart.mjs +11 -0
  83. package/dist/es/chart/LegendPortalContext.mjs +3 -3
  84. package/dist/es/chart/LineChart.mjs +5 -5
  85. package/dist/es/chart/PieChart.mjs +5 -5
  86. package/dist/es/chart/RadarChart.mjs +5 -5
  87. package/dist/es/chart/RadialBarChart.mjs +5 -5
  88. package/dist/es/chart/RechartsWrapper.mjs +113 -89
  89. package/dist/es/chart/ScatterChart.mjs +5 -5
  90. package/dist/es/chart/Surface.mjs +3 -3
  91. package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
  92. package/dist/es/chart/TooltipPortalContext.mjs +3 -3
  93. package/dist/es/chart/Treemap.mjs +379 -0
  94. package/dist/es/chart/const.mjs +2 -2
  95. package/dist/es/chart/generateCategoricalChart.mjs +99 -89
  96. package/dist/es/chart/provideClipPathId.mjs +12 -7
  97. package/dist/es/chart/treemapUtils.mjs +32 -0
  98. package/dist/es/components/Cell.mjs +16 -4
  99. package/dist/es/components/Customized.mjs +43 -0
  100. package/dist/es/components/Text.mjs +3 -3
  101. package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
  102. package/dist/es/components/Tooltip.mjs +274 -199
  103. package/dist/es/components/label/Label.mjs +30 -26
  104. package/dist/es/components/label/LabelList.mjs +45 -39
  105. package/dist/es/components/label/types.mjs +10 -6
  106. package/dist/es/components/label/utils.mjs +194 -162
  107. package/dist/es/components/legend/Legend.mjs +82 -71
  108. package/dist/es/components/legend/LegendSymbol.mjs +40 -38
  109. package/dist/es/components/legend/hooks/useLegend.mjs +71 -46
  110. package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
  111. package/dist/es/components/legend/type.mjs +2 -2
  112. package/dist/es/components/legend/utils.mjs +19 -11
  113. package/dist/es/components/utils.mjs +35 -22
  114. package/dist/es/container/ClipPath.mjs +14 -14
  115. package/dist/es/container/Layer.mjs +9 -7
  116. package/dist/es/container/ResponsiveContainer.mjs +3 -3
  117. package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
  118. package/dist/es/container/Surface.mjs +25 -23
  119. package/dist/es/container/useSizeContext.mjs +3 -3
  120. package/dist/es/context/ChartDataContextProvider.mjs +19 -13
  121. package/dist/es/context/PanoramaContextProvider.mjs +15 -10
  122. package/dist/es/context/accessibilityContext.mjs +3 -3
  123. package/dist/es/context/cartesianLabelListContext.mjs +3 -3
  124. package/dist/es/context/chartLayoutContext.mjs +33 -30
  125. package/dist/es/context/cursorLayerContext.mjs +3 -3
  126. package/dist/es/context/graphicalLayerContext.mjs +3 -3
  127. package/dist/es/context/labelLayerContext.mjs +3 -3
  128. package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
  129. package/dist/es/context/useTooltipAxis.mjs +14 -12
  130. package/dist/es/events/useChartSynchronisation.mjs +91 -66
  131. package/dist/es/hooks/publicHooks.mjs +207 -0
  132. package/dist/es/hooks/useIsAnimating.mjs +28 -0
  133. package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
  134. package/dist/es/index.mjs +54 -42
  135. package/dist/es/polar/pie/Pie.mjs +131 -115
  136. package/dist/es/polar/pie/type.mjs +8 -10
  137. package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
  138. package/dist/es/polar/radar/PolarGrid.mjs +72 -59
  139. package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
  140. package/dist/es/polar/radar/Radar.mjs +181 -145
  141. package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
  142. package/dist/es/polar/radial-bar/type.mjs +9 -9
  143. package/dist/es/shape/Cross.mjs +11 -10
  144. package/dist/es/shape/Curve.mjs +71 -44
  145. package/dist/es/shape/Dot.mjs +12 -11
  146. package/dist/es/shape/Polygon.mjs +19 -0
  147. package/dist/es/shape/Rectangle.mjs +41 -30
  148. package/dist/es/shape/Sector.mjs +105 -79
  149. package/dist/es/shape/Symbols.mjs +45 -34
  150. package/dist/es/shape/Trapezoid.mjs +50 -0
  151. package/dist/es/state/ReportChartProps.mjs +23 -24
  152. package/dist/es/state/ReportMainChartProps.mjs +26 -21
  153. package/dist/es/state/ReportPolarOptions.mjs +23 -22
  154. package/dist/es/state/SetGraphicalItem.mjs +42 -27
  155. package/dist/es/state/SetLegendPayload.mjs +17 -13
  156. package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
  157. package/dist/es/state/brushSlice.mjs +12 -8
  158. package/dist/es/state/cartesianAxisSlice.mjs +23 -17
  159. package/dist/es/state/chartDataSlice.mjs +18 -13
  160. package/dist/es/state/externalEventsMiddleware.mjs +25 -15
  161. package/dist/es/state/graphicalItemsSlice.mjs +29 -25
  162. package/dist/es/state/hooks.mjs +24 -3
  163. package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
  164. package/dist/es/state/layoutSlice.mjs +18 -12
  165. package/dist/es/state/legendSlice.mjs +19 -14
  166. package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
  167. package/dist/es/state/optionsSlice.mjs +14 -11
  168. package/dist/es/state/polarAxisSlice.mjs +15 -13
  169. package/dist/es/state/polarOptionsSlice.mjs +8 -6
  170. package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
  171. package/dist/es/state/referenceElementsSlice.mjs +21 -19
  172. package/dist/es/state/rootPropsSlice.mjs +20 -9
  173. package/dist/es/state/selectors/areaSelectors.mjs +65 -55
  174. package/dist/es/state/selectors/axisSelectors.mjs +784 -569
  175. package/dist/es/state/selectors/barSelectors.mjs +225 -162
  176. package/dist/es/state/selectors/brushSelectors.mjs +15 -14
  177. package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
  178. package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
  179. package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
  180. package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
  181. package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
  182. package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
  183. package/dist/es/state/selectors/common.mjs +2 -2
  184. package/dist/es/state/selectors/containerSelectors.mjs +5 -2
  185. package/dist/es/state/selectors/dataSelectors.mjs +28 -9
  186. package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
  187. package/dist/es/state/selectors/legendSelectors.mjs +7 -6
  188. package/dist/es/state/selectors/lineSelectors.mjs +54 -47
  189. package/dist/es/state/selectors/pickAxisId.mjs +2 -2
  190. package/dist/es/state/selectors/pickAxisType.mjs +2 -2
  191. package/dist/es/state/selectors/pieSelectors.mjs +116 -81
  192. package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
  193. package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
  194. package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
  195. package/dist/es/state/selectors/polarSelectors.mjs +79 -62
  196. package/dist/es/state/selectors/radarSelectors.mjs +111 -91
  197. package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
  198. package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
  199. package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
  200. package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
  201. package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
  202. package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
  203. package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
  204. package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
  205. package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
  206. package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
  207. package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
  208. package/dist/es/state/selectors/selectors.mjs +94 -75
  209. package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
  210. package/dist/es/state/selectors/touchSelectors.mjs +17 -14
  211. package/dist/es/state/store.mjs +46 -46
  212. package/dist/es/state/tooltipSlice.mjs +64 -37
  213. package/dist/es/state/touchEventsMiddleware.mjs +35 -29
  214. package/dist/es/state/utils/useReportScale.mjs +16 -13
  215. package/dist/es/synchronisation/syncSelectors.mjs +3 -3
  216. package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
  217. package/dist/es/types/common.mjs +12 -0
  218. package/dist/es/types/event.mjs +164 -2
  219. package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
  220. package/dist/es/utils/VueUtils.mjs +35 -14
  221. package/dist/es/utils/attrs.mjs +43 -26
  222. package/dist/es/utils/cartesian.mjs +47 -15
  223. package/dist/es/utils/cell.mjs +28 -0
  224. package/dist/es/utils/chart.mjs +298 -197
  225. package/dist/es/utils/const.mjs +30 -2
  226. package/dist/es/utils/createCategoricalInverse.mjs +46 -0
  227. package/dist/es/utils/createContext.mjs +28 -9
  228. package/dist/es/utils/data-utils.mjs +9 -8
  229. package/dist/es/utils/data.mjs +35 -21
  230. package/dist/es/utils/events.mjs +5 -3
  231. package/dist/es/utils/getLinearRegression.mjs +28 -11
  232. package/dist/es/utils/grid.mjs +20 -5
  233. package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
  234. package/dist/es/utils/legend.mjs +13 -12
  235. package/dist/es/utils/log.mjs +10 -7
  236. package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
  237. package/dist/es/utils/polar.mjs +37 -30
  238. package/dist/es/utils/props.mjs +16 -10
  239. package/dist/es/utils/resolveDefaultProps.mjs +23 -4
  240. package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
  241. package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
  242. package/dist/es/utils/scale/utils/utils.mjs +43 -24
  243. package/dist/es/utils/scale.mjs +46 -0
  244. package/dist/es/utils/style.mjs +24 -13
  245. package/dist/es/utils/tick.mjs +34 -23
  246. package/dist/es/utils/tooltip/translate.mjs +63 -49
  247. package/dist/es/utils/validate.mjs +40 -29
  248. package/dist/hooks/publicHooks.d.ts +143 -0
  249. package/dist/hooks/useIsAnimating.d.ts +14 -0
  250. package/dist/index.d.ts +1 -0
  251. package/dist/polar/pie/type.d.ts +2 -2
  252. package/dist/polar/radar/Radar.d.ts +4 -4
  253. package/dist/shape/Curve.d.ts +2 -1
  254. package/dist/shape/Polygon.d.ts +9 -0
  255. package/dist/shape/Rectangle.d.ts +0 -4
  256. package/dist/shape/Sector.d.ts +2 -2
  257. package/dist/shape/Symbols.d.ts +2 -1
  258. package/dist/shape/Trapezoid.d.ts +30 -0
  259. package/dist/shape/index.d.ts +2 -0
  260. package/dist/shape/types.d.ts +4 -5
  261. package/dist/state/ReportChartProps.d.ts +3 -3
  262. package/dist/state/graphicalItemsSlice.d.ts +1 -1
  263. package/dist/state/rootPropsSlice.d.ts +2 -2
  264. package/dist/state/selectors/axisSelectors.d.ts +5 -0
  265. package/dist/types/axis.d.ts +2 -2
  266. package/dist/types/bar.d.ts +2 -6
  267. package/dist/types/categorical.d.ts +2 -2
  268. package/dist/types/common.d.ts +7 -1
  269. package/dist/types/tooltip.d.ts +2 -2
  270. package/dist/utils/cell.d.ts +11 -0
  271. package/dist/utils/createCategoricalInverse.d.ts +16 -0
  272. package/dist/utils/scale.d.ts +23 -0
  273. package/package.json +2 -1
@@ -1,16 +1,17 @@
1
- import { defineComponent as e, onUnmounted as t, ref as n, watch as r } from "vue";
2
- import { animate as i } from "motion-v";
3
- import { usePreferredReducedMotion as a } from "@vueuse/core";
1
+ import { defineComponent, onUnmounted, ref, watch } from "vue";
2
+ import { animate } from "motion-v";
3
+ import { usePreferredReducedMotion } from "@vueuse/core";
4
4
  //#region src/animation/Animate.tsx
5
- var o = {
5
+ var DEFAULT_TRANSITION = {
6
6
  duration: .4,
7
7
  ease: "easeOut"
8
- }, s = /* @__PURE__ */ e({
8
+ };
9
+ var Animate = /* @__PURE__ */ defineComponent({
9
10
  name: "Animate",
10
11
  props: {
11
12
  isActive: {
12
13
  type: Boolean,
13
- default: !0
14
+ default: true
14
15
  },
15
16
  transition: {
16
17
  type: Object,
@@ -37,27 +38,52 @@ var o = {
37
38
  default: 1
38
39
  }
39
40
  },
40
- setup(e, { slots: s }) {
41
- let c = null, l = n(0), u = a(), d = () => {
42
- c && c.stop(), e.onAnimationStart && e.onAnimationStart(), c = i(e.from, e.to, {
43
- ...o,
44
- ...e.transition,
45
- onUpdate: (t) => {
46
- l.value = t, e.onUpdate && e.onUpdate(t);
41
+ setup(props, { slots }) {
42
+ let animationControls = null;
43
+ const currentValue = ref(0);
44
+ const reducedMotion = usePreferredReducedMotion();
45
+ const startAnimation = () => {
46
+ if (animationControls) animationControls.stop();
47
+ if (props.onAnimationStart) props.onAnimationStart();
48
+ animationControls = animate(props.from, props.to, {
49
+ ...DEFAULT_TRANSITION,
50
+ ...props.transition,
51
+ onUpdate: (latest) => {
52
+ currentValue.value = latest;
53
+ if (props.onUpdate) props.onUpdate(latest);
47
54
  },
48
55
  onComplete: () => {
49
- l.value = 1, e.onAnimationEnd && e.onAnimationEnd();
56
+ currentValue.value = 1;
57
+ if (props.onAnimationEnd) props.onAnimationEnd();
50
58
  }
51
59
  });
52
- }, f = () => {
53
- c &&= (c.stop(), null);
54
60
  };
55
- return r([() => e.isActive, u], ([t, n]) => {
56
- t ? n === "reduce" ? (f(), e.onAnimationStart && e.onAnimationStart(), l.value = e.to, e.onAnimationEnd && e.onAnimationEnd()) : d() : (f(), l.value = e.to);
57
- }, { immediate: !0 }), t(() => {
58
- f();
59
- }), () => s.default ? s.default(l.value) : null;
61
+ const stopAnimation = () => {
62
+ if (animationControls) {
63
+ animationControls.stop();
64
+ animationControls = null;
65
+ }
66
+ };
67
+ watch([() => props.isActive, reducedMotion], ([isActive, motion]) => {
68
+ if (isActive) if (motion === "reduce") {
69
+ stopAnimation();
70
+ if (props.onAnimationStart) props.onAnimationStart();
71
+ currentValue.value = props.to;
72
+ if (props.onAnimationEnd) props.onAnimationEnd();
73
+ } else startAnimation();
74
+ else {
75
+ stopAnimation();
76
+ currentValue.value = props.to;
77
+ }
78
+ }, { immediate: true });
79
+ onUnmounted(() => {
80
+ stopAnimation();
81
+ });
82
+ return () => {
83
+ if (!slots.default) return null;
84
+ return slots.default(currentValue.value);
85
+ };
60
86
  }
61
87
  });
62
88
  //#endregion
63
- export { s as Animate };
89
+ export { Animate };
@@ -1,8 +1,8 @@
1
- import { useOffset as e } from "../context/chartLayoutContext.mjs";
2
- import { useNeedsClip as t } from "./useNeedsClip.mjs";
3
- import { createVNode as n, defineComponent as r } from "vue";
1
+ import { useOffset } from "../context/chartLayoutContext.mjs";
2
+ import { useNeedsClip } from "./useNeedsClip.mjs";
3
+ import { createVNode, defineComponent } from "vue";
4
4
  //#region src/cartesian/GraphicalItemClipPath.tsx
5
- var i = /* @__PURE__ */ r({
5
+ var GraphicalItemClipPath = /* @__PURE__ */ defineComponent({
6
6
  name: "GraphicalItemClipPath",
7
7
  props: {
8
8
  xAxisId: {
@@ -15,22 +15,23 @@ var i = /* @__PURE__ */ r({
15
15
  },
16
16
  clipPathId: {
17
17
  type: String,
18
- required: !0
18
+ required: true
19
19
  }
20
20
  },
21
- setup(r) {
22
- let i = e(), { needClipX: a, needClipY: o, needClip: s } = t(r.xAxisId, r.yAxisId);
21
+ setup(props) {
22
+ const offset = useOffset();
23
+ const { needClipX, needClipY, needClip } = useNeedsClip(props.xAxisId, props.yAxisId);
23
24
  return () => {
24
- if (!s) return null;
25
- let { left: e, top: t, width: c, height: l } = i.value;
26
- return n("clipPath", { id: `clipPath-${r.clipPathId}` }, [n("rect", {
27
- x: a ? e : e - c / 2,
28
- y: o ? t : t - l / 2,
29
- width: a ? c : c * 2,
30
- height: o ? l : l * 2
25
+ if (!needClip) return null;
26
+ const { left, top, width, height } = offset.value;
27
+ return createVNode("clipPath", { "id": `clipPath-${props.clipPathId}` }, [createVNode("rect", {
28
+ "x": needClipX ? left : left - width / 2,
29
+ "y": needClipY ? top : top - height / 2,
30
+ "width": needClipX ? width : width * 2,
31
+ "height": needClipY ? height : height * 2
31
32
  }, null)]);
32
33
  };
33
34
  }
34
35
  });
35
36
  //#endregion
36
- export { i as GraphicalItemClipPath };
37
+ export { GraphicalItemClipPath };
@@ -1,23 +1,23 @@
1
- import { isNullish as e } from "../../utils/validate.mjs";
2
- import { selectActiveTooltipIndex as t } from "../../state/selectors/tooltipSelectors.mjs";
3
- import { useAppSelector as n } from "../../state/hooks.mjs";
4
- import { Layer as r } from "../../container/Layer.mjs";
5
- import { Dot as i } from "../../shape/Dot.mjs";
6
- import { createVNode as a, defineComponent as o, isVNode as s } from "vue";
1
+ import { isNullish } from "../../utils/validate.mjs";
2
+ import { selectActiveTooltipIndex } from "../../state/selectors/tooltipSelectors.mjs";
3
+ import { useAppSelector } from "../../state/hooks.mjs";
4
+ import { Layer } from "../../container/Layer.mjs";
5
+ import { Dot } from "../../shape/Dot.mjs";
6
+ import { createVNode, defineComponent, isVNode } from "vue";
7
7
  //#region src/cartesian/area/ActivePoints.tsx
8
- function c(e) {
9
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !s(e);
8
+ function _isSlot(s) {
9
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
10
10
  }
11
- var l = /* @__PURE__ */ o({
11
+ var ActivePoints = /* @__PURE__ */ defineComponent({
12
12
  name: "ActivePoints",
13
13
  props: {
14
14
  points: {
15
15
  type: Array,
16
- required: !0
16
+ required: true
17
17
  },
18
18
  mainColor: {
19
19
  type: String,
20
- required: !0
20
+ required: true
21
21
  },
22
22
  itemDataKey: {
23
23
  type: [
@@ -25,7 +25,7 @@ var l = /* @__PURE__ */ o({
25
25
  Number,
26
26
  Function
27
27
  ],
28
- required: !0
28
+ required: true
29
29
  },
30
30
  activeDot: {
31
31
  type: [
@@ -33,42 +33,46 @@ var l = /* @__PURE__ */ o({
33
33
  Boolean,
34
34
  Function
35
35
  ],
36
- required: !0
36
+ required: true
37
37
  }
38
38
  },
39
39
  slots: Object,
40
- setup(r, { slots: i }) {
41
- let a = n(t);
40
+ setup(props, { slots }) {
41
+ const activeTooltipIndex = useAppSelector(selectActiveTooltipIndex);
42
42
  return () => {
43
- let { points: t } = r;
44
- if (!t?.length || e(a.value)) return null;
45
- let n = t[Number(a.value)];
46
- return e(n) ? null : u({
47
- point: n,
48
- childIndex: Number(a.value),
49
- mainColor: r.mainColor,
50
- dataKey: r.itemDataKey,
51
- activeDot: r.activeDot,
52
- slots: i
43
+ const { points } = props;
44
+ if (!points?.length || isNullish(activeTooltipIndex.value)) return null;
45
+ const activePoint = points[Number(activeTooltipIndex.value)];
46
+ if (isNullish(activePoint)) return null;
47
+ return renderActivePoint({
48
+ point: activePoint,
49
+ childIndex: Number(activeTooltipIndex.value),
50
+ mainColor: props.mainColor,
51
+ dataKey: props.itemDataKey,
52
+ activeDot: props.activeDot,
53
+ slots
53
54
  });
54
55
  };
55
56
  }
56
57
  });
57
- function u({ point: e, childIndex: t, mainColor: n, activeDot: o, dataKey: s, slots: l }) {
58
- if (o === !1) return null;
59
- let u = {
60
- index: t,
61
- dataKey: s,
62
- cx: e.x,
63
- cy: e.y,
64
- r: 4,
65
- fill: n,
58
+ function renderActivePoint({ point, childIndex, mainColor, activeDot, dataKey, slots }) {
59
+ if (activeDot === false) return null;
60
+ const dotProps = {
61
+ "index": childIndex,
62
+ dataKey,
63
+ "cx": point.x,
64
+ "cy": point.y,
65
+ "r": 4,
66
+ "fill": mainColor,
66
67
  "stroke-width": 2,
67
- stroke: "#fff",
68
- payload: e.payload,
69
- value: e.value
70
- }, d;
71
- return d = l.activeDot ? l.activeDot(u) : a(i, u, null), a(r, { class: "v-charts-active-dot" }, c(d) ? d : { default: () => [d] });
68
+ "stroke": "#fff",
69
+ "payload": point.payload,
70
+ "value": point.value
71
+ };
72
+ let dot;
73
+ if (slots.activeDot) dot = slots.activeDot(dotProps);
74
+ else dot = createVNode(Dot, dotProps, null);
75
+ return createVNode(Layer, { "class": "v-charts-active-dot" }, _isSlot(dot) ? dot : { default: () => [dot] });
72
76
  }
73
77
  //#endregion
74
- export { l as ActivePoints };
78
+ export { ActivePoints };
@@ -1,41 +1,52 @@
1
- import { AreaVueProps as e } from "./type.mjs";
2
- import { useArea as t } from "./hooks/useArea.mjs";
3
- import { Layer as n } from "../../container/Layer.mjs";
4
- import { StaticArea as r } from "./RenderArea.mjs";
5
- import { ClipRect as i } from "./ClipRect.mjs";
6
- import { ActivePoints as a } from "./ActivePoints.mjs";
7
- import { useSetupGraphicalItem as o } from "../../hooks/useSetupGraphicalItem.mjs";
8
- import { useGraphicalLayerRef as s } from "../../context/graphicalLayerContext.mjs";
9
- import { Fragment as c, Teleport as l, createVNode as u, defineComponent as d, isVNode as f } from "vue";
1
+ import { AreaVueProps } from "./type.mjs";
2
+ import { useArea } from "./hooks/useArea.mjs";
3
+ import { Layer } from "../../container/Layer.mjs";
4
+ import { StaticArea } from "./RenderArea.mjs";
5
+ import { ClipRect } from "./ClipRect.mjs";
6
+ import { ActivePoints } from "./ActivePoints.mjs";
7
+ import { useSetupGraphicalItem } from "../../hooks/useSetupGraphicalItem.mjs";
8
+ import { useGraphicalLayerRef } from "../../context/graphicalLayerContext.mjs";
9
+ import { Fragment, Teleport, createVNode, defineComponent, isVNode } from "vue";
10
10
  //#region src/cartesian/area/Area.tsx
11
- function p(e) {
12
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
11
+ function _isSlot(s) {
12
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
13
13
  }
14
- var m = /* @__PURE__ */ d({
14
+ /**
15
+ * Type-safe Area component with slot types preserved in .d.ts output.
16
+ * The `new () => { $slots }` pattern ensures Volar picks up slot types
17
+ * even when consuming from compiled declarations.
18
+ */
19
+ var Area = /* @__PURE__ */ defineComponent({
15
20
  name: "Area",
16
- props: e,
17
- inheritAttrs: !1,
21
+ props: AreaVueProps,
22
+ inheritAttrs: false,
18
23
  slots: Object,
19
- setup(e, { attrs: d, slots: f }) {
20
- o(e, "area");
21
- let { shouldRender: m, areaData: g, points: _, clipPathId: v, shouldShowAnimation: y } = t(e, d, f.dot), b = s(null);
24
+ setup(props, { attrs, slots }) {
25
+ useSetupGraphicalItem(props, "area");
26
+ const { shouldRender, areaData, points, clipPathId, shouldShowAnimation } = useArea(props, attrs, slots.dot);
27
+ const graphicalLayerRef = useGraphicalLayerRef(null);
22
28
  return () => {
23
- let t;
24
- if (!m.value) return null;
25
- let o;
26
- f.activeDot && (o = { activeDot: f.activeDot });
27
- let s = u(c, null, [u(n, { class: ["v-charts-area", d.class] }, p(t = y.value ? u(n, { key: "area-with-animation" }, { default: () => [u("defs", null, [u("clipPath", { id: `animationClipPath-${v.value}` }, [u(i, null, null)])]), u(n, { "clip-path": `url(#animationClipPath-${v.value})` }, { default: () => [u(r, null, null)] })] }) : u(r, { key: "static-area" }, null)) ? t : { default: () => [t] }), u(a, {
28
- points: g.value?.points ?? [],
29
- mainColor: h(d.stroke, e.fill),
30
- itemDataKey: e.dataKey,
31
- activeDot: e.activeDot
32
- }, p(o) ? o : { default: () => [o] })]);
33
- return b?.value ? u(l, { to: b.value }, p(s) ? s : { default: () => [s] }) : s;
29
+ let _slot;
30
+ if (!shouldRender.value) return null;
31
+ let activeDot;
32
+ if (slots.activeDot) activeDot = { activeDot: slots.activeDot };
33
+ const renderAreaContent = () => {
34
+ if (shouldShowAnimation.value) return createVNode(Layer, { "key": "area-with-animation" }, { default: () => [createVNode("defs", null, [createVNode("clipPath", { "id": `animationClipPath-${clipPathId.value}` }, [createVNode(ClipRect, null, null)])]), createVNode(Layer, { "clip-path": `url(#animationClipPath-${clipPathId.value})` }, { default: () => [createVNode(StaticArea, null, null)] })] });
35
+ return createVNode(StaticArea, { "key": "static-area" }, null);
36
+ };
37
+ const areaContent = createVNode(Fragment, null, [createVNode(Layer, { "class": ["v-charts-area", attrs.class] }, _isSlot(_slot = renderAreaContent()) ? _slot : { default: () => [_slot] }), createVNode(ActivePoints, {
38
+ "points": areaData.value?.points ?? [],
39
+ "mainColor": getLegendItemColor(attrs.stroke, props.fill),
40
+ "itemDataKey": props.dataKey,
41
+ "activeDot": props.activeDot
42
+ }, _isSlot(activeDot) ? activeDot : { default: () => [activeDot] })]);
43
+ if (graphicalLayerRef?.value) return createVNode(Teleport, { "to": graphicalLayerRef.value }, _isSlot(areaContent) ? areaContent : { default: () => [areaContent] });
44
+ return areaContent;
34
45
  };
35
46
  }
36
47
  });
37
- function h(e, t) {
38
- return e && e !== "none" ? e : t;
48
+ function getLegendItemColor(stroke, fill) {
49
+ return stroke && stroke !== "none" ? stroke : fill;
39
50
  }
40
51
  //#endregion
41
- export { m as Area };
52
+ export { Area };
@@ -1,104 +1,125 @@
1
- import { isNumber as e, isWellBehavedNumber as t } from "../../utils/validate.mjs";
2
- import { useAreaContext as n } from "./hooks/useArea.mjs";
3
- import { Animate as r } from "../../animation/Animate.mjs";
4
- import { createVNode as i, defineComponent as a, ref as o, watch as s } from "vue";
1
+ import { isNumber, isWellBehavedNumber } from "../../utils/validate.mjs";
2
+ import { useAreaContext } from "./hooks/useArea.mjs";
3
+ import { Animate } from "../../animation/Animate.mjs";
4
+ import { createVNode, defineComponent, ref, watch } from "vue";
5
5
  //#region src/cartesian/area/ClipRect.tsx
6
- var c = /* @__PURE__ */ a({
6
+ var HorizontalRect = /* @__PURE__ */ defineComponent({
7
7
  name: "HorizontalRect",
8
8
  props: {
9
9
  alpha: {
10
10
  type: Number,
11
- required: !0
11
+ required: true
12
12
  },
13
13
  points: {
14
14
  type: Array,
15
- required: !0
15
+ required: true
16
16
  },
17
17
  baseLine: {
18
18
  type: [Number, Array],
19
- required: !0
19
+ required: true
20
20
  },
21
21
  strokeWidth: {
22
22
  type: Number,
23
- required: !0
23
+ required: true
24
24
  }
25
25
  },
26
- setup(t) {
27
- let { points: n } = t;
26
+ setup(props) {
27
+ const { points } = props;
28
28
  return () => {
29
- let { alpha: r, baseLine: a, strokeWidth: o } = t, s = n[0].x, c = n[n.length - 1].x, l = r * Math.abs(s - c), u = Math.max(...n.map((e) => e.y || 0));
30
- return e(a) ? u = Math.max(a, u) : a && Array.isArray(a) && a.length && (u = Math.max(...a.map((e) => e.y || 0), u)), e(u) ? i("rect", {
31
- x: s < c ? s : s - l,
32
- y: 0,
33
- width: l,
34
- height: Math.floor(u + (o ? parseInt(`${o}`, 10) : 1))
35
- }, null) : null;
29
+ const { alpha, baseLine, strokeWidth } = props;
30
+ const startX = points[0].x;
31
+ const endX = points[points.length - 1].x;
32
+ const width = alpha * Math.abs(startX - endX);
33
+ let maxY = Math.max(...points.map((entry) => entry.y || 0));
34
+ if (isNumber(baseLine)) maxY = Math.max(baseLine, maxY);
35
+ else if (baseLine && Array.isArray(baseLine) && baseLine.length) maxY = Math.max(...baseLine.map((entry) => entry.y || 0), maxY);
36
+ if (isNumber(maxY)) return createVNode("rect", {
37
+ "x": startX < endX ? startX : startX - width,
38
+ "y": 0,
39
+ "width": width,
40
+ "height": Math.floor(maxY + (strokeWidth ? parseInt(`${strokeWidth}`, 10) : 1))
41
+ }, null);
42
+ return null;
36
43
  };
37
44
  }
38
- }), l = /* @__PURE__ */ a({
45
+ });
46
+ var VerticalRect = /* @__PURE__ */ defineComponent({
39
47
  name: "VerticalRect",
40
48
  props: {
41
49
  alpha: {
42
50
  type: Number,
43
- required: !0
51
+ required: true
44
52
  },
45
53
  points: {
46
54
  type: Array,
47
- required: !0
55
+ required: true
48
56
  },
49
57
  baseLine: {
50
58
  type: [Number, Array],
51
- required: !0
59
+ required: true
52
60
  },
53
61
  strokeWidth: {
54
62
  type: Number,
55
- required: !0
63
+ required: true
56
64
  }
57
65
  },
58
- setup(n) {
59
- let { points: r } = n;
66
+ setup(props) {
67
+ const { points } = props;
60
68
  return () => {
61
- let { alpha: a, baseLine: o, strokeWidth: s } = n, c = r[0].y, l = r[r.length - 1].y;
62
- if (!t(c) || !t(l)) return null;
63
- let u = a * Math.abs(c - l), d = Math.max(...r.map((e) => e.x || 0));
64
- return e(o) ? d = Math.max(o, d) : o && Array.isArray(o) && o.length && (d = Math.max(...o.map((e) => e.x || 0), d)), i("rect", {
65
- x: 0,
66
- y: c < l ? c : c - u,
67
- width: d + (s ? parseInt(`${s}`, 10) : 1),
68
- height: Math.floor(u)
69
+ const { alpha, baseLine, strokeWidth } = props;
70
+ const startY = points[0].y;
71
+ const endY = points[points.length - 1].y;
72
+ if (!isWellBehavedNumber(startY) || !isWellBehavedNumber(endY)) return null;
73
+ const height = alpha * Math.abs(startY - endY);
74
+ let maxX = Math.max(...points.map((entry) => entry.x || 0));
75
+ if (isNumber(baseLine)) maxX = Math.max(baseLine, maxX);
76
+ else if (baseLine && Array.isArray(baseLine) && baseLine.length) maxX = Math.max(...baseLine.map((entry) => entry.x || 0), maxX);
77
+ return createVNode("rect", {
78
+ "x": 0,
79
+ "y": startY < endY ? startY : startY - height,
80
+ "width": maxX + (strokeWidth ? parseInt(`${strokeWidth}`, 10) : 1),
81
+ "height": Math.floor(height)
69
82
  }, null);
70
83
  };
71
84
  }
72
- }), u = /* @__PURE__ */ a({
85
+ });
86
+ var ClipRect = /* @__PURE__ */ defineComponent({
73
87
  name: "ClipRect",
74
88
  setup() {
75
- let { points: e, props: t, areaData: a, layout: u, isClipRectAnimating: d } = n(), f = o(!1);
76
- s(e, (e) => {
77
- e && e.length > 0 && !f.value && (f.value = !0);
78
- }, { immediate: !0 });
79
- let p = () => {
80
- f.value = !1, d.value = !1, t.onAnimationEnd?.();
89
+ const { points, props, areaData, layout, isClipRectAnimating } = useAreaContext();
90
+ const isAnimationActive = ref(false);
91
+ watch(points, (newPoints) => {
92
+ if (newPoints && newPoints.length > 0 && !isAnimationActive.value) isAnimationActive.value = true;
93
+ }, { immediate: true });
94
+ const handleAnimationEnd = () => {
95
+ isAnimationActive.value = false;
96
+ isClipRectAnimating.value = false;
97
+ props.onAnimationEnd?.();
81
98
  };
82
99
  return () => {
83
- let n = a.value?.baseLine;
84
- return !e.value || e.value.length === 0 ? null : i(r, {
85
- isActive: f.value,
86
- transition: t.transition,
87
- onAnimationStart: t.onAnimationStart,
88
- onAnimationEnd: p
89
- }, { default: (r) => u.value === "horizontal" ? i(c, {
90
- alpha: r,
91
- points: e.value,
92
- baseLine: n,
93
- strokeWidth: t.strokeWidth || 2
94
- }, null) : i(l, {
95
- alpha: r,
96
- points: e.value,
97
- baseLine: n,
98
- strokeWidth: t.strokeWidth || 2
99
- }, null) });
100
+ const baseLine = areaData.value?.baseLine;
101
+ if (!points.value || points.value.length === 0) return null;
102
+ return createVNode(Animate, {
103
+ "isActive": isAnimationActive.value,
104
+ "transition": props.transition,
105
+ "onAnimationStart": props.onAnimationStart,
106
+ "onAnimationEnd": handleAnimationEnd
107
+ }, { default: (t) => {
108
+ if (layout.value === "horizontal") return createVNode(HorizontalRect, {
109
+ "alpha": t,
110
+ "points": points.value,
111
+ "baseLine": baseLine,
112
+ "strokeWidth": props.strokeWidth || 2
113
+ }, null);
114
+ return createVNode(VerticalRect, {
115
+ "alpha": t,
116
+ "points": points.value,
117
+ "baseLine": baseLine,
118
+ "strokeWidth": props.strokeWidth || 2
119
+ }, null);
120
+ } });
100
121
  };
101
122
  }
102
123
  });
103
124
  //#endregion
104
- export { u as ClipRect };
125
+ export { ClipRect };