@coinbase/cds-mobile-visualization 3.4.0-beta.2 → 3.4.0-beta.20
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 +122 -0
- package/dts/chart/CartesianChart.d.ts +92 -34
- 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/ChartProvider.d.ts +3 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +97 -32
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +6 -13
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +39 -28
- 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 +49 -12
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +40 -19
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +3 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +41 -46
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +2 -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 +4 -1
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts +5 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
- package/dts/chart/legend/Legend.d.ts +168 -0
- package/dts/chart/legend/Legend.d.ts.map +1 -0
- package/dts/chart/legend/index.d.ts +4 -0
- package/dts/chart/legend/index.d.ts.map +1 -0
- 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 +61 -27
- 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 +136 -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 +38 -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 +230 -42
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +54 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +46 -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/bar.d.ts +34 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +52 -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 +59 -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 +40 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +178 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/esm/chart/CartesianChart.js +199 -75
- package/esm/chart/ChartContextBridge.js +159 -0
- package/esm/chart/ChartProvider.js +2 -2
- package/esm/chart/Path.js +200 -114
- package/esm/chart/PeriodSelector.js +7 -3
- package/esm/chart/__stories__/CartesianChart.stories.js +307 -134
- package/esm/chart/__stories__/ChartTransitions.stories.js +629 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +201 -75
- package/esm/chart/area/Area.js +27 -35
- package/esm/chart/area/AreaChart.js +17 -12
- package/esm/chart/area/DottedArea.js +64 -108
- package/esm/chart/area/GradientArea.js +37 -91
- package/esm/chart/area/SolidArea.js +24 -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 +7 -1
- package/esm/chart/bar/BarChart.js +17 -37
- package/esm/chart/bar/BarPlot.js +43 -35
- package/esm/chart/bar/BarStack.js +84 -37
- package/esm/chart/bar/BarStackGroup.js +7 -17
- package/esm/chart/bar/DefaultBar.js +29 -51
- package/esm/chart/bar/DefaultBarStack.js +34 -58
- package/esm/chart/bar/__stories__/BarChart.stories.js +948 -88
- package/esm/chart/gradient/Gradient.js +53 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +4 -1
- package/esm/chart/legend/DefaultLegendEntry.js +42 -0
- package/esm/chart/legend/DefaultLegendShape.js +64 -0
- package/esm/chart/legend/Legend.js +59 -0
- package/esm/chart/legend/__stories__/Legend.stories.js +574 -0
- package/esm/chart/legend/index.js +3 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
- package/esm/chart/line/DottedLine.js +31 -14
- package/esm/chart/line/Line.js +96 -68
- package/esm/chart/line/LineChart.js +21 -14
- package/esm/chart/line/ReferenceLine.js +80 -63
- package/esm/chart/line/SolidLine.js +27 -10
- package/esm/chart/line/__stories__/LineChart.stories.js +1748 -2048
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +177 -28
- package/esm/chart/line/index.js +1 -1
- package/esm/chart/point/DefaultPointLabel.js +39 -0
- package/esm/chart/point/Point.js +186 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +180 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
- package/esm/chart/scrubber/Scrubber.js +130 -144
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +165 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +208 -0
- package/esm/chart/scrubber/ScrubberProvider.js +46 -54
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +760 -0
- 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 +47 -31
- package/esm/chart/utils/bar.js +43 -0
- package/esm/chart/utils/chart.js +57 -3
- package/esm/chart/utils/gradient.js +305 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/path.js +84 -8
- package/esm/chart/utils/point.js +171 -17
- package/esm/chart/utils/scale.js +242 -2
- package/esm/chart/utils/scrubber.js +146 -0
- package/esm/chart/utils/transition.js +220 -0
- package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
- package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +51 -26
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
- package/package.json +15 -10
- 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/__stories__/Chart.stories.js +0 -79
- package/esm/chart/line/GradientLine.js +0 -62
- package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
|
@@ -1,34 +1,22 @@
|
|
|
1
|
-
const _excluded = ["label"]
|
|
1
|
+
const _excluded = ["label"],
|
|
2
|
+
_excluded2 = ["label", "font", "hideDot", "style"];
|
|
2
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; }
|
|
3
4
|
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
|
-
import { forwardRef, memo, useMemo, useState } from 'react';
|
|
5
|
-
import { View } from 'react-native';
|
|
5
|
+
import { forwardRef, memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { ScrollView, View } from 'react-native';
|
|
7
|
+
import { interpolateColor, runOnJS, useAnimatedReaction, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
6
8
|
import { assets } from '@coinbase/cds-common/internal/data/assets';
|
|
7
9
|
import { useTabsContext } from '@coinbase/cds-common/tabs/TabsContext';
|
|
8
10
|
import { IconButton } from '@coinbase/cds-mobile/buttons';
|
|
11
|
+
import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
|
|
9
12
|
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
10
|
-
import {
|
|
13
|
+
import { Icon } from '@coinbase/cds-mobile/icons';
|
|
14
|
+
import { HStack } from '@coinbase/cds-mobile/layout';
|
|
11
15
|
import { SegmentedTab } from '@coinbase/cds-mobile/tabs/SegmentedTab';
|
|
12
|
-
import {
|
|
16
|
+
import { tabsSpringConfig } from '@coinbase/cds-mobile/tabs/Tabs';
|
|
17
|
+
import { Text } from '@coinbase/cds-mobile/typography';
|
|
13
18
|
import { LiveTabLabel, PeriodSelector, PeriodSelectorActiveIndicator } from '../PeriodSelector';
|
|
14
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
export default {
|
|
16
|
-
component: PeriodSelector,
|
|
17
|
-
title: 'Components/Chart/PeriodSelector'
|
|
18
|
-
};
|
|
19
|
-
const Example = _ref => {
|
|
20
|
-
let {
|
|
21
|
-
children,
|
|
22
|
-
title,
|
|
23
|
-
description
|
|
24
|
-
} = _ref;
|
|
25
|
-
return /*#__PURE__*/_jsxs(VStack, {
|
|
26
|
-
gap: 2,
|
|
27
|
-
children: [/*#__PURE__*/_jsx(TextHeadline, {
|
|
28
|
-
children: title
|
|
29
|
-
}), description, children]
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
20
|
const PeriodSelectorExample = () => {
|
|
33
21
|
const tabs = [{
|
|
34
22
|
id: '1H',
|
|
@@ -77,10 +65,31 @@ const MinWidthPeriodSelectorExample = () => {
|
|
|
77
65
|
label: 'All'
|
|
78
66
|
}];
|
|
79
67
|
const [activeTab, setActiveTab] = useState(tabs[0]);
|
|
68
|
+
return /*#__PURE__*/_jsx(PeriodSelector, {
|
|
69
|
+
activeTab: activeTab,
|
|
70
|
+
gap: 0.5,
|
|
71
|
+
onChange: tab => setActiveTab(tab),
|
|
72
|
+
tabs: tabs,
|
|
73
|
+
width: "fit-content"
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const PaddedPeriodSelectorExample = () => {
|
|
77
|
+
const tabs = [{
|
|
78
|
+
id: '1W',
|
|
79
|
+
label: '1W'
|
|
80
|
+
}, {
|
|
81
|
+
id: '1M',
|
|
82
|
+
label: '1M'
|
|
83
|
+
}, {
|
|
84
|
+
id: 'YTD',
|
|
85
|
+
label: 'YTD'
|
|
86
|
+
}];
|
|
87
|
+
const [activeTab, setActiveTab] = useState(tabs[0]);
|
|
80
88
|
return /*#__PURE__*/_jsx(PeriodSelector, {
|
|
81
89
|
activeTab: activeTab,
|
|
82
90
|
gap: 2,
|
|
83
91
|
onChange: tab => setActiveTab(tab),
|
|
92
|
+
padding: 3,
|
|
84
93
|
tabs: tabs,
|
|
85
94
|
width: "fit-content"
|
|
86
95
|
});
|
|
@@ -116,7 +125,6 @@ const LivePeriodSelectorExample = () => {
|
|
|
116
125
|
});
|
|
117
126
|
};
|
|
118
127
|
const TooManyPeriodsSelectorExample = () => {
|
|
119
|
-
const theme = useTheme();
|
|
120
128
|
const tabs = useMemo(() => [{
|
|
121
129
|
id: '1H',
|
|
122
130
|
label: /*#__PURE__*/_jsx(LiveTabLabel, {})
|
|
@@ -145,55 +153,48 @@ const TooManyPeriodsSelectorExample = () => {
|
|
|
145
153
|
const [activeTab, setActiveTab] = useState(tabs[0]);
|
|
146
154
|
const isLive = useMemo(() => (activeTab == null ? void 0 : activeTab.id) === '1H', [activeTab]);
|
|
147
155
|
const activeBackground = useMemo(() => !isLive ? 'bgPrimaryWash' : 'bgNegativeWash', [isLive]);
|
|
148
|
-
const gradientOverlayStyles = useMemo(() => [{
|
|
149
|
-
position: 'absolute',
|
|
150
|
-
right: 0,
|
|
151
|
-
bottom: 0,
|
|
152
|
-
top: 0,
|
|
153
|
-
width: theme.space[4],
|
|
154
|
-
backgroundColor: theme.color.bgPrimary,
|
|
155
|
-
opacity: 0.8
|
|
156
|
-
}], [theme.space, theme.color.bgPrimary]);
|
|
157
156
|
return /*#__PURE__*/_jsxs(HStack, {
|
|
158
157
|
alignItems: "center",
|
|
159
158
|
justifyContent: "space-between",
|
|
160
159
|
maxWidth: "100%",
|
|
161
|
-
overflow: "hidden",
|
|
162
160
|
width: "100%",
|
|
163
|
-
children: [/*#__PURE__*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
180
|
-
pointerEvents: "none",
|
|
181
|
-
style: gradientOverlayStyles
|
|
182
|
-
})]
|
|
161
|
+
children: [/*#__PURE__*/_jsx(ScrollView, {
|
|
162
|
+
horizontal: true,
|
|
163
|
+
contentContainerStyle: {
|
|
164
|
+
paddingEnd: 8,
|
|
165
|
+
flexGrow: 1
|
|
166
|
+
},
|
|
167
|
+
showsHorizontalScrollIndicator: false,
|
|
168
|
+
children: /*#__PURE__*/_jsx(PeriodSelector, {
|
|
169
|
+
activeBackground: activeBackground,
|
|
170
|
+
activeTab: activeTab,
|
|
171
|
+
gap: 1,
|
|
172
|
+
justifyContent: "flex-start",
|
|
173
|
+
onChange: setActiveTab,
|
|
174
|
+
tabs: tabs,
|
|
175
|
+
width: "fit-content"
|
|
176
|
+
})
|
|
183
177
|
}), /*#__PURE__*/_jsx(IconButton, {
|
|
184
178
|
compact: true,
|
|
185
179
|
accessibilityLabel: "Configure chart",
|
|
186
180
|
flexShrink: 0,
|
|
187
|
-
height: 36,
|
|
188
181
|
name: "filter",
|
|
189
182
|
variant: "secondary"
|
|
190
183
|
})]
|
|
191
184
|
});
|
|
192
185
|
};
|
|
193
186
|
const btcColor = assets.btc.color;
|
|
194
|
-
const BTCActiveIndicator = /*#__PURE__*/memo(props =>
|
|
195
|
-
|
|
196
|
-
|
|
187
|
+
const BTCActiveIndicator = /*#__PURE__*/memo(props => {
|
|
188
|
+
const theme = useTheme();
|
|
189
|
+
const {
|
|
190
|
+
activeTab
|
|
191
|
+
} = useTabsContext();
|
|
192
|
+
const isLive = useMemo(() => (activeTab == null ? void 0 : activeTab.id) === '1H', [activeTab]);
|
|
193
|
+
const backgroundColor = useMemo(() => isLive ? theme.color.bgNegativeWash : btcColor + "1A", [isLive, theme.color.bgNegativeWash]);
|
|
194
|
+
return /*#__PURE__*/_jsx(PeriodSelectorActiveIndicator, _extends({}, props, {
|
|
195
|
+
background: backgroundColor
|
|
196
|
+
}));
|
|
197
|
+
});
|
|
197
198
|
const BTCActiveExcludingLiveIndicator = /*#__PURE__*/memo(props => {
|
|
198
199
|
const theme = useTheme();
|
|
199
200
|
const {
|
|
@@ -205,30 +206,67 @@ const BTCActiveExcludingLiveIndicator = /*#__PURE__*/memo(props => {
|
|
|
205
206
|
background: backgroundColor
|
|
206
207
|
}));
|
|
207
208
|
});
|
|
208
|
-
const BTCTab = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((
|
|
209
|
+
const BTCTab = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
209
210
|
let {
|
|
210
211
|
label
|
|
211
|
-
} =
|
|
212
|
-
props = _objectWithoutPropertiesLoose(
|
|
212
|
+
} = _ref,
|
|
213
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
213
214
|
const {
|
|
214
215
|
activeTab
|
|
215
216
|
} = useTabsContext();
|
|
216
217
|
const isActive = (activeTab == null ? void 0 : activeTab.id) === props.id;
|
|
217
|
-
const
|
|
218
|
+
const theme = useTheme();
|
|
219
|
+
|
|
220
|
+
// If label is already a React element (like LiveTabLabel), pass it through directly
|
|
221
|
+
// For string labels, wrap with custom BTC color when active
|
|
222
|
+
const wrappedLabel = typeof label === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
223
|
+
dangerouslySetColor: isActive ? btcColor : theme.color.fg,
|
|
224
|
+
font: "label1",
|
|
225
|
+
children: label
|
|
226
|
+
}) : label;
|
|
218
227
|
return /*#__PURE__*/_jsx(SegmentedTab, _extends({
|
|
219
228
|
ref: ref,
|
|
220
|
-
label:
|
|
221
|
-
dangerouslySetColor: textColor,
|
|
222
|
-
children: label
|
|
223
|
-
})
|
|
229
|
+
label: wrappedLabel
|
|
224
230
|
}, props));
|
|
225
231
|
}));
|
|
232
|
+
const BTCLiveLabel = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
233
|
+
let {
|
|
234
|
+
label = 'LIVE',
|
|
235
|
+
font = 'label1',
|
|
236
|
+
hideDot,
|
|
237
|
+
style
|
|
238
|
+
} = _ref2,
|
|
239
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
240
|
+
const theme = useTheme();
|
|
241
|
+
const dotStyle = useMemo(() => ({
|
|
242
|
+
width: theme.space[1],
|
|
243
|
+
height: theme.space[1],
|
|
244
|
+
borderRadius: 1000,
|
|
245
|
+
marginRight: theme.space[0.75],
|
|
246
|
+
backgroundColor: btcColor
|
|
247
|
+
}), [theme.space]);
|
|
248
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
249
|
+
ref: ref,
|
|
250
|
+
style: [{
|
|
251
|
+
flexDirection: 'row',
|
|
252
|
+
alignItems: 'center'
|
|
253
|
+
}, style],
|
|
254
|
+
children: [!hideDot && /*#__PURE__*/_jsx(View, {
|
|
255
|
+
style: dotStyle
|
|
256
|
+
}), /*#__PURE__*/_jsx(Text, _extends({
|
|
257
|
+
font: font,
|
|
258
|
+
style: {
|
|
259
|
+
color: btcColor
|
|
260
|
+
}
|
|
261
|
+
}, props, {
|
|
262
|
+
children: label
|
|
263
|
+
}))]
|
|
264
|
+
});
|
|
265
|
+
}));
|
|
226
266
|
const ColoredPeriodSelectorExample = () => {
|
|
227
267
|
const tabs = [{
|
|
228
268
|
id: '1H',
|
|
229
|
-
label: /*#__PURE__*/_jsx(
|
|
230
|
-
dangerouslySetColor: btcColor
|
|
231
|
-
})
|
|
269
|
+
label: /*#__PURE__*/_jsx(BTCLiveLabel, {})
|
|
232
270
|
}, {
|
|
233
271
|
id: '1D',
|
|
234
272
|
label: '1D'
|
|
@@ -283,12 +321,100 @@ const ColoredExcludingLivePeriodSelectorExample = () => {
|
|
|
283
321
|
tabs: tabs
|
|
284
322
|
});
|
|
285
323
|
};
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
324
|
+
const ColoredIcon = /*#__PURE__*/memo(_ref3 => {
|
|
325
|
+
let {
|
|
326
|
+
tabId,
|
|
327
|
+
name
|
|
328
|
+
} = _ref3;
|
|
329
|
+
const {
|
|
330
|
+
activeTab
|
|
331
|
+
} = useTabsContext();
|
|
332
|
+
const isActive = (activeTab == null ? void 0 : activeTab.id) === tabId;
|
|
333
|
+
const theme = useTheme();
|
|
334
|
+
const progress = useSharedValue(isActive ? 1 : 0);
|
|
335
|
+
const [color, setColor] = useState(isActive ? theme.color.fgPrimary : theme.color.fg);
|
|
336
|
+
useEffect(() => {
|
|
337
|
+
progress.value = withSpring(isActive ? 1 : 0, tabsSpringConfig);
|
|
338
|
+
}, [isActive, progress]);
|
|
339
|
+
useAnimatedReaction(() => interpolateColor(progress.value, [0, 1], [theme.color.fg, theme.color.fgPrimary]), newColor => {
|
|
340
|
+
runOnJS(setColor)(newColor);
|
|
341
|
+
});
|
|
342
|
+
return /*#__PURE__*/_jsx(Icon, {
|
|
343
|
+
active: true,
|
|
344
|
+
name: name,
|
|
345
|
+
size: "s",
|
|
346
|
+
styles: {
|
|
347
|
+
icon: {
|
|
348
|
+
color
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
function IconsPeriodSelectorExample() {
|
|
354
|
+
const theme = useTheme();
|
|
355
|
+
const tabs = [{
|
|
356
|
+
id: 'buy',
|
|
357
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
358
|
+
name: "chartLine",
|
|
359
|
+
tabId: "buy"
|
|
360
|
+
})
|
|
361
|
+
}, {
|
|
362
|
+
id: 'sell',
|
|
363
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
364
|
+
name: "chartCandles",
|
|
365
|
+
tabId: "sell"
|
|
366
|
+
})
|
|
367
|
+
}, {
|
|
368
|
+
id: 'convert',
|
|
369
|
+
label: /*#__PURE__*/_jsx(ColoredIcon, {
|
|
370
|
+
name: "chartBar",
|
|
371
|
+
tabId: "convert"
|
|
292
372
|
})
|
|
373
|
+
}];
|
|
374
|
+
const [activeTab, updateActiveTab] = useState(tabs[0]);
|
|
375
|
+
const handleChange = useCallback(activeTab => updateActiveTab(activeTab), []);
|
|
376
|
+
return /*#__PURE__*/_jsx(PeriodSelector, {
|
|
377
|
+
accessibilityLabel: "Switch token action views",
|
|
378
|
+
activeTab: activeTab,
|
|
379
|
+
borderRadius: 300,
|
|
380
|
+
gap: 0.5,
|
|
381
|
+
onChange: handleChange,
|
|
382
|
+
padding: 0.5,
|
|
383
|
+
styles: {
|
|
384
|
+
activeIndicator: {
|
|
385
|
+
borderRadius: theme.borderRadius[200]
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
tabs: tabs,
|
|
389
|
+
width: "fit-content"
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
export default function All() {
|
|
393
|
+
return /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
394
|
+
children: [/*#__PURE__*/_jsx(Example, {
|
|
395
|
+
title: "Basic",
|
|
396
|
+
children: /*#__PURE__*/_jsx(PeriodSelectorExample, {})
|
|
397
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
398
|
+
title: "Min Width",
|
|
399
|
+
children: /*#__PURE__*/_jsx(MinWidthPeriodSelectorExample, {})
|
|
400
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
401
|
+
title: "Live Period",
|
|
402
|
+
children: /*#__PURE__*/_jsx(LivePeriodSelectorExample, {})
|
|
403
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
404
|
+
title: "Too Many Periods",
|
|
405
|
+
children: /*#__PURE__*/_jsx(TooManyPeriodsSelectorExample, {})
|
|
406
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
407
|
+
title: "Colored (BTC)",
|
|
408
|
+
children: /*#__PURE__*/_jsx(ColoredPeriodSelectorExample, {})
|
|
409
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
410
|
+
title: "Colored Excluding Live",
|
|
411
|
+
children: /*#__PURE__*/_jsx(ColoredExcludingLivePeriodSelectorExample, {})
|
|
412
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
413
|
+
title: "With Padding",
|
|
414
|
+
children: /*#__PURE__*/_jsx(PaddedPeriodSelectorExample, {})
|
|
415
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
416
|
+
title: "With Icons",
|
|
417
|
+
children: /*#__PURE__*/_jsx(IconsPeriodSelectorExample, {})
|
|
418
|
+
})]
|
|
293
419
|
});
|
|
294
|
-
}
|
|
420
|
+
}
|
package/esm/chart/area/Area.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { memo, useMemo } from 'react';
|
|
2
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
3
2
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
4
3
|
import { getAreaPath } from '../utils';
|
|
5
4
|
import { DottedArea } from './DottedArea';
|
|
@@ -7,37 +6,31 @@ import { GradientArea } from './GradientArea';
|
|
|
7
6
|
import { SolidArea } from './SolidArea';
|
|
8
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
8
|
export const Area = /*#__PURE__*/memo(_ref => {
|
|
10
|
-
var _ref2;
|
|
11
9
|
let {
|
|
12
10
|
seriesId,
|
|
13
|
-
curve = '
|
|
11
|
+
curve = 'bump',
|
|
14
12
|
type = 'solid',
|
|
15
|
-
AreaComponent:
|
|
16
|
-
fill:
|
|
13
|
+
AreaComponent: AreaComponentProp,
|
|
14
|
+
fill: fillProp,
|
|
17
15
|
fillOpacity = 1,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
baseline,
|
|
17
|
+
connectNulls,
|
|
18
|
+
gradient: gradientProp,
|
|
19
|
+
transitions,
|
|
20
|
+
transition,
|
|
21
|
+
animate
|
|
21
22
|
} = _ref;
|
|
22
|
-
const theme = useTheme();
|
|
23
23
|
const {
|
|
24
24
|
getSeries,
|
|
25
25
|
getSeriesData,
|
|
26
26
|
getXScale,
|
|
27
27
|
getYScale,
|
|
28
|
-
getXAxis
|
|
29
|
-
drawingArea
|
|
28
|
+
getXAxis
|
|
30
29
|
} = useCartesianChartContext();
|
|
31
|
-
|
|
32
|
-
// Get sourceData from series (using stacked data if available)
|
|
33
30
|
const matchedSeries = useMemo(() => getSeries(seriesId), [seriesId, getSeries]);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const sourceData = useMemo(() =>
|
|
37
|
-
return getSeriesData(seriesId) || null;
|
|
38
|
-
}, [seriesId, getSeriesData]);
|
|
39
|
-
|
|
40
|
-
// Get scales and axes for this series
|
|
31
|
+
const gradient = useMemo(() => gradientProp != null ? gradientProp : matchedSeries == null ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries == null ? void 0 : matchedSeries.gradient]);
|
|
32
|
+
const fill = useMemo(() => fillProp != null ? fillProp : matchedSeries == null ? void 0 : matchedSeries.color, [fillProp, matchedSeries == null ? void 0 : matchedSeries.color]);
|
|
33
|
+
const sourceData = useMemo(() => getSeriesData(seriesId), [seriesId, getSeriesData]);
|
|
41
34
|
const xAxis = getXAxis();
|
|
42
35
|
const xScale = getXScale();
|
|
43
36
|
const yScale = getYScale(matchedSeries == null ? void 0 : matchedSeries.yAxisId);
|
|
@@ -51,35 +44,34 @@ export const Area = /*#__PURE__*/memo(_ref => {
|
|
|
51
44
|
xScale,
|
|
52
45
|
yScale,
|
|
53
46
|
curve,
|
|
54
|
-
xData
|
|
47
|
+
xData,
|
|
48
|
+
connectNulls
|
|
55
49
|
});
|
|
56
|
-
}, [sourceData, xScale, yScale, curve, xAxis == null ? void 0 : xAxis.data]);
|
|
50
|
+
}, [sourceData, xScale, yScale, curve, xAxis == null ? void 0 : xAxis.data, connectNulls]);
|
|
57
51
|
const AreaComponent = useMemo(() => {
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
52
|
+
if (AreaComponentProp) {
|
|
53
|
+
return AreaComponentProp;
|
|
60
54
|
}
|
|
61
55
|
switch (type) {
|
|
62
|
-
case 'solid':
|
|
63
|
-
return SolidArea;
|
|
64
56
|
case 'dotted':
|
|
65
57
|
return DottedArea;
|
|
66
58
|
case 'gradient':
|
|
67
|
-
default:
|
|
68
59
|
return GradientArea;
|
|
60
|
+
case 'solid':
|
|
61
|
+
default:
|
|
62
|
+
return SolidArea;
|
|
69
63
|
}
|
|
70
|
-
}, [
|
|
71
|
-
if (!xScale || !yScale || !sourceData || !area)
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
const fill = (_ref2 = specifiedFill != null ? specifiedFill : matchedSeries == null ? void 0 : matchedSeries.color) != null ? _ref2 : theme.color.fgPrimary;
|
|
64
|
+
}, [AreaComponentProp, type]);
|
|
65
|
+
if (!xScale || !yScale || !sourceData || !area) return;
|
|
75
66
|
return /*#__PURE__*/_jsx(AreaComponent, {
|
|
67
|
+
animate: animate,
|
|
76
68
|
baseline: baseline,
|
|
77
|
-
clipRect: drawingArea,
|
|
78
69
|
d: area,
|
|
79
70
|
fill: fill,
|
|
80
71
|
fillOpacity: fillOpacity,
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
gradient: gradient,
|
|
73
|
+
transition: transition,
|
|
74
|
+
transitions: transitions,
|
|
83
75
|
yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId
|
|
84
76
|
});
|
|
85
77
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
|
|
1
|
+
const _excluded = ["series", "stacked", "AreaComponent", "curve", "fillOpacity", "type", "connectNulls", "transition", "LineComponent", "strokeWidth", "showXAxis", "showYAxis", "showLines", "lineType", "xAxis", "yAxis", "inset", "children"],
|
|
2
2
|
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
|
|
3
3
|
_excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
|
|
4
4
|
_excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId"],
|
|
5
|
-
_excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId"];
|
|
5
|
+
_excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "type", "lineType"];
|
|
6
6
|
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); }
|
|
7
7
|
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; }
|
|
8
8
|
import { forwardRef, memo, useMemo } from 'react';
|
|
@@ -20,6 +20,8 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
20
20
|
curve,
|
|
21
21
|
fillOpacity,
|
|
22
22
|
type,
|
|
23
|
+
connectNulls,
|
|
24
|
+
transition,
|
|
23
25
|
LineComponent,
|
|
24
26
|
strokeWidth,
|
|
25
27
|
showXAxis,
|
|
@@ -28,11 +30,11 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
28
30
|
lineType = 'solid',
|
|
29
31
|
xAxis,
|
|
30
32
|
yAxis,
|
|
31
|
-
inset
|
|
33
|
+
inset,
|
|
32
34
|
children
|
|
33
35
|
} = _ref,
|
|
34
36
|
chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
35
|
-
const calculatedInset = useMemo(() => getChartInset(
|
|
37
|
+
const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
|
|
36
38
|
|
|
37
39
|
// Convert AreaSeries to Series for Chart context
|
|
38
40
|
const chartSeries = useMemo(() => {
|
|
@@ -41,6 +43,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
41
43
|
data: s.data,
|
|
42
44
|
label: s.label,
|
|
43
45
|
color: s.color,
|
|
46
|
+
gradient: s.gradient,
|
|
44
47
|
yAxisId: s.yAxisId,
|
|
45
48
|
stackId: s.stackId
|
|
46
49
|
}));
|
|
@@ -120,27 +123,29 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
120
123
|
areaPropsFromSeries = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
121
124
|
return /*#__PURE__*/_jsx(Area, _extends({
|
|
122
125
|
AreaComponent: AreaComponent,
|
|
126
|
+
connectNulls: connectNulls,
|
|
123
127
|
curve: curve,
|
|
124
128
|
fillOpacity: fillOpacity,
|
|
125
129
|
seriesId: id,
|
|
130
|
+
transition: transition,
|
|
126
131
|
type: type
|
|
127
132
|
}, areaPropsFromSeries), id);
|
|
128
133
|
}), showLines && (series == null ? void 0 : series.map(_ref5 => {
|
|
129
134
|
let {
|
|
130
135
|
id,
|
|
131
|
-
|
|
136
|
+
// Area type (don't pass to Line)
|
|
137
|
+
lineType: seriesLineType
|
|
132
138
|
} = _ref5,
|
|
133
|
-
|
|
139
|
+
otherPropsFromSeries = _objectWithoutPropertiesLoose(_ref5, _excluded5);
|
|
134
140
|
return /*#__PURE__*/_jsx(Line, _extends({
|
|
135
141
|
LineComponent: LineComponent,
|
|
142
|
+
connectNulls: connectNulls,
|
|
136
143
|
curve: curve,
|
|
137
|
-
seriesId: id
|
|
138
|
-
,
|
|
139
|
-
stroke: color // Default to series color
|
|
140
|
-
,
|
|
144
|
+
seriesId: id,
|
|
141
145
|
strokeWidth: strokeWidth,
|
|
142
|
-
|
|
143
|
-
|
|
146
|
+
transition: transition,
|
|
147
|
+
type: seriesLineType != null ? seriesLineType : lineType
|
|
148
|
+
}, otherPropsFromSeries), id);
|
|
144
149
|
})), children]
|
|
145
150
|
}));
|
|
146
151
|
}));
|