@coinbase/cds-mobile-visualization 3.4.0-beta.18 → 3.4.0-beta.19

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 (68) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dts/chart/Path.d.ts +35 -13
  3. package/dts/chart/Path.d.ts.map +1 -1
  4. package/dts/chart/area/Area.d.ts +7 -11
  5. package/dts/chart/area/Area.d.ts.map +1 -1
  6. package/dts/chart/area/AreaChart.d.ts +1 -1
  7. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  8. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  9. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  10. package/dts/chart/bar/Bar.d.ts +32 -2
  11. package/dts/chart/bar/Bar.d.ts.map +1 -1
  12. package/dts/chart/bar/BarChart.d.ts +2 -0
  13. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  14. package/dts/chart/bar/BarPlot.d.ts +2 -1
  15. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  16. package/dts/chart/bar/BarStack.d.ts +5 -10
  17. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  18. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  19. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  20. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  21. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  22. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  23. package/dts/chart/line/Line.d.ts +4 -9
  24. package/dts/chart/line/Line.d.ts.map +1 -1
  25. package/dts/chart/line/LineChart.d.ts +1 -1
  26. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  27. package/dts/chart/point/Point.d.ts +18 -2
  28. package/dts/chart/point/Point.d.ts.map +1 -1
  29. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +9 -1
  30. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
  31. package/dts/chart/scrubber/Scrubber.d.ts +45 -24
  32. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  33. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +9 -1
  34. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
  35. package/dts/chart/utils/bar.d.ts +34 -0
  36. package/dts/chart/utils/bar.d.ts.map +1 -1
  37. package/dts/chart/utils/path.d.ts +6 -0
  38. package/dts/chart/utils/path.d.ts.map +1 -1
  39. package/dts/chart/utils/transition.d.ts +59 -21
  40. package/dts/chart/utils/transition.d.ts.map +1 -1
  41. package/esm/chart/Path.js +16 -14
  42. package/esm/chart/__stories__/CartesianChart.stories.js +3 -77
  43. package/esm/chart/__stories__/ChartTransitions.stories.js +629 -0
  44. package/esm/chart/area/Area.js +2 -0
  45. package/esm/chart/area/DottedArea.js +7 -3
  46. package/esm/chart/area/GradientArea.js +4 -2
  47. package/esm/chart/area/SolidArea.js +4 -2
  48. package/esm/chart/bar/Bar.js +2 -0
  49. package/esm/chart/bar/BarChart.js +4 -2
  50. package/esm/chart/bar/BarPlot.js +2 -0
  51. package/esm/chart/bar/BarStack.js +3 -0
  52. package/esm/chart/bar/DefaultBar.js +15 -15
  53. package/esm/chart/bar/DefaultBarStack.js +14 -3
  54. package/esm/chart/bar/__stories__/BarChart.stories.js +448 -52
  55. package/esm/chart/line/DottedLine.js +4 -2
  56. package/esm/chart/line/Line.js +6 -18
  57. package/esm/chart/line/SolidLine.js +4 -2
  58. package/esm/chart/line/__stories__/LineChart.stories.js +17 -226
  59. package/esm/chart/line/__stories__/ReferenceLine.stories.js +95 -1
  60. package/esm/chart/point/Point.js +33 -35
  61. package/esm/chart/scrubber/DefaultScrubberBeacon.js +2 -5
  62. package/esm/chart/scrubber/Scrubber.js +10 -8
  63. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +29 -7
  64. package/esm/chart/utils/bar.js +43 -0
  65. package/esm/chart/utils/path.js +8 -0
  66. package/esm/chart/utils/transition.js +96 -61
  67. package/package.json +5 -5
  68. package/esm/chart/__stories__/Chart.stories.js +0 -77
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "transition", "gradient"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "transitions", "transition", "gradient"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  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; }
4
4
  import { memo } from 'react';
@@ -18,6 +18,7 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
18
18
  fillOpacity = 1,
19
19
  yAxisId,
20
20
  animate,
21
+ transitions,
21
22
  transition,
22
23
  gradient
23
24
  } = _ref,
@@ -28,7 +29,8 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
28
29
  d: d,
29
30
  fill: fill != null ? fill : theme.color.fgPrimary,
30
31
  fillOpacity: fillOpacity,
31
- transition: transition
32
+ transition: transition,
33
+ transitions: transitions
32
34
  }, pathProps, {
33
35
  children: gradient && /*#__PURE__*/_jsx(Gradient, {
34
36
  gradient: gradient,
@@ -33,6 +33,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
33
33
  borderRadius = 4,
34
34
  roundTop = true,
35
35
  roundBottom = true,
36
+ transitions,
36
37
  transition
37
38
  } = _ref;
38
39
  const theme = useTheme();
@@ -64,6 +65,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
64
65
  stroke: stroke,
65
66
  strokeWidth: strokeWidth,
66
67
  transition: transition,
68
+ transitions: transitions,
67
69
  width: width,
68
70
  x: x,
69
71
  y: y
@@ -1,4 +1,4 @@
1
- const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize", "transition"],
1
+ const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize", "transitions", "transition"],
2
2
  _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"];
4
4
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
@@ -30,6 +30,7 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
30
30
  stackGap,
31
31
  barMinSize,
32
32
  stackMinSize,
33
+ transitions,
33
34
  transition
34
35
  } = _ref,
35
36
  chartProps = _objectWithoutPropertiesLoose(_ref, _excluded);
@@ -119,7 +120,8 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
119
120
  stackMinSize: stackMinSize,
120
121
  stroke: stroke,
121
122
  strokeWidth: strokeWidth,
122
- transition: transition
123
+ transition: transition,
124
+ transitions: transitions
123
125
  }), children]
124
126
  }));
125
127
  }));
@@ -24,6 +24,7 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
24
24
  stackGap,
25
25
  barMinSize,
26
26
  stackMinSize,
27
+ transitions,
27
28
  transition
28
29
  } = _ref;
29
30
  const {
@@ -96,6 +97,7 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
96
97
  strokeWidth: defaultStrokeWidth,
97
98
  totalStacks: stackGroups.length,
98
99
  transition: transition,
100
+ transitions: transitions,
99
101
  yAxisId: group.yAxisId
100
102
  }, group.stackId))
101
103
  });
@@ -35,6 +35,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
35
35
  barMinSize,
36
36
  stackMinSize,
37
37
  roundBaseline,
38
+ transitions,
38
39
  transition
39
40
  } = _ref;
40
41
  const theme = useTheme();
@@ -534,6 +535,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
534
535
  stroke: defaultStroke,
535
536
  strokeWidth: defaultStrokeWidth,
536
537
  transition: transition,
538
+ transitions: transitions,
537
539
  width: bar.width,
538
540
  x: bar.x,
539
541
  y: bar.y
@@ -549,6 +551,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
549
551
  roundBottom: stackRoundBottom,
550
552
  roundTop: stackRoundTop,
551
553
  transition: transition,
554
+ transitions: transitions,
552
555
  width: stackRect.width,
553
556
  x: stackRect.x,
554
557
  y: stackRect.y,
@@ -2,7 +2,8 @@ import { memo, useMemo } from 'react';
2
2
  import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
3
3
  import { useCartesianChartContext } from '../ChartProvider';
4
4
  import { Path } from '../Path';
5
- import { getBarPath } from '../utils';
5
+ import { defaultBarEnterTransition, getBarPath, withStaggerDelayTransition } from '../utils';
6
+ import { defaultTransition, getTransition } from '../utils/transition';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  /**
8
9
  * Default bar component that renders a solid bar with animation support.
@@ -13,7 +14,7 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
13
14
  y,
14
15
  width,
15
16
  height,
16
- borderRadius,
17
+ borderRadius = 4,
17
18
  roundTop,
18
19
  roundBottom,
19
20
  d,
@@ -22,35 +23,34 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
22
23
  stroke,
23
24
  strokeWidth,
24
25
  originY,
26
+ transitions,
25
27
  transition
26
28
  } = _ref;
27
29
  const {
28
- animate
30
+ animate,
31
+ drawingArea
29
32
  } = useCartesianChartContext();
30
33
  const theme = useTheme();
31
34
  const defaultFill = fill || theme.color.fgPrimary;
32
- const targetPath = useMemo(() => {
33
- const effectiveBorderRadius = borderRadius != null ? borderRadius : 0;
34
- const effectiveRoundTop = roundTop != null ? roundTop : true;
35
- const effectiveRoundBottom = roundBottom != null ? roundBottom : true;
36
- return d || getBarPath(x, y, width, height, effectiveBorderRadius, effectiveRoundTop, effectiveRoundBottom);
37
- }, [x, y, width, height, borderRadius, roundTop, roundBottom, d]);
35
+ const normalizedX = useMemo(() => drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0, [x, drawingArea.x, drawingArea.width]);
36
+ const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedX), [transitions == null ? void 0 : transitions.enter, animate, normalizedX]);
37
+ const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedX), [transitions == null ? void 0 : transitions.update, transition, animate, normalizedX]);
38
38
  const initialPath = useMemo(() => {
39
- const effectiveBorderRadius = borderRadius != null ? borderRadius : 0;
40
- const effectiveRoundTop = roundTop != null ? roundTop : true;
41
- const effectiveRoundBottom = roundBottom != null ? roundBottom : true;
42
39
  const baselineY = originY != null ? originY : y + height;
43
- return getBarPath(x, baselineY, width, 1, effectiveBorderRadius, effectiveRoundTop, effectiveRoundBottom);
40
+ return getBarPath(x, baselineY, width, 1, borderRadius, !!roundTop, !!roundBottom);
44
41
  }, [x, originY, y, height, width, borderRadius, roundTop, roundBottom]);
45
42
  return /*#__PURE__*/_jsx(Path, {
46
43
  animate: animate,
47
44
  clipPath: null,
48
- d: targetPath,
45
+ d: d,
49
46
  fill: stroke ? 'none' : defaultFill,
50
47
  fillOpacity: fillOpacity,
51
48
  initialPath: initialPath,
52
49
  stroke: stroke,
53
50
  strokeWidth: strokeWidth,
54
- transition: transition
51
+ transitions: {
52
+ enter: enterTransition,
53
+ update: updateTransition
54
+ }
55
55
  });
56
56
  });
@@ -2,7 +2,8 @@ import { memo, useMemo } from 'react';
2
2
  import { Group } from '@shopify/react-native-skia';
3
3
  import { useCartesianChartContext } from '../ChartProvider';
4
4
  import { getBarPath } from '../utils';
5
- import { usePathTransition } from '../utils/transition';
5
+ import { defaultBarEnterTransition, withStaggerDelayTransition } from '../utils/bar';
6
+ import { defaultTransition, getTransition, usePathTransition } from '../utils/transition';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  /**
8
9
  * Default stack component that renders children in a group with animated clip path.
@@ -18,12 +19,19 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
18
19
  roundTop = true,
19
20
  roundBottom = true,
20
21
  yOrigin,
22
+ transitions,
21
23
  transition
22
24
  } = _ref;
23
25
  const {
24
- animate
26
+ animate,
27
+ drawingArea
25
28
  } = useCartesianChartContext();
26
29
 
30
+ // Compute normalized x position for stagger delay calculation
31
+ const normalizedX = useMemo(() => drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0, [x, drawingArea.x, drawingArea.width]);
32
+ const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedX), [animate, transitions == null ? void 0 : transitions.enter, normalizedX]);
33
+ const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedX), [animate, transitions == null ? void 0 : transitions.update, transition, normalizedX]);
34
+
27
35
  // Generate target clip path (full bar)
28
36
  const targetPath = useMemo(() => {
29
37
  return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
@@ -37,7 +45,10 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
37
45
  const animatedClipPath = usePathTransition({
38
46
  currentPath: targetPath,
39
47
  initialPath,
40
- transition
48
+ transitions: {
49
+ enter: enterTransition,
50
+ update: updateTransition
51
+ }
41
52
  });
42
53
  const clipPath = animate ? animatedClipPath : targetPath;
43
54
  return /*#__PURE__*/_jsx(Group, {