@coinbase/cds-mobile-visualization 3.4.0-beta.4 → 3.4.0-beta.6

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 (179) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dts/chart/CartesianChart.d.ts +57 -33
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/ChartContextBridge.d.ts +28 -0
  5. package/dts/chart/ChartContextBridge.d.ts.map +1 -0
  6. package/dts/chart/Path.d.ts +77 -34
  7. package/dts/chart/Path.d.ts.map +1 -1
  8. package/dts/chart/PeriodSelector.d.ts +1 -1
  9. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  10. package/dts/chart/area/Area.d.ts +42 -27
  11. package/dts/chart/area/Area.d.ts.map +1 -1
  12. package/dts/chart/area/AreaChart.d.ts +51 -10
  13. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  14. package/dts/chart/area/DottedArea.d.ts +21 -2
  15. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  16. package/dts/chart/area/GradientArea.d.ts +19 -13
  17. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  18. package/dts/chart/area/SolidArea.d.ts +17 -2
  19. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  20. package/dts/chart/axis/Axis.d.ts +68 -78
  21. package/dts/chart/axis/Axis.d.ts.map +1 -1
  22. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  23. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  24. package/dts/chart/axis/XAxis.d.ts +1 -1
  25. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  26. package/dts/chart/axis/YAxis.d.ts +2 -2
  27. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  28. package/dts/chart/axis/index.d.ts +1 -0
  29. package/dts/chart/axis/index.d.ts.map +1 -1
  30. package/dts/chart/bar/Bar.d.ts +16 -13
  31. package/dts/chart/bar/Bar.d.ts.map +1 -1
  32. package/dts/chart/bar/BarChart.d.ts +36 -20
  33. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  34. package/dts/chart/bar/BarPlot.d.ts +2 -1
  35. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  36. package/dts/chart/bar/BarStack.d.ts +39 -48
  37. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  38. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  39. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  40. package/dts/chart/bar/DefaultBar.d.ts +1 -1
  41. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  42. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  43. package/dts/chart/gradient/Gradient.d.ts +25 -0
  44. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  45. package/dts/chart/gradient/index.d.ts +2 -0
  46. package/dts/chart/gradient/index.d.ts.map +1 -0
  47. package/dts/chart/index.d.ts +3 -1
  48. package/dts/chart/index.d.ts.map +1 -1
  49. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  50. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  51. package/dts/chart/line/DottedLine.d.ts +13 -5
  52. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  53. package/dts/chart/line/Line.d.ts +62 -25
  54. package/dts/chart/line/Line.d.ts.map +1 -1
  55. package/dts/chart/line/LineChart.d.ts +43 -9
  56. package/dts/chart/line/LineChart.d.ts.map +1 -1
  57. package/dts/chart/line/ReferenceLine.d.ts +65 -22
  58. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  59. package/dts/chart/line/SolidLine.d.ts +8 -5
  60. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  61. package/dts/chart/line/index.d.ts +1 -1
  62. package/dts/chart/line/index.d.ts.map +1 -1
  63. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  64. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  65. package/dts/chart/point/Point.d.ts +120 -0
  66. package/dts/chart/point/Point.d.ts.map +1 -0
  67. package/dts/chart/point/index.d.ts +3 -0
  68. package/dts/chart/point/index.d.ts.map +1 -0
  69. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
  70. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  71. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  72. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  73. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
  74. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  75. package/dts/chart/scrubber/Scrubber.d.ts +168 -41
  76. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  77. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
  78. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  79. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
  80. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  81. package/dts/chart/scrubber/ScrubberProvider.d.ts +6 -3
  82. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
  83. package/dts/chart/scrubber/index.d.ts +3 -0
  84. package/dts/chart/scrubber/index.d.ts.map +1 -1
  85. package/dts/chart/text/ChartText.d.ts +151 -77
  86. package/dts/chart/text/ChartText.d.ts.map +1 -1
  87. package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
  88. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  89. package/dts/chart/text/index.d.ts +1 -1
  90. package/dts/chart/text/index.d.ts.map +1 -1
  91. package/dts/chart/utils/chart.d.ts +34 -7
  92. package/dts/chart/utils/chart.d.ts.map +1 -1
  93. package/dts/chart/utils/context.d.ts +28 -7
  94. package/dts/chart/utils/context.d.ts.map +1 -1
  95. package/dts/chart/utils/gradient.d.ts +117 -0
  96. package/dts/chart/utils/gradient.d.ts.map +1 -0
  97. package/dts/chart/utils/index.d.ts +3 -0
  98. package/dts/chart/utils/index.d.ts.map +1 -1
  99. package/dts/chart/utils/path.d.ts +53 -0
  100. package/dts/chart/utils/path.d.ts.map +1 -1
  101. package/dts/chart/utils/point.d.ts +60 -1
  102. package/dts/chart/utils/point.d.ts.map +1 -1
  103. package/dts/chart/utils/scale.d.ts +91 -0
  104. package/dts/chart/utils/scale.d.ts.map +1 -1
  105. package/dts/chart/utils/scrubber.d.ts +39 -0
  106. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  107. package/dts/chart/utils/transition.d.ts +140 -0
  108. package/dts/chart/utils/transition.d.ts.map +1 -0
  109. package/esm/chart/CartesianChart.js +164 -70
  110. package/esm/chart/ChartContextBridge.js +148 -0
  111. package/esm/chart/Path.js +196 -113
  112. package/esm/chart/PeriodSelector.js +1 -1
  113. package/esm/chart/__stories__/CartesianChart.stories.js +371 -129
  114. package/esm/chart/__stories__/Chart.stories.js +2 -4
  115. package/esm/chart/area/Area.js +25 -35
  116. package/esm/chart/area/AreaChart.js +17 -12
  117. package/esm/chart/area/DottedArea.js +61 -109
  118. package/esm/chart/area/GradientArea.js +35 -91
  119. package/esm/chart/area/SolidArea.js +22 -8
  120. package/esm/chart/area/__stories__/AreaChart.stories.js +1 -1
  121. package/esm/chart/axis/Axis.js +2 -0
  122. package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
  123. package/esm/chart/axis/XAxis.js +62 -56
  124. package/esm/chart/axis/YAxis.js +58 -52
  125. package/esm/chart/axis/__stories__/Axis.stories.js +0 -1
  126. package/esm/chart/axis/index.js +1 -0
  127. package/esm/chart/bar/Bar.js +3 -1
  128. package/esm/chart/bar/BarChart.js +15 -37
  129. package/esm/chart/bar/BarPlot.js +41 -35
  130. package/esm/chart/bar/BarStack.js +75 -38
  131. package/esm/chart/bar/BarStackGroup.js +6 -16
  132. package/esm/chart/bar/DefaultBar.js +26 -48
  133. package/esm/chart/bar/DefaultBarStack.js +23 -58
  134. package/esm/chart/bar/__stories__/BarChart.stories.js +463 -77
  135. package/esm/chart/gradient/Gradient.js +53 -0
  136. package/esm/chart/gradient/index.js +1 -0
  137. package/esm/chart/index.js +3 -1
  138. package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
  139. package/esm/chart/line/DottedLine.js +29 -14
  140. package/esm/chart/line/Line.js +106 -67
  141. package/esm/chart/line/LineChart.js +20 -14
  142. package/esm/chart/line/ReferenceLine.js +73 -62
  143. package/esm/chart/line/SolidLine.js +25 -10
  144. package/esm/chart/line/__stories__/LineChart.stories.js +2098 -1975
  145. package/esm/chart/line/__stories__/ReferenceLine.stories.js +83 -28
  146. package/esm/chart/line/index.js +1 -1
  147. package/esm/chart/point/DefaultPointLabel.js +39 -0
  148. package/esm/chart/point/Point.js +188 -0
  149. package/esm/chart/point/index.js +2 -0
  150. package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
  151. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
  152. package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
  153. package/esm/chart/scrubber/Scrubber.js +130 -148
  154. package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
  155. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
  156. package/esm/chart/scrubber/ScrubberProvider.js +46 -54
  157. package/esm/chart/scrubber/index.js +3 -1
  158. package/esm/chart/text/ChartText.js +242 -174
  159. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +6 -5
  160. package/esm/chart/text/index.js +1 -1
  161. package/esm/chart/utils/chart.js +44 -3
  162. package/esm/chart/utils/gradient.js +305 -0
  163. package/esm/chart/utils/index.js +3 -0
  164. package/esm/chart/utils/path.js +76 -8
  165. package/esm/chart/utils/point.js +116 -5
  166. package/esm/chart/utils/scale.js +230 -1
  167. package/esm/chart/utils/scrubber.js +139 -0
  168. package/esm/chart/utils/transition.js +221 -0
  169. package/package.json +11 -9
  170. package/dts/chart/Point.d.ts +0 -103
  171. package/dts/chart/Point.d.ts.map +0 -1
  172. package/dts/chart/line/GradientLine.d.ts +0 -45
  173. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  174. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -75
  175. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  176. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  177. package/esm/chart/Point.js +0 -111
  178. package/esm/chart/line/GradientLine.js +0 -62
  179. package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
@@ -0,0 +1,221 @@
1
+ const _excluded = ["type"],
2
+ _excluded2 = ["type"],
3
+ _excluded3 = ["type"];
4
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
5
+ import { useEffect, useMemo, useRef } from 'react';
6
+ import { useAnimatedReaction, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
7
+ import { notifyChange, Skia } from '@shopify/react-native-skia';
8
+ import { interpolatePath } from 'd3-interpolate-path';
9
+
10
+ /**
11
+ * Transition for animations.
12
+ * Supports timing and spring animation types.
13
+ * Used for paths, positions, opacity, and any other animated properties.
14
+ *
15
+ * @example
16
+ * // Spring animation
17
+ * { type: 'spring', damping: 10, stiffness: 100 }
18
+ *
19
+ * @example
20
+ * // Timing animation
21
+ * { type: 'timing', duration: 500, easing: Easing.inOut(Easing.ease) }
22
+ */
23
+
24
+ /**
25
+ * Default transition configuration used across all chart components.
26
+ */
27
+ export const defaultTransition = {
28
+ type: 'spring',
29
+ stiffness: 900,
30
+ damping: 120
31
+ };
32
+
33
+ /**
34
+ * Duration in milliseconds for accessory elements to fade in.
35
+ */
36
+ export const accessoryFadeTransitionDuration = 150;
37
+
38
+ /**
39
+ * Delay in milliseconds before accessory elements fade in.
40
+ */
41
+ export const accessoryFadeTransitionDelay = 350;
42
+
43
+ /**
44
+ * Custom hook that uses d3-interpolate-path for more robust path interpolation.
45
+ * then use Skia's native interpolation in the worklet.
46
+ *
47
+ * @param progress - Shared value between 0 and 1
48
+ * @param fromPath - Starting path as SVG string
49
+ * @param toPath - Ending path as SVG string
50
+ * @returns Interpolated SkPath as a shared value
51
+ */
52
+ export const useD3PathInterpolation = (progress, fromPath, toPath) => {
53
+ // Pre-compute intermediate paths on JS thread using d3-interpolate-path
54
+ const {
55
+ fromSkiaPath,
56
+ i0,
57
+ i1,
58
+ toSkiaPath
59
+ } = useMemo(() => {
60
+ var _Skia$Path$MakeFromSV, _Skia$Path$MakeFromSV2, _Skia$Path$MakeFromSV3, _Skia$Path$MakeFromSV4;
61
+ const pathInterpolator = interpolatePath(fromPath, toPath);
62
+ const d = 1e-3;
63
+ return {
64
+ fromSkiaPath: (_Skia$Path$MakeFromSV = Skia.Path.MakeFromSVGString(fromPath)) != null ? _Skia$Path$MakeFromSV : Skia.Path.Make(),
65
+ i0: (_Skia$Path$MakeFromSV2 = Skia.Path.MakeFromSVGString(pathInterpolator(d))) != null ? _Skia$Path$MakeFromSV2 : Skia.Path.Make(),
66
+ i1: (_Skia$Path$MakeFromSV3 = Skia.Path.MakeFromSVGString(pathInterpolator(1 - d))) != null ? _Skia$Path$MakeFromSV3 : Skia.Path.Make(),
67
+ toSkiaPath: (_Skia$Path$MakeFromSV4 = Skia.Path.MakeFromSVGString(toPath)) != null ? _Skia$Path$MakeFromSV4 : Skia.Path.Make()
68
+ };
69
+ }, [fromPath, toPath]);
70
+ const result = useSharedValue(fromSkiaPath);
71
+ useAnimatedReaction(() => progress.value, t => {
72
+ 'worklet';
73
+
74
+ var _i1$interpolate;
75
+ result.value = (_i1$interpolate = i1.interpolate(i0, t)) != null ? _i1$interpolate : toSkiaPath;
76
+ notifyChange(result);
77
+ }, [fromSkiaPath, i0, i1, toSkiaPath]);
78
+ return result;
79
+ };
80
+
81
+ // Interpolator and useInterpolator are brought over from non exported code in @shopify/react-native-skia
82
+ /**
83
+ * @worklet
84
+ */
85
+
86
+ export const useInterpolator = (factory, value, interpolator, input, output, options) => {
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ const init = useMemo(() => factory(), []);
89
+ const result = useSharedValue(init);
90
+ useAnimatedReaction(() => value.value, val => {
91
+ result.value = interpolator(val, input, output, options, result.value);
92
+ notifyChange(result);
93
+ }, [input, output, options]);
94
+ return result;
95
+ };
96
+
97
+ /**
98
+ * Builds a react-native-reanimated animation based on the configuration.
99
+ *
100
+ * @param targetValue - The target value to animate to
101
+ * @param config - The transition configuration
102
+ * @returns The animation value to assign to a shared value
103
+ *
104
+ * @example
105
+ * // Use directly for animation
106
+ * progress.value = 0;
107
+ * progress.value = buildTransition(1, { type: 'spring', damping: 10, stiffness: 100 });
108
+ *
109
+ * @example
110
+ * // Coordinate animations
111
+ * animatedX.value = buildTransition(100, { type: 'spring', damping: 10, stiffness: 100 });
112
+ * animatedY.value = buildTransition(200, { type: 'spring', damping: 10, stiffness: 100 });
113
+ *
114
+ * @example
115
+ * // Timing animation
116
+ * progress.value = buildTransition(1, { type: 'timing', duration: 500 });
117
+ */
118
+ export const buildTransition = (targetValue, transition) => {
119
+ 'worklet';
120
+
121
+ switch (transition.type) {
122
+ case 'timing':
123
+ {
124
+ const timingConfig = _objectWithoutPropertiesLoose(transition, _excluded);
125
+ return withTiming(targetValue, timingConfig);
126
+ }
127
+ case 'spring':
128
+ {
129
+ const springConfig = _objectWithoutPropertiesLoose(transition, _excluded2);
130
+ return withSpring(targetValue, springConfig);
131
+ }
132
+ default:
133
+ {
134
+ // Fallback to default transition config
135
+ const springConfig = _objectWithoutPropertiesLoose(defaultTransition, _excluded3);
136
+ return withSpring(targetValue, springConfig);
137
+ }
138
+ }
139
+ };
140
+
141
+ /**
142
+ * Hook for path animation state and transitions.
143
+ *
144
+ * @param currentPath - Current target path to animate to
145
+ * @param initialPath - Initial path for enter animation. When provided, the first animation will go from initialPath to currentPath.
146
+ * @param transition - Transition configuration
147
+ * @returns Animated SkPath as a shared value
148
+ *
149
+ * @example
150
+ * // Simple path transition
151
+ * const path = usePathTransition({
152
+ * currentPath: d ?? '',
153
+ * animate: shouldAnimate,
154
+ * transition: { type: 'timing', duration: 3000 }
155
+ * });
156
+ *
157
+ * @example
158
+ * // Enter animation with different initial config (like DefaultBar)
159
+ * const path = usePathTransition({
160
+ * currentPath: targetPath,
161
+ * initialPath: baselinePath,
162
+ * animate: true,
163
+ * transition: { type: 'timing', duration: 300 }
164
+ * });
165
+ */
166
+ export const usePathTransition = _ref => {
167
+ let {
168
+ currentPath,
169
+ initialPath,
170
+ transition = defaultTransition
171
+ } = _ref;
172
+ const isInitialRender = useRef(true);
173
+ const previousPathRef = useRef(initialPath != null ? initialPath : currentPath);
174
+ const targetPathRef = useRef(currentPath);
175
+ const progress = useSharedValue(0);
176
+ const {
177
+ fromPath,
178
+ toPath
179
+ } = useMemo(() => {
180
+ const isNewPath = targetPathRef.current !== currentPath;
181
+ if (!isNewPath) {
182
+ return {
183
+ fromPath: previousPathRef.current,
184
+ toPath: targetPathRef.current
185
+ };
186
+ }
187
+ const currentProgress = progress.value;
188
+ const isInterrupting = currentProgress > 0 && currentProgress < 1;
189
+ if (isInterrupting) {
190
+ // Animation was interrupted - capture current interpolated path
191
+ const pathInterpolator = interpolatePath(previousPathRef.current, targetPathRef.current);
192
+ const currentInterpolatedPath = pathInterpolator(currentProgress);
193
+ return {
194
+ fromPath: currentInterpolatedPath,
195
+ toPath: currentPath
196
+ };
197
+ }
198
+
199
+ // Normal transition (from completed position to new target)
200
+ const startPath = isInitialRender.current && initialPath ? initialPath : targetPathRef.current;
201
+ return {
202
+ fromPath: startPath,
203
+ toPath: currentPath
204
+ };
205
+ }, [currentPath, initialPath, progress]);
206
+ useEffect(() => {
207
+ const isPathChange = targetPathRef.current !== currentPath;
208
+ const isInitialAnimation = isInitialRender.current && initialPath;
209
+
210
+ // Trigger animation if path changed OR if this is the initial render with an initialPath
211
+ if (isPathChange || isInitialAnimation) {
212
+ // Update refs for next render
213
+ previousPathRef.current = fromPath;
214
+ targetPathRef.current = toPath;
215
+ progress.value = 0;
216
+ progress.value = buildTransition(1, transition);
217
+ isInitialRender.current = false;
218
+ }
219
+ }, [currentPath, initialPath, transition, fromPath, toPath, progress]);
220
+ return useD3PathInterpolation(progress, fromPath, toPath);
221
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cds-mobile-visualization",
3
- "version": "3.4.0-beta.4",
3
+ "version": "3.4.0-beta.6",
4
4
  "description": "Coinbase Design System - Mobile Visualization Native",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,10 +32,11 @@
32
32
  "CHANGELOG"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@coinbase/cds-common": "^8.17.4",
36
- "@coinbase/cds-lottie-files": "^3.3.2",
37
- "@coinbase/cds-mobile": "^8.17.4",
38
- "@coinbase/cds-utils": "^2.3.3",
35
+ "@coinbase/cds-common": "^8.21.8",
36
+ "@coinbase/cds-lottie-files": "^3.3.3",
37
+ "@coinbase/cds-mobile": "^8.21.8",
38
+ "@coinbase/cds-utils": "^2.3.4",
39
+ "@shopify/react-native-skia": "^1.12.4 || ^2.0.0",
39
40
  "react": "^18.3.1",
40
41
  "react-native": "^0.74.5",
41
42
  "react-native-gesture-handler": "^2.16.2",
@@ -52,11 +53,12 @@
52
53
  "@babel/preset-env": "^7.28.0",
53
54
  "@babel/preset-react": "^7.27.1",
54
55
  "@babel/preset-typescript": "^7.27.1",
55
- "@coinbase/cds-common": "^8.17.4",
56
- "@coinbase/cds-lottie-files": "^3.3.2",
57
- "@coinbase/cds-mobile": "^8.17.4",
58
- "@coinbase/cds-utils": "^2.3.3",
56
+ "@coinbase/cds-common": "^8.21.8",
57
+ "@coinbase/cds-lottie-files": "^3.3.3",
58
+ "@coinbase/cds-mobile": "^8.21.8",
59
+ "@coinbase/cds-utils": "^2.3.4",
59
60
  "@figma/code-connect": "^1.3.4",
61
+ "@shopify/react-native-skia": "1.12.4",
60
62
  "@types/react": "^18.3.12",
61
63
  "react-native-gesture-handler": "2.16.2",
62
64
  "react-native-reanimated": "3.14.0",
@@ -1,103 +0,0 @@
1
- import type { SharedProps } from '@coinbase/cds-common/types';
2
- import type { ChartTextChildren } from './text/ChartText';
3
- import { type ChartTextProps } from './text';
4
- /**
5
- * Parameters passed to renderPoints callback function.
6
- */
7
- export type RenderPointsParams = {
8
- /**
9
- * X coordinate in SVG pixel space.
10
- */
11
- x: number;
12
- /**
13
- * Y coordinate in SVG pixel space.
14
- */
15
- y: number;
16
- /**
17
- * X coordinate in data space (usually same as index).
18
- */
19
- dataX: number;
20
- /**
21
- * Y coordinate in data space (same as value).
22
- */
23
- dataY: number;
24
- };
25
- /**
26
- * Shared configuration for point appearance and behavior.
27
- * Used by line-associated points rendered via Line/LineChart components.
28
- */
29
- export type PointConfig = {
30
- /**
31
- * The fill color of the point.
32
- */
33
- fill?: string;
34
- /**
35
- * Optional Y-axis id to specify which axis to plot along.
36
- * Defaults to the first y-axis
37
- */
38
- yAxisId?: string;
39
- /**
40
- * Radius of the point.
41
- * @default 4
42
- */
43
- radius?: number;
44
- /**
45
- * Opacity of the point.
46
- */
47
- opacity?: number;
48
- /**
49
- * Handler for when the point is clicked.
50
- */
51
- onPress?: (point: { x: number; y: number; dataX: number; dataY: number }) => void;
52
- /**
53
- * Handler for when the scrubber enters this point.
54
- */
55
- onScrubberEnter?: (point: { x: number; y: number }) => void;
56
- /**
57
- * Color of the outer stroke around the point.
58
- * @default theme.color.bg
59
- */
60
- stroke?: string;
61
- /**
62
- * Outer stroke width of the point.
63
- * Set to 0 to remove the stroke.
64
- * @default 2
65
- */
66
- strokeWidth?: number;
67
- /**
68
- * Simple text label to display at the point position.
69
- * If provided, a ChartText will be automatically rendered.
70
- */
71
- label?: ChartTextChildren;
72
- /**
73
- * Configuration for the automatically rendered label.
74
- * Only used when `label` prop is provided.
75
- */
76
- labelProps?: Omit<ChartTextProps, 'x' | 'y' | 'children'>;
77
- /**
78
- * Accessibility label for screen readers to describe the point.
79
- * If not provided, a default label will be generated using the data coordinates.
80
- */
81
- accessibilityLabel?: string;
82
- };
83
- export type PointProps = SharedProps &
84
- PointConfig & {
85
- /**
86
- * X coordinate in data space (not pixel coordinates).
87
- */
88
- dataX: number;
89
- /**
90
- * Y coordinate in data space (not pixel coordinates).
91
- */
92
- dataY: number;
93
- /**
94
- * Optional pixel coordinates to use instead of calculating from dataX/dataY.
95
- * Useful for performance when coordinates are already calculated.
96
- */
97
- pixelCoordinates?: {
98
- x: number;
99
- y: number;
100
- };
101
- };
102
- export declare const Point: import('react').NamedExoticComponent<PointProps>;
103
- //# sourceMappingURL=Point.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../src/chart/Point.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGxD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAClF;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5D;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,GAAG,GAAG,UAAU,CAAC,CAAC;IAC1D;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAClC,WAAW,GAAG;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,gBAAgB,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAAC;AAEJ,eAAO,MAAM,KAAK,kDAyFjB,CAAC"}
@@ -1,45 +0,0 @@
1
- import type { SharedProps } from '@coinbase/cds-common/types';
2
- import { type PathProps } from '../Path';
3
- export type GradientLineProps = SharedProps &
4
- Omit<PathProps, 'stroke' | 'strokeOpacity' | 'strokeWidth'> & {
5
- /**
6
- * The color of the line.
7
- * @default theme.color.bgLine
8
- */
9
- stroke?: string;
10
- /**
11
- * Opacity of the line.
12
- * @default 1
13
- */
14
- strokeOpacity?: number;
15
- /**
16
- * Path stroke width
17
- * @default 2
18
- */
19
- strokeWidth?: number;
20
- /**
21
- * The color of the start of the gradient.
22
- * @default stroke or theme.color.bgLine
23
- */
24
- startColor?: string;
25
- /**
26
- * The color of the end of the gradient.
27
- * @default stroke or theme.color.bgLine
28
- */
29
- endColor?: string;
30
- /**
31
- * Opacity of the start color.
32
- * @default strokeOpacity
33
- */
34
- startOpacity?: number;
35
- /**
36
- * Opacity of the end color.
37
- * @default strokeOpacity
38
- */
39
- endOpacity?: number;
40
- };
41
- /**
42
- * A gradient line component which uses path element.
43
- */
44
- export declare const GradientLine: import('react').NamedExoticComponent<GradientLineProps>;
45
- //# sourceMappingURL=GradientLine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GradientLine.d.ts","sourceRoot":"","sources":["../../../src/chart/line/GradientLine.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG,WAAW,GACzC,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,eAAe,GAAG,aAAa,CAAC,GAAG;IAC5D;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,YAAY,yDAmDxB,CAAC"}
@@ -1,75 +0,0 @@
1
- import type { SharedProps } from '@coinbase/cds-common/types';
2
- export type ScrubberBeaconRef = {
3
- /**
4
- * Triggers a single pulse animation.
5
- */
6
- pulse: () => void;
7
- };
8
- export type ScrubberBeaconProps = SharedProps & {
9
- /**
10
- * Optional data X coordinate to position the beacon.
11
- * If not provided, uses the scrubber position from context.
12
- */
13
- dataX?: number;
14
- /**
15
- * Optional data Y coordinate to position the beacon.
16
- * If not provided, looks up the Y value from series data at scrubber position.
17
- */
18
- dataY?: number;
19
- /**
20
- * Filter to only show dot for specific series (used for hover-based positioning).
21
- */
22
- seriesId?: string;
23
- /**
24
- * Color of the beacon point.
25
- * If not provided, uses the series color.
26
- */
27
- color?: string;
28
- /**
29
- * Opacity of the beacon.
30
- * @default 1
31
- */
32
- opacity?: number;
33
- /**
34
- * Pulse the scrubber beacon while it is at rest.
35
- */
36
- idlePulse?: boolean;
37
- };
38
- /**
39
- * The ScrubberBeacon is a special instance of a Point used to mark the scrubber's position on a specific series.
40
- */
41
- export declare const ScrubberBeacon: import('react').MemoExoticComponent<
42
- import('react').ForwardRefExoticComponent<
43
- SharedProps & {
44
- /**
45
- * Optional data X coordinate to position the beacon.
46
- * If not provided, uses the scrubber position from context.
47
- */
48
- dataX?: number;
49
- /**
50
- * Optional data Y coordinate to position the beacon.
51
- * If not provided, looks up the Y value from series data at scrubber position.
52
- */
53
- dataY?: number;
54
- /**
55
- * Filter to only show dot for specific series (used for hover-based positioning).
56
- */
57
- seriesId?: string;
58
- /**
59
- * Color of the beacon point.
60
- * If not provided, uses the series color.
61
- */
62
- color?: string;
63
- /**
64
- * Opacity of the beacon.
65
- * @default 1
66
- */
67
- opacity?: number;
68
- /**
69
- * Pulse the scrubber beacon while it is at rest.
70
- */
71
- idlePulse?: boolean;
72
- } & import('react').RefAttributes<ScrubberBeaconRef>
73
- >
74
- >;
75
- //# sourceMappingURL=ScrubberBeacon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScrubberBeacon.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberBeacon.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAe9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;IAjCzB;;;OAGG;YACK,MAAM;IACd;;;OAGG;YACK,MAAM;IACd;;OAEG;eACQ,MAAM;IACjB;;;OAGG;YACK,MAAM;IACd;;;OAGG;cACO,MAAM;IAChB;;OAEG;gBACS,OAAO;sDAgMpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SmartChartTextGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/text/SmartChartTextGroup.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAC;IACzB;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1C,CAAC;AAiBF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,gEAwL/B,CAAC"}
@@ -1,111 +0,0 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import { memo, useEffect, useMemo } from 'react';
3
- import { Circle, G } from 'react-native-svg';
4
- import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
5
- import { useCartesianChartContext } from './ChartProvider';
6
- import { ChartText } from './text';
7
- import { projectPoint, useScrubberContext } from './utils';
8
-
9
- /**
10
- * Parameters passed to renderPoints callback function.
11
- */
12
-
13
- /**
14
- * Shared configuration for point appearance and behavior.
15
- * Used by line-associated points rendered via Line/LineChart components.
16
- */
17
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
18
- export const Point = /*#__PURE__*/memo(_ref => {
19
- let {
20
- dataX,
21
- dataY,
22
- yAxisId,
23
- fill,
24
- radius = 4,
25
- opacity,
26
- onPress,
27
- onScrubberEnter,
28
- stroke,
29
- strokeWidth = 2,
30
- accessibilityLabel,
31
- label,
32
- labelProps,
33
- pixelCoordinates,
34
- testID
35
- } = _ref;
36
- const theme = useTheme();
37
- const effectiveStroke = stroke != null ? stroke : theme.color.bg;
38
- const {
39
- getXScale,
40
- getYScale
41
- } = useCartesianChartContext();
42
- const {
43
- scrubberPosition
44
- } = useScrubberContext();
45
- const xScale = getXScale();
46
- const yScale = getYScale(yAxisId);
47
-
48
- // Scrubber detection: check if this point is highlighted by the scrubber
49
- const isScrubberHighlighted = scrubberPosition !== undefined && scrubberPosition === dataX;
50
-
51
- // Use provided pixelCoordinates or calculate from data coordinates
52
- const pixelCoordinate = useMemo(() => {
53
- if (pixelCoordinates) {
54
- return pixelCoordinates;
55
- }
56
- if (!xScale || !yScale) {
57
- return {
58
- x: 0,
59
- y: 0
60
- };
61
- }
62
- return projectPoint({
63
- x: dataX,
64
- y: dataY,
65
- xScale,
66
- yScale
67
- });
68
- }, [pixelCoordinates, xScale, yScale, dataX, dataY]);
69
- useEffect(() => {
70
- if (isScrubberHighlighted && onScrubberEnter) {
71
- onScrubberEnter({
72
- x: pixelCoordinate.x,
73
- y: pixelCoordinate.y
74
- });
75
- }
76
- }, [isScrubberHighlighted, onScrubberEnter, pixelCoordinate.x, pixelCoordinate.y]);
77
- if (!xScale || !yScale) {
78
- return null;
79
- }
80
- return /*#__PURE__*/_jsxs(_Fragment, {
81
- children: [/*#__PURE__*/_jsx(G, {
82
- opacity: opacity,
83
- testID: testID,
84
- transform: [{
85
- translateX: pixelCoordinate.x
86
- }, {
87
- translateY: pixelCoordinate.y
88
- }],
89
- children: /*#__PURE__*/_jsx(Circle, {
90
- accessibilityLabel: accessibilityLabel,
91
- cx: 0,
92
- cy: 0,
93
- fill: fill != null ? fill : theme.color.fgPrimary,
94
- onPress: onPress ? event => onPress({
95
- dataX,
96
- dataY,
97
- x: pixelCoordinate.x,
98
- y: pixelCoordinate.y
99
- }) : undefined,
100
- r: radius,
101
- stroke: effectiveStroke,
102
- strokeWidth: strokeWidth
103
- })
104
- }), label && /*#__PURE__*/_jsx(ChartText, _extends({
105
- x: pixelCoordinate.x,
106
- y: pixelCoordinate.y
107
- }, labelProps, {
108
- children: label
109
- }))]
110
- });
111
- });
@@ -1,62 +0,0 @@
1
- const _excluded = ["fill", "stroke", "startColor", "endColor", "strokeOpacity", "startOpacity", "endOpacity", "strokeLinecap", "strokeLinejoin", "strokeWidth", "animate"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import { memo, useId } from 'react';
5
- import { Defs, LinearGradient, Stop } from 'react-native-svg';
6
- import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
7
- import { useCartesianChartContext } from '../ChartProvider';
8
- import { Path } from '../Path';
9
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
10
- /**
11
- * A gradient line component which uses path element.
12
- */
13
- export const GradientLine = /*#__PURE__*/memo(_ref => {
14
- var _ref2, _ref3;
15
- let {
16
- fill = 'none',
17
- stroke,
18
- startColor,
19
- endColor,
20
- strokeOpacity = 1,
21
- startOpacity = strokeOpacity,
22
- endOpacity = strokeOpacity,
23
- strokeLinecap = 'round',
24
- strokeLinejoin = 'round',
25
- strokeWidth = 2,
26
- animate
27
- } = _ref,
28
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
29
- const context = useCartesianChartContext();
30
- const theme = useTheme();
31
- const patternId = useId();
32
- const shouldAnimate = animate != null ? animate : context.animate;
33
- return /*#__PURE__*/_jsxs(_Fragment, {
34
- children: [/*#__PURE__*/_jsx(Defs, {
35
- children: /*#__PURE__*/_jsxs(LinearGradient, {
36
- id: patternId,
37
- x1: "0%",
38
- x2: "0%",
39
- y1: "0%",
40
- y2: "100%",
41
- children: [/*#__PURE__*/_jsx(Stop, {
42
- offset: "0%",
43
- stopColor: (_ref2 = startColor != null ? startColor : stroke) != null ? _ref2 : theme.color.bgLine,
44
- stopOpacity: startOpacity
45
- }), /*#__PURE__*/_jsx(Stop, {
46
- offset: "100%",
47
- stopColor: (_ref3 = endColor != null ? endColor : stroke) != null ? _ref3 : theme.color.bgLine,
48
- stopOpacity: endOpacity
49
- })]
50
- })
51
- }), /*#__PURE__*/_jsx(Path, _extends({
52
- animate: shouldAnimate,
53
- clipOffset: strokeWidth,
54
- fill: fill,
55
- stroke: "url(#" + patternId + ")",
56
- strokeLinecap: strokeLinecap,
57
- strokeLinejoin: strokeLinejoin,
58
- strokeOpacity: strokeOpacity,
59
- strokeWidth: strokeWidth
60
- }, props))]
61
- });
62
- });