@coinbase/cds-web-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.
Files changed (198) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/dts/chart/CartesianChart.d.ts +56 -3
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/ChartProvider.d.ts +3 -0
  5. package/dts/chart/ChartProvider.d.ts.map +1 -1
  6. package/dts/chart/Path.d.ts +64 -7
  7. package/dts/chart/Path.d.ts.map +1 -1
  8. package/dts/chart/PeriodSelector.d.ts +5 -15
  9. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  10. package/dts/chart/area/Area.d.ts +50 -25
  11. package/dts/chart/area/Area.d.ts.map +1 -1
  12. package/dts/chart/area/AreaChart.d.ts +46 -6
  13. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  14. package/dts/chart/area/DottedArea.d.ts +21 -44
  15. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  16. package/dts/chart/area/GradientArea.d.ts +21 -12
  17. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  18. package/dts/chart/area/SolidArea.d.ts +16 -1
  19. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  20. package/dts/chart/axis/Axis.d.ts +109 -63
  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 +50 -12
  31. package/dts/chart/bar/Bar.d.ts.map +1 -1
  32. package/dts/chart/bar/BarChart.d.ts +20 -8
  33. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  34. package/dts/chart/bar/BarPlot.d.ts +3 -1
  35. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  36. package/dts/chart/bar/BarStack.d.ts +41 -46
  37. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  38. package/dts/chart/bar/BarStackGroup.d.ts +2 -0
  39. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  40. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  41. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  42. package/dts/chart/gradient/Gradient.d.ts +35 -0
  43. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  44. package/dts/chart/gradient/index.d.ts +2 -0
  45. package/dts/chart/gradient/index.d.ts.map +1 -0
  46. package/dts/chart/index.d.ts +3 -1
  47. package/dts/chart/index.d.ts.map +1 -1
  48. package/dts/chart/legend/DefaultLegendEntry.d.ts +21 -0
  49. package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
  50. package/dts/chart/legend/DefaultLegendShape.d.ts +7 -0
  51. package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
  52. package/dts/chart/legend/Legend.d.ts +169 -0
  53. package/dts/chart/legend/Legend.d.ts.map +1 -0
  54. package/dts/chart/legend/index.d.ts +4 -0
  55. package/dts/chart/legend/index.d.ts.map +1 -0
  56. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  57. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  58. package/dts/chart/line/DottedLine.d.ts +15 -3
  59. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  60. package/dts/chart/line/Line.d.ts +84 -28
  61. package/dts/chart/line/Line.d.ts.map +1 -1
  62. package/dts/chart/line/LineChart.d.ts +28 -8
  63. package/dts/chart/line/LineChart.d.ts.map +1 -1
  64. package/dts/chart/line/ReferenceLine.d.ts +91 -44
  65. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  66. package/dts/chart/line/SolidLine.d.ts +14 -3
  67. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  68. package/dts/chart/line/index.d.ts +1 -1
  69. package/dts/chart/line/index.d.ts.map +1 -1
  70. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  71. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  72. package/dts/chart/point/Point.d.ts +217 -0
  73. package/dts/chart/point/Point.d.ts.map +1 -0
  74. package/dts/chart/point/index.d.ts +3 -0
  75. package/dts/chart/point/index.d.ts.map +1 -0
  76. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +41 -0
  77. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  78. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  79. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  80. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +10 -0
  81. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  82. package/dts/chart/scrubber/Scrubber.d.ts +287 -70
  83. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  84. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +80 -0
  85. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  86. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +47 -0
  87. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  88. package/dts/chart/scrubber/index.d.ts +3 -0
  89. package/dts/chart/scrubber/index.d.ts.map +1 -1
  90. package/dts/chart/text/ChartText.d.ts +46 -43
  91. package/dts/chart/text/ChartText.d.ts.map +1 -1
  92. package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
  93. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  94. package/dts/chart/text/index.d.ts +1 -1
  95. package/dts/chart/text/index.d.ts.map +1 -1
  96. package/dts/chart/utils/axis.d.ts +25 -1
  97. package/dts/chart/utils/axis.d.ts.map +1 -1
  98. package/dts/chart/utils/bar.d.ts +34 -0
  99. package/dts/chart/utils/bar.d.ts.map +1 -1
  100. package/dts/chart/utils/chart.d.ts +45 -7
  101. package/dts/chart/utils/chart.d.ts.map +1 -1
  102. package/dts/chart/utils/context.d.ts +6 -0
  103. package/dts/chart/utils/context.d.ts.map +1 -1
  104. package/dts/chart/utils/gradient.d.ts +104 -0
  105. package/dts/chart/utils/gradient.d.ts.map +1 -0
  106. package/dts/chart/utils/index.d.ts +4 -0
  107. package/dts/chart/utils/index.d.ts.map +1 -1
  108. package/dts/chart/utils/interpolate.d.ts +112 -0
  109. package/dts/chart/utils/interpolate.d.ts.map +1 -0
  110. package/dts/chart/utils/path.d.ts +30 -1
  111. package/dts/chart/utils/path.d.ts.map +1 -1
  112. package/dts/chart/utils/point.d.ts +40 -7
  113. package/dts/chart/utils/point.d.ts.map +1 -1
  114. package/dts/chart/utils/scale.d.ts +11 -0
  115. package/dts/chart/utils/scale.d.ts.map +1 -1
  116. package/dts/chart/utils/scrubber.d.ts +40 -0
  117. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  118. package/dts/chart/utils/transition.d.ts +101 -0
  119. package/dts/chart/utils/transition.d.ts.map +1 -0
  120. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -1
  121. package/esm/chart/CartesianChart.js +170 -83
  122. package/esm/chart/ChartProvider.js +2 -2
  123. package/esm/chart/Path.js +59 -54
  124. package/esm/chart/PeriodSelector.js +36 -32
  125. package/esm/chart/area/Area.js +26 -34
  126. package/esm/chart/area/AreaChart.js +29 -15
  127. package/esm/chart/area/DottedArea.js +39 -89
  128. package/esm/chart/area/GradientArea.js +37 -80
  129. package/esm/chart/area/SolidArea.js +32 -11
  130. package/esm/chart/axis/Axis.js +4 -39
  131. package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
  132. package/esm/chart/axis/XAxis.js +184 -63
  133. package/esm/chart/axis/YAxis.js +190 -57
  134. package/esm/chart/axis/index.js +1 -0
  135. package/esm/chart/bar/Bar.js +7 -1
  136. package/esm/chart/bar/BarChart.js +17 -32
  137. package/esm/chart/bar/BarPlot.js +5 -2
  138. package/esm/chart/bar/BarStack.js +74 -22
  139. package/esm/chart/bar/BarStackGroup.js +8 -18
  140. package/esm/chart/bar/DefaultBar.js +23 -28
  141. package/esm/chart/bar/DefaultBarStack.js +24 -20
  142. package/esm/chart/gradient/Gradient.js +104 -0
  143. package/esm/chart/gradient/index.js +1 -0
  144. package/esm/chart/index.js +3 -1
  145. package/esm/chart/legend/DefaultLegendEntry.css +1 -0
  146. package/esm/chart/legend/DefaultLegendEntry.js +50 -0
  147. package/esm/chart/legend/DefaultLegendShape.css +5 -0
  148. package/esm/chart/legend/DefaultLegendShape.js +47 -0
  149. package/esm/chart/legend/Legend.js +76 -0
  150. package/esm/chart/legend/index.js +3 -0
  151. package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
  152. package/esm/chart/line/DottedLine.js +41 -17
  153. package/esm/chart/line/Line.js +87 -75
  154. package/esm/chart/line/LineChart.js +24 -8
  155. package/esm/chart/line/ReferenceLine.js +41 -43
  156. package/esm/chart/line/SolidLine.js +39 -15
  157. package/esm/chart/line/index.js +1 -1
  158. package/esm/chart/{line/GradientLine.js → point/DefaultPointLabel.js} +31 -45
  159. package/esm/chart/point/Point.css +2 -0
  160. package/esm/chart/{Point.js → point/Point.js} +87 -62
  161. package/esm/chart/point/index.js +2 -0
  162. package/esm/chart/scrubber/DefaultScrubberBeacon.js +154 -0
  163. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +57 -0
  164. package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberLabel.js} +15 -18
  165. package/esm/chart/scrubber/Scrubber.js +97 -392
  166. package/esm/chart/scrubber/ScrubberBeaconGroup.js +174 -0
  167. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +201 -0
  168. package/esm/chart/scrubber/index.js +3 -1
  169. package/esm/chart/text/ChartText.js +15 -20
  170. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
  171. package/esm/chart/text/index.js +1 -1
  172. package/esm/chart/utils/axis.js +47 -31
  173. package/esm/chart/utils/bar.js +48 -0
  174. package/esm/chart/utils/chart.js +42 -3
  175. package/esm/chart/utils/gradient.js +257 -0
  176. package/esm/chart/utils/index.js +4 -0
  177. package/esm/chart/utils/interpolate.js +644 -0
  178. package/esm/chart/utils/path.js +41 -9
  179. package/esm/chart/utils/point.js +99 -12
  180. package/esm/chart/utils/scale.js +13 -2
  181. package/esm/chart/utils/scrubber.js +137 -0
  182. package/esm/chart/utils/transition.js +133 -0
  183. package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
  184. package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +8 -4
  185. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
  186. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
  187. package/package.json +12 -11
  188. package/dts/chart/Point.d.ts +0 -153
  189. package/dts/chart/Point.d.ts.map +0 -1
  190. package/dts/chart/line/GradientLine.d.ts +0 -42
  191. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  192. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -93
  193. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  194. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +0 -7
  195. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +0 -1
  196. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  197. package/esm/chart/Point.css +0 -2
  198. package/esm/chart/scrubber/ScrubberBeacon.js +0 -195
@@ -5,9 +5,16 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
5
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
6
  import React, { memo, useMemo } from 'react';
7
7
  import { useCartesianChartContext } from '../ChartProvider';
8
+ import { evaluateGradientAtValue, getGradientConfig } from '../utils/gradient';
8
9
  import { Bar } from './Bar';
9
10
  import { DefaultBarStack } from './DefaultBarStack';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ const EPSILON = 1e-4;
13
+
14
+ /**
15
+ * Extended series type that includes bar-specific properties.
16
+ */
17
+
11
18
  /**
12
19
  * BarStack component that renders a single stack of bars at a specific category index.
13
20
  * Handles the stacking logic for bars within a single category.
@@ -29,13 +36,17 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
29
36
  stackGap,
30
37
  barMinSize,
31
38
  stackMinSize,
32
- roundBaseline
39
+ roundBaseline,
40
+ transitions,
41
+ transition
33
42
  } = _ref;
34
43
  const {
35
44
  getSeriesData,
36
- getXAxis
45
+ getXAxis,
46
+ getXScale,
47
+ getSeries
37
48
  } = useCartesianChartContext();
38
- const stackGapPx = stackGap;
49
+ const xScale = getXScale();
39
50
  const barMinSizePx = barMinSize;
40
51
  const stackMinSizePx = stackMinSize;
41
52
  const xAxis = getXAxis();
@@ -47,6 +58,20 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
47
58
  const baseline = (_yScale = yScale(baselineValue)) !== null && _yScale !== void 0 ? _yScale : rect.y + rect.height;
48
59
  return Math.max(rect.y, Math.min(baseline, rect.y + rect.height));
49
60
  }, [rect.height, rect.y, yScale]);
61
+ const seriesGradients = useMemo(() => {
62
+ return series.map(s => {
63
+ if (!s.gradient || !xScale || !yScale) return null;
64
+ const gradientScale = s.gradient.axis === 'x' ? xScale : yScale;
65
+ const stops = getGradientConfig(s.gradient, xScale, yScale);
66
+ if (!stops) return null;
67
+ return {
68
+ seriesId: s.id,
69
+ gradient: s.gradient,
70
+ scale: gradientScale,
71
+ stops
72
+ };
73
+ });
74
+ }, [series, xScale, yScale]);
50
75
 
51
76
  // Calculate bars for this specific category
52
77
  const {
@@ -65,7 +90,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
65
90
 
66
91
  // Process each series in the stack
67
92
  series.forEach(s => {
68
- var _yScale2, _yScale3;
93
+ var _yScale2, _yScale3, _s$color;
69
94
  const data = getSeriesData(s.id);
70
95
  if (!data) return;
71
96
  const value = data[categoryIndex];
@@ -103,6 +128,30 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
103
128
  // Update stack bounds
104
129
  minY = Math.min(minY, y);
105
130
  maxY = Math.max(maxY, y + height);
131
+ let barFill = (_s$color = s.color) !== null && _s$color !== void 0 ? _s$color : 'var(--color-fgPrimary)';
132
+
133
+ // Evaluate gradient if provided (using precomputed stops)
134
+ const seriesGradientConfig = seriesGradients.find(g => (g === null || g === void 0 ? void 0 : g.seriesId) === s.id);
135
+ if (seriesGradientConfig && originalValue !== null && originalValue !== undefined) {
136
+ var _seriesGradientConfig;
137
+ const axis = (_seriesGradientConfig = seriesGradientConfig.gradient.axis) !== null && _seriesGradientConfig !== void 0 ? _seriesGradientConfig : 'y';
138
+ // For x-axis gradient, use the categoryIndex
139
+ // For y-axis gradient, use the ORIGINAL data value (not the processed top value)
140
+ // This is important for bar charts where originalValue might be a single number (e.g., -40, 15)
141
+ // or a tuple (e.g., [0, 10] for range bars)
142
+ let evalValue;
143
+ if (axis === 'x') {
144
+ evalValue = categoryIndex;
145
+ } else {
146
+ // Use original value for evaluation - handles both single numbers and tuples
147
+ evalValue = Array.isArray(originalValue) ? originalValue[1] : originalValue;
148
+ }
149
+ const evaluatedColor = evaluateGradientAtValue(seriesGradientConfig.stops, evalValue, seriesGradientConfig.scale);
150
+ if (evaluatedColor) {
151
+ // Only apply gradient color if fill is not explicitly set
152
+ barFill = evaluatedColor;
153
+ }
154
+ }
106
155
  allBars.push({
107
156
  seriesId: s.id,
108
157
  x,
@@ -111,21 +160,17 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
111
160
  height,
112
161
  dataY: value,
113
162
  // Store the actual data value
114
- // Use series-specific properties, falling back to defaults
163
+ fill: barFill,
164
+ // Check if the bar should be rounded based on the baseline, with an epsilon to handle floating-point rounding
165
+ roundTop: roundBaseline || Math.abs(barTop - baseline) >= EPSILON,
166
+ roundBottom: roundBaseline || Math.abs(barBottom - baseline) >= EPSILON,
115
167
  BarComponent: s.BarComponent,
116
- fill: s.fill || s.color || 'var(--color-fgPrimary)',
117
- fillOpacity: s.fillOpacity,
118
- stroke: s.stroke,
119
- strokeWidth: s.strokeWidth,
120
- // Pass context data for custom components
121
- roundTop: roundBaseline || barTop !== baseline,
122
- roundBottom: roundBaseline || barBottom !== baseline,
123
168
  shouldApplyGap
124
169
  });
125
170
  });
126
171
 
127
172
  // Apply proportional gap distribution to maintain total stack height
128
- if (stackGapPx && allBars.length > 1) {
173
+ if (stackGap && allBars.length > 1) {
129
174
  // Separate bars by baseline side
130
175
  const barsAboveBaseline = allBars.filter(bar => {
131
176
  const [bottom, top] = bar.dataY.sort((a, b) => a - b);
@@ -138,7 +183,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
138
183
 
139
184
  // Apply proportional gaps to bars above baseline
140
185
  if (barsAboveBaseline.length > 1) {
141
- const totalGapSpace = stackGapPx * (barsAboveBaseline.length - 1);
186
+ const totalGapSpace = stackGap * (barsAboveBaseline.length - 1);
142
187
  const totalDataHeight = barsAboveBaseline.reduce((sum, bar) => sum + bar.height, 0);
143
188
  const heightReduction = totalGapSpace / totalDataHeight;
144
189
 
@@ -160,13 +205,13 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
160
205
  }
161
206
 
162
207
  // Move to next position (include gap for next bar)
163
- currentY = newY - (index < sortedBars.length - 1 ? stackGapPx : 0);
208
+ currentY = newY - (index < sortedBars.length - 1 ? stackGap : 0);
164
209
  });
165
210
  }
166
211
 
167
212
  // Apply proportional gaps to bars below baseline
168
213
  if (barsBelowBaseline.length > 1) {
169
- const totalGapSpace = stackGapPx * (barsBelowBaseline.length - 1);
214
+ const totalGapSpace = stackGap * (barsBelowBaseline.length - 1);
170
215
  const totalDataHeight = barsBelowBaseline.reduce((sum, bar) => sum + bar.height, 0);
171
216
  const heightReduction = totalGapSpace / totalDataHeight;
172
217
 
@@ -187,7 +232,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
187
232
  }
188
233
 
189
234
  // Move to next position (include gap for next bar)
190
- currentY = currentY + newHeight + (index < sortedBars.length - 1 ? stackGapPx : 0);
235
+ currentY = currentY + newHeight + (index < sortedBars.length - 1 ? stackGap : 0);
191
236
  });
192
237
  }
193
238
 
@@ -323,8 +368,8 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
323
368
  return bars.sort((a, b) => b.y - a.y).map((a, index) => {
324
369
  const barBefore = index > 0 ? bars[index - 1] : null;
325
370
  const barAfter = index < bars.length - 1 ? bars[index + 1] : null;
326
- const shouldRoundTop = index === bars.length - 1 || a.shouldApplyGap && stackGapPx || !a.shouldApplyGap && barAfter && barAfter.y + barAfter.height !== a.y;
327
- const shouldRoundBottom = index === 0 || a.shouldApplyGap && stackGapPx || !a.shouldApplyGap && barBefore && barBefore.y !== a.y + a.height;
371
+ const shouldRoundTop = index === bars.length - 1 || a.shouldApplyGap && stackGap || !a.shouldApplyGap && barAfter && barAfter.y + barAfter.height !== a.y;
372
+ const shouldRoundBottom = index === 0 || a.shouldApplyGap && stackGap || !a.shouldApplyGap && barBefore && barBefore.y !== a.y + a.height;
328
373
  return _objectSpread(_objectSpread({}, a), {}, {
329
374
  roundTop: Boolean(a.roundTop && shouldRoundTop),
330
375
  roundBottom: Boolean(a.roundBottom && shouldRoundBottom)
@@ -479,7 +524,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
479
524
  bars: allBars,
480
525
  stackRect: stackBounds
481
526
  };
482
- }, [series, x, width, getSeriesData, categoryIndex, roundBaseline, baseline, stackGapPx, barMinSizePx, stackMinSizePx, yScale]);
527
+ }, [series, stackGap, barMinSizePx, x, baseline, width, stackMinSizePx, getSeriesData, categoryIndex, yScale, seriesGradients, roundBaseline]);
483
528
  const xData = xAxis !== null && xAxis !== void 0 && xAxis.data && Array.isArray(xAxis.data) && typeof xAxis.data[0] === 'number' ? xAxis.data : undefined;
484
529
  const dataX = xData ? xData[categoryIndex] : categoryIndex;
485
530
  const barElements = bars.map((bar, index) => {
@@ -495,21 +540,28 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
495
540
  originY: baseline,
496
541
  roundBottom: bar.roundBottom,
497
542
  roundTop: bar.roundTop,
543
+ seriesId: bar.seriesId,
498
544
  stroke: (_bar$stroke = bar.stroke) !== null && _bar$stroke !== void 0 ? _bar$stroke : defaultStroke,
499
545
  strokeWidth: (_bar$strokeWidth = bar.strokeWidth) !== null && _bar$strokeWidth !== void 0 ? _bar$strokeWidth : defaultStrokeWidth,
546
+ transition: transition,
547
+ transitions: transitions,
500
548
  width: bar.width,
501
549
  x: bar.x,
502
550
  y: bar.y
503
551
  }, "".concat(bar.seriesId, "-").concat(categoryIndex, "-").concat(index));
504
552
  });
505
- const stackRoundBottom = roundBaseline || stackRect.y + stackRect.height !== baseline;
506
- const stackRoundTop = roundBaseline || stackRect.y !== baseline;
553
+
554
+ // Check if the bar should be rounded based on the baseline, with an epsilon to handle floating-point rounding
555
+ const stackRoundBottom = roundBaseline || Math.abs(stackRect.y + stackRect.height - baseline) >= EPSILON;
556
+ const stackRoundTop = roundBaseline || Math.abs(stackRect.y - baseline) >= EPSILON;
507
557
  return /*#__PURE__*/_jsx(BarStackComponent, {
508
558
  borderRadius: borderRadius,
509
559
  categoryIndex: categoryIndex,
510
560
  height: stackRect.height,
511
561
  roundBottom: stackRoundBottom,
512
562
  roundTop: stackRoundTop,
563
+ transition: transition,
564
+ transitions: transitions,
513
565
  width: stackRect.width,
514
566
  x: stackRect.x,
515
567
  y: stackRect.y,
@@ -25,26 +25,15 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
25
25
  } = _ref,
26
26
  props = _objectWithoutProperties(_ref, _excluded);
27
27
  const {
28
- getSeriesData,
29
28
  getXScale,
30
29
  getYScale,
31
- drawingArea
30
+ drawingArea,
31
+ dataLength
32
32
  } = useCartesianChartContext();
33
33
  const xScale = getXScale();
34
34
  const yScale = getYScale(yAxisId);
35
- const maxDataLength = useMemo(() => {
36
- if (!series || series.length === 0) return 0;
37
- let maxLength = 0;
38
- series.forEach(s => {
39
- const data = getSeriesData(s.id);
40
- if (data && data.length > maxLength) {
41
- maxLength = data.length;
42
- }
43
- });
44
- return maxLength;
45
- }, [series, getSeriesData]);
46
35
  const stackConfigs = useMemo(() => {
47
- if (!xScale || !yScale || !drawingArea || maxDataLength === 0) return [];
36
+ if (!xScale || !yScale || !drawingArea || dataLength === 0) return [];
48
37
  if (!isCategoricalScale(xScale)) {
49
38
  return [];
50
39
  }
@@ -57,7 +46,8 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
57
46
  const configs = [];
58
47
 
59
48
  // Calculate position for each category
60
- for (let categoryIndex = 0; categoryIndex < maxDataLength; categoryIndex++) {
49
+ // todo: look at using xDomain for this instead of dataLength
50
+ for (let categoryIndex = 0; categoryIndex < dataLength; categoryIndex++) {
61
51
  // Get x position for this category
62
52
  const categoryX = xScale(categoryIndex);
63
53
  if (categoryX !== undefined) {
@@ -71,11 +61,11 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
71
61
  }
72
62
  }
73
63
  return configs;
74
- }, [xScale, yScale, drawingArea, maxDataLength, stackIndex, totalStacks, barPadding]);
64
+ }, [xScale, yScale, drawingArea, dataLength, stackIndex, totalStacks, barPadding]);
75
65
  if (xScale && !isCategoricalScale(xScale)) {
76
- throw new Error('BarStackGroup requires a band scale for x-axis. See https://cds.coinbase.com/components/graphs/XAxis/#scale-type');
66
+ throw new Error('BarStackGroup requires a band scale for x-axis. See https://cds.coinbase.com/components/charts/XAxis/#scale-type');
77
67
  }
78
- if (!yScale || !drawingArea || stackConfigs.length === 0) return;
68
+ if (!yScale || !drawingArea || stackConfigs.length === 0) return null;
79
69
  return stackConfigs.map(_ref2 => {
80
70
  let {
81
71
  categoryIndex,
@@ -1,4 +1,4 @@
1
- const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY"];
1
+ const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY", "seriesId", "transitions", "transition"];
2
2
  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; }
3
3
  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; }
4
4
  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; }
@@ -7,9 +7,9 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
7
7
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
8
  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; }
9
9
  import React, { memo, useMemo } from 'react';
10
- import { m as motion } from 'framer-motion';
11
10
  import { useCartesianChartContext } from '../ChartProvider';
12
- import { getBarPath } from '../utils';
11
+ import { Path } from '../Path';
12
+ import { defaultBarEnterTransition, defaultTransition, getBarPath, getTransition, withStaggerDelayTransition } from '../utils';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  /**
15
15
  * Default bar component that renders a solid bar with animation.
@@ -26,39 +26,34 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
26
26
  fill = 'var(--color-fgPrimary)',
27
27
  fillOpacity = 1,
28
28
  dataX,
29
- dataY
29
+ dataY,
30
+ seriesId,
31
+ transitions,
32
+ transition
30
33
  } = _ref,
31
34
  props = _objectWithoutProperties(_ref, _excluded);
32
35
  const {
33
- animate
36
+ animate,
37
+ drawingArea
34
38
  } = useCartesianChartContext();
39
+ const normalizedX = useMemo(() => drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0, [x, drawingArea.x, drawingArea.width]);
40
+ const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedX), [transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, normalizedX]);
41
+ const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedX), [transitions === null || transitions === void 0 ? void 0 : transitions.update, transition, animate, normalizedX]);
35
42
  const initialPath = useMemo(() => {
36
- if (!animate) return undefined;
37
- // Need a minimum height to allow for animation
38
43
  const minHeight = 1;
39
44
  const initialY = (originY !== null && originY !== void 0 ? originY : 0) - minHeight;
40
- return getBarPath(x, initialY, width, minHeight, borderRadius, !!roundTop, !!roundBottom);
41
- }, [animate, x, originY, width, borderRadius, roundTop, roundBottom]);
42
- if (animate && initialPath) {
43
- return /*#__PURE__*/_jsx(motion.path, _objectSpread(_objectSpread({}, props), {}, {
44
- animate: {
45
- d
46
- },
47
- fill: fill,
48
- fillOpacity: fillOpacity,
49
- initial: {
50
- d: initialPath
51
- },
52
- transition: {
53
- type: 'spring',
54
- duration: 1,
55
- bounce: 0
56
- }
57
- }));
58
- }
59
- return /*#__PURE__*/_jsx("path", _objectSpread(_objectSpread({}, props), {}, {
45
+ return getBarPath(x, initialY, width, minHeight, borderRadius !== null && borderRadius !== void 0 ? borderRadius : 0, !!roundTop, !!roundBottom);
46
+ }, [x, originY, width, borderRadius, roundTop, roundBottom]);
47
+ return /*#__PURE__*/_jsx(Path, _objectSpread(_objectSpread({}, props), {}, {
48
+ animate: animate,
49
+ clipRect: null,
60
50
  d: d,
61
51
  fill: fill,
62
- fillOpacity: fillOpacity
52
+ fillOpacity: fillOpacity,
53
+ initialPath: initialPath,
54
+ transitions: {
55
+ enter: enterTransition,
56
+ update: updateTransition
57
+ }
63
58
  }));
64
59
  });
@@ -1,7 +1,8 @@
1
1
  import { memo, useId, useMemo } from 'react';
2
2
  import { m as motion } from 'framer-motion';
3
3
  import { useCartesianChartContext } from '../ChartProvider';
4
- import { getBarPath } from '../utils';
4
+ import { defaultBarEnterTransition, defaultTransition, getBarPath, getTransition, withStaggerDelayTransition } from '../utils';
5
+ import { usePathTransition } from '../utils/transition';
5
6
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
6
7
  /**
7
8
  * Default stack component that renders children in a group with animated clip path.
@@ -18,36 +19,39 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
18
19
  borderRadius = 4,
19
20
  roundTop = true,
20
21
  roundBottom = true,
21
- yOrigin
22
+ yOrigin,
23
+ transitions,
24
+ transition
22
25
  } = _ref;
23
26
  const {
24
- animate
27
+ animate,
28
+ drawingArea
25
29
  } = useCartesianChartContext();
26
30
  const clipPathId = useId();
27
- const clipPathData = useMemo(() => {
31
+ const normalizedX = useMemo(() => drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0, [x, drawingArea.x, drawingArea.width]);
32
+ const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedX), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.enter, normalizedX]);
33
+ const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedX), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.update, transition, normalizedX]);
34
+ const targetPath = useMemo(() => {
28
35
  return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
29
36
  }, [x, y, width, height, borderRadius, roundTop, roundBottom]);
30
- const initialClipPathData = useMemo(() => {
31
- return getBarPath(x, yOrigin !== null && yOrigin !== void 0 ? yOrigin : y + height, width, 1, borderRadius, roundTop, roundBottom);
37
+ const initialPath = useMemo(() => {
38
+ const baselineY = yOrigin !== null && yOrigin !== void 0 ? yOrigin : y + height;
39
+ return getBarPath(x, baselineY, width, 1, borderRadius, roundTop, roundBottom);
32
40
  }, [x, yOrigin, y, height, width, borderRadius, roundTop, roundBottom]);
41
+ const animatedClipPath = usePathTransition({
42
+ currentPath: targetPath,
43
+ initialPath,
44
+ transitions: {
45
+ enter: enterTransition,
46
+ update: updateTransition
47
+ }
48
+ });
33
49
  return /*#__PURE__*/_jsxs(_Fragment, {
34
50
  children: [/*#__PURE__*/_jsx("defs", {
35
51
  children: /*#__PURE__*/_jsx("clipPath", {
36
52
  id: clipPathId,
37
- children: animate ? /*#__PURE__*/_jsx(motion.path, {
38
- animate: {
39
- d: clipPathData
40
- },
41
- initial: {
42
- d: initialClipPathData
43
- },
44
- transition: {
45
- type: 'spring',
46
- duration: 1,
47
- bounce: 0
48
- }
49
- }) : /*#__PURE__*/_jsx("path", {
50
- d: clipPathData
53
+ children: /*#__PURE__*/_jsx(motion.path, {
54
+ d: animatedClipPath
51
55
  })
52
56
  })
53
57
  }), /*#__PURE__*/_jsx("g", {
@@ -0,0 +1,104 @@
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 { memo, useMemo } from 'react';
7
+ import { m as motion } from 'framer-motion';
8
+ import { useCartesianChartContext } from '../ChartProvider';
9
+ import { getGradientConfig } from '../utils/gradient';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ /**
12
+ * Renders an SVG linearGradient element based on a GradientDefinition.
13
+ * The gradient can be referenced via `fill="url(#${id})"` or `stroke="url(#${id})"`.
14
+ */
15
+ export const Gradient = /*#__PURE__*/memo(_ref => {
16
+ var _gradient$axis;
17
+ let {
18
+ id,
19
+ gradient,
20
+ yAxisId,
21
+ animate: animateProp,
22
+ transition
23
+ } = _ref;
24
+ const context = useCartesianChartContext();
25
+ const animate = animateProp !== null && animateProp !== void 0 ? animateProp : context.animate;
26
+ const xScale = context.getXScale();
27
+ const yScale = context.getYScale(yAxisId);
28
+
29
+ // Process gradient definition into stops
30
+ const stops = useMemo(() => {
31
+ if (!xScale || !yScale) return;
32
+ return getGradientConfig(gradient, xScale, yScale);
33
+ }, [gradient, xScale, yScale]);
34
+ const drawingArea = context.drawingArea;
35
+ const yAxis = context.getYAxis(yAxisId);
36
+ const xAxis = context.getXAxis();
37
+
38
+ // If gradient processing failed, don't render
39
+ if (!stops) return null;
40
+ const axis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
41
+ let coordinates;
42
+ if (axis === 'y') {
43
+ const yRange = yAxis === null || yAxis === void 0 ? void 0 : yAxis.range;
44
+ if (yRange) {
45
+ coordinates = {
46
+ x1: drawingArea.x,
47
+ y1: yRange.max,
48
+ x2: drawingArea.x,
49
+ y2: yRange.min
50
+ };
51
+ } else {
52
+ coordinates = {
53
+ x1: drawingArea.x,
54
+ y1: drawingArea.y + drawingArea.height,
55
+ x2: drawingArea.x,
56
+ y2: drawingArea.y
57
+ };
58
+ }
59
+ } else {
60
+ const xRange = xAxis === null || xAxis === void 0 ? void 0 : xAxis.range;
61
+ if (xRange) {
62
+ coordinates = {
63
+ x1: xRange.min,
64
+ y1: drawingArea.y,
65
+ x2: xRange.max,
66
+ y2: drawingArea.y
67
+ };
68
+ } else {
69
+ coordinates = {
70
+ x1: drawingArea.x,
71
+ y1: drawingArea.y,
72
+ x2: drawingArea.x + drawingArea.width,
73
+ y2: drawingArea.y
74
+ };
75
+ }
76
+ }
77
+ return /*#__PURE__*/_jsx("linearGradient", _objectSpread(_objectSpread({
78
+ gradientUnits: "userSpaceOnUse",
79
+ id: id
80
+ }, coordinates), {}, {
81
+ children: stops.map((stop, index) => {
82
+ const offset = "".concat(stop.offset * 100, "%");
83
+ const opacity = stop.opacity;
84
+ if (!animate) {
85
+ return /*#__PURE__*/_jsx("stop", {
86
+ offset: offset,
87
+ stopColor: stop.color,
88
+ stopOpacity: opacity !== null && opacity !== void 0 ? opacity : 1
89
+ }, "".concat(id, "-stop-").concat(index));
90
+ }
91
+ return /*#__PURE__*/_jsx(motion.stop, {
92
+ animate: {
93
+ offset
94
+ },
95
+ initial: {
96
+ offset
97
+ },
98
+ stopColor: stop.color,
99
+ stopOpacity: opacity !== null && opacity !== void 0 ? opacity : 1,
100
+ transition: transition
101
+ }, "".concat(id, "-stop-").concat(index));
102
+ })
103
+ }));
104
+ });
@@ -0,0 +1 @@
1
+ export { Gradient } from './Gradient';
@@ -4,10 +4,12 @@ export * from './axis/index';
4
4
  export * from './bar/index';
5
5
  export * from './CartesianChart';
6
6
  export * from './ChartProvider';
7
+ export * from './gradient/index';
8
+ export * from './legend/index';
7
9
  export * from './line/index';
8
10
  export * from './Path';
9
11
  export * from './PeriodSelector';
10
- export * from './Point';
12
+ export * from './point/index';
11
13
  export * from './scrubber/index';
12
14
  export * from './text/index';
13
15
  export * from './utils/index';
@@ -0,0 +1 @@
1
+ .cds-legendEntryCss-l16mq69f{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
@@ -0,0 +1,50 @@
1
+ const _excluded = ["seriesId", "label", "color", "shape", "ShapeComponent", "gap", "className", "classNames", "style", "styles", "testID"];
2
+ 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
6
+ 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); }
7
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
+ 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; }
9
+ import { memo } from 'react';
10
+ import { cx } from '@coinbase/cds-web';
11
+ import { HStack } from '@coinbase/cds-web/layout';
12
+ import { Text } from '@coinbase/cds-web/typography';
13
+ import { DefaultLegendShape } from './DefaultLegendShape';
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ const legendEntryCss = "cds-legendEntryCss-l16mq69f";
16
+ export const DefaultLegendEntry = /*#__PURE__*/memo(_ref => {
17
+ let {
18
+ seriesId,
19
+ label,
20
+ color,
21
+ shape,
22
+ ShapeComponent = DefaultLegendShape,
23
+ gap = 1,
24
+ className,
25
+ classNames,
26
+ style,
27
+ styles,
28
+ testID
29
+ } = _ref,
30
+ props = _objectWithoutProperties(_ref, _excluded);
31
+ return /*#__PURE__*/_jsxs(HStack, _objectSpread(_objectSpread({
32
+ className: cx(legendEntryCss, className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
33
+ "data-testid": testID,
34
+ gap: gap,
35
+ style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
36
+ }, props), {}, {
37
+ children: [/*#__PURE__*/_jsx(ShapeComponent, {
38
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.shape,
39
+ color: color,
40
+ shape: shape,
41
+ style: styles === null || styles === void 0 ? void 0 : styles.shape
42
+ }), typeof label === 'string' ? /*#__PURE__*/_jsx(Text, {
43
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
44
+ font: "label1",
45
+ style: styles === null || styles === void 0 ? void 0 : styles.label,
46
+ children: label
47
+ }) : label]
48
+ }));
49
+ });
50
+ import "./DefaultLegendEntry.css";
@@ -0,0 +1,5 @@
1
+ .cds-containerCss-c18taxk5{width:10px;height:24px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}
2
+ .cds-pillCss-p17vg36s{width:6px;height:24px;border-radius:3px;}
3
+ .cds-circleCss-cge4n06{width:10px;height:10px;border-radius:5px;}
4
+ .cds-squareCss-s4trv9b{width:10px;height:10px;}
5
+ .cds-squircleCss-s1e4cx3y{width:10px;height:10px;border-radius:2px;}
@@ -0,0 +1,47 @@
1
+ const _excluded = ["color", "shape", "className", "style"];
2
+ 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
6
+ 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); }
7
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
+ 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; }
9
+ import React, { memo } from 'react';
10
+ import { cx } from '@coinbase/cds-web';
11
+ import { Box } from '@coinbase/cds-web/layout';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const containerCss = "cds-containerCss-c18taxk5";
14
+ const pillCss = "cds-pillCss-p17vg36s";
15
+ const circleCss = "cds-circleCss-cge4n06";
16
+ const squareCss = "cds-squareCss-s4trv9b";
17
+ const squircleCss = "cds-squircleCss-s1e4cx3y";
18
+ const stylesByVariant = {
19
+ pill: pillCss,
20
+ circle: circleCss,
21
+ square: squareCss,
22
+ squircle: squircleCss
23
+ };
24
+ const isVariantShape = shape => typeof shape === 'string' && shape in stylesByVariant;
25
+ export const DefaultLegendShape = /*#__PURE__*/memo(_ref => {
26
+ let {
27
+ color = 'var(--color-fgPrimary)',
28
+ shape = 'circle',
29
+ className,
30
+ style
31
+ } = _ref,
32
+ props = _objectWithoutProperties(_ref, _excluded);
33
+ if (!isVariantShape(shape)) return shape;
34
+ const variantStyle = stylesByVariant[shape];
35
+ return /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({
36
+ className: cx(containerCss, className),
37
+ style: style
38
+ }, props), {}, {
39
+ children: /*#__PURE__*/_jsx("span", {
40
+ className: variantStyle,
41
+ style: {
42
+ backgroundColor: color
43
+ }
44
+ })
45
+ }));
46
+ });
47
+ import "./DefaultLegendShape.css";