@coinbase/cds-web-visualization 3.3.0 → 3.4.0-beta.1

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 (204) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dts/chart/CartesianChart.d.ts +36 -0
  3. package/dts/chart/CartesianChart.d.ts.map +1 -0
  4. package/dts/chart/ChartProvider.d.ts +6 -0
  5. package/dts/chart/ChartProvider.d.ts.map +1 -0
  6. package/dts/chart/Path.d.ts +34 -0
  7. package/dts/chart/Path.d.ts.map +1 -0
  8. package/dts/chart/PeriodSelector.d.ts +61 -0
  9. package/dts/chart/PeriodSelector.d.ts.map +1 -0
  10. package/dts/chart/Point.d.ts +153 -0
  11. package/dts/chart/Point.d.ts.map +1 -0
  12. package/dts/chart/area/Area.d.ts +48 -0
  13. package/dts/chart/area/Area.d.ts.map +1 -0
  14. package/dts/chart/area/AreaChart.d.ts +52 -0
  15. package/dts/chart/area/AreaChart.d.ts.map +1 -0
  16. package/dts/chart/area/DottedArea.d.ts +68 -0
  17. package/dts/chart/area/DottedArea.d.ts.map +1 -0
  18. package/dts/chart/area/GradientArea.d.ts +30 -0
  19. package/dts/chart/area/GradientArea.d.ts.map +1 -0
  20. package/dts/chart/area/SolidArea.d.ts +8 -0
  21. package/dts/chart/area/SolidArea.d.ts.map +1 -0
  22. package/dts/chart/area/index.d.ts +6 -0
  23. package/dts/chart/area/index.d.ts.map +1 -0
  24. package/dts/chart/axis/Axis.d.ts +208 -0
  25. package/dts/chart/axis/Axis.d.ts.map +1 -0
  26. package/dts/chart/axis/XAxis.d.ts +16 -0
  27. package/dts/chart/axis/XAxis.d.ts.map +1 -0
  28. package/dts/chart/axis/YAxis.d.ts +21 -0
  29. package/dts/chart/axis/YAxis.d.ts.map +1 -0
  30. package/dts/chart/axis/index.d.ts +4 -0
  31. package/dts/chart/axis/index.d.ts.map +1 -0
  32. package/dts/chart/bar/Bar.d.ts +91 -0
  33. package/dts/chart/bar/Bar.d.ts.map +1 -0
  34. package/dts/chart/bar/BarChart.d.ts +53 -0
  35. package/dts/chart/bar/BarChart.d.ts.map +1 -0
  36. package/dts/chart/bar/BarPlot.d.ts +29 -0
  37. package/dts/chart/bar/BarPlot.d.ts.map +1 -0
  38. package/dts/chart/bar/BarStack.d.ts +111 -0
  39. package/dts/chart/bar/BarStack.d.ts.map +1 -0
  40. package/dts/chart/bar/BarStackGroup.d.ts +35 -0
  41. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
  42. package/dts/chart/bar/DefaultBar.d.ts +17 -0
  43. package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
  44. package/dts/chart/bar/DefaultBarStack.d.ts +16 -0
  45. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
  46. package/dts/chart/bar/index.d.ts +8 -0
  47. package/dts/chart/bar/index.d.ts.map +1 -0
  48. package/dts/chart/index.d.ts +13 -0
  49. package/dts/chart/index.d.ts.map +1 -0
  50. package/dts/chart/line/DottedLine.d.ts +14 -0
  51. package/dts/chart/line/DottedLine.d.ts.map +1 -0
  52. package/dts/chart/line/GradientLine.d.ts +42 -0
  53. package/dts/chart/line/GradientLine.d.ts.map +1 -0
  54. package/dts/chart/line/Line.d.ts +80 -0
  55. package/dts/chart/line/Line.d.ts.map +1 -0
  56. package/dts/chart/line/LineChart.d.ts +59 -0
  57. package/dts/chart/line/LineChart.d.ts.map +1 -0
  58. package/dts/chart/line/ReferenceLine.d.ts +131 -0
  59. package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
  60. package/dts/chart/line/SolidLine.d.ts +14 -0
  61. package/dts/chart/line/SolidLine.d.ts.map +1 -0
  62. package/dts/chart/line/index.d.ts +7 -0
  63. package/dts/chart/line/index.d.ts.map +1 -0
  64. package/dts/chart/scrubber/Scrubber.d.ts +149 -0
  65. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
  66. package/dts/chart/scrubber/ScrubberBeacon.d.ts +93 -0
  67. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +1 -0
  68. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +7 -0
  69. package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +1 -0
  70. package/dts/chart/scrubber/ScrubberProvider.d.ts +17 -0
  71. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
  72. package/dts/chart/scrubber/index.d.ts +2 -0
  73. package/dts/chart/scrubber/index.d.ts.map +1 -0
  74. package/dts/chart/text/ChartText.d.ts +114 -0
  75. package/dts/chart/text/ChartText.d.ts.map +1 -0
  76. package/dts/chart/text/SmartChartTextGroup.d.ts +55 -0
  77. package/dts/chart/text/SmartChartTextGroup.d.ts.map +1 -0
  78. package/dts/chart/text/index.d.ts +3 -0
  79. package/dts/chart/text/index.d.ts.map +1 -0
  80. package/dts/chart/utils/axis.d.ts +342 -0
  81. package/dts/chart/utils/axis.d.ts.map +1 -0
  82. package/dts/chart/utils/bar.d.ts +20 -0
  83. package/dts/chart/utils/bar.d.ts.map +1 -0
  84. package/dts/chart/utils/chart.d.ts +97 -0
  85. package/dts/chart/utils/chart.d.ts.map +1 -0
  86. package/dts/chart/utils/context.d.ts +95 -0
  87. package/dts/chart/utils/context.d.ts.map +1 -0
  88. package/dts/chart/utils/index.d.ts +8 -0
  89. package/dts/chart/utils/index.d.ts.map +1 -0
  90. package/dts/chart/utils/path.d.ts +107 -0
  91. package/dts/chart/utils/path.d.ts.map +1 -0
  92. package/dts/chart/utils/point.d.ts +75 -0
  93. package/dts/chart/utils/point.d.ts.map +1 -0
  94. package/dts/chart/utils/scale.d.ts +43 -0
  95. package/dts/chart/utils/scale.d.ts.map +1 -0
  96. package/dts/index.d.ts +2 -1
  97. package/dts/index.d.ts.map +1 -1
  98. package/dts/sparkline/Counter.d.ts +7 -2
  99. package/dts/sparkline/Sparkline.d.ts +61 -16
  100. package/dts/sparkline/Sparkline.d.ts.map +1 -1
  101. package/dts/sparkline/SparklineArea.d.ts +12 -4
  102. package/dts/sparkline/SparklineArea.d.ts.map +1 -1
  103. package/dts/sparkline/SparklineAreaPattern.d.ts +12 -4
  104. package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
  105. package/dts/sparkline/SparklineGradient.d.ts +21 -10
  106. package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
  107. package/dts/sparkline/SparklinePath.d.ts +8 -6
  108. package/dts/sparkline/__figma__/Sparkline.figma.d.ts +1 -1
  109. package/dts/sparkline/generateSparklineWithId.d.ts +8 -2
  110. package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
  111. package/dts/sparkline/index.d.ts +1 -1
  112. package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts +9 -5
  113. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +168 -118
  114. package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
  115. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +22 -9
  116. package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
  117. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +4 -2
  118. package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts +4 -2
  119. package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +5 -3
  120. package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +11 -6
  121. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +21 -7
  122. package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
  123. package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +21 -16
  124. package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +17 -12
  125. package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts +23 -10
  126. package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts +12 -12
  127. package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +22 -14
  128. package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +1 -1
  129. package/dts/sparkline/sparkline-interactive/fade.d.ts +1 -1
  130. package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +11 -11
  131. package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +101 -93
  132. package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +1 -1
  133. package/esm/chart/CartesianChart.css +1 -0
  134. package/esm/chart/CartesianChart.js +258 -0
  135. package/esm/chart/ChartProvider.js +10 -0
  136. package/esm/chart/Path.js +89 -0
  137. package/esm/chart/PeriodSelector.css +1 -0
  138. package/esm/chart/PeriodSelector.js +126 -0
  139. package/esm/chart/Point.css +2 -0
  140. package/esm/chart/Point.js +171 -0
  141. package/esm/chart/area/Area.js +85 -0
  142. package/esm/chart/area/AreaChart.js +164 -0
  143. package/esm/chart/area/DottedArea.js +141 -0
  144. package/esm/chart/area/GradientArea.js +111 -0
  145. package/esm/chart/area/SolidArea.js +29 -0
  146. package/esm/chart/area/index.js +7 -0
  147. package/esm/chart/axis/Axis.js +46 -0
  148. package/esm/chart/axis/XAxis.css +2 -0
  149. package/esm/chart/axis/XAxis.js +195 -0
  150. package/esm/chart/axis/YAxis.css +2 -0
  151. package/esm/chart/axis/YAxis.js +183 -0
  152. package/esm/chart/axis/index.js +5 -0
  153. package/esm/chart/bar/Bar.js +59 -0
  154. package/esm/chart/bar/BarChart.js +147 -0
  155. package/esm/chart/bar/BarPlot.js +96 -0
  156. package/esm/chart/bar/BarStack.js +519 -0
  157. package/esm/chart/bar/BarStackGroup.js +96 -0
  158. package/esm/chart/bar/DefaultBar.js +64 -0
  159. package/esm/chart/bar/DefaultBarStack.js +60 -0
  160. package/esm/chart/bar/index.js +9 -0
  161. package/esm/chart/index.js +14 -0
  162. package/esm/chart/line/DottedLine.js +38 -0
  163. package/esm/chart/line/GradientLine.js +58 -0
  164. package/esm/chart/line/Line.js +159 -0
  165. package/esm/chart/line/LineChart.js +120 -0
  166. package/esm/chart/line/ReferenceLine.js +142 -0
  167. package/esm/chart/line/SolidLine.js +34 -0
  168. package/esm/chart/line/index.js +8 -0
  169. package/esm/chart/scrubber/Scrubber.js +483 -0
  170. package/esm/chart/scrubber/ScrubberBeacon.js +195 -0
  171. package/esm/chart/scrubber/ScrubberBeaconLabel.js +33 -0
  172. package/esm/chart/scrubber/ScrubberProvider.js +228 -0
  173. package/esm/chart/scrubber/index.js +2 -0
  174. package/esm/chart/text/ChartText.js +236 -0
  175. package/esm/chart/text/SmartChartTextGroup.js +226 -0
  176. package/esm/chart/text/index.js +4 -0
  177. package/esm/chart/utils/axis.js +593 -0
  178. package/esm/chart/utils/bar.js +24 -0
  179. package/esm/chart/utils/chart.js +229 -0
  180. package/esm/chart/utils/context.js +15 -0
  181. package/esm/chart/utils/index.js +9 -0
  182. package/esm/chart/utils/path.js +204 -0
  183. package/esm/chart/utils/point.js +118 -0
  184. package/esm/chart/utils/scale.js +48 -0
  185. package/esm/index.js +4 -1
  186. package/esm/sparkline/Sparkline.js +129 -15
  187. package/esm/sparkline/SparklineArea.js +7 -2
  188. package/esm/sparkline/SparklineAreaPattern.js +4 -2
  189. package/esm/sparkline/SparklineGradient.js +16 -58
  190. package/esm/sparkline/generateSparklineWithId.js +3 -2
  191. package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
  192. package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
  193. package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
  194. package/package.json +15 -11
  195. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +0 -374
  196. package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +0 -1
  197. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +0 -2
  198. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +0 -1
  199. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +0 -2
  200. package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +0 -1
  201. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +0 -87
  202. package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +0 -1
  203. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +0 -2
  204. package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +0 -1
@@ -0,0 +1,97 @@
1
+ export declare const defaultStackId = 'DEFAULT_STACK_ID';
2
+ export type AxisBounds = {
3
+ min: number;
4
+ max: number;
5
+ };
6
+ /**
7
+ * Type guard to check if bounds are complete with both min and max values.
8
+ * @param bounds - The bounds to validate
9
+ * @returns True if bounds has both min and max defined
10
+ */
11
+ export declare const isValidBounds: (bounds: Partial<AxisBounds>) => bounds is AxisBounds;
12
+ export type Series = {
13
+ /**
14
+ * The id of the series.
15
+ */
16
+ id: string;
17
+ /**
18
+ * The data array for this series. Use null values to create gaps in the visualization.
19
+ *
20
+ * Can be either:
21
+ * - Array of numbers: `[10, -5, 20]`
22
+ * - Array of tuples: `[[0, 10], [0, -5], [0, 20]]` [baseline, value] pairs
23
+ */
24
+ data?: Array<number | null> | Array<[number, number] | null>;
25
+ /**
26
+ * The label of the series. Can be a React node or a function that receives the data index and returns a React node.
27
+ */
28
+ label?: string | ((dataIndex: number) => string);
29
+ /**
30
+ * The color of the series.
31
+ */
32
+ color?: string;
33
+ /**
34
+ * The ID of the y-axis this series uses.
35
+ * Defaults to defaultAxisId if not specified.
36
+ */
37
+ yAxisId?: string;
38
+ /**
39
+ * The stack group this series belongs to.
40
+ * Series with the same stackId value will be stacked together.
41
+ * If not specified, the series will not be stacked.
42
+ */
43
+ stackId?: string;
44
+ };
45
+ /**
46
+ * Calculates the domain of a chart from series data.
47
+ * Domain represents the range of x-values from the data.
48
+ */
49
+ export declare const getChartDomain: (
50
+ series: Series[],
51
+ min?: number,
52
+ max?: number,
53
+ ) => Partial<AxisBounds>;
54
+ /**
55
+ * Transforms series data into stacked data using D3's stack algorithm.
56
+ * Returns a map of series ID to transformed [baseline, value] tuples.
57
+ *
58
+ * @param series - Array of series with potential stack properties
59
+ * @returns Map of series ID to stacked data arrays
60
+ */
61
+ export declare const getStackedSeriesData: (
62
+ series: Series[],
63
+ ) => Map<string, Array<[number, number] | null>>;
64
+ /**
65
+ * Calculates the range of a chart from series data.
66
+ * Range represents the range of y-values from the data.
67
+ * Handles stacking by transforming data when series have stack properties.
68
+ */
69
+ export declare const getChartRange: (
70
+ series: Series[],
71
+ min?: number,
72
+ max?: number,
73
+ ) => Partial<AxisBounds>;
74
+ export type ChartInset = {
75
+ top: number;
76
+ left: number;
77
+ bottom: number;
78
+ right: number;
79
+ };
80
+ export declare const defaultChartInset: ChartInset;
81
+ /**
82
+ * Normalize padding to include all sides with a value.
83
+ * @param padding - The padding to get.
84
+ * @param defaults - Optional complete default values to use instead of 0.
85
+ * @returns The calculated padding.
86
+ */
87
+ /**
88
+ * Normalize inset to include all sides with a value.
89
+ * @param inset - The inset to get.
90
+ * @param defaults - Optional complete default values to use instead of 0.
91
+ * @returns The calculated inset.
92
+ */
93
+ export declare const getChartInset: (
94
+ inset?: number | Partial<ChartInset>,
95
+ defaults?: ChartInset,
96
+ ) => ChartInset;
97
+ //# sourceMappingURL=chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/chart.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAA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iBAAiB,EAAE,UAK/B,CAAC;AAEF;;;;;GAKG;AACH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,EACpC,WAAW,UAAU,KACpB,UAuBF,CAAC"}
@@ -0,0 +1,95 @@
1
+ import type { Rect } from '@coinbase/cds-common/types';
2
+ import type { AxisConfig } from './axis';
3
+ import type { Series } from './chart';
4
+ import type { ChartScaleFunction } from './scale';
5
+ /**
6
+ * Context value for Cartesian (X/Y) coordinate charts.
7
+ * Contains axis-specific methods and properties for rectangular coordinate systems.
8
+ */
9
+ export type CartesianChartContextValue = {
10
+ /**
11
+ * The series data for the chart.
12
+ */
13
+ series: Series[];
14
+ /**
15
+ * Returns the series which matches the seriesId or undefined.
16
+ * @param seriesId - A series' id
17
+ */
18
+ getSeries: (seriesId?: string) => Series | undefined;
19
+ /**
20
+ * Returns the data for a series
21
+ * @param seriesId - A series' id
22
+ * @returns data for series, if series exists
23
+ */
24
+ getSeriesData: (seriesId?: string) => Array<[number, number] | null> | undefined;
25
+ /**
26
+ * Whether to animate the chart.
27
+ */
28
+ animate: boolean;
29
+ /**
30
+ * Width of the chart SVG.
31
+ */
32
+ width: number;
33
+ /**
34
+ * Height of the chart SVG.
35
+ */
36
+ height: number;
37
+ /**
38
+ * Get x-axis configuration.
39
+ */
40
+ getXAxis: () => AxisConfig | undefined;
41
+ /**
42
+ * Get y-axis configuration by ID.
43
+ * @param id - The axis ID. Defaults to defaultAxisId.
44
+ */
45
+ getYAxis: (id?: string) => AxisConfig | undefined;
46
+ /**
47
+ * Get x-axis scale function.
48
+ */
49
+ getXScale: () => ChartScaleFunction | undefined;
50
+ /**
51
+ * Get y-axis scale function by ID.
52
+ * @param id - The axis ID. Defaults to defaultAxisId.
53
+ */
54
+ getYScale: (id?: string) => ChartScaleFunction | undefined;
55
+ /**
56
+ * Drawing area of the chart.
57
+ */
58
+ drawingArea: Rect;
59
+ /**
60
+ * Registers an axis.
61
+ * Used by axis components to reserve space in the chart, preventing overlap with the drawing area.
62
+ * @param id - The axis ID
63
+ * @param position - The axis position ('top'/'bottom' for x-axis, 'left'/'right' for y-axis)
64
+ * @param size - The size of the axis in pixels
65
+ */
66
+ registerAxis: (id: string, position: 'top' | 'bottom' | 'left' | 'right', size: number) => void;
67
+ /**
68
+ * Unregisters an axis.
69
+ */
70
+ unregisterAxis: (id: string) => void;
71
+ /**
72
+ * Gets the rectangle bounds of a requested axis.
73
+ * Computes the bounds of the axis based on the chart's drawing area chart/axis config, and axis position.
74
+ */
75
+ getAxisBounds: (id: string) => Rect | undefined;
76
+ };
77
+ export type ScrubberContextValue = {
78
+ /**
79
+ * Enables scrubbing interactions.
80
+ * When true, allows scrubbing and makes scrubber components interactive.
81
+ */
82
+ enableScrubbing: boolean;
83
+ /**
84
+ * The current position of the scrubber.
85
+ */
86
+ scrubberPosition?: number;
87
+ /**
88
+ * Callback fired when the scrubber position changes.
89
+ * Receives the dataIndex of the scrubber or undefined when not scrubbing.
90
+ */
91
+ onScrubberPositionChange: (index: number | undefined) => void;
92
+ };
93
+ export declare const ScrubberContext: import('react').Context<ScrubberContextValue | undefined>;
94
+ export declare const useScrubberContext: () => ScrubberContextValue;
95
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,SAAS,EAAE,CA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;CAC/D,CAAC;AAEF,eAAO,MAAM,eAAe,2DAA6D,CAAC;AAE1F,eAAO,MAAM,kBAAkB,QAAO,oBAMrC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './axis';
2
+ export * from './bar';
3
+ export * from './chart';
4
+ export * from './context';
5
+ export * from './path';
6
+ export * from './point';
7
+ export * from './scale';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { type ChartScaleFunction } from './scale';
2
+ export type ChartPathCurveType =
3
+ | 'bump'
4
+ | 'catmullRom'
5
+ | 'linear'
6
+ | 'linearClosed'
7
+ | 'monotone'
8
+ | 'natural'
9
+ | 'step'
10
+ | 'stepBefore'
11
+ | 'stepAfter';
12
+ /**
13
+ * Get the d3 curve function for a path.
14
+ * See https://d3js.org/d3-shape/curve
15
+ * @param curve - The curve type. Defaults to 'linear'.
16
+ * @returns The d3 curve function.
17
+ */
18
+ export declare const getPathCurveFunction: (
19
+ curve?: ChartPathCurveType,
20
+ ) => import('d3-shape').CurveFactory;
21
+ /**
22
+ * Generates an SVG line path string from data using chart scale functions.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
27
+ * const path = getLinePath({ data: [1, 2, 3], chartScale, curve: 'linear' });
28
+ * ```
29
+ */
30
+ export declare const getLinePath: ({
31
+ data,
32
+ curve,
33
+ xScale,
34
+ yScale,
35
+ xData,
36
+ }: {
37
+ data: (
38
+ | number
39
+ | null
40
+ | {
41
+ x: number;
42
+ y: number;
43
+ }
44
+ )[];
45
+ curve?: ChartPathCurveType;
46
+ xScale: ChartScaleFunction;
47
+ yScale: ChartScaleFunction;
48
+ xData?: number[];
49
+ }) => string;
50
+ /**
51
+ * Generates an SVG area path string from data using chart scale functions.
52
+ * Supports both single values (area from baseline to value) and tuples ([baseline, value]).
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // Single values - area from baseline to value
57
+ * const area = getAreaPath({
58
+ * data: [1, 2, 3],
59
+ * xScale,
60
+ * yScale,
61
+ * });
62
+ *
63
+ * // Range values - area from low to high
64
+ * const rangeArea = getAreaPath({
65
+ * data: [[0, 3], [2, 4], [1, 5]],
66
+ * xScale,
67
+ * yScale,
68
+ * curve: 'monotone'
69
+ * });
70
+ * ```
71
+ */
72
+ export declare const getAreaPath: ({
73
+ data,
74
+ curve,
75
+ xScale,
76
+ yScale,
77
+ xData,
78
+ }: {
79
+ data: (number | null)[] | Array<[number, number] | null>;
80
+ xScale: ChartScaleFunction;
81
+ yScale: ChartScaleFunction;
82
+ curve: ChartPathCurveType;
83
+ xData?: number[];
84
+ }) => string;
85
+ /**
86
+ * Creates an SVG path string for a rectangle with selective corner rounding.
87
+ * Useful for creating bars in charts with optional rounded corners.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * // Simple rectangle bar
92
+ * const barPath = getBarPath(10, 20, 50, 100, 0, false, false);
93
+ *
94
+ * // Bar with rounded top corners
95
+ * const roundedPath = getBarPath(10, 20, 50, 100, 8, true, false);
96
+ * ```
97
+ */
98
+ export declare const getBarPath: (
99
+ x: number,
100
+ y: number,
101
+ width: number,
102
+ height: number,
103
+ radius: number,
104
+ roundTop: boolean,
105
+ roundBottom: boolean,
106
+ ) => string;
107
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/path.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,cAAc,GACd,UAAU,GACV,SAAS,GACT,MAAM,GACN,YAAY,GACZ,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAO,kBAA6B,oCAsBxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,yCAMzB;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IACnD,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,KAAG,MAgBH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,yCAMzB;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACzD,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,KAAG,MAgFH,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GACrB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,UAAU,OAAO,EACjB,aAAa,OAAO,KACnB,MA0BF,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { type ChartScaleFunction } from './scale';
2
+ /**
3
+ * Get a point from a data value and a scale.
4
+ * @note for categorical scales, the point will be centered within the band.
5
+ * @note for log scales, zero and negative values are clamped to a small positive value.
6
+ * @param data - the data value.
7
+ * @param scale - the scale function.
8
+ * @returns the pixel value (defaulting to 0 if data value is not defined in scale).
9
+ */
10
+ export declare const getPointOnScale: (dataValue: number, scale: ChartScaleFunction) => number;
11
+ /**
12
+ * Projects a data point to pixel coordinates using the chart scale.
13
+ * Automatically handles log scale transformations for zero/negative values.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
18
+ * const pixelCoord = projectPoint({ x: 5, y: 10, chartScale });
19
+ * ```
20
+ * @example
21
+ * ```typescript
22
+ * const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
23
+ * const pixelCoord = projectPoint({ x: 2, y: 10, chartScale, xData: ['Jan', 'Feb', 'Mar'] });
24
+ * ```
25
+ */
26
+ export declare const projectPoint: ({
27
+ x,
28
+ y,
29
+ xScale,
30
+ yScale,
31
+ }: {
32
+ x: number;
33
+ y: number;
34
+ xScale: ChartScaleFunction;
35
+ yScale: ChartScaleFunction;
36
+ }) => {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ /**
41
+ * Projects multiple data points to pixel coordinates using chart scale functions.
42
+ * Handles both numeric and band scales automatically.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
47
+ * const pixelPoints = projectPoints({ data, chartScale });
48
+ * // For mixed scales
49
+ * const pixelPoints = projectPoints({ data, chartScale, xData: ['Jan', 'Feb', 'Mar'] });
50
+ * ```
51
+ */
52
+ export declare const projectPoints: ({
53
+ data,
54
+ xScale,
55
+ yScale,
56
+ xData,
57
+ yData,
58
+ }: {
59
+ data: (
60
+ | number
61
+ | null
62
+ | {
63
+ x: number;
64
+ y: number;
65
+ }
66
+ )[];
67
+ xData?: number[];
68
+ yData?: number[];
69
+ xScale: ChartScaleFunction;
70
+ yScale: ChartScaleFunction;
71
+ }) => Array<{
72
+ x: number;
73
+ y: number;
74
+ } | null>;
75
+ //# sourceMappingURL=point.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAkD,MAAM,SAAS,CAAC;AAElG;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,EAAE,OAAO,kBAAkB,KAAG,MAc9E,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,GAAI,2BAK1B;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;CAC5B,KAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAEzB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,yCAM3B;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;CAC5B,KAAG,KAAK,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAqDxC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { ScaleBand, ScaleLinear, ScaleLogarithmic } from 'd3-scale';
2
+ import type { AxisBounds } from './chart';
3
+ export type ChartAxisScaleType = 'linear' | 'log' | 'band';
4
+ export type NumericScale =
5
+ | ScaleLinear<number, number, never>
6
+ | ScaleLogarithmic<number, number, never>;
7
+ export type CategoricalScale = ScaleBand<number>;
8
+ export type ChartScaleFunction = NumericScale | CategoricalScale;
9
+ export declare const isCategoricalScale: (scale: ChartScaleFunction) => scale is CategoricalScale;
10
+ export declare const isNumericScale: (scale: ChartScaleFunction) => scale is NumericScale;
11
+ /**
12
+ * Type guard to check if a scale is logarithmic.
13
+ */
14
+ export declare const isLogScale: (
15
+ scale: ChartScaleFunction,
16
+ ) => scale is ScaleLogarithmic<number, number, never>;
17
+ /**
18
+ * Create a numeric scale (linear or logarithmic)
19
+ * @returns A numeric scale function
20
+ */
21
+ export declare const getNumericScale: ({
22
+ scaleType,
23
+ domain,
24
+ range,
25
+ }: {
26
+ scaleType: 'linear' | 'log';
27
+ domain: AxisBounds;
28
+ range: AxisBounds;
29
+ }) => NumericScale;
30
+ /**
31
+ * Create a categorical scale (band)
32
+ * @returns A categorical scale function
33
+ */
34
+ export declare const getCategoricalScale: ({
35
+ domain,
36
+ range,
37
+ padding,
38
+ }: {
39
+ domain: AxisBounds;
40
+ range: AxisBounds;
41
+ padding?: number;
42
+ }) => CategoricalScale;
43
+ //# sourceMappingURL=scale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/scale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3D,MAAM,MAAM,YAAY,GACpB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,GAClC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,gBAAgB,CAAC;AAEjE,eAAO,MAAM,kBAAkB,GAAI,OAAO,kBAAkB,KAAG,KAAK,IAAI,gBAEvE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,kBAAkB,KAAG,KAAK,IAAI,YAEnE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,kBAAkB,KACxB,KAAK,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAEjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,+BAI7B;IACD,SAAS,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;CACnB,KAAG,YAGH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,6BAIjC;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,gBAOH,CAAC"}
package/dts/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './chart';
1
2
  export * from './sparkline';
2
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -1,3 +1,8 @@
1
1
  import type { CounterBaseProps } from '@coinbase/cds-web/visualizations/Counter';
2
- export declare const Counter: ({ startNum, endNum, renderNum, durationInMillis }: CounterBaseProps) => import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=Counter.d.ts.map
2
+ export declare const Counter: ({
3
+ startNum,
4
+ endNum,
5
+ renderNum,
6
+ durationInMillis,
7
+ }: CounterBaseProps) => import('react/jsx-runtime').JSX.Element;
8
+ //# sourceMappingURL=Counter.d.ts.map
@@ -1,22 +1,67 @@
1
1
  import React from 'react';
2
2
  import type { ElementChildren, SharedProps } from '@coinbase/cds-common/types';
3
3
  import type { SparklineAreaBaseProps } from './SparklineArea';
4
+ import type { SparklinePathRef } from './SparklinePath';
5
+ export type SparklineStrokeType = 'gradient' | 'solid';
6
+ export type SparklineFillType = 'dotted' | 'gradient' | 'gradientDotted';
4
7
  export type SparklineBaseProps = SharedProps & {
5
- /** @danger Use this only if the background color beneath the Sparkline is a non-CDS color. It ensures an accessible contrast by returning either white or black when color is set to 'auto'. Accepts any valid color format (hex, RGB, RGBA). */
6
- background?: string;
7
- /** The color of the Sparkline graph's line. Accepts any raw color value (hex, rgba, hsl, etc) or 'auto'. Using 'auto' dynamically selects black or white for optimal accessibility. Does not work with CDS theme color names like 'fgPrimary' or CSS variables. */
8
- color: string;
9
- /** Height of the Sparkline */
10
- height: number;
11
- /** Svg path as string. CDS offers a `useSparklinePath` which is useful to generate this string. This is accessible via `import { useSparklinePath } from '@coinbase/cds-common/visualizations/useSparklinePath';`. Alternatively, you can use product tailored tooling to generate the SVG path. This component only requires a valid path string is provided. */
12
- path?: string;
13
- /** Width of the Sparkline */
14
- width: number;
15
- /** an optional SparklineArea that can be used to fill in the Sparkline */
16
- children?: ElementChildren<SparklineAreaBaseProps>;
17
- /** Scales the sparkline to show more or less variance. Use a number less than 1 for less variance and a number greater than 1 for more variance. If you use a number greater than 1 it may clip the boundaries of the sparkline. */
18
- yAxisScalingFactor?: number;
8
+ /** @danger Use this only if the background color beneath the Sparkline is a non-CDS color. It ensures an accessible contrast by returning either white or black when color is set to 'auto'. Accepts any valid color format (hex, RGB, RGBA). */
9
+ background?: string;
10
+ /** The color of the Sparkline graph's line. Accepts any raw color value (hex, rgba, hsl, etc) or 'auto'. Using 'auto' dynamically selects black or white for optimal accessibility. Does not work with CDS theme color names like 'fgPrimary' or CSS variables. */
11
+ color: string;
12
+ /** Height of the Sparkline */
13
+ height: number;
14
+ /** Svg path as string. CDS offers a `useSparklinePath` which is useful to generate this string. This is accessible via `import { useSparklinePath } from '@coinbase/cds-common/visualizations/useSparklinePath';`. Alternatively, you can use product tailored tooling to generate the SVG path. This component only requires a valid path string is provided. */
15
+ path?: string;
16
+ /** Width of the Sparkline */
17
+ width: number;
18
+ /** an optional SparklineArea that can be used to fill in the Sparkline */
19
+ children?: ElementChildren<SparklineAreaBaseProps>;
20
+ /** Scales the sparkline to show more or less variance. Use a number less than 1 for less variance and a number greater than 1 for more variance. If you use a number greater than 1 it may clip the boundaries of the sparkline. */
21
+ yAxisScalingFactor?: number;
22
+ /**
23
+ * Type of stroke to use for the line
24
+ * @default 'solid'
25
+ */
26
+ strokeType?: SparklineStrokeType;
27
+ /**
28
+ * Type of fill to use for the area
29
+ * @default 'dotted'
30
+ */
31
+ fillType?: SparklineFillType;
19
32
  };
20
33
  export type SparklineProps = SparklineBaseProps;
21
- export declare const Sparkline: React.MemoExoticComponent<({ background, color, height, path, width, yAxisScalingFactor, children, }: SparklineBaseProps) => import("react/jsx-runtime").JSX.Element>;
22
- //# sourceMappingURL=Sparkline.d.ts.map
34
+ /**
35
+ * @deprecated Use LineChart instead.
36
+ */
37
+ export declare const Sparkline: React.MemoExoticComponent<
38
+ React.ForwardRefExoticComponent<
39
+ SharedProps & {
40
+ /** @danger Use this only if the background color beneath the Sparkline is a non-CDS color. It ensures an accessible contrast by returning either white or black when color is set to 'auto'. Accepts any valid color format (hex, RGB, RGBA). */
41
+ background?: string;
42
+ /** The color of the Sparkline graph's line. Accepts any raw color value (hex, rgba, hsl, etc) or 'auto'. Using 'auto' dynamically selects black or white for optimal accessibility. Does not work with CDS theme color names like 'fgPrimary' or CSS variables. */
43
+ color: string;
44
+ /** Height of the Sparkline */
45
+ height: number;
46
+ /** Svg path as string. CDS offers a `useSparklinePath` which is useful to generate this string. This is accessible via `import { useSparklinePath } from '@coinbase/cds-common/visualizations/useSparklinePath';`. Alternatively, you can use product tailored tooling to generate the SVG path. This component only requires a valid path string is provided. */
47
+ path?: string;
48
+ /** Width of the Sparkline */
49
+ width: number;
50
+ /** an optional SparklineArea that can be used to fill in the Sparkline */
51
+ children?: ElementChildren<SparklineAreaBaseProps>;
52
+ /** Scales the sparkline to show more or less variance. Use a number less than 1 for less variance and a number greater than 1 for more variance. If you use a number greater than 1 it may clip the boundaries of the sparkline. */
53
+ yAxisScalingFactor?: number;
54
+ /**
55
+ * Type of stroke to use for the line
56
+ * @default 'solid'
57
+ */
58
+ strokeType?: SparklineStrokeType;
59
+ /**
60
+ * Type of fill to use for the area
61
+ * @default 'dotted'
62
+ */
63
+ fillType?: SparklineFillType;
64
+ } & React.RefAttributes<SparklinePathRef>
65
+ >
66
+ >;
67
+ //# sourceMappingURL=Sparkline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sparkline.d.ts","sourceRoot":"","sources":["../../src/sparkline/Sparkline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAO/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAI9D,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,iPAAiP;IACjP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oQAAoQ;IACpQ,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,kWAAkW;IAClW,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,eAAe,CAAC,sBAAsB,CAAC,CAAC;IACnD,oOAAoO;IACpO,kBAAkB,CAAC,EA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P,MAAM;IACb,8BAA8B;YACtB,MAAM;IACd,kWAAkW;WAC3V,MAAM;IACb,6BAA6B;WACtB,MAAM;IACb,0EAA0E;eAC/D,eAAe,CAAC,sBAAsB,CAAC;IAClD,oOAAoO;yBAC/M,MAAM;IAC3B;;;OAGG;iBACU,mBAAmB;IAChC;;;OAGG;eACQ,iBAAiB;2CA4J7B,CAAC"}
@@ -1,7 +1,15 @@
1
1
  import React from 'react';
2
2
  export type SparklineAreaBaseProps = {
3
- area?: string;
4
- patternId?: string;
3
+ area?: string;
4
+ patternId?: string;
5
+ maskId?: string;
5
6
  };
6
- export declare const SparklineArea: React.MemoExoticComponent<React.ForwardRefExoticComponent<SparklineAreaBaseProps & React.RefAttributes<SVGPathElement | null>>>;
7
- //# sourceMappingURL=SparklineArea.d.ts.map
7
+ /**
8
+ * @deprecated Use AreaChart instead.
9
+ */
10
+ export declare const SparklineArea: React.MemoExoticComponent<
11
+ React.ForwardRefExoticComponent<
12
+ SparklineAreaBaseProps & React.RefAttributes<SVGPathElement | null>
13
+ >
14
+ >;
15
+ //# sourceMappingURL=SparklineArea.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SparklineArea.d.ts","sourceRoot":"","sources":["../../src/sparkline/SparklineArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,aAAa,iIAMzB,CAAC"}
1
+ {"version":3,"file":"SparklineArea.d.ts","sourceRoot":"","sources":["../../src/sparkline/SparklineArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,iIAazB,CAAC"}
@@ -1,6 +1,14 @@
1
1
  export type SparklineAreaPatternBaseProps = {
2
- color: string;
3
- id: string;
2
+ color: string;
3
+ id: string;
4
+ /**
5
+ * Opacity for the pattern. If not provided, uses theme-based opacity from useSparklineAreaOpacity.
6
+ */
7
+ opacity?: number;
4
8
  };
5
- export declare const SparklineAreaPattern: ({ color, id }: SparklineAreaPatternBaseProps) => import("react/jsx-runtime").JSX.Element;
6
- //# sourceMappingURL=SparklineAreaPattern.d.ts.map
9
+ export declare const SparklineAreaPattern: ({
10
+ color,
11
+ id,
12
+ opacity,
13
+ }: SparklineAreaPatternBaseProps) => import('react/jsx-runtime').JSX.Element;
14
+ //# sourceMappingURL=SparklineAreaPattern.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SparklineAreaPattern.d.ts","sourceRoot":"","sources":["../../src/sparkline/SparklineAreaPattern.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,eAAe,6BAA6B,4CAWhF,CAAC"}
1
+ {"version":3,"file":"SparklineAreaPattern.d.ts","sourceRoot":"","sources":["../../src/sparkline/SparklineAreaPattern.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,wBAAwB,6BAA6B,4CAazF,CAAC"}
@@ -1,12 +1,23 @@
1
1
  import React from 'react';
2
2
  import type { SparklinePathRef } from './SparklinePath';
3
- export declare const SparklineGradient: React.MemoExoticComponent<React.ForwardRefExoticComponent<import("@coinbase/cds-common").SharedProps & {
4
- background?: string;
5
- color: string;
6
- height: number;
7
- path?: string;
8
- width: number;
9
- children?: import("@coinbase/cds-common").ElementChildren<import("./SparklineArea").SparklineAreaBaseProps>;
10
- yAxisScalingFactor?: number;
11
- } & React.RefAttributes<SparklinePathRef>>>;
12
- //# sourceMappingURL=SparklineGradient.d.ts.map
3
+ /**
4
+ * @deprecated Use LineChart instead.
5
+ */
6
+ export declare const SparklineGradient: React.MemoExoticComponent<
7
+ React.ForwardRefExoticComponent<
8
+ import('@coinbase/cds-common').SharedProps & {
9
+ background?: string;
10
+ color: string;
11
+ height: number;
12
+ path?: string;
13
+ width: number;
14
+ children?: import('@coinbase/cds-common').ElementChildren<
15
+ import('./SparklineArea').SparklineAreaBaseProps
16
+ >;
17
+ yAxisScalingFactor?: number;
18
+ strokeType?: import('./Sparkline').SparklineStrokeType;
19
+ fillType?: import('./Sparkline').SparklineFillType;
20
+ } & React.RefAttributes<SparklinePathRef>
21
+ >
22
+ >;
23
+ //# sourceMappingURL=SparklineGradient.d.ts.map