@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.
Files changed (187) hide show
  1. package/CHANGELOG.md +60 -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 +2 -2
  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 +86 -118
  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 +64 -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 +68 -20
  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 +172 -43
  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/axis.d.ts +25 -1
  92. package/dts/chart/utils/axis.d.ts.map +1 -1
  93. package/dts/chart/utils/chart.d.ts +34 -7
  94. package/dts/chart/utils/chart.d.ts.map +1 -1
  95. package/dts/chart/utils/context.d.ts +28 -7
  96. package/dts/chart/utils/context.d.ts.map +1 -1
  97. package/dts/chart/utils/gradient.d.ts +117 -0
  98. package/dts/chart/utils/gradient.d.ts.map +1 -0
  99. package/dts/chart/utils/index.d.ts +3 -0
  100. package/dts/chart/utils/index.d.ts.map +1 -1
  101. package/dts/chart/utils/path.d.ts +53 -0
  102. package/dts/chart/utils/path.d.ts.map +1 -1
  103. package/dts/chart/utils/point.d.ts +71 -7
  104. package/dts/chart/utils/point.d.ts.map +1 -1
  105. package/dts/chart/utils/scale.d.ts +102 -0
  106. package/dts/chart/utils/scale.d.ts.map +1 -1
  107. package/dts/chart/utils/scrubber.d.ts +39 -0
  108. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  109. package/dts/chart/utils/transition.d.ts +140 -0
  110. package/dts/chart/utils/transition.d.ts.map +1 -0
  111. package/esm/chart/CartesianChart.js +164 -70
  112. package/esm/chart/ChartContextBridge.js +148 -0
  113. package/esm/chart/Path.js +198 -113
  114. package/esm/chart/PeriodSelector.js +2 -2
  115. package/esm/chart/__stories__/CartesianChart.stories.js +378 -131
  116. package/esm/chart/__stories__/Chart.stories.js +2 -4
  117. package/esm/chart/__stories__/PeriodSelector.stories.js +103 -75
  118. package/esm/chart/area/Area.js +25 -35
  119. package/esm/chart/area/AreaChart.js +17 -12
  120. package/esm/chart/area/DottedArea.js +61 -109
  121. package/esm/chart/area/GradientArea.js +35 -91
  122. package/esm/chart/area/SolidArea.js +22 -8
  123. package/esm/chart/area/__stories__/AreaChart.stories.js +1 -1
  124. package/esm/chart/axis/Axis.js +5 -39
  125. package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
  126. package/esm/chart/axis/XAxis.js +148 -66
  127. package/esm/chart/axis/YAxis.js +149 -65
  128. package/esm/chart/axis/__stories__/Axis.stories.js +259 -1
  129. package/esm/chart/axis/index.js +1 -0
  130. package/esm/chart/bar/Bar.js +3 -1
  131. package/esm/chart/bar/BarChart.js +15 -37
  132. package/esm/chart/bar/BarPlot.js +41 -35
  133. package/esm/chart/bar/BarStack.js +75 -38
  134. package/esm/chart/bar/BarStackGroup.js +6 -16
  135. package/esm/chart/bar/DefaultBar.js +26 -48
  136. package/esm/chart/bar/DefaultBarStack.js +23 -58
  137. package/esm/chart/bar/__stories__/BarChart.stories.js +502 -77
  138. package/esm/chart/gradient/Gradient.js +53 -0
  139. package/esm/chart/gradient/index.js +1 -0
  140. package/esm/chart/index.js +3 -1
  141. package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
  142. package/esm/chart/line/DottedLine.js +29 -14
  143. package/esm/chart/line/Line.js +106 -67
  144. package/esm/chart/line/LineChart.js +20 -14
  145. package/esm/chart/line/ReferenceLine.js +80 -63
  146. package/esm/chart/line/SolidLine.js +25 -10
  147. package/esm/chart/line/__stories__/LineChart.stories.js +2101 -1977
  148. package/esm/chart/line/__stories__/ReferenceLine.stories.js +83 -28
  149. package/esm/chart/line/index.js +1 -1
  150. package/esm/chart/point/DefaultPointLabel.js +39 -0
  151. package/esm/chart/point/Point.js +188 -0
  152. package/esm/chart/point/index.js +2 -0
  153. package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
  154. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
  155. package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
  156. package/esm/chart/scrubber/Scrubber.js +126 -146
  157. package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
  158. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
  159. package/esm/chart/scrubber/ScrubberProvider.js +46 -54
  160. package/esm/chart/scrubber/index.js +3 -1
  161. package/esm/chart/text/ChartText.js +242 -174
  162. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +6 -5
  163. package/esm/chart/text/index.js +1 -1
  164. package/esm/chart/utils/axis.js +45 -29
  165. package/esm/chart/utils/chart.js +44 -3
  166. package/esm/chart/utils/gradient.js +305 -0
  167. package/esm/chart/utils/index.js +3 -0
  168. package/esm/chart/utils/path.js +76 -8
  169. package/esm/chart/utils/point.js +171 -17
  170. package/esm/chart/utils/scale.js +242 -2
  171. package/esm/chart/utils/scrubber.js +139 -0
  172. package/esm/chart/utils/transition.js +185 -0
  173. package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
  174. package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
  175. package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +51 -26
  176. package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
  177. package/package.json +15 -9
  178. package/dts/chart/Point.d.ts +0 -103
  179. package/dts/chart/Point.d.ts.map +0 -1
  180. package/dts/chart/line/GradientLine.d.ts +0 -45
  181. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  182. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -75
  183. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  184. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  185. package/esm/chart/Point.js +0 -111
  186. package/esm/chart/line/GradientLine.js +0 -62
  187. package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
@@ -1,34 +1,19 @@
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
5
  import { forwardRef, memo, useMemo, useState } from 'react';
5
- import { View } from 'react-native';
6
+ import { ScrollView, View } from 'react-native';
6
7
  import { assets } from '@coinbase/cds-common/internal/data/assets';
7
8
  import { useTabsContext } from '@coinbase/cds-common/tabs/TabsContext';
8
9
  import { IconButton } from '@coinbase/cds-mobile/buttons';
10
+ import { Example, ExampleScreen } from '@coinbase/cds-mobile/examples/ExampleScreen';
9
11
  import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
10
- import { Box, HStack, VStack } from '@coinbase/cds-mobile/layout';
12
+ import { HStack } from '@coinbase/cds-mobile/layout';
11
13
  import { SegmentedTab } from '@coinbase/cds-mobile/tabs/SegmentedTab';
12
- import { TextHeadline, TextLabel1 } from '@coinbase/cds-mobile/typography';
14
+ import { Text } from '@coinbase/cds-mobile/typography';
13
15
  import { LiveTabLabel, PeriodSelector, PeriodSelectorActiveIndicator } from '../PeriodSelector';
14
16
  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
17
  const PeriodSelectorExample = () => {
33
18
  const tabs = [{
34
19
  id: '1H',
@@ -79,7 +64,7 @@ const MinWidthPeriodSelectorExample = () => {
79
64
  const [activeTab, setActiveTab] = useState(tabs[0]);
80
65
  return /*#__PURE__*/_jsx(PeriodSelector, {
81
66
  activeTab: activeTab,
82
- gap: 2,
67
+ gap: 0.5,
83
68
  onChange: tab => setActiveTab(tab),
84
69
  tabs: tabs,
85
70
  width: "fit-content"
@@ -116,7 +101,6 @@ const LivePeriodSelectorExample = () => {
116
101
  });
117
102
  };
118
103
  const TooManyPeriodsSelectorExample = () => {
119
- const theme = useTheme();
120
104
  const tabs = useMemo(() => [{
121
105
  id: '1H',
122
106
  label: /*#__PURE__*/_jsx(LiveTabLabel, {})
@@ -145,55 +129,48 @@ const TooManyPeriodsSelectorExample = () => {
145
129
  const [activeTab, setActiveTab] = useState(tabs[0]);
146
130
  const isLive = useMemo(() => (activeTab == null ? void 0 : activeTab.id) === '1H', [activeTab]);
147
131
  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
132
  return /*#__PURE__*/_jsxs(HStack, {
158
133
  alignItems: "center",
159
134
  justifyContent: "space-between",
160
135
  maxWidth: "100%",
161
- overflow: "hidden",
162
136
  width: "100%",
163
- children: [/*#__PURE__*/_jsxs(Box, {
164
- flexGrow: 1,
165
- overflow: "hidden",
166
- position: "relative",
167
- children: [/*#__PURE__*/_jsx(Box, {
168
- overflow: "scroll",
169
- paddingEnd: 2,
170
- children: /*#__PURE__*/_jsx(PeriodSelector, {
171
- activeBackground: activeBackground,
172
- activeTab: activeTab,
173
- gap: 1,
174
- justifyContent: "flex-start",
175
- onChange: setActiveTab,
176
- tabs: tabs,
177
- width: "fit-content"
178
- })
179
- }), /*#__PURE__*/_jsx(View, {
180
- pointerEvents: "none",
181
- style: gradientOverlayStyles
182
- })]
137
+ children: [/*#__PURE__*/_jsx(ScrollView, {
138
+ horizontal: true,
139
+ contentContainerStyle: {
140
+ paddingEnd: 8,
141
+ flexGrow: 1
142
+ },
143
+ showsHorizontalScrollIndicator: false,
144
+ children: /*#__PURE__*/_jsx(PeriodSelector, {
145
+ activeBackground: activeBackground,
146
+ activeTab: activeTab,
147
+ gap: 1,
148
+ justifyContent: "flex-start",
149
+ onChange: setActiveTab,
150
+ tabs: tabs,
151
+ width: "fit-content"
152
+ })
183
153
  }), /*#__PURE__*/_jsx(IconButton, {
184
154
  compact: true,
185
155
  accessibilityLabel: "Configure chart",
186
156
  flexShrink: 0,
187
- height: 36,
188
157
  name: "filter",
189
158
  variant: "secondary"
190
159
  })]
191
160
  });
192
161
  };
193
162
  const btcColor = assets.btc.color;
194
- const BTCActiveIndicator = /*#__PURE__*/memo(props => /*#__PURE__*/_jsx(PeriodSelectorActiveIndicator, _extends({}, props, {
195
- background: btcColor + "1A"
196
- })));
163
+ const BTCActiveIndicator = /*#__PURE__*/memo(props => {
164
+ const theme = useTheme();
165
+ const {
166
+ activeTab
167
+ } = useTabsContext();
168
+ const isLive = useMemo(() => (activeTab == null ? void 0 : activeTab.id) === '1H', [activeTab]);
169
+ const backgroundColor = useMemo(() => isLive ? theme.color.bgNegativeWash : btcColor + "1A", [isLive, theme.color.bgNegativeWash]);
170
+ return /*#__PURE__*/_jsx(PeriodSelectorActiveIndicator, _extends({}, props, {
171
+ background: backgroundColor
172
+ }));
173
+ });
197
174
  const BTCActiveExcludingLiveIndicator = /*#__PURE__*/memo(props => {
198
175
  const theme = useTheme();
199
176
  const {
@@ -205,30 +182,67 @@ const BTCActiveExcludingLiveIndicator = /*#__PURE__*/memo(props => {
205
182
  background: backgroundColor
206
183
  }));
207
184
  });
208
- const BTCTab = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
185
+ const BTCTab = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
209
186
  let {
210
187
  label
211
- } = _ref2,
212
- props = _objectWithoutPropertiesLoose(_ref2, _excluded);
188
+ } = _ref,
189
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
213
190
  const {
214
191
  activeTab
215
192
  } = useTabsContext();
216
193
  const isActive = (activeTab == null ? void 0 : activeTab.id) === props.id;
217
- const textColor = isActive ? btcColor : undefined;
194
+ const theme = useTheme();
195
+
196
+ // If label is already a React element (like LiveTabLabel), pass it through directly
197
+ // For string labels, wrap with custom BTC color when active
198
+ const wrappedLabel = typeof label === 'string' ? /*#__PURE__*/_jsx(Text, {
199
+ dangerouslySetColor: isActive ? btcColor : theme.color.fg,
200
+ font: "label1",
201
+ children: label
202
+ }) : label;
218
203
  return /*#__PURE__*/_jsx(SegmentedTab, _extends({
219
204
  ref: ref,
220
- label: /*#__PURE__*/_jsx(TextLabel1, {
221
- dangerouslySetColor: textColor,
222
- children: label
223
- })
205
+ label: wrappedLabel
224
206
  }, props));
225
207
  }));
208
+ const BTCLiveLabel = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
209
+ let {
210
+ label = 'LIVE',
211
+ font = 'label1',
212
+ hideDot,
213
+ style
214
+ } = _ref2,
215
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
216
+ const theme = useTheme();
217
+ const dotStyle = useMemo(() => ({
218
+ width: theme.space[1],
219
+ height: theme.space[1],
220
+ borderRadius: 1000,
221
+ marginRight: theme.space[0.75],
222
+ backgroundColor: btcColor
223
+ }), [theme.space]);
224
+ return /*#__PURE__*/_jsxs(View, {
225
+ ref: ref,
226
+ style: [{
227
+ flexDirection: 'row',
228
+ alignItems: 'center'
229
+ }, style],
230
+ children: [!hideDot && /*#__PURE__*/_jsx(View, {
231
+ style: dotStyle
232
+ }), /*#__PURE__*/_jsx(Text, _extends({
233
+ font: font,
234
+ style: {
235
+ color: btcColor
236
+ }
237
+ }, props, {
238
+ children: label
239
+ }))]
240
+ });
241
+ }));
226
242
  const ColoredPeriodSelectorExample = () => {
227
243
  const tabs = [{
228
244
  id: '1H',
229
- label: /*#__PURE__*/_jsx(LiveTabLabel, {
230
- dangerouslySetColor: btcColor
231
- })
245
+ label: /*#__PURE__*/_jsx(BTCLiveLabel, {})
232
246
  }, {
233
247
  id: '1D',
234
248
  label: '1D'
@@ -283,12 +297,26 @@ const ColoredExcludingLivePeriodSelectorExample = () => {
283
297
  tabs: tabs
284
298
  });
285
299
  };
286
- export const All = () => {
287
- return /*#__PURE__*/_jsx(VStack, {
288
- gap: 2,
289
- children: /*#__PURE__*/_jsx(Example, {
290
- title: "Basic Example",
300
+ export default function All() {
301
+ return /*#__PURE__*/_jsxs(ExampleScreen, {
302
+ children: [/*#__PURE__*/_jsx(Example, {
303
+ title: "Basic",
291
304
  children: /*#__PURE__*/_jsx(PeriodSelectorExample, {})
292
- })
305
+ }), /*#__PURE__*/_jsx(Example, {
306
+ title: "Min Width",
307
+ children: /*#__PURE__*/_jsx(MinWidthPeriodSelectorExample, {})
308
+ }), /*#__PURE__*/_jsx(Example, {
309
+ title: "Live Period",
310
+ children: /*#__PURE__*/_jsx(LivePeriodSelectorExample, {})
311
+ }), /*#__PURE__*/_jsx(Example, {
312
+ title: "Too Many Periods",
313
+ children: /*#__PURE__*/_jsx(TooManyPeriodsSelectorExample, {})
314
+ }), /*#__PURE__*/_jsx(Example, {
315
+ title: "Colored (BTC)",
316
+ children: /*#__PURE__*/_jsx(ColoredPeriodSelectorExample, {})
317
+ }), /*#__PURE__*/_jsx(Example, {
318
+ title: "Colored Excluding Live",
319
+ children: /*#__PURE__*/_jsx(ColoredExcludingLivePeriodSelectorExample, {})
320
+ })]
293
321
  });
294
- };
322
+ }
@@ -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,30 @@ 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 = 'linear',
11
+ curve = 'bump',
14
12
  type = 'solid',
15
- AreaComponent: SelectedAreaComponent,
16
- fill: specifiedFill,
13
+ AreaComponent: AreaComponentProp,
14
+ fill: fillProp,
17
15
  fillOpacity = 1,
18
- stroke,
19
- strokeWidth,
20
- baseline
16
+ baseline,
17
+ connectNulls,
18
+ gradient: gradientProp,
19
+ transition,
20
+ animate
21
21
  } = _ref;
22
- const theme = useTheme();
23
22
  const {
24
23
  getSeries,
25
24
  getSeriesData,
26
25
  getXScale,
27
26
  getYScale,
28
- getXAxis,
29
- drawingArea
27
+ getXAxis
30
28
  } = useCartesianChartContext();
31
-
32
- // Get sourceData from series (using stacked data if available)
33
29
  const matchedSeries = useMemo(() => getSeries(seriesId), [seriesId, getSeries]);
34
-
35
- // Check for stacked data first, then fall back to raw data
36
- const sourceData = useMemo(() => {
37
- return getSeriesData(seriesId) || null;
38
- }, [seriesId, getSeriesData]);
39
-
40
- // Get scales and axes for this series
30
+ const gradient = useMemo(() => gradientProp != null ? gradientProp : matchedSeries == null ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries == null ? void 0 : matchedSeries.gradient]);
31
+ const fill = useMemo(() => fillProp != null ? fillProp : matchedSeries == null ? void 0 : matchedSeries.color, [fillProp, matchedSeries == null ? void 0 : matchedSeries.color]);
32
+ const sourceData = useMemo(() => getSeriesData(seriesId), [seriesId, getSeriesData]);
41
33
  const xAxis = getXAxis();
42
34
  const xScale = getXScale();
43
35
  const yScale = getYScale(matchedSeries == null ? void 0 : matchedSeries.yAxisId);
@@ -51,35 +43,33 @@ export const Area = /*#__PURE__*/memo(_ref => {
51
43
  xScale,
52
44
  yScale,
53
45
  curve,
54
- xData
46
+ xData,
47
+ connectNulls
55
48
  });
56
- }, [sourceData, xScale, yScale, curve, xAxis == null ? void 0 : xAxis.data]);
49
+ }, [sourceData, xScale, yScale, curve, xAxis == null ? void 0 : xAxis.data, connectNulls]);
57
50
  const AreaComponent = useMemo(() => {
58
- if (SelectedAreaComponent) {
59
- return SelectedAreaComponent;
51
+ if (AreaComponentProp) {
52
+ return AreaComponentProp;
60
53
  }
61
54
  switch (type) {
62
- case 'solid':
63
- return SolidArea;
64
55
  case 'dotted':
65
56
  return DottedArea;
66
57
  case 'gradient':
67
- default:
68
58
  return GradientArea;
59
+ case 'solid':
60
+ default:
61
+ return SolidArea;
69
62
  }
70
- }, [SelectedAreaComponent, type]);
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;
63
+ }, [AreaComponentProp, type]);
64
+ if (!xScale || !yScale || !sourceData || !area) return;
75
65
  return /*#__PURE__*/_jsx(AreaComponent, {
66
+ animate: animate,
76
67
  baseline: baseline,
77
- clipRect: drawingArea,
78
68
  d: area,
79
69
  fill: fill,
80
70
  fillOpacity: fillOpacity,
81
- stroke: stroke,
82
- strokeWidth: strokeWidth,
71
+ gradient: gradient,
72
+ transition: transition,
83
73
  yAxisId: matchedSeries == null ? void 0 : matchedSeries.yAxisId
84
74
  });
85
75
  });
@@ -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: userInset,
33
+ inset,
32
34
  children
33
35
  } = _ref,
34
36
  chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
35
- const calculatedInset = useMemo(() => getChartInset(userInset, defaultChartInset), [userInset]);
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
- color
136
+ // Area type (don't pass to Line)
137
+ lineType: seriesLineType
132
138
  } = _ref5,
133
- linePropsFromSeries = _objectWithoutPropertiesLoose(_ref5, _excluded5);
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 // Line component now handles stacked data automatically
138
- ,
139
- stroke: color // Default to series color
140
- ,
144
+ seriesId: id,
141
145
  strokeWidth: strokeWidth,
142
- type: lineType
143
- }, linePropsFromSeries), id + "-line");
146
+ transition: transition,
147
+ type: seriesLineType != null ? seriesLineType : lineType
148
+ }, otherPropsFromSeries), id);
144
149
  })), children]
145
150
  }));
146
151
  }));
@@ -1,128 +1,80 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "clipRect"];
1
+ const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transition"];
2
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
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 { Circle, Defs, G, LinearGradient, Mask, Pattern, Stop } from 'react-native-svg';
4
+ import { memo, useMemo } from 'react';
6
5
  import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
6
+ import { Group, Skia } from '@shopify/react-native-skia';
7
7
  import { useCartesianChartContext } from '../ChartProvider';
8
+ import { Gradient } from '../gradient';
8
9
  import { Path } from '../Path';
9
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { createGradient, getBaseline } from '../utils';
11
+ import { getDottedAreaPath } from '../utils/path';
12
+ import { usePathTransition } from '../utils/transition';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ /**
15
+ * A customizable dotted area gradient component.
16
+ * When no gradient is provided, renders a default gradient based
17
+ * on the fill color and peak/baseline opacities.
18
+ */
10
19
  export const DottedArea = /*#__PURE__*/memo(_ref => {
11
20
  let {
12
21
  d,
13
- fill,
14
- fillOpacity = 1,
22
+ fill: fillProp,
15
23
  patternSize = 4,
16
24
  dotSize = 1,
17
25
  peakOpacity = 1,
18
26
  baselineOpacity = 0,
19
27
  baseline,
20
28
  yAxisId,
21
- clipRect
29
+ gradient: gradientProp,
30
+ animate: animateProp,
31
+ transition
22
32
  } = _ref,
23
33
  pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
24
34
  const theme = useTheme();
25
- const context = useCartesianChartContext();
26
- const patternId = useId();
27
- const gradientId = useId();
28
- const maskId = useId();
29
- const dotCenterPosition = patternSize / 2;
30
-
31
- // Get the y-scale for the specified axis (or default)
32
- const yScale = context.getYScale(yAxisId);
33
- const yRange = yScale == null ? void 0 : yScale.range();
34
- const yDomain = yScale == null ? void 0 : yScale.domain();
35
-
36
- // Use chart range if available, otherwise fall back to percentage
37
- const useUserSpaceUnits = yRange !== undefined;
38
-
39
- // Auto-calculate baseline position based on domain
40
- let baselinePosition;
41
- let baselinePercentage;
42
- if (yScale && yDomain) {
43
- const [minValue, maxValue] = yDomain;
44
- let dataBaseline;
45
- if (minValue >= 0) {
46
- // All positive: baseline at min
47
- dataBaseline = minValue;
48
- } else if (maxValue <= 0) {
49
- // All negative: baseline at max
50
- dataBaseline = maxValue;
51
- } else {
52
- // Crosses zero: baseline at 0
53
- dataBaseline = 0;
54
- }
55
- if (useUserSpaceUnits && yRange) {
56
- // Get the actual y coordinate for the baseline
57
- const scaledValue = yScale(baseline != null ? baseline : dataBaseline);
58
- if (typeof scaledValue === 'number') {
59
- baselinePosition = scaledValue;
60
- }
61
- } else {
62
- // Calculate percentage position
63
- baselinePercentage = (maxValue - (baseline != null ? baseline : dataBaseline)) / (maxValue - minValue) * 100 + "%";
64
- }
65
- }
66
- const gradientY1 = useUserSpaceUnits && yRange ? String(yRange[1]) : '0%';
67
- const gradientY2 = useUserSpaceUnits && yRange ? String(yRange[0]) : '100%';
68
- const effectiveFill = fill != null ? fill : theme.color.fgPrimary;
69
- return /*#__PURE__*/_jsxs(G, {
70
- children: [/*#__PURE__*/_jsxs(Defs, {
71
- children: [/*#__PURE__*/_jsx(Pattern, {
72
- height: patternSize,
73
- id: patternId,
74
- patternUnits: "userSpaceOnUse",
75
- width: patternSize,
76
- x: "0",
77
- y: "0",
78
- children: /*#__PURE__*/_jsx(Circle, {
79
- cx: dotCenterPosition,
80
- cy: dotCenterPosition,
81
- fill: effectiveFill,
82
- r: dotSize
83
- })
84
- }), /*#__PURE__*/_jsx(LinearGradient, {
85
- gradientUnits: useUserSpaceUnits ? 'userSpaceOnUse' : 'objectBoundingBox',
86
- id: gradientId,
87
- x1: useUserSpaceUnits ? '0' : '0%',
88
- x2: useUserSpaceUnits ? '0' : '0%',
89
- y1: gradientY1,
90
- y2: gradientY2,
91
- children: baselinePosition !== undefined || baselinePercentage !== undefined ? /* Diverging gradient: high opacity at extremes, low at baseline */
92
- [/*#__PURE__*/_jsx(Stop, {
93
- offset: "0%",
94
- stopColor: "white",
95
- stopOpacity: peakOpacity
96
- }, "0"), /*#__PURE__*/_jsx(Stop, {
97
- offset: baselinePercentage != null ? baselinePercentage : (baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100 + "%",
98
- stopColor: "white",
99
- stopOpacity: baselineOpacity
100
- }, "1"), /*#__PURE__*/_jsx(Stop, {
101
- offset: "100%",
102
- stopColor: "white",
103
- stopOpacity: peakOpacity
104
- }, "2")] : /* Simple gradient from top to bottom */
105
- [/*#__PURE__*/_jsx(Stop, {
106
- offset: "0%",
107
- stopColor: "white",
108
- stopOpacity: peakOpacity
109
- }, "0"), /*#__PURE__*/_jsx(Stop, {
110
- offset: "100%",
111
- stopColor: "white",
112
- stopOpacity: baselineOpacity
113
- }, "1")]
114
- }), /*#__PURE__*/_jsx(Mask, {
115
- id: maskId,
116
- children: /*#__PURE__*/_jsx(Path, {
117
- d: d,
118
- fill: "url(#" + gradientId + ")"
119
- })
120
- })]
121
- }), /*#__PURE__*/_jsx(Path, _extends({
122
- clipRect: clipRect,
123
- d: d,
124
- fill: "url(#" + patternId + ")",
125
- mask: "url(#" + maskId + ")"
126
- }, pathProps))]
35
+ const {
36
+ drawingArea,
37
+ animate,
38
+ getYAxis
39
+ } = useCartesianChartContext();
40
+ const yAxisConfig = getYAxis(yAxisId);
41
+ const fill = useMemo(() => fillProp != null ? fillProp : theme.color.fgPrimary, [fillProp, theme.color.fgPrimary]);
42
+ const dottedPath = useMemo(() => {
43
+ if (!drawingArea) return '';
44
+ return getDottedAreaPath({
45
+ x: drawingArea.x,
46
+ y: drawingArea.y,
47
+ width: drawingArea.width,
48
+ height: drawingArea.height
49
+ }, patternSize, dotSize);
50
+ }, [drawingArea, patternSize, dotSize]);
51
+ const animatedClipPath = usePathTransition({
52
+ currentPath: d,
53
+ transition
54
+ });
55
+ const staticClipPath = useMemo(() => {
56
+ var _Skia$Path$MakeFromSV;
57
+ if (!d) return;
58
+ return (_Skia$Path$MakeFromSV = Skia.Path.MakeFromSVGString(d)) != null ? _Skia$Path$MakeFromSV : undefined;
59
+ }, [d]);
60
+ const gradient = useMemo(() => {
61
+ if (gradientProp) return gradientProp;
62
+ if (!yAxisConfig) return;
63
+ const baselineValue = getBaseline(yAxisConfig.domain, baseline);
64
+ return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
65
+ }, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
66
+ return /*#__PURE__*/_jsx(Group, {
67
+ clip: animate ? animatedClipPath : staticClipPath,
68
+ children: /*#__PURE__*/_jsx(Path, _extends({
69
+ animate: animateProp != null ? animateProp : animate,
70
+ d: dottedPath,
71
+ fill: fill,
72
+ transition: transition
73
+ }, pathProps, {
74
+ children: gradient && /*#__PURE__*/_jsx(Gradient, {
75
+ gradient: gradient,
76
+ yAxisId: yAxisId
77
+ })
78
+ }))
127
79
  });
128
80
  });