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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["usePrevious.ts"],"names":["React","usePrevious","value","ref","useRef","useEffect","current"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,OAAO,SAASC,WAAT,CAAwBC,KAAxB,EAAkC;AACvC;AACA;AACA,QAAMC,GAAG,GAAGH,KAAK,CAACI,MAAN,EAAZ,CAHuC,CAIvC;;AACAJ,EAAAA,KAAK,CAACK,SAAN,CAAgB,MAAM;AACpBF,IAAAA,GAAG,CAACG,OAAJ,GAAcJ,KAAd;AACD,GAFD,EAEG,CAACA,KAAD,CAFH,EALuC,CAO1B;AACb;;AACA,SAAOC,GAAG,CAACG,OAAX;AACD","sourcesContent":["import * as React from 'react';\n\nexport function usePrevious<T>(value: T) {\n // The ref object is a generic container whose current property is mutable ...\n // ... and can hold any value, similar to an instance property on a class\n const ref = React.useRef<T>();\n // Store current value in ref\n React.useEffect(() => {\n ref.current = value;\n }, [value]); // Only re-run if value changes\n // Return previous value (happens before update in useEffect above)\n return ref.current;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { TCandle } from '../types';
2
+ export declare function getDomain(rows: TCandle[]): [min: number, max: number];
@@ -0,0 +1,6 @@
1
+ import type { TDomain } from '../types';
2
+ export declare function getHeight({ value, domain, maxHeight, }: {
3
+ value: number;
4
+ domain: TDomain;
5
+ maxHeight: number;
6
+ }): number;
@@ -0,0 +1,6 @@
1
+ import type { TDomain } from '../types';
2
+ export declare function getPrice({ y, domain, maxHeight, }: {
3
+ y: number;
4
+ domain: TDomain;
5
+ maxHeight: number;
6
+ }): number;
@@ -0,0 +1,6 @@
1
+ import type { TDomain } from '../types';
2
+ export declare function getY({ value, domain, maxHeight, }: {
3
+ value: number;
4
+ domain: TDomain;
5
+ maxHeight: number;
6
+ }): number;
@@ -0,0 +1,4 @@
1
+ export * from './getDomain';
2
+ export * from './getHeight';
3
+ export * from './getPrice';
4
+ export * from './getY';
@@ -5,6 +5,7 @@ export declare const LineChartDimensionsContext: React.Context<{
5
5
  height: number;
6
6
  path: string;
7
7
  area: string;
8
+ shape: any;
8
9
  gutter: number;
9
10
  pathWidth: number;
10
11
  }>;
@@ -13,7 +14,7 @@ declare type LineChartProps = ViewProps & {
13
14
  yGutter?: number;
14
15
  width?: number;
15
16
  height?: number;
16
- shape?: string;
17
+ shape?: unknown;
17
18
  /**
18
19
  * If your `LineChart.Provider` uses a dictionary with multiple IDs for multiple paths, then this field is required.
19
20
  */
@@ -21,4 +22,7 @@ declare type LineChartProps = ViewProps & {
21
22
  absolute?: boolean;
22
23
  };
23
24
  export declare function LineChart({ children, yGutter, width, height, shape, id, absolute, ...props }: LineChartProps): JSX.Element;
25
+ export declare namespace LineChart {
26
+ var displayName: string;
27
+ }
24
28
  export {};
@@ -3,6 +3,7 @@ import Animated from 'react-native-reanimated';
3
3
  import { LineChartPathProps } from './Path';
4
4
  export declare const LineChartPathContext: React.Context<{
5
5
  color: string;
6
+ isInactive: boolean;
6
7
  isTransitionEnabled: boolean;
7
8
  }>;
8
9
  declare type LineChartPathWrapperProps = {
@@ -10,9 +11,17 @@ declare type LineChartPathWrapperProps = {
10
11
  animationProps?: Partial<Animated.WithTimingConfig>;
11
12
  children?: React.ReactNode;
12
13
  color?: string;
14
+ inactiveColor?: string;
13
15
  width?: number;
16
+ widthOffset?: number;
14
17
  pathProps?: Partial<LineChartPathProps>;
15
18
  showInactivePath?: boolean;
19
+ animateOnMount?: 'foreground';
20
+ mountAnimationDuration?: number;
21
+ mountAnimationProps?: Partial<Animated.WithTimingConfig>;
16
22
  };
17
- export declare function LineChartPathWrapper({ animationDuration, animationProps, children, color, width: strokeWidth, pathProps, showInactivePath, }: LineChartPathWrapperProps): JSX.Element;
23
+ export declare function LineChartPathWrapper({ animationDuration, animationProps, children, color, inactiveColor, width: strokeWidth, widthOffset, pathProps, showInactivePath, animateOnMount, mountAnimationDuration, mountAnimationProps, }: LineChartPathWrapperProps): JSX.Element;
24
+ export declare namespace LineChartPathWrapper {
25
+ var displayName: string;
26
+ }
18
27
  export {};
@@ -10,4 +10,7 @@ declare type LineChartProviderProps = {
10
10
  xLength?: number;
11
11
  };
12
12
  export declare function LineChartProvider({ children, data, yRange, onCurrentIndexChange, xLength, }: LineChartProviderProps): JSX.Element;
13
+ export declare namespace LineChartProvider {
14
+ var displayName: string;
15
+ }
13
16
  export {};
@@ -8,3 +8,6 @@ export declare const CursorContext: React.Context<{
8
8
  type: string;
9
9
  }>;
10
10
  export declare function LineChartCursor({ children, type, ...props }: LineChartCursorProps): JSX.Element;
11
+ export declare namespace LineChartCursor {
12
+ var displayName: string;
13
+ }
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { ViewProps } from 'react-native';
3
3
  import Animated from 'react-native-reanimated';
4
4
  import { LineChartCursorProps } from './Cursor';
5
- declare type LineChartCursorCrosshairProps = Omit<LineChartCursorProps, 'type'> & {
5
+ declare type LineChartCursorCrosshairProps = Omit<LineChartCursorProps, 'children' | 'type'> & {
6
6
  children?: React.ReactNode;
7
7
  color?: string;
8
8
  size?: number;
@@ -12,4 +12,7 @@ declare type LineChartCursorCrosshairProps = Omit<LineChartCursorProps, 'type'>
12
12
  crosshairOuterProps?: ViewProps;
13
13
  };
14
14
  export declare function LineChartCursorCrosshair({ children, color, size, outerSize, crosshairWrapperProps, crosshairProps, crosshairOuterProps, ...props }: LineChartCursorCrosshairProps): JSX.Element;
15
+ export declare namespace LineChartCursorCrosshair {
16
+ var displayName: string;
17
+ }
15
18
  export {};
@@ -5,5 +5,8 @@ declare type LineChartCursorLineProps = {
5
5
  color?: string;
6
6
  lineProps?: Partial<LineProps>;
7
7
  };
8
- export declare const LineChartCursorLine: ({ children, color, lineProps, }: LineChartCursorLineProps) => JSX.Element;
8
+ export declare function LineChartCursorLine({ children, color, lineProps, }: LineChartCursorLineProps): JSX.Element;
9
+ export declare namespace LineChartCursorLine {
10
+ var displayName: string;
11
+ }
9
12
  export {};
@@ -10,4 +10,7 @@ declare type LineChartDatetimeProps = {
10
10
  style?: Animated.AnimateProps<RNTextProps>['style'];
11
11
  };
12
12
  export declare function LineChartDatetimeText({ locale, options, format, variant, style, }: LineChartDatetimeProps): JSX.Element;
13
+ export declare namespace LineChartDatetimeText {
14
+ var displayName: string;
15
+ }
13
16
  export {};
@@ -1,28 +1,31 @@
1
1
  /// <reference types="react" />
2
- import type { ViewProps } from 'react-native';
2
+ import Animated from 'react-native-reanimated';
3
+ import { CircleProps } from 'react-native-svg';
3
4
  export declare type LineChartDotProps = {
4
- dotProps?: ViewProps;
5
- outerDotProps?: ViewProps;
5
+ dotProps?: Animated.AnimateProps<CircleProps>;
6
+ outerDotProps?: Animated.AnimateProps<CircleProps>;
6
7
  color?: string;
8
+ inactiveColor?: string;
9
+ showInactiveColor?: boolean;
7
10
  at: number;
8
11
  size?: number;
12
+ hasPulse?: boolean;
13
+ hasOuterDot?: boolean;
9
14
  /**
10
15
  * If `always`, the outer dot will still animate when interaction is active.
11
16
  *
12
- * If `never`, the outer dot will never animate.
13
- *
14
17
  * If `while-inactive`, the outer dot will animate only when the interaction is inactive.
15
18
  *
16
19
  * Default: `while-inactive`
17
20
  */
18
- pulsesOuter?: 'always' | 'while-inactive' | 'never';
21
+ pulseBehaviour?: 'always' | 'while-inactive';
19
22
  /**
20
23
  * Defaults to `size * 4`
21
24
  */
22
25
  outerSize?: number;
23
26
  pulseDurationMs?: number;
24
27
  };
25
- export declare function LineChartDot({ color, at, size, pulsesOuter, outerSize, dotProps, outerDotProps, }: LineChartDotProps): JSX.Element;
28
+ export declare function LineChartDot({ at, color: defaultColor, dotProps, hasOuterDot: defaultHasOuterDot, hasPulse, inactiveColor, outerDotProps, pulseBehaviour, pulseDurationMs, showInactiveColor, size, outerSize, }: LineChartDotProps): JSX.Element;
26
29
  export declare namespace LineChartDot {
27
30
  var displayName: string;
28
31
  }
@@ -6,3 +6,6 @@ export declare type LineChartGradientProps = Animated.AnimateProps<PathProps> &
6
6
  children?: React.ReactNode;
7
7
  };
8
8
  export declare function LineChartGradient({ color: overrideColor, children, ...props }: LineChartGradientProps): JSX.Element;
9
+ export declare namespace LineChartGradient {
10
+ var displayName: string;
11
+ }
@@ -1,6 +1,5 @@
1
- import { ReactNode, ReactChild } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { ViewProps } from 'react-native';
3
- export default function flattenChildren(children: ReactNode, depth?: number, keys?: (string | number)[]): ReactChild[];
4
3
  declare type Props = {
5
4
  children: ReactNode;
6
5
  } & ViewProps;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import Animated from 'react-native-reanimated';
3
+ import { PathProps } from 'react-native-svg';
4
+ export declare type LineChartColorProps = Animated.AnimateProps<PathProps> & {
5
+ color?: string;
6
+ from: number;
7
+ to: number;
8
+ showInactiveColor?: boolean;
9
+ inactiveColor?: string;
10
+ width?: number;
11
+ };
12
+ export declare function LineChartHighlight({ color, inactiveColor, showInactiveColor, from, to, width: strokeWidth, ...props }: LineChartColorProps): JSX.Element;
13
+ export declare namespace LineChartHighlight {
14
+ var displayName: string;
15
+ }
@@ -29,5 +29,8 @@ declare type HorizontalLineProps = {
29
29
  value: number;
30
30
  } | number;
31
31
  };
32
- export declare const LineChartHorizontalLine: ({ color, lineProps, at, offsetY, }: HorizontalLineProps) => JSX.Element;
32
+ export declare function LineChartHorizontalLine({ color, lineProps, at, offsetY, }: HorizontalLineProps): JSX.Element;
33
+ export declare namespace LineChartHorizontalLine {
34
+ var displayName: string;
35
+ }
33
36
  export {};
@@ -3,6 +3,7 @@ import Animated from 'react-native-reanimated';
3
3
  import { PathProps } from 'react-native-svg';
4
4
  export declare type LineChartPathProps = Animated.AnimateProps<PathProps> & {
5
5
  color?: string;
6
+ inactiveColor?: string;
6
7
  width?: number;
7
8
  isInactive?: boolean;
8
9
  /**
@@ -22,4 +23,7 @@ export declare type LineChartPathProps = Animated.AnimateProps<PathProps> & {
22
23
  */
23
24
  isTransitionEnabled?: boolean;
24
25
  };
25
- export declare function LineChartPath({ color, width: strokeWidth, isInactive, isTransitionEnabled, ...props }: LineChartPathProps): JSX.Element;
26
+ export declare function LineChartPath({ color, inactiveColor, width: strokeWidth, ...props }: LineChartPathProps): JSX.Element;
27
+ export declare namespace LineChartPath {
28
+ var displayName: string;
29
+ }
@@ -9,3 +9,6 @@ export declare type LineChartPriceTextProps = {
9
9
  style?: Animated.AnimateProps<RNTextProps>['style'];
10
10
  };
11
11
  export declare function LineChartPriceText({ format, precision, variant, style, }: LineChartPriceTextProps): JSX.Element;
12
+ export declare namespace LineChartPriceText {
13
+ var displayName: string;
14
+ }
@@ -12,4 +12,7 @@ declare type LineChartTooltipProps = Animated.AnimateProps<ViewProps> & {
12
12
  textStyle?: LineChartPriceTextProps['style'];
13
13
  };
14
14
  export declare function LineChartTooltip({ children, xGutter, yGutter, cursorGutter, position, textProps, textStyle, ...props }: LineChartTooltipProps): JSX.Element;
15
+ export declare namespace LineChartTooltip {
16
+ var displayName: string;
17
+ }
15
18
  export {};
@@ -1,25 +1,29 @@
1
- /// <reference types="react" />
2
- import { LineChartGradient } from './Gradient';
3
1
  import { LineChart as _LineChart } from './Chart';
4
2
  import { LineChartPathWrapper } from './ChartPath';
3
+ import { LineChartHighlight } from './Highlight';
5
4
  import { LineChartProvider } from './Context';
6
5
  import { LineChartCursor } from './Cursor';
7
6
  import { LineChartCursorCrosshair } from './CursorCrosshair';
7
+ import { LineChartCursorLine } from './CursorLine';
8
+ import { LineChartDot } from './Dot';
9
+ import { LineChartGradient } from './Gradient';
10
+ import { LineChartGroup } from './Group';
11
+ import { LineChartHorizontalLine } from './HorizontalLine';
8
12
  import { LineChartTooltip } from './Tooltip';
9
13
  import { LineChartPriceText } from './PriceText';
10
14
  import { LineChartDatetimeText } from './DatetimeText';
11
15
  import { useLineChartDatetime } from './useDatetime';
12
16
  import { useLineChartPrice } from './usePrice';
13
17
  import { useLineChart } from './useLineChart';
14
- import { LineChartGroup } from './Group';
15
- import { LineChartDot } from './Dot';
16
- export * from './Gradient';
17
18
  export * from './Chart';
18
19
  export * from './ChartPath';
20
+ export * from './Highlight';
19
21
  export * from './Context';
20
22
  export * from './Cursor';
21
23
  export * from './CursorCrosshair';
22
24
  export * from './CursorLine';
25
+ export * from './Dot';
26
+ export * from './Gradient';
23
27
  export * from './Tooltip';
24
28
  export * from './DatetimeText';
25
29
  export * from './Path';
@@ -29,28 +33,16 @@ export * from './useLineChart';
29
33
  export * from './usePrice';
30
34
  export * from './types';
31
35
  export declare const LineChart: typeof _LineChart & {
32
- Gradient: typeof LineChartGradient;
33
36
  Chart: typeof _LineChart;
37
+ Dot: typeof LineChartDot;
34
38
  Path: typeof LineChartPathWrapper;
35
39
  Cursor: typeof LineChartCursor;
36
40
  CursorCrosshair: typeof LineChartCursorCrosshair;
37
- CursorLine: ({ children, color, lineProps, }: {
38
- children?: import("react").ReactNode;
39
- color?: string | undefined;
40
- lineProps?: Partial<import("react-native-svg").LineProps> | undefined;
41
- }) => JSX.Element;
42
- HorizontalLine: ({ color, lineProps, at, offsetY, }: {
43
- color?: string | undefined;
44
- lineProps?: Partial<import("react-native-svg").LineProps> | undefined;
45
- offsetY?: number | undefined;
46
- at?: number | {
47
- index: number;
48
- value?: undefined;
49
- } | {
50
- index?: undefined;
51
- value: number;
52
- } | undefined;
53
- }) => JSX.Element;
41
+ CursorLine: typeof LineChartCursorLine;
42
+ Gradient: typeof LineChartGradient;
43
+ Group: typeof LineChartGroup;
44
+ Highlight: typeof LineChartHighlight;
45
+ HorizontalLine: typeof LineChartHorizontalLine;
54
46
  Tooltip: typeof LineChartTooltip;
55
47
  Provider: typeof LineChartProvider;
56
48
  PriceText: typeof LineChartPriceText;
@@ -58,6 +50,4 @@ export declare const LineChart: typeof _LineChart & {
58
50
  useDatetime: typeof useLineChartDatetime;
59
51
  usePrice: typeof useLineChartPrice;
60
52
  useChart: typeof useLineChart;
61
- Group: typeof LineChartGroup;
62
- Dot: typeof LineChartDot;
63
53
  };
@@ -0,0 +1,8 @@
1
+ export default function useAnimatedPath({ enabled, path, }: {
2
+ enabled?: boolean;
3
+ path: string;
4
+ }): {
5
+ animatedProps: Partial<{
6
+ d: string;
7
+ }>;
8
+ };
@@ -0,0 +1,9 @@
1
+ import type { TLineChartData, YDomain } from '../types';
2
+ export declare function getArea({ data, width, height, gutter, shape: _shape, yDomain, }: {
3
+ data: TLineChartData;
4
+ width: number;
5
+ height: number;
6
+ gutter: number;
7
+ shape?: unknown;
8
+ yDomain: YDomain;
9
+ }): string;
@@ -0,0 +1,2 @@
1
+ import type { TLineChartPoint } from '../types';
2
+ export declare function getDomain(rows: TLineChartPoint[]): [number, number];
@@ -0,0 +1,11 @@
1
+ import type { TLineChartData, YDomain } from '../types';
2
+ export declare function getPath({ data, from, to, width, height, gutter, shape: _shape, yDomain, }: {
3
+ data: TLineChartData;
4
+ from?: number;
5
+ to?: number;
6
+ width: number;
7
+ height: number;
8
+ gutter: number;
9
+ shape?: unknown;
10
+ yDomain: YDomain;
11
+ }): string;
@@ -0,0 +1,5 @@
1
+ export * from './getArea';
2
+ export * from './getDomain';
3
+ export * from './getPath';
4
+ export * from './interpolatePath';
5
+ export * from './lineChartDataPropToArray';
@@ -47,4 +47,4 @@ export declare function interpolatePathCommands(aCommandsInput: any, bCommandsIn
47
47
  * end command object and returns true if the segment should be excluded from splitting.
48
48
  * @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string.
49
49
  */
50
- export default function interpolatePath(a: any, b: any, excludeSegment: any): (t: any) => any;
50
+ export declare function interpolatePath(a: any, b: any, excludeSegment: any): (t: any) => any;
@@ -0,0 +1,2 @@
1
+ import type { TLineChartData, TLineChartDataProp } from '../types';
2
+ export declare function lineChartDataPropToArray(dataProp: TLineChartDataProp): TLineChartData;
@@ -1,4 +1,4 @@
1
1
  export * from './charts/candle';
2
2
  export * from './charts/line';
3
- export * from './utils';
4
3
  export * from './components/AnimatedText';
4
+ export * from './utils';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @worklet
3
+ */
4
+ export declare function formatDatetime({ value, locale, options, }: {
5
+ value: number;
6
+ locale?: string;
7
+ options?: Intl.DateTimeFormatOptions;
8
+ }): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @worklet
3
+ */
4
+ export declare function formatPrice({ value: _value, defaultPrice: _defaultPrice, precision, }: {
5
+ value: string;
6
+ defaultPrice?: string;
7
+ precision?: number;
8
+ }): string;
@@ -0,0 +1,3 @@
1
+ export * from './formatDatetime';
2
+ export * from './formatPrice';
3
+ export * from './usePrevious';
@@ -0,0 +1 @@
1
+ export declare function usePrevious<T>(value: T): T | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wagmi-charts",
3
- "version": "1.8.0",
3
+ "version": "2.0.0",
4
4
  "description": "A sweet candlestick chart for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -39,6 +39,7 @@
39
39
  "d3-interpolate-path": "^2.2.3",
40
40
  "d3-scale": "^2",
41
41
  "d3-shape": "^3.0.1",
42
+ "react-keyed-flatten-children": "^1.3.0",
42
43
  "react-native-redash": "^16.1.1",
43
44
  "react-native-svg": "^12.1.1"
44
45
  },
@@ -92,7 +93,8 @@
92
93
  "useTabs": false
93
94
  }
94
95
  ],
95
- "@typescript-eslint/no-explicit-any": "error"
96
+ "@typescript-eslint/no-explicit-any": "error",
97
+ "no-shadow": "off"
96
98
  }
97
99
  },
98
100
  "eslintIgnore": [
@@ -0,0 +1,9 @@
1
+ import type { TCandle } from '../types';
2
+
3
+ export function getDomain(rows: TCandle[]): [min: number, max: number] {
4
+ 'worklet';
5
+ const values = rows.map(({ high, low }) => [high, low]).flat();
6
+ const min = Math.min(...values);
7
+ const max = Math.max(...values);
8
+ return [min - (max - min) * 0.025, max + (max - min) * 0.025];
9
+ }
@@ -0,0 +1,21 @@
1
+ import { interpolate, Extrapolate } from 'react-native-reanimated';
2
+
3
+ import type { TDomain } from '../types';
4
+
5
+ export function getHeight({
6
+ value,
7
+ domain,
8
+ maxHeight,
9
+ }: {
10
+ value: number;
11
+ domain: TDomain;
12
+ maxHeight: number;
13
+ }) {
14
+ 'worklet';
15
+ return interpolate(
16
+ value,
17
+ [0, Math.max(...domain) - Math.min(...domain)],
18
+ [0, maxHeight],
19
+ Extrapolate.CLAMP
20
+ );
21
+ }
@@ -0,0 +1,17 @@
1
+ import { interpolate, Extrapolate } from 'react-native-reanimated';
2
+
3
+ import type { TDomain } from '../types';
4
+
5
+ export function getPrice({
6
+ y,
7
+ domain,
8
+ maxHeight,
9
+ }: {
10
+ y: number;
11
+ domain: TDomain;
12
+ maxHeight: number;
13
+ }) {
14
+ 'worklet';
15
+ if (y === -1) return -1;
16
+ return interpolate(y, [0, maxHeight], domain.reverse(), Extrapolate.CLAMP);
17
+ }
@@ -0,0 +1,16 @@
1
+ import { interpolate, Extrapolate } from 'react-native-reanimated';
2
+
3
+ import type { TDomain } from '../types';
4
+
5
+ export function getY({
6
+ value,
7
+ domain,
8
+ maxHeight,
9
+ }: {
10
+ value: number;
11
+ domain: TDomain;
12
+ maxHeight: number;
13
+ }) {
14
+ 'worklet';
15
+ return interpolate(value, domain, [maxHeight, 0], Extrapolate.CLAMP);
16
+ }
@@ -0,0 +1,4 @@
1
+ export * from './getDomain';
2
+ export * from './getHeight';
3
+ export * from './getPrice';
4
+ export * from './getY';
@@ -1,4 +1,6 @@
1
1
  import * as React from 'react';
2
+ // @ts-ignore
3
+ import * as d3Shape from 'd3-shape';
2
4
  import { Dimensions, StyleSheet, View, ViewProps } from 'react-native';
3
5
  import { LineChartContext } from './Context';
4
6
  import { LineChartIdProvider, useLineChartData } from './Data';
@@ -10,6 +12,7 @@ export const LineChartDimensionsContext = React.createContext({
10
12
  height: 0,
11
13
  path: '',
12
14
  area: '',
15
+ shape: d3Shape.curveBumpX,
13
16
  gutter: 0,
14
17
  pathWidth: 0,
15
18
  });
@@ -19,7 +22,7 @@ type LineChartProps = ViewProps & {
19
22
  yGutter?: number;
20
23
  width?: number;
21
24
  height?: number;
22
- shape?: string;
25
+ shape?: unknown;
23
26
  /**
24
27
  * If your `LineChart.Provider` uses a dictionary with multiple IDs for multiple paths, then this field is required.
25
28
  */
@@ -29,12 +32,14 @@ type LineChartProps = ViewProps & {
29
32
 
30
33
  const { width: screenWidth } = Dimensions.get('window');
31
34
 
35
+ LineChart.displayName = 'LineChart';
36
+
32
37
  export function LineChart({
33
38
  children,
34
39
  yGutter = 16,
35
40
  width = screenWidth,
36
41
  height = screenWidth,
37
- shape,
42
+ shape = d3Shape.curveBumpX,
38
43
  id,
39
44
  absolute,
40
45
  ...props
@@ -88,8 +93,9 @@ export function LineChart({
88
93
  width,
89
94
  height,
90
95
  pathWidth,
96
+ shape,
91
97
  }),
92
- [area, height, path, width, yGutter, pathWidth]
98
+ [yGutter, area, path, width, height, pathWidth, shape]
93
99
  );
94
100
 
95
101
  return (