react-native-wagmi-charts 2.7.2 → 2.8.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 (357) hide show
  1. package/README.md +42 -15
  2. package/lib/commonjs/charts/candle/Candle.js +177 -93
  3. package/lib/commonjs/charts/candle/Candle.js.map +1 -1
  4. package/lib/commonjs/charts/candle/Candles.js +66 -43
  5. package/lib/commonjs/charts/candle/Candles.js.map +1 -1
  6. package/lib/commonjs/charts/candle/Chart.js +38 -28
  7. package/lib/commonjs/charts/candle/Chart.js.map +1 -1
  8. package/lib/commonjs/charts/candle/Context.js +74 -43
  9. package/lib/commonjs/charts/candle/Context.js.map +1 -1
  10. package/lib/commonjs/charts/candle/Crosshair.js +191 -81
  11. package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
  12. package/lib/commonjs/charts/candle/CrosshairTooltip.js +140 -61
  13. package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
  14. package/lib/commonjs/charts/candle/DatetimeText.js +19 -14
  15. package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
  16. package/lib/commonjs/charts/candle/Line.js +73 -28
  17. package/lib/commonjs/charts/candle/Line.js.map +1 -1
  18. package/lib/commonjs/charts/candle/PriceText.js +19 -14
  19. package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
  20. package/lib/commonjs/charts/candle/index.js +67 -64
  21. package/lib/commonjs/charts/candle/types.js +4 -4
  22. package/lib/commonjs/charts/candle/useCandleData.js +9 -12
  23. package/lib/commonjs/charts/candle/useCandlestickChart.js +10 -9
  24. package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
  25. package/lib/commonjs/charts/candle/useDatetime.js +16 -18
  26. package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
  27. package/lib/commonjs/charts/candle/usePrice.js +21 -22
  28. package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
  29. package/lib/commonjs/charts/candle/utils/getDomain.js +5 -8
  30. package/lib/commonjs/charts/candle/utils/getHeight.js +12 -11
  31. package/lib/commonjs/charts/candle/utils/getPrice.js +12 -11
  32. package/lib/commonjs/charts/candle/utils/getY.js +12 -11
  33. package/lib/commonjs/charts/candle/utils/index.js +16 -16
  34. package/lib/commonjs/charts/line/Axis.js +402 -0
  35. package/lib/commonjs/charts/line/Axis.js.map +1 -0
  36. package/lib/commonjs/charts/line/Chart.js +140 -69
  37. package/lib/commonjs/charts/line/Chart.js.map +1 -1
  38. package/lib/commonjs/charts/line/ChartPath.js +290 -90
  39. package/lib/commonjs/charts/line/ChartPath.js.map +1 -1
  40. package/lib/commonjs/charts/line/Context.js +98 -40
  41. package/lib/commonjs/charts/line/Context.js.map +1 -1
  42. package/lib/commonjs/charts/line/Cursor.js +130 -75
  43. package/lib/commonjs/charts/line/Cursor.js.map +1 -1
  44. package/lib/commonjs/charts/line/CursorCrosshair.js +151 -58
  45. package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
  46. package/lib/commonjs/charts/line/CursorLine.js +251 -45
  47. package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
  48. package/lib/commonjs/charts/line/Data.js +73 -35
  49. package/lib/commonjs/charts/line/Data.js.map +1 -1
  50. package/lib/commonjs/charts/line/DatetimeText.js +27 -14
  51. package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
  52. package/lib/commonjs/charts/line/Dot.js +150 -57
  53. package/lib/commonjs/charts/line/Dot.js.map +1 -1
  54. package/lib/commonjs/charts/line/Gradient.js +124 -54
  55. package/lib/commonjs/charts/line/Gradient.js.map +1 -1
  56. package/lib/commonjs/charts/line/Group.js +54 -24
  57. package/lib/commonjs/charts/line/Group.js.map +1 -1
  58. package/lib/commonjs/charts/line/Highlight.js +115 -47
  59. package/lib/commonjs/charts/line/Highlight.js.map +1 -1
  60. package/lib/commonjs/charts/line/HorizontalLine.js +92 -40
  61. package/lib/commonjs/charts/line/HorizontalLine.js.map +1 -1
  62. package/lib/commonjs/charts/line/HoverTrap/index.js +10 -7
  63. package/lib/commonjs/charts/line/HoverTrap/index.js.map +1 -1
  64. package/lib/commonjs/charts/line/HoverTrap/index.web.js +115 -86
  65. package/lib/commonjs/charts/line/HoverTrap/index.web.js.map +1 -1
  66. package/lib/commonjs/charts/line/LineChartPathContext.js +14 -11
  67. package/lib/commonjs/charts/line/LineChartPathContext.js.map +1 -1
  68. package/lib/commonjs/charts/line/Path.js +78 -39
  69. package/lib/commonjs/charts/line/Path.js.map +1 -1
  70. package/lib/commonjs/charts/line/PriceText.js +113 -14
  71. package/lib/commonjs/charts/line/PriceText.js.map +1 -1
  72. package/lib/commonjs/charts/line/Tooltip.js +236 -106
  73. package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
  74. package/lib/commonjs/charts/line/index.js +75 -62
  75. package/lib/commonjs/charts/line/index.js.map +1 -1
  76. package/lib/commonjs/charts/line/types.js +4 -4
  77. package/lib/commonjs/charts/line/useAnimatedPath.js +28 -23
  78. package/lib/commonjs/charts/line/useAnimatedPath.js.map +1 -1
  79. package/lib/commonjs/charts/line/useCurrentY.js +17 -17
  80. package/lib/commonjs/charts/line/useDatetime.js +34 -33
  81. package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
  82. package/lib/commonjs/charts/line/useLineChart.js +21 -17
  83. package/lib/commonjs/charts/line/useLineChart.js.map +1 -1
  84. package/lib/commonjs/charts/line/usePrice.js +30 -28
  85. package/lib/commonjs/charts/line/usePrice.js.map +1 -1
  86. package/lib/commonjs/charts/line/utils/getArea.js +48 -20
  87. package/lib/commonjs/charts/line/utils/getArea.js.map +1 -1
  88. package/lib/commonjs/charts/line/utils/getDomain.js +5 -7
  89. package/lib/commonjs/charts/line/utils/getPath.js +54 -20
  90. package/lib/commonjs/charts/line/utils/getPath.js.map +1 -1
  91. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +8 -5
  92. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js.map +1 -1
  93. package/lib/commonjs/charts/line/utils/index.js +19 -19
  94. package/lib/commonjs/charts/line/utils/interpolatePath.js +102 -62
  95. package/lib/commonjs/charts/line/utils/interpolatePath.js.map +1 -1
  96. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +5 -5
  97. package/lib/commonjs/components/AnimatedText.js +66 -39
  98. package/lib/commonjs/components/AnimatedText.js.map +1 -1
  99. package/lib/commonjs/index.js +27 -16
  100. package/lib/commonjs/index.js.map +1 -1
  101. package/lib/commonjs/types.js +2 -0
  102. package/lib/commonjs/types.js.map +1 -0
  103. package/lib/commonjs/utils/formatDatetime.js +5 -9
  104. package/lib/commonjs/utils/formatPrice.js +13 -9
  105. package/lib/commonjs/utils/formatPrice.js.map +1 -1
  106. package/lib/commonjs/utils/index.js +13 -13
  107. package/lib/commonjs/utils/usePrevious.js +10 -9
  108. package/lib/commonjs/utils/usePrevious.js.map +1 -1
  109. package/lib/module/charts/candle/Candle.js +126 -76
  110. package/lib/module/charts/candle/Candle.js.map +1 -1
  111. package/lib/module/charts/candle/Candles.js +53 -34
  112. package/lib/module/charts/candle/Candles.js.map +1 -1
  113. package/lib/module/charts/candle/Chart.js +23 -20
  114. package/lib/module/charts/candle/Chart.js.map +1 -1
  115. package/lib/module/charts/candle/Context.js +53 -23
  116. package/lib/module/charts/candle/Context.js.map +1 -1
  117. package/lib/module/charts/candle/Crosshair.js +152 -69
  118. package/lib/module/charts/candle/Crosshair.js.map +1 -1
  119. package/lib/module/charts/candle/CrosshairTooltip.js +102 -52
  120. package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
  121. package/lib/module/charts/candle/DatetimeText.js +5 -5
  122. package/lib/module/charts/candle/Line.js +37 -19
  123. package/lib/module/charts/candle/PriceText.js +5 -5
  124. package/lib/module/charts/candle/PriceText.js.map +1 -1
  125. package/lib/module/charts/candle/index.js +2 -2
  126. package/lib/module/charts/candle/types.js +1 -1
  127. package/lib/module/charts/candle/useCandleData.js +3 -7
  128. package/lib/module/charts/candle/useCandlestickChart.js +2 -2
  129. package/lib/module/charts/candle/useCandlestickChart.js.map +1 -1
  130. package/lib/module/charts/candle/useDatetime.js +10 -12
  131. package/lib/module/charts/candle/useDatetime.js.map +1 -1
  132. package/lib/module/charts/candle/usePrice.js +12 -14
  133. package/lib/module/charts/candle/usePrice.js.map +1 -1
  134. package/lib/module/charts/candle/utils/getDomain.js +2 -5
  135. package/lib/module/charts/candle/utils/getHeight.js +8 -7
  136. package/lib/module/charts/candle/utils/getPrice.js +2 -6
  137. package/lib/module/charts/candle/utils/getY.js +2 -6
  138. package/lib/module/charts/candle/utils/index.js +1 -1
  139. package/lib/module/charts/line/Axis.js +349 -0
  140. package/lib/module/charts/line/Axis.js.map +1 -0
  141. package/lib/module/charts/line/Chart.js +82 -46
  142. package/lib/module/charts/line/Chart.js.map +1 -1
  143. package/lib/module/charts/line/ChartPath.js +246 -77
  144. package/lib/module/charts/line/ChartPath.js.map +1 -1
  145. package/lib/module/charts/line/Context.js +65 -32
  146. package/lib/module/charts/line/Context.js.map +1 -1
  147. package/lib/module/charts/line/Cursor.js +87 -60
  148. package/lib/module/charts/line/Cursor.js.map +1 -1
  149. package/lib/module/charts/line/CursorCrosshair.js +118 -50
  150. package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
  151. package/lib/module/charts/line/CursorLine.js +210 -33
  152. package/lib/module/charts/line/CursorLine.js.map +1 -1
  153. package/lib/module/charts/line/Data.js +41 -28
  154. package/lib/module/charts/line/Data.js.map +1 -1
  155. package/lib/module/charts/line/DatetimeText.js +14 -6
  156. package/lib/module/charts/line/DatetimeText.js.map +1 -1
  157. package/lib/module/charts/line/Dot.js +95 -41
  158. package/lib/module/charts/line/Dot.js.map +1 -1
  159. package/lib/module/charts/line/Gradient.js +80 -42
  160. package/lib/module/charts/line/Gradient.js.map +1 -1
  161. package/lib/module/charts/line/Group.js +15 -14
  162. package/lib/module/charts/line/Highlight.js +62 -32
  163. package/lib/module/charts/line/Highlight.js.map +1 -1
  164. package/lib/module/charts/line/HorizontalLine.js +49 -27
  165. package/lib/module/charts/line/HorizontalLine.js.map +1 -1
  166. package/lib/module/charts/line/HoverTrap/index.js +3 -2
  167. package/lib/module/charts/line/HoverTrap/index.web.js +102 -76
  168. package/lib/module/charts/line/HoverTrap/index.web.js.map +1 -1
  169. package/lib/module/charts/line/LineChartPathContext.js +3 -3
  170. package/lib/module/charts/line/Path.js +34 -27
  171. package/lib/module/charts/line/Path.js.map +1 -1
  172. package/lib/module/charts/line/PriceText.js +80 -6
  173. package/lib/module/charts/line/PriceText.js.map +1 -1
  174. package/lib/module/charts/line/Tooltip.js +202 -94
  175. package/lib/module/charts/line/Tooltip.js.map +1 -1
  176. package/lib/module/charts/line/index.js +6 -3
  177. package/lib/module/charts/line/index.js.map +1 -1
  178. package/lib/module/charts/line/types.js +1 -1
  179. package/lib/module/charts/line/useAnimatedPath.js +22 -16
  180. package/lib/module/charts/line/useAnimatedPath.js.map +1 -1
  181. package/lib/module/charts/line/useCurrentY.js +4 -9
  182. package/lib/module/charts/line/useDatetime.js +28 -27
  183. package/lib/module/charts/line/useDatetime.js.map +1 -1
  184. package/lib/module/charts/line/useLineChart.js +11 -8
  185. package/lib/module/charts/line/useLineChart.js.map +1 -1
  186. package/lib/module/charts/line/usePrice.js +24 -22
  187. package/lib/module/charts/line/usePrice.js.map +1 -1
  188. package/lib/module/charts/line/utils/getArea.js +16 -11
  189. package/lib/module/charts/line/utils/getArea.js.map +1 -1
  190. package/lib/module/charts/line/utils/getDomain.js +2 -4
  191. package/lib/module/charts/line/utils/getPath.js +22 -11
  192. package/lib/module/charts/line/utils/getPath.js.map +1 -1
  193. package/lib/module/charts/line/utils/getXPositionForCurve.js +5 -2
  194. package/lib/module/charts/line/utils/getXPositionForCurve.js.map +1 -1
  195. package/lib/module/charts/line/utils/index.js +1 -1
  196. package/lib/module/charts/line/utils/interpolatePath.js +99 -59
  197. package/lib/module/charts/line/utils/interpolatePath.js.map +1 -1
  198. package/lib/module/charts/line/utils/lineChartDataPropToArray.js +2 -2
  199. package/lib/module/components/AnimatedText.js +24 -30
  200. package/lib/module/components/AnimatedText.js.map +1 -1
  201. package/lib/module/index.js +2 -1
  202. package/lib/module/index.js.map +1 -1
  203. package/lib/module/types.js +1 -0
  204. package/lib/module/types.js.map +1 -0
  205. package/lib/module/utils/formatDatetime.js +2 -6
  206. package/lib/module/utils/formatPrice.js +10 -6
  207. package/lib/module/utils/formatPrice.js.map +1 -1
  208. package/lib/module/utils/index.js +1 -1
  209. package/lib/module/utils/usePrevious.js +2 -2
  210. package/lib/module/utils/usePrevious.js.map +1 -1
  211. package/lib/typescript/src/charts/candle/Candle.d.ts +45 -31
  212. package/lib/typescript/src/charts/candle/Candle.d.ts.map +1 -1
  213. package/lib/typescript/src/charts/candle/Candles.d.ts +25 -14
  214. package/lib/typescript/src/charts/candle/Candles.d.ts.map +1 -1
  215. package/lib/typescript/src/charts/candle/Chart.d.ts +13 -8
  216. package/lib/typescript/src/charts/candle/Chart.d.ts.map +1 -1
  217. package/lib/typescript/src/charts/candle/Context.d.ts +15 -8
  218. package/lib/typescript/src/charts/candle/Context.d.ts.map +1 -1
  219. package/lib/typescript/src/charts/candle/Crosshair.d.ts +19 -10
  220. package/lib/typescript/src/charts/candle/Crosshair.d.ts.map +1 -1
  221. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +16 -9
  222. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts.map +1 -1
  223. package/lib/typescript/src/charts/candle/DatetimeText.d.ts +17 -11
  224. package/lib/typescript/src/charts/candle/DatetimeText.d.ts.map +1 -1
  225. package/lib/typescript/src/charts/candle/Line.d.ts +10 -5
  226. package/lib/typescript/src/charts/candle/Line.d.ts.map +1 -1
  227. package/lib/typescript/src/charts/candle/PriceText.d.ts +16 -9
  228. package/lib/typescript/src/charts/candle/PriceText.d.ts.map +1 -1
  229. package/lib/typescript/src/charts/candle/index.d.ts +32 -14
  230. package/lib/typescript/src/charts/candle/index.d.ts.map +1 -1
  231. package/lib/typescript/src/charts/candle/types.d.ts +16 -19
  232. package/lib/typescript/src/charts/candle/types.d.ts.map +1 -1
  233. package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -1
  234. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -1
  235. package/lib/typescript/src/charts/candle/useDatetime.d.ts +14 -10
  236. package/lib/typescript/src/charts/candle/useDatetime.d.ts.map +1 -1
  237. package/lib/typescript/src/charts/candle/usePrice.d.ts +13 -8
  238. package/lib/typescript/src/charts/candle/usePrice.d.ts.map +1 -1
  239. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -1
  240. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +9 -5
  241. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +9 -5
  242. package/lib/typescript/src/charts/candle/utils/getY.d.ts +9 -5
  243. package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -1
  244. package/lib/typescript/src/charts/line/Axis.d.ts +33 -0
  245. package/lib/typescript/src/charts/line/Axis.d.ts.map +1 -0
  246. package/lib/typescript/src/charts/line/Chart.d.ts +33 -23
  247. package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -1
  248. package/lib/typescript/src/charts/line/ChartPath.d.ts +29 -16
  249. package/lib/typescript/src/charts/line/ChartPath.d.ts.map +1 -1
  250. package/lib/typescript/src/charts/line/Context.d.ts +17 -10
  251. package/lib/typescript/src/charts/line/Context.d.ts.map +1 -1
  252. package/lib/typescript/src/charts/line/Cursor.d.ts +23 -12
  253. package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -1
  254. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +25 -13
  255. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -1
  256. package/lib/typescript/src/charts/line/CursorLine.d.ts +19 -8
  257. package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -1
  258. package/lib/typescript/src/charts/line/Data.d.ts +17 -13
  259. package/lib/typescript/src/charts/line/DatetimeText.d.ts +16 -10
  260. package/lib/typescript/src/charts/line/DatetimeText.d.ts.map +1 -1
  261. package/lib/typescript/src/charts/line/Dot.d.ts +40 -27
  262. package/lib/typescript/src/charts/line/Dot.d.ts.map +1 -1
  263. package/lib/typescript/src/charts/line/Gradient.d.ts +11 -7
  264. package/lib/typescript/src/charts/line/Gradient.d.ts.map +1 -1
  265. package/lib/typescript/src/charts/line/Group.d.ts +6 -3
  266. package/lib/typescript/src/charts/line/Highlight.d.ts +19 -11
  267. package/lib/typescript/src/charts/line/Highlight.d.ts.map +1 -1
  268. package/lib/typescript/src/charts/line/HorizontalLine.d.ts +30 -26
  269. package/lib/typescript/src/charts/line/HorizontalLine.d.ts.map +1 -1
  270. package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +1 -1
  271. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +2 -2
  272. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts.map +1 -1
  273. package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +4 -4
  274. package/lib/typescript/src/charts/line/Path.d.ts +30 -25
  275. package/lib/typescript/src/charts/line/Path.d.ts.map +1 -1
  276. package/lib/typescript/src/charts/line/PriceText.d.ts +30 -14
  277. package/lib/typescript/src/charts/line/PriceText.d.ts.map +1 -1
  278. package/lib/typescript/src/charts/line/Tooltip.d.ts +36 -24
  279. package/lib/typescript/src/charts/line/Tooltip.d.ts.map +1 -1
  280. package/lib/typescript/src/charts/line/index.d.ts +34 -20
  281. package/lib/typescript/src/charts/line/index.d.ts.map +1 -1
  282. package/lib/typescript/src/charts/line/types.d.ts +19 -18
  283. package/lib/typescript/src/charts/line/types.d.ts.map +1 -1
  284. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +10 -7
  285. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts.map +1 -1
  286. package/lib/typescript/src/charts/line/useCurrentY.d.ts +2 -2
  287. package/lib/typescript/src/charts/line/useCurrentY.d.ts.map +1 -1
  288. package/lib/typescript/src/charts/line/useDatetime.d.ts +12 -8
  289. package/lib/typescript/src/charts/line/useDatetime.d.ts.map +1 -1
  290. package/lib/typescript/src/charts/line/useLineChart.d.ts +10 -10
  291. package/lib/typescript/src/charts/line/usePrice.d.ts +12 -8
  292. package/lib/typescript/src/charts/line/usePrice.d.ts.map +1 -1
  293. package/lib/typescript/src/charts/line/utils/getArea.d.ts +17 -9
  294. package/lib/typescript/src/charts/line/utils/getArea.d.ts.map +1 -1
  295. package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -1
  296. package/lib/typescript/src/charts/line/utils/getPath.d.ts +21 -11
  297. package/lib/typescript/src/charts/line/utils/getPath.d.ts.map +1 -1
  298. package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +1 -1
  299. package/lib/typescript/src/charts/line/utils/index.d.ts +1 -1
  300. package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +17 -5
  301. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +4 -2
  302. package/lib/typescript/src/components/AnimatedText.d.ts +7 -4
  303. package/lib/typescript/src/components/AnimatedText.d.ts.map +1 -1
  304. package/lib/typescript/src/index.d.ts +2 -1
  305. package/lib/typescript/src/index.d.ts.map +1 -1
  306. package/lib/typescript/src/types.d.ts +8 -0
  307. package/lib/typescript/src/types.d.ts.map +1 -0
  308. package/lib/typescript/src/utils/formatDatetime.d.ts +9 -5
  309. package/lib/typescript/src/utils/formatPrice.d.ts +9 -5
  310. package/lib/typescript/src/utils/formatPrice.d.ts.map +1 -1
  311. package/lib/typescript/src/utils/index.d.ts +1 -1
  312. package/lib/typescript/src/utils/usePrevious.d.ts +1 -1
  313. package/package.json +19 -43
  314. package/src/charts/candle/Candle.tsx +2 -17
  315. package/src/charts/candle/Candles.tsx +1 -3
  316. package/src/charts/candle/Chart.tsx +1 -1
  317. package/src/charts/candle/Context.tsx +30 -7
  318. package/src/charts/candle/Crosshair.tsx +25 -10
  319. package/src/charts/candle/CrosshairTooltip.tsx +3 -1
  320. package/src/charts/candle/DatetimeText.tsx +3 -3
  321. package/src/charts/candle/PriceText.tsx +4 -3
  322. package/src/charts/candle/types.ts +1 -7
  323. package/src/charts/candle/useCandlestickChart.ts +1 -1
  324. package/src/charts/candle/useDatetime.ts +3 -1
  325. package/src/charts/candle/usePrice.ts +5 -1
  326. package/src/charts/line/Axis.tsx +363 -0
  327. package/src/charts/line/Chart.tsx +10 -7
  328. package/src/charts/line/ChartPath.tsx +77 -18
  329. package/src/charts/line/Context.tsx +29 -18
  330. package/src/charts/line/Cursor.tsx +18 -9
  331. package/src/charts/line/CursorCrosshair.tsx +29 -9
  332. package/src/charts/line/CursorLine.tsx +177 -18
  333. package/src/charts/line/Data.tsx +6 -4
  334. package/src/charts/line/DatetimeText.tsx +14 -5
  335. package/src/charts/line/Dot.tsx +5 -4
  336. package/src/charts/line/Gradient.tsx +4 -7
  337. package/src/charts/line/Highlight.tsx +10 -6
  338. package/src/charts/line/HorizontalLine.tsx +2 -8
  339. package/src/charts/line/HoverTrap/index.web.tsx +93 -60
  340. package/src/charts/line/Path.tsx +12 -19
  341. package/src/charts/line/PriceText.tsx +76 -6
  342. package/src/charts/line/Tooltip.tsx +131 -64
  343. package/src/charts/line/index.ts +4 -1
  344. package/src/charts/line/types.ts +1 -2
  345. package/src/charts/line/useAnimatedPath.ts +1 -2
  346. package/src/charts/line/useDatetime.ts +13 -10
  347. package/src/charts/line/useLineChart.ts +1 -1
  348. package/src/charts/line/usePrice.ts +6 -4
  349. package/src/charts/line/utils/getArea.ts +12 -10
  350. package/src/charts/line/utils/getPath.ts +13 -10
  351. package/src/charts/line/utils/getXPositionForCurve.ts +1 -1
  352. package/src/charts/line/utils/interpolatePath.ts +2 -2
  353. package/src/components/AnimatedText.tsx +13 -20
  354. package/src/index.ts +1 -0
  355. package/src/types.ts +7 -0
  356. package/src/utils/formatPrice.ts +7 -7
  357. package/src/utils/usePrevious.ts +1 -1
@@ -76,8 +76,9 @@ function validateLineChartId(dataContext: LineChartDataContext, id?: string) {
76
76
  const joinedIds = otherIds.join(', ');
77
77
 
78
78
  const suggestion = otherIds.length
79
- ? `Did you mean to use ${singular ? 'this ID' : 'one of these IDs'
80
- }: ${joinedIds}`
79
+ ? `Did you mean to use ${
80
+ singular ? 'this ID' : 'one of these IDs'
81
+ }: ${joinedIds}`
81
82
  : `You didn't pass any IDs to your <LineChart.Provider />'s data prop. Did you mean to pass an array instead?`;
82
83
 
83
84
  console.warn(
@@ -91,8 +92,9 @@ ${suggestion}`
91
92
 
92
93
  const joinedIds = otherIds.join(', ');
93
94
  const suggestion = otherIds.length
94
- ? `Did you mean to use ${singular ? 'this ID' : 'one of these IDs'
95
- }: ${joinedIds}`
95
+ ? `Did you mean to use ${
96
+ singular ? 'this ID' : 'one of these IDs'
97
+ }: ${joinedIds}`
96
98
  : `You didn't pass any IDs to your <LineChart.Provider />'s data prop. Did you mean to pass an array instead?`;
97
99
 
98
100
  console.error(`[react-native-wagmi-charts] Missing data "id" prop on LineChart. You must pass an id prop to <LineChart /> when using a dictionary for your data.
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { TextProps as RNTextProps } from 'react-native';
3
- import type Animated from 'react-native-reanimated';
4
-
3
+ import type { AnimatedProps } from 'react-native-reanimated';
4
+ import { useDerivedValue } from 'react-native-reanimated';
5
5
  import { useLineChartDatetime } from './useDatetime';
6
- import type { TFormatterFn } from 'react-native-wagmi-charts';
6
+ import type { TFormatterFn } from '../../types';
7
7
  import { AnimatedText } from '../../components/AnimatedText';
8
8
 
9
9
  type LineChartDatetimeProps = {
@@ -11,7 +11,7 @@ type LineChartDatetimeProps = {
11
11
  options?: Intl.DateTimeFormatOptions;
12
12
  format?: TFormatterFn<number>;
13
13
  variant?: 'formatted' | 'value';
14
- style?: Animated.AnimateProps<RNTextProps>['style'];
14
+ style?: AnimatedProps<RNTextProps>['style'];
15
15
  };
16
16
 
17
17
  LineChartDatetimeText.displayName = 'LineChartDatetimeText';
@@ -24,5 +24,14 @@ export function LineChartDatetimeText({
24
24
  style,
25
25
  }: LineChartDatetimeProps) {
26
26
  const datetime = useLineChartDatetime({ format, locale, options });
27
- return <AnimatedText text={datetime[variant]} style={style} />;
27
+
28
+ const text = useDerivedValue(() => {
29
+ const value = datetime[variant].value;
30
+ if (typeof value === 'number') {
31
+ return value === 0 || isNaN(value) ? '' : value.toString();
32
+ }
33
+ return value || '';
34
+ }, [datetime, variant]);
35
+
36
+ return <AnimatedText text={text} style={style} />;
28
37
  }
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import Animated, {
4
4
  Easing,
@@ -7,6 +7,7 @@ import Animated, {
7
7
  withRepeat,
8
8
  withSequence,
9
9
  withTiming,
10
+ AnimatedProps,
10
11
  } from 'react-native-reanimated';
11
12
  import { Circle, CircleProps } from 'react-native-svg';
12
13
 
@@ -19,8 +20,8 @@ import { useLineChart } from './useLineChart';
19
20
  const AnimatedCircle = Animated.createAnimatedComponent(Circle);
20
21
 
21
22
  export type LineChartDotProps = {
22
- dotProps?: Animated.AnimateProps<CircleProps>;
23
- outerDotProps?: Animated.AnimateProps<CircleProps>;
23
+ dotProps?: AnimatedProps<CircleProps>;
24
+ outerDotProps?: AnimatedProps<CircleProps>;
24
25
  color?: string;
25
26
  inactiveColor?: string;
26
27
  showInactiveColor?: boolean;
@@ -92,7 +93,7 @@ export function LineChartDot({
92
93
  );
93
94
 
94
95
  const animatedOuterDotProps = useAnimatedProps(() => {
95
- let defaultProps = {
96
+ const defaultProps = {
96
97
  cx: x.value,
97
98
  cy: y.value,
98
99
  opacity: 0.1,
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
- import Animated from 'react-native-reanimated';
2
+ import Animated, { AnimatedProps } from 'react-native-reanimated';
3
3
  import { Defs, LinearGradient, Stop, Path, PathProps } from 'react-native-svg';
4
-
5
4
  import { LineChartDimensionsContext } from './Chart';
6
5
  import { LineChartPathContext } from './LineChartPathContext';
7
- import useAnimatedPath from './useAnimatedPath';
6
+ import { useAnimatedPath } from './useAnimatedPath';
8
7
 
9
8
  const AnimatedPath = Animated.createAnimatedComponent(Path);
10
9
 
11
- export type LineChartGradientProps = Animated.AnimateProps<PathProps> & {
10
+ export type LineChartGradientProps = AnimatedProps<PathProps> & {
12
11
  color?: string;
13
12
  children?: React.ReactNode;
14
13
  };
@@ -25,7 +24,6 @@ export function LineChartGradient({
25
24
  const { area } = React.useContext(LineChartDimensionsContext);
26
25
  const { color: contextColor, isTransitionEnabled } =
27
26
  React.useContext(LineChartPathContext);
28
-
29
27
  const color = overrideColor || contextColor;
30
28
 
31
29
  ////////////////////////////////////////////////
@@ -52,8 +50,7 @@ export function LineChartGradient({
52
50
  y1="0"
53
51
  y2="100%"
54
52
  >
55
- {/*@ts-ignore*/}
56
- {children}
53
+ {children as React.ReactElement[]}
57
54
  </LinearGradient>
58
55
  </Defs>
59
56
  ) : (
@@ -1,15 +1,14 @@
1
1
  import * as React from 'react';
2
- import Animated from 'react-native-reanimated';
2
+ import Animated, { AnimatedProps } from 'react-native-reanimated';
3
3
  import { ClipPath, Defs, G, Path, PathProps, Rect } from 'react-native-svg';
4
-
5
4
  import { LineChartDimensionsContext } from './Chart';
6
5
  import { LineChartPathContext } from './LineChartPathContext';
7
- import useAnimatedPath from './useAnimatedPath';
6
+ import { useAnimatedPath } from './useAnimatedPath';
8
7
  import { getXPositionForCurve } from './utils/getXPositionForCurve';
9
8
 
10
9
  const AnimatedPath = Animated.createAnimatedComponent(Path);
11
10
 
12
- export type LineChartColorProps = Animated.AnimateProps<PathProps> & {
11
+ export type LineChartColorProps = AnimatedProps<PathProps> & {
13
12
  color?: string;
14
13
  from: number;
15
14
  to: number;
@@ -45,13 +44,18 @@ export function LineChartHighlight({
45
44
 
46
45
  ////////////////////////////////////////////////
47
46
 
47
+ const clipId = React.useMemo(
48
+ () => `clip-${Math.random().toString(36).substring(2, 11)}`,
49
+ []
50
+ );
51
+
48
52
  const clipStart = getXPositionForCurve(parsedPath, from);
49
53
  const clipEnd = getXPositionForCurve(parsedPath, to);
50
54
 
51
55
  return (
52
56
  <G>
53
57
  <Defs>
54
- <ClipPath id="clip">
58
+ <ClipPath id={clipId}>
55
59
  <Rect
56
60
  x={clipStart}
57
61
  y="0"
@@ -62,7 +66,7 @@ export function LineChartHighlight({
62
66
  </ClipPath>
63
67
  </Defs>
64
68
  <AnimatedPath
65
- clipPath="url(#clip)"
69
+ clipPath={`url(#${clipId})`}
66
70
  animatedProps={animatedProps}
67
71
  fill="transparent"
68
72
  stroke={isInactive ? inactiveColor || color : color}
@@ -23,15 +23,11 @@ type HorizontalLineProps = {
23
23
  * This may be useful to customize the line's position based on the thickness of your cursor or chart path.
24
24
  *
25
25
  * ```tsx
26
- * <LineChart.HorizontalLine
27
- * at={{ index: 3 }}
28
- * />
26
+ * <LineChart.HorizontalLine at={{ index: 3 }} />
29
27
  *
30
28
  * // or
31
29
  *
32
- * <LineChart.HorizontalLine
33
- * at={{ value: 320.32}}
34
- * />
30
+ * <LineChart.HorizontalLine at={{ value: 320.32 }} />
35
31
  * ```
36
32
  */
37
33
  at?:
@@ -78,9 +74,7 @@ export function LineChartHorizontalLine({
78
74
 
79
75
  const offsetTop = yDomain.max - at.value;
80
76
  const percentageOffsetTop = offsetTop / (yDomain.max - yDomain.min);
81
-
82
77
  const heightBetweenGutters = height - gutter * 2;
83
-
84
78
  const offsetTopPixels = gutter + percentageOffsetTop * heightBetweenGutters;
85
79
 
86
80
  return withTiming(offsetTopPixels + offsetY);
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { View, StyleSheet } from 'react-native';
3
3
 
4
4
  import { LineChartDimensionsContext } from '../Chart';
@@ -6,74 +6,116 @@ import { useLineChart } from '../useLineChart';
6
6
 
7
7
  import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
8
8
 
9
- let isEnabled = false;
9
+ /**
10
+ * Minimum time in milliseconds that must pass between touch events before a
11
+ * hover state is activated on web.
12
+ */
13
+ const HOVER_THRESHOLD_MS = 1000;
10
14
 
11
- // the following logic comes from the creator of react-native-web
12
- // https://gist.github.com/necolas/1c494e44e23eb7f8c5864a2fac66299a
13
- // it's also used by MotiPressable's hover interactions
14
- // https://github.com/nandorojo/moti/blob/master/packages/interactions/src/pressable/hoverable.tsx
15
- if (canUseDOM) {
16
- /**
17
- * Web browsers emulate mouse events (and hover states) after touch events.
18
- * This code infers when the currently-in-use modality supports hover
19
- * (including for multi-modality devices) and considers "hover" to be enabled
20
- * if a mouse movement occurs more than 1 second after the last touch event.
21
- * This threshold is long enough to account for longer delays between the
22
- * browser firing touch and mouse events on low-powered devices.
23
- */
24
- const HOVER_THRESHOLD_MS = 1000;
25
- let lastTouchTimestamp = 0;
15
+ /**
16
+ * Hover state manager for web platform. This singleton ensures global hover
17
+ * detection is properly initialized and cleaned up.
18
+ */
19
+ class HoverStateManager {
20
+ private isEnabled = false;
21
+ private lastTouchTimestamp = 0;
22
+ private initialized = false;
26
23
 
27
- function enableHover() {
28
- if (isEnabled || Date.now() - lastTouchTimestamp < HOVER_THRESHOLD_MS) {
29
- return;
24
+ constructor() {
25
+ if (canUseDOM) {
26
+ this.initialize();
30
27
  }
31
- isEnabled = true;
32
28
  }
33
29
 
34
- function disableHover() {
35
- lastTouchTimestamp = Date.now();
36
- if (isEnabled) {
37
- isEnabled = false;
30
+ private initialize() {
31
+ if (this.initialized) return;
32
+
33
+ /**
34
+ * The following logic comes from the creator of react-native-web:
35
+ * https://gist.github.com/necolas/1c494e44e23eb7f8c5864a2fac66299a
36
+ * It's also used by MotiPressable's hover interactions:
37
+ * https://github.com/nandorojo/moti/blob/master/packages/interactions/src/pressable/hoverable.tsx
38
+ *
39
+ * Web browsers emulate mouse events (and hover states) after touch events.
40
+ * This code infers when the currently-in-use modality supports hover
41
+ * (including for multi-modality devices) and considers "hover" to be enabled
42
+ * if a mouse movement occurs more than 1 second after the last touch event.
43
+ * This threshold is long enough to account for longer delays between the
44
+ * browser firing touch and mouse events on low-powered devices.
45
+ */
46
+ document.addEventListener('touchstart', this.disableHover, true);
47
+ document.addEventListener('touchmove', this.disableHover, true);
48
+ document.addEventListener('mousemove', this.enableHover, true);
49
+ this.initialized = true;
50
+ }
51
+
52
+ private enableHover = () => {
53
+ if (
54
+ this.isEnabled ||
55
+ Date.now() - this.lastTouchTimestamp < HOVER_THRESHOLD_MS
56
+ ) {
57
+ return;
58
+ }
59
+ this.isEnabled = true;
60
+ };
61
+
62
+ private disableHover = () => {
63
+ this.lastTouchTimestamp = Date.now();
64
+ if (this.isEnabled) {
65
+ this.isEnabled = false;
38
66
  }
67
+ };
68
+
69
+ public isHoverEnabled(): boolean {
70
+ return this.isEnabled;
39
71
  }
40
72
 
41
- document.addEventListener('touchstart', disableHover, true);
42
- document.addEventListener('touchmove', disableHover, true);
43
- document.addEventListener('mousemove', enableHover, true);
73
+ /**
74
+ * Cleanup method for removing event listeners. Note: In practice, this may
75
+ * never be called since these are app-level listeners, but it's provided for
76
+ * completeness and testing purposes.
77
+ */
78
+ public cleanup() {
79
+ if (!this.initialized || !canUseDOM) return;
80
+ document.removeEventListener('touchstart', this.disableHover, true);
81
+ document.removeEventListener('touchmove', this.disableHover, true);
82
+ document.removeEventListener('mousemove', this.enableHover, true);
83
+ this.initialized = false;
84
+ }
44
85
  }
45
86
 
46
- function isHoverEnabled(): boolean {
47
- return isEnabled;
48
- }
87
+ // Singleton instance
88
+ const hoverStateManager = new HoverStateManager();
49
89
 
50
90
  export const LineChartHoverTrap = () => {
51
91
  const { width, parsedPath } = React.useContext(LineChartDimensionsContext);
52
92
  const { currentX, currentIndex, isActive, data } = useLineChart();
53
93
 
54
94
  const onMouseMove = React.useCallback(
55
- ({ x }: { x: number }) => {
56
- if (isHoverEnabled()) {
57
- if (parsedPath) {
58
- const boundedX = Math.min(x, width);
59
- isActive.value = true;
60
- currentX.value = boundedX;
61
-
62
- // on Web, we could drag the cursor to be negative, breaking it
63
- // so we clamp the index at 0 to fix it
64
- // https://github.com/coinjar/react-native-wagmi-charts/issues/24
65
- const minIndex = 0;
66
- const boundedIndex = Math.max(
67
- minIndex,
68
- Math.round(boundedX / width / (1 / (data ? data.length - 1 : 1)))
69
- );
70
-
71
- currentIndex.value = boundedIndex;
72
- }
73
- } else {
95
+ (e: React.MouseEvent<HTMLElement>) => {
96
+ if (!hoverStateManager.isHoverEnabled()) {
74
97
  isActive.value = false;
75
98
  currentIndex.value = -1;
99
+ return;
76
100
  }
101
+
102
+ if (!parsedPath) return;
103
+
104
+ const rect = e.currentTarget.getBoundingClientRect();
105
+ const boundedX = Math.min(e.clientX - rect.left, width);
106
+ isActive.value = true;
107
+ currentX.value = boundedX;
108
+
109
+ // on Web, we could drag the cursor to be negative, breaking it
110
+ // so we clamp the index at 0 to fix it
111
+ // https://github.com/coinjar/react-native-wagmi-charts/issues/24
112
+ const minIndex = 0;
113
+ const boundedIndex = Math.max(
114
+ minIndex,
115
+ Math.round(boundedX / width / (1 / (data ? data.length - 1 : 1)))
116
+ );
117
+
118
+ currentIndex.value = boundedIndex;
77
119
  },
78
120
  [currentIndex, currentX, data, isActive, parsedPath, width]
79
121
  );
@@ -87,16 +129,7 @@ export const LineChartHoverTrap = () => {
87
129
  <View
88
130
  style={StyleSheet.absoluteFill}
89
131
  // @ts-expect-error mouse move event
90
- onMouseMove={React.useCallback(
91
- // eslint-disable-next-line no-undef
92
- (e: React.MouseEvent<HTMLElement>) => {
93
- let rect = e.currentTarget.getBoundingClientRect();
94
- let x = e.clientX - rect.left; // x position within the element.
95
-
96
- onMouseMove({ x });
97
- },
98
- [onMouseMove]
99
- )}
132
+ onMouseMove={onMouseMove}
100
133
  onMouseLeave={onMouseLeave}
101
134
  />
102
135
  );
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
- import Animated from 'react-native-reanimated';
2
+ import Animated, { AnimatedProps } from 'react-native-reanimated';
3
3
  import { Path, PathProps } from 'react-native-svg';
4
-
5
4
  import { LineChartDimensionsContext } from './Chart';
6
5
  import { LineChartPathContext } from './LineChartPathContext';
7
- import useAnimatedPath from './useAnimatedPath';
6
+ import { useAnimatedPath } from './useAnimatedPath';
8
7
 
9
8
  const AnimatedPath = Animated.createAnimatedComponent(Path);
10
9
 
11
- export type LineChartPathProps = Animated.AnimateProps<PathProps> & {
10
+ export type LineChartPathProps = AnimatedProps<PathProps> & {
12
11
  color?: string;
13
12
  inactiveColor?: string;
14
13
  width?: number;
@@ -20,7 +19,7 @@ export type LineChartPathProps = Animated.AnimateProps<PathProps> & {
20
19
  *
21
20
  * While this use case is rare, it may be useful on web, where animations might not work as well.
22
21
  *
23
- * **Example**
22
+ ***Example**
24
23
  *
25
24
  * ```tsx
26
25
  * <LineChart.Path
@@ -43,25 +42,19 @@ export function LineChartPath({
43
42
  const { isTransitionEnabled, isInactive } =
44
43
  React.useContext(LineChartPathContext);
45
44
 
46
- ////////////////////////////////////////////////
47
-
48
45
  const { animatedProps } = useAnimatedPath({
49
46
  enabled: isTransitionEnabled,
50
47
  path,
51
48
  });
52
49
 
53
- ////////////////////////////////////////////////
54
-
55
50
  return (
56
- <>
57
- <AnimatedPath
58
- animatedProps={animatedProps}
59
- fill="transparent"
60
- stroke={isInactive ? inactiveColor || color : color}
61
- strokeOpacity={isInactive && !inactiveColor ? 0.2 : 1}
62
- strokeWidth={strokeWidth}
63
- {...props}
64
- />
65
- </>
51
+ <AnimatedPath
52
+ animatedProps={animatedProps}
53
+ fill="transparent"
54
+ stroke={isInactive ? inactiveColor || color : color}
55
+ strokeOpacity={isInactive && !inactiveColor ? 0.2 : 1}
56
+ strokeWidth={strokeWidth}
57
+ {...props}
58
+ />
66
59
  );
67
60
  }
@@ -1,21 +1,35 @@
1
- import React from 'react';
2
- import type { TextProps as RNTextProps } from 'react-native';
3
- import type Animated from 'react-native-reanimated';
4
-
1
+ import React, { useState } from 'react';
2
+ import { Text, TextStyle } from 'react-native';
3
+ import type { TextProps as RNTextProps, StyleProp } from 'react-native';
4
+ import type { AnimatedProps } from 'react-native-reanimated';
5
+ import {
6
+ useDerivedValue,
7
+ useAnimatedReaction,
8
+ runOnJS,
9
+ } from 'react-native-reanimated';
5
10
  import { useLineChartPrice } from './usePrice';
6
- import type { TFormatterFn } from '../candle/types';
11
+ import { useLineChart } from './useLineChart';
12
+ import type { TFormatterFn } from '../../types';
7
13
  import { AnimatedText } from '../../components/AnimatedText';
8
14
 
9
15
  export type LineChartPriceTextProps = {
10
16
  format?: TFormatterFn<string>;
11
17
  precision?: number;
12
18
  variant?: 'formatted' | 'value';
13
- style?: Animated.AnimateProps<RNTextProps>['style'];
19
+ style?: AnimatedProps<RNTextProps>['style'];
14
20
  /**
15
21
  * By default, it will use the current active index from the chart.
16
22
  * If this is set it will use the index provided.
17
23
  */
18
24
  index?: number;
25
+ /**
26
+ * Use optimized rendering for high-frequency updates (bypasses AnimatedText)
27
+ */
28
+ useOptimizedRendering?: boolean;
29
+ /**
30
+ * Function to determine text color based on the formatted value
31
+ */
32
+ getTextColor?: (formattedValue: string) => string;
19
33
  };
20
34
 
21
35
  LineChartPriceText.displayName = 'LineChartPriceText';
@@ -26,7 +40,63 @@ export function LineChartPriceText({
26
40
  variant = 'formatted',
27
41
  style,
28
42
  index,
43
+ useOptimizedRendering = false,
44
+ getTextColor,
29
45
  }: LineChartPriceTextProps) {
30
46
  const price = useLineChartPrice({ format, precision, index });
47
+
48
+ // If we have a custom format function and optimized rendering is enabled,
49
+ // use regular React state instead of AnimatedText
50
+ if (format && useOptimizedRendering) {
51
+ const { currentIndex, data } = useLineChart();
52
+ const [displayText, setDisplayText] = useState('');
53
+ const [textColor, setTextColor] = useState('#000000');
54
+
55
+ const updateText = (newText: string) => {
56
+ setDisplayText(newText);
57
+ // Update color if getTextColor function is provided
58
+ if (getTextColor) {
59
+ setTextColor(getTextColor(newText));
60
+ }
61
+ };
62
+
63
+ const textValue = useDerivedValue(() => {
64
+ if (!data) {
65
+ return '';
66
+ }
67
+ if (
68
+ (typeof currentIndex.value === 'undefined' ||
69
+ currentIndex.value === -1) &&
70
+ index == null
71
+ ) {
72
+ return '';
73
+ }
74
+ let price = 0;
75
+ price =
76
+ data[Math.min(index ?? currentIndex.value, data.length - 1)]!.value;
77
+ const valueString = price.toFixed(precision).toString();
78
+
79
+ // Call format function directly in worklet
80
+ return format({ value: valueString, formatted: valueString });
81
+ }, [currentIndex, data, precision]);
82
+
83
+ // Use useAnimatedReaction to update React state with runOnJS
84
+ useAnimatedReaction(
85
+ () => textValue.value,
86
+ (current, previous) => {
87
+ if (current !== previous) {
88
+ runOnJS(updateText)(current);
89
+ }
90
+ },
91
+ [textValue]
92
+ );
93
+
94
+ // Merge the text color with the provided style
95
+ const dynamicStyle = [style, { color: textColor }] as StyleProp<TextStyle>;
96
+
97
+ return <Text style={dynamicStyle}>{displayText}</Text>;
98
+ }
99
+
100
+ // For non-custom format, use the original approach
31
101
  return <AnimatedText text={price[variant]} style={style} />;
32
102
  }