@coinbase/cds-web-visualization 3.4.0-beta.2 → 3.4.0-beta.21

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 +122 -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 +99 -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 +303 -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 +56 -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 +45 -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 +101 -392
  166. package/esm/chart/scrubber/ScrubberBeaconGroup.js +174 -0
  167. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +209 -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
@@ -3,16 +3,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
3
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
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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
- import React, { memo, useMemo } from 'react';
6
+ import React, { memo } from 'react';
7
7
  import { cx } from '@coinbase/cds-web';
8
8
  import { useCartesianChartContext } from '../ChartProvider';
9
- import { ChartText } from '../text';
10
9
  import { getPointOnScale } from '../utils';
10
+ import { DefaultReferenceLineLabel } from './DefaultReferenceLineLabel';
11
11
  import { DottedLine } from './DottedLine';
12
-
13
- /**
14
- * Configuration for ReferenceLine label rendering using ChartText.
15
- */
16
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
13
  export const ReferenceLine = /*#__PURE__*/memo(_ref => {
18
14
  let {
@@ -23,8 +19,16 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
23
19
  labelPosition = dataY !== undefined ? 'right' : 'top',
24
20
  testID,
25
21
  LineComponent = DottedLine,
22
+ LabelComponent = DefaultReferenceLineLabel,
23
+ labelElevated,
24
+ labelFont,
25
+ labelDx,
26
+ labelDy,
27
+ labelHorizontalAlignment,
28
+ labelVerticalAlignment,
29
+ labelBoundsInset,
26
30
  stroke = 'var(--color-bgLine)',
27
- labelProps,
31
+ opacity,
28
32
  className,
29
33
  style,
30
34
  classNames,
@@ -36,36 +40,6 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
36
40
  drawingArea
37
41
  } = useCartesianChartContext();
38
42
 
39
- // For horizontal lines (dataY defined): default to verticalAlignment: 'middle'
40
- // For vertical lines (dataX defined): default to horizontalAlignment: 'center'
41
- const isHorizontal = dataY !== undefined;
42
-
43
- // Merge default props with user provided props, including text-specific styles and classNames
44
- const finalLabelProps = useMemo(() => _objectSpread(_objectSpread(_objectSpread({
45
- borderRadius: 4,
46
- color: 'var(--color-fgMuted)',
47
- elevation: 0,
48
- inset: {
49
- top: 8,
50
- bottom: 8,
51
- left: 12,
52
- right: 12
53
- }
54
- }, isHorizontal ? {
55
- verticalAlignment: 'middle'
56
- } : {
57
- horizontalAlignment: 'center'
58
- }), labelProps), {}, {
59
- // Merge classNames for text
60
- classNames: _objectSpread(_objectSpread({}, labelProps === null || labelProps === void 0 ? void 0 : labelProps.classNames), (classNames === null || classNames === void 0 ? void 0 : classNames.label) && {
61
- text: classNames.label
62
- }),
63
- // Merge styles for text
64
- styles: _objectSpread(_objectSpread({}, labelProps === null || labelProps === void 0 ? void 0 : labelProps.styles), (styles === null || styles === void 0 ? void 0 : styles.label) && {
65
- text: styles.label
66
- })
67
- }), [isHorizontal, labelProps, classNames === null || classNames === void 0 ? void 0 : classNames.label, styles === null || styles === void 0 ? void 0 : styles.label]);
68
-
69
43
  // Combine root classNames
70
44
  const rootClassName = cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root);
71
45
  // Combine root styles
@@ -95,13 +69,27 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
95
69
  style: rootStyle,
96
70
  children: [/*#__PURE__*/_jsx(LineComponent, {
97
71
  animate: false,
72
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.line,
98
73
  d: "M".concat(drawingArea.x, ",").concat(yPixel, " L").concat(drawingArea.x + drawingArea.width, ",").concat(yPixel),
99
- stroke: stroke
100
- }), label && /*#__PURE__*/_jsx(ChartText, _objectSpread(_objectSpread({}, finalLabelProps), {}, {
74
+ stroke: stroke,
75
+ strokeOpacity: opacity,
76
+ style: styles === null || styles === void 0 ? void 0 : styles.line
77
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
78
+ boundsInset: labelBoundsInset,
79
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
80
+ dx: labelDx,
81
+ dy: labelDy,
82
+ elevated: labelElevated,
83
+ font: labelFont,
84
+ horizontalAlignment: labelHorizontalAlignment,
85
+ opacity: opacity,
86
+ style: styles === null || styles === void 0 ? void 0 : styles.label,
87
+ testID: testID,
88
+ verticalAlignment: labelVerticalAlignment !== null && labelVerticalAlignment !== void 0 ? labelVerticalAlignment : 'middle',
101
89
  x: labelX,
102
90
  y: yPixel,
103
91
  children: label
104
- }))]
92
+ })]
105
93
  });
106
94
  }
107
95
 
@@ -129,13 +117,27 @@ export const ReferenceLine = /*#__PURE__*/memo(_ref => {
129
117
  style: rootStyle,
130
118
  children: [/*#__PURE__*/_jsx(LineComponent, {
131
119
  animate: false,
120
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.line,
132
121
  d: "M".concat(xPixel, ",").concat(drawingArea.y, " L").concat(xPixel, ",").concat(drawingArea.y + drawingArea.height),
133
- stroke: stroke
134
- }), label && /*#__PURE__*/_jsx(ChartText, _objectSpread(_objectSpread({}, finalLabelProps), {}, {
122
+ stroke: stroke,
123
+ strokeOpacity: opacity,
124
+ style: styles === null || styles === void 0 ? void 0 : styles.line
125
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
126
+ boundsInset: labelBoundsInset,
127
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
128
+ dx: labelDx,
129
+ dy: labelDy,
130
+ elevated: labelElevated,
131
+ font: labelFont,
132
+ horizontalAlignment: labelHorizontalAlignment !== null && labelHorizontalAlignment !== void 0 ? labelHorizontalAlignment : 'center',
133
+ opacity: opacity,
134
+ style: styles === null || styles === void 0 ? void 0 : styles.label,
135
+ testID: testID,
136
+ verticalAlignment: labelVerticalAlignment,
135
137
  x: xPixel,
136
138
  y: labelY,
137
139
  children: label
138
- }))]
140
+ })]
139
141
  });
140
142
  }
141
143
  return;
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth"];
1
+ const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "gradient", "yAxisId", "animate", "transitions", "transition", "d"];
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; }
@@ -6,29 +6,53 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
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
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
- import { memo } from 'react';
9
+ import { memo, useId } from 'react';
10
+ import { Gradient } from '../gradient';
10
11
  import { Path } from '../Path';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
13
  /**
13
- * A customizable solid line component which uses path element.
14
+ * A customizable solid line component.
15
+ * Supports gradient for gradient effects and smooth data transitions.
14
16
  */
15
17
  export const SolidLine = /*#__PURE__*/memo(_ref => {
18
+ var _transitions$update;
16
19
  let {
17
20
  fill = 'none',
18
- stroke = 'var(--color-bgLine)',
21
+ stroke = 'var(--color-fgPrimary)',
19
22
  strokeLinecap = 'round',
20
23
  strokeLinejoin = 'round',
21
24
  strokeOpacity = 1,
22
- strokeWidth = 2
25
+ strokeWidth = 2,
26
+ gradient,
27
+ yAxisId,
28
+ animate,
29
+ transitions,
30
+ transition,
31
+ d
23
32
  } = _ref,
24
33
  props = _objectWithoutProperties(_ref, _excluded);
25
- return /*#__PURE__*/_jsx(Path, _objectSpread({
26
- clipOffset: strokeWidth,
27
- fill: fill,
28
- stroke: stroke,
29
- strokeLinecap: strokeLinecap,
30
- strokeLinejoin: strokeLinejoin,
31
- strokeOpacity: strokeOpacity,
32
- strokeWidth: strokeWidth
33
- }, props));
34
+ const gradientId = useId();
35
+ return /*#__PURE__*/_jsxs(_Fragment, {
36
+ children: [gradient && /*#__PURE__*/_jsx("defs", {
37
+ children: /*#__PURE__*/_jsx(Gradient, {
38
+ animate: animate,
39
+ gradient: gradient,
40
+ id: gradientId,
41
+ transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
42
+ yAxisId: yAxisId
43
+ })
44
+ }), /*#__PURE__*/_jsx(Path, _objectSpread({
45
+ animate: animate,
46
+ clipOffset: strokeWidth,
47
+ d: d,
48
+ fill: fill,
49
+ stroke: gradient ? "url(#".concat(gradientId, ")") : stroke,
50
+ strokeLinecap: strokeLinecap,
51
+ strokeLinejoin: strokeLinejoin,
52
+ strokeOpacity: strokeOpacity,
53
+ strokeWidth: strokeWidth,
54
+ transition: transition,
55
+ transitions: transitions
56
+ }, props))]
57
+ });
34
58
  });
@@ -1,6 +1,6 @@
1
1
  // codegen:start {preset: barrel, include: ./*.tsx, exclude: ./__stories__/*.tsx}
2
+ export * from './DefaultReferenceLineLabel';
2
3
  export * from './DottedLine';
3
- export * from './GradientLine';
4
4
  export * from './Line';
5
5
  export * from './LineChart';
6
6
  export * from './ReferenceLine';
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "startColor", "endColor", "strokeOpacity", "startOpacity", "endOpacity", "strokeLinecap", "strokeLinejoin", "strokeWidth"];
1
+ const _excluded = ["x", "y", "position", "offset", "children"];
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; }
@@ -6,53 +6,39 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
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
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
- import { memo, useId } from 'react';
10
- import { Path } from '../Path';
11
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
9
+ import { memo, useMemo } from 'react';
10
+ import { ChartText } from '../text';
11
+ import { getAlignmentFromPosition, getLabelCoordinates } from '../utils/point';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
12
13
  /**
13
- * A gradient line component which uses path element.
14
+ * DefaultPointLabel is the default label component for point labels.
15
+ * It renders text at the specified position relative to the point.
14
16
  */
15
- export const GradientLine = /*#__PURE__*/memo(_ref => {
17
+ export const DefaultPointLabel = /*#__PURE__*/memo(_ref => {
16
18
  let {
17
- fill = 'none',
18
- stroke = 'var(--color-bgLine)',
19
- startColor,
20
- endColor,
21
- strokeOpacity = 1,
22
- startOpacity = strokeOpacity,
23
- endOpacity = strokeOpacity,
24
- strokeLinecap = 'round',
25
- strokeLinejoin = 'round',
26
- strokeWidth = 2
19
+ x,
20
+ y,
21
+ position = 'center',
22
+ offset,
23
+ children
27
24
  } = _ref,
28
25
  props = _objectWithoutProperties(_ref, _excluded);
29
- const patternId = useId();
30
- return /*#__PURE__*/_jsxs(_Fragment, {
31
- children: [/*#__PURE__*/_jsx("defs", {
32
- children: /*#__PURE__*/_jsxs("linearGradient", {
33
- id: patternId,
34
- x1: "0%",
35
- x2: "0%",
36
- y1: "0%",
37
- y2: "100%",
38
- children: [/*#__PURE__*/_jsx("stop", {
39
- offset: "0%",
40
- stopColor: startColor !== null && startColor !== void 0 ? startColor : stroke,
41
- stopOpacity: startOpacity
42
- }), /*#__PURE__*/_jsx("stop", {
43
- offset: "100%",
44
- stopColor: endColor !== null && endColor !== void 0 ? endColor : stroke,
45
- stopOpacity: endOpacity
46
- })]
47
- })
48
- }), /*#__PURE__*/_jsx(Path, _objectSpread({
49
- clipOffset: strokeWidth,
50
- fill: fill,
51
- stroke: "url(#".concat(patternId, ")"),
52
- strokeLinecap: strokeLinecap,
53
- strokeLinejoin: strokeLinejoin,
54
- strokeOpacity: strokeOpacity,
55
- strokeWidth: strokeWidth
56
- }, props))]
57
- });
26
+ const {
27
+ horizontalAlignment,
28
+ verticalAlignment
29
+ } = useMemo(() => getAlignmentFromPosition(position), [position]);
30
+ const labelCoordinates = useMemo(() => {
31
+ if (offset === undefined) return {
32
+ x,
33
+ y
34
+ };
35
+ return getLabelCoordinates(x, y, position, offset);
36
+ }, [x, y, position, offset]);
37
+ return /*#__PURE__*/_jsx(ChartText, _objectSpread(_objectSpread({}, props), {}, {
38
+ horizontalAlignment: horizontalAlignment,
39
+ verticalAlignment: verticalAlignment,
40
+ x: labelCoordinates.x,
41
+ y: labelCoordinates.y,
42
+ children: children
43
+ }));
58
44
  });
@@ -0,0 +1,2 @@
1
+ .cds-containerCss-ckemp0e{outline:none;}
2
+ .cds-innerPointCss-ik8duli{border-radius:var(--borderRadius-1000);outline:none;}.cds-innerPointCss-ik8duli:focus{outline:none;}.cds-innerPointCss-ik8duli:focus-visible{outline:2px solid var(--color-fgPrimary);outline-offset:2px;}
@@ -1,4 +1,4 @@
1
- const _excluded = ["dataX", "dataY", "yAxisId", "fill", "radius", "opacity", "onClick", "onScrubberEnter", "className", "style", "classNames", "styles", "stroke", "strokeWidth", "accessibilityLabel", "label", "labelProps", "testID", "pixelCoordinates", "animate"];
1
+ const _excluded = ["dataX", "dataY", "yAxisId", "fill", "radius", "opacity", "onClick", "className", "style", "classNames", "styles", "stroke", "strokeWidth", "accessibilityLabel", "label", "LabelComponent", "labelPosition", "labelOffset", "labelFont", "testID", "animate", "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; }
@@ -6,23 +6,18 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
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
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
- import React, { memo, useEffect, useMemo } from 'react';
9
+ import React, { memo, useMemo } from 'react';
10
10
  import { cx } from '@coinbase/cds-web';
11
11
  import { m as motion } from 'framer-motion';
12
- import { useCartesianChartContext } from './ChartProvider';
13
- import { ChartText } from './text';
14
- import { projectPoint, useScrubberContext } from './utils';
15
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
16
- const containerCss = "cds-containerCss-c137x6qr";
17
- const innerPointCss = "cds-innerPointCss-i1qyub1f";
12
+ import { useCartesianChartContext } from '../ChartProvider';
13
+ import { defaultAccessoryEnterTransition, defaultTransition, getTransition, projectPoint } from '../utils';
14
+ import { DefaultPointLabel } from './DefaultPointLabel';
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ const containerCss = "cds-containerCss-ckemp0e";
17
+ const innerPointCss = "cds-innerPointCss-ik8duli";
18
18
 
19
19
  /**
20
- * Parameters passed to renderPoints callback function.
21
- */
22
-
23
- /**
24
- * Shared configuration for point appearance and behavior.
25
- * Used by line-associated points rendered via Line/LineChart components.
20
+ * Props for point label components.
26
21
  */
27
22
 
28
23
  export const Point = /*#__PURE__*/memo(_ref => {
@@ -31,10 +26,9 @@ export const Point = /*#__PURE__*/memo(_ref => {
31
26
  dataY,
32
27
  yAxisId,
33
28
  fill = 'var(--color-fgPrimary)',
34
- radius = 4,
29
+ radius = 5,
35
30
  opacity,
36
31
  onClick,
37
- onScrubberEnter,
38
32
  className,
39
33
  style,
40
34
  classNames,
@@ -43,27 +37,28 @@ export const Point = /*#__PURE__*/memo(_ref => {
43
37
  strokeWidth = 2,
44
38
  accessibilityLabel,
45
39
  label,
46
- labelProps,
40
+ LabelComponent = DefaultPointLabel,
41
+ labelPosition = 'center',
42
+ labelOffset = radius * 2,
43
+ labelFont,
47
44
  testID,
48
- pixelCoordinates,
49
- animate
45
+ animate: animateProp,
46
+ transitions,
47
+ transition
50
48
  } = _ref,
51
49
  svgProps = _objectWithoutProperties(_ref, _excluded);
52
50
  const {
53
51
  getXScale,
54
52
  getYScale,
55
- animate: animationEnabled
53
+ animate: animationEnabled,
54
+ drawingArea
56
55
  } = useCartesianChartContext();
57
- const {
58
- scrubberPosition
59
- } = useScrubberContext();
56
+ const animate = animateProp !== null && animateProp !== void 0 ? animateProp : animationEnabled;
57
+ const enterTransition = useMemo(() => getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultAccessoryEnterTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.enter]);
58
+ const updateTransition = useMemo(() => getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.update, transition]);
60
59
  const xScale = getXScale();
61
60
  const yScale = getYScale(yAxisId);
62
- const isScrubberHighlighted = scrubberPosition !== undefined && scrubberPosition === dataX;
63
61
  const pixelCoordinate = useMemo(() => {
64
- if (pixelCoordinates) {
65
- return pixelCoordinates;
66
- }
67
62
  if (!xScale || !yScale) {
68
63
  return {
69
64
  x: 0,
@@ -76,15 +71,11 @@ export const Point = /*#__PURE__*/memo(_ref => {
76
71
  xScale,
77
72
  yScale
78
73
  });
79
- }, [xScale, yScale, dataX, dataY, pixelCoordinates]);
80
- useEffect(() => {
81
- if (isScrubberHighlighted && onScrubberEnter) {
82
- onScrubberEnter({
83
- x: pixelCoordinate.x,
84
- y: pixelCoordinate.y
85
- });
86
- }
87
- }, [isScrubberHighlighted, onScrubberEnter, pixelCoordinate.x, pixelCoordinate.y]);
74
+ }, [xScale, yScale, dataX, dataY]);
75
+ const isWithinDrawingArea = useMemo(() => {
76
+ if (!pixelCoordinate) return false;
77
+ return pixelCoordinate.x >= drawingArea.x && pixelCoordinate.x <= drawingArea.x + drawingArea.width && pixelCoordinate.y >= drawingArea.y && pixelCoordinate.y <= drawingArea.y + drawingArea.height;
78
+ }, [pixelCoordinate, drawingArea]);
88
79
  const innerPoint = useMemo(() => {
89
80
  const mergedStyles = _objectSpread(_objectSpread({
90
81
  cursor: onClick !== undefined ? 'pointer' : undefined
@@ -113,21 +104,38 @@ export const Point = /*#__PURE__*/memo(_ref => {
113
104
  });
114
105
  }
115
106
  } : undefined;
116
-
117
- // Use the animate prop if provided, otherwise fall back to chart context
118
- const shouldAnimateInteractions = animate !== null && animate !== void 0 ? animate : animationEnabled;
119
- const shouldAnimatePosition = animate !== null && animate !== void 0 ? animate : animationEnabled;
107
+ if (!animate) {
108
+ return /*#__PURE__*/_jsx("circle", _objectSpread({
109
+ "aria-label": accessibilityLabel,
110
+ className: cx(innerPointCss, className, classNames === null || classNames === void 0 ? void 0 : classNames.point),
111
+ cx: pixelCoordinate.x,
112
+ cy: pixelCoordinate.y,
113
+ fill: fill,
114
+ onClick: onClick ? event => onClick(event, {
115
+ dataX,
116
+ dataY,
117
+ x: pixelCoordinate.x,
118
+ y: pixelCoordinate.y
119
+ }) : undefined,
120
+ onKeyDown: handleKeyDown,
121
+ r: radius,
122
+ role: onClick ? 'button' : undefined,
123
+ stroke: stroke,
124
+ strokeWidth: strokeWidth,
125
+ style: mergedStyles,
126
+ tabIndex: onClick ? 0 : -1
127
+ }, svgProps));
128
+ }
120
129
  return /*#__PURE__*/_jsx(motion.circle, _objectSpread({
121
- animate: shouldAnimatePosition ? {
130
+ animate: {
122
131
  cx: pixelCoordinate.x,
123
132
  cy: pixelCoordinate.y
124
- } : undefined,
133
+ },
125
134
  "aria-label": accessibilityLabel,
126
135
  className: cx(innerPointCss, className, classNames === null || classNames === void 0 ? void 0 : classNames.point),
127
136
  cx: pixelCoordinate.x,
128
137
  cy: pixelCoordinate.y,
129
138
  fill: fill,
130
- initial: false,
131
139
  onClick: onClick ? event => onClick(event, {
132
140
  dataX,
133
141
  dataY,
@@ -142,30 +150,47 @@ export const Point = /*#__PURE__*/memo(_ref => {
142
150
  style: mergedStyles,
143
151
  tabIndex: onClick ? 0 : -1,
144
152
  transition: {
145
- duration: 0.3,
146
- ease: 'easeInOut'
153
+ cx: updateTransition,
154
+ cy: updateTransition
147
155
  },
148
156
  variants: variants,
149
- whileHover: shouldAnimateInteractions && onClick ? 'hovered' : 'default',
150
- whileTap: shouldAnimateInteractions && onClick ? 'pressed' : 'default'
157
+ whileHover: onClick ? 'hovered' : 'default',
158
+ whileTap: onClick ? 'pressed' : 'default'
151
159
  }, svgProps));
152
- }, [style, styles === null || styles === void 0 ? void 0 : styles.point, classNames === null || classNames === void 0 ? void 0 : classNames.point, fill, animate, animationEnabled, radius, className, onClick, stroke, strokeWidth, svgProps, dataX, dataY, pixelCoordinate.x, pixelCoordinate.y, accessibilityLabel]);
160
+ }, [style, styles === null || styles === void 0 ? void 0 : styles.point, classNames === null || classNames === void 0 ? void 0 : classNames.point, fill, animate, radius, className, onClick, stroke, strokeWidth, svgProps, dataX, dataY, pixelCoordinate.x, pixelCoordinate.y, accessibilityLabel, updateTransition]);
153
161
  if (!xScale || !yScale) {
154
- return null;
162
+ return;
155
163
  }
156
- return /*#__PURE__*/_jsxs(_Fragment, {
157
- children: [/*#__PURE__*/_jsx("g", {
158
- className: cx(containerCss, classNames === null || classNames === void 0 ? void 0 : classNames.container),
159
- "data-testid": testID,
160
- opacity: opacity,
161
- style: styles === null || styles === void 0 ? void 0 : styles.container,
162
- children: innerPoint
163
- }), label && /*#__PURE__*/_jsx(ChartText, _objectSpread(_objectSpread({
164
- x: pixelCoordinate.x,
165
- y: pixelCoordinate.y
166
- }, labelProps), {}, {
167
- children: label
168
- }))]
164
+ return /*#__PURE__*/_jsx("g", {
165
+ opacity: isWithinDrawingArea ? 1 : 0,
166
+ children: /*#__PURE__*/_jsxs(motion.g, {
167
+ animate: {
168
+ opacity: 1
169
+ },
170
+ initial: animate ? {
171
+ opacity: 0
172
+ } : false,
173
+ transition: {
174
+ opacity: enterTransition
175
+ },
176
+ children: [/*#__PURE__*/_jsx("g", {
177
+ className: cx(containerCss, classNames === null || classNames === void 0 ? void 0 : classNames.root),
178
+ "data-testid": testID,
179
+ opacity: opacity,
180
+ style: styles === null || styles === void 0 ? void 0 : styles.root,
181
+ children: innerPoint
182
+ }), label && /*#__PURE__*/_jsx(LabelComponent, {
183
+ dataX: dataX,
184
+ dataY: dataY,
185
+ fill: fill,
186
+ font: labelFont,
187
+ offset: labelOffset,
188
+ position: labelPosition,
189
+ x: pixelCoordinate.x,
190
+ y: pixelCoordinate.y,
191
+ children: label
192
+ })]
193
+ })
169
194
  });
170
195
  });
171
196
  import "./Point.css";
@@ -0,0 +1,2 @@
1
+ export * from './DefaultPointLabel';
2
+ export * from './Point';