@coinbase/cds-web-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 +10 -0
  2. package/dts/chart/Path.d.ts +49 -12
  3. package/dts/chart/Path.d.ts.map +1 -1
  4. package/dts/chart/area/Area.d.ts +6 -11
  5. package/dts/chart/area/Area.d.ts.map +1 -1
  6. package/dts/chart/area/AreaChart.d.ts +15 -2
  7. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  8. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  9. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  10. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  11. package/dts/chart/bar/Bar.d.ts +32 -1
  12. package/dts/chart/bar/Bar.d.ts.map +1 -1
  13. package/dts/chart/bar/BarChart.d.ts +1 -0
  14. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  15. package/dts/chart/bar/BarPlot.d.ts +2 -1
  16. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  17. package/dts/chart/bar/BarStack.d.ts +4 -10
  18. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  19. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  20. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  21. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  22. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  23. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  24. package/dts/chart/line/Line.d.ts +17 -20
  25. package/dts/chart/line/Line.d.ts.map +1 -1
  26. package/dts/chart/line/LineChart.d.ts +2 -0
  27. package/dts/chart/line/LineChart.d.ts.map +1 -1
  28. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  29. package/dts/chart/point/Point.d.ts +18 -2
  30. package/dts/chart/point/Point.d.ts.map +1 -1
  31. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +22 -29
  32. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
  33. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -1
  34. package/dts/chart/scrubber/Scrubber.d.ts +85 -52
  35. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  36. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +9 -1
  37. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -1
  38. package/dts/chart/utils/bar.d.ts +34 -0
  39. package/dts/chart/utils/bar.d.ts.map +1 -1
  40. package/dts/chart/utils/path.d.ts +6 -0
  41. package/dts/chart/utils/path.d.ts.map +1 -1
  42. package/dts/chart/utils/transition.d.ts +50 -14
  43. package/dts/chart/utils/transition.d.ts.map +1 -1
  44. package/esm/chart/Path.js +20 -21
  45. package/esm/chart/area/Area.js +2 -0
  46. package/esm/chart/area/AreaChart.js +4 -1
  47. package/esm/chart/area/DottedArea.js +8 -4
  48. package/esm/chart/area/GradientArea.js +6 -3
  49. package/esm/chart/area/SolidArea.js +6 -3
  50. package/esm/chart/bar/Bar.js +2 -0
  51. package/esm/chart/bar/BarChart.js +4 -2
  52. package/esm/chart/bar/BarPlot.js +2 -0
  53. package/esm/chart/bar/BarStack.js +3 -0
  54. package/esm/chart/bar/DefaultBar.js +20 -23
  55. package/esm/chart/bar/DefaultBarStack.js +23 -17
  56. package/esm/chart/line/DottedLine.js +5 -2
  57. package/esm/chart/line/Line.js +12 -26
  58. package/esm/chart/line/LineChart.js +4 -2
  59. package/esm/chart/line/SolidLine.js +6 -3
  60. package/esm/chart/point/Point.js +39 -23
  61. package/esm/chart/scrubber/DefaultScrubberBeacon.js +25 -34
  62. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +25 -14
  63. package/esm/chart/scrubber/Scrubber.js +7 -13
  64. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +19 -5
  65. package/esm/chart/utils/bar.js +48 -0
  66. package/esm/chart/utils/path.js +9 -0
  67. package/esm/chart/utils/transition.js +63 -41
  68. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transition"];
1
+ const _excluded = ["d", "fill", "patternSize", "dotSize", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "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; }
@@ -18,6 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  * on the fill color and peak/baseline opacities.
19
19
  */
20
20
  export const DottedArea = /*#__PURE__*/memo(_ref => {
21
+ var _transitions$update;
21
22
  let {
22
23
  d,
23
24
  fill = 'var(--color-fgPrimary)',
@@ -29,6 +30,7 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
29
30
  yAxisId,
30
31
  gradient: gradientProp,
31
32
  animate,
33
+ transitions,
32
34
  transition
33
35
  } = _ref,
34
36
  pathProps = _objectWithoutProperties(_ref, _excluded);
@@ -67,13 +69,14 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
67
69
  animate: animate,
68
70
  d: d,
69
71
  fill: "url(#".concat(patternId, ")"),
70
- transition: transition
72
+ transition: transition,
73
+ transitions: transitions
71
74
  })
72
75
  }), gradient && /*#__PURE__*/_jsx(Gradient, {
73
76
  animate: animate,
74
77
  gradient: gradient,
75
78
  id: gradientId,
76
- transition: transition,
79
+ transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
77
80
  yAxisId: yAxisId
78
81
  })]
79
82
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -81,7 +84,8 @@ export const DottedArea = /*#__PURE__*/memo(_ref => {
81
84
  d: d,
82
85
  fill: gradient ? "url(#".concat(gradientId, ")") : fill,
83
86
  mask: "url(#".concat(maskId, ")"),
84
- transition: transition
87
+ transition: transition,
88
+ transitions: transitions
85
89
  }, pathProps))]
86
90
  });
87
91
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["d", "fill", "fillOpacity", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "transition"];
1
+ const _excluded = ["d", "fill", "fillOpacity", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "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; }
@@ -21,6 +21,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
21
21
  * - For all-positive or all-negative data: Creates a simple gradient from baseline to peak.
22
22
  */
23
23
  export const GradientArea = /*#__PURE__*/memo(_ref => {
24
+ var _transitions$update;
24
25
  let {
25
26
  d,
26
27
  fill = 'var(--color-fgPrimary)',
@@ -31,6 +32,7 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
31
32
  yAxisId,
32
33
  gradient: gradientProp,
33
34
  animate,
35
+ transitions,
34
36
  transition
35
37
  } = _ref,
36
38
  pathProps = _objectWithoutProperties(_ref, _excluded);
@@ -51,7 +53,7 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
51
53
  animate: animate,
52
54
  gradient: gradient,
53
55
  id: patternId,
54
- transition: transition,
56
+ transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
55
57
  yAxisId: yAxisId
56
58
  })
57
59
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -59,7 +61,8 @@ export const GradientArea = /*#__PURE__*/memo(_ref => {
59
61
  d: d,
60
62
  fill: gradient ? "url(#".concat(patternId, ")") : fill,
61
63
  fillOpacity: fillOpacity,
62
- transition: transition
64
+ transition: transition,
65
+ transitions: transitions
63
66
  }, pathProps))]
64
67
  });
65
68
  });
@@ -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 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; }
@@ -16,12 +16,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
16
16
  * Otherwise, renders with solid fill.
17
17
  */
18
18
  export const SolidArea = /*#__PURE__*/memo(_ref => {
19
+ var _transitions$update;
19
20
  let {
20
21
  d,
21
22
  fill = 'var(--color-fgPrimary)',
22
23
  fillOpacity = 1,
23
24
  yAxisId,
24
25
  animate,
26
+ transitions,
25
27
  transition,
26
28
  gradient
27
29
  } = _ref,
@@ -33,7 +35,7 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
33
35
  animate: animate,
34
36
  gradient: gradient,
35
37
  id: patternId,
36
- transition: transition,
38
+ transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
37
39
  yAxisId: yAxisId
38
40
  })
39
41
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -41,7 +43,8 @@ export const SolidArea = /*#__PURE__*/memo(_ref => {
41
43
  d: d,
42
44
  fill: gradient ? "url(#".concat(patternId, ")") : fill,
43
45
  fillOpacity: fillOpacity,
44
- transition: transition
46
+ transition: transition,
47
+ transitions: transitions
45
48
  }, pathProps))]
46
49
  });
47
50
  });
@@ -32,6 +32,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
32
32
  borderRadius = 4,
33
33
  roundTop = true,
34
34
  roundBottom = true,
35
+ transitions,
35
36
  transition
36
37
  } = _ref;
37
38
  const barPath = useMemo(() => {
@@ -56,6 +57,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
56
57
  stroke: stroke,
57
58
  strokeWidth: strokeWidth,
58
59
  transition: transition,
60
+ transitions: transitions,
59
61
  width: width,
60
62
  x: x,
61
63
  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 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; }
@@ -35,6 +35,7 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
35
35
  stackGap,
36
36
  barMinSize,
37
37
  stackMinSize,
38
+ transitions,
38
39
  transition
39
40
  } = _ref,
40
41
  chartProps = _objectWithoutProperties(_ref, _excluded);
@@ -124,7 +125,8 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
124
125
  stackMinSize: stackMinSize,
125
126
  stroke: stroke,
126
127
  strokeWidth: strokeWidth,
127
- transition: transition
128
+ transition: transition,
129
+ transitions: transitions
128
130
  }), children]
129
131
  }));
130
132
  }));
@@ -23,6 +23,7 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
23
23
  stackGap,
24
24
  barMinSize,
25
25
  stackMinSize,
26
+ transitions,
26
27
  transition
27
28
  } = _ref;
28
29
  const {
@@ -90,6 +91,7 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
90
91
  strokeWidth: defaultStrokeWidth,
91
92
  totalStacks: stackGroups.length,
92
93
  transition: transition,
94
+ transitions: transitions,
93
95
  yAxisId: group.yAxisId
94
96
  }, group.stackId))
95
97
  })]
@@ -37,6 +37,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
37
37
  barMinSize,
38
38
  stackMinSize,
39
39
  roundBaseline,
40
+ transitions,
40
41
  transition
41
42
  } = _ref;
42
43
  const {
@@ -543,6 +544,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
543
544
  stroke: (_bar$stroke = bar.stroke) !== null && _bar$stroke !== void 0 ? _bar$stroke : defaultStroke,
544
545
  strokeWidth: (_bar$strokeWidth = bar.strokeWidth) !== null && _bar$strokeWidth !== void 0 ? _bar$strokeWidth : defaultStrokeWidth,
545
546
  transition: transition,
547
+ transitions: transitions,
546
548
  width: bar.width,
547
549
  x: bar.x,
548
550
  y: bar.y
@@ -559,6 +561,7 @@ export const BarStack = /*#__PURE__*/memo(_ref => {
559
561
  roundBottom: stackRoundBottom,
560
562
  roundTop: stackRoundTop,
561
563
  transition: transition,
564
+ transitions: transitions,
562
565
  width: stackRect.width,
563
566
  x: stackRect.x,
564
567
  y: stackRect.y,
@@ -1,4 +1,4 @@
1
- const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY", "seriesId", "transition"];
1
+ const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY", "seriesId", "transitions", "transition"];
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -7,9 +7,9 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
7
7
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
8
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
9
9
  import React, { memo, useMemo } from 'react';
10
- import { m as motion } from 'framer-motion';
11
10
  import { useCartesianChartContext } from '../ChartProvider';
12
- import { getBarPath } from '../utils';
11
+ import { Path } from '../Path';
12
+ import { defaultBarEnterTransition, defaultTransition, getBarPath, getTransition, withStaggerDelayTransition } from '../utils';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  /**
15
15
  * Default bar component that renders a solid bar with animation.
@@ -28,35 +28,32 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
28
28
  dataX,
29
29
  dataY,
30
30
  seriesId,
31
+ transitions,
31
32
  transition
32
33
  } = _ref,
33
34
  props = _objectWithoutProperties(_ref, _excluded);
34
35
  const {
35
- animate
36
+ animate,
37
+ drawingArea
36
38
  } = useCartesianChartContext();
39
+ const normalizedX = useMemo(() => drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0, [x, drawingArea.x, drawingArea.width]);
40
+ const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedX), [transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, normalizedX]);
41
+ const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedX), [transitions === null || transitions === void 0 ? void 0 : transitions.update, transition, animate, normalizedX]);
37
42
  const initialPath = useMemo(() => {
38
- if (!animate) return undefined;
39
- // Need a minimum height to allow for animation
40
43
  const minHeight = 1;
41
44
  const initialY = (originY !== null && originY !== void 0 ? originY : 0) - minHeight;
42
- return getBarPath(x, initialY, width, minHeight, borderRadius, !!roundTop, !!roundBottom);
43
- }, [animate, x, originY, width, borderRadius, roundTop, roundBottom]);
44
- if (animate && initialPath) {
45
- return /*#__PURE__*/_jsx(motion.path, _objectSpread(_objectSpread({}, props), {}, {
46
- animate: {
47
- d
48
- },
49
- fill: fill,
50
- fillOpacity: fillOpacity,
51
- initial: {
52
- d: initialPath
53
- },
54
- transition: transition
55
- }));
56
- }
57
- return /*#__PURE__*/_jsx("path", _objectSpread(_objectSpread({}, props), {}, {
45
+ return getBarPath(x, initialY, width, minHeight, borderRadius !== null && borderRadius !== void 0 ? borderRadius : 0, !!roundTop, !!roundBottom);
46
+ }, [x, originY, width, borderRadius, roundTop, roundBottom]);
47
+ return /*#__PURE__*/_jsx(Path, _objectSpread(_objectSpread({}, props), {}, {
48
+ animate: animate,
49
+ clipRect: null,
58
50
  d: d,
59
51
  fill: fill,
60
- fillOpacity: fillOpacity
52
+ fillOpacity: fillOpacity,
53
+ initialPath: initialPath,
54
+ transitions: {
55
+ enter: enterTransition,
56
+ update: updateTransition
57
+ }
61
58
  }));
62
59
  });
@@ -1,7 +1,8 @@
1
1
  import { memo, useId, useMemo } from 'react';
2
2
  import { m as motion } from 'framer-motion';
3
3
  import { useCartesianChartContext } from '../ChartProvider';
4
- import { getBarPath } from '../utils';
4
+ import { defaultBarEnterTransition, defaultTransition, getBarPath, getTransition, withStaggerDelayTransition } from '../utils';
5
+ import { usePathTransition } from '../utils/transition';
5
6
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
6
7
  /**
7
8
  * Default stack component that renders children in a group with animated clip path.
@@ -19,33 +20,38 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
19
20
  roundTop = true,
20
21
  roundBottom = true,
21
22
  yOrigin,
23
+ transitions,
22
24
  transition
23
25
  } = _ref;
24
26
  const {
25
- animate
27
+ animate,
28
+ drawingArea
26
29
  } = useCartesianChartContext();
27
30
  const clipPathId = useId();
28
- const clipPathData = useMemo(() => {
31
+ const normalizedX = useMemo(() => drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0, [x, drawingArea.x, drawingArea.width]);
32
+ const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedX), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.enter, normalizedX]);
33
+ const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedX), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.update, transition, normalizedX]);
34
+ const targetPath = useMemo(() => {
29
35
  return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
30
36
  }, [x, y, width, height, borderRadius, roundTop, roundBottom]);
31
- const initialClipPathData = useMemo(() => {
32
- if (!animate) return undefined;
33
- return getBarPath(x, yOrigin !== null && yOrigin !== void 0 ? yOrigin : y + height, width, 1, borderRadius, roundTop, roundBottom);
34
- }, [animate, x, yOrigin, y, height, width, borderRadius, roundTop, roundBottom]);
37
+ const initialPath = useMemo(() => {
38
+ const baselineY = yOrigin !== null && yOrigin !== void 0 ? yOrigin : y + height;
39
+ return getBarPath(x, baselineY, width, 1, borderRadius, roundTop, roundBottom);
40
+ }, [x, yOrigin, y, height, width, borderRadius, roundTop, roundBottom]);
41
+ const animatedClipPath = usePathTransition({
42
+ currentPath: targetPath,
43
+ initialPath,
44
+ transitions: {
45
+ enter: enterTransition,
46
+ update: updateTransition
47
+ }
48
+ });
35
49
  return /*#__PURE__*/_jsxs(_Fragment, {
36
50
  children: [/*#__PURE__*/_jsx("defs", {
37
51
  children: /*#__PURE__*/_jsx("clipPath", {
38
52
  id: clipPathId,
39
- children: animate ? /*#__PURE__*/_jsx(motion.path, {
40
- animate: {
41
- d: clipPathData
42
- },
43
- initial: {
44
- d: initialClipPathData
45
- },
46
- transition: transition
47
- }) : /*#__PURE__*/_jsx("path", {
48
- d: clipPathData
53
+ children: /*#__PURE__*/_jsx(motion.path, {
54
+ d: animatedClipPath
49
55
  })
50
56
  })
51
57
  }), /*#__PURE__*/_jsx("g", {
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect", "gradient", "yAxisId", "animate", "transition", "d"];
1
+ const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect", "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; }
@@ -15,6 +15,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
15
15
  * Supports gradient for gradient effects on the dots.
16
16
  */
17
17
  export const DottedLine = /*#__PURE__*/memo(_ref => {
18
+ var _transitions$update;
18
19
  let {
19
20
  fill = 'none',
20
21
  stroke = 'var(--color-fgPrimary)',
@@ -27,6 +28,7 @@ export const DottedLine = /*#__PURE__*/memo(_ref => {
27
28
  gradient,
28
29
  yAxisId,
29
30
  animate,
31
+ transitions,
30
32
  transition,
31
33
  d
32
34
  } = _ref,
@@ -38,7 +40,7 @@ export const DottedLine = /*#__PURE__*/memo(_ref => {
38
40
  animate: animate,
39
41
  gradient: gradient,
40
42
  id: gradientId,
41
- transition: transition,
43
+ transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
42
44
  yAxisId: yAxisId
43
45
  })
44
46
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -53,6 +55,7 @@ export const DottedLine = /*#__PURE__*/memo(_ref => {
53
55
  strokeOpacity: strokeOpacity,
54
56
  strokeWidth: strokeWidth,
55
57
  transition: transition,
58
+ transitions: transitions,
56
59
  vectorEffect: vectorEffect
57
60
  }, props))]
58
61
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transition", "gradient"];
1
+ const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transitions", "transition", "gradient"];
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -7,11 +7,10 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
7
7
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
8
8
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
9
9
  import React, { memo, useMemo } from 'react';
10
- import { m as motion } from 'framer-motion';
11
10
  import { Area } from '../area/Area';
12
11
  import { useCartesianChartContext } from '../ChartProvider';
13
12
  import { Point } from '../point';
14
- import { accessoryFadeTransitionDelay, accessoryFadeTransitionDuration, evaluateGradientAtValue, getGradientConfig, getLineData, getLinePath } from '../utils';
13
+ import { evaluateGradientAtValue, getGradientConfig, getLineData, getLinePath } from '../utils';
15
14
  import { DottedLine } from './DottedLine';
16
15
  import { SolidLine } from './SolidLine';
17
16
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
@@ -32,6 +31,7 @@ export const Line = /*#__PURE__*/memo(_ref => {
32
31
  opacity = 1,
33
32
  points,
34
33
  connectNulls,
34
+ transitions,
35
35
  transition,
36
36
  gradient: gradientProp
37
37
  } = _ref,
@@ -108,6 +108,7 @@ export const Line = /*#__PURE__*/memo(_ref => {
108
108
  gradient: gradient,
109
109
  seriesId: seriesId,
110
110
  transition: transition,
111
+ transitions: transitions,
111
112
  type: areaType
112
113
  }), /*#__PURE__*/_jsx(LineComponent, _objectSpread({
113
114
  d: path,
@@ -115,27 +116,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
115
116
  stroke: stroke,
116
117
  strokeOpacity: strokeOpacity !== null && strokeOpacity !== void 0 ? strokeOpacity : opacity,
117
118
  transition: transition,
119
+ transitions: transitions,
118
120
  yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
119
- }, props)), points && /*#__PURE__*/_jsx(motion.g, _objectSpread(_objectSpread({
120
- "data-component": "line-points-group"
121
- }, animate ? {
122
- animate: {
123
- opacity: 1,
124
- transition: {
125
- duration: accessoryFadeTransitionDuration,
126
- delay: accessoryFadeTransitionDelay
127
- }
128
- },
129
- exit: {
130
- opacity: 0,
131
- transition: {
132
- duration: accessoryFadeTransitionDuration
133
- }
134
- },
135
- initial: {
136
- opacity: 0
137
- }
138
- } : {}), {}, {
121
+ }, props)), points && /*#__PURE__*/_jsx("g", {
122
+ "data-component": "line-points-group",
139
123
  children: chartData.map((value, index) => {
140
124
  var _pointConfig$onClick;
141
125
  if (value === null) return;
@@ -167,7 +151,8 @@ export const Line = /*#__PURE__*/memo(_ref => {
167
151
  if (points === true) {
168
152
  return /*#__PURE__*/_jsx(Point, _objectSpread({
169
153
  onClick: onPointClick,
170
- transition: transition
154
+ transition: transition,
155
+ transitions: transitions
171
156
  }, defaults), "".concat(seriesId, "-").concat(index));
172
157
  }
173
158
 
@@ -177,9 +162,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
177
162
  const pointConfig = result === true ? {} : result;
178
163
  return /*#__PURE__*/_jsx(Point, _objectSpread(_objectSpread({
179
164
  onClick: (_pointConfig$onClick = pointConfig.onClick) !== null && _pointConfig$onClick !== void 0 ? _pointConfig$onClick : onPointClick,
180
- transition: transition
165
+ transition: transition,
166
+ transitions: transitions
181
167
  }, defaults), pointConfig), "".concat(seriesId, "-").concat(index));
182
168
  })
183
- }))]
169
+ })]
184
170
  });
185
171
  });
@@ -1,4 +1,4 @@
1
- const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
1
+ const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transitions", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
2
2
  _excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
3
3
  _excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
4
4
  _excluded4 = ["id", "data", "label", "color", "yAxisId", "legendShape"];
@@ -30,6 +30,7 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
30
30
  strokeWidth,
31
31
  strokeOpacity,
32
32
  connectNulls,
33
+ transitions,
33
34
  transition,
34
35
  opacity,
35
36
  showXAxis,
@@ -103,7 +104,7 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
103
104
  children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
104
105
  axisId: yAxisId
105
106
  }, yAxisVisualProps)), series === null || series === void 0 ? void 0 : series.map(_ref4 => {
106
- var _linePropsFromSeries$;
107
+ var _linePropsFromSeries$, _linePropsFromSeries$2;
107
108
  let {
108
109
  id,
109
110
  data,
@@ -127,6 +128,7 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
127
128
  strokeOpacity: strokeOpacity,
128
129
  strokeWidth: strokeWidth,
129
130
  transition: (_linePropsFromSeries$ = linePropsFromSeries.transition) !== null && _linePropsFromSeries$ !== void 0 ? _linePropsFromSeries$ : transition,
131
+ transitions: (_linePropsFromSeries$2 = linePropsFromSeries.transitions) !== null && _linePropsFromSeries$2 !== void 0 ? _linePropsFromSeries$2 : transitions,
130
132
  type: type
131
133
  }, linePropsFromSeries), id);
132
134
  }), children]
@@ -1,4 +1,4 @@
1
- const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "gradient", "yAxisId", "animate", "transition", "d"];
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; }
@@ -15,6 +15,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
15
15
  * Supports gradient for gradient effects and smooth data transitions.
16
16
  */
17
17
  export const SolidLine = /*#__PURE__*/memo(_ref => {
18
+ var _transitions$update;
18
19
  let {
19
20
  fill = 'none',
20
21
  stroke = 'var(--color-fgPrimary)',
@@ -25,6 +26,7 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
25
26
  gradient,
26
27
  yAxisId,
27
28
  animate,
29
+ transitions,
28
30
  transition,
29
31
  d
30
32
  } = _ref,
@@ -36,7 +38,7 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
36
38
  animate: animate,
37
39
  gradient: gradient,
38
40
  id: gradientId,
39
- transition: transition,
41
+ transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
40
42
  yAxisId: yAxisId
41
43
  })
42
44
  }), /*#__PURE__*/_jsx(Path, _objectSpread({
@@ -49,7 +51,8 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
49
51
  strokeLinejoin: strokeLinejoin,
50
52
  strokeOpacity: strokeOpacity,
51
53
  strokeWidth: strokeWidth,
52
- transition: transition
54
+ transition: transition,
55
+ transitions: transitions
53
56
  }, props))]
54
57
  });
55
58
  });