react-native-wagmi-charts 1.8.0 → 2.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 (213) hide show
  1. package/.DS_Store +0 -0
  2. package/README.md +331 -196
  3. package/example/.DS_Store +0 -0
  4. package/example/src/LineChart.tsx +10 -4
  5. package/example/src/data/line-data.json +20 -20
  6. package/lib/commonjs/charts/candle/utils/getDomain.js +19 -0
  7. package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -0
  8. package/lib/commonjs/charts/candle/utils/getHeight.js +19 -0
  9. package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -0
  10. package/lib/commonjs/charts/candle/utils/getPrice.js +20 -0
  11. package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -0
  12. package/lib/commonjs/charts/candle/utils/getY.js +19 -0
  13. package/lib/commonjs/charts/candle/utils/getY.js.map +1 -0
  14. package/lib/commonjs/charts/candle/utils/index.js +58 -0
  15. package/lib/commonjs/charts/candle/utils/index.js.map +1 -0
  16. package/lib/commonjs/charts/line/Chart.js +9 -3
  17. package/lib/commonjs/charts/line/Chart.js.map +1 -1
  18. package/lib/commonjs/charts/line/ChartPath.js +73 -17
  19. package/lib/commonjs/charts/line/ChartPath.js.map +1 -1
  20. package/lib/commonjs/charts/line/Context.js +1 -0
  21. package/lib/commonjs/charts/line/Context.js.map +1 -1
  22. package/lib/commonjs/charts/line/Cursor.js +1 -0
  23. package/lib/commonjs/charts/line/Cursor.js.map +1 -1
  24. package/lib/commonjs/charts/line/CursorCrosshair.js +10 -3
  25. package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
  26. package/lib/commonjs/charts/line/CursorLine.js +6 -6
  27. package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
  28. package/lib/commonjs/charts/line/DatetimeText.js +2 -0
  29. package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
  30. package/lib/commonjs/charts/line/Dot.js +67 -62
  31. package/lib/commonjs/charts/line/Dot.js.map +1 -1
  32. package/lib/commonjs/charts/line/Gradient.js +8 -25
  33. package/lib/commonjs/charts/line/Gradient.js.map +1 -1
  34. package/lib/commonjs/charts/line/Group.js +5 -25
  35. package/lib/commonjs/charts/line/Group.js.map +1 -1
  36. package/lib/commonjs/charts/line/Highlight.js +92 -0
  37. package/lib/commonjs/charts/line/Highlight.js.map +1 -0
  38. package/lib/commonjs/charts/line/HorizontalLine.js +6 -6
  39. package/lib/commonjs/charts/line/HorizontalLine.js.map +1 -1
  40. package/lib/commonjs/charts/line/Path.js +19 -30
  41. package/lib/commonjs/charts/line/Path.js.map +1 -1
  42. package/lib/commonjs/charts/line/PriceText.js +2 -0
  43. package/lib/commonjs/charts/line/PriceText.js.map +1 -1
  44. package/lib/commonjs/charts/line/Tooltip.js +2 -0
  45. package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
  46. package/lib/commonjs/charts/line/index.js +47 -20
  47. package/lib/commonjs/charts/line/index.js.map +1 -1
  48. package/lib/commonjs/charts/line/useAnimatedPath.js +44 -0
  49. package/lib/commonjs/charts/line/useAnimatedPath.js.map +1 -0
  50. package/lib/commonjs/charts/line/{utils.js → utils/getArea.js} +2 -49
  51. package/lib/commonjs/charts/line/utils/getArea.js.map +1 -0
  52. package/lib/commonjs/charts/line/utils/getDomain.js +16 -0
  53. package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -0
  54. package/lib/commonjs/charts/line/utils/getPath.js +34 -0
  55. package/lib/commonjs/charts/line/utils/getPath.js.map +1 -0
  56. package/lib/commonjs/charts/line/utils/index.js +71 -0
  57. package/lib/commonjs/charts/line/utils/index.js.map +1 -0
  58. package/lib/commonjs/charts/line/{interpolatePath.js → utils/interpolatePath.js} +1 -1
  59. package/lib/commonjs/charts/line/{interpolatePath.js.map → utils/interpolatePath.js.map} +1 -1
  60. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +27 -0
  61. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js.map +1 -0
  62. package/lib/commonjs/index.js +8 -8
  63. package/lib/commonjs/index.js.map +1 -1
  64. package/lib/commonjs/utils/formatDatetime.js +21 -0
  65. package/lib/commonjs/utils/formatDatetime.js.map +1 -0
  66. package/lib/commonjs/utils/formatPrice.js +46 -0
  67. package/lib/commonjs/utils/formatPrice.js.map +1 -0
  68. package/lib/commonjs/utils/index.js +45 -0
  69. package/lib/commonjs/utils/index.js.map +1 -0
  70. package/lib/commonjs/{utils.js → utils/usePrevious.js} +1 -57
  71. package/lib/commonjs/utils/usePrevious.js.map +1 -0
  72. package/lib/module/charts/candle/utils/getDomain.js +12 -0
  73. package/lib/module/charts/candle/utils/getDomain.js.map +1 -0
  74. package/lib/module/charts/candle/utils/getHeight.js +11 -0
  75. package/lib/module/charts/candle/utils/getHeight.js.map +1 -0
  76. package/lib/module/charts/candle/utils/getPrice.js +12 -0
  77. package/lib/module/charts/candle/utils/getPrice.js.map +1 -0
  78. package/lib/module/charts/candle/utils/getY.js +11 -0
  79. package/lib/module/charts/candle/utils/getY.js.map +1 -0
  80. package/lib/module/charts/candle/utils/index.js +5 -0
  81. package/lib/module/charts/candle/utils/index.js.map +1 -0
  82. package/lib/module/charts/line/Chart.js +9 -4
  83. package/lib/module/charts/line/Chart.js.map +1 -1
  84. package/lib/module/charts/line/ChartPath.js +69 -17
  85. package/lib/module/charts/line/ChartPath.js.map +1 -1
  86. package/lib/module/charts/line/Context.js +1 -0
  87. package/lib/module/charts/line/Context.js.map +1 -1
  88. package/lib/module/charts/line/Cursor.js +1 -0
  89. package/lib/module/charts/line/Cursor.js.map +1 -1
  90. package/lib/module/charts/line/CursorCrosshair.js +10 -4
  91. package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
  92. package/lib/module/charts/line/CursorLine.js +4 -3
  93. package/lib/module/charts/line/CursorLine.js.map +1 -1
  94. package/lib/module/charts/line/DatetimeText.js +1 -0
  95. package/lib/module/charts/line/DatetimeText.js.map +1 -1
  96. package/lib/module/charts/line/Dot.js +66 -63
  97. package/lib/module/charts/line/Dot.js.map +1 -1
  98. package/lib/module/charts/line/Gradient.js +8 -24
  99. package/lib/module/charts/line/Gradient.js.map +1 -1
  100. package/lib/module/charts/line/Group.js +2 -24
  101. package/lib/module/charts/line/Group.js.map +1 -1
  102. package/lib/module/charts/line/Highlight.js +69 -0
  103. package/lib/module/charts/line/Highlight.js.map +1 -0
  104. package/lib/module/charts/line/HorizontalLine.js +4 -3
  105. package/lib/module/charts/line/HorizontalLine.js.map +1 -1
  106. package/lib/module/charts/line/Path.js +17 -29
  107. package/lib/module/charts/line/Path.js.map +1 -1
  108. package/lib/module/charts/line/PriceText.js +1 -0
  109. package/lib/module/charts/line/PriceText.js.map +1 -1
  110. package/lib/module/charts/line/Tooltip.js +1 -0
  111. package/lib/module/charts/line/Tooltip.js.map +1 -1
  112. package/lib/module/charts/line/index.js +12 -8
  113. package/lib/module/charts/line/index.js.map +1 -1
  114. package/lib/module/charts/line/useAnimatedPath.js +34 -0
  115. package/lib/module/charts/line/useAnimatedPath.js.map +1 -0
  116. package/lib/module/charts/line/utils/getArea.js +19 -0
  117. package/lib/module/charts/line/utils/getArea.js.map +1 -0
  118. package/lib/module/charts/line/utils/getDomain.js +9 -0
  119. package/lib/module/charts/line/utils/getDomain.js.map +1 -0
  120. package/lib/module/charts/line/utils/getPath.js +21 -0
  121. package/lib/module/charts/line/utils/getPath.js.map +1 -0
  122. package/lib/module/charts/line/utils/index.js +6 -0
  123. package/lib/module/charts/line/utils/index.js.map +1 -0
  124. package/lib/module/charts/line/{interpolatePath.js → utils/interpolatePath.js} +1 -1
  125. package/lib/module/charts/line/{interpolatePath.js.map → utils/interpolatePath.js.map} +1 -1
  126. package/lib/module/charts/line/utils/lineChartDataPropToArray.js +20 -0
  127. package/lib/module/charts/line/utils/lineChartDataPropToArray.js.map +1 -0
  128. package/lib/module/index.js +1 -1
  129. package/lib/module/index.js.map +1 -1
  130. package/lib/module/utils/formatDatetime.js +14 -0
  131. package/lib/module/utils/formatDatetime.js.map +1 -0
  132. package/lib/module/{utils.js → utils/formatPrice.js} +1 -29
  133. package/lib/module/utils/formatPrice.js.map +1 -0
  134. package/lib/module/utils/index.js +4 -0
  135. package/lib/module/utils/index.js.map +1 -0
  136. package/lib/module/utils/usePrevious.js +14 -0
  137. package/lib/module/utils/usePrevious.js.map +1 -0
  138. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +2 -0
  139. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +6 -0
  140. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +6 -0
  141. package/lib/typescript/src/charts/candle/utils/getY.d.ts +6 -0
  142. package/lib/typescript/src/charts/candle/utils/index.d.ts +4 -0
  143. package/lib/typescript/src/charts/line/Chart.d.ts +5 -1
  144. package/lib/typescript/src/charts/line/ChartPath.d.ts +10 -1
  145. package/lib/typescript/src/charts/line/Context.d.ts +3 -0
  146. package/lib/typescript/src/charts/line/Cursor.d.ts +3 -0
  147. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +4 -1
  148. package/lib/typescript/src/charts/line/CursorLine.d.ts +4 -1
  149. package/lib/typescript/src/charts/line/DatetimeText.d.ts +3 -0
  150. package/lib/typescript/src/charts/line/Dot.d.ts +10 -7
  151. package/lib/typescript/src/charts/line/Gradient.d.ts +3 -0
  152. package/lib/typescript/src/charts/line/Group.d.ts +1 -2
  153. package/lib/typescript/src/charts/line/Highlight.d.ts +15 -0
  154. package/lib/typescript/src/charts/line/HorizontalLine.d.ts +4 -1
  155. package/lib/typescript/src/charts/line/Path.d.ts +5 -1
  156. package/lib/typescript/src/charts/line/PriceText.d.ts +3 -0
  157. package/lib/typescript/src/charts/line/Tooltip.d.ts +3 -0
  158. package/lib/typescript/src/charts/line/index.d.ts +15 -25
  159. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +8 -0
  160. package/lib/typescript/src/charts/line/utils/getArea.d.ts +9 -0
  161. package/lib/typescript/src/charts/line/utils/getDomain.d.ts +2 -0
  162. package/lib/typescript/src/charts/line/utils/getPath.d.ts +11 -0
  163. package/lib/typescript/src/charts/line/utils/index.d.ts +5 -0
  164. package/lib/typescript/src/charts/line/{interpolatePath.d.ts → utils/interpolatePath.d.ts} +1 -1
  165. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +2 -0
  166. package/lib/typescript/src/index.d.ts +1 -1
  167. package/lib/typescript/src/utils/formatDatetime.d.ts +8 -0
  168. package/lib/typescript/src/utils/formatPrice.d.ts +8 -0
  169. package/lib/typescript/src/utils/index.d.ts +3 -0
  170. package/lib/typescript/src/utils/usePrevious.d.ts +1 -0
  171. package/package.json +4 -2
  172. package/src/charts/candle/utils/getDomain.ts +9 -0
  173. package/src/charts/candle/utils/getHeight.ts +21 -0
  174. package/src/charts/candle/utils/getPrice.ts +17 -0
  175. package/src/charts/candle/utils/getY.ts +16 -0
  176. package/src/charts/candle/utils/index.ts +4 -0
  177. package/src/charts/line/Chart.tsx +9 -3
  178. package/src/charts/line/ChartPath.tsx +109 -33
  179. package/src/charts/line/Context.tsx +2 -0
  180. package/src/charts/line/Cursor.tsx +2 -0
  181. package/src/charts/line/CursorCrosshair.tsx +20 -5
  182. package/src/charts/line/CursorLine.tsx +5 -3
  183. package/src/charts/line/DatetimeText.tsx +2 -0
  184. package/src/charts/line/Dot.tsx +83 -86
  185. package/src/charts/line/Gradient.tsx +7 -34
  186. package/src/charts/line/Group.tsx +4 -47
  187. package/src/charts/line/Highlight.tsx +78 -0
  188. package/src/charts/line/HorizontalLine.tsx +5 -3
  189. package/src/charts/line/Path.tsx +14 -38
  190. package/src/charts/line/PriceText.tsx +2 -0
  191. package/src/charts/line/Tooltip.tsx +2 -0
  192. package/src/charts/line/index.ts +11 -7
  193. package/src/charts/line/useAnimatedPath.ts +47 -0
  194. package/src/charts/line/utils/getArea.ts +38 -0
  195. package/src/charts/line/utils/getDomain.ts +7 -0
  196. package/src/charts/line/utils/getPath.ts +48 -0
  197. package/src/charts/line/utils/index.ts +5 -0
  198. package/src/charts/line/{interpolatePath.ts → utils/interpolatePath.ts} +1 -1
  199. package/src/charts/line/utils/lineChartDataPropToArray.ts +25 -0
  200. package/src/index.ts +1 -1
  201. package/src/utils/formatDatetime.ts +16 -0
  202. package/src/{utils.ts → utils/formatPrice.ts} +0 -31
  203. package/src/utils/index.ts +3 -0
  204. package/src/utils/usePrevious.ts +13 -0
  205. package/yarn.lock +8 -1
  206. package/lib/commonjs/charts/line/utils.js.map +0 -1
  207. package/lib/commonjs/utils.js.map +0 -1
  208. package/lib/module/charts/line/utils.js +0 -60
  209. package/lib/module/charts/line/utils.js.map +0 -1
  210. package/lib/module/utils.js.map +0 -1
  211. package/lib/typescript/src/charts/line/utils.d.ts +0 -20
  212. package/lib/typescript/src/utils.d.ts +0 -17
  213. package/src/charts/line/utils.ts +0 -100
@@ -1 +1 @@
1
- {"version":3,"sources":["Cursor.tsx"],"names":["CursorContext","React","createContext","type","LineChartCursor","children","props","pathWidth","width","path","useContext","LineChartDimensionsContext","currentX","currentIndex","isActive","data","parsedPath","useMemo","undefined","onGestureEvent","onActive","x","boundedX","value","minIndex","boundedIndex","Math","max","round","length","onEnd","StyleSheet","absoluteFill"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AAEA;;AACA;;;;;;;;AAOO,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAN,CAAoB;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAApB,CAAtB;;;AAEA,SAASC,eAAT,CAAyB;AAC9BC,EAAAA,QAD8B;AAE9BF,EAAAA,IAF8B;AAG9B,KAAGG;AAH2B,CAAzB,EAIkB;AACvB,QAAM;AAAEC,IAAAA,SAAS,EAAEC,KAAb;AAAoBC,IAAAA;AAApB,MAA6BR,KAAK,CAACS,UAAN,CACjCC,iCADiC,CAAnC;AAGA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,MAA6C,iCAAn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import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport {\n GestureEvent,\n LongPressGestureHandler,\n LongPressGestureHandlerEventPayload,\n LongPressGestureHandlerProps,\n} from 'react-native-gesture-handler';\nimport Animated, { useAnimatedGestureHandler } from 'react-native-reanimated';\nimport { parse } from 'react-native-redash';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { useLineChart } from './useLineChart';\n\nexport type LineChartCursorProps = LongPressGestureHandlerProps & {\n children: React.ReactNode;\n type: 'line' | 'crosshair';\n};\n\nexport const CursorContext = React.createContext({ type: '' });\n\nexport function LineChartCursor({\n children,\n type,\n ...props\n}: LineChartCursorProps) {\n const { pathWidth: width, path } = React.useContext(\n LineChartDimensionsContext\n );\n const { currentX, currentIndex, isActive, data } = useLineChart();\n\n const parsedPath = React.useMemo(\n () => (path ? parse(path) : undefined),\n [path]\n );\n\n const onGestureEvent = useAnimatedGestureHandler<\n GestureEvent<LongPressGestureHandlerEventPayload>\n >({\n onActive: ({ x }) => {\n if (parsedPath) {\n const boundedX = x <= width ? x : width;\n isActive.value = true;\n currentX.value = boundedX;\n\n // on Web, we could drag the cursor to be negative, breaking it\n // so we clamp the index at 0 to fix it\n // https://github.com/coinjar/react-native-wagmi-charts/issues/24\n const minIndex = 0;\n const boundedIndex = Math.max(\n minIndex,\n Math.round(boundedX / width / (1 / (data.length - 1)))\n );\n\n currentIndex.value = boundedIndex;\n }\n },\n onEnd: () => {\n isActive.value = false;\n currentIndex.value = -1;\n },\n });\n\n return (\n <CursorContext.Provider value={{ type }}>\n <LongPressGestureHandler\n minDurationMs={0}\n maxDist={999999}\n onGestureEvent={onGestureEvent}\n {...props}\n >\n <Animated.View style={StyleSheet.absoluteFill}>\n {children}\n </Animated.View>\n </LongPressGestureHandler>\n </CursorContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"sources":["Cursor.tsx"],"names":["CursorContext","React","createContext","type","LineChartCursor","displayName","children","props","pathWidth","width","path","useContext","LineChartDimensionsContext","currentX","currentIndex","isActive","data","parsedPath","useMemo","undefined","onGestureEvent","onActive","x","boundedX","value","minIndex","boundedIndex","Math","max","round","length","onEnd","StyleSheet","absoluteFill"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AAEA;;AACA;;;;;;;;AAOO,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAN,CAAoB;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAApB,CAAtB;;AAEPC,eAAe,CAACC,WAAhB,GAA8B,iBAA9B;;AAEO,SAASD,eAAT,CAAyB;AAC9BE,EAAAA,QAD8B;AAE9BH,EAAAA,IAF8B;AAG9B,KAAGI;AAH2B,CAAzB,EAIkB;AACvB,QAAM;AAAEC,IAAAA,SAAS,EAAEC,KAAb;AAAoBC,IAAAA;AAApB,MAA6BT,KAAK,CAACU,UAAN,CACjCC,iCADiC,CAAnC;AAGA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,MAA6C,iCAAnD;AAEA,QAAMC,UAAU,GAAGhB,KAAK,CAACiB,OAAN,CACjB,MAAOR,IAAI,GAAG,8BAAMA,IAAN,CAAH,GAAiBS,SADX,EAEjB,CAACT,IAAD,CAFiB,CAAnB;AAKA,QAAMU,cAAc,GAAG,sDAErB;AACAC,IAAAA,QAAQ,EAAE,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAW;AACnB,UAAIL,UAAJ,EAAgB;AACd,cAAMM,QAAQ,GAAGD,CAAC,IAAIb,KAAL,GAAaa,CAAb,GAAiBb,KAAlC;AACAM,QAAAA,QAAQ,CAACS,KAAT,GAAiB,IAAjB;AACAX,QAAAA,QAAQ,CAACW,KAAT,GAAiBD,QAAjB,CAHc,CAKd;AACA;AACA;;AACA,cAAME,QAAQ,GAAG,CAAjB;AACA,cAAMC,YAAY,GAAGC,IAAI,CAACC,GAAL,CACnBH,QADmB,EAEnBE,IAAI,CAACE,KAAL,CAAWN,QAAQ,GAAGd,KAAX,IAAoB,KAAKO,IAAI,CAACc,MAAL,GAAc,CAAnB,CAApB,CAAX,CAFmB,CAArB;AAKAhB,QAAAA,YAAY,CAACU,KAAb,GAAqBE,YAArB;AACD;AACF,KAlBD;AAmBAK,IAAAA,KAAK,EAAE,MAAM;AACXhB,MAAAA,QAAQ,CAACS,KAAT,GAAiB,KAAjB;AACAV,MAAAA,YAAY,CAACU,KAAb,GAAqB,CAAC,CAAtB;AACD;AAtBD,GAFqB,CAAvB;AA2BA,sBACE,oBAAC,aAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAE;AAAErB,MAAAA;AAAF;AAA/B,kBACE,oBAAC,kDAAD;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,OAAO,EAAE,MAFX;AAGE,IAAA,cAAc,EAAEiB;AAHlB,KAIMb,KAJN,gBAME,oBAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEyB,wBAAWC;AAAjC,KACG3B,QADH,CANF,CADF,CADF;AAcD","sourcesContent":["import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport {\n GestureEvent,\n LongPressGestureHandler,\n LongPressGestureHandlerEventPayload,\n LongPressGestureHandlerProps,\n} from 'react-native-gesture-handler';\nimport Animated, { useAnimatedGestureHandler } from 'react-native-reanimated';\nimport { parse } from 'react-native-redash';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { useLineChart } from './useLineChart';\n\nexport type LineChartCursorProps = LongPressGestureHandlerProps & {\n children: React.ReactNode;\n type: 'line' | 'crosshair';\n};\n\nexport const CursorContext = React.createContext({ type: '' });\n\nLineChartCursor.displayName = 'LineChartCursor';\n\nexport function LineChartCursor({\n children,\n type,\n ...props\n}: LineChartCursorProps) {\n const { pathWidth: width, path } = React.useContext(\n LineChartDimensionsContext\n );\n const { currentX, currentIndex, isActive, data } = useLineChart();\n\n const parsedPath = React.useMemo(\n () => (path ? parse(path) : undefined),\n [path]\n );\n\n const onGestureEvent = useAnimatedGestureHandler<\n GestureEvent<LongPressGestureHandlerEventPayload>\n >({\n onActive: ({ x }) => {\n if (parsedPath) {\n const boundedX = x <= width ? x : width;\n isActive.value = true;\n currentX.value = boundedX;\n\n // on Web, we could drag the cursor to be negative, breaking it\n // so we clamp the index at 0 to fix it\n // https://github.com/coinjar/react-native-wagmi-charts/issues/24\n const minIndex = 0;\n const boundedIndex = Math.max(\n minIndex,\n Math.round(boundedX / width / (1 / (data.length - 1)))\n );\n\n currentIndex.value = boundedIndex;\n }\n },\n onEnd: () => {\n isActive.value = false;\n currentIndex.value = -1;\n },\n });\n\n return (\n <CursorContext.Provider value={{ type }}>\n <LongPressGestureHandler\n minDurationMs={0}\n maxDist={999999}\n onGestureEvent={onGestureEvent}\n {...props}\n >\n <Animated.View style={StyleSheet.absoluteFill}>\n {children}\n </Animated.View>\n </LongPressGestureHandler>\n </CursorContext.Provider>\n );\n}\n"]}
@@ -21,6 +21,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
21
21
 
22
22
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
23
 
24
+ LineChartCursorCrosshair.displayName = 'LineChartCursorCrosshair';
25
+
24
26
  function LineChartCursorCrosshair({
25
27
  children,
26
28
  color = 'black',
@@ -35,16 +37,21 @@ function LineChartCursorCrosshair({
35
37
  currentX,
36
38
  currentY,
37
39
  isActive
38
- } = (0, _useLineChart.useLineChart)();
40
+ } = (0, _useLineChart.useLineChart)(); // It seems that enabling spring animation on initial render on Android causes a crash.
41
+
42
+ const [enableSpringAnimation, setEnableSpringAnimation] = React.useState(_reactNative.Platform.OS === 'ios');
43
+ React.useEffect(() => {
44
+ setEnableSpringAnimation(true);
45
+ }, []);
39
46
  const animatedCursorStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
40
47
  transform: [{
41
48
  translateX: currentX.value - outerSize / 2
42
49
  }, {
43
50
  translateY: currentY.value - outerSize / 2
44
51
  }, {
45
- scale: (0, _reactNativeReanimated.withSpring)(isActive.value ? 1 : 0, {
52
+ scale: enableSpringAnimation ? (0, _reactNativeReanimated.withSpring)(isActive.value ? 1 : 0, {
46
53
  damping: 10
47
- })
54
+ }) : 0
48
55
  }]
49
56
  }));
50
57
  return /*#__PURE__*/React.createElement(_Cursor.LineChartCursor, _extends({
@@ -1 +1 @@
1
- {"version":3,"sources":["CursorCrosshair.tsx"],"names":["LineChartCursorCrosshair","children","color","size","outerSize","crosshairWrapperProps","crosshairProps","crosshairOuterProps","props","currentX","currentY","isActive","animatedCursorStyle","transform","translateX","value","translateY","scale","damping","width","height","alignItems","justifyContent","style","backgroundColor","borderRadius","opacity","position"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAKA;;AACA;;;;;;;;AAYO,SAASA,wBAAT,CAAkC;AACvCC,EAAAA,QADuC;AAEvCC,EAAAA,KAAK,GAAG,OAF+B;AAGvCC,EAAAA,IAAI,GAAG,CAHgC;AAIvCC,EAAAA,SAAS,GAAG,EAJ2B;AAKvCC,EAAAA,qBAAqB,GAAG,EALe;AAMvCC,EAAAA,cAAc,GAAG,EANsB;AAOvCC,EAAAA,mBAAmB,GAAG,EAPiB;AAQvC,KAAGC;AARoC,CAAlC,EAS2B;AAChC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA;AAAtB,MAAmC,iCAAzC;AAEA,QAAMC,mBAAmB,GAAG,6CAAiB,OAAO;AAClDC,IAAAA,SAAS,EAAE,CACT;AAAEC,MAAAA,UAAU,EAAEL,QAAQ,CAACM,KAAT,GAAiBX,SAAS,GAAG;AAA3C,KADS,EAET;AAAEY,MAAAA,UAAU,EAAEN,QAAQ,CAACK,KAAT,GAAiBX,SAAS,GAAG;AAA3C,KAFS,EAGT;AACEa,MAAAA,KAAK,EAAE,uCAAWN,QAAQ,CAACI,KAAT,GAAiB,CAAjB,GAAqB,CAAhC,EAAmC;AACxCG,QAAAA,OAAO,EAAE;AAD+B,OAAnC;AADT,KAHS;AADuC,GAAP,CAAjB,CAA5B;AAYA,sBACE,oBAAC,uBAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KAAsCV,KAAtC,gBACE,oBAAC,8BAAD,CAAU,IAAV,eACMH,qBADN;AAEE,IAAA,KAAK,EAAE,CACL;AACEc,MAAAA,KAAK,EAAEf,SADT;AAEEgB,MAAAA,MAAM,EAAEhB,SAFV;AAGEiB,MAAAA,UAAU,EAAE,QAHd;AAIEC,MAAAA,cAAc,EAAE;AAJlB,KADK,EAOLV,mBAPK,EAQLP,qBAAqB,CAACkB,KARjB;AAFT,mBAaE,oBAAC,iBAAD,eACMhB,mBADN;AAEE,IAAA,KAAK,EAAE,CACL;AACEiB,MAAAA,eAAe,EAAEtB,KADnB;AAEEiB,MAAAA,KAAK,EAAEf,SAFT;AAGEgB,MAAAA,MAAM,EAAEhB,SAHV;AAIEqB,MAAAA,YAAY,EAAErB,SAJhB;AAKEsB,MAAAA,OAAO,EAAE,GALX;AAMEC,MAAAA,QAAQ,EAAE;AANZ,KADK,EASLpB,mBAAmB,CAACgB,KATf;AAFT,KAbF,eA2BE,oBAAC,iBAAD,eACMjB,cADN;AAEE,IAAA,KAAK,EAAE,CACL;AACEkB,MAAAA,eAAe,EAAEtB,KADnB;AAEEiB,MAAAA,KAAK,EAAEhB,IAFT;AAGEiB,MAAAA,MAAM,EAAEjB,IAHV;AAIEsB,MAAAA,YAAY,EAAEtB;AAJhB,KADK,EAOLG,cAAc,CAACiB,KAPV;AAFT,KA3BF,CADF,EAyCGtB,QAzCH,CADF;AA6CD","sourcesContent":["import * as React from 'react';\nimport { View, ViewProps } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { LineChartCursor, LineChartCursorProps } from './Cursor';\nimport { useLineChart } from './useLineChart';\n\ntype LineChartCursorCrosshairProps = Omit<LineChartCursorProps, 'type'> & {\n children?: React.ReactNode;\n color?: string;\n size?: number;\n outerSize?: number;\n crosshairWrapperProps?: Animated.AnimateProps<ViewProps>;\n crosshairProps?: ViewProps;\n crosshairOuterProps?: ViewProps;\n};\n\nexport function LineChartCursorCrosshair({\n children,\n color = 'black',\n size = 8,\n outerSize = 32,\n crosshairWrapperProps = {},\n crosshairProps = {},\n crosshairOuterProps = {},\n ...props\n}: LineChartCursorCrosshairProps) {\n const { currentX, currentY, isActive } = useLineChart();\n\n const animatedCursorStyle = useAnimatedStyle(() => ({\n transform: [\n { translateX: currentX.value - outerSize / 2 },\n { translateY: currentY.value - outerSize / 2 },\n {\n scale: withSpring(isActive.value ? 1 : 0, {\n damping: 10,\n }),\n },\n ],\n }));\n\n return (\n <LineChartCursor type=\"crosshair\" {...props}>\n <Animated.View\n {...crosshairWrapperProps}\n style={[\n {\n width: outerSize,\n height: outerSize,\n alignItems: 'center',\n justifyContent: 'center',\n },\n animatedCursorStyle,\n crosshairWrapperProps.style,\n ]}\n >\n <View\n {...crosshairOuterProps}\n style={[\n {\n backgroundColor: color,\n width: outerSize,\n height: outerSize,\n borderRadius: outerSize,\n opacity: 0.1,\n position: 'absolute',\n },\n crosshairOuterProps.style,\n ]}\n />\n <View\n {...crosshairProps}\n style={[\n {\n backgroundColor: color,\n width: size,\n height: size,\n borderRadius: size,\n },\n crosshairProps.style,\n ]}\n />\n </Animated.View>\n {children}\n </LineChartCursor>\n );\n}\n"]}
1
+ {"version":3,"sources":["CursorCrosshair.tsx"],"names":["LineChartCursorCrosshair","displayName","children","color","size","outerSize","crosshairWrapperProps","crosshairProps","crosshairOuterProps","props","currentX","currentY","isActive","enableSpringAnimation","setEnableSpringAnimation","React","useState","Platform","OS","useEffect","animatedCursorStyle","transform","translateX","value","translateY","scale","damping","width","height","alignItems","justifyContent","style","backgroundColor","borderRadius","opacity","position"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAKA;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V,eACMH,qBADN;AAEE,IAAA,KAAK,EAAE,CACL;AACEqB,MAAAA,KAAK,EAAEtB,SADT;AAEEuB,MAAAA,MAAM,EAAEvB,SAFV;AAGEwB,MAAAA,UAAU,EAAE,QAHd;AAIEC,MAAAA,cAAc,EAAE;AAJlB,KADK,EAOLV,mBAPK,EAQLd,qBAAqB,CAACyB,KARjB;AAFT,mBAaE,oBAAC,iBAAD,eACMvB,mBADN;AAEE,IAAA,KAAK,EAAE,CACL;AACEwB,MAAAA,eAAe,EAAE7B,KADnB;AAEEwB,MAAAA,KAAK,EAAEtB,SAFT;AAGEuB,MAAAA,MAAM,EAAEvB,SAHV;AAIE4B,MAAAA,YAAY,EAAE5B,SAJhB;AAKE6B,MAAAA,OAAO,EAAE,GALX;AAMEC,MAAAA,QAAQ,EAAE;AANZ,KADK,EASL3B,mBAAmB,CAACuB,KATf;AAFT,KAbF,eA2BE,oBAAC,iBAAD,eACMxB,cADN;AAEE,IAAA,KAAK,EAAE,CACL;AACEyB,MAAAA,eAAe,EAAE7B,KADnB;AAEEwB,MAAAA,KAAK,EAAEvB,IAFT;AAGEwB,MAAAA,MAAM,EAAExB,IAHV;AAIE6B,MAAAA,YAAY,EAAE7B;AAJhB,KADK,EAOLG,cAAc,CAACwB,KAPV;AAFT,KA3BF,CADF,EAyCG7B,QAzCH,CADF;AA6CD","sourcesContent":["import * as React from 'react';\nimport { Platform, View, ViewProps } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { LineChartCursor, LineChartCursorProps } from './Cursor';\nimport { useLineChart } from './useLineChart';\n\ntype LineChartCursorCrosshairProps = Omit<\n LineChartCursorProps,\n 'children' | 'type'\n> & {\n children?: React.ReactNode;\n color?: string;\n size?: number;\n outerSize?: number;\n crosshairWrapperProps?: Animated.AnimateProps<ViewProps>;\n crosshairProps?: ViewProps;\n crosshairOuterProps?: ViewProps;\n};\n\nLineChartCursorCrosshair.displayName = 'LineChartCursorCrosshair';\n\nexport function LineChartCursorCrosshair({\n children,\n color = 'black',\n size = 8,\n outerSize = 32,\n crosshairWrapperProps = {},\n crosshairProps = {},\n crosshairOuterProps = {},\n ...props\n}: LineChartCursorCrosshairProps) {\n const { currentX, currentY, isActive } = useLineChart();\n\n // It seems that enabling spring animation on initial render on Android causes a crash.\n const [enableSpringAnimation, setEnableSpringAnimation] = React.useState(\n Platform.OS === 'ios'\n );\n React.useEffect(() => {\n setEnableSpringAnimation(true);\n }, []);\n\n const animatedCursorStyle = useAnimatedStyle(() => ({\n transform: [\n { translateX: currentX.value - outerSize / 2 },\n { translateY: currentY.value - outerSize / 2 },\n {\n scale: enableSpringAnimation\n ? withSpring(isActive.value ? 1 : 0, {\n damping: 10,\n })\n : 0,\n },\n ],\n }));\n\n return (\n <LineChartCursor type=\"crosshair\" {...props}>\n <Animated.View\n {...crosshairWrapperProps}\n style={[\n {\n width: outerSize,\n height: outerSize,\n alignItems: 'center',\n justifyContent: 'center',\n },\n animatedCursorStyle,\n crosshairWrapperProps.style,\n ]}\n >\n <View\n {...crosshairOuterProps}\n style={[\n {\n backgroundColor: color,\n width: outerSize,\n height: outerSize,\n borderRadius: outerSize,\n opacity: 0.1,\n position: 'absolute',\n },\n crosshairOuterProps.style,\n ]}\n />\n <View\n {...crosshairProps}\n style={[\n {\n backgroundColor: color,\n width: size,\n height: size,\n borderRadius: size,\n },\n crosshairProps.style,\n ]}\n />\n </Animated.View>\n {children}\n </LineChartCursor>\n );\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.LineChartCursorLine = void 0;
6
+ exports.LineChartCursorLine = LineChartCursorLine;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -27,11 +27,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
27
27
 
28
28
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
29
29
 
30
- const LineChartCursorLine = ({
30
+ LineChartCursorLine.displayName = 'LineChartCursorLine';
31
+
32
+ function LineChartCursorLine({
31
33
  children,
32
34
  color = 'gray',
33
35
  lineProps = {}
34
- }) => {
36
+ }) {
35
37
  const {
36
38
  height
37
39
  } = _react.default.useContext(_Chart.LineChartDimensionsContext);
@@ -62,9 +64,7 @@ const LineChartCursorLine = ({
62
64
  stroke: color,
63
65
  strokeDasharray: "3 3"
64
66
  }, lineProps)))), children);
65
- };
66
-
67
- exports.LineChartCursorLine = LineChartCursorLine;
67
+ }
68
68
 
69
69
  const styles = _reactNative.StyleSheet.create({
70
70
  svg: { ..._reactNative.StyleSheet.absoluteFillObject,
@@ -1 +1 @@
1
- {"version":3,"sources":["CursorLine.tsx"],"names":["LineChartCursorLine","children","color","lineProps","height","React","useContext","LineChartDimensionsContext","currentX","isActive","vertical","opacity","value","transform","translateX","styles","svg","StyleSheet","create","absoluteFillObject"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAQO,MAAMA,mBAAmB,GAAG,CAAC;AAClCC,EAAAA,QADkC;AAElCC,EAAAA,KAAK,GAAG,MAF0B;AAGlCC,EAAAA,SAAS,GAAG;AAHsB,CAAD,KAIH;AAC9B,QAAM;AAAEC,IAAAA;AAAF,MAAaC,eAAMC,UAAN,CAAiBC,iCAAjB,CAAnB;;AACA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyB,iCAA/B;AAEA,QAAMC,QAAQ,GAAG,6CAAiB,OAAO;AACvCC,IAAAA,OAAO,EAAEF,QAAQ,CAACG,KAAT,GAAiB,CAAjB,GAAqB,CADS;AAEvCR,IAAAA,MAAM,EAAE,MAF+B;AAGvCS,IAAAA,SAAS,EAAE,CAAC;AAAEC,MAAAA,UAAU,EAAEN,QAAQ,CAACI;AAAvB,KAAD;AAH4B,GAAP,CAAjB,CAAjB;AAMA,sBACE,6BAAC,uBAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,kBACE,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEF;AAAtB,kBACE,6BAAC,uBAAD;AAAK,IAAA,KAAK,EAAEK,MAAM,CAACC;AAAnB,kBACE,6BAAC,oBAAD;AACE,IAAA,EAAE,EAAE,CADN;AAEE,IAAA,EAAE,EAAE,CAFN;AAGE,IAAA,EAAE,EAAE,CAHN;AAIE,IAAA,EAAE,EAAEZ,MAJN;AAKE,IAAA,WAAW,EAAE,CALf;AAME,IAAA,MAAM,EAAEF,KANV;AAOE,IAAA,eAAe,EAAC;AAPlB,KAQMC,SARN,EADF,CADF,CADF,EAeGF,QAfH,CADF;AAmBD,CAjCM;;;;AAmCP,MAAMc,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,GAAG,EAAE,EACH,GAAGC,wBAAWE,kBADX;AAEH;AACAf,IAAAA,MAAM,EAAE;AAHL;AAD0B,CAAlB,CAAf","sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Animated, { useAnimatedStyle } from 'react-native-reanimated';\nimport Svg, { Line as SVGLine, LineProps } from 'react-native-svg';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartCursor } from './Cursor';\nimport { useLineChart } from './useLineChart';\n\ntype LineChartCursorLineProps = {\n children?: React.ReactNode;\n color?: string;\n lineProps?: Partial<LineProps>;\n};\n\nexport const LineChartCursorLine = ({\n children,\n color = 'gray',\n lineProps = {},\n}: LineChartCursorLineProps) => {\n const { height } = React.useContext(LineChartDimensionsContext);\n const { currentX, isActive } = useLineChart();\n\n const vertical = useAnimatedStyle(() => ({\n opacity: isActive.value ? 1 : 0,\n height: '100%',\n transform: [{ translateX: currentX.value }],\n }));\n\n return (\n <LineChartCursor type=\"line\">\n <Animated.View style={vertical}>\n <Svg style={styles.svg}>\n <SVGLine\n x1={0}\n y1={0}\n x2={0}\n y2={height}\n strokeWidth={2}\n stroke={color}\n strokeDasharray=\"3 3\"\n {...lineProps}\n />\n </Svg>\n </Animated.View>\n {children}\n </LineChartCursor>\n );\n};\n\nconst styles = StyleSheet.create({\n svg: {\n ...StyleSheet.absoluteFillObject,\n // height: 100% is required for <svg /> on web\n height: '100%',\n },\n});\n"]}
1
+ {"version":3,"sources":["CursorLine.tsx"],"names":["LineChartCursorLine","displayName","children","color","lineProps","height","React","useContext","LineChartDimensionsContext","currentX","isActive","vertical","opacity","value","transform","translateX","styles","svg","StyleSheet","create","absoluteFillObject"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAQAA,mBAAmB,CAACC,WAApB,GAAkC,qBAAlC;;AAEO,SAASD,mBAAT,CAA6B;AAClCE,EAAAA,QADkC;AAElCC,EAAAA,KAAK,GAAG,MAF0B;AAGlCC,EAAAA,SAAS,GAAG;AAHsB,CAA7B,EAIsB;AAC3B,QAAM;AAAEC,IAAAA;AAAF,MAAaC,eAAMC,UAAN,CAAiBC,iCAAjB,CAAnB;;AACA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyB,iCAA/B;AAEA,QAAMC,QAAQ,GAAG,6CAAiB,OAAO;AACvCC,IAAAA,OAAO,EAAEF,QAAQ,CAACG,KAAT,GAAiB,CAAjB,GAAqB,CADS;AAEvCR,IAAAA,MAAM,EAAE,MAF+B;AAGvCS,IAAAA,SAAS,EAAE,CAAC;AAAEC,MAAAA,UAAU,EAAEN,QAAQ,CAACI;AAAvB,KAAD;AAH4B,GAAP,CAAjB,CAAjB;AAMA,sBACE,6BAAC,uBAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,kBACE,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEF;AAAtB,kBACE,6BAAC,uBAAD;AAAK,IAAA,KAAK,EAAEK,MAAM,CAACC;AAAnB,kBACE,6BAAC,oBAAD;AACE,IAAA,EAAE,EAAE,CADN;AAEE,IAAA,EAAE,EAAE,CAFN;AAGE,IAAA,EAAE,EAAE,CAHN;AAIE,IAAA,EAAE,EAAEZ,MAJN;AAKE,IAAA,WAAW,EAAE,CALf;AAME,IAAA,MAAM,EAAEF,KANV;AAOE,IAAA,eAAe,EAAC;AAPlB,KAQMC,SARN,EADF,CADF,CADF,EAeGF,QAfH,CADF;AAmBD;;AAED,MAAMc,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,GAAG,EAAE,EACH,GAAGC,wBAAWE,kBADX;AAEH;AACAf,IAAAA,MAAM,EAAE;AAHL;AAD0B,CAAlB,CAAf","sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Animated, { useAnimatedStyle } from 'react-native-reanimated';\nimport Svg, { Line as SVGLine, LineProps } from 'react-native-svg';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartCursor } from './Cursor';\nimport { useLineChart } from './useLineChart';\n\ntype LineChartCursorLineProps = {\n children?: React.ReactNode;\n color?: string;\n lineProps?: Partial<LineProps>;\n};\n\nLineChartCursorLine.displayName = 'LineChartCursorLine';\n\nexport function LineChartCursorLine({\n children,\n color = 'gray',\n lineProps = {},\n}: LineChartCursorLineProps) {\n const { height } = React.useContext(LineChartDimensionsContext);\n const { currentX, isActive } = useLineChart();\n\n const vertical = useAnimatedStyle(() => ({\n opacity: isActive.value ? 1 : 0,\n height: '100%',\n transform: [{ translateX: currentX.value }],\n }));\n\n return (\n <LineChartCursor type=\"line\">\n <Animated.View style={vertical}>\n <Svg style={styles.svg}>\n <SVGLine\n x1={0}\n y1={0}\n x2={0}\n y2={height}\n strokeWidth={2}\n stroke={color}\n strokeDasharray=\"3 3\"\n {...lineProps}\n />\n </Svg>\n </Animated.View>\n {children}\n </LineChartCursor>\n );\n}\n\nconst styles = StyleSheet.create({\n svg: {\n ...StyleSheet.absoluteFillObject,\n // height: 100% is required for <svg /> on web\n height: '100%',\n },\n});\n"]}
@@ -15,6 +15,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
15
15
 
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
+ LineChartDatetimeText.displayName = 'LineChartDatetimeText';
19
+
18
20
  function LineChartDatetimeText({
19
21
  locale,
20
22
  options,
@@ -1 +1 @@
1
- {"version":3,"sources":["DatetimeText.tsx"],"names":["LineChartDatetimeText","locale","options","format","variant","style","datetime"],"mappings":";;;;;;;AAAA;;AAIA;;AAEA;;;;;;AAUO,SAASA,qBAAT,CAA+B;AACpCC,EAAAA,MADoC;AAEpCC,EAAAA,OAFoC;AAGpCC,EAAAA,MAHoC;AAIpCC,EAAAA,OAAO,GAAG,WAJ0B;AAKpCC,EAAAA;AALoC,CAA/B,EAMoB;AACzB,QAAMC,QAAQ,GAAG,uCAAqB;AAAEH,IAAAA,MAAF;AAAUF,IAAAA,MAAV;AAAkBC,IAAAA;AAAlB,GAArB,CAAjB;AACA,sBAAO,oBAAC,0BAAD;AAAc,IAAA,IAAI,EAAEI,QAAQ,CAACF,OAAD,CAA5B;AAAuC,IAAA,KAAK,EAAEC;AAA9C,IAAP;AACD","sourcesContent":["import * as React from 'react';\nimport type { TextProps as RNTextProps } from 'react-native';\nimport type Animated from 'react-native-reanimated';\n\nimport { useLineChartDatetime } from './useDatetime';\nimport type { TFormatterFn } from 'react-native-wagmi-charts';\nimport { AnimatedText } from '../../components/AnimatedText';\n\ntype LineChartDatetimeProps = {\n locale?: string;\n options?: Intl.DateTimeFormatOptions;\n format?: TFormatterFn<number>;\n variant?: 'formatted' | 'value';\n style?: Animated.AnimateProps<RNTextProps>['style'];\n};\n\nexport function LineChartDatetimeText({\n locale,\n options,\n format,\n variant = 'formatted',\n style,\n}: LineChartDatetimeProps) {\n const datetime = useLineChartDatetime({ format, locale, options });\n return <AnimatedText text={datetime[variant]} style={style} />;\n}\n"]}
1
+ {"version":3,"sources":["DatetimeText.tsx"],"names":["LineChartDatetimeText","displayName","locale","options","format","variant","style","datetime"],"mappings":";;;;;;;AAAA;;AAIA;;AAEA;;;;;;AAUAA,qBAAqB,CAACC,WAAtB,GAAoC,uBAApC;;AAEO,SAASD,qBAAT,CAA+B;AACpCE,EAAAA,MADoC;AAEpCC,EAAAA,OAFoC;AAGpCC,EAAAA,MAHoC;AAIpCC,EAAAA,OAAO,GAAG,WAJ0B;AAKpCC,EAAAA;AALoC,CAA/B,EAMoB;AACzB,QAAMC,QAAQ,GAAG,uCAAqB;AAAEH,IAAAA,MAAF;AAAUF,IAAAA,MAAV;AAAkBC,IAAAA;AAAlB,GAArB,CAAjB;AACA,sBAAO,oBAAC,0BAAD;AAAc,IAAA,IAAI,EAAEI,QAAQ,CAACF,OAAD,CAA5B;AAAuC,IAAA,KAAK,EAAEC;AAA9C,IAAP;AACD","sourcesContent":["import * as React from 'react';\nimport type { TextProps as RNTextProps } from 'react-native';\nimport type Animated from 'react-native-reanimated';\n\nimport { useLineChartDatetime } from './useDatetime';\nimport type { TFormatterFn } from 'react-native-wagmi-charts';\nimport { AnimatedText } from '../../components/AnimatedText';\n\ntype LineChartDatetimeProps = {\n locale?: string;\n options?: Intl.DateTimeFormatOptions;\n format?: TFormatterFn<number>;\n variant?: 'formatted' | 'value';\n style?: Animated.AnimateProps<RNTextProps>['style'];\n};\n\nLineChartDatetimeText.displayName = 'LineChartDatetimeText';\n\nexport function LineChartDatetimeText({\n locale,\n options,\n format,\n variant = 'formatted',\n style,\n}: LineChartDatetimeProps) {\n const datetime = useLineChartDatetime({ format, locale, options });\n return <AnimatedText text={datetime[variant]} style={style} />;\n}\n"]}
@@ -9,12 +9,14 @@ var React = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
11
 
12
- var _reactNative = require("react-native");
12
+ var _reactNativeSvg = require("react-native-svg");
13
13
 
14
14
  var _reactNativeRedash = require("react-native-redash");
15
15
 
16
16
  var _Chart = require("./Chart");
17
17
 
18
+ var _ChartPath = require("./ChartPath");
19
+
18
20
  var _useLineChart = require("./useLineChart");
19
21
 
20
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -23,16 +25,23 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
25
 
24
26
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
27
 
28
+ const AnimatedCircle = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Circle);
29
+
26
30
  LineChartDot.displayName = 'LineChartDot';
27
31
 
28
32
  function LineChartDot({
29
- color = 'black',
30
33
  at,
31
- size = 8,
32
- pulsesOuter = 'while-inactive',
33
- outerSize = size * 4,
34
+ color: defaultColor = 'black',
34
35
  dotProps,
35
- outerDotProps
36
+ hasOuterDot: defaultHasOuterDot = false,
37
+ hasPulse = false,
38
+ inactiveColor,
39
+ outerDotProps,
40
+ pulseBehaviour = 'while-inactive',
41
+ pulseDurationMs = 800,
42
+ showInactiveColor = true,
43
+ size = 4,
44
+ outerSize = size * 4
36
45
  }) {
37
46
  const {
38
47
  data,
@@ -41,81 +50,77 @@ function LineChartDot({
41
50
  const {
42
51
  path,
43
52
  pathWidth: width
44
- } = React.useContext(_Chart.LineChartDimensionsContext);
45
- const parsedPath = React.useMemo(() => (0, _reactNativeRedash.parse)(path), [path]);
46
- const pointWidth = React.useMemo(() => width / (data.length - 1), [data.length, width]);
53
+ } = React.useContext(_Chart.LineChartDimensionsContext); ////////////////////////////////////////////////////////////
54
+
55
+ const {
56
+ isInactive: _isInactive
57
+ } = React.useContext(_ChartPath.LineChartPathContext);
58
+ const isInactive = showInactiveColor && _isInactive;
59
+ const color = isInactive ? inactiveColor || defaultColor : defaultColor;
60
+ const opacity = isInactive && !inactiveColor ? 0.5 : 1;
61
+ const hasOuterDot = defaultHasOuterDot || hasPulse; ////////////////////////////////////////////////////////////
62
+
63
+ const parsedPath = React.useMemo(() => (0, _reactNativeRedash.parse)(path), [path]); ////////////////////////////////////////////////////////////
64
+
65
+ const pointWidth = React.useMemo(() => width / (data.length - 1), [data.length, width]); ////////////////////////////////////////////////////////////
66
+
47
67
  const x = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.withTiming)(pointWidth * at));
48
- const y = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.withTiming)((0, _reactNativeRedash.getYForX)(parsedPath, x.value) || 0));
49
- const containerStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
50
- return {
51
- transform: [{
52
- translateX: x.value - outerSize / 2
53
- }, {
54
- translateY: y.value - outerSize / 2
55
- }]
68
+ const y = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.withTiming)((0, _reactNativeRedash.getYForX)(parsedPath, x.value) || 0)); ////////////////////////////////////////////////////////////
69
+
70
+ const animatedDotProps = (0, _reactNativeReanimated.useAnimatedProps)(() => ({
71
+ cx: x.value,
72
+ cy: y.value
73
+ }));
74
+ const animatedOuterDotProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
75
+ let defaultProps = {
76
+ cx: x.value,
77
+ cy: y.value,
78
+ opacity: 0.1,
79
+ r: outerSize
56
80
  };
57
- });
58
- const outerStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
59
- let opacity = 0.1;
60
81
 
61
- if (pulsesOuter === 'never') {
62
- return {
63
- opacity
64
- };
82
+ if (!hasPulse) {
83
+ return defaultProps;
65
84
  }
66
85
 
67
- const enterMs = 800;
86
+ if (isActive.value && pulseBehaviour === 'while-inactive') {
87
+ return { ...defaultProps,
88
+ r: 0
89
+ };
90
+ }
68
91
 
69
92
  const easing = _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.sin);
70
93
 
71
94
  const animatedOpacity = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0.8), (0, _reactNativeReanimated.withTiming)(0, {
72
- duration: enterMs,
95
+ duration: pulseDurationMs,
73
96
  easing
74
97
  })), -1, false);
75
- const scale = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0), (0, _reactNativeReanimated.withTiming)(1, {
76
- duration: enterMs,
98
+ const scale = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0), (0, _reactNativeReanimated.withTiming)(outerSize, {
99
+ duration: pulseDurationMs,
77
100
  easing
78
101
  })), -1, false);
79
102
 
80
- if (pulsesOuter === 'while-inactive') {
81
- return {
103
+ if (pulseBehaviour === 'while-inactive') {
104
+ return { ...defaultProps,
82
105
  opacity: isActive.value ? (0, _reactNativeReanimated.withTiming)(0) : animatedOpacity,
83
- transform: [{
84
- scale: isActive.value ? (0, _reactNativeReanimated.withTiming)(0) : scale
85
- }]
106
+ r: isActive.value ? (0, _reactNativeReanimated.withTiming)(0) : scale
86
107
  };
87
108
  }
88
109
 
89
- return {
110
+ return { ...defaultProps,
90
111
  opacity: animatedOpacity,
91
- transform: [{
92
- scale
93
- }]
112
+ r: scale
94
113
  };
95
- }, [pulsesOuter]);
96
- return /*#__PURE__*/React.createElement(_reactNativeReanimated.default.View, {
97
- pointerEvents: "none",
98
- style: (0, React.useMemo)(() => [{
99
- width: outerSize,
100
- height: outerSize,
101
- alignItems: 'center',
102
- justifyContent: 'center'
103
- }, containerStyle], [containerStyle, outerSize])
104
- }, /*#__PURE__*/React.createElement(_reactNativeReanimated.default.View, _extends({}, outerDotProps, {
105
- style: (0, React.useMemo)(() => [{
106
- backgroundColor: color,
107
- width: outerSize,
108
- height: outerSize,
109
- borderRadius: outerSize,
110
- position: 'absolute'
111
- }, outerStyle, outerDotProps === null || outerDotProps === void 0 ? void 0 : outerDotProps.style], [color, outerSize, outerStyle, outerDotProps === null || outerDotProps === void 0 ? void 0 : outerDotProps.style])
112
- })), /*#__PURE__*/React.createElement(_reactNative.View, _extends({}, dotProps, {
113
- style: (0, React.useMemo)(() => [{
114
- backgroundColor: color,
115
- width: size,
116
- height: size,
117
- borderRadius: size
118
- }, dotProps === null || dotProps === void 0 ? void 0 : dotProps.style], [color, size, dotProps === null || dotProps === void 0 ? void 0 : dotProps.style])
119
- })));
114
+ }, [outerSize]); ////////////////////////////////////////////////////////////
115
+
116
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AnimatedCircle, _extends({
117
+ animatedProps: animatedDotProps,
118
+ r: size,
119
+ fill: color,
120
+ opacity: opacity
121
+ }, dotProps)), hasOuterDot && /*#__PURE__*/React.createElement(AnimatedCircle, _extends({
122
+ animatedProps: animatedOuterDotProps,
123
+ fill: color
124
+ }, outerDotProps)));
120
125
  }
121
126
  //# sourceMappingURL=Dot.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Dot.tsx"],"names":["LineChartDot","displayName","color","at","size","pulsesOuter","outerSize","dotProps","outerDotProps","data","isActive","path","pathWidth","width","React","useContext","LineChartDimensionsContext","parsedPath","useMemo","pointWidth","length","x","y","value","containerStyle","transform","translateX","translateY","outerStyle","opacity","enterMs","easing","Easing","out","sin","animatedOpacity","duration","scale","height","alignItems","justifyContent","backgroundColor","borderRadius","position","style"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAGA;;AACA;;;;;;;;AA0BAA,YAAY,CAACC,WAAb,GAA2B,cAA3B;;AAEO,SAASD,YAAT,CAAsB;AAC3BE,EAAAA,KAAK,GAAG,OADmB;AAE3BC,EAAAA,EAF2B;AAG3BC,EAAAA,IAAI,GAAG,CAHoB;AAI3BC,EAAAA,WAAW,GAAG,gBAJa;AAK3BC,EAAAA,SAAS,GAAGF,IAAI,GAAG,CALQ;AAM3BG,EAAAA,QAN2B;AAO3BC,EAAAA;AAP2B,CAAtB,EAQe;AACpB,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAqB,iCAA3B;AACA,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,SAAS,EAAEC;AAAnB,MAA6BC,KAAK,CAACC,UAAN,CACjCC,iCADiC,CAAnC;AAIA,QAAMC,UAAU,GAAGH,KAAK,CAACI,OAAN,CAAc,MAAM,8BAAMP,IAAN,CAApB,EAAiC,CAACA,IAAD,CAAjC,CAAnB;AACA,QAAMQ,UAAU,GAAGL,KAAK,CAACI,OAAN,CACjB,MAAML,KAAK,IAAIJ,IAAI,CAACW,MAAL,GAAc,CAAlB,CADM,EAEjB,CAACX,IAAI,CAACW,MAAN,EAAcP,KAAd,CAFiB,CAAnB;AAKA,QAAMQ,CAAC,GAAG,4CAAgB,MAAM,uCAAWF,UAAU,GAAGhB,EAAxB,CAAtB,CAAV;AACA,QAAMmB,CAAC,GAAG,4CAAgB,MACxB,uCAAW,iCAASL,UAAT,EAAsBI,CAAC,CAACE,KAAxB,KAAkC,CAA7C,CADQ,CAAV;AAIA,QAAMC,cAAc,GAAG,6C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A,QAAQ,CAAEqC,KAAxB,CAVK;AAFT,KAhCF,CADF;AAkDD","sourcesContent":["import * as React from 'react';\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useDerivedValue,\n withRepeat,\n withSequence,\n withTiming,\n} from 'react-native-reanimated';\nimport { View } from 'react-native';\nimport { getYForX, parse } from 'react-native-redash';\nimport { useMemo } from 'react';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { useLineChart } from './useLineChart';\nimport type { ViewProps } from 'react-native';\n\nexport type LineChartDotProps = {\n dotProps?: ViewProps;\n outerDotProps?: ViewProps;\n color?: string;\n at: number;\n size?: number;\n /**\n * If `always`, the outer dot will still animate when interaction is active.\n *\n * If `never`, the outer dot will never animate.\n *\n * If `while-inactive`, the outer dot will animate only when the interaction is inactive.\n *\n * Default: `while-inactive`\n */\n pulsesOuter?: 'always' | 'while-inactive' | 'never';\n /**\n * Defaults to `size * 4`\n */\n outerSize?: number;\n pulseDurationMs?: number;\n};\n\nLineChartDot.displayName = 'LineChartDot';\n\nexport function LineChartDot({\n color = 'black',\n at,\n size = 8,\n pulsesOuter = 'while-inactive',\n outerSize = size * 4,\n dotProps,\n outerDotProps,\n}: LineChartDotProps) {\n const { data, isActive } = useLineChart();\n const { path, pathWidth: width } = React.useContext(\n LineChartDimensionsContext\n );\n\n const parsedPath = React.useMemo(() => parse(path), [path]);\n const pointWidth = React.useMemo(\n () => width / (data.length - 1),\n [data.length, width]\n );\n\n const x = useDerivedValue(() => withTiming(pointWidth * at));\n const y = useDerivedValue(() =>\n withTiming(getYForX(parsedPath!, x.value) || 0)\n );\n\n const containerStyle = useAnimatedStyle(() => {\n return {\n transform: [\n { translateX: x.value - outerSize / 2 },\n { translateY: y.value - outerSize / 2 },\n ],\n };\n });\n const outerStyle = useAnimatedStyle(() => {\n let opacity = 0.1;\n if (pulsesOuter === 'never') {\n return {\n opacity,\n };\n }\n const enterMs = 800;\n const easing = Easing.out(Easing.sin);\n const animatedOpacity = withRepeat(\n withSequence(\n withTiming(0.8),\n withTiming(0, {\n duration: enterMs,\n easing,\n })\n ),\n -1,\n false\n );\n const scale = withRepeat(\n withSequence(\n withTiming(0),\n withTiming(1, {\n duration: enterMs,\n easing,\n })\n ),\n -1,\n false\n );\n\n if (pulsesOuter === 'while-inactive') {\n return {\n opacity: isActive.value ? withTiming(0) : animatedOpacity,\n transform: [\n {\n scale: isActive.value ? withTiming(0) : scale,\n },\n ],\n };\n }\n return {\n opacity: animatedOpacity,\n transform: [\n {\n scale,\n },\n ],\n };\n }, [pulsesOuter]);\n\n return (\n <Animated.View\n pointerEvents=\"none\"\n style={useMemo(\n () => [\n {\n width: outerSize,\n height: outerSize,\n alignItems: 'center',\n justifyContent: 'center',\n },\n containerStyle,\n ],\n [containerStyle, outerSize]\n )}\n >\n <Animated.View\n {...outerDotProps}\n style={useMemo(\n () => [\n {\n backgroundColor: color,\n width: outerSize,\n height: outerSize,\n borderRadius: outerSize,\n position: 'absolute',\n },\n outerStyle,\n outerDotProps?.style,\n ],\n [color, outerSize, outerStyle, outerDotProps?.style]\n )}\n />\n <View\n {...dotProps}\n style={useMemo(\n () => [\n {\n backgroundColor: color,\n width: size,\n height: size,\n borderRadius: size,\n },\n dotProps?.style,\n ],\n [color, size, dotProps?.style]\n )}\n />\n </Animated.View>\n );\n}\n"]}
1
+ {"version":3,"sources":["Dot.tsx"],"names":["AnimatedCircle","Animated","createAnimatedComponent","Circle","LineChartDot","displayName","at","color","defaultColor","dotProps","hasOuterDot","defaultHasOuterDot","hasPulse","inactiveColor","outerDotProps","pulseBehaviour","pulseDurationMs","showInactiveColor","size","outerSize","data","isActive","path","pathWidth","width","React","useContext","LineChartDimensionsContext","isInactive","_isInactive","LineChartPathContext","opacity","parsedPath","useMemo","pointWidth","length","x","y","value","animatedDotProps","cx","cy","animatedOuterDotProps","defaultProps","r","easing","Easing","out","sin","animatedOpacity","duration","scale"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;;;;;;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,CADsB,EAQtB,CAAC,CARqB,EAStB,KATsB,CAAxB;AAWA,UAAMM,KAAK,GAAG,uCACZ,yCACE,uCAAW,CAAX,CADF,EAEE,uCAAWhC,SAAX,EAAsB;AACpB+B,MAAAA,QAAQ,EAAElC,eADU;AAEpB6B,MAAAA;AAFoB,KAAtB,CAFF,CADY,EAQZ,CAAC,CARW,EASZ,KATY,CAAd;;AAYA,QAAI9B,cAAc,KAAK,gBAAvB,EAAyC;AACvC,aAAO,EACL,GAAG4B,YADE;AAELZ,QAAAA,OAAO,EAAEV,QAAQ,CAACiB,KAAT,GAAiB,uCAAW,CAAX,CAAjB,GAAiCW,eAFrC;AAGLL,QAAAA,CAAC,EAAEvB,QAAQ,CAACiB,KAAT,GAAiB,uCAAW,CAAX,CAAjB,GAAiCa;AAH/B,OAAP;AAKD;;AACD,WAAO,EACL,GAAGR,YADE;AAELZ,MAAAA,OAAO,EAAEkB,eAFJ;AAGLL,MAAAA,CAAC,EAAEO;AAHE,KAAP;AAKD,GAvD6B,EAuD3B,CAAChC,SAAD,CAvD2B,CAA9B,CAvCoB,CAgGpB;;AAEA,sBACE,uDACE,oBAAC,cAAD;AACE,IAAA,aAAa,EAAEoB,gBADjB;AAEE,IAAA,CAAC,EAAErB,IAFL;AAGE,IAAA,IAAI,EAAEX,KAHR;AAIE,IAAA,OAAO,EAAEwB;AAJX,KAKMtB,QALN,EADF,EAQGC,WAAW,iBACV,oBAAC,cAAD;AACE,IAAA,aAAa,EAAEgC,qBADjB;AAEE,IAAA,IAAI,EAAEnC;AAFR,KAGMO,aAHN,EATJ,CADF;AAkBD","sourcesContent":["import * as React from 'react';\nimport Animated, {\n Easing,\n useAnimatedProps,\n useDerivedValue,\n withRepeat,\n withSequence,\n withTiming,\n} from 'react-native-reanimated';\nimport { Circle, CircleProps } from 'react-native-svg';\nimport { getYForX, parse } from 'react-native-redash';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartPathContext } from './ChartPath';\nimport { useLineChart } from './useLineChart';\n\nconst AnimatedCircle = Animated.createAnimatedComponent(Circle);\n\nexport type LineChartDotProps = {\n dotProps?: Animated.AnimateProps<CircleProps>;\n outerDotProps?: Animated.AnimateProps<CircleProps>;\n color?: string;\n inactiveColor?: string;\n showInactiveColor?: boolean;\n at: number;\n size?: number;\n hasPulse?: boolean;\n hasOuterDot?: boolean;\n /**\n * If `always`, the outer dot will still animate when interaction is active.\n *\n * If `while-inactive`, the outer dot will animate only when the interaction is inactive.\n *\n * Default: `while-inactive`\n */\n pulseBehaviour?: 'always' | 'while-inactive';\n /**\n * Defaults to `size * 4`\n */\n outerSize?: number;\n pulseDurationMs?: number;\n};\n\nLineChartDot.displayName = 'LineChartDot';\n\nexport function LineChartDot({\n at,\n color: defaultColor = 'black',\n dotProps,\n hasOuterDot: defaultHasOuterDot = false,\n hasPulse = false,\n inactiveColor,\n outerDotProps,\n pulseBehaviour = 'while-inactive',\n pulseDurationMs = 800,\n showInactiveColor = true,\n size = 4,\n outerSize = size * 4,\n}: LineChartDotProps) {\n const { data, isActive } = useLineChart();\n const { path, pathWidth: width } = React.useContext(\n LineChartDimensionsContext\n );\n\n ////////////////////////////////////////////////////////////\n\n const { isInactive: _isInactive } = React.useContext(LineChartPathContext);\n const isInactive = showInactiveColor && _isInactive;\n const color = isInactive ? inactiveColor || defaultColor : defaultColor;\n const opacity = isInactive && !inactiveColor ? 0.5 : 1;\n const hasOuterDot = defaultHasOuterDot || hasPulse;\n\n ////////////////////////////////////////////////////////////\n\n const parsedPath = React.useMemo(() => parse(path), [path]);\n\n ////////////////////////////////////////////////////////////\n\n const pointWidth = React.useMemo(\n () => width / (data.length - 1),\n [data.length, width]\n );\n\n ////////////////////////////////////////////////////////////\n\n const x = useDerivedValue(() => withTiming(pointWidth * at));\n const y = useDerivedValue(() =>\n withTiming(getYForX(parsedPath!, x.value) || 0)\n );\n\n ////////////////////////////////////////////////////////////\n\n const animatedDotProps = useAnimatedProps(() => ({\n cx: x.value,\n cy: y.value,\n }));\n\n const animatedOuterDotProps = useAnimatedProps(() => {\n let defaultProps = {\n cx: x.value,\n cy: y.value,\n opacity: 0.1,\n r: outerSize,\n };\n\n if (!hasPulse) {\n return defaultProps;\n }\n\n if (isActive.value && pulseBehaviour === 'while-inactive') {\n return {\n ...defaultProps,\n r: 0,\n };\n }\n\n const easing = Easing.out(Easing.sin);\n const animatedOpacity = withRepeat(\n withSequence(\n withTiming(0.8),\n withTiming(0, {\n duration: pulseDurationMs,\n easing,\n })\n ),\n -1,\n false\n );\n const scale = withRepeat(\n withSequence(\n withTiming(0),\n withTiming(outerSize, {\n duration: pulseDurationMs,\n easing,\n })\n ),\n -1,\n false\n );\n\n if (pulseBehaviour === 'while-inactive') {\n return {\n ...defaultProps,\n opacity: isActive.value ? withTiming(0) : animatedOpacity,\n r: isActive.value ? withTiming(0) : scale,\n };\n }\n return {\n ...defaultProps,\n opacity: animatedOpacity,\n r: scale,\n };\n }, [outerSize]);\n\n ////////////////////////////////////////////////////////////\n\n return (\n <>\n <AnimatedCircle\n animatedProps={animatedDotProps}\n r={size}\n fill={color}\n opacity={opacity}\n {...dotProps}\n />\n {hasOuterDot && (\n <AnimatedCircle\n animatedProps={animatedOuterDotProps}\n fill={color}\n {...outerDotProps}\n />\n )}\n </>\n );\n}\n"]}
@@ -7,7 +7,7 @@ exports.LineChartGradient = LineChartGradient;
7
7
 
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
 
10
- var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
11
11
 
12
12
  var _reactNativeSvg = require("react-native-svg");
13
13
 
@@ -15,9 +15,7 @@ var _Chart = require("./Chart");
15
15
 
16
16
  var _ChartPath = require("./ChartPath");
17
17
 
18
- var _interpolatePath = _interopRequireDefault(require("./interpolatePath"));
19
-
20
- var _utils = require("../../utils");
18
+ var _useAnimatedPath = _interopRequireDefault(require("./useAnimatedPath"));
21
19
 
22
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
21
 
@@ -30,6 +28,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
30
28
  const AnimatedPath = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Path);
31
29
 
32
30
  let id = 0;
31
+ LineChartGradient.displayName = 'LineChartGradient';
33
32
 
34
33
  function LineChartGradient({
35
34
  color: overrideColor = undefined,
@@ -45,27 +44,11 @@ function LineChartGradient({
45
44
  } = React.useContext(_ChartPath.LineChartPathContext);
46
45
  const color = overrideColor || contextColor; ////////////////////////////////////////////////
47
46
 
48
- const transition = (0, _reactNativeReanimated.useSharedValue)(0);
49
- const previousPath = (0, _utils.usePrevious)(area);
50
- (0, _reactNativeReanimated.useAnimatedReaction)(() => {
51
- return area;
52
- }, (_, previous) => {
53
- if (previous) {
54
- transition.value = 0;
55
- transition.value = (0, _reactNativeReanimated.withTiming)(1);
56
- }
57
- }, [area]);
58
- const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
59
- let d = area || '';
60
-
61
- if (previousPath && isTransitionEnabled) {
62
- const pathInterpolator = (0, _interpolatePath.default)(previousPath, area, null);
63
- d = pathInterpolator(transition.value);
64
- }
65
-
66
- return {
67
- d
68
- };
47
+ const {
48
+ animatedProps
49
+ } = (0, _useAnimatedPath.default)({
50
+ enabled: isTransitionEnabled,
51
+ path: area
69
52
  }); ////////////////////////////////////////////////
70
53
 
71
54
  const localId = React.useRef(++id); ////////////////////////////////////////////////
@@ -1 +1 @@
1
- {"version":3,"sources":["Gradient.tsx"],"names":["AnimatedPath","Animated","createAnimatedComponent","Path","id","LineChartGradient","color","overrideColor","undefined","children","props","area","React","useContext","LineChartDimensionsContext","contextColor","isTransitionEnabled","LineChartPathContext","transition","previousPath","_","previous","value","animatedProps","d","pathInterpolator","localId","useRef","current"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,YAAY,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,CAAhB,CAvCyB,CAyCzB;;AAEA,sBACE,0CACGK,QAAQ,gBACP,oBAAC,oBAAD,qBACE,oBAAC,8BAAD;AACE,IAAA,EAAE,EAAG,GAAEiB,OAAO,CAACE,OAAQ,EADzB;AAEE,IAAA,EAAE,EAAC,GAFL;AAGE,IAAA,EAAE,EAAC,GAHL;AAIE,IAAA,EAAE,EAAC,GAJL;AAKE,IAAA,EAAE,EAAC;AALL,KAOGnB,QAPH,CADF,CADO,gBAaP,oBAAC,oBAAD,qBACE,oBAAC,8BAAD;AACE,IAAA,EAAE,EAAG,GAAEiB,OAAO,CAACE,OAAQ,EADzB;AAEE,IAAA,EAAE,EAAC,GAFL;AAGE,IAAA,EAAE,EAAC,GAHL;AAIE,IAAA,EAAE,EAAC,GAJL;AAKE,IAAA,EAAE,EAAC;AALL,kBAOE,oBAAC,oBAAD;AAAM,IAAA,MAAM,EAAC,KAAb;AAAmB,IAAA,SAAS,EAAEtB,KAA9B;AAAqC,IAAA,WAAW,EAAE;AAAlD,IAPF,eAQE,oBAAC,oBAAD;AAAM,IAAA,MAAM,EAAC,KAAb;AAAmB,IAAA,SAAS,EAAEA,KAA9B;AAAqC,IAAA,WAAW,EAAE;AAAlD,IARF,eASE,oBAAC,oBAAD;AAAM,IAAA,MAAM,EAAC,MAAb;AAAoB,IAAA,SAAS,EAAEA,KAA/B;AAAsC,IAAA,WAAW,EAAE;AAAnD,IATF,CADF,CAdJ,eA4BE,oBAAC,YAAD;AACE,IAAA,aAAa,EAAEiB,aADjB;AAEE,IAAA,IAAI,EAAG,QAAOG,OAAO,CAACE,OAAQ;AAFhC,KAGMlB,KAHN,EA5BF,CADF;AAoCD","sourcesContent":["import * as React from 'react';\nimport Animated, {\n useAnimatedProps,\n useAnimatedReaction,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { Defs, LinearGradient, Stop, Path, PathProps } from 'react-native-svg';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartPathContext } from './ChartPath';\nimport interpolatePath from './interpolatePath';\nimport { usePrevious } from '../../utils';\n\nconst AnimatedPath = Animated.createAnimatedComponent(Path);\n\nexport type LineChartGradientProps = Animated.AnimateProps<PathProps> & {\n color?: string;\n children?: React.ReactNode;\n};\n\nlet id = 0;\n\nexport function LineChartGradient({\n color: overrideColor = undefined,\n children,\n ...props\n}: LineChartGradientProps) {\n const { area } = React.useContext(LineChartDimensionsContext);\n const { color: contextColor, isTransitionEnabled } =\n React.useContext(LineChartPathContext);\n\n const color = overrideColor || contextColor;\n\n ////////////////////////////////////////////////\n\n const transition = useSharedValue(0);\n\n const previousPath = usePrevious(area);\n\n useAnimatedReaction(\n () => {\n return area;\n },\n (_, previous) => {\n if (previous) {\n transition.value = 0;\n transition.value = withTiming(1);\n }\n },\n [area]\n );\n\n const animatedProps = useAnimatedProps(() => {\n let d = area || '';\n if (previousPath && isTransitionEnabled) {\n const pathInterpolator = interpolatePath(previousPath, area, null);\n d = pathInterpolator(transition.value);\n }\n return {\n d,\n };\n });\n\n ////////////////////////////////////////////////\n\n const localId = React.useRef(++id);\n\n ////////////////////////////////////////////////\n\n return (\n <>\n {children ? (\n <Defs>\n <LinearGradient\n id={`${localId.current}`}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n >\n {children}\n </LinearGradient>\n </Defs>\n ) : (\n <Defs>\n <LinearGradient\n id={`${localId.current}`}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n >\n <Stop offset=\"20%\" stopColor={color} stopOpacity={0.15} />\n <Stop offset=\"40%\" stopColor={color} stopOpacity={0.05} />\n <Stop offset=\"100%\" stopColor={color} stopOpacity={0} />\n </LinearGradient>\n </Defs>\n )}\n <AnimatedPath\n animatedProps={animatedProps}\n fill={`url(#${localId.current})`}\n {...props}\n />\n </>\n );\n}\n"]}
1
+ {"version":3,"sources":["Gradient.tsx"],"names":["AnimatedPath","Animated","createAnimatedComponent","Path","id","LineChartGradient","displayName","color","overrideColor","undefined","children","props","area","React","useContext","LineChartDimensionsContext","contextColor","isTransitionEnabled","LineChartPathContext","animatedProps","enabled","path","localId","useRef","current"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,+BAASC,uBAAT,CAAiCC,oBAAjC,CAArB;;AAOA,IAAIC,EAAE,GAAG,CAAT;AAEAC,iBAAiB,CAACC,WAAlB,GAAgC,mBAAhC;;AAEO,SAASD,iBAAT,CAA2B;AAChCE,EAAAA,KAAK,EAAEC,aAAa,GAAGC,SADS;AAEhCC,EAAAA,QAFgC;AAGhC,KAAGC;AAH6B,CAA3B,EAIoB;AACzB,QAAM;AAAEC,IAAAA;AAAF,MAAWC,KAAK,CAACC,UAAN,CAAiBC,iCAAjB,CAAjB;AACA,QAAM;AAAER,IAAAA,KAAK,EAAES,YAAT;AAAuBC,IAAAA;AAAvB,MACJJ,KAAK,CAACC,UAAN,CAAiBI,+BAAjB,CADF;AAGA,QAAMX,KAAK,GAAGC,aAAa,IAAIQ,YAA/B,CALyB,CAOzB;;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAoB,8BAAgB;AACxCC,IAAAA,OAAO,EAAEH,mBAD+B;AAExCI,IAAAA,IAAI,EAAET;AAFkC,GAAhB,CAA1B,CATyB,CAczB;;AAEA,QAAMU,OAAO,GAAGT,KAAK,CAACU,MAAN,CAAa,EAAEnB,EAAf,CAAhB,CAhByB,CAkBzB;;AAEA,sBACE,0CACGM,QAAQ,gBACP,oBAAC,oBAAD,qBACE,oBAAC,8BAAD;AACE,IAAA,EAAE,EAAG,GAAEY,OAAO,CAACE,OAAQ,EADzB;AAEE,IAAA,EAAE,EAAC,GAFL;AAGE,IAAA,EAAE,EAAC,GAHL;AAIE,IAAA,EAAE,EAAC,GAJL;AAKE,IAAA,EAAE,EAAC;AALL,KAOGd,QAPH,CADF,CADO,gBAaP,oBAAC,oBAAD,qBACE,oBAAC,8BAAD;AACE,IAAA,EAAE,EAAG,GAAEY,OAAO,CAACE,OAAQ,EADzB;AAEE,IAAA,EAAE,EAAC,GAFL;AAGE,IAAA,EAAE,EAAC,GAHL;AAIE,IAAA,EAAE,EAAC,GAJL;AAKE,IAAA,EAAE,EAAC;AALL,kBAOE,oBAAC,oBAAD;AAAM,IAAA,MAAM,EAAC,KAAb;AAAmB,IAAA,SAAS,EAAEjB,KAA9B;AAAqC,IAAA,WAAW,EAAE;AAAlD,IAPF,eAQE,oBAAC,oBAAD;AAAM,IAAA,MAAM,EAAC,KAAb;AAAmB,IAAA,SAAS,EAAEA,KAA9B;AAAqC,IAAA,WAAW,EAAE;AAAlD,IARF,eASE,oBAAC,oBAAD;AAAM,IAAA,MAAM,EAAC,MAAb;AAAoB,IAAA,SAAS,EAAEA,KAA/B;AAAsC,IAAA,WAAW,EAAE;AAAnD,IATF,CADF,CAdJ,eA4BE,oBAAC,YAAD;AACE,IAAA,aAAa,EAAEY,aADjB;AAEE,IAAA,IAAI,EAAG,QAAOG,OAAO,CAACE,OAAQ;AAFhC,KAGMb,KAHN,EA5BF,CADF;AAoCD","sourcesContent":["import * as React from 'react';\nimport Animated from 'react-native-reanimated';\nimport { Defs, LinearGradient, Stop, Path, PathProps } from 'react-native-svg';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartPathContext } from './ChartPath';\nimport useAnimatedPath from './useAnimatedPath';\n\nconst AnimatedPath = Animated.createAnimatedComponent(Path);\n\nexport type LineChartGradientProps = Animated.AnimateProps<PathProps> & {\n color?: string;\n children?: React.ReactNode;\n};\n\nlet id = 0;\n\nLineChartGradient.displayName = 'LineChartGradient';\n\nexport function LineChartGradient({\n color: overrideColor = undefined,\n children,\n ...props\n}: LineChartGradientProps) {\n const { area } = React.useContext(LineChartDimensionsContext);\n const { color: contextColor, isTransitionEnabled } =\n React.useContext(LineChartPathContext);\n\n const color = overrideColor || contextColor;\n\n ////////////////////////////////////////////////\n\n const { animatedProps } = useAnimatedPath({\n enabled: isTransitionEnabled,\n path: area,\n });\n\n ////////////////////////////////////////////////\n\n const localId = React.useRef(++id);\n\n ////////////////////////////////////////////////\n\n return (\n <>\n {children ? (\n <Defs>\n <LinearGradient\n id={`${localId.current}`}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n >\n {children}\n </LinearGradient>\n </Defs>\n ) : (\n <Defs>\n <LinearGradient\n id={`${localId.current}`}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n >\n <Stop offset=\"20%\" stopColor={color} stopOpacity={0.15} />\n <Stop offset=\"40%\" stopColor={color} stopOpacity={0.05} />\n <Stop offset=\"100%\" stopColor={color} stopOpacity={0} />\n </LinearGradient>\n </Defs>\n )}\n <AnimatedPath\n animatedProps={animatedProps}\n fill={`url(#${localId.current})`}\n {...props}\n />\n </>\n );\n}\n"]}
@@ -3,47 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = flattenChildren;
7
6
  exports.LineChartGroup = LineChartGroup;
8
7
 
9
8
  var _react = _interopRequireWildcard(require("react"));
10
9
 
11
10
  var _reactNative = require("react-native");
12
11
 
12
+ var _reactKeyedFlattenChildren = _interopRequireDefault(require("react-keyed-flatten-children"));
13
+
13
14
  var _Chart = require("./Chart");
14
15
 
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
15
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
19
 
17
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
21
 
19
- /* Returns React children into an array, flattening fragments.
20
-
21
- Forked from https://github.com/grrowl/react-keyed-flatten-children/blob/master/index.ts
22
- */
23
- function flattenChildren(children, depth = 0, keys = []) {
24
- return _react.Children.toArray(children).reduce( // eslint-disable-next-line
25
- (acc, node, nodeIndex) => {
26
- if (node.type === _react.default.Fragment) {
27
- acc.push.apply(acc, flattenChildren(node.props.children, depth + 1, keys.concat(node.key || nodeIndex)));
28
- } else {
29
- if ( /*#__PURE__*/(0, _react.isValidElement)(node)) {
30
- acc.push( /*#__PURE__*/(0, _react.cloneElement)(node, {
31
- key: keys.concat(String(node.key)).join('.')
32
- }));
33
- } else if (typeof node === 'string' || typeof node === 'number') {
34
- acc.push(node);
35
- }
36
- }
37
-
38
- return acc;
39
- }, []);
40
- }
41
-
42
22
  function LineChartGroup({
43
23
  children,
44
24
  ...props
45
25
  }) {
46
- const flatChildren = flattenChildren(children);
26
+ const flatChildren = (0, _reactKeyedFlattenChildren.default)(children);
47
27
 
48
28
  const flatChildrenCount = _react.Children.count(flatChildren);
49
29
 
@@ -1 +1 @@
1
- {"version":3,"sources":["Group.tsx"],"names":["flattenChildren","children","depth","keys","Children","toArray","reduce","acc","node","nodeIndex","type","React","Fragment","push","apply","props","concat","key","String","join","LineChartGroup","flatChildren","flatChildrenCount","count","map","child","index","isLast","LineChart","absolute"],"mappings":";;;;;;;;AAAA;;AAaA;;AACA;;;;;;AAZA;AACA;AACA;AACA;AAWe,SAASA,eAAT,CACbC,QADa,EAEbC,KAAa,GAAG,CAFH,EAGbC,IAAyB,GAA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G,CAA7C;;AACA,QAAI,CAACK,MAAD,IAAWF,KAAK,CAACf,IAAN,KAAekB,gBAA9B,EAAyC;AACvC,0BAAO,yBAAaH,KAAb,EAAoB;AACzBI,QAAAA,QAAQ,EAAE;AADe,OAApB,CAAP;AAGD;;AACD,WAAOJ,KAAP;AACD,GARA,CAFH,CADF;AAcD","sourcesContent":["import React from 'react';\n\n/* Returns React children into an array, flattening fragments.\n\nForked from https://github.com/grrowl/react-keyed-flatten-children/blob/master/index.ts\n*/\nimport {\n ReactNode,\n ReactChild,\n Children,\n isValidElement,\n cloneElement,\n} from 'react';\nimport { ViewProps, View } from 'react-native';\nimport { LineChart } from './Chart';\n\nexport default function flattenChildren(\n children: ReactNode,\n depth: number = 0,\n keys: (string | number)[] = []\n): ReactChild[] {\n return Children.toArray(children).reduce(\n // eslint-disable-next-line\n (acc: ReactChild[], node: any, nodeIndex) => {\n if (node.type === React.Fragment) {\n acc.push.apply(\n acc,\n flattenChildren(\n node.props.children,\n depth + 1,\n keys.concat(node.key || nodeIndex)\n )\n );\n } else {\n if (isValidElement(node)) {\n acc.push(\n cloneElement(node, {\n key: keys.concat(String(node.key)).join('.'),\n })\n );\n } else if (typeof node === 'string' || typeof node === 'number') {\n acc.push(node);\n }\n }\n return acc;\n },\n []\n );\n}\n\ntype Props = {\n children: ReactNode;\n} & ViewProps;\n\nexport function LineChartGroup({ children, ...props }: Props) {\n const flatChildren = flattenChildren(children);\n const flatChildrenCount = Children.count(flatChildren);\n return (\n <View {...props}>\n {/* eslint-disable-next-line */}\n {Children.map(flatChildren, (child: any, index) => {\n const isLast = index === flatChildrenCount - 1;\n if (!isLast && child.type === LineChart) {\n return cloneElement(child, {\n absolute: true,\n });\n }\n return child;\n })}\n </View>\n );\n}\n"]}
1
+ {"version":3,"sources":["Group.tsx"],"names":["LineChartGroup","children","props","flatChildren","flatChildrenCount","Children","count","map","child","index","isLast","type","LineChart","absolute"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;;;;;;;AAMO,SAASA,cAAT,CAAwB;AAAEC,EAAAA,QAAF;AAAY,KAAGC;AAAf,CAAxB,EAAuD;AAC5D,QAAMC,YAAY,GAAG,wCAAgBF,QAAhB,CAArB;;AACA,QAAMG,iBAAiB,GAAGC,gBAASC,KAAT,CAAeH,YAAf,CAA1B;;AACA,sBACE,6BAAC,iBAAD,EAAUD,KAAV,EAEGG,gBAASE,GAAT,CAAaJ,YAAb,EAA2B,CAACK,KAAD,EAAaC,KAAb,KAAuB;AACjD,UAAMC,MAAM,GAAGD,KAAK,KAAKL,iBAAiB,GAAG,CAA7C;;AACA,QAAI,CAACM,MAAD,IAAWF,KAAK,CAACG,IAAN,KAAeC,gBAA9B,EAAyC;AACvC,0BAAO,yBAAaJ,KAAb,EAAoB;AACzBK,QAAAA,QAAQ,EAAE;AADe,OAApB,CAAP;AAGD;;AACD,WAAOL,KAAP;AACD,GARA,CAFH,CADF;AAcD","sourcesContent":["import React from 'react';\nimport { ReactNode, Children, cloneElement } from 'react';\nimport { ViewProps, View } from 'react-native';\nimport flattenChildren from 'react-keyed-flatten-children';\n\nimport { LineChart } from './Chart';\n\ntype Props = {\n children: ReactNode;\n} & ViewProps;\n\nexport function LineChartGroup({ children, ...props }: Props) {\n const flatChildren = flattenChildren(children);\n const flatChildrenCount = Children.count(flatChildren);\n return (\n <View {...props}>\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n {Children.map(flatChildren, (child: any, index) => {\n const isLast = index === flatChildrenCount - 1;\n if (!isLast && child.type === LineChart) {\n return cloneElement(child, {\n absolute: true,\n });\n }\n return child;\n })}\n </View>\n );\n}\n"]}