vccs 0.1.0 → 0.2.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 (215) hide show
  1. package/dist/cartesian/funnel/Funnel.d.ts +2 -0
  2. package/dist/cartesian/funnel/index.d.ts +2 -0
  3. package/dist/cartesian/funnel/type.d.ts +74 -5
  4. package/dist/cartesian/index.d.ts +1 -0
  5. package/dist/chart/FunnelChart.d.ts +1 -0
  6. package/dist/chart/index.d.ts +1 -0
  7. package/dist/es/animation/Animate.mjs +48 -22
  8. package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
  9. package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
  10. package/dist/es/cartesian/area/Area.mjs +42 -31
  11. package/dist/es/cartesian/area/ClipRect.mjs +79 -58
  12. package/dist/es/cartesian/area/RenderArea.mjs +142 -108
  13. package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
  14. package/dist/es/cartesian/area/type.mjs +11 -11
  15. package/dist/es/cartesian/area/utils.mjs +69 -49
  16. package/dist/es/cartesian/axis/XAxis.mjs +87 -73
  17. package/dist/es/cartesian/axis/YAxis.mjs +67 -56
  18. package/dist/es/cartesian/bar/Bar.mjs +93 -71
  19. package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
  20. package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
  21. package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
  22. package/dist/es/cartesian/bar/type.mjs +9 -9
  23. package/dist/es/cartesian/bar/utils.mjs +97 -70
  24. package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
  25. package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
  26. package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
  27. package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
  28. package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
  29. package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
  30. package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
  31. package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
  32. package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
  33. package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
  34. package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
  35. package/dist/es/cartesian/funnel/Funnel.mjs +177 -0
  36. package/dist/es/cartesian/funnel/type.mjs +80 -0
  37. package/dist/es/cartesian/funnel/utils.mjs +102 -0
  38. package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
  39. package/dist/es/cartesian/line/Line.mjs +41 -37
  40. package/dist/es/cartesian/line/StaticLine.mjs +191 -122
  41. package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
  42. package/dist/es/cartesian/line/type.mjs +11 -11
  43. package/dist/es/cartesian/line/utils.mjs +27 -26
  44. package/dist/es/cartesian/reference-area/ReferenceArea.mjs +86 -69
  45. package/dist/es/cartesian/reference-line/ReferenceLine.mjs +99 -77
  46. package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
  47. package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
  48. package/dist/es/cartesian/useNeedsClip.mjs +18 -9
  49. package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
  50. package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
  51. package/dist/es/chart/AreaChart.mjs +5 -5
  52. package/dist/es/chart/BarChart.mjs +5 -5
  53. package/dist/es/chart/ComposedChart.mjs +5 -5
  54. package/dist/es/chart/FunnelChart.mjs +11 -0
  55. package/dist/es/chart/LegendPortalContext.mjs +3 -3
  56. package/dist/es/chart/LineChart.mjs +5 -5
  57. package/dist/es/chart/PieChart.mjs +5 -5
  58. package/dist/es/chart/RadarChart.mjs +5 -5
  59. package/dist/es/chart/RadialBarChart.mjs +5 -5
  60. package/dist/es/chart/RechartsWrapper.mjs +111 -88
  61. package/dist/es/chart/ScatterChart.mjs +5 -5
  62. package/dist/es/chart/Surface.mjs +3 -3
  63. package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
  64. package/dist/es/chart/TooltipPortalContext.mjs +3 -3
  65. package/dist/es/chart/const.mjs +2 -2
  66. package/dist/es/chart/generateCategoricalChart.mjs +97 -88
  67. package/dist/es/chart/provideClipPathId.mjs +12 -7
  68. package/dist/es/components/Cell.mjs +16 -4
  69. package/dist/es/components/Text.mjs +3 -3
  70. package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
  71. package/dist/es/components/Tooltip.mjs +274 -199
  72. package/dist/es/components/label/Label.mjs +30 -26
  73. package/dist/es/components/label/LabelList.mjs +45 -39
  74. package/dist/es/components/label/types.mjs +8 -5
  75. package/dist/es/components/label/utils.mjs +194 -162
  76. package/dist/es/components/legend/Legend.mjs +82 -71
  77. package/dist/es/components/legend/LegendSymbol.mjs +40 -38
  78. package/dist/es/components/legend/hooks/useLegend.mjs +66 -46
  79. package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
  80. package/dist/es/components/legend/type.mjs +2 -2
  81. package/dist/es/components/legend/utils.mjs +19 -11
  82. package/dist/es/components/utils.mjs +35 -22
  83. package/dist/es/container/ClipPath.mjs +14 -14
  84. package/dist/es/container/Layer.mjs +9 -7
  85. package/dist/es/container/ResponsiveContainer.mjs +3 -3
  86. package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
  87. package/dist/es/container/Surface.mjs +23 -19
  88. package/dist/es/container/useSizeContext.mjs +3 -3
  89. package/dist/es/context/ChartDataContextProvider.mjs +19 -13
  90. package/dist/es/context/PanoramaContextProvider.mjs +15 -10
  91. package/dist/es/context/accessibilityContext.mjs +3 -3
  92. package/dist/es/context/cartesianLabelListContext.mjs +3 -3
  93. package/dist/es/context/chartLayoutContext.mjs +33 -30
  94. package/dist/es/context/cursorLayerContext.mjs +3 -3
  95. package/dist/es/context/graphicalLayerContext.mjs +3 -3
  96. package/dist/es/context/labelLayerContext.mjs +3 -3
  97. package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
  98. package/dist/es/context/useTooltipAxis.mjs +14 -12
  99. package/dist/es/events/useChartSynchronisation.mjs +91 -66
  100. package/dist/es/hooks/useIsAnimating.mjs +28 -0
  101. package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
  102. package/dist/es/index.mjs +46 -42
  103. package/dist/es/polar/pie/Pie.mjs +131 -115
  104. package/dist/es/polar/pie/type.mjs +6 -6
  105. package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
  106. package/dist/es/polar/radar/PolarGrid.mjs +72 -59
  107. package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
  108. package/dist/es/polar/radar/Radar.mjs +181 -145
  109. package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
  110. package/dist/es/polar/radial-bar/type.mjs +9 -9
  111. package/dist/es/shape/Cross.mjs +11 -10
  112. package/dist/es/shape/Curve.mjs +69 -43
  113. package/dist/es/shape/Dot.mjs +12 -11
  114. package/dist/es/shape/Rectangle.mjs +41 -26
  115. package/dist/es/shape/Sector.mjs +103 -75
  116. package/dist/es/shape/Symbols.mjs +45 -34
  117. package/dist/es/shape/Trapezoid.mjs +52 -0
  118. package/dist/es/state/ReportChartProps.mjs +21 -20
  119. package/dist/es/state/ReportMainChartProps.mjs +26 -21
  120. package/dist/es/state/ReportPolarOptions.mjs +23 -22
  121. package/dist/es/state/SetGraphicalItem.mjs +42 -27
  122. package/dist/es/state/SetLegendPayload.mjs +17 -13
  123. package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
  124. package/dist/es/state/brushSlice.mjs +12 -8
  125. package/dist/es/state/cartesianAxisSlice.mjs +23 -17
  126. package/dist/es/state/chartDataSlice.mjs +18 -13
  127. package/dist/es/state/externalEventsMiddleware.mjs +25 -15
  128. package/dist/es/state/graphicalItemsSlice.mjs +29 -25
  129. package/dist/es/state/hooks.mjs +4 -3
  130. package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
  131. package/dist/es/state/layoutSlice.mjs +18 -12
  132. package/dist/es/state/legendSlice.mjs +19 -14
  133. package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
  134. package/dist/es/state/optionsSlice.mjs +14 -11
  135. package/dist/es/state/polarAxisSlice.mjs +15 -13
  136. package/dist/es/state/polarOptionsSlice.mjs +8 -6
  137. package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
  138. package/dist/es/state/referenceElementsSlice.mjs +21 -19
  139. package/dist/es/state/rootPropsSlice.mjs +20 -9
  140. package/dist/es/state/selectors/areaSelectors.mjs +65 -55
  141. package/dist/es/state/selectors/axisSelectors.mjs +755 -569
  142. package/dist/es/state/selectors/barSelectors.mjs +225 -162
  143. package/dist/es/state/selectors/brushSelectors.mjs +15 -14
  144. package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
  145. package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
  146. package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
  147. package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
  148. package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
  149. package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
  150. package/dist/es/state/selectors/common.mjs +2 -2
  151. package/dist/es/state/selectors/containerSelectors.mjs +5 -2
  152. package/dist/es/state/selectors/dataSelectors.mjs +28 -9
  153. package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
  154. package/dist/es/state/selectors/legendSelectors.mjs +7 -6
  155. package/dist/es/state/selectors/lineSelectors.mjs +54 -47
  156. package/dist/es/state/selectors/pickAxisId.mjs +2 -2
  157. package/dist/es/state/selectors/pickAxisType.mjs +2 -2
  158. package/dist/es/state/selectors/pieSelectors.mjs +116 -81
  159. package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
  160. package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
  161. package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
  162. package/dist/es/state/selectors/polarSelectors.mjs +79 -62
  163. package/dist/es/state/selectors/radarSelectors.mjs +111 -91
  164. package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
  165. package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
  166. package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
  167. package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
  168. package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
  169. package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
  170. package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
  171. package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
  172. package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
  173. package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
  174. package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
  175. package/dist/es/state/selectors/selectors.mjs +94 -75
  176. package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
  177. package/dist/es/state/selectors/touchSelectors.mjs +17 -14
  178. package/dist/es/state/store.mjs +46 -46
  179. package/dist/es/state/tooltipSlice.mjs +64 -37
  180. package/dist/es/state/touchEventsMiddleware.mjs +35 -29
  181. package/dist/es/state/utils/useReportScale.mjs +16 -13
  182. package/dist/es/synchronisation/syncSelectors.mjs +3 -3
  183. package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
  184. package/dist/es/types/event.mjs +164 -2
  185. package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
  186. package/dist/es/utils/VueUtils.mjs +35 -14
  187. package/dist/es/utils/attrs.mjs +43 -26
  188. package/dist/es/utils/cartesian.mjs +47 -15
  189. package/dist/es/utils/chart.mjs +298 -197
  190. package/dist/es/utils/const.mjs +30 -2
  191. package/dist/es/utils/createContext.mjs +28 -9
  192. package/dist/es/utils/data-utils.mjs +9 -8
  193. package/dist/es/utils/data.mjs +35 -21
  194. package/dist/es/utils/events.mjs +5 -3
  195. package/dist/es/utils/getLinearRegression.mjs +28 -11
  196. package/dist/es/utils/grid.mjs +20 -5
  197. package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
  198. package/dist/es/utils/legend.mjs +13 -12
  199. package/dist/es/utils/log.mjs +10 -7
  200. package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
  201. package/dist/es/utils/polar.mjs +37 -30
  202. package/dist/es/utils/props.mjs +16 -10
  203. package/dist/es/utils/resolveDefaultProps.mjs +23 -4
  204. package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
  205. package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
  206. package/dist/es/utils/scale/utils/utils.mjs +43 -24
  207. package/dist/es/utils/style.mjs +24 -13
  208. package/dist/es/utils/tick.mjs +34 -23
  209. package/dist/es/utils/tooltip/translate.mjs +63 -49
  210. package/dist/es/utils/validate.mjs +40 -29
  211. package/dist/hooks/useIsAnimating.d.ts +14 -0
  212. package/dist/shape/Trapezoid.d.ts +31 -0
  213. package/dist/shape/index.d.ts +1 -0
  214. package/dist/state/graphicalItemsSlice.d.ts +1 -1
  215. package/package.json +1 -1
@@ -1,38 +1,40 @@
1
- import { isNumOrStr as e } from "../utils/validate.mjs";
2
- import { Curve as t } from "../shape/Curve.mjs";
3
- import { useTooltipEventType as n } from "../state/selectors/selectTooltipEventType.mjs";
4
- import { setTooltipSettingsState as r } from "../state/tooltipSlice.mjs";
5
- import { useAppDispatch as i, useAppSelector as a } from "../state/hooks.mjs";
6
- import { useChartLayout as o, useOffsetInternal as s, useViewBox as c } from "../context/chartLayoutContext.mjs";
7
- import { selectActiveCoordinate as l, selectActiveLabel as u, selectIsTooltipActive as d, selectTooltipPayload as f, useChartName as p } from "../state/selectors/selectors.mjs";
8
- import { Rectangle as m } from "../shape/Rectangle.mjs";
9
- import { useCursorLayerRef as h } from "../context/cursorLayerContext.mjs";
10
- import { usePortal as g } from "../chart/TooltipPortalContext.mjs";
11
- import { useAccessibilityLayer as _ } from "../context/accessibilityContext.mjs";
12
- import { getTooltipTranslate as v } from "../utils/tooltip/translate.mjs";
13
- import { Cross as y } from "../shape/Cross.mjs";
14
- import { Sector as b } from "../shape/Sector.mjs";
15
- import { getCursorPoints as x } from "./utils.mjs";
16
- import { useTooltipAxisBandSize as S } from "../context/useTooltipAxis.mjs";
17
- import { useTooltipChartSynchronisation as C } from "../synchronisation/useChartSynchronisation.mjs";
18
- import { Fragment as w, Teleport as T, computed as E, createVNode as D, defineComponent as O, isVNode as k, reactive as A, ref as j, watch as M, watchEffect as N, watchPostEffect as P } from "vue";
19
- import { sortBy as F, uniqBy as I } from "es-toolkit/compat";
20
- import { animate as L } from "motion-v";
21
- import { useElementBounding as R, useMagicKeys as z, usePreferredReducedMotion as B } from "@vueuse/core";
1
+ import { isNumOrStr } from "../utils/validate.mjs";
2
+ import { Curve } from "../shape/Curve.mjs";
3
+ import { useTooltipEventType } from "../state/selectors/selectTooltipEventType.mjs";
4
+ import { setTooltipSettingsState } from "../state/tooltipSlice.mjs";
5
+ import { useAppDispatch, useAppSelector } from "../state/hooks.mjs";
6
+ import { useChartLayout, useOffsetInternal, useViewBox } from "../context/chartLayoutContext.mjs";
7
+ import { selectActiveCoordinate, selectActiveLabel, selectIsTooltipActive, selectTooltipPayload, useChartName } from "../state/selectors/selectors.mjs";
8
+ import { Rectangle } from "../shape/Rectangle.mjs";
9
+ import { useCursorLayerRef } from "../context/cursorLayerContext.mjs";
10
+ import { usePortal } from "../chart/TooltipPortalContext.mjs";
11
+ import { useAccessibilityLayer } from "../context/accessibilityContext.mjs";
12
+ import { getTooltipTranslate } from "../utils/tooltip/translate.mjs";
13
+ import { Cross } from "../shape/Cross.mjs";
14
+ import { Sector } from "../shape/Sector.mjs";
15
+ import { getCursorPoints } from "./utils.mjs";
16
+ import { useTooltipAxisBandSize } from "../context/useTooltipAxis.mjs";
17
+ import { useTooltipChartSynchronisation } from "../synchronisation/useChartSynchronisation.mjs";
18
+ import { Fragment, Teleport, computed, createVNode, defineComponent, isVNode, reactive, ref, watch, watchEffect, watchPostEffect } from "vue";
19
+ import { sortBy, uniqBy } from "es-toolkit/compat";
20
+ import { animate } from "motion-v";
21
+ import { useElementBounding, useMagicKeys, usePreferredReducedMotion } from "@vueuse/core";
22
22
  //#region src/components/Tooltip.tsx
23
- function V(e) {
24
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !k(e);
23
+ function _isSlot(s) {
24
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
25
25
  }
26
- function H(e) {
27
- return e.dataKey;
26
+ function defaultUniqBy(entry) {
27
+ return entry.dataKey;
28
28
  }
29
- function U(e, t, n) {
30
- return t === !0 ? I(e, n) : typeof t == "function" ? I(e, t) : e;
29
+ function getUniqPayload(payload, option, defaultUniqBy) {
30
+ if (option === true) return uniqBy(payload, defaultUniqBy);
31
+ if (typeof option === "function") return uniqBy(payload, option);
32
+ return payload;
31
33
  }
32
- function W(t) {
33
- return Array.isArray(t) && e(t[0]) && e(t[1]) ? t.join(" ~ ") : t;
34
+ function defaultFormatter(value) {
35
+ return Array.isArray(value) && isNumOrStr(value[0]) && isNumOrStr(value[1]) ? value.join(" ~ ") : value;
34
36
  }
35
- var G = /* @__PURE__ */ O({
37
+ var DefaultTooltipContent = /* @__PURE__ */ defineComponent({
36
38
  name: "DefaultTooltipContent",
37
39
  props: {
38
40
  label: [String, Number],
@@ -48,57 +50,66 @@ var G = /* @__PURE__ */ O({
48
50
  itemSorter: [Function, String],
49
51
  formatter: Function
50
52
  },
51
- setup(e) {
53
+ setup(props) {
52
54
  return () => {
53
- if (!e.active || !e.payload?.length) return null;
54
- let { contentStyle: t, labelStyle: n, itemStyle: r } = e, i = {
55
+ if (!props.active || !props.payload?.length) return null;
56
+ const { contentStyle, labelStyle, itemStyle } = props;
57
+ const finalStyle = {
55
58
  margin: 0,
56
59
  padding: "10px",
57
60
  backgroundColor: "#fff",
58
61
  border: "1px solid #ccc",
59
62
  whiteSpace: "nowrap",
60
- ...t
61
- }, a = {
63
+ ...contentStyle
64
+ };
65
+ const finalLabelStyle = {
62
66
  margin: 0,
63
- ...n
64
- }, { itemSorter: o, payload: s, formatter: c } = e, l = o ? F(s, o) : s;
65
- return D("div", {
66
- class: "v-charts-tooltip-content",
67
- style: i
68
- }, [e.label && D("div", {
69
- class: "v-charts-tooltip-label",
70
- style: a
71
- }, [e.label]), D("div", { class: "v-charts-tooltip-list" }, [l.map((t, n) => {
72
- let i = {
67
+ ...labelStyle
68
+ };
69
+ const { itemSorter, payload, formatter } = props;
70
+ const sortedPayload = itemSorter ? sortBy(payload, itemSorter) : payload;
71
+ return createVNode("div", {
72
+ "class": "v-charts-tooltip-content",
73
+ "style": finalStyle
74
+ }, [props.label && createVNode("div", {
75
+ "class": "v-charts-tooltip-label",
76
+ "style": finalLabelStyle
77
+ }, [props.label]), createVNode("div", { "class": "v-charts-tooltip-list" }, [sortedPayload.map((entry, index) => {
78
+ const finalItemStyle = {
73
79
  display: "block",
74
80
  paddingTop: 4,
75
81
  paddingBottom: 4,
76
- color: t.color || "#000",
77
- ...r
78
- }, a = t.formatter || c || W, { value: o, name: l } = t, u = o, d = l;
79
- if (a) {
80
- let e = a(o, l, t, n, s);
81
- if (Array.isArray(e)) [u, d] = e;
82
- else if (e != null) u = e;
82
+ color: entry.color || "#000",
83
+ ...itemStyle
84
+ };
85
+ const finalFormatter = entry.formatter || formatter || defaultFormatter;
86
+ const { value, name } = entry;
87
+ let finalValue = value;
88
+ let finalName = name;
89
+ if (finalFormatter) {
90
+ const formatted = finalFormatter(value, name, entry, index, payload);
91
+ if (Array.isArray(formatted)) [finalValue, finalName] = formatted;
92
+ else if (formatted != null) finalValue = formatted;
83
93
  else return null;
84
94
  }
85
- return D("div", {
86
- key: n,
87
- class: "v-charts-tooltip-item",
88
- style: i
95
+ return createVNode("div", {
96
+ "key": index,
97
+ "class": "v-charts-tooltip-item",
98
+ "style": finalItemStyle
89
99
  }, [
90
- D("span", {
91
- class: "v-charts-tooltip-item-name",
92
- style: { color: t.color }
93
- }, [t.name]),
94
- D("span", { class: "v-charts-tooltip-separator" }, [e.separator]),
95
- D("span", { class: "v-charts-tooltip-item-value" }, [u]),
96
- D("span", { class: "v-charts-tooltip-item-unit" }, [t.unit || ""])
100
+ createVNode("span", {
101
+ "class": "v-charts-tooltip-item-name",
102
+ "style": { color: entry.color }
103
+ }, [entry.name]),
104
+ createVNode("span", { "class": "v-charts-tooltip-separator" }, [props.separator]),
105
+ createVNode("span", { "class": "v-charts-tooltip-item-value" }, [finalValue]),
106
+ createVNode("span", { "class": "v-charts-tooltip-item-unit" }, [entry.unit || ""])
97
107
  ]);
98
108
  })])]);
99
109
  };
100
110
  }
101
- }), K = /* @__PURE__ */ O({
111
+ });
112
+ var TooltipBoundingBox = /* @__PURE__ */ defineComponent({
102
113
  name: "TooltipBoundingBox",
103
114
  props: {
104
115
  allowEscapeViewBox: Object,
@@ -119,64 +130,86 @@ var G = /* @__PURE__ */ O({
119
130
  viewBox: Object,
120
131
  style: Object
121
132
  },
122
- setup(e, { slots: t }) {
123
- let n = j(!1), r = A({
133
+ setup(props, { slots }) {
134
+ const dismissed = ref(false);
135
+ const dismissedAtCoordinate = reactive({
124
136
  x: 0,
125
137
  y: 0
126
138
  });
127
- N(() => {
128
- (e.coordinate?.x !== r.x || e.coordinate?.y !== r.y) && (n.value = !1);
139
+ watchEffect(() => {
140
+ if (props.coordinate?.x !== dismissedAtCoordinate.x || props.coordinate?.y !== dismissedAtCoordinate.y) dismissed.value = false;
129
141
  }, { flush: "post" });
130
- let { escape: i } = z();
131
- M(i, (t) => {
132
- t && (n.value = !0, r.x = e.coordinate?.x ?? 0, r.y = e.coordinate?.y ?? 0);
142
+ const { escape } = useMagicKeys();
143
+ watch(escape, (v) => {
144
+ if (v) {
145
+ dismissed.value = true;
146
+ dismissedAtCoordinate.x = props.coordinate?.x ?? 0;
147
+ dismissedAtCoordinate.y = props.coordinate?.y ?? 0;
148
+ }
133
149
  });
134
- let a = j(), o = R(a, {}), s, c, l = B(), u = E(() => {
135
- let { allowEscapeViewBox: t, coordinate: n, position: r, reverseDirection: i, viewBox: a } = e, { cssClasses: c, cssProperties: l, transform: u } = v({
136
- allowEscapeViewBox: t,
137
- coordinate: n,
138
- offsetTopLeft: e.offset,
139
- position: r,
140
- reverseDirection: i,
150
+ const el = ref();
151
+ const lastBoundingBox = useElementBounding(el, {});
152
+ let preTransform;
153
+ let animationControls;
154
+ const reducedMotion = usePreferredReducedMotion();
155
+ const currentTransform = computed(() => {
156
+ const { allowEscapeViewBox, coordinate, position, reverseDirection, viewBox } = props;
157
+ let { cssClasses, cssProperties, transform } = getTooltipTranslate({
158
+ allowEscapeViewBox,
159
+ coordinate,
160
+ offsetTopLeft: props.offset,
161
+ position,
162
+ reverseDirection,
141
163
  tooltipBox: {
142
- height: o.height.value,
143
- width: o.width.value
164
+ height: lastBoundingBox.height.value,
165
+ width: lastBoundingBox.width.value
144
166
  },
145
- useTranslate3d: !1,
146
- viewBox: a
167
+ useTranslate3d: false,
168
+ viewBox
147
169
  });
148
- return u = !o.height.value && s ? s : u, s = u || s, {
149
- cssClasses: c,
150
- cssProperties: l,
151
- transform: u
170
+ transform = !lastBoundingBox.height.value && preTransform ? preTransform : transform;
171
+ preTransform = transform || preTransform;
172
+ return {
173
+ cssClasses,
174
+ cssProperties,
175
+ transform
152
176
  };
153
177
  });
154
- return P((t) => {
155
- let n = a.value, r = u.value.transform;
156
- !n || !r?.transform || (e.isAnimationActive && l.value !== "reduce" ? c = L(n, { transform: r.transform }, e.transition) : n.style.transform = r.transform, t(() => {
157
- c?.stop(), c = void 0;
158
- }));
159
- }), () => {
160
- let { active: r, hasPayload: i, style: o } = e, { cssClasses: s, cssProperties: c } = u.value, l = {
161
- ...c,
178
+ watchPostEffect((onCleanup) => {
179
+ const element = el.value;
180
+ const transform = currentTransform.value.transform;
181
+ if (!element || !transform?.transform) return;
182
+ if (props.isAnimationActive && reducedMotion.value !== "reduce") animationControls = animate(element, { transform: transform.transform }, props.transition);
183
+ else element.style.transform = transform.transform;
184
+ onCleanup(() => {
185
+ animationControls?.stop();
186
+ animationControls = void 0;
187
+ });
188
+ });
189
+ return () => {
190
+ const { active, hasPayload, style } = props;
191
+ const { cssClasses, cssProperties } = currentTransform.value;
192
+ const boundingBoxStyle = {
193
+ ...cssProperties,
162
194
  pointerEvents: "none",
163
- visibility: !n.value && r && i ? "visible" : "hidden",
195
+ visibility: !dismissed.value && active && hasPayload ? "visible" : "hidden",
164
196
  position: "absolute",
165
197
  top: 0,
166
198
  left: 0,
167
- ...o
199
+ ...style
168
200
  };
169
- return D("div", {
170
- role: "tooltip",
201
+ return createVNode("div", {
202
+ "role": "tooltip",
171
203
  "aria-live": "polite",
172
- tabindex: -1,
173
- class: s,
174
- style: l,
175
- ref: a
176
- }, [t.default?.()]);
204
+ "tabindex": -1,
205
+ "class": cssClasses,
206
+ "style": boundingBoxStyle,
207
+ "ref": el
208
+ }, [slots.default?.()]);
177
209
  };
178
210
  }
179
- }), q = /* @__PURE__ */ O({
211
+ });
212
+ var Cursor = /* @__PURE__ */ defineComponent({
180
213
  name: "Cursor",
181
214
  props: {
182
215
  cursor: [Boolean, Object],
@@ -186,70 +219,86 @@ var G = /* @__PURE__ */ O({
186
219
  payload: Array,
187
220
  index: String
188
221
  },
189
- setup(e) {
190
- let n = s(), r = o(), i = p(), a = S(), c = h(null), l = E(() => x(r.value, e.coordinate, n.value));
222
+ setup(props) {
223
+ const offset = useOffsetInternal();
224
+ const layout = useChartLayout();
225
+ const chartName = useChartName();
226
+ const tooltipAxisBandSize = useTooltipAxisBandSize();
227
+ const cursorLayerRef = useCursorLayerRef(null);
228
+ const points = computed(() => getCursorPoints(layout.value, props.coordinate, offset.value));
191
229
  return () => {
192
- if (!e.cursor || !e.coordinate) return null;
193
- let o = i.value === "ScatterChart";
194
- if (!o && e.tooltipEventType !== "axis") return null;
195
- let s = e.cursor, u = typeof s == "object" ? s : {}, d;
196
- if (o) {
197
- let { offset: t, ...r } = e.coordinate, { top: i, left: a, width: o, height: s } = n.value, c = {
230
+ if (!props.cursor || !props.coordinate) return null;
231
+ const isScatterChart = chartName.value === "ScatterChart";
232
+ if (!isScatterChart && props.tooltipEventType !== "axis") return null;
233
+ const cursor = props.cursor;
234
+ const cursorSvgProps = typeof cursor === "object" ? cursor : {};
235
+ let cursorElement;
236
+ if (isScatterChart) {
237
+ const { offset: _offset, ...coord } = props.coordinate;
238
+ const { top, left, width, height } = offset.value;
239
+ const crossProps = {
198
240
  stroke: "#ccc",
199
241
  fill: "none",
200
- ...r,
201
- top: i,
202
- left: a,
203
- width: o,
204
- height: s,
242
+ ...coord,
243
+ top,
244
+ left,
245
+ width,
246
+ height,
205
247
  class: "v-charts-tooltip-cursor",
206
248
  style: { pointerEvents: "none" },
207
- ...u
249
+ ...cursorSvgProps
208
250
  };
209
- d = e.cursorSlot ? e.cursorSlot(c) : D(y, c, null);
210
- } else if (i.value === "BarChart") {
211
- let t = a.value ?? 0, i = t / 2, o = e.coordinate, s = n.value, c = {
251
+ cursorElement = props.cursorSlot ? props.cursorSlot(crossProps) : createVNode(Cross, crossProps, null);
252
+ } else if (chartName.value === "BarChart") {
253
+ const bandSize = tooltipAxisBandSize.value ?? 0;
254
+ const halfSize = bandSize / 2;
255
+ const coord = props.coordinate;
256
+ const off = offset.value;
257
+ const rectProps = {
212
258
  stroke: "none",
213
259
  fill: "#ccc",
214
- x: r.value === "horizontal" ? o.x - i : s.left + .5,
215
- y: r.value === "horizontal" ? s.top + .5 : o.y - i,
216
- width: r.value === "horizontal" ? t : s.width - 1,
217
- height: r.value === "horizontal" ? s.height - 1 : t,
260
+ x: layout.value === "horizontal" ? coord.x - halfSize : off.left + .5,
261
+ y: layout.value === "horizontal" ? off.top + .5 : coord.y - halfSize,
262
+ width: layout.value === "horizontal" ? bandSize : off.width - 1,
263
+ height: layout.value === "horizontal" ? off.height - 1 : bandSize,
218
264
  class: "v-charts-tooltip-cursor",
219
265
  style: { pointerEvents: "none" },
220
- ...u
266
+ ...cursorSvgProps
221
267
  };
222
- d = e.cursorSlot ? e.cursorSlot(c) : D(m, c, null);
223
- } else if (r.value === "radial" && e.coordinate?.cx != null) {
224
- let t = l.value, n = {
225
- cx: t.cx,
226
- cy: t.cy,
227
- startAngle: t.startAngle,
228
- endAngle: t.endAngle,
229
- innerRadius: t.radius,
230
- outerRadius: t.radius,
268
+ cursorElement = props.cursorSlot ? props.cursorSlot(rectProps) : createVNode(Rectangle, rectProps, null);
269
+ } else if (layout.value === "radial" && props.coordinate?.cx != null) {
270
+ const radialPoints = points.value;
271
+ const sectorProps = {
272
+ cx: radialPoints.cx,
273
+ cy: radialPoints.cy,
274
+ startAngle: radialPoints.startAngle,
275
+ endAngle: radialPoints.endAngle,
276
+ innerRadius: radialPoints.radius,
277
+ outerRadius: radialPoints.radius,
231
278
  stroke: "#ccc",
232
279
  fill: "none",
233
280
  class: "v-charts-tooltip-cursor",
234
281
  style: { pointerEvents: "none" },
235
- ...u
282
+ ...cursorSvgProps
236
283
  };
237
- d = e.cursorSlot ? e.cursorSlot(n) : D(b, n, null);
284
+ cursorElement = props.cursorSlot ? props.cursorSlot(sectorProps) : createVNode(Sector, sectorProps, null);
238
285
  } else {
239
- let n = {
286
+ const cursorProps = {
240
287
  stroke: "#ccc",
241
288
  class: ["v-charts-tooltip-cursor"],
242
- layout: r.value,
243
- points: l.value,
289
+ layout: layout.value,
290
+ points: points.value,
244
291
  style: { pointerEvents: "none" },
245
- ...u
292
+ ...cursorSvgProps
246
293
  };
247
- d = e.cursorSlot ? e.cursorSlot(n) : D(t, n, null);
294
+ cursorElement = props.cursorSlot ? props.cursorSlot(cursorProps) : createVNode(Curve, cursorProps, null);
248
295
  }
249
- return c?.value ? D(T, { to: c.value }, V(d) ? d : { default: () => [d] }) : d;
296
+ if (cursorLayerRef?.value) return createVNode(Teleport, { "to": cursorLayerRef.value }, _isSlot(cursorElement) ? cursorElement : { default: () => [cursorElement] });
297
+ return cursorElement;
250
298
  };
251
299
  }
252
- }), J = /* @__PURE__ */ O({
300
+ });
301
+ var Tooltip = /* @__PURE__ */ defineComponent({
253
302
  name: "Tooltip",
254
303
  props: {
255
304
  active: {
@@ -260,23 +309,23 @@ var G = /* @__PURE__ */ O({
260
309
  allowEscapeViewBox: {
261
310
  type: Object,
262
311
  default: () => ({
263
- x: !1,
264
- y: !1
312
+ x: false,
313
+ y: false
265
314
  })
266
315
  },
267
316
  content: [Object, Function],
268
317
  cursor: {
269
318
  type: [Boolean, Object],
270
- default: !0
319
+ default: true
271
320
  },
272
321
  filterNull: {
273
322
  type: Boolean,
274
- default: !0
323
+ default: true
275
324
  },
276
325
  defaultIndex: [Number, String],
277
326
  isAnimationActive: {
278
327
  type: Boolean,
279
- default: !0
328
+ default: true
280
329
  },
281
330
  offset: {
282
331
  type: Number,
@@ -291,8 +340,8 @@ var G = /* @__PURE__ */ O({
291
340
  reverseDirection: {
292
341
  type: Object,
293
342
  default: () => ({
294
- x: !1,
295
- y: !1
343
+ x: false,
344
+ y: false
296
345
  })
297
346
  },
298
347
  shared: {
@@ -333,56 +382,82 @@ var G = /* @__PURE__ */ O({
333
382
  }
334
383
  },
335
384
  slots: Object,
336
- setup(e, { slots: t }) {
337
- let o = i(), s = E(() => typeof e.defaultIndex == "number" ? String(e.defaultIndex) : e.defaultIndex);
338
- N(() => {
339
- o(r({
340
- shared: e.shared,
341
- trigger: e.trigger,
342
- axisId: e.axisId,
343
- active: e.active,
344
- defaultIndex: s.value
385
+ setup(props, { slots }) {
386
+ const dispatch = useAppDispatch();
387
+ const defaultIndexAsString = computed(() => typeof props.defaultIndex === "number" ? String(props.defaultIndex) : props.defaultIndex);
388
+ watchEffect(() => {
389
+ dispatch(setTooltipSettingsState({
390
+ shared: props.shared,
391
+ trigger: props.trigger,
392
+ axisId: props.axisId,
393
+ active: props.active,
394
+ defaultIndex: defaultIndexAsString.value
345
395
  }));
346
396
  });
347
- let p = c(), m = _(), h = n(e.shared), v = a((t) => d(t, h.value, e.trigger, s.value)), y = a((t) => f(t, h.value, e.trigger, s.value)), b = a((t) => u(t, h.value, e.trigger, s.value)), x = a((t) => l(t, h.value, e.trigger, s.value)), S = E(() => y.value ?? []), O = g(), k = E(() => e.portal ?? O?.value), A = E(() => e.active ?? v.value?.isActive), j = E(() => h.value === "axis" ? b.value : void 0), M = [], P = E(() => {
348
- if (!A.value) return M;
349
- let t = S.value ?? M;
350
- return e.filterNull && t.length > 0 && (t = U(t.filter((t) => t.value != null && (t.hide !== !0 || e.includeHidden)), e.payloadUniqBy, H)), t;
351
- }), F = E(() => P.value.length > 0), I = E(() => e.content ? e.content : G), L = E(() => ({
352
- ...e,
353
- payload: P.value,
354
- label: j.value,
355
- active: A.value,
356
- coordinate: x.value,
357
- accessibilityLayer: m.value
358
- })), R = E(() => !!t.content);
359
- return C({
360
- tooltipEventType: h,
361
- trigger: e.trigger,
362
- activeCoordinate: x,
363
- activeLabel: j,
364
- activeIndex: E(() => v.value?.activeIndex),
365
- isTooltipActive: A
366
- }), () => k.value ? D(w, null, [D("foreignObject", null, [D(T, { to: k.value }, { default: () => [D(K, {
367
- allowEscapeViewBox: e.allowEscapeViewBox,
368
- isAnimationActive: e.isAnimationActive,
369
- active: A.value,
370
- coordinate: x.value,
371
- hasPayload: F.value,
372
- offset: e.offset,
373
- position: e.position,
374
- reverseDirection: e.reverseDirection,
375
- viewBox: p.value,
376
- style: e.style
377
- }, { default: () => [R.value ? t.content(L.value) : D(I.value, L.value, null)] })] })]), A.value && D(q, {
378
- cursor: e.cursor,
379
- cursorSlot: t.cursor,
380
- tooltipEventType: h.value,
381
- coordinate: x.value,
382
- payload: S.value,
383
- index: v.value?.activeIndex
384
- }, null)]) : null;
397
+ const viewBox = useViewBox();
398
+ const accessibilityLayer = useAccessibilityLayer();
399
+ const tooltipEventType = useTooltipEventType(props.shared);
400
+ const tooltipState = useAppSelector((state) => selectIsTooltipActive(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
401
+ const payloadFromRedux = useAppSelector((state) => selectTooltipPayload(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
402
+ const labelFromRedux = useAppSelector((state) => selectActiveLabel(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
403
+ const coordinate = useAppSelector((state) => selectActiveCoordinate(state, tooltipEventType.value, props.trigger, defaultIndexAsString.value));
404
+ const payload = computed(() => payloadFromRedux.value ?? []);
405
+ const tooltipPortalFromContext = usePortal();
406
+ const tooltipPortal = computed(() => props.portal ?? tooltipPortalFromContext?.value);
407
+ const finalIsActive = computed(() => props.active ?? tooltipState.value?.isActive);
408
+ const finalLabel = computed(() => tooltipEventType.value === "axis" ? labelFromRedux.value : void 0);
409
+ const emptyPayload = [];
410
+ const finalPayload = computed(() => {
411
+ if (!finalIsActive.value) return emptyPayload;
412
+ let result = payload.value ?? emptyPayload;
413
+ if (props.filterNull && result.length > 0) result = getUniqPayload(result.filter((entry) => entry.value != null && (entry.hide !== true || props.includeHidden)), props.payloadUniqBy, defaultUniqBy);
414
+ return result;
415
+ });
416
+ const hasPayload = computed(() => finalPayload.value.length > 0);
417
+ const contentComponent = computed(() => {
418
+ if (props.content) return props.content;
419
+ return DefaultTooltipContent;
420
+ });
421
+ const contentProps = computed(() => ({
422
+ ...props,
423
+ payload: finalPayload.value,
424
+ label: finalLabel.value,
425
+ active: finalIsActive.value,
426
+ coordinate: coordinate.value,
427
+ accessibilityLayer: accessibilityLayer.value
428
+ }));
429
+ const hasContentSlot = computed(() => !!slots.content);
430
+ useTooltipChartSynchronisation({
431
+ tooltipEventType,
432
+ trigger: props.trigger,
433
+ activeCoordinate: coordinate,
434
+ activeLabel: finalLabel,
435
+ activeIndex: computed(() => tooltipState.value?.activeIndex),
436
+ isTooltipActive: finalIsActive
437
+ });
438
+ return () => {
439
+ if (!tooltipPortal.value) return null;
440
+ return createVNode(Fragment, null, [createVNode("foreignObject", null, [createVNode(Teleport, { "to": tooltipPortal.value }, { default: () => [createVNode(TooltipBoundingBox, {
441
+ "allowEscapeViewBox": props.allowEscapeViewBox,
442
+ "isAnimationActive": props.isAnimationActive,
443
+ "active": finalIsActive.value,
444
+ "coordinate": coordinate.value,
445
+ "hasPayload": hasPayload.value,
446
+ "offset": props.offset,
447
+ "position": props.position,
448
+ "reverseDirection": props.reverseDirection,
449
+ "viewBox": viewBox.value,
450
+ "style": props.style
451
+ }, { default: () => [hasContentSlot.value ? slots.content(contentProps.value) : createVNode(contentComponent.value, contentProps.value, null)] })] })]), finalIsActive.value && createVNode(Cursor, {
452
+ "cursor": props.cursor,
453
+ "cursorSlot": slots.cursor,
454
+ "tooltipEventType": tooltipEventType.value,
455
+ "coordinate": coordinate.value,
456
+ "payload": payload.value,
457
+ "index": tooltipState.value?.activeIndex
458
+ }, null)]);
459
+ };
385
460
  }
386
461
  });
387
462
  //#endregion
388
- export { J as default, U as getUniqPayload };
463
+ export { Tooltip as default, getUniqPayload };