@coinbase/cds-mobile-visualization 3.4.0-beta.1 → 3.4.0-beta.11
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.
- package/CHANGELOG.md +60 -0
- package/dts/chart/CartesianChart.d.ts +57 -33
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/ChartContextBridge.d.ts +28 -0
- package/dts/chart/ChartContextBridge.d.ts.map +1 -0
- package/dts/chart/Path.d.ts +77 -34
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +2 -2
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +42 -27
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +51 -10
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts +21 -2
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts +19 -13
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts +17 -2
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +86 -118
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +1 -1
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +2 -2
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/axis/index.d.ts +1 -0
- package/dts/chart/axis/index.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +16 -13
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +36 -20
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +2 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +39 -48
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBar.d.ts +1 -1
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
- package/dts/chart/gradient/Gradient.d.ts +25 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +3 -1
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +13 -5
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +64 -25
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +43 -9
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +68 -20
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts +8 -5
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/line/index.d.ts +1 -1
- package/dts/chart/line/index.d.ts.map +1 -1
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +120 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +172 -43
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +6 -3
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dts/chart/scrubber/index.d.ts +3 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -1
- package/dts/chart/text/ChartText.d.ts +151 -77
- package/dts/chart/text/ChartText.d.ts.map +1 -1
- package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +1 -1
- package/dts/chart/text/index.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +25 -1
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +34 -7
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +28 -7
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +117 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +3 -0
- package/dts/chart/utils/index.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +53 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +71 -7
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scale.d.ts +102 -0
- package/dts/chart/utils/scale.d.ts.map +1 -1
- package/dts/chart/utils/scrubber.d.ts +39 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +140 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/esm/chart/CartesianChart.js +164 -70
- package/esm/chart/ChartContextBridge.js +148 -0
- package/esm/chart/Path.js +198 -113
- package/esm/chart/PeriodSelector.js +2 -2
- package/esm/chart/__stories__/CartesianChart.stories.js +378 -131
- package/esm/chart/__stories__/Chart.stories.js +2 -4
- package/esm/chart/__stories__/PeriodSelector.stories.js +103 -75
- package/esm/chart/area/Area.js +25 -35
- package/esm/chart/area/AreaChart.js +17 -12
- package/esm/chart/area/DottedArea.js +61 -109
- package/esm/chart/area/GradientArea.js +35 -91
- package/esm/chart/area/SolidArea.js +22 -8
- package/esm/chart/area/__stories__/AreaChart.stories.js +1 -1
- package/esm/chart/axis/Axis.js +5 -39
- package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
- package/esm/chart/axis/XAxis.js +148 -66
- package/esm/chart/axis/YAxis.js +149 -65
- package/esm/chart/axis/__stories__/Axis.stories.js +259 -1
- package/esm/chart/axis/index.js +1 -0
- package/esm/chart/bar/Bar.js +3 -1
- package/esm/chart/bar/BarChart.js +15 -37
- package/esm/chart/bar/BarPlot.js +41 -35
- package/esm/chart/bar/BarStack.js +75 -38
- package/esm/chart/bar/BarStackGroup.js +6 -16
- package/esm/chart/bar/DefaultBar.js +26 -48
- package/esm/chart/bar/DefaultBarStack.js +23 -58
- package/esm/chart/bar/__stories__/BarChart.stories.js +502 -77
- package/esm/chart/gradient/Gradient.js +53 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +3 -1
- package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
- package/esm/chart/line/DottedLine.js +29 -14
- package/esm/chart/line/Line.js +106 -67
- package/esm/chart/line/LineChart.js +20 -14
- package/esm/chart/line/ReferenceLine.js +80 -63
- package/esm/chart/line/SolidLine.js +25 -10
- package/esm/chart/line/__stories__/LineChart.stories.js +2101 -1977
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +83 -28
- package/esm/chart/line/index.js +1 -1
- package/esm/chart/point/DefaultPointLabel.js +39 -0
- package/esm/chart/point/Point.js +188 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
- package/esm/chart/scrubber/Scrubber.js +126 -146
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
- package/esm/chart/scrubber/ScrubberProvider.js +46 -54
- package/esm/chart/scrubber/index.js +3 -1
- package/esm/chart/text/ChartText.js +242 -174
- package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +6 -5
- package/esm/chart/text/index.js +1 -1
- package/esm/chart/utils/axis.js +45 -29
- package/esm/chart/utils/chart.js +44 -3
- package/esm/chart/utils/gradient.js +305 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/path.js +76 -8
- package/esm/chart/utils/point.js +171 -17
- package/esm/chart/utils/scale.js +242 -2
- package/esm/chart/utils/scrubber.js +139 -0
- package/esm/chart/utils/transition.js +185 -0
- package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +51 -26
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
- package/package.json +15 -9
- package/dts/chart/Point.d.ts +0 -103
- package/dts/chart/Point.d.ts.map +0 -1
- package/dts/chart/line/GradientLine.d.ts +0 -45
- package/dts/chart/line/GradientLine.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -75
- package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
- package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
- package/esm/chart/Point.js +0 -111
- package/esm/chart/line/GradientLine.js +0 -62
- package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
package/esm/chart/Path.js
CHANGED
|
@@ -1,133 +1,218 @@
|
|
|
1
|
-
const _excluded = ["
|
|
2
|
-
|
|
1
|
+
const _excluded = ["d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "transition"],
|
|
2
|
+
_excluded2 = ["animate", "clipRect", "clipPath", "clipOffset", "d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "transition"];
|
|
3
3
|
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); }
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
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 { memo, useEffect, useMemo } from 'react';
|
|
6
|
+
import { useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
7
|
+
import { Group, Path as SkiaPath, Skia, usePathInterpolation } from '@shopify/react-native-skia';
|
|
8
|
+
import { usePathTransition } from './utils/transition';
|
|
9
9
|
import { useCartesianChartContext } from './ChartProvider';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import { unwrapAnimatedValue } from './utils';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Duration in milliseconds for path enter transition.
|
|
14
|
+
*/
|
|
15
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
export const pathEnterTransitionDuration = 500;
|
|
17
|
+
const AnimatedPath = /*#__PURE__*/memo(_ref => {
|
|
13
18
|
let {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
d = '',
|
|
20
|
+
initialPath,
|
|
21
|
+
fill,
|
|
22
|
+
fillOpacity,
|
|
23
|
+
stroke,
|
|
24
|
+
strokeOpacity,
|
|
25
|
+
strokeWidth,
|
|
26
|
+
strokeCap,
|
|
27
|
+
strokeJoin,
|
|
28
|
+
children,
|
|
29
|
+
transition
|
|
30
|
+
} = _ref,
|
|
31
|
+
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
32
|
+
const isDAnimated = typeof d !== 'string';
|
|
33
|
+
|
|
34
|
+
// When d is animated, usePathTransition handles static path transitions.
|
|
35
|
+
// For animated d values, we skip usePathTransition and use useDerivedValue directly.
|
|
36
|
+
const animatedPath = usePathTransition({
|
|
37
|
+
currentPath: isDAnimated ? '' : d,
|
|
38
|
+
initialPath,
|
|
39
|
+
transition
|
|
40
|
+
});
|
|
41
|
+
const isFilled = fill !== undefined && fill !== 'none';
|
|
42
|
+
const isStroked = stroke !== undefined && stroke !== 'none';
|
|
43
|
+
const activePath = useDerivedValue(() => {
|
|
44
|
+
if (isDAnimated) {
|
|
45
|
+
var _d$value;
|
|
46
|
+
return (_d$value = d.value) != null ? _d$value : Skia.Path.Make();
|
|
47
|
+
}
|
|
48
|
+
return animatedPath.value;
|
|
49
|
+
});
|
|
50
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
51
|
+
children: [isFilled && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
52
|
+
color: fill,
|
|
53
|
+
opacity: fillOpacity,
|
|
54
|
+
path: activePath,
|
|
55
|
+
style: "fill"
|
|
56
|
+
}, pathProps, {
|
|
57
|
+
children: children
|
|
58
|
+
})), isStroked && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
59
|
+
color: stroke,
|
|
60
|
+
opacity: strokeOpacity,
|
|
61
|
+
path: activePath,
|
|
62
|
+
strokeCap: strokeCap,
|
|
63
|
+
strokeJoin: strokeJoin,
|
|
64
|
+
strokeWidth: strokeWidth,
|
|
65
|
+
style: "stroke"
|
|
66
|
+
}, pathProps, {
|
|
67
|
+
children: children
|
|
68
|
+
}))]
|
|
23
69
|
});
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
animatedWidth.value = withTiming(width + totalOffset, {
|
|
26
|
-
duration: 1000
|
|
27
|
-
});
|
|
28
|
-
}, [animatedWidth, width, totalOffset]);
|
|
29
|
-
return /*#__PURE__*/_jsx(AnimatedRect, _extends({
|
|
30
|
-
animatedProps: animatedProps
|
|
31
|
-
}, rectProps));
|
|
32
70
|
});
|
|
33
|
-
export const Path = /*#__PURE__*/memo(
|
|
34
|
-
|
|
71
|
+
export const Path = /*#__PURE__*/memo(props => {
|
|
72
|
+
const {
|
|
73
|
+
animate: animateProp,
|
|
35
74
|
clipRect,
|
|
36
|
-
|
|
75
|
+
clipPath: clipPathProp,
|
|
76
|
+
clipOffset = 0,
|
|
37
77
|
d = '',
|
|
78
|
+
initialPath,
|
|
38
79
|
fill,
|
|
80
|
+
fillOpacity,
|
|
39
81
|
stroke,
|
|
40
|
-
strokeWidth,
|
|
41
82
|
strokeOpacity,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const fromPath = useMemo(() => {
|
|
60
|
-
if (!animate) return targetPath;
|
|
61
|
-
return previousPath != null ? previousPath : targetPath;
|
|
62
|
-
}, [animate, previousPath, targetPath]);
|
|
63
|
-
const pathInterpolator = useMemo(() => interpolate.interpolatePath(fromPath, targetPath), [fromPath, targetPath]);
|
|
64
|
-
const updatePath = useCallback(progress => {
|
|
65
|
-
var _pathRef$current;
|
|
66
|
-
if (!pathInterpolator) return;
|
|
67
|
-
const val = Number(progress.toFixed(4));
|
|
68
|
-
(_pathRef$current = pathRef.current) == null || _pathRef$current.setNativeProps({
|
|
69
|
-
d: pathInterpolator(val)
|
|
70
|
-
});
|
|
71
|
-
}, [pathInterpolator]);
|
|
72
|
-
useAnimatedReaction(() => animationProgress.value, progress => {
|
|
73
|
-
'worklet';
|
|
83
|
+
strokeWidth,
|
|
84
|
+
strokeCap,
|
|
85
|
+
strokeJoin,
|
|
86
|
+
children,
|
|
87
|
+
transition
|
|
88
|
+
} = props,
|
|
89
|
+
pathProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
90
|
+
const context = useCartesianChartContext();
|
|
91
|
+
const rect = clipRect != null ? clipRect : context.drawingArea;
|
|
92
|
+
const animate = animateProp != null ? animateProp : context.animate;
|
|
93
|
+
|
|
94
|
+
// The clip offset provides extra padding to prevent path from being cut off
|
|
95
|
+
// Area charts typically use offset=0 for exact clipping, while lines use offset=2 for breathing room
|
|
96
|
+
const totalOffset = clipOffset * 2; // Applied on both sides
|
|
97
|
+
|
|
98
|
+
// Animation progress for clip path reveal
|
|
99
|
+
const clipProgress = useSharedValue(animate ? 0 : 1);
|
|
74
100
|
|
|
75
|
-
|
|
76
|
-
}, [updatePath]);
|
|
101
|
+
// Trigger clip path animation when component mounts and animate is true
|
|
77
102
|
useEffect(() => {
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
d: targetPath
|
|
103
|
+
if (animate) {
|
|
104
|
+
clipProgress.value = withTiming(1, {
|
|
105
|
+
duration: pathEnterTransitionDuration
|
|
82
106
|
});
|
|
83
|
-
animationProgress.value = 1;
|
|
84
|
-
return;
|
|
85
107
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
108
|
+
}, [animate, clipProgress]);
|
|
109
|
+
|
|
110
|
+
// Create initial and target clip paths for animation
|
|
111
|
+
const {
|
|
112
|
+
initialClipPath,
|
|
113
|
+
targetClipPath
|
|
114
|
+
} = useMemo(() => {
|
|
115
|
+
if (!rect) return {
|
|
116
|
+
initialClipPath: null,
|
|
117
|
+
targetClipPath: null
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Initial clip path (width = 0)
|
|
121
|
+
const initial = Skia.Path.Make();
|
|
122
|
+
initial.addRect({
|
|
123
|
+
x: rect.x - clipOffset,
|
|
124
|
+
y: rect.y - clipOffset,
|
|
125
|
+
width: 0,
|
|
126
|
+
height: rect.height + totalOffset
|
|
89
127
|
});
|
|
90
|
-
}, [animate, animationProgress, targetPath, pathInterpolator]);
|
|
91
|
-
if (!d || !rect) return;
|
|
92
128
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
129
|
+
// Target clip path (full width)
|
|
130
|
+
const target = Skia.Path.Make();
|
|
131
|
+
target.addRect({
|
|
132
|
+
x: rect.x - clipOffset,
|
|
133
|
+
y: rect.y - clipOffset,
|
|
134
|
+
width: rect.width + totalOffset,
|
|
135
|
+
height: rect.height + totalOffset
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
initialClipPath: initial,
|
|
139
|
+
targetClipPath: target
|
|
140
|
+
};
|
|
141
|
+
}, [rect, clipOffset, totalOffset]);
|
|
142
|
+
|
|
143
|
+
// Use usePathInterpolation for animated clip path
|
|
144
|
+
const animatedClipPath = usePathInterpolation(clipProgress, [0, 1], animate && initialClipPath && targetClipPath ? [initialClipPath, targetClipPath] : targetClipPath ? [targetClipPath, targetClipPath] : [Skia.Path.Make(), Skia.Path.Make()]);
|
|
145
|
+
|
|
146
|
+
// Resolve the final clip path:
|
|
147
|
+
// 1. If clipPath prop was explicitly provided, use it (even if null = no clipping)
|
|
148
|
+
// 2. If animating, use the interpolated clip path
|
|
149
|
+
// 3. Otherwise, use static target clip path
|
|
150
|
+
const resolvedClipPath = useMemo(() => {
|
|
151
|
+
// If clipPath was explicitly provided (null or string), use it directly
|
|
152
|
+
if (clipPathProp !== undefined) {
|
|
153
|
+
return clipPathProp;
|
|
154
|
+
}
|
|
96
155
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
156
|
+
// If not animating or paths are null, return target clip path
|
|
157
|
+
if (!animate || !targetClipPath) {
|
|
158
|
+
return targetClipPath;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Return undefined here since we'll use animatedClipPath directly
|
|
162
|
+
return undefined;
|
|
163
|
+
}, [clipPathProp, animate, targetClipPath]);
|
|
164
|
+
|
|
165
|
+
// Convert SVG path string to SkPath for static rendering
|
|
166
|
+
const staticPath = useDerivedValue(() => {
|
|
167
|
+
var _Skia$Path$MakeFromSV;
|
|
168
|
+
const dValue = unwrapAnimatedValue(d);
|
|
169
|
+
if (!dValue) return Skia.Path.Make();
|
|
170
|
+
return (_Skia$Path$MakeFromSV = Skia.Path.MakeFromSVGString(dValue)) != null ? _Skia$Path$MakeFromSV : Skia.Path.Make();
|
|
171
|
+
}, [d]);
|
|
172
|
+
const isFilled = fill !== undefined && fill !== 'none';
|
|
173
|
+
const isStroked = stroke !== undefined && stroke !== 'none';
|
|
174
|
+
const content = !animate ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
175
|
+
children: [isFilled && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
176
|
+
color: fill,
|
|
177
|
+
opacity: fillOpacity,
|
|
178
|
+
path: staticPath,
|
|
179
|
+
style: "fill"
|
|
180
|
+
}, pathProps, {
|
|
181
|
+
children: children
|
|
182
|
+
})), isStroked && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
183
|
+
color: stroke,
|
|
184
|
+
opacity: strokeOpacity,
|
|
185
|
+
path: staticPath,
|
|
186
|
+
strokeCap: strokeCap,
|
|
187
|
+
strokeJoin: strokeJoin,
|
|
129
188
|
strokeWidth: strokeWidth,
|
|
130
|
-
|
|
131
|
-
}, pathProps
|
|
189
|
+
style: "stroke"
|
|
190
|
+
}, pathProps, {
|
|
191
|
+
children: children
|
|
192
|
+
}))]
|
|
193
|
+
}) : /*#__PURE__*/_jsx(AnimatedPath, {
|
|
194
|
+
d: d,
|
|
195
|
+
fill: fill,
|
|
196
|
+
fillOpacity: fillOpacity,
|
|
197
|
+
initialPath: initialPath,
|
|
198
|
+
stroke: stroke,
|
|
199
|
+
strokeCap: strokeCap,
|
|
200
|
+
strokeJoin: strokeJoin,
|
|
201
|
+
strokeOpacity: strokeOpacity,
|
|
202
|
+
strokeWidth: strokeWidth,
|
|
203
|
+
transition: transition,
|
|
204
|
+
children: children
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// Determine which clip path to use
|
|
208
|
+
const finalClipPath = animate && resolvedClipPath === undefined ? animatedClipPath : resolvedClipPath;
|
|
209
|
+
|
|
210
|
+
// If finalClipPath is null, render without clipping
|
|
211
|
+
if (finalClipPath === null) {
|
|
212
|
+
return content;
|
|
213
|
+
}
|
|
214
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
215
|
+
clip: finalClipPath,
|
|
216
|
+
children: content
|
|
132
217
|
});
|
|
133
218
|
});
|
|
@@ -9,7 +9,7 @@ import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
|
9
9
|
import { SegmentedTabs } from '@coinbase/cds-mobile/tabs';
|
|
10
10
|
import { SegmentedTab } from '@coinbase/cds-mobile/tabs/SegmentedTab';
|
|
11
11
|
import { tabsSpringConfig } from '@coinbase/cds-mobile/tabs/Tabs';
|
|
12
|
-
import { Text } from '@coinbase/cds-mobile/typography
|
|
12
|
+
import { Text } from '@coinbase/cds-mobile/typography';
|
|
13
13
|
|
|
14
14
|
// Animated active indicator to support smooth transition of background color
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -55,7 +55,7 @@ export const PeriodSelectorActiveIndicator = _ref => {
|
|
|
55
55
|
width: animatedValues.value.width,
|
|
56
56
|
backgroundColor: animatedValues.value.backgroundColor
|
|
57
57
|
}), [animatedValues]);
|
|
58
|
-
if (!width) return
|
|
58
|
+
if (!width) return;
|
|
59
59
|
return /*#__PURE__*/_jsx(Animated.View, {
|
|
60
60
|
style: [{
|
|
61
61
|
position: position,
|