@coinbase/cds-web-visualization 0.0.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +3 -0
  2. package/dts/index.d.ts +2 -0
  3. package/dts/index.d.ts.map +1 -0
  4. package/dts/sparkline/Counter.d.ts +3 -0
  5. package/dts/sparkline/Counter.d.ts.map +1 -0
  6. package/dts/sparkline/Sparkline.d.ts +22 -0
  7. package/dts/sparkline/Sparkline.d.ts.map +1 -0
  8. package/dts/sparkline/SparklineArea.d.ts +7 -0
  9. package/dts/sparkline/SparklineArea.d.ts.map +1 -0
  10. package/dts/sparkline/SparklineAreaPattern.d.ts +6 -0
  11. package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -0
  12. package/dts/sparkline/SparklineGradient.d.ts +12 -0
  13. package/dts/sparkline/SparklineGradient.d.ts.map +1 -0
  14. package/dts/sparkline/SparklinePath.d.ts +10 -0
  15. package/dts/sparkline/SparklinePath.d.ts.map +1 -0
  16. package/dts/sparkline/__figma__/Sparkline.figma.d.ts +2 -0
  17. package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +1 -0
  18. package/dts/sparkline/generateSparklineWithId.d.ts +5 -0
  19. package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -0
  20. package/dts/sparkline/index.d.ts +6 -0
  21. package/dts/sparkline/index.d.ts.map +1 -0
  22. package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts +9 -0
  23. package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts.map +1 -0
  24. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +149 -0
  25. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -0
  26. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +13 -0
  27. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -0
  28. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +3 -0
  29. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +1 -0
  30. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts +3 -0
  31. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts.map +1 -0
  32. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +6 -0
  33. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +1 -0
  34. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +12 -0
  35. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -0
  36. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +11 -0
  37. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -0
  38. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +20 -0
  39. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +1 -0
  40. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +20 -0
  41. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +1 -0
  42. package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts +17 -0
  43. package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts.map +1 -0
  44. package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts +18 -0
  45. package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts.map +1 -0
  46. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +23 -0
  47. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +1 -0
  48. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +2 -0
  49. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +1 -0
  50. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +374 -0
  51. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +1 -0
  52. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +2 -0
  53. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +1 -0
  54. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +2 -0
  55. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +1 -0
  56. package/dts/sparkline/sparkline-interactive/fade.d.ts +3 -0
  57. package/dts/sparkline/sparkline-interactive/fade.d.ts.map +1 -0
  58. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +13 -0
  59. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +1 -0
  60. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +104 -0
  61. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +1 -0
  62. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +2 -0
  63. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +1 -0
  64. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +87 -0
  65. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +1 -0
  66. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +2 -0
  67. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +1 -0
  68. package/esm/index.js +1 -0
  69. package/esm/sparkline/Counter.css +3 -0
  70. package/esm/sparkline/Counter.js +35 -0
  71. package/esm/sparkline/Sparkline.js +50 -0
  72. package/esm/sparkline/SparklineArea.js +13 -0
  73. package/esm/sparkline/SparklineAreaPattern.js +35 -0
  74. package/esm/sparkline/SparklineGradient.js +72 -0
  75. package/esm/sparkline/SparklinePath.js +19 -0
  76. package/esm/sparkline/__figma__/Sparkline.figma.js +24 -0
  77. package/esm/sparkline/generateSparklineWithId.js +6 -0
  78. package/esm/sparkline/index.js +5 -0
  79. package/esm/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.js +21 -0
  80. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +313 -0
  81. package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +105 -0
  82. package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.css +2 -0
  83. package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +26 -0
  84. package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.css +2 -0
  85. package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.js +24 -0
  86. package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.css +4 -0
  87. package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +65 -0
  88. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.css +1 -0
  89. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +80 -0
  90. package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +52 -0
  91. package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +70 -0
  92. package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +45 -0
  93. package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.css +5 -0
  94. package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.js +199 -0
  95. package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.js +39 -0
  96. package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +92 -0
  97. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +89 -0
  98. package/esm/sparkline/sparkline-interactive/fade.css +2 -0
  99. package/esm/sparkline/sparkline-interactive/fade.js +14 -0
  100. package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +28 -0
  101. package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +225 -0
  102. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +108 -0
  103. package/package.json +63 -5
  104. package/index.js +0 -1
@@ -0,0 +1,225 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import React, { forwardRef, memo, useCallback, useImperativeHandle, useMemo, useRef } from 'react';
7
+ import { subheadIconSignMap } from '@coinbase/cds-common/tokens/sparkline';
8
+ import { debounce } from '@coinbase/cds-common/utils/debounce';
9
+ import { AccessibilityAnnouncer } from '@coinbase/cds-web/AccessibilityAnnouncer/AccessibilityAnnouncer';
10
+ import { VStack } from '@coinbase/cds-web/layout';
11
+ import { Text } from '@coinbase/cds-web/typography/Text';
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ export * from '@coinbase/cds-common/types/SparklineInteractiveHeaderBaseProps';
14
+ const variantColorMap = {
15
+ positive: 'bgPositive',
16
+ negative: 'bgNegative',
17
+ foregroundMuted: 'fgMuted'
18
+ };
19
+ export const interpolateSubHeadText = subHead => {
20
+ if (subHead.priceChange && subHead.percent) {
21
+ return "".concat(subHead.priceChange, " (").concat(subHead.percent, ")");
22
+ }
23
+ if (subHead.priceChange) {
24
+ return subHead.priceChange;
25
+ }
26
+ return '';
27
+ };
28
+ const SparklineInteractiveHeaderStable = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, forwardedRef) => {
29
+ let {
30
+ defaultLabel,
31
+ defaultTitle,
32
+ defaultSubHead,
33
+ testID,
34
+ labelNode,
35
+ compact
36
+ } = _ref;
37
+ const labelRef = useRef(null);
38
+ const titleRef = useRef(null);
39
+ const subHeadIconRef = useRef(null);
40
+ const subHeadA11yRef = useRef(null);
41
+ const subHeadRef = useRef(null);
42
+ const subHeadAccessoryRef = useRef(null);
43
+ const valuesRef = useRef({
44
+ title: defaultTitle,
45
+ label: defaultLabel,
46
+ subHead: defaultSubHead
47
+ });
48
+ const updateLabel = useCallback(label => {
49
+ var _valuesRef$current;
50
+ const prevLabel = (_valuesRef$current = valuesRef.current) === null || _valuesRef$current === void 0 ? void 0 : _valuesRef$current.label;
51
+ if (prevLabel !== label) {
52
+ if (labelRef.current) {
53
+ labelRef.current.innerText = label;
54
+ }
55
+ valuesRef.current = _objectSpread(_objectSpread({}, valuesRef.current), {}, {
56
+ label
57
+ });
58
+ }
59
+ }, []);
60
+ const updateTitle = useCallback(title => {
61
+ var _valuesRef$current2;
62
+ const prevTitle = (_valuesRef$current2 = valuesRef.current) === null || _valuesRef$current2 === void 0 ? void 0 : _valuesRef$current2.title;
63
+ if (prevTitle !== title && typeof title === 'string') {
64
+ if (titleRef.current) {
65
+ titleRef.current.innerText = title;
66
+ }
67
+ valuesRef.current = _objectSpread(_objectSpread({}, valuesRef.current), {}, {
68
+ title
69
+ });
70
+ }
71
+ }, []);
72
+
73
+ // To make sure we don't spam the screen reader, we debounce this update
74
+ const debouncedUpdateMessage = useMemo(() => debounce(subHead => {
75
+ if (subHeadA11yRef.current) {
76
+ const message = "".concat(valuesRef.current.label, " was ").concat(valuesRef.current.title, " ").concat(subHead.accessibilityLabel, " ").concat(interpolateSubHeadText(subHead));
77
+ subHeadA11yRef.current.innerText = message;
78
+ }
79
+ }, 500), []);
80
+ const safelyUpdateSubHeadA11yRef = useCallback(debouncedUpdateMessage, [debouncedUpdateMessage]);
81
+ const updateSubHead = useCallback(subHead => {
82
+ var _valuesRef$current3;
83
+ const prevSubHead = (_valuesRef$current3 = valuesRef.current) === null || _valuesRef$current3 === void 0 ? void 0 : _valuesRef$current3.subHead;
84
+ if (prevSubHead !== subHead) {
85
+ if (subHeadIconRef.current) {
86
+ subHeadIconRef.current.innerText = subheadIconSignMap[subHead.sign];
87
+ subHeadIconRef.current.style.color = "var(--color-".concat(variantColorMap[subHead.variant], ")");
88
+ }
89
+ if (subHeadRef.current) {
90
+ subHeadRef.current.innerText = interpolateSubHeadText(subHead);
91
+ subHeadRef.current.style.color = "var(--color-".concat(variantColorMap[subHead.variant], ")");
92
+ }
93
+ if (subHeadAccessoryRef.current) {
94
+ var _subHead$accessoryTex;
95
+ subHeadAccessoryRef.current.innerText = (_subHead$accessoryTex = subHead.accessoryText) !== null && _subHead$accessoryTex !== void 0 ? _subHead$accessoryTex : '';
96
+ }
97
+
98
+ // Update a11y message
99
+ if (subHeadA11yRef.current) {
100
+ safelyUpdateSubHeadA11yRef(subHead);
101
+ }
102
+ valuesRef.current = _objectSpread(_objectSpread({}, valuesRef.current), {}, {
103
+ subHead
104
+ });
105
+ }
106
+ }, [safelyUpdateSubHeadA11yRef]);
107
+
108
+ // update is triggered from a parent component.
109
+ // We track the values of each input in a valuesRef object
110
+ // so that we can avoid updating unnecessarily if previous
111
+ // value is the same as the new value
112
+ const update = useCallback(_ref2 => {
113
+ let {
114
+ label,
115
+ title,
116
+ subHead
117
+ } = _ref2;
118
+ if (label) {
119
+ updateLabel(label);
120
+ }
121
+ if (title) {
122
+ updateTitle(title);
123
+ }
124
+ if (subHead) {
125
+ updateSubHead(subHead);
126
+ }
127
+ }, [updateLabel, updateSubHead, updateTitle]);
128
+ useImperativeHandle(forwardedRef, () => {
129
+ return {
130
+ update
131
+ };
132
+ }, [update]);
133
+ const label = !!defaultLabel && /*#__PURE__*/_jsx(Text, {
134
+ as: "div",
135
+ color: "fgMuted",
136
+ font: "headline",
137
+ children: /*#__PURE__*/_jsx("span", {
138
+ ref: labelRef,
139
+ children: defaultLabel
140
+ })
141
+ });
142
+ const subHeadColorStyles = defaultSubHead ? {
143
+ color: "var(--color-".concat(variantColorMap[defaultSubHead.variant], ")"),
144
+ marginRight: 'var(--space-0_5)'
145
+ } : {
146
+ marginRight: 'var(--space-0_5)'
147
+ };
148
+ const subHead = !!defaultSubHead && /*#__PURE__*/_jsxs(_Fragment, {
149
+ children: [/*#__PURE__*/_jsxs(Text, {
150
+ tabularNumbers: true,
151
+ as: "span",
152
+ font: compact ? 'label1' : 'title4',
153
+ children: [/*#__PURE__*/_jsx("span", {
154
+ ref: subHeadIconRef,
155
+ style: subHeadColorStyles,
156
+ children: subheadIconSignMap[defaultSubHead.sign]
157
+ }), /*#__PURE__*/_jsx("span", {
158
+ ref: subHeadRef,
159
+ style: subHeadColorStyles,
160
+ children: interpolateSubHeadText(defaultSubHead)
161
+ })]
162
+ }), !!defaultSubHead.accessoryText && /*#__PURE__*/_jsx(Text, {
163
+ "aria-hidden": true,
164
+ tabularNumbers: true,
165
+ as: "span",
166
+ color: "fgMuted",
167
+ paddingStart: 1,
168
+ children: /*#__PURE__*/_jsx("span", {
169
+ ref: subHeadAccessoryRef,
170
+ children: defaultSubHead.accessoryText
171
+ })
172
+ })]
173
+ });
174
+ const title = /*#__PURE__*/_jsxs(VStack, {
175
+ alignItems: "baseline",
176
+ padding: 0,
177
+ children: [typeof defaultTitle === 'string' ? /*#__PURE__*/_jsx(Text, {
178
+ tabularNumbers: true,
179
+ as: "div",
180
+ color: "fg",
181
+ font: compact ? 'title1' : 'display3',
182
+ paddingEnd: 1,
183
+ children: /*#__PURE__*/_jsx("span", {
184
+ ref: titleRef,
185
+ children: defaultTitle
186
+ })
187
+ }) : defaultTitle, subHead]
188
+ });
189
+ return /*#__PURE__*/_jsxs(_Fragment, {
190
+ children: [/*#__PURE__*/_jsxs("div", {
191
+ "aria-hidden": true,
192
+ "data-testid": testID,
193
+ style: {
194
+ width: '100%'
195
+ },
196
+ children: [labelNode !== null && labelNode !== void 0 ? labelNode : label, title]
197
+ }), /*#__PURE__*/_jsx(AccessibilityAnnouncer, {
198
+ ref: subHeadA11yRef
199
+ })]
200
+ });
201
+ }));
202
+ export const SparklineInteractiveHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref3, ref) => {
203
+ let {
204
+ defaultLabel,
205
+ defaultTitle,
206
+ defaultSubHead,
207
+ testID,
208
+ labelNode,
209
+ compact
210
+ } = _ref3;
211
+ return /*#__PURE__*/_jsx(SparklineInteractiveHeaderStable
212
+ // All updates after initial load should be handled imperatively
213
+ // via update function in forwarded ref to prevent overriding
214
+ // values unexpectedly. This is why we use ref here so that the
215
+ // default value is stable and never updates on re-renders
216
+ , {
217
+ ref: ref,
218
+ compact: compact,
219
+ defaultLabel: useRef(defaultLabel).current,
220
+ defaultSubHead: useRef(defaultSubHead).current,
221
+ defaultTitle: useRef(defaultTitle).current,
222
+ labelNode: labelNode,
223
+ testID: testID
224
+ });
225
+ }));
@@ -0,0 +1,108 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import React from 'react';
7
+ import { figma } from '@figma/code-connect';
8
+ import { SparklineInteractive } from '../../sparkline-interactive/SparklineInteractive';
9
+ import { SparklineInteractiveHeader } from '../SparklineInteractiveHeader';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ figma.connect(SparklineInteractiveHeader, 'https://www.figma.com/design/k5CtyJccNQUGMI5bI4lJ2g/✨-CDS-Components?node-id=320-14931&m=dev', {
12
+ imports: ["import { SparklineInteractiveHeader } from '@coinbase/cds-web-visualization';", "import { SparklineInteractive } from '@coinbase/cds-web-visualization';"],
13
+ props: {
14
+ compact: figma.boolean('compact'),
15
+ disableScrubbing: figma.boolean('scrubbing', {
16
+ false: true,
17
+ true: false
18
+ })
19
+ },
20
+ example: props => {
21
+ const periods = [{
22
+ label: '1H',
23
+ value: 'hour'
24
+ }, {
25
+ label: '1D',
26
+ value: 'day'
27
+ }, {
28
+ label: '1W',
29
+ value: 'week'
30
+ }, {
31
+ label: '1M',
32
+ value: 'month'
33
+ }, {
34
+ label: '1Y',
35
+ value: 'year'
36
+ }, {
37
+ label: 'All',
38
+ value: 'all'
39
+ }];
40
+ const data = {
41
+ hour: [],
42
+ day: [{
43
+ value: 49259.38,
44
+ date: new Date('2021-12-05T04:00:00.000Z')
45
+ }, {
46
+ value: 49163.79,
47
+ date: new Date('2021-12-05T04:05:00.000Z')
48
+ }, {
49
+ value: 49146.66,
50
+ date: new Date('2021-12-05T04:10:00.000Z')
51
+ }, {
52
+ value: 49083.92,
53
+ date: new Date('2021-12-05T04:15:00.000Z')
54
+ }, {
55
+ value: 49115.3,
56
+ date: new Date('2021-12-05T04:20:00.000Z')
57
+ }, {
58
+ value: 48992.14,
59
+ date: new Date('2021-12-05T04:25:00.000Z')
60
+ }, {
61
+ value: 49075.75,
62
+ date: new Date('2021-12-05T04:30:00.000Z')
63
+ }, {
64
+ value: 49025.78,
65
+ date: new Date('2021-12-05T04:35:00.000Z')
66
+ }, {
67
+ value: 49066.23,
68
+ date: new Date('2021-12-05T04:40:00.000Z')
69
+ }, {
70
+ value: 49247.82,
71
+ date: new Date('2021-12-05T04:45:00.000Z')
72
+ }],
73
+ week: [],
74
+ month: [],
75
+ year: [],
76
+ all: []
77
+ };
78
+ const defaultSubHead = {
79
+ percent: '1.35%',
80
+ sign: 'upwardTrend',
81
+ variant: 'positive',
82
+ accessibilityLabel: 'on Sunday, December 5, 2021 at 10:55 PM, up',
83
+ priceChange: '$21.36'
84
+ };
85
+ const header = /*#__PURE__*/_jsx(SparklineInteractiveHeader, {
86
+ defaultLabel: "Portfolio balance"
87
+ // @ts-expect-error: defaultSubHead is not part of the type definition
88
+ ,
89
+ defaultSubHead: defaultSubHead,
90
+ defaultTitle: "$10,023.82"
91
+ });
92
+ return /*#__PURE__*/_jsx(SparklineInteractive, _objectSpread({
93
+ data: data,
94
+ defaultPeriod: "day",
95
+ formatDate: date => date.toLocaleString('en-US', {
96
+ timeZone: 'America/New_York',
97
+ hour: 'numeric',
98
+ minute: 'numeric'
99
+ }),
100
+ headerNode: header,
101
+ onPeriodChanged: () => {},
102
+ onScrub: () => {},
103
+ onScrubEnd: () => {},
104
+ periods: periods,
105
+ strokeColor: "#cb51bb"
106
+ }, props));
107
+ }
108
+ });
package/package.json CHANGED
@@ -1,8 +1,66 @@
1
1
  {
2
2
  "name": "@coinbase/cds-web-visualization",
3
- "version": "0.0.0",
4
- "description": "Placeholder package",
5
- "main": "index.js",
6
- "author": "Coinbase Inc.",
7
- "license": "Apache-2.0"
3
+ "version": "3.3.0",
4
+ "description": "Coinbase Design System - Web Sparkline",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@github.com:coinbase/cds-staging.git",
8
+ "directory": "packages/web-visualization"
9
+ },
10
+ "type": "module",
11
+ "main": "./esm/index.js",
12
+ "types": "./dts/index.d.ts",
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "types": "./dts/index.d.ts",
17
+ "default": "./esm/index.js"
18
+ },
19
+ "./sparkline": {
20
+ "types": "./dts/sparkline/index.d.ts",
21
+ "default": "./esm/sparkline/index.js"
22
+ },
23
+ "./*": {
24
+ "types": "./dts/*.d.ts",
25
+ "default": "./esm/*.js"
26
+ }
27
+ },
28
+ "sideEffects": [
29
+ "*.css"
30
+ ],
31
+ "files": [
32
+ "dts",
33
+ "esm",
34
+ "CHANGELOG"
35
+ ],
36
+ "peerDependencies": {
37
+ "@coinbase/cds-common": "workspace:^",
38
+ "@coinbase/cds-lottie-files": "workspace:^",
39
+ "@coinbase/cds-utils": "workspace:^",
40
+ "@coinbase/cds-web": "workspace:^",
41
+ "react": "^18.3.1",
42
+ "react-dom": "^18.3.1"
43
+ },
44
+ "dependencies": {
45
+ "d3-color": "^3.1.0",
46
+ "d3-interpolate": "^3.0.1",
47
+ "d3-interpolate-path": "^2.3.0",
48
+ "d3-selection": "^3.0.0",
49
+ "d3-transition": "^3.0.1",
50
+ "lodash": "^4.17.21"
51
+ },
52
+ "devDependencies": {
53
+ "@babel/core": "^7.28.0",
54
+ "@babel/preset-env": "^7.28.0",
55
+ "@babel/preset-react": "^7.27.1",
56
+ "@babel/preset-typescript": "^7.27.1",
57
+ "@coinbase/cds-common": "workspace:^",
58
+ "@coinbase/cds-lottie-files": "workspace:^",
59
+ "@coinbase/cds-utils": "workspace:^",
60
+ "@coinbase/cds-web": "workspace:^",
61
+ "@figma/code-connect": "^1.3.4",
62
+ "@linaria/core": "^3.0.0-beta.22",
63
+ "@types/react": "^18.3.12",
64
+ "@types/react-dom": "^18.3.1"
65
+ }
8
66
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- console.log("Temporary package");