@coinbase/cds-web-visualization 3.4.0-beta.12 → 3.4.0-beta.14

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 (51) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dts/chart/CartesianChart.d.ts +18 -1
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  5. package/dts/chart/bar/Bar.d.ts +4 -0
  6. package/dts/chart/bar/Bar.d.ts.map +1 -1
  7. package/dts/chart/bar/BarChart.d.ts +4 -2
  8. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  9. package/dts/chart/bar/BarStack.d.ts +11 -2
  10. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  11. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  12. package/dts/chart/index.d.ts +1 -0
  13. package/dts/chart/index.d.ts.map +1 -1
  14. package/dts/chart/legend/DefaultLegendEntry.d.ts +21 -0
  15. package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
  16. package/dts/chart/legend/DefaultLegendShape.d.ts +7 -0
  17. package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
  18. package/dts/chart/legend/Legend.d.ts +169 -0
  19. package/dts/chart/legend/Legend.d.ts.map +1 -0
  20. package/dts/chart/legend/index.d.ts +4 -0
  21. package/dts/chart/legend/index.d.ts.map +1 -0
  22. package/dts/chart/line/LineChart.d.ts.map +1 -1
  23. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +25 -1
  24. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
  25. package/dts/chart/scrubber/Scrubber.d.ts +31 -0
  26. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  27. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +10 -0
  28. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
  29. package/dts/chart/utils/chart.d.ts +18 -0
  30. package/dts/chart/utils/chart.d.ts.map +1 -1
  31. package/esm/chart/CartesianChart.js +66 -34
  32. package/esm/chart/area/AreaChart.js +4 -2
  33. package/esm/chart/bar/Bar.js +2 -0
  34. package/esm/chart/bar/BarStack.js +7 -0
  35. package/esm/chart/bar/DefaultBar.js +2 -1
  36. package/esm/chart/index.js +1 -0
  37. package/esm/chart/legend/DefaultLegendEntry.css +1 -0
  38. package/esm/chart/legend/DefaultLegendEntry.js +50 -0
  39. package/esm/chart/legend/DefaultLegendShape.css +5 -0
  40. package/esm/chart/legend/DefaultLegendShape.js +47 -0
  41. package/esm/chart/legend/Legend.js +76 -0
  42. package/esm/chart/legend/index.js +3 -0
  43. package/esm/chart/line/LineChart.js +5 -3
  44. package/esm/chart/scrubber/DefaultScrubberBeacon.js +74 -66
  45. package/esm/chart/scrubber/Scrubber.js +4 -1
  46. package/esm/chart/scrubber/ScrubberBeaconGroup.js +11 -3
  47. package/esm/chart/utils/chart.js +13 -0
  48. package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
  49. package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
  50. package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
  51. package/package.json +5 -6
@@ -1 +1 @@
1
- {"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/chart.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,OAAO,CAAC,UAAU,CAAC,KAAG,MAAM,IAAI,UAChB,CAAC;AAEvD,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,EAAE,EA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rubberPositionChange", "width", "height", "className", "classNames", "style", "styles"];
1
+ const _excluded = ["series", "children", "animate", "xAxis", "yAxis", "inset", "enableScrubbing", "onScrubberPositionChange", "legend", "legendPosition", "legendAccessibilityLabel", "width", "height", "className", "classNames", "style", "styles", "accessibilityLabel"];
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; }
@@ -12,8 +12,9 @@ import { useDimensions } from '@coinbase/cds-web/hooks/useDimensions';
12
12
  import { Box } from '@coinbase/cds-web/layout';
13
13
  import { ScrubberProvider } from './scrubber/ScrubberProvider';
14
14
  import { CartesianChartProvider } from './ChartProvider';
15
+ import { Legend } from './legend';
15
16
  import { defaultAxisId, defaultChartInset, getAxisConfig, getAxisDomain, getAxisRange, getAxisScale, getChartInset, getStackedSeriesData as calculateStackedSeriesData, useTotalAxisPadding } from './utils';
16
- import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
18
  const focusStylesCss = "cds-focusStylesCss-f4oy7ru";
18
19
  export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
19
20
  let {
@@ -25,12 +26,16 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
25
26
  inset,
26
27
  enableScrubbing,
27
28
  onScrubberPositionChange,
29
+ legend,
30
+ legendPosition = 'bottom',
31
+ legendAccessibilityLabel,
28
32
  width = '100%',
29
33
  height = '100%',
30
34
  className,
31
35
  classNames,
32
36
  style,
33
- styles
37
+ styles,
38
+ accessibilityLabel
34
39
  } = _ref,
35
40
  props = _objectWithoutProperties(_ref, _excluded);
36
41
  const {
@@ -269,43 +274,70 @@ export const CartesianChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, r
269
274
  }), [series, getSeries, getStackedSeriesData, animate, chartWidth, chartHeight, getXAxis, getYAxis, getXScale, getYScale, chartRect, dataLength, registerAxis, unregisterAxis, getAxisBounds]);
270
275
  const rootClassNames = useMemo(() => cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root), [className, classNames]);
271
276
  const rootStyles = useMemo(() => _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root), [style, styles === null || styles === void 0 ? void 0 : styles.root]);
277
+ const legendElement = useMemo(() => {
278
+ if (!legend) return;
279
+ if (legend === true) {
280
+ const isHorizontal = legendPosition === 'top' || legendPosition === 'bottom';
281
+ const flexDirection = isHorizontal ? 'row' : 'column';
282
+ return /*#__PURE__*/_jsx(Legend, {
283
+ accessibilityLabel: legendAccessibilityLabel,
284
+ flexDirection: flexDirection
285
+ });
286
+ }
287
+ return legend;
288
+ }, [legend, legendAccessibilityLabel, legendPosition]);
289
+ const rootBoxProps = useMemo(() => _objectSpread({
290
+ className: rootClassNames,
291
+ height,
292
+ style: rootStyles,
293
+ width
294
+ }, props), [rootClassNames, height, rootStyles, width, props]);
295
+ const chartContent = /*#__PURE__*/_jsx(Box, {
296
+ ref: node => {
297
+ observe(node);
298
+ },
299
+ height: legend ? undefined : height,
300
+ style: {
301
+ flex: 1,
302
+ minHeight: 0,
303
+ minWidth: 0
304
+ },
305
+ width: legend ? undefined : width,
306
+ children: /*#__PURE__*/_jsx(Box, {
307
+ ref: node => {
308
+ const svgElement = node;
309
+ svgRef.current = svgElement;
310
+ // Forward the ref to the user
311
+ if (ref) {
312
+ if (typeof ref === 'function') {
313
+ ref(svgElement);
314
+ } else {
315
+ ref.current = svgElement;
316
+ }
317
+ }
318
+ },
319
+ accessibilityLabel: accessibilityLabel,
320
+ "aria-live": "polite",
321
+ as: "svg",
322
+ className: cx(enableScrubbing && focusStylesCss, classNames === null || classNames === void 0 ? void 0 : classNames.chart),
323
+ height: "100%",
324
+ style: styles === null || styles === void 0 ? void 0 : styles.chart,
325
+ tabIndex: enableScrubbing ? 0 : undefined,
326
+ width: "100%",
327
+ children: children
328
+ })
329
+ });
272
330
  return /*#__PURE__*/_jsx(CartesianChartProvider, {
273
331
  value: contextValue,
274
332
  children: /*#__PURE__*/_jsx(ScrubberProvider, {
275
333
  enableScrubbing: !!enableScrubbing,
276
334
  onScrubberPositionChange: onScrubberPositionChange,
277
335
  svgRef: svgRef,
278
- children: /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({
279
- ref: node => {
280
- observe(node);
281
- },
282
- className: rootClassNames,
283
- height: height,
284
- style: rootStyles,
285
- width: width
286
- }, props), {}, {
287
- children: /*#__PURE__*/_jsx(Box, {
288
- ref: node => {
289
- const svgElement = node;
290
- svgRef.current = svgElement;
291
- // Forward the ref to the user
292
- if (ref) {
293
- if (typeof ref === 'function') {
294
- ref(svgElement);
295
- } else {
296
- ref.current = svgElement;
297
- }
298
- }
299
- },
300
- "aria-live": "polite",
301
- as: "svg",
302
- className: cx(enableScrubbing && focusStylesCss, classNames === null || classNames === void 0 ? void 0 : classNames.chart),
303
- height: "100%",
304
- style: styles === null || styles === void 0 ? void 0 : styles.chart,
305
- tabIndex: enableScrubbing ? 0 : undefined,
306
- width: "100%",
307
- children: children
308
- })
336
+ children: legend ? /*#__PURE__*/_jsxs(Box, _objectSpread(_objectSpread({}, rootBoxProps), {}, {
337
+ flexDirection: legendPosition === 'top' || legendPosition === 'bottom' ? 'column' : 'row',
338
+ children: [(legendPosition === 'top' || legendPosition === 'left') && legendElement, chartContent, (legendPosition === 'bottom' || legendPosition === 'right') && legendElement]
339
+ })) : /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({}, rootBoxProps), {}, {
340
+ children: chartContent
309
341
  }))
310
342
  })
311
343
  });
@@ -1,8 +1,8 @@
1
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
- _excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId", "transition"],
5
- _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "type", "lineType", "transition"];
4
+ _excluded4 = ["id", "data", "label", "color", "yAxisId", "opacity", "LineComponent", "stackId", "legendShape", "transition"],
5
+ _excluded5 = ["id", "data", "label", "color", "yAxisId", "fill", "fillOpacity", "stackId", "legendShape", "type", "lineType", "transition"];
6
6
  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; }
7
7
  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; }
8
8
  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; }
@@ -131,6 +131,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
131
131
  opacity,
132
132
  LineComponent,
133
133
  stackId,
134
+ legendShape,
134
135
  transition: seriesTransition
135
136
  } = _ref4,
136
137
  areaPropsFromSeries = _objectWithoutProperties(_ref4, _excluded4);
@@ -153,6 +154,7 @@ export const AreaChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
153
154
  fill,
154
155
  fillOpacity,
155
156
  stackId,
157
+ legendShape,
156
158
  type,
157
159
  // Area type (don't pass to Line)
158
160
  lineType: seriesLineType,
@@ -23,6 +23,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
23
23
  originY,
24
24
  dataX,
25
25
  dataY,
26
+ seriesId,
26
27
  BarComponent = DefaultBar,
27
28
  fill = 'var(--color-fgPrimary)',
28
29
  fillOpacity = 1,
@@ -51,6 +52,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
51
52
  originY: effectiveOriginY,
52
53
  roundBottom: roundBottom,
53
54
  roundTop: roundTop,
55
+ seriesId: seriesId,
54
56
  stroke: stroke,
55
57
  strokeWidth: strokeWidth,
56
58
  transition: transition,
@@ -10,6 +10,11 @@ import { Bar } from './Bar';
10
10
  import { DefaultBarStack } from './DefaultBarStack';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  const EPSILON = 1e-4;
13
+
14
+ /**
15
+ * Extended series type that includes bar-specific properties.
16
+ */
17
+
13
18
  /**
14
19
  * BarStack component that renders a single stack of bars at a specific category index.
15
20
  * Handles the stacking logic for bars within a single category.
@@ -158,6 +163,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
158
163
  // Check if the bar should be rounded based on the baseline, with an epsilon to handle floating-point rounding
159
164
  roundTop: roundBaseline || Math.abs(barTop - baseline) >= EPSILON,
160
165
  roundBottom: roundBaseline || Math.abs(barBottom - baseline) >= EPSILON,
166
+ BarComponent: s.BarComponent,
161
167
  shouldApplyGap
162
168
  });
163
169
  });
@@ -533,6 +539,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
533
539
  originY: baseline,
534
540
  roundBottom: bar.roundBottom,
535
541
  roundTop: bar.roundTop,
542
+ seriesId: bar.seriesId,
536
543
  stroke: (_bar$stroke = bar.stroke) !== null && _bar$stroke !== void 0 ? _bar$stroke : defaultStroke,
537
544
  strokeWidth: (_bar$strokeWidth = bar.strokeWidth) !== null && _bar$strokeWidth !== void 0 ? _bar$strokeWidth : defaultStrokeWidth,
538
545
  transition: transition,
@@ -1,4 +1,4 @@
1
- const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY", "transition"];
1
+ const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY", "seriesId", "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; }
@@ -27,6 +27,7 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
27
27
  fillOpacity = 1,
28
28
  dataX,
29
29
  dataY,
30
+ seriesId,
30
31
  transition
31
32
  } = _ref,
32
33
  props = _objectWithoutProperties(_ref, _excluded);
@@ -5,6 +5,7 @@ export * from './bar/index';
5
5
  export * from './CartesianChart';
6
6
  export * from './ChartProvider';
7
7
  export * from './gradient/index';
8
+ export * from './legend/index';
8
9
  export * from './line/index';
9
10
  export * from './Path';
10
11
  export * from './PeriodSelector';
@@ -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";
@@ -0,0 +1,76 @@
1
+ const _excluded = ["flexDirection", "justifyContent", "alignItems", "flexWrap", "columnGap", "rowGap", "seriesIds", "EntryComponent", "ShapeComponent", "accessibilityLabel", "className", "classNames", "style", "styles"];
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 { forwardRef, memo, useMemo } from 'react';
10
+ import { Box } from '@coinbase/cds-web/layout';
11
+ import { useCartesianChartContext } from '../ChartProvider';
12
+ import { DefaultLegendEntry } from './DefaultLegendEntry';
13
+ import { DefaultLegendShape } from './DefaultLegendShape';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ export const Legend = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
16
+ var _classNames$root;
17
+ let {
18
+ flexDirection = 'row',
19
+ justifyContent = 'center',
20
+ alignItems = flexDirection === 'row' ? 'center' : 'flex-start',
21
+ flexWrap = 'wrap',
22
+ columnGap = 2,
23
+ rowGap = 0.75,
24
+ seriesIds,
25
+ EntryComponent = DefaultLegendEntry,
26
+ ShapeComponent = DefaultLegendShape,
27
+ accessibilityLabel = 'Legend',
28
+ className,
29
+ classNames,
30
+ style,
31
+ styles
32
+ } = _ref,
33
+ props = _objectWithoutProperties(_ref, _excluded);
34
+ const {
35
+ series
36
+ } = useCartesianChartContext();
37
+ const filteredSeries = useMemo(() => {
38
+ if (seriesIds === undefined) return series;
39
+ return series.filter(s => seriesIds.includes(s.id));
40
+ }, [series, seriesIds]);
41
+ if (filteredSeries.length === 0) return;
42
+ return /*#__PURE__*/_jsx(Box, _objectSpread(_objectSpread({
43
+ ref: ref,
44
+ accessibilityLabel: accessibilityLabel,
45
+ alignItems: alignItems,
46
+ className: (_classNames$root = classNames === null || classNames === void 0 ? void 0 : classNames.root) !== null && _classNames$root !== void 0 ? _classNames$root : className,
47
+ columnGap: columnGap,
48
+ flexDirection: flexDirection,
49
+ flexWrap: flexWrap,
50
+ justifyContent: justifyContent,
51
+ role: "group",
52
+ rowGap: rowGap,
53
+ style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
54
+ }, props), {}, {
55
+ children: filteredSeries.map(s => {
56
+ var _s$label;
57
+ return /*#__PURE__*/_jsx(EntryComponent, {
58
+ ShapeComponent: ShapeComponent,
59
+ classNames: {
60
+ root: classNames === null || classNames === void 0 ? void 0 : classNames.entry,
61
+ shape: classNames === null || classNames === void 0 ? void 0 : classNames.entryShape,
62
+ label: classNames === null || classNames === void 0 ? void 0 : classNames.entryLabel
63
+ },
64
+ color: s.color,
65
+ label: (_s$label = s.label) !== null && _s$label !== void 0 ? _s$label : s.id,
66
+ seriesId: s.id,
67
+ shape: s.legendShape,
68
+ styles: {
69
+ root: styles === null || styles === void 0 ? void 0 : styles.entry,
70
+ shape: styles === null || styles === void 0 ? void 0 : styles.entryShape,
71
+ label: styles === null || styles === void 0 ? void 0 : styles.entryLabel
72
+ }
73
+ }, s.id);
74
+ })
75
+ }));
76
+ }));
@@ -0,0 +1,3 @@
1
+ export * from './DefaultLegendEntry';
2
+ export * from './DefaultLegendShape';
3
+ export * from './Legend';
@@ -1,7 +1,7 @@
1
1
  const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
2
2
  _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
4
- _excluded4 = ["id", "data", "label", "color", "yAxisId"];
4
+ _excluded4 = ["id", "data", "label", "color", "yAxisId", "legendShape"];
5
5
  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; }
6
6
  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; }
7
7
  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; }
@@ -51,7 +51,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
51
51
  color: s.color,
52
52
  yAxisId: s.yAxisId,
53
53
  stackId: s.stackId,
54
- gradient: s.gradient
54
+ gradient: s.gradient,
55
+ legendShape: s.legendShape
55
56
  }));
56
57
  }, [series]);
57
58
 
@@ -108,7 +109,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
108
109
  data,
109
110
  label,
110
111
  color,
111
- yAxisId
112
+ yAxisId,
113
+ legendShape
112
114
  } = _ref4,
113
115
  linePropsFromSeries = _objectWithoutProperties(_ref4, _excluded4);
114
116
  return /*#__PURE__*/_jsx(Line, _objectSpread({