@coinbase/cds-mobile-visualization 3.3.0 → 3.4.0-beta.10

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 (265) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dts/chart/CartesianChart.d.ts +125 -0
  3. package/dts/chart/CartesianChart.d.ts.map +1 -0
  4. package/dts/chart/ChartContextBridge.d.ts +28 -0
  5. package/dts/chart/ChartContextBridge.d.ts.map +1 -0
  6. package/dts/chart/ChartProvider.d.ts +6 -0
  7. package/dts/chart/ChartProvider.d.ts.map +1 -0
  8. package/dts/chart/Path.d.ts +91 -0
  9. package/dts/chart/Path.d.ts.map +1 -0
  10. package/dts/chart/PeriodSelector.d.ts +85 -0
  11. package/dts/chart/PeriodSelector.d.ts.map +1 -0
  12. package/dts/chart/area/Area.d.ts +77 -0
  13. package/dts/chart/area/Area.d.ts.map +1 -0
  14. package/dts/chart/area/AreaChart.d.ts +131 -0
  15. package/dts/chart/area/AreaChart.d.ts.map +1 -0
  16. package/dts/chart/area/DottedArea.d.ts +46 -0
  17. package/dts/chart/area/DottedArea.d.ts.map +1 -0
  18. package/dts/chart/area/GradientArea.d.ts +36 -0
  19. package/dts/chart/area/GradientArea.d.ts.map +1 -0
  20. package/dts/chart/area/SolidArea.d.ts +23 -0
  21. package/dts/chart/area/SolidArea.d.ts.map +1 -0
  22. package/dts/chart/area/index.d.ts +6 -0
  23. package/dts/chart/area/index.d.ts.map +1 -0
  24. package/dts/chart/axis/Axis.d.ts +194 -0
  25. package/dts/chart/axis/Axis.d.ts.map +1 -0
  26. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  27. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  28. package/dts/chart/axis/XAxis.d.ts +16 -0
  29. package/dts/chart/axis/XAxis.d.ts.map +1 -0
  30. package/dts/chart/axis/YAxis.d.ts +21 -0
  31. package/dts/chart/axis/YAxis.d.ts.map +1 -0
  32. package/dts/chart/axis/index.d.ts +5 -0
  33. package/dts/chart/axis/index.d.ts.map +1 -0
  34. package/dts/chart/bar/Bar.d.ts +92 -0
  35. package/dts/chart/bar/Bar.d.ts.map +1 -0
  36. package/dts/chart/bar/BarChart.d.ts +113 -0
  37. package/dts/chart/bar/BarChart.d.ts.map +1 -0
  38. package/dts/chart/bar/BarPlot.d.ts +30 -0
  39. package/dts/chart/bar/BarPlot.d.ts.map +1 -0
  40. package/dts/chart/bar/BarStack.d.ts +102 -0
  41. package/dts/chart/bar/BarStack.d.ts.map +1 -0
  42. package/dts/chart/bar/BarStackGroup.d.ts +36 -0
  43. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
  44. package/dts/chart/bar/DefaultBar.d.ts +7 -0
  45. package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
  46. package/dts/chart/bar/DefaultBarStack.d.ts +7 -0
  47. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
  48. package/dts/chart/bar/index.d.ts +8 -0
  49. package/dts/chart/bar/index.d.ts.map +1 -0
  50. package/dts/chart/gradient/Gradient.d.ts +25 -0
  51. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  52. package/dts/chart/gradient/index.d.ts +2 -0
  53. package/dts/chart/gradient/index.d.ts.map +1 -0
  54. package/dts/chart/index.d.ts +15 -0
  55. package/dts/chart/index.d.ts.map +1 -0
  56. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  57. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  58. package/dts/chart/line/DottedLine.d.ts +20 -0
  59. package/dts/chart/line/DottedLine.d.ts.map +1 -0
  60. package/dts/chart/line/Line.d.ts +115 -0
  61. package/dts/chart/line/Line.d.ts.map +1 -0
  62. package/dts/chart/line/LineChart.d.ts +118 -0
  63. package/dts/chart/line/LineChart.d.ts.map +1 -0
  64. package/dts/chart/line/ReferenceLine.d.ts +139 -0
  65. package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
  66. package/dts/chart/line/SolidLine.d.ts +15 -0
  67. package/dts/chart/line/SolidLine.d.ts.map +1 -0
  68. package/dts/chart/line/index.d.ts +7 -0
  69. package/dts/chart/line/index.d.ts.map +1 -0
  70. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  71. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  72. package/dts/chart/point/Point.d.ts +120 -0
  73. package/dts/chart/point/Point.d.ts.map +1 -0
  74. package/dts/chart/point/index.d.ts +3 -0
  75. package/dts/chart/point/index.d.ts.map +1 -0
  76. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
  77. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  78. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  79. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  80. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
  81. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  82. package/dts/chart/scrubber/Scrubber.d.ts +233 -0
  83. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
  84. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
  85. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  86. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
  87. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  88. package/dts/chart/scrubber/ScrubberProvider.d.ts +20 -0
  89. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
  90. package/dts/chart/scrubber/index.d.ts +5 -0
  91. package/dts/chart/scrubber/index.d.ts.map +1 -0
  92. package/dts/chart/text/ChartText.d.ts +164 -0
  93. package/dts/chart/text/ChartText.d.ts.map +1 -0
  94. package/dts/chart/text/ChartTextGroup.d.ts +61 -0
  95. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  96. package/dts/chart/text/index.d.ts +3 -0
  97. package/dts/chart/text/index.d.ts.map +1 -0
  98. package/dts/chart/utils/axis.d.ts +342 -0
  99. package/dts/chart/utils/axis.d.ts.map +1 -0
  100. package/dts/chart/utils/bar.d.ts +20 -0
  101. package/dts/chart/utils/bar.d.ts.map +1 -0
  102. package/dts/chart/utils/chart.d.ts +124 -0
  103. package/dts/chart/utils/chart.d.ts.map +1 -0
  104. package/dts/chart/utils/context.d.ts +116 -0
  105. package/dts/chart/utils/context.d.ts.map +1 -0
  106. package/dts/chart/utils/gradient.d.ts +117 -0
  107. package/dts/chart/utils/gradient.d.ts.map +1 -0
  108. package/dts/chart/utils/index.d.ts +11 -0
  109. package/dts/chart/utils/index.d.ts.map +1 -0
  110. package/dts/chart/utils/path.d.ts +160 -0
  111. package/dts/chart/utils/path.d.ts.map +1 -0
  112. package/dts/chart/utils/point.d.ts +134 -0
  113. package/dts/chart/utils/point.d.ts.map +1 -0
  114. package/dts/chart/utils/scale.d.ts +134 -0
  115. package/dts/chart/utils/scale.d.ts.map +1 -0
  116. package/dts/chart/utils/scrubber.d.ts +39 -0
  117. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  118. package/dts/chart/utils/transition.d.ts +140 -0
  119. package/dts/chart/utils/transition.d.ts.map +1 -0
  120. package/dts/index.d.ts +2 -1
  121. package/dts/index.d.ts.map +1 -1
  122. package/dts/sparkline/Counter.d.ts +7 -2
  123. package/dts/sparkline/Sparkline.d.ts +67 -16
  124. package/dts/sparkline/Sparkline.d.ts.map +1 -1
  125. package/dts/sparkline/SparklineArea.d.ts +10 -4
  126. package/dts/sparkline/SparklineArea.d.ts.map +1 -1
  127. package/dts/sparkline/SparklineAreaPattern.d.ts +12 -4
  128. package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
  129. package/dts/sparkline/SparklineGradient.d.ts +21 -10
  130. package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
  131. package/dts/sparkline/__figma__/Sparkline.figma.d.ts +1 -1
  132. package/dts/sparkline/generateSparklineWithId.d.ts +8 -2
  133. package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
  134. package/dts/sparkline/index.d.ts +1 -1
  135. package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +8 -3
  136. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +132 -110
  137. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
  138. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +22 -9
  139. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
  140. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +18 -7
  141. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +9 -4
  142. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +11 -6
  143. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +7 -5
  144. package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +22 -10
  145. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +21 -7
  146. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
  147. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +21 -16
  148. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +29 -23
  149. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +22 -14
  150. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +1 -1
  151. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +9 -5
  152. package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +11 -6
  153. package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +5 -2
  154. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +17 -17
  155. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +16 -13
  156. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +106 -98
  157. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +1 -1
  158. package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +22 -19
  159. package/esm/chart/CartesianChart.js +335 -0
  160. package/esm/chart/ChartContextBridge.js +148 -0
  161. package/esm/chart/ChartProvider.js +10 -0
  162. package/esm/chart/Path.js +218 -0
  163. package/esm/chart/PeriodSelector.js +136 -0
  164. package/esm/chart/__stories__/CartesianChart.stories.js +723 -0
  165. package/esm/chart/__stories__/Chart.stories.js +77 -0
  166. package/esm/chart/__stories__/PeriodSelector.stories.js +322 -0
  167. package/esm/chart/area/Area.js +75 -0
  168. package/esm/chart/area/AreaChart.js +151 -0
  169. package/esm/chart/area/DottedArea.js +80 -0
  170. package/esm/chart/area/GradientArea.js +54 -0
  171. package/esm/chart/area/SolidArea.js +38 -0
  172. package/esm/chart/area/__stories__/AreaChart.stories.js +100 -0
  173. package/esm/chart/area/index.js +7 -0
  174. package/esm/chart/axis/Axis.js +45 -0
  175. package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
  176. package/esm/chart/axis/XAxis.js +188 -0
  177. package/esm/chart/axis/YAxis.js +177 -0
  178. package/esm/chart/axis/__stories__/Axis.stories.js +276 -0
  179. package/esm/chart/axis/index.js +6 -0
  180. package/esm/chart/bar/Bar.js +69 -0
  181. package/esm/chart/bar/BarChart.js +125 -0
  182. package/esm/chart/bar/BarPlot.js +102 -0
  183. package/esm/chart/bar/BarStack.js +551 -0
  184. package/esm/chart/bar/BarStackGroup.js +79 -0
  185. package/esm/chart/bar/DefaultBar.js +56 -0
  186. package/esm/chart/bar/DefaultBarStack.js +47 -0
  187. package/esm/chart/bar/__stories__/BarChart.stories.js +668 -0
  188. package/esm/chart/bar/index.js +9 -0
  189. package/esm/chart/gradient/Gradient.js +53 -0
  190. package/esm/chart/gradient/index.js +1 -0
  191. package/esm/chart/index.js +16 -0
  192. package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
  193. package/esm/chart/line/DottedLine.js +50 -0
  194. package/esm/chart/line/Line.js +178 -0
  195. package/esm/chart/line/LineChart.js +121 -0
  196. package/esm/chart/line/ReferenceLine.js +132 -0
  197. package/esm/chart/line/SolidLine.js +46 -0
  198. package/esm/chart/line/__stories__/LineChart.stories.js +2372 -0
  199. package/esm/chart/line/__stories__/ReferenceLine.stories.js +132 -0
  200. package/esm/chart/line/index.js +8 -0
  201. package/esm/chart/point/DefaultPointLabel.js +39 -0
  202. package/esm/chart/point/Point.js +188 -0
  203. package/esm/chart/point/index.js +2 -0
  204. package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
  205. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
  206. package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
  207. package/esm/chart/scrubber/Scrubber.js +166 -0
  208. package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
  209. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
  210. package/esm/chart/scrubber/ScrubberProvider.js +135 -0
  211. package/esm/chart/scrubber/index.js +4 -0
  212. package/esm/chart/text/ChartText.js +305 -0
  213. package/esm/chart/text/ChartTextGroup.js +211 -0
  214. package/esm/chart/text/index.js +4 -0
  215. package/esm/chart/utils/axis.js +592 -0
  216. package/esm/chart/utils/bar.js +24 -0
  217. package/esm/chart/utils/chart.js +270 -0
  218. package/esm/chart/utils/context.js +15 -0
  219. package/esm/chart/utils/gradient.js +305 -0
  220. package/esm/chart/utils/index.js +12 -0
  221. package/esm/chart/utils/path.js +274 -0
  222. package/esm/chart/utils/point.js +229 -0
  223. package/esm/chart/utils/scale.js +277 -0
  224. package/esm/chart/utils/scrubber.js +139 -0
  225. package/esm/chart/utils/transition.js +185 -0
  226. package/esm/index.js +4 -1
  227. package/esm/sparkline/Sparkline.js +129 -16
  228. package/esm/sparkline/SparklineArea.js +7 -2
  229. package/esm/sparkline/SparklineAreaPattern.js +4 -2
  230. package/esm/sparkline/SparklineGradient.js +4 -0
  231. package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
  232. package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
  233. package/esm/sparkline/generateSparklineWithId.js +3 -2
  234. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
  235. package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
  236. package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
  237. package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +76 -24
  238. package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
  239. package/package.json +17 -11
  240. package/dts/sparkline/__stories__/Sparkline.stories.d.ts +0 -3
  241. package/dts/sparkline/__stories__/Sparkline.stories.d.ts.map +0 -1
  242. package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts +0 -3
  243. package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts.map +0 -1
  244. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +0 -3
  245. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +0 -1
  246. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +0 -2
  247. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +0 -1
  248. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts +0 -2
  249. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts.map +0 -1
  250. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts +0 -2
  251. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts.map +0 -1
  252. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +0 -2
  253. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +0 -1
  254. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts +0 -2
  255. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts.map +0 -1
  256. package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts +0 -2
  257. package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts.map +0 -1
  258. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts +0 -2
  259. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts.map +0 -1
  260. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +0 -4
  261. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +0 -1
  262. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +0 -2
  263. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +0 -1
  264. package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts +0 -2
  265. package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts.map +0 -1
@@ -0,0 +1,132 @@
1
+ const _excluded = ["accentColor", "yellowColor"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
+ import { memo, useCallback } from 'react';
5
+ import { useTheme } from '@coinbase/cds-mobile';
6
+ import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
7
+ import { DefaultReferenceLineLabel } from '../DefaultReferenceLineLabel';
8
+ import { DottedLine } from '../DottedLine';
9
+ import { LineChart } from '../LineChart';
10
+ import { ReferenceLine } from '../ReferenceLine';
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const LiquidationLabelMobile = /*#__PURE__*/memo(_ref => {
13
+ let {
14
+ accentColor,
15
+ yellowColor
16
+ } = _ref,
17
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
18
+ return /*#__PURE__*/_jsx(DefaultReferenceLineLabel, _extends({}, props, {
19
+ background: accentColor,
20
+ borderRadius: 100,
21
+ color: "rgb(" + yellowColor + ")",
22
+ horizontalAlignment: "left",
23
+ inset: {
24
+ top: 4,
25
+ bottom: 4,
26
+ left: 8,
27
+ right: 8
28
+ }
29
+ }));
30
+ });
31
+ const ReferenceLineStories = () => {
32
+ const theme = useTheme();
33
+ const liquidationLabelComponent = useCallback(props => /*#__PURE__*/_jsx(LiquidationLabelMobile, _extends({}, props, {
34
+ accentColor: theme.color.accentSubtleYellow,
35
+ yellowColor: theme.spectrum.yellow70
36
+ })), [theme.color.accentSubtleYellow, theme.spectrum.yellow70]);
37
+ return /*#__PURE__*/_jsxs(ExampleScreen, {
38
+ children: [/*#__PURE__*/_jsx(Example, {
39
+ title: "Simple Reference Line",
40
+ children: /*#__PURE__*/_jsx(LineChart, {
41
+ showArea: true,
42
+ height: 250,
43
+ series: [{
44
+ id: 'prices',
45
+ data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58],
46
+ color: theme.color.fgPositive
47
+ }],
48
+ children: /*#__PURE__*/_jsx(ReferenceLine, {
49
+ LineComponent: props => /*#__PURE__*/_jsx(DottedLine, _extends({}, props, {
50
+ dashIntervals: [0, 16],
51
+ strokeWidth: 3
52
+ })),
53
+ dataY: 10,
54
+ stroke: theme.color.fg
55
+ })
56
+ })
57
+ }), /*#__PURE__*/_jsx(Example, {
58
+ title: "With Labels",
59
+ children: /*#__PURE__*/_jsxs(LineChart, {
60
+ showArea: true,
61
+ height: 250,
62
+ inset: 0,
63
+ series: [{
64
+ id: 'prices',
65
+ data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
66
+ }],
67
+ children: [/*#__PURE__*/_jsx(ReferenceLine, {
68
+ dataX: 4,
69
+ label: "Vertical Reference Line",
70
+ labelHorizontalAlignment: "left"
71
+ }), /*#__PURE__*/_jsx(ReferenceLine, {
72
+ dataY: 70,
73
+ label: "Horizontal Reference Line",
74
+ labelHorizontalAlignment: "right",
75
+ labelVerticalAlignment: "bottom"
76
+ })]
77
+ })
78
+ }), /*#__PURE__*/_jsx(Example, {
79
+ title: "Label Customization",
80
+ children: /*#__PURE__*/_jsxs(LineChart, {
81
+ showArea: true,
82
+ height: 250,
83
+ series: [{
84
+ id: 'prices',
85
+ data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
86
+ }],
87
+ children: [/*#__PURE__*/_jsx(ReferenceLine, {
88
+ dataY: 75,
89
+ label: "Top Right",
90
+ labelDx: -8,
91
+ labelDy: -8,
92
+ labelFont: "label1",
93
+ labelHorizontalAlignment: "right",
94
+ labelPosition: "right",
95
+ labelVerticalAlignment: "bottom"
96
+ }), /*#__PURE__*/_jsx(ReferenceLine, {
97
+ dataX: 7,
98
+ label: "Bottom Left",
99
+ labelDx: 8,
100
+ labelDy: 8,
101
+ labelFont: "label1",
102
+ labelHorizontalAlignment: "left",
103
+ labelPosition: "top",
104
+ labelVerticalAlignment: "top"
105
+ })]
106
+ })
107
+ }), /*#__PURE__*/_jsx(Example, {
108
+ title: "With Custom Label Component",
109
+ children: /*#__PURE__*/_jsx(LineChart, {
110
+ height: 250,
111
+ inset: {
112
+ right: 32,
113
+ top: 0,
114
+ left: 0,
115
+ bottom: 0
116
+ },
117
+ series: [{
118
+ id: 'prices',
119
+ data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
120
+ }],
121
+ children: /*#__PURE__*/_jsx(ReferenceLine, {
122
+ LabelComponent: liquidationLabelComponent,
123
+ dataY: 25,
124
+ label: "Liquidation",
125
+ labelPosition: "left",
126
+ stroke: theme.color.bgWarning
127
+ })
128
+ })
129
+ })]
130
+ });
131
+ };
132
+ export default ReferenceLineStories;
@@ -0,0 +1,8 @@
1
+ // codegen:start {preset: barrel, include: ./*.tsx, exclude: ./__stories__/*.tsx}
2
+ export * from './DefaultReferenceLineLabel';
3
+ export * from './DottedLine';
4
+ export * from './Line';
5
+ export * from './LineChart';
6
+ export * from './ReferenceLine';
7
+ export * from './SolidLine';
8
+ // codegen:end
@@ -0,0 +1,39 @@
1
+ const _excluded = ["x", "y", "position", "offset", "children"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
+ import { memo, useMemo } from 'react';
5
+ import { ChartText } from '../text';
6
+ import { getAlignmentFromPosition, getLabelCoordinates } from '../utils/point';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ /**
9
+ * DefaultPointLabel is the default label component for point labels.
10
+ * It renders text at the specified position relative to the point.
11
+ */
12
+ export const DefaultPointLabel = /*#__PURE__*/memo(_ref => {
13
+ let {
14
+ x,
15
+ y,
16
+ position = 'center',
17
+ offset,
18
+ children
19
+ } = _ref,
20
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
21
+ const {
22
+ horizontalAlignment,
23
+ verticalAlignment
24
+ } = useMemo(() => getAlignmentFromPosition(position), [position]);
25
+ const labelCoordinates = useMemo(() => {
26
+ if (offset === undefined) return {
27
+ x,
28
+ y
29
+ };
30
+ return getLabelCoordinates(x, y, position, offset);
31
+ }, [x, y, position, offset]);
32
+ return /*#__PURE__*/_jsx(ChartText, _extends({}, props, {
33
+ horizontalAlignment: horizontalAlignment,
34
+ verticalAlignment: verticalAlignment,
35
+ x: labelCoordinates.x,
36
+ y: labelCoordinates.y,
37
+ children: children
38
+ }));
39
+ });
@@ -0,0 +1,188 @@
1
+ import { memo, useEffect, useMemo } from 'react';
2
+ import { cancelAnimation, useDerivedValue, useSharedValue } from 'react-native-reanimated';
3
+ import { usePreviousValue } from '@coinbase/cds-common/hooks/usePreviousValue';
4
+ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
5
+ import { Circle, Group, interpolateColors } from '@shopify/react-native-skia';
6
+ import { useCartesianChartContext } from '../ChartProvider';
7
+ import { projectPoint } from '../utils';
8
+ import { buildTransition, defaultTransition } from '../utils/transition';
9
+ import { DefaultPointLabel } from './DefaultPointLabel';
10
+
11
+ /**
12
+ * Props for point label components.
13
+ */
14
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
+ export const Point = /*#__PURE__*/memo(_ref => {
16
+ let {
17
+ dataX,
18
+ dataY,
19
+ yAxisId,
20
+ fill: fillProp,
21
+ radius = 5,
22
+ opacity,
23
+ stroke: strokeProp,
24
+ strokeWidth = 2,
25
+ label,
26
+ LabelComponent = DefaultPointLabel,
27
+ labelPosition = 'center',
28
+ labelOffset,
29
+ labelFont,
30
+ transition = defaultTransition,
31
+ animate: animateProp
32
+ } = _ref;
33
+ const theme = useTheme();
34
+ const stroke = strokeProp != null ? strokeProp : theme.color.bg;
35
+ const fill = fillProp != null ? fillProp : theme.color.fgPrimary;
36
+ const {
37
+ getXScale,
38
+ getYScale,
39
+ animate: animationEnabled,
40
+ drawingArea
41
+ } = useCartesianChartContext();
42
+ const animate = animateProp != null ? animateProp : animationEnabled;
43
+ const xScale = getXScale();
44
+ const yScale = getYScale(yAxisId);
45
+ const shouldAnimate = animate != null ? animate : false;
46
+
47
+ // Calculate pixel coordinates from data coordinates
48
+ const pixelCoordinate = useMemo(() => {
49
+ if (!xScale || !yScale) {
50
+ return undefined;
51
+ }
52
+ return projectPoint({
53
+ x: dataX,
54
+ y: dataY,
55
+ xScale,
56
+ yScale
57
+ });
58
+ }, [xScale, yScale, dataX, dataY]);
59
+ const previousPixelCoordinate = usePreviousValue(pixelCoordinate);
60
+ const previousFill = usePreviousValue(fill);
61
+
62
+ // Animated values for position
63
+ const animatedX = useSharedValue(0);
64
+ const animatedY = useSharedValue(0);
65
+
66
+ // Animated value for color interpolation (0 = old color, 1 = new color)
67
+ const colorProgress = useSharedValue(1);
68
+
69
+ // Update position when coordinates change
70
+ useEffect(() => {
71
+ if (!pixelCoordinate) {
72
+ return;
73
+ }
74
+ if (shouldAnimate && previousPixelCoordinate) {
75
+ animatedX.value = buildTransition(pixelCoordinate.x, transition);
76
+ animatedY.value = buildTransition(pixelCoordinate.y, transition);
77
+ } else {
78
+ cancelAnimation(animatedX);
79
+ cancelAnimation(animatedY);
80
+ animatedX.value = pixelCoordinate.x;
81
+ animatedY.value = pixelCoordinate.y;
82
+ }
83
+ }, [pixelCoordinate, shouldAnimate, previousPixelCoordinate, animatedX, animatedY, transition]);
84
+
85
+ // Update color when fill changes
86
+ useEffect(() => {
87
+ if (shouldAnimate && previousFill && previousFill !== fill) {
88
+ colorProgress.value = 0;
89
+ colorProgress.value = buildTransition(1, transition);
90
+ } else {
91
+ cancelAnimation(colorProgress);
92
+ colorProgress.value = 1;
93
+ }
94
+ }, [fill, shouldAnimate, previousFill, colorProgress, transition]);
95
+
96
+ // Create animated point for circles
97
+ const animatedPoint = useDerivedValue(() => {
98
+ return {
99
+ x: animatedX.value,
100
+ y: animatedY.value
101
+ };
102
+ }, [animatedX, animatedY]);
103
+
104
+ // Interpolate between previous and current fill color
105
+ const animatedFillColor = useDerivedValue(() => {
106
+ if (!previousFill || previousFill === fill) {
107
+ return fill;
108
+ }
109
+ return interpolateColors(colorProgress.value, [0, 1], [previousFill, fill]);
110
+ }, [colorProgress, previousFill, fill]);
111
+
112
+ // Check if point is within drawing area
113
+ const isWithinDrawingArea = useDerivedValue(() => {
114
+ return animatedX.value >= drawingArea.x && animatedX.value <= drawingArea.x + drawingArea.width && animatedY.value >= drawingArea.y && animatedY.value <= drawingArea.y + drawingArea.height;
115
+ }, [animatedX, animatedY, drawingArea]);
116
+
117
+ // Compute effective opacity based on drawing area bounds
118
+ const effectiveOpacity = useDerivedValue(() => {
119
+ const baseOpacity = opacity != null ? opacity : 1;
120
+ return isWithinDrawingArea.value ? baseOpacity : 0;
121
+ }, [isWithinDrawingArea, opacity]);
122
+ const offset = useMemo(() => labelOffset != null ? labelOffset : radius * 2, [labelOffset, radius]);
123
+ if (!pixelCoordinate) {
124
+ return null;
125
+ }
126
+
127
+ // If animation is disabled or on first render, use static rendering
128
+ if (!shouldAnimate || !previousPixelCoordinate) {
129
+ const isWithinBounds = pixelCoordinate.x >= drawingArea.x && pixelCoordinate.x <= drawingArea.x + drawingArea.width && pixelCoordinate.y >= drawingArea.y && pixelCoordinate.y <= drawingArea.y + drawingArea.height;
130
+ const staticOpacity = isWithinBounds ? opacity != null ? opacity : 1 : 0;
131
+ return /*#__PURE__*/_jsxs(_Fragment, {
132
+ children: [/*#__PURE__*/_jsxs(Group, {
133
+ opacity: staticOpacity,
134
+ children: [strokeWidth > 0 && /*#__PURE__*/_jsx(Circle, {
135
+ c: {
136
+ x: pixelCoordinate.x,
137
+ y: pixelCoordinate.y
138
+ },
139
+ color: stroke,
140
+ r: radius + strokeWidth / 2
141
+ }), /*#__PURE__*/_jsx(Circle, {
142
+ c: {
143
+ x: pixelCoordinate.x,
144
+ y: pixelCoordinate.y
145
+ },
146
+ color: fill,
147
+ r: radius - strokeWidth / 2
148
+ })]
149
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
150
+ dataX: dataX,
151
+ dataY: dataY,
152
+ fill: fill,
153
+ font: labelFont,
154
+ offset: offset,
155
+ position: labelPosition,
156
+ x: pixelCoordinate.x,
157
+ y: pixelCoordinate.y,
158
+ children: label
159
+ })]
160
+ });
161
+ }
162
+
163
+ // Animated rendering
164
+ return /*#__PURE__*/_jsxs(_Fragment, {
165
+ children: [/*#__PURE__*/_jsxs(Group, {
166
+ opacity: effectiveOpacity,
167
+ children: [strokeWidth > 0 && /*#__PURE__*/_jsx(Circle, {
168
+ c: animatedPoint,
169
+ color: stroke,
170
+ r: radius + strokeWidth / 2
171
+ }), /*#__PURE__*/_jsx(Circle, {
172
+ c: animatedPoint,
173
+ color: animatedFillColor,
174
+ r: radius - strokeWidth / 2
175
+ })]
176
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
177
+ dataX: dataX,
178
+ dataY: dataY,
179
+ fill: fill,
180
+ font: labelFont,
181
+ offset: offset,
182
+ position: labelPosition,
183
+ x: pixelCoordinate.x,
184
+ y: pixelCoordinate.y,
185
+ children: label
186
+ })]
187
+ });
188
+ });
@@ -0,0 +1,2 @@
1
+ export * from './DefaultPointLabel';
2
+ export * from './Point';
@@ -0,0 +1,179 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import { forwardRef, memo, useImperativeHandle, useMemo } from 'react';
3
+ import { cancelAnimation, Easing, useAnimatedReaction, useDerivedValue, useSharedValue, withRepeat, withSequence } from 'react-native-reanimated';
4
+ import { useTheme } from '@coinbase/cds-mobile';
5
+ import { Circle, Group } from '@shopify/react-native-skia';
6
+ import { useCartesianChartContext } from '../ChartProvider';
7
+ import { unwrapAnimatedValue } from '../utils';
8
+ import { projectPointWithSerializableScale } from '../utils/point';
9
+ import { buildTransition, defaultTransition } from '../utils/transition';
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const radius = 5;
12
+ const strokeWidth = 2;
13
+ const pulseOpacityStart = 0.5;
14
+ const pulseOpacityEnd = 0;
15
+ const pulseRadiusStart = 10;
16
+ const pulseRadiusEnd = 15;
17
+ const defaultPulseTransition = {
18
+ type: 'timing',
19
+ duration: 1600,
20
+ easing: Easing.bezier(0.0, 0.0, 0.0, 1.0)
21
+ };
22
+ const defaultPulseRepeatDelay = 400;
23
+ export const DefaultScrubberBeacon = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
24
+ let {
25
+ seriesId,
26
+ color: colorProp,
27
+ dataX,
28
+ dataY,
29
+ isIdle,
30
+ idlePulse,
31
+ animate = true,
32
+ transitions,
33
+ opacity: opacityProp = 1
34
+ } = _ref;
35
+ const theme = useTheme();
36
+ const {
37
+ getSeries,
38
+ getXSerializableScale,
39
+ getYSerializableScale,
40
+ drawingArea
41
+ } = useCartesianChartContext();
42
+ const targetSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
43
+ const xScale = useMemo(() => getXSerializableScale(), [getXSerializableScale]);
44
+ const yScale = useMemo(() => getYSerializableScale(targetSeries == null ? void 0 : targetSeries.yAxisId), [getYSerializableScale, targetSeries == null ? void 0 : targetSeries.yAxisId]);
45
+ const color = useMemo(() => {
46
+ var _ref2;
47
+ return (_ref2 = colorProp != null ? colorProp : targetSeries == null ? void 0 : targetSeries.color) != null ? _ref2 : theme.color.fgPrimary;
48
+ }, [colorProp, targetSeries == null ? void 0 : targetSeries.color, theme.color.fgPrimary]);
49
+ const updateTransition = useMemo(() => {
50
+ var _transitions$update;
51
+ return (_transitions$update = transitions == null ? void 0 : transitions.update) != null ? _transitions$update : defaultTransition;
52
+ }, [transitions == null ? void 0 : transitions.update]);
53
+ const pulseTransition = useMemo(() => {
54
+ var _transitions$pulse;
55
+ return (_transitions$pulse = transitions == null ? void 0 : transitions.pulse) != null ? _transitions$pulse : defaultPulseTransition;
56
+ }, [transitions == null ? void 0 : transitions.pulse]);
57
+ const pulseRepeatDelay = useMemo(() => {
58
+ var _transitions$pulseRep;
59
+ return (_transitions$pulseRep = transitions == null ? void 0 : transitions.pulseRepeatDelay) != null ? _transitions$pulseRep : defaultPulseRepeatDelay;
60
+ }, [transitions == null ? void 0 : transitions.pulseRepeatDelay]);
61
+ const pulseOpacity = useSharedValue(0);
62
+ const pulseRadius = useSharedValue(pulseRadiusStart);
63
+ const animatedX = useSharedValue(0);
64
+ const animatedY = useSharedValue(0);
65
+
66
+ // Calculate the target point position - project data to pixels
67
+ const targetPoint = useDerivedValue(() => {
68
+ if (!xScale || !yScale) return {
69
+ x: 0,
70
+ y: 0
71
+ };
72
+ return projectPointWithSerializableScale({
73
+ x: unwrapAnimatedValue(dataX),
74
+ y: unwrapAnimatedValue(dataY),
75
+ xScale,
76
+ yScale
77
+ });
78
+ }, [dataX, dataY, xScale, yScale]);
79
+ useAnimatedReaction(() => {
80
+ return {
81
+ point: targetPoint.value,
82
+ isIdle: unwrapAnimatedValue(isIdle)
83
+ };
84
+ }, (current, previous) => {
85
+ // When animation is disabled, on initial render, or when we are starting,
86
+ // continuing, or finishing scrubbing we should immediately transition
87
+ if (!animate || previous === null || !previous.isIdle || !current.isIdle) {
88
+ animatedX.value = current.point.x;
89
+ animatedY.value = current.point.y;
90
+ return;
91
+ }
92
+ animatedX.value = buildTransition(current.point.x, updateTransition);
93
+ animatedY.value = buildTransition(current.point.y, updateTransition);
94
+ }, [animate, updateTransition]);
95
+
96
+ // Create animated point using the animated values
97
+ const animatedPoint = useDerivedValue(() => {
98
+ return {
99
+ x: animatedX.value,
100
+ y: animatedY.value
101
+ };
102
+ }, [animatedX, animatedY]);
103
+ useImperativeHandle(ref, () => ({
104
+ pulse: () => {
105
+ // Only trigger manual pulse when idlePulse is not enabled
106
+ if (!idlePulse) {
107
+ cancelAnimation(pulseOpacity);
108
+ cancelAnimation(pulseRadius);
109
+
110
+ // Manual pulse without delay
111
+ const immediatePulseTransition = _extends({}, pulseTransition, {
112
+ delay: 0
113
+ });
114
+ pulseOpacity.value = pulseOpacityStart;
115
+ pulseRadius.value = pulseRadiusStart;
116
+ pulseOpacity.value = buildTransition(pulseOpacityEnd, immediatePulseTransition);
117
+ pulseRadius.value = buildTransition(pulseRadiusEnd, immediatePulseTransition);
118
+ }
119
+ }
120
+ }), [idlePulse, pulseOpacity, pulseRadius, pulseTransition]);
121
+
122
+ // Watch idlePulse changes and control continuous pulse
123
+ useAnimatedReaction(() => idlePulse, (current, previous) => {
124
+ if (!animate) return;
125
+ if (current) {
126
+ // Start continuous pulse when idlePulse is enabled
127
+ // Create instant transition to reset pulse after delay
128
+ const instantTransition = {
129
+ type: 'timing',
130
+ duration: 0
131
+ };
132
+ const resetWithDelay = _extends({}, instantTransition, {
133
+ delay: pulseRepeatDelay
134
+ });
135
+ pulseOpacity.value = pulseOpacityStart;
136
+ pulseRadius.value = pulseRadiusStart;
137
+ pulseOpacity.value = withRepeat(withSequence(buildTransition(pulseOpacityEnd, pulseTransition), buildTransition(pulseOpacityStart, resetWithDelay)), -1,
138
+ // infinite loop
139
+ false);
140
+ pulseRadius.value = withRepeat(withSequence(buildTransition(pulseRadiusEnd, pulseTransition), buildTransition(pulseRadiusStart, resetWithDelay)), -1,
141
+ // infinite loop
142
+ false);
143
+ } else {
144
+ // Stop pulse when idlePulse is disabled
145
+ cancelAnimation(pulseOpacity);
146
+ cancelAnimation(pulseRadius);
147
+ pulseOpacity.value = pulseOpacityEnd;
148
+ pulseRadius.value = pulseRadiusStart;
149
+ }
150
+ }, [animate, pulseTransition, pulseRepeatDelay]);
151
+ const pulseVisibility = useDerivedValue(() => {
152
+ // Never pulse when scrubbing
153
+ if (!unwrapAnimatedValue(isIdle)) return 0;
154
+ return pulseOpacity.value;
155
+ }, [isIdle, pulseOpacity]);
156
+ const beaconOpacity = useDerivedValue(() => {
157
+ const point = targetPoint.value;
158
+ const isWithinDrawingArea = point.x >= drawingArea.x && point.x <= drawingArea.x + drawingArea.width && point.y >= drawingArea.y && point.y <= drawingArea.y + drawingArea.height;
159
+ const userOpacity = unwrapAnimatedValue(opacityProp);
160
+ return isWithinDrawingArea ? userOpacity : 0;
161
+ }, [targetPoint, drawingArea, opacityProp]);
162
+ return /*#__PURE__*/_jsxs(Group, {
163
+ opacity: beaconOpacity,
164
+ children: [/*#__PURE__*/_jsx(Circle, {
165
+ c: animatedPoint,
166
+ color: color,
167
+ opacity: pulseVisibility,
168
+ r: pulseRadius
169
+ }), /*#__PURE__*/_jsx(Circle, {
170
+ c: animatedPoint,
171
+ color: theme.color.bg,
172
+ r: radius + strokeWidth / 2
173
+ }), /*#__PURE__*/_jsx(Circle, {
174
+ c: animatedPoint,
175
+ color: color,
176
+ r: radius - strokeWidth / 2
177
+ })]
178
+ });
179
+ }));
@@ -0,0 +1,43 @@
1
+ const _excluded = ["background", "color", "elevated", "borderRadius", "font", "verticalAlignment", "inset", "label"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
+ import { memo } from 'react';
5
+ import { useTheme } from '@coinbase/cds-mobile';
6
+ import { ChartText } from '../text';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const labelVerticalInset = 3.5;
9
+ const labelHorizontalInset = 4;
10
+ /**
11
+ * DefaultScrubberBeaconLabel is a special instance of ChartText used to label a series' scrubber beacon.
12
+ */
13
+ export const DefaultScrubberBeaconLabel = /*#__PURE__*/memo(_ref => {
14
+ let {
15
+ background,
16
+ color,
17
+ elevated = true,
18
+ borderRadius = 4,
19
+ font = 'label1',
20
+ verticalAlignment = 'middle',
21
+ inset = {
22
+ left: labelHorizontalInset,
23
+ right: labelHorizontalInset,
24
+ top: labelVerticalInset,
25
+ bottom: labelVerticalInset
26
+ },
27
+ label
28
+ } = _ref,
29
+ chartTextProps = _objectWithoutPropertiesLoose(_ref, _excluded);
30
+ const theme = useTheme();
31
+ return /*#__PURE__*/_jsx(ChartText, _extends({
32
+ disableRepositioning: true,
33
+ background: background != null ? background : theme.color.bg,
34
+ borderRadius: borderRadius,
35
+ color: color != null ? color : theme.color.fgPrimary,
36
+ elevated: elevated,
37
+ font: font,
38
+ inset: inset,
39
+ verticalAlignment: verticalAlignment
40
+ }, chartTextProps, {
41
+ children: label
42
+ }));
43
+ });
@@ -0,0 +1,28 @@
1
+ const _excluded = ["verticalAlignment", "dy", "boundsInset"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
+ import { memo } from 'react';
5
+ import { useCartesianChartContext } from '../ChartProvider';
6
+ import { DefaultReferenceLineLabel } from '../line';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ /**
9
+ * DefaultScrubberLabel is the default label component for the scrubber line.
10
+ * It will automatically add padding around the label when elevated to fit within chart bounds to prevent shadow from being cutoff.
11
+ * It will also center the label vertically with the top available area.
12
+ */
13
+ export const DefaultScrubberLabel = /*#__PURE__*/memo(_ref => {
14
+ let {
15
+ verticalAlignment = 'middle',
16
+ dy,
17
+ boundsInset
18
+ } = _ref,
19
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
20
+ const {
21
+ drawingArea
22
+ } = useCartesianChartContext();
23
+ return /*#__PURE__*/_jsx(DefaultReferenceLineLabel, _extends({
24
+ boundsInset: boundsInset,
25
+ dy: dy != null ? dy : -0.5 * drawingArea.y,
26
+ verticalAlignment: verticalAlignment
27
+ }, props));
28
+ });