@coinbase/cds-mobile-visualization 3.8.1 → 4.0.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 (303) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dts/chart/index.d.ts +1 -15
  3. package/dts/chart/index.d.ts.map +1 -1
  4. package/dts/index.d.ts.map +1 -1
  5. package/dts/sparkline/index.d.ts +1 -5
  6. package/dts/sparkline/index.d.ts.map +1 -1
  7. package/esm/chart/index.js +1 -17
  8. package/esm/index.js +1 -3
  9. package/esm/sparkline/index.js +1 -5
  10. package/package.json +26 -20
  11. package/dts/chart/CartesianChart.d.ts +0 -206
  12. package/dts/chart/CartesianChart.d.ts.map +0 -1
  13. package/dts/chart/ChartContextBridge.d.ts +0 -28
  14. package/dts/chart/ChartContextBridge.d.ts.map +0 -1
  15. package/dts/chart/ChartProvider.d.ts +0 -9
  16. package/dts/chart/ChartProvider.d.ts.map +0 -1
  17. package/dts/chart/Path.d.ts +0 -121
  18. package/dts/chart/Path.d.ts.map +0 -1
  19. package/dts/chart/PeriodSelector.d.ts +0 -100
  20. package/dts/chart/PeriodSelector.d.ts.map +0 -1
  21. package/dts/chart/area/Area.d.ts +0 -83
  22. package/dts/chart/area/Area.d.ts.map +0 -1
  23. package/dts/chart/area/AreaChart.d.ts +0 -155
  24. package/dts/chart/area/AreaChart.d.ts.map +0 -1
  25. package/dts/chart/area/DottedArea.d.ts +0 -46
  26. package/dts/chart/area/DottedArea.d.ts.map +0 -1
  27. package/dts/chart/area/GradientArea.d.ts +0 -36
  28. package/dts/chart/area/GradientArea.d.ts.map +0 -1
  29. package/dts/chart/area/SolidArea.d.ts +0 -23
  30. package/dts/chart/area/SolidArea.d.ts.map +0 -1
  31. package/dts/chart/area/index.d.ts +0 -6
  32. package/dts/chart/area/index.d.ts.map +0 -1
  33. package/dts/chart/axis/Axis.d.ts +0 -174
  34. package/dts/chart/axis/Axis.d.ts.map +0 -1
  35. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +0 -8
  36. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +0 -1
  37. package/dts/chart/axis/XAxis.d.ts +0 -22
  38. package/dts/chart/axis/XAxis.d.ts.map +0 -1
  39. package/dts/chart/axis/YAxis.d.ts +0 -22
  40. package/dts/chart/axis/YAxis.d.ts.map +0 -1
  41. package/dts/chart/axis/index.d.ts +0 -5
  42. package/dts/chart/axis/index.d.ts.map +0 -1
  43. package/dts/chart/bar/Bar.d.ts +0 -100
  44. package/dts/chart/bar/Bar.d.ts.map +0 -1
  45. package/dts/chart/bar/BarChart.d.ts +0 -158
  46. package/dts/chart/bar/BarChart.d.ts.map +0 -1
  47. package/dts/chart/bar/BarPlot.d.ts +0 -31
  48. package/dts/chart/bar/BarPlot.d.ts.map +0 -1
  49. package/dts/chart/bar/BarStack.d.ts +0 -127
  50. package/dts/chart/bar/BarStack.d.ts.map +0 -1
  51. package/dts/chart/bar/BarStackGroup.d.ts +0 -37
  52. package/dts/chart/bar/BarStackGroup.d.ts.map +0 -1
  53. package/dts/chart/bar/DefaultBar.d.ts +0 -7
  54. package/dts/chart/bar/DefaultBar.d.ts.map +0 -1
  55. package/dts/chart/bar/DefaultBarStack.d.ts +0 -7
  56. package/dts/chart/bar/DefaultBarStack.d.ts.map +0 -1
  57. package/dts/chart/bar/PercentageBarChart.d.ts +0 -106
  58. package/dts/chart/bar/PercentageBarChart.d.ts.map +0 -1
  59. package/dts/chart/bar/index.d.ts +0 -9
  60. package/dts/chart/bar/index.d.ts.map +0 -1
  61. package/dts/chart/gradient/Gradient.d.ts +0 -41
  62. package/dts/chart/gradient/Gradient.d.ts.map +0 -1
  63. package/dts/chart/gradient/index.d.ts +0 -2
  64. package/dts/chart/gradient/index.d.ts.map +0 -1
  65. package/dts/chart/legend/DefaultLegendEntry.d.ts +0 -5
  66. package/dts/chart/legend/DefaultLegendEntry.d.ts.map +0 -1
  67. package/dts/chart/legend/DefaultLegendShape.d.ts +0 -5
  68. package/dts/chart/legend/DefaultLegendShape.d.ts.map +0 -1
  69. package/dts/chart/legend/Legend.d.ts +0 -168
  70. package/dts/chart/legend/Legend.d.ts.map +0 -1
  71. package/dts/chart/legend/index.d.ts +0 -4
  72. package/dts/chart/legend/index.d.ts.map +0 -1
  73. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +0 -9
  74. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +0 -1
  75. package/dts/chart/line/DottedLine.d.ts +0 -20
  76. package/dts/chart/line/DottedLine.d.ts.map +0 -1
  77. package/dts/chart/line/Line.d.ts +0 -122
  78. package/dts/chart/line/Line.d.ts.map +0 -1
  79. package/dts/chart/line/LineChart.d.ts +0 -135
  80. package/dts/chart/line/LineChart.d.ts.map +0 -1
  81. package/dts/chart/line/ReferenceLine.d.ts +0 -140
  82. package/dts/chart/line/ReferenceLine.d.ts.map +0 -1
  83. package/dts/chart/line/SolidLine.d.ts +0 -15
  84. package/dts/chart/line/SolidLine.d.ts.map +0 -1
  85. package/dts/chart/line/index.d.ts +0 -7
  86. package/dts/chart/line/index.d.ts.map +0 -1
  87. package/dts/chart/point/DefaultPointLabel.d.ts +0 -10
  88. package/dts/chart/point/DefaultPointLabel.d.ts.map +0 -1
  89. package/dts/chart/point/Point.d.ts +0 -144
  90. package/dts/chart/point/Point.d.ts.map +0 -1
  91. package/dts/chart/point/index.d.ts +0 -3
  92. package/dts/chart/point/index.d.ts.map +0 -1
  93. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +0 -38
  94. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +0 -1
  95. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +0 -12
  96. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +0 -1
  97. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +0 -12
  98. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +0 -1
  99. package/dts/chart/scrubber/Scrubber.d.ts +0 -302
  100. package/dts/chart/scrubber/Scrubber.d.ts.map +0 -1
  101. package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +0 -12
  102. package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +0 -1
  103. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +0 -54
  104. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +0 -1
  105. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +0 -46
  106. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +0 -1
  107. package/dts/chart/scrubber/ScrubberProvider.d.ts +0 -20
  108. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +0 -1
  109. package/dts/chart/scrubber/index.d.ts +0 -5
  110. package/dts/chart/scrubber/index.d.ts.map +0 -1
  111. package/dts/chart/text/ChartText.d.ts +0 -164
  112. package/dts/chart/text/ChartText.d.ts.map +0 -1
  113. package/dts/chart/text/ChartTextGroup.d.ts +0 -61
  114. package/dts/chart/text/ChartTextGroup.d.ts.map +0 -1
  115. package/dts/chart/text/index.d.ts +0 -3
  116. package/dts/chart/text/index.d.ts.map +0 -1
  117. package/dts/chart/utils/axis.d.ts +0 -387
  118. package/dts/chart/utils/axis.d.ts.map +0 -1
  119. package/dts/chart/utils/bar.d.ts +0 -225
  120. package/dts/chart/utils/bar.d.ts.map +0 -1
  121. package/dts/chart/utils/chart.d.ts +0 -165
  122. package/dts/chart/utils/chart.d.ts.map +0 -1
  123. package/dts/chart/utils/context.d.ts +0 -131
  124. package/dts/chart/utils/context.d.ts.map +0 -1
  125. package/dts/chart/utils/gradient.d.ts +0 -129
  126. package/dts/chart/utils/gradient.d.ts.map +0 -1
  127. package/dts/chart/utils/index.d.ts +0 -11
  128. package/dts/chart/utils/index.d.ts.map +0 -1
  129. package/dts/chart/utils/path.d.ts +0 -186
  130. package/dts/chart/utils/path.d.ts.map +0 -1
  131. package/dts/chart/utils/point.d.ts +0 -146
  132. package/dts/chart/utils/point.d.ts.map +0 -1
  133. package/dts/chart/utils/scale.d.ts +0 -145
  134. package/dts/chart/utils/scale.d.ts.map +0 -1
  135. package/dts/chart/utils/scrubber.d.ts +0 -40
  136. package/dts/chart/utils/scrubber.d.ts.map +0 -1
  137. package/dts/chart/utils/transition.d.ts +0 -181
  138. package/dts/chart/utils/transition.d.ts.map +0 -1
  139. package/dts/sparkline/Counter.d.ts +0 -8
  140. package/dts/sparkline/Counter.d.ts.map +0 -1
  141. package/dts/sparkline/Sparkline.d.ts +0 -74
  142. package/dts/sparkline/Sparkline.d.ts.map +0 -1
  143. package/dts/sparkline/SparklineArea.d.ts +0 -15
  144. package/dts/sparkline/SparklineArea.d.ts.map +0 -1
  145. package/dts/sparkline/SparklineAreaPattern.d.ts +0 -14
  146. package/dts/sparkline/SparklineAreaPattern.d.ts.map +0 -1
  147. package/dts/sparkline/SparklineGradient.d.ts +0 -24
  148. package/dts/sparkline/SparklineGradient.d.ts.map +0 -1
  149. package/dts/sparkline/__figma__/Sparkline.figma.d.ts +0 -2
  150. package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +0 -1
  151. package/dts/sparkline/generateSparklineWithId.d.ts +0 -11
  152. package/dts/sparkline/generateSparklineWithId.d.ts.map +0 -1
  153. package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +0 -23
  154. package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts.map +0 -1
  155. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +0 -185
  156. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +0 -1
  157. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +0 -25
  158. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +0 -1
  159. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +0 -28
  160. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +0 -1
  161. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +0 -13
  162. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +0 -1
  163. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +0 -17
  164. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +0 -1
  165. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +0 -11
  166. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts.map +0 -1
  167. package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +0 -26
  168. package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts.map +0 -1
  169. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +0 -25
  170. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +0 -1
  171. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +0 -25
  172. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +0 -1
  173. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +0 -39
  174. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +0 -1
  175. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +0 -31
  176. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +0 -1
  177. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +0 -2
  178. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +0 -1
  179. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +0 -13
  180. package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts.map +0 -1
  181. package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +0 -16
  182. package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts.map +0 -1
  183. package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +0 -6
  184. package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts.map +0 -1
  185. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +0 -22
  186. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +0 -1
  187. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +0 -34
  188. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts.map +0 -1
  189. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +0 -118
  190. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +0 -1
  191. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +0 -2
  192. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +0 -1
  193. package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +0 -29
  194. package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts.map +0 -1
  195. package/esm/chart/CartesianChart.js +0 -431
  196. package/esm/chart/ChartContextBridge.js +0 -159
  197. package/esm/chart/ChartProvider.js +0 -10
  198. package/esm/chart/Path.js +0 -255
  199. package/esm/chart/PeriodSelector.js +0 -139
  200. package/esm/chart/__stories__/CartesianChart.stories.js +0 -659
  201. package/esm/chart/__stories__/ChartAccessibility.stories.js +0 -721
  202. package/esm/chart/__stories__/ChartTransitions.stories.js +0 -693
  203. package/esm/chart/__stories__/PeriodSelector.stories.js +0 -420
  204. package/esm/chart/area/Area.js +0 -85
  205. package/esm/chart/area/AreaChart.js +0 -152
  206. package/esm/chart/area/DottedArea.js +0 -92
  207. package/esm/chart/area/GradientArea.js +0 -63
  208. package/esm/chart/area/SolidArea.js +0 -45
  209. package/esm/chart/area/__stories__/AreaChart.stories.js +0 -370
  210. package/esm/chart/area/index.js +0 -7
  211. package/esm/chart/axis/Axis.js +0 -9
  212. package/esm/chart/axis/DefaultAxisTickLabel.js +0 -11
  213. package/esm/chart/axis/XAxis.js +0 -256
  214. package/esm/chart/axis/YAxis.js +0 -255
  215. package/esm/chart/axis/__stories__/Axis.stories.js +0 -552
  216. package/esm/chart/axis/index.js +0 -6
  217. package/esm/chart/bar/Bar.js +0 -71
  218. package/esm/chart/bar/BarChart.js +0 -122
  219. package/esm/chart/bar/BarPlot.js +0 -106
  220. package/esm/chart/bar/BarStack.js +0 -173
  221. package/esm/chart/bar/BarStackGroup.js +0 -89
  222. package/esm/chart/bar/DefaultBar.js +0 -79
  223. package/esm/chart/bar/DefaultBarStack.js +0 -68
  224. package/esm/chart/bar/PercentageBarChart.js +0 -99
  225. package/esm/chart/bar/__stories__/BarChart.stories.js +0 -1417
  226. package/esm/chart/bar/__stories__/PercentageBarChart.stories.js +0 -833
  227. package/esm/chart/bar/index.js +0 -10
  228. package/esm/chart/gradient/Gradient.js +0 -156
  229. package/esm/chart/gradient/index.js +0 -1
  230. package/esm/chart/legend/DefaultLegendEntry.js +0 -42
  231. package/esm/chart/legend/DefaultLegendShape.js +0 -64
  232. package/esm/chart/legend/Legend.js +0 -59
  233. package/esm/chart/legend/__stories__/Legend.stories.js +0 -574
  234. package/esm/chart/legend/index.js +0 -3
  235. package/esm/chart/line/DefaultReferenceLineLabel.js +0 -66
  236. package/esm/chart/line/DottedLine.js +0 -57
  237. package/esm/chart/line/Line.js +0 -180
  238. package/esm/chart/line/LineChart.js +0 -149
  239. package/esm/chart/line/ReferenceLine.js +0 -132
  240. package/esm/chart/line/SolidLine.js +0 -53
  241. package/esm/chart/line/__stories__/LineChart.stories.js +0 -2018
  242. package/esm/chart/line/__stories__/ReferenceLine.stories.js +0 -226
  243. package/esm/chart/line/index.js +0 -8
  244. package/esm/chart/point/DefaultPointLabel.js +0 -39
  245. package/esm/chart/point/Point.js +0 -187
  246. package/esm/chart/point/index.js +0 -2
  247. package/esm/chart/scrubber/DefaultScrubberBeacon.js +0 -182
  248. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +0 -43
  249. package/esm/chart/scrubber/DefaultScrubberLabel.js +0 -44
  250. package/esm/chart/scrubber/Scrubber.js +0 -198
  251. package/esm/chart/scrubber/ScrubberAccessibilityView.js +0 -177
  252. package/esm/chart/scrubber/ScrubberBeaconGroup.js +0 -169
  253. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +0 -212
  254. package/esm/chart/scrubber/ScrubberProvider.js +0 -140
  255. package/esm/chart/scrubber/__stories__/Scrubber.stories.js +0 -946
  256. package/esm/chart/scrubber/index.js +0 -4
  257. package/esm/chart/text/ChartText.js +0 -305
  258. package/esm/chart/text/ChartTextGroup.js +0 -211
  259. package/esm/chart/text/index.js +0 -4
  260. package/esm/chart/utils/axis.js +0 -664
  261. package/esm/chart/utils/bar.js +0 -906
  262. package/esm/chart/utils/chart.js +0 -329
  263. package/esm/chart/utils/context.js +0 -22
  264. package/esm/chart/utils/gradient.js +0 -319
  265. package/esm/chart/utils/index.js +0 -12
  266. package/esm/chart/utils/path.js +0 -304
  267. package/esm/chart/utils/point.js +0 -282
  268. package/esm/chart/utils/scale.js +0 -288
  269. package/esm/chart/utils/scrubber.js +0 -146
  270. package/esm/chart/utils/transition.js +0 -241
  271. package/esm/sparkline/Counter.js +0 -45
  272. package/esm/sparkline/Sparkline.js +0 -165
  273. package/esm/sparkline/SparklineArea.js +0 -20
  274. package/esm/sparkline/SparklineAreaPattern.js +0 -38
  275. package/esm/sparkline/SparklineGradient.js +0 -77
  276. package/esm/sparkline/__figma__/Sparkline.figma.js +0 -22
  277. package/esm/sparkline/__stories__/Sparkline.stories.js +0 -124
  278. package/esm/sparkline/__stories__/SparklineGradient.stories.js +0 -126
  279. package/esm/sparkline/generateSparklineWithId.js +0 -7
  280. package/esm/sparkline/sparkline-interactive/SparklineAccessibleView.js +0 -75
  281. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +0 -308
  282. package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +0 -116
  283. package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +0 -131
  284. package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +0 -99
  285. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +0 -82
  286. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMinMax.js +0 -103
  287. package/esm/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.js +0 -104
  288. package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +0 -57
  289. package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +0 -124
  290. package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +0 -80
  291. package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +0 -109
  292. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +0 -85
  293. package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +0 -526
  294. package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.js +0 -58
  295. package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.js +0 -37
  296. package/esm/sparkline/sparkline-interactive/useMinMaxTransform.js +0 -56
  297. package/esm/sparkline/sparkline-interactive/useOpacityAnimation.js +0 -23
  298. package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +0 -47
  299. package/esm/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.js +0 -34
  300. package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +0 -233
  301. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +0 -104
  302. package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +0 -565
  303. package/esm/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.js +0 -117
@@ -1,226 +0,0 @@
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, useMemo } from 'react';
5
- import { useDerivedValue, withTiming } from 'react-native-reanimated';
6
- import { sparklineInteractiveData } from '@coinbase/cds-common/internal/visualizations/SparklineInteractiveData';
7
- import { useTheme } from '@coinbase/cds-mobile';
8
- import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
9
- import { useCartesianChartContext } from '../../ChartProvider';
10
- import { Scrubber } from '../../scrubber';
11
- import { getPointOnSerializableScale, useScrubberContext } from '../../utils';
12
- import { DefaultReferenceLineLabel } from '../DefaultReferenceLineLabel';
13
- import { DottedLine } from '../DottedLine';
14
- import { LineChart } from '../LineChart';
15
- import { ReferenceLine } from '../ReferenceLine';
16
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
- const LiquidationLabelMobile = /*#__PURE__*/memo(_ref => {
18
- let {
19
- accentColor,
20
- yellowColor
21
- } = _ref,
22
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
23
- return /*#__PURE__*/_jsx(DefaultReferenceLineLabel, _extends({}, props, {
24
- background: accentColor,
25
- borderRadius: 100,
26
- color: "rgb(" + yellowColor + ")",
27
- horizontalAlignment: "left",
28
- inset: {
29
- top: 4,
30
- bottom: 4,
31
- left: 8,
32
- right: 8
33
- }
34
- }));
35
- });
36
- const ReferenceLineStories = () => {
37
- const theme = useTheme();
38
- const liquidationLabelComponent = useCallback(props => /*#__PURE__*/_jsx(LiquidationLabelMobile, _extends({}, props, {
39
- accentColor: theme.color.accentSubtleYellow,
40
- yellowColor: theme.spectrum.yellow70
41
- })), [theme.color.accentSubtleYellow, theme.spectrum.yellow70]);
42
- return /*#__PURE__*/_jsxs(ExampleScreen, {
43
- children: [/*#__PURE__*/_jsx(Example, {
44
- title: "Simple Reference Line",
45
- children: /*#__PURE__*/_jsx(LineChart, {
46
- showArea: true,
47
- height: 250,
48
- series: [{
49
- id: 'prices',
50
- data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58],
51
- color: theme.color.fgPositive
52
- }],
53
- children: /*#__PURE__*/_jsx(ReferenceLine, {
54
- LineComponent: props => /*#__PURE__*/_jsx(DottedLine, _extends({}, props, {
55
- dashIntervals: [0, 16],
56
- strokeWidth: 3
57
- })),
58
- dataY: 10,
59
- stroke: theme.color.fg
60
- })
61
- })
62
- }), /*#__PURE__*/_jsx(Example, {
63
- title: "With Labels",
64
- children: /*#__PURE__*/_jsxs(LineChart, {
65
- showArea: true,
66
- height: 250,
67
- inset: 0,
68
- series: [{
69
- id: 'prices',
70
- data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
71
- }],
72
- children: [/*#__PURE__*/_jsx(ReferenceLine, {
73
- dataX: 4,
74
- label: "Vertical Reference Line",
75
- labelHorizontalAlignment: "left"
76
- }), /*#__PURE__*/_jsx(ReferenceLine, {
77
- dataY: 70,
78
- label: "Horizontal Reference Line",
79
- labelHorizontalAlignment: "right",
80
- labelVerticalAlignment: "bottom"
81
- })]
82
- })
83
- }), /*#__PURE__*/_jsx(Example, {
84
- title: "Label Customization",
85
- children: /*#__PURE__*/_jsxs(LineChart, {
86
- showArea: true,
87
- height: 250,
88
- series: [{
89
- id: 'prices',
90
- data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
91
- }],
92
- children: [/*#__PURE__*/_jsx(ReferenceLine, {
93
- dataY: 75,
94
- label: "Top Right",
95
- labelDx: -8,
96
- labelDy: -8,
97
- labelFont: "label1",
98
- labelHorizontalAlignment: "right",
99
- labelPosition: "right",
100
- labelVerticalAlignment: "bottom"
101
- }), /*#__PURE__*/_jsx(ReferenceLine, {
102
- dataX: 7,
103
- label: "Bottom Left",
104
- labelDx: 8,
105
- labelDy: 8,
106
- labelFont: "label1",
107
- labelHorizontalAlignment: "left",
108
- labelPosition: "top",
109
- labelVerticalAlignment: "top"
110
- })]
111
- })
112
- }), /*#__PURE__*/_jsx(Example, {
113
- title: "With Custom Label Component",
114
- children: /*#__PURE__*/_jsx(LineChart, {
115
- height: 250,
116
- inset: {
117
- right: 32,
118
- top: 0,
119
- left: 0,
120
- bottom: 0
121
- },
122
- series: [{
123
- id: 'prices',
124
- data: [10, 22, 29, 45, 98, 45, 22, 52, 21, 4, 68, 20, 21, 58]
125
- }],
126
- children: /*#__PURE__*/_jsx(ReferenceLine, {
127
- LabelComponent: liquidationLabelComponent,
128
- dataY: 25,
129
- label: "Liquidation",
130
- labelPosition: "left",
131
- stroke: theme.color.bgWarning
132
- })
133
- })
134
- }), /*#__PURE__*/_jsx(Example, {
135
- title: "Start Price Reference Line",
136
- children: /*#__PURE__*/_jsx(StartPriceReferenceLine, {})
137
- })]
138
- });
139
- };
140
- const FADE_ZONE = 128;
141
- const StartPriceLabel = /*#__PURE__*/memo(props => {
142
- const theme = useTheme();
143
- const {
144
- scrubberPosition
145
- } = useScrubberContext();
146
- const {
147
- getXSerializableScale,
148
- drawingArea
149
- } = useCartesianChartContext();
150
- const xScale = useMemo(() => getXSerializableScale(), [getXSerializableScale]);
151
- const opacity = useDerivedValue(() => {
152
- if (scrubberPosition.value === undefined) return withTiming(0, {
153
- duration: 250
154
- });
155
- if (!xScale) return withTiming(1, {
156
- duration: 250
157
- });
158
- const scrubX = getPointOnSerializableScale(scrubberPosition.value, xScale);
159
- const rightEdge = drawingArea.x + drawingArea.width;
160
- const target = rightEdge - scrubX >= FADE_ZONE ? 1 : 0;
161
- return withTiming(target, {
162
- duration: 250
163
- });
164
- }, [scrubberPosition, xScale, drawingArea]);
165
- return /*#__PURE__*/_jsx(DefaultReferenceLineLabel, _extends({}, props, {
166
- background: theme.color.bgSecondary,
167
- borderRadius: 12.5,
168
- color: theme.color.fg,
169
- font: "label1",
170
- inset: {
171
- top: 4,
172
- bottom: 4,
173
- left: 8,
174
- right: 8
175
- },
176
- opacity: opacity
177
- }));
178
- });
179
- function StartPriceReferenceLine() {
180
- const theme = useTheme();
181
- const hourData = useMemo(() => sparklineInteractiveData.hour, []);
182
- const startPrice = hourData[0].value;
183
- const endPrice = hourData[hourData.length - 1].value;
184
- const isPositive = endPrice >= startPrice;
185
- const seriesColor = isPositive ? theme.color.fgPositive : theme.color.fgNegative;
186
- return /*#__PURE__*/_jsxs(LineChart, {
187
- enableScrubbing: true,
188
- showArea: true,
189
- areaType: "dotted",
190
- height: 300,
191
- inset: 0,
192
- series: [{
193
- id: 'hourly-prices',
194
- data: hourData.map(d => d.value),
195
- color: seriesColor
196
- }],
197
- xAxis: {
198
- range: _ref2 => {
199
- let {
200
- min,
201
- max
202
- } = _ref2;
203
- return {
204
- min,
205
- max: max - 24
206
- };
207
- }
208
- },
209
- children: [/*#__PURE__*/_jsx(Scrubber, {}), /*#__PURE__*/_jsx(ReferenceLine, {
210
- LabelComponent: StartPriceLabel,
211
- LineComponent: props => /*#__PURE__*/_jsx(DottedLine, _extends({}, props, {
212
- dashIntervals: [0, 16],
213
- strokeWidth: 3
214
- })),
215
- dataY: startPrice,
216
- label: startPrice.toLocaleString('en-US', {
217
- minimumFractionDigits: 2,
218
- maximumFractionDigits: 2
219
- }),
220
- labelDx: -12,
221
- labelHorizontalAlignment: "right",
222
- stroke: theme.color.fgMuted
223
- })]
224
- });
225
- }
226
- export default ReferenceLineStories;
@@ -1,8 +0,0 @@
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
@@ -1,39 +0,0 @@
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
- });
@@ -1,187 +0,0 @@
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, defaultAccessoryEnterTransition, defaultTransition, getTransition } 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
- xAxisId,
20
- yAxisId,
21
- fill: fillProp,
22
- radius = 5,
23
- opacity,
24
- stroke: strokeProp,
25
- strokeWidth = 2,
26
- label,
27
- LabelComponent = DefaultPointLabel,
28
- labelPosition = 'center',
29
- labelOffset,
30
- labelFont,
31
- transitions,
32
- transition,
33
- animate: animateProp
34
- } = _ref;
35
- const theme = useTheme();
36
- const stroke = strokeProp != null ? strokeProp : theme.color.bg;
37
- const fill = fillProp != null ? fillProp : theme.color.fgPrimary;
38
- const {
39
- getXScale,
40
- getYScale,
41
- animate: animationEnabled,
42
- drawingArea
43
- } = useCartesianChartContext();
44
- const animate = animateProp != null ? animateProp : animationEnabled;
45
- const xScale = getXScale(xAxisId);
46
- const yScale = getYScale(yAxisId);
47
- const shouldAnimate = animate != null ? animate : false;
48
- const updateTransition = useMemo(() => getTransition((transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), [animate, transitions == null ? void 0 : transitions.update, transition]);
49
- const enterTransition = useMemo(() => getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultAccessoryEnterTransition), [animate, transitions == null ? void 0 : transitions.enter]);
50
-
51
- // Calculate pixel coordinates from data coordinates
52
- const pixelCoordinate = useMemo(() => {
53
- if (!xScale || !yScale) {
54
- return undefined;
55
- }
56
- return projectPoint({
57
- x: dataX,
58
- y: dataY,
59
- xScale,
60
- yScale
61
- });
62
- }, [xScale, yScale, dataX, dataY]);
63
- const previousPixelCoordinate = usePreviousValue(pixelCoordinate);
64
- const previousFill = usePreviousValue(fill);
65
-
66
- // Animated values for position
67
- const animatedX = useSharedValue(0);
68
- const animatedY = useSharedValue(0);
69
- const enterOpacity = useSharedValue(shouldAnimate ? 0 : 1);
70
- const colorProgress = useSharedValue(1);
71
- const isReady = !!xScale && !!yScale;
72
- useEffect(() => {
73
- if (!shouldAnimate || !isReady) return;
74
- enterOpacity.value = buildTransition(1, enterTransition);
75
- }, [shouldAnimate, isReady, enterTransition, enterOpacity]);
76
-
77
- // Update position when coordinates change
78
- useEffect(() => {
79
- if (!pixelCoordinate) {
80
- return;
81
- }
82
- if (shouldAnimate && previousPixelCoordinate) {
83
- animatedX.value = buildTransition(pixelCoordinate.x, updateTransition);
84
- animatedY.value = buildTransition(pixelCoordinate.y, updateTransition);
85
- } else {
86
- cancelAnimation(animatedX);
87
- cancelAnimation(animatedY);
88
- animatedX.value = pixelCoordinate.x;
89
- animatedY.value = pixelCoordinate.y;
90
- }
91
- }, [pixelCoordinate, shouldAnimate, previousPixelCoordinate, animatedX, animatedY, updateTransition]);
92
-
93
- // Update color when fill changes
94
- useEffect(() => {
95
- if (shouldAnimate && previousFill && previousFill !== fill) {
96
- colorProgress.value = 0;
97
- colorProgress.value = buildTransition(1, updateTransition);
98
- } else {
99
- cancelAnimation(colorProgress);
100
- colorProgress.value = 1;
101
- }
102
- }, [fill, shouldAnimate, previousFill, colorProgress, updateTransition]);
103
-
104
- // Create animated point for circles
105
- const animatedPoint = useDerivedValue(() => {
106
- return {
107
- x: animatedX.value,
108
- y: animatedY.value
109
- };
110
- }, [animatedX, animatedY]);
111
-
112
- // Interpolate between previous and current fill color
113
- const animatedFillColor = useDerivedValue(() => {
114
- if (!previousFill || previousFill === fill) {
115
- return fill;
116
- }
117
- return interpolateColors(colorProgress.value, [0, 1], [previousFill, fill]);
118
- }, [colorProgress, previousFill, fill]);
119
- const isWithinDrawingArea = useMemo(() => {
120
- if (!pixelCoordinate) return false;
121
- return pixelCoordinate.x >= drawingArea.x && pixelCoordinate.x <= drawingArea.x + drawingArea.width && pixelCoordinate.y >= drawingArea.y && pixelCoordinate.y <= drawingArea.y + drawingArea.height;
122
- }, [pixelCoordinate, drawingArea]);
123
- const effectiveOpacity = useDerivedValue(() => {
124
- const baseOpacity = opacity != null ? opacity : 1;
125
- return isWithinDrawingArea ? baseOpacity * enterOpacity.value : 0;
126
- }, [isWithinDrawingArea, opacity, enterOpacity]);
127
- const offset = useMemo(() => labelOffset != null ? labelOffset : radius * 2, [labelOffset, radius]);
128
- if (!pixelCoordinate) {
129
- return null;
130
- }
131
- if (!shouldAnimate) {
132
- const isWithinBounds = pixelCoordinate.x >= drawingArea.x && pixelCoordinate.x <= drawingArea.x + drawingArea.width && pixelCoordinate.y >= drawingArea.y && pixelCoordinate.y <= drawingArea.y + drawingArea.height;
133
- const staticOpacity = isWithinBounds ? opacity != null ? opacity : 1 : 0;
134
- return /*#__PURE__*/_jsxs(_Fragment, {
135
- children: [/*#__PURE__*/_jsxs(Group, {
136
- opacity: staticOpacity,
137
- children: [strokeWidth > 0 && /*#__PURE__*/_jsx(Circle, {
138
- c: {
139
- x: pixelCoordinate.x,
140
- y: pixelCoordinate.y
141
- },
142
- color: stroke,
143
- r: radius + strokeWidth / 2
144
- }), /*#__PURE__*/_jsx(Circle, {
145
- c: {
146
- x: pixelCoordinate.x,
147
- y: pixelCoordinate.y
148
- },
149
- color: fill,
150
- r: radius - strokeWidth / 2
151
- })]
152
- }), label && /*#__PURE__*/_jsx(LabelComponent, {
153
- dataX: dataX,
154
- dataY: dataY,
155
- fill: fill,
156
- font: labelFont,
157
- offset: offset,
158
- position: labelPosition,
159
- x: pixelCoordinate.x,
160
- y: pixelCoordinate.y,
161
- children: label
162
- })]
163
- });
164
- }
165
- return /*#__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
- }), label && /*#__PURE__*/_jsx(LabelComponent, {
176
- dataX: dataX,
177
- dataY: dataY,
178
- fill: fill,
179
- font: labelFont,
180
- offset: offset,
181
- position: labelPosition,
182
- x: pixelCoordinate.x,
183
- y: pixelCoordinate.y,
184
- children: label
185
- })]
186
- });
187
- });
@@ -1,2 +0,0 @@
1
- export * from './DefaultPointLabel';
2
- export * from './Point';
@@ -1,182 +0,0 @@
1
- import { forwardRef, memo, useEffect, useImperativeHandle, useMemo } from 'react';
2
- import { cancelAnimation, Easing, useAnimatedReaction, useDerivedValue, useSharedValue, withDelay, withRepeat, withSequence, withTiming } from 'react-native-reanimated';
3
- import { useTheme } from '@coinbase/cds-mobile';
4
- import { Circle, Group } from '@shopify/react-native-skia';
5
- import { useCartesianChartContext } from '../ChartProvider';
6
- import { unwrapAnimatedValue } from '../utils';
7
- import { projectPointWithSerializableScale } from '../utils/point';
8
- import { buildTransition, defaultTransition, getTransition } from '../utils/transition';
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
- const defaultRadius = 5;
11
- const defaultStrokeWidth = 2;
12
- const pulseOpacityStart = 0.5;
13
- const pulseOpacityEnd = 0;
14
- const pulseRadiusStartMultiplier = 2;
15
- const pulseRadiusEndMultiplier = 3;
16
- const defaultPulseTransition = {
17
- type: 'timing',
18
- duration: 1600,
19
- easing: Easing.bezier(0.0, 0.0, 0.0, 1.0)
20
- };
21
- const defaultPulseRepeatDelay = 400;
22
- export const DefaultScrubberBeacon = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
23
- let {
24
- seriesId,
25
- color: colorProp,
26
- dataX,
27
- dataY,
28
- isIdle,
29
- idlePulse,
30
- animate = true,
31
- transitions,
32
- opacity: opacityProp = 1,
33
- radius = defaultRadius,
34
- stroke,
35
- strokeWidth = defaultStrokeWidth
36
- } = _ref;
37
- const theme = useTheme();
38
- const {
39
- getSeries,
40
- getXSerializableScale,
41
- getYSerializableScale,
42
- drawingArea
43
- } = useCartesianChartContext();
44
- const targetSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
45
- const xScale = useMemo(() => getXSerializableScale(targetSeries == null ? void 0 : targetSeries.xAxisId), [getXSerializableScale, targetSeries == null ? void 0 : targetSeries.xAxisId]);
46
- const yScale = useMemo(() => getYSerializableScale(targetSeries == null ? void 0 : targetSeries.yAxisId), [getYSerializableScale, targetSeries == null ? void 0 : targetSeries.yAxisId]);
47
- const color = useMemo(() => {
48
- var _ref2;
49
- return (_ref2 = colorProp != null ? colorProp : targetSeries == null ? void 0 : targetSeries.color) != null ? _ref2 : theme.color.fgPrimary;
50
- }, [colorProp, targetSeries == null ? void 0 : targetSeries.color, theme.color.fgPrimary]);
51
- const updateTransition = useMemo(() => getTransition(transitions == null ? void 0 : transitions.update, animate, defaultTransition), [transitions == null ? void 0 : transitions.update, animate]);
52
- const pulseTransition = useMemo(() => {
53
- var _transitions$pulse;
54
- return (_transitions$pulse = transitions == null ? void 0 : transitions.pulse) != null ? _transitions$pulse : defaultPulseTransition;
55
- }, [transitions == null ? void 0 : transitions.pulse]);
56
- const pulseRepeatDelay = useMemo(() => {
57
- var _transitions$pulseRep;
58
- return (_transitions$pulseRep = transitions == null ? void 0 : transitions.pulseRepeatDelay) != null ? _transitions$pulseRep : defaultPulseRepeatDelay;
59
- }, [transitions == null ? void 0 : transitions.pulseRepeatDelay]);
60
- const pulseRadiusStart = radius * pulseRadiusStartMultiplier;
61
- const pulseRadiusEnd = radius * pulseRadiusEndMultiplier;
62
- const pulseOpacity = useSharedValue(0);
63
- const pulseRadius = useSharedValue(pulseRadiusStart);
64
-
65
- // Convert idlePulse prop to SharedValue so useAnimatedReaction can detect changes.
66
- // In the new React Native architecture, regular JS props are captured by value in worklets
67
- // and won't update when the prop changes.
68
- const idlePulseShared = useSharedValue(idlePulse != null ? idlePulse : false);
69
- useEffect(() => {
70
- idlePulseShared.value = idlePulse != null ? idlePulse : false;
71
- }, [idlePulse, idlePulseShared]);
72
- const animatedX = useSharedValue(null);
73
- const animatedY = useSharedValue(null);
74
-
75
- // Calculate the target point position - project data to pixels
76
- const targetPoint = useDerivedValue(() => {
77
- if (!xScale || !yScale) return {
78
- x: 0,
79
- y: 0
80
- };
81
- return projectPointWithSerializableScale({
82
- x: unwrapAnimatedValue(dataX),
83
- y: unwrapAnimatedValue(dataY),
84
- xScale,
85
- yScale
86
- });
87
- }, [dataX, dataY, xScale, yScale]);
88
- useAnimatedReaction(() => {
89
- return {
90
- point: targetPoint.value,
91
- isIdle: unwrapAnimatedValue(isIdle)
92
- };
93
- }, (current, previous) => {
94
- // When animation is disabled, on initial render, or when we are starting,
95
- // continuing, or finishing scrubbing we should immediately transition
96
- if (!animate || previous === null || !previous.isIdle || !current.isIdle) {
97
- animatedX.value = current.point.x;
98
- animatedY.value = current.point.y;
99
- return;
100
- }
101
- animatedX.value = buildTransition(current.point.x, updateTransition);
102
- animatedY.value = buildTransition(current.point.y, updateTransition);
103
- }, [animate, updateTransition]);
104
-
105
- // Create animated point using the animated values
106
- const animatedPoint = useDerivedValue(() => {
107
- // If the animated values have not been set yet, return the target point
108
- if (animatedX.value === null || animatedY.value === null) return targetPoint.value;
109
- return {
110
- x: animatedX.value,
111
- y: animatedY.value
112
- };
113
- }, [targetPoint, animatedX, animatedY]);
114
- useImperativeHandle(ref, () => ({
115
- pulse: () => {
116
- // Only trigger manual pulse when idlePulse is not enabled
117
- if (!idlePulseShared.value) {
118
- cancelAnimation(pulseOpacity);
119
- cancelAnimation(pulseRadius);
120
-
121
- // Manual pulse without delay
122
- pulseOpacity.value = pulseOpacityStart;
123
- pulseRadius.value = pulseRadiusStart;
124
- pulseOpacity.value = buildTransition(pulseOpacityEnd, pulseTransition);
125
- pulseRadius.value = buildTransition(pulseRadiusEnd, pulseTransition);
126
- }
127
- }
128
- }), [idlePulseShared, pulseOpacity, pulseRadius, pulseTransition, pulseRadiusStart, pulseRadiusEnd]);
129
-
130
- // Watch idlePulse changes and control continuous pulse
131
- useAnimatedReaction(() => idlePulseShared.value, current => {
132
- if (current) {
133
- // Start continuous pulse when idlePulse is enabled
134
- pulseOpacity.value = pulseOpacityStart;
135
- pulseRadius.value = pulseRadiusStart;
136
- pulseOpacity.value = withRepeat(withSequence(buildTransition(pulseOpacityEnd, pulseTransition), withDelay(pulseRepeatDelay, withTiming(pulseOpacityStart, {
137
- duration: 0
138
- }))), -1,
139
- // infinite loop
140
- false);
141
- pulseRadius.value = withRepeat(withSequence(buildTransition(pulseRadiusEnd, pulseTransition), withDelay(pulseRepeatDelay, withTiming(pulseRadiusStart, {
142
- duration: 0
143
- }))), -1,
144
- // infinite loop
145
- false);
146
- } else {
147
- // Stop pulse when idlePulse is disabled
148
- cancelAnimation(pulseOpacity);
149
- cancelAnimation(pulseRadius);
150
- pulseOpacity.value = pulseOpacityEnd;
151
- pulseRadius.value = pulseRadiusStart;
152
- }
153
- }, [pulseTransition, pulseRepeatDelay, pulseRadiusStart, pulseRadiusEnd]);
154
- const pulseVisibility = useDerivedValue(() => {
155
- // Never pulse when scrubbing
156
- if (!unwrapAnimatedValue(isIdle)) return 0;
157
- return pulseOpacity.value;
158
- }, [isIdle, pulseOpacity]);
159
- const beaconOpacity = useDerivedValue(() => {
160
- const point = targetPoint.value;
161
- const isWithinDrawingArea = point.x >= drawingArea.x && point.x <= drawingArea.x + drawingArea.width && point.y >= drawingArea.y && point.y <= drawingArea.y + drawingArea.height;
162
- const userOpacity = unwrapAnimatedValue(opacityProp);
163
- return isWithinDrawingArea ? userOpacity : 0;
164
- }, [targetPoint, drawingArea, opacityProp]);
165
- return /*#__PURE__*/_jsxs(Group, {
166
- opacity: beaconOpacity,
167
- children: [/*#__PURE__*/_jsx(Circle, {
168
- c: animatedPoint,
169
- color: color,
170
- opacity: pulseVisibility,
171
- r: pulseRadius
172
- }), /*#__PURE__*/_jsx(Circle, {
173
- c: animatedPoint,
174
- color: stroke != null ? stroke : theme.color.bg,
175
- r: radius + strokeWidth / 2
176
- }), /*#__PURE__*/_jsx(Circle, {
177
- c: animatedPoint,
178
- color: color,
179
- r: radius - strokeWidth / 2
180
- })]
181
- });
182
- }));
@@ -1,43 +0,0 @@
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
- });