@ledgerhq/lumen-ui-react-visualization 0.1.11 → 0.1.12

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 (78) hide show
  1. package/dist/index.js +13 -9
  2. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +1 -1
  3. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -1
  4. package/dist/lib/Components/CartesianChart/CartesianChart.js +78 -79
  5. package/dist/lib/Components/CartesianChart/RevealClip/RevealClipDefs.d.ts +3 -0
  6. package/dist/lib/Components/CartesianChart/RevealClip/RevealClipDefs.d.ts.map +1 -0
  7. package/dist/lib/Components/CartesianChart/RevealClip/RevealClipDefs.js +41 -0
  8. package/dist/lib/Components/CartesianChart/RevealClip/context.d.ts +7 -0
  9. package/dist/lib/Components/CartesianChart/RevealClip/context.d.ts.map +1 -0
  10. package/dist/lib/Components/CartesianChart/RevealClip/context.js +6 -0
  11. package/dist/lib/Components/CartesianChart/RevealClip/index.d.ts +3 -0
  12. package/dist/lib/Components/CartesianChart/RevealClip/index.d.ts.map +1 -0
  13. package/dist/lib/Components/CartesianChart/RevealClip/types.d.ts +37 -0
  14. package/dist/lib/Components/CartesianChart/RevealClip/types.d.ts.map +1 -0
  15. package/dist/lib/Components/CartesianChart/RevealClip/utils.d.ts +17 -0
  16. package/dist/lib/Components/CartesianChart/RevealClip/utils.d.ts.map +1 -0
  17. package/dist/lib/Components/CartesianChart/RevealClip/utils.js +23 -0
  18. package/dist/lib/Components/CartesianChart/types.d.ts +6 -0
  19. package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
  20. package/dist/lib/Components/CartesianChart/utils.js +8 -8
  21. package/dist/lib/Components/Line/Line.d.ts.map +1 -1
  22. package/dist/lib/Components/Line/Line.js +22 -21
  23. package/dist/lib/Components/LineChart/LineChart.d.ts +1 -1
  24. package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
  25. package/dist/lib/Components/LineChart/LineChart.js +36 -34
  26. package/dist/lib/Components/LineChart/types.d.ts +5 -0
  27. package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
  28. package/dist/lib/Components/Point/Point.d.ts.map +1 -1
  29. package/dist/lib/Components/Point/Point.js +19 -17
  30. package/dist/lib/Components/ReferenceLine/ReferenceLine.d.ts +3 -0
  31. package/dist/lib/Components/ReferenceLine/ReferenceLine.d.ts.map +1 -0
  32. package/dist/lib/Components/ReferenceLine/ReferenceLine.js +122 -0
  33. package/dist/lib/Components/ReferenceLine/constants.d.ts +4 -0
  34. package/dist/lib/Components/ReferenceLine/constants.d.ts.map +1 -0
  35. package/dist/lib/Components/ReferenceLine/constants.js +7 -0
  36. package/dist/lib/Components/ReferenceLine/index.d.ts +3 -0
  37. package/dist/lib/Components/ReferenceLine/index.d.ts.map +1 -0
  38. package/dist/lib/Components/ReferenceLine/types.d.ts +74 -0
  39. package/dist/lib/Components/ReferenceLine/types.d.ts.map +1 -0
  40. package/dist/lib/Components/ReferenceLine/utils.d.ts +49 -0
  41. package/dist/lib/Components/ReferenceLine/utils.d.ts.map +1 -0
  42. package/dist/lib/Components/ReferenceLine/utils.js +65 -0
  43. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.d.ts +3 -0
  44. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.d.ts.map +1 -0
  45. package/dist/lib/Components/{ChartTooltip → Scrubber/DefaultScrubberTooltip}/ChartTooltipItem.js +13 -9
  46. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.d.ts +12 -0
  47. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.d.ts.map +1 -0
  48. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.js +85 -0
  49. package/dist/lib/Components/{ChartTooltip → Scrubber/DefaultScrubberTooltip}/constants.d.ts +2 -1
  50. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.d.ts.map +1 -0
  51. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.js +13 -0
  52. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/index.d.ts +3 -0
  53. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/index.d.ts.map +1 -0
  54. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/utils.d.ts +43 -0
  55. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/utils.d.ts.map +1 -0
  56. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/utils.js +59 -0
  57. package/dist/lib/Components/Scrubber/Scrubber.d.ts +14 -2
  58. package/dist/lib/Components/Scrubber/Scrubber.d.ts.map +1 -1
  59. package/dist/lib/Components/Scrubber/Scrubber.js +107 -81
  60. package/dist/lib/Components/Scrubber/index.d.ts +2 -1
  61. package/dist/lib/Components/Scrubber/index.d.ts.map +1 -1
  62. package/dist/lib/Components/Scrubber/types.d.ts +99 -1
  63. package/dist/lib/Components/Scrubber/types.d.ts.map +1 -1
  64. package/dist/lib/Components/index.d.ts +1 -1
  65. package/dist/lib/Components/index.d.ts.map +1 -1
  66. package/dist/package.json +3 -3
  67. package/package.json +2 -2
  68. package/dist/lib/Components/ChartTooltip/ChartTooltip.d.ts +0 -23
  69. package/dist/lib/Components/ChartTooltip/ChartTooltip.d.ts.map +0 -1
  70. package/dist/lib/Components/ChartTooltip/ChartTooltip.js +0 -81
  71. package/dist/lib/Components/ChartTooltip/ChartTooltipItem.d.ts +0 -3
  72. package/dist/lib/Components/ChartTooltip/ChartTooltipItem.d.ts.map +0 -1
  73. package/dist/lib/Components/ChartTooltip/constants.d.ts.map +0 -1
  74. package/dist/lib/Components/ChartTooltip/constants.js +0 -12
  75. package/dist/lib/Components/ChartTooltip/index.d.ts +0 -3
  76. package/dist/lib/Components/ChartTooltip/index.d.ts.map +0 -1
  77. package/dist/lib/Components/ChartTooltip/types.d.ts +0 -61
  78. package/dist/lib/Components/ChartTooltip/types.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,13 +1,17 @@
1
- import { ChartTooltip as t } from "./lib/Components/ChartTooltip/ChartTooltip.js";
2
- import { LineChart as p } from "./lib/Components/LineChart/LineChart.js";
3
- import { Point as b, PointLabel as f } from "./lib/Components/Point/Point.js";
1
+ import { LineChart as o } from "./lib/Components/LineChart/LineChart.js";
2
+ import { Point as f, PointLabel as p } from "./lib/Components/Point/Point.js";
3
+ import { ReferenceLine as x } from "./lib/Components/ReferenceLine/ReferenceLine.js";
4
4
  import { Scrubber as i } from "./lib/Components/Scrubber/Scrubber.js";
5
- import { useScrubberContext as a } from "./lib/Components/Scrubber/context/scrubberContext.js";
5
+ import { useScrubberContext as u } from "./lib/Components/Scrubber/context/scrubberContext.js";
6
+ import { ChartTooltipItem as c } from "./lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.js";
7
+ import { DefaultScrubberTooltip as C } from "./lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.js";
6
8
  export {
7
- t as ChartTooltip,
8
- p as LineChart,
9
- b as Point,
10
- f as PointLabel,
9
+ c as ChartTooltipItem,
10
+ C as DefaultScrubberTooltip,
11
+ o as LineChart,
12
+ f as Point,
13
+ p as PointLabel,
14
+ x as ReferenceLine,
11
15
  i as Scrubber,
12
- a as useScrubberContext
16
+ u as useScrubberContext
13
17
  };
@@ -1,3 +1,3 @@
1
1
  import { CartesianChartProps } from './types';
2
- export declare function CartesianChart({ series, xAxis, yAxis, width, height, inset, axisPadding, ariaLabel, enableScrubbing, onScrubberPositionChange, children, }: CartesianChartProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function CartesianChart({ series, xAxis, yAxis, width, height, inset, axisPadding, ariaLabel, enableScrubbing, onScrubberPositionChange, animate, children, }: CartesianChartProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=CartesianChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQnD,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAuB,EACvB,KAAK,EACL,WAAW,EACX,SAAmB,EACnB,eAAuB,EACvB,wBAAwB,EACxB,QAAQ,GACT,EAAE,mBAAmB,2CA4GrB"}
1
+ {"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQnD,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAuB,EACvB,KAAK,EACL,WAAW,EACX,SAAmB,EACnB,eAAuB,EACvB,wBAAwB,EACxB,OAAc,EACd,QAAQ,GACT,EAAE,mBAAmB,2CA6FrB"}
@@ -1,96 +1,95 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { useRef as C, useState as W, useCallback as z, useEffect as G, useMemo as y } from "react";
3
- import { ScrubberProvider as T } from "../Scrubber/ScrubberProvider.js";
4
- import { resolveInset as V, resolveAxisPadding as _, OVERFLOW_NEGATIVE_MARGIN as R, DEFAULT_HEIGHT as k } from "./utils.js";
5
- import { useBuildChartContext as F } from "./context/useBuildChartContext.js";
6
- import { CartesianChartProvider as H } from "./context/cartesianChartContext.js";
7
- function D({
8
- series: h,
9
- xAxis: x,
10
- yAxis: E,
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useRef as p, useState as O, useCallback as P, useEffect as W, useMemo as h } from "react";
3
+ import { ScrubberProvider as w } from "../Scrubber/ScrubberProvider.js";
4
+ import { resolveInset as z, resolveAxisPadding as G, OVERFLOW_NEGATIVE_MARGIN as T, DEFAULT_HEIGHT as V } from "./utils.js";
5
+ import { useBuildChartContext as _ } from "./context/useBuildChartContext.js";
6
+ import { CartesianChartProvider as k } from "./context/cartesianChartContext.js";
7
+ import { RevealClipDefs as D } from "./RevealClip/RevealClipDefs.js";
8
+ function q({
9
+ series: d,
10
+ xAxis: C,
11
+ yAxis: R,
11
12
  width: e = "100%",
12
- height: r = k,
13
- inset: a,
13
+ height: s = V,
14
+ inset: l,
14
15
  axisPadding: c,
15
- ariaLabel: I = "Chart",
16
- enableScrubbing: o = !1,
17
- onScrubberPositionChange: b,
18
- children: l
16
+ ariaLabel: b = "Chart",
17
+ enableScrubbing: i = !1,
18
+ onScrubberPositionChange: y,
19
+ animate: x = !0,
20
+ children: A
19
21
  }) {
20
- const n = C(null), f = C(null), [u, A] = W(
22
+ const a = p(null), f = p(null), [E, I] = O(
21
23
  typeof e == "number" ? e : void 0
22
- ), i = typeof e != "number", v = z((s) => {
23
- const [p] = s;
24
- p && A(p.contentRect.width);
24
+ ), t = typeof e != "number", u = P((n) => {
25
+ const [m] = n;
26
+ m && I(m.contentRect.width);
25
27
  }, []);
26
- G(() => {
27
- if (!i || !n.current || typeof ResizeObserver > "u")
28
+ W(() => {
29
+ if (!t || !a.current || typeof ResizeObserver > "u")
28
30
  return;
29
- const s = new ResizeObserver(v);
30
- return s.observe(n.current), () => s.disconnect();
31
- }, [i, v]);
32
- const d = typeof e == "number" ? e : u ?? 0, M = y(() => V(a), [a]), O = y(
33
- () => _(c),
31
+ const n = new ResizeObserver(u);
32
+ return n.observe(a.current), () => n.disconnect();
33
+ }, [t, u]);
34
+ const o = typeof e == "number" ? e : E ?? 0, g = h(() => z(l), [l]), M = h(
35
+ () => G(c),
34
36
  [c]
35
- ), P = F({
36
- series: h,
37
- xAxis: x,
38
- yAxis: E,
39
- width: d,
40
- height: r,
41
- inset: M,
42
- axisPadding: O
43
- }), m = /* @__PURE__ */ t(
44
- "svg",
45
- {
46
- ref: f,
47
- "data-testid": "chart-svg",
48
- width: d,
49
- height: r,
50
- role: "img",
51
- "aria-label": I || "Chart",
52
- tabIndex: o ? 0 : void 0,
53
- style: {
54
- display: "block",
55
- overflow: "visible",
56
- outline: o ? "none" : void 0
57
- },
58
- children: /* @__PURE__ */ t(H, { value: P, children: o ? /* @__PURE__ */ t(
59
- T,
60
- {
61
- svgRef: f,
62
- enableScrubbing: o,
63
- onScrubberPositionChange: b,
64
- children: l
65
- }
66
- ) : l })
67
- }
68
- );
69
- return i ? /* @__PURE__ */ t(
37
+ ), v = _({
38
+ series: d,
39
+ xAxis: C,
40
+ yAxis: R,
41
+ width: o,
42
+ height: s,
43
+ inset: g,
44
+ axisPadding: M
45
+ });
46
+ return /* @__PURE__ */ r(
70
47
  "div",
71
48
  {
72
- ref: n,
49
+ ref: t ? a : void 0,
73
50
  "data-testid": "chart-container",
74
51
  style: {
75
- width: e,
76
- height: r,
77
- ...R
52
+ width: t ? e : o,
53
+ height: s,
54
+ ...T
78
55
  },
79
- children: u !== void 0 && m
80
- }
81
- ) : /* @__PURE__ */ t(
82
- "div",
83
- {
84
- "data-testid": "chart-container",
85
- style: {
86
- width: d,
87
- height: r,
88
- ...R
89
- },
90
- children: m
56
+ children: o > 0 && /* @__PURE__ */ r(
57
+ "svg",
58
+ {
59
+ ref: f,
60
+ "data-testid": "chart-svg",
61
+ width: o,
62
+ height: s,
63
+ role: "img",
64
+ "aria-label": b || "Chart",
65
+ tabIndex: i ? 0 : void 0,
66
+ style: {
67
+ display: "block",
68
+ overflow: "visible",
69
+ outline: i ? "none" : void 0
70
+ },
71
+ children: /* @__PURE__ */ r(k, { value: v, children: /* @__PURE__ */ r(
72
+ w,
73
+ {
74
+ svgRef: f,
75
+ enableScrubbing: i,
76
+ onScrubberPositionChange: y,
77
+ children: /* @__PURE__ */ r(
78
+ D,
79
+ {
80
+ drawingArea: v.drawingArea,
81
+ series: d,
82
+ animate: x,
83
+ children: A
84
+ }
85
+ )
86
+ }
87
+ ) })
88
+ }
89
+ )
91
90
  }
92
91
  );
93
92
  }
94
93
  export {
95
- D as CartesianChart
94
+ q as CartesianChart
96
95
  };
@@ -0,0 +1,3 @@
1
+ import { RevealClipDefsProps } from './types';
2
+ export declare function RevealClipDefs({ children, drawingArea, series, animate, transitions, }: RevealClipDefsProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=RevealClipDefs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RevealClipDefs.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/RevealClip/RevealClipDefs.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMnD,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,WAAW,EACX,MAAM,EACN,OAAc,EACd,WAAW,GACZ,EAAE,mBAAmB,2CA4CrB"}
@@ -0,0 +1,41 @@
1
+ import { jsx as i, Fragment as d, jsxs as F } from "react/jsx-runtime";
2
+ import { useMemo as x } from "react";
3
+ import { OVERFLOW_BUFFER as t } from "../utils.js";
4
+ import { RevealClipContext as D } from "./context.js";
5
+ import { useComputeDataFingerprint as y, useRevealClipAnimation as C } from "./utils.js";
6
+ const E = 0.8, R = "linear";
7
+ function O({
8
+ children: n,
9
+ drawingArea: e,
10
+ series: l,
11
+ animate: s = !0,
12
+ transitions: r
13
+ }) {
14
+ const m = !s, c = r?.enter?.duration ?? E, p = r?.enter?.easing ?? R, a = y({ series: l }), { clipId: o, animationStyle: u, keyframe: f } = C({
15
+ duration: c,
16
+ easing: p,
17
+ drawingArea: e
18
+ }), h = x(
19
+ () => ({
20
+ clipPathAttr: `url(#${o})`
21
+ }),
22
+ [o]
23
+ );
24
+ return m ? /* @__PURE__ */ i(d, { children: n }) : /* @__PURE__ */ F(D.Provider, { value: h, children: [
25
+ /* @__PURE__ */ i("defs", { children: /* @__PURE__ */ i("clipPath", { id: o, children: /* @__PURE__ */ i(
26
+ "rect",
27
+ {
28
+ x: e.x - t.left,
29
+ y: e.y - t.top,
30
+ height: e.height + t.top + t.bottom,
31
+ width: e.width + t.left + t.right,
32
+ style: { animation: u }
33
+ }
34
+ ) }) }),
35
+ /* @__PURE__ */ i("style", { children: f }),
36
+ n
37
+ ] }, a);
38
+ }
39
+ export {
40
+ O as RevealClipDefs
41
+ };
@@ -0,0 +1,7 @@
1
+ type RevealClipContextValue = {
2
+ clipPathAttr: string;
3
+ };
4
+ export declare const RevealClipContext: import('react').Context<RevealClipContextValue | undefined>;
5
+ export declare const useRevealClip: () => string | undefined;
6
+ export {};
7
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/RevealClip/context.ts"],"names":[],"mappings":"AAEA,KAAK,sBAAsB,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,6DAElB,CAAC;AAEb,eAAO,MAAM,aAAa,QAAO,MAAM,GAAG,SAEzC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { useContext as t, createContext as e } from "react";
2
+ const o = e(void 0), n = () => t(o)?.clipPathAttr;
3
+ export {
4
+ o as RevealClipContext,
5
+ n as useRevealClip
6
+ };
@@ -0,0 +1,3 @@
1
+ export { RevealClipDefs } from './RevealClipDefs';
2
+ export { useRevealClip } from './context';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/RevealClip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from 'react';
2
+ import { DrawingArea, Series } from '../../../utils';
3
+ export type EnterTransitionConfig = {
4
+ /**
5
+ * Duration in seconds. @default 0.8
6
+ */
7
+ duration?: number;
8
+ /**
9
+ * CSS easing function. @default 'linear'
10
+ */
11
+ easing?: string;
12
+ };
13
+ export type RevealClipDefsProps = {
14
+ children: ReactNode;
15
+ /**
16
+ * The drawing area whose bounds define the clip rectangle.
17
+ */
18
+ drawingArea: DrawingArea;
19
+ /**
20
+ * Whether to animate the chart.
21
+ * @default true
22
+ */
23
+ animate?: boolean;
24
+ /**
25
+ * Transition configuration.
26
+ * @default { enter: { duration: 0.8, easing: 'linear' } }
27
+ */
28
+ transitions?: {
29
+ enter?: EnterTransitionConfig;
30
+ };
31
+ /**
32
+ * Data series used to compute a fingerprint that restarts
33
+ * the animation when data changes.
34
+ */
35
+ series: Series[];
36
+ };
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/RevealClip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,qBAAqB,CAAA;KAAE,CAAC;IAChD;;;OAGG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { DrawingArea, Series } from '../../../utils/types';
2
+ type RevealClipAnimationConfig = {
3
+ duration: number;
4
+ easing: string;
5
+ drawingArea: DrawingArea;
6
+ };
7
+ type RevealClipAnimationResult = {
8
+ clipId: string;
9
+ animationStyle: string;
10
+ keyframe: string;
11
+ };
12
+ export declare const useRevealClipAnimation: ({ duration, easing, drawingArea, }: RevealClipAnimationConfig) => RevealClipAnimationResult;
13
+ export declare const useComputeDataFingerprint: ({ series, }: {
14
+ series: Series[];
15
+ }) => string;
16
+ export {};
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/RevealClip/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGhE,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,oCAIpC,yBAAyB,KAAG,yBAY9B,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,aAEvC;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,KAAG,MAEH,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { useId as a, useMemo as n } from "react";
2
+ import { OVERFLOW_BUFFER as m } from "../utils.js";
3
+ const s = ({
4
+ duration: t,
5
+ easing: e,
6
+ drawingArea: r
7
+ }) => {
8
+ const o = a(), i = `reveal-clip-${o.replaceAll(":", "")}`;
9
+ return n(
10
+ () => ({
11
+ clipId: o,
12
+ animationStyle: `${i} ${t}s ${e} forwards`,
13
+ keyframe: `@keyframes ${i} { from { width: 0; } to { width: ${r.width + m.left + m.right}px; } }`
14
+ }),
15
+ [o, i, t, e, r.width]
16
+ );
17
+ }, c = ({
18
+ series: t
19
+ }) => t.map((e) => e.data?.join(",") ?? "").join("|");
20
+ export {
21
+ c as useComputeDataFingerprint,
22
+ s as useRevealClipAnimation
23
+ };
@@ -57,5 +57,11 @@ export type CartesianChartProps = {
57
57
  * Receives `undefined` when the scrubber leaves the chart.
58
58
  */
59
59
  onScrubberPositionChange?: (index: number | undefined) => void;
60
+ /**
61
+ * Whether to animate the chart on mount and data changes.
62
+ * Duration is 0.8 seconds and easing is linear.
63
+ * @default true
64
+ */
65
+ animate?: boolean;
60
66
  };
61
67
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAChE,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/D;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -1,13 +1,13 @@
1
1
  const m = 160, r = {
2
- top: 30,
3
- right: 20,
4
- bottom: 30,
5
- left: 20
2
+ top: 50,
3
+ right: 50,
4
+ bottom: 50,
5
+ left: 50
6
6
  }, f = {
7
- marginTop: -30,
8
- marginRight: -20,
9
- marginBottom: -30,
10
- marginLeft: -20
7
+ marginTop: -50,
8
+ marginRight: -50,
9
+ marginBottom: -50,
10
+ marginLeft: -50
11
11
  }, e = {
12
12
  top: 0,
13
13
  right: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/Line.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,MAAM,EACN,QAAgB,EAChB,QAAQ,EAAE,SAAsB,GACjC,EAAE,SAAS,kDA6EX"}
1
+ {"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/Line.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,MAAM,EACN,QAAgB,EAChB,QAAQ,EAAE,SAAsB,GACjC,EAAE,SAAS,kDA8EX"}
@@ -1,28 +1,29 @@
1
- import { jsxs as l, Fragment as m, jsx as e } from "react/jsx-runtime";
1
+ import { jsxs as l, jsx as e, Fragment as P } from "react/jsx-runtime";
2
2
  import { useId as S, useMemo as d } from "react";
3
3
  import { isNumericScale as A } from "../../utils/scales/scales.js";
4
- import { toScaledPoints as P, buildLinePath as I, buildAreaPath as L } from "./utils.js";
5
- import { useCartesianChartContext as T } from "../CartesianChart/context/cartesianChartContext.js";
6
- import { cssVar as j } from "../../../libs/design-core/dist/lib/cssVar/cssVar.js";
7
- const O = 0.15;
8
- function N({
9
- seriesId: g,
10
- stroke: h,
11
- showArea: n = !1,
4
+ import { toScaledPoints as I, buildLinePath as L, buildAreaPath as T } from "./utils.js";
5
+ import { useCartesianChartContext as j } from "../CartesianChart/context/cartesianChartContext.js";
6
+ import { useRevealClip as v } from "../CartesianChart/RevealClip/context.js";
7
+ import { cssVar as O } from "../../../libs/design-core/dist/lib/cssVar/cssVar.js";
8
+ const R = 0.15;
9
+ function Y({
10
+ seriesId: u,
11
+ stroke: g,
12
+ showArea: i = !1,
12
13
  areaType: _ = "gradient"
13
14
  }) {
14
- const { getXScale: x, getYScale: k, getXAxisConfig: C, drawingArea: i, seriesMap: y } = T(), s = x(), o = k(), c = C(), p = S(), r = y.get(g), a = h ?? r?.stroke, t = d(
15
- () => r?.data && s && o && A(o) ? P(r.data, s, o, c?.data) : null,
15
+ const { getXScale: h, getYScale: x, getXAxisConfig: C, drawingArea: n, seriesMap: k } = j(), y = v(), s = h(), o = x(), c = C(), p = S(), r = k.get(u), a = g ?? r?.stroke, t = d(
16
+ () => r?.data && s && o && A(o) ? I(r.data, s, o, c?.data) : null,
16
17
  [r, s, o, c]
17
18
  ), f = d(
18
- () => t ? I(t) : null,
19
+ () => t ? L(t) : null,
19
20
  [t]
20
- ), u = d(
21
- () => n && t && i ? L(t, i) : null,
22
- [n, t, i]
21
+ ), m = d(
22
+ () => i && t && n ? T(t, n) : null,
23
+ [i, t, n]
23
24
  );
24
- return f ? /* @__PURE__ */ l(m, { children: [
25
- n && u && a && /* @__PURE__ */ l(m, { children: [
25
+ return f ? /* @__PURE__ */ l("g", { clipPath: y, children: [
26
+ i && m && a && /* @__PURE__ */ l(P, { children: [
26
27
  /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ l(
27
28
  "linearGradient",
28
29
  {
@@ -38,7 +39,7 @@ function N({
38
39
  {
39
40
  offset: "0%",
40
41
  stopColor: a,
41
- stopOpacity: O
42
+ stopOpacity: R
42
43
  }
43
44
  ),
44
45
  /* @__PURE__ */ e("stop", { offset: "100%", stopColor: a, stopOpacity: 0 })
@@ -49,7 +50,7 @@ function N({
49
50
  "path",
50
51
  {
51
52
  "data-testid": "line-area",
52
- d: u,
53
+ d: m,
53
54
  fill: `url(#${p})`,
54
55
  stroke: "none"
55
56
  }
@@ -62,7 +63,7 @@ function N({
62
63
  d: f,
63
64
  fill: "none",
64
65
  stroke: a,
65
- strokeWidth: j("var(--stroke-2)"),
66
+ strokeWidth: O("var(--stroke-2)"),
66
67
  strokeLinecap: "round",
67
68
  strokeLinejoin: "round"
68
69
  }
@@ -70,5 +71,5 @@ function N({
70
71
  ] }) : null;
71
72
  }
72
73
  export {
73
- N as Line
74
+ Y as Line
74
75
  };
@@ -1,3 +1,3 @@
1
1
  import { LineChartProps } from './types';
2
- export declare function LineChart({ series, showArea, areaType, showXAxis, showYAxis, xAxis, yAxis, width, height, inset, enableScrubbing, onScrubberPositionChange, children, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function LineChart({ series, showArea, areaType, showXAxis, showYAxis, xAxis, yAxis, width, height, inset, enableScrubbing, onScrubberPositionChange, animate, children, }: LineChartProps): import("react/jsx-runtime").JSX.Element;
3
3
  //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/LineChart.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,QAAgB,EAChB,QAAqB,EACrB,SAAiB,EACjB,SAAiB,EACjB,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAY,EACZ,KAAK,EACL,eAAe,EACf,wBAAwB,EACxB,QAAQ,GACT,EAAE,cAAc,2CA0EhB"}
1
+ {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/LineChart.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,QAAgB,EAChB,QAAqB,EACrB,SAAiB,EACjB,SAAiB,EACjB,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAY,EACZ,KAAK,EACL,eAAe,EACf,wBAAwB,EACxB,OAAO,EACP,QAAQ,GACT,EAAE,cAAc,2CA2EhB"}
@@ -1,10 +1,10 @@
1
- import { jsxs as H, jsx as e } from "react/jsx-runtime";
2
- import { useMemo as j } from "react";
3
- import { DEFAULT_AXIS_WIDTH as F, YAxis as U } from "../Axis/YAxis/YAxis.js";
4
- import { DEFAULT_AXIS_HEIGHT as m, XAxis as V } from "../Axis/XAxis/XAxis.js";
5
- import { CartesianChart as W } from "../CartesianChart/CartesianChart.js";
6
- import { Line as h } from "../Line/Line.js";
7
- function B({
1
+ import { jsxs as j, jsx as e } from "react/jsx-runtime";
2
+ import { useMemo as F } from "react";
3
+ import { DEFAULT_AXIS_WIDTH as U, YAxis as V } from "../Axis/YAxis/YAxis.js";
4
+ import { DEFAULT_AXIS_HEIGHT as m, XAxis as W } from "../Axis/XAxis/XAxis.js";
5
+ import { CartesianChart as h } from "../CartesianChart/CartesianChart.js";
6
+ import { Line as v } from "../Line/Line.js";
7
+ function J({
8
8
  series: r,
9
9
  showArea: d = !1,
10
10
  areaType: c = "gradient",
@@ -17,29 +17,30 @@ function B({
17
17
  inset: T,
18
18
  enableScrubbing: g,
19
19
  onScrubberPositionChange: u,
20
- children: A
20
+ animate: A,
21
+ children: D
21
22
  }) {
22
23
  const {
23
- scaleType: D,
24
- data: C,
25
- domain: I,
24
+ scaleType: C,
25
+ data: I,
26
+ domain: P,
26
27
  ...n
27
28
  } = f ?? {}, {
28
- scaleType: P,
29
- data: L,
30
- domain: S,
29
+ scaleType: L,
30
+ data: S,
31
+ domain: _,
31
32
  ...o
32
- } = l ?? {}, _ = {
33
- scaleType: D,
34
- data: C,
35
- domain: I
36
- }, b = {
37
- scaleType: P,
38
- data: L,
39
- domain: S
40
- }, E = j(() => {
33
+ } = l ?? {}, b = {
34
+ scaleType: C,
35
+ data: I,
36
+ domain: P
37
+ }, E = {
38
+ scaleType: L,
39
+ data: S,
40
+ domain: _
41
+ }, H = F(() => {
41
42
  if (!t && !i) return;
42
- const a = n.position === "top" ? "top" : "bottom", s = o.position === "end" ? "right" : "left", p = o.width ?? F;
43
+ const a = n.position === "top" ? "top" : "bottom", s = o.position === "end" ? "right" : "left", p = o.width ?? U;
43
44
  return {
44
45
  top: t && a === "top" ? m : 0,
45
46
  bottom: t && a === "bottom" ? m : 0,
@@ -53,23 +54,24 @@ function B({
53
54
  o.position,
54
55
  o.width
55
56
  ]);
56
- return /* @__PURE__ */ H(
57
- W,
57
+ return /* @__PURE__ */ j(
58
+ h,
58
59
  {
59
60
  series: r ?? [],
60
- xAxis: _,
61
- yAxis: b,
61
+ xAxis: b,
62
+ yAxis: E,
62
63
  width: x,
63
64
  height: y,
64
65
  inset: T,
65
- axisPadding: E,
66
+ axisPadding: H,
66
67
  enableScrubbing: g,
67
68
  onScrubberPositionChange: u,
69
+ animate: A,
68
70
  children: [
69
- t && /* @__PURE__ */ e(V, { ...n }),
70
- i && /* @__PURE__ */ e(U, { ...o }),
71
+ t && /* @__PURE__ */ e(W, { ...n }),
72
+ i && /* @__PURE__ */ e(V, { ...o }),
71
73
  r?.map((a) => /* @__PURE__ */ e(
72
- h,
74
+ v,
73
75
  {
74
76
  seriesId: a.id,
75
77
  showArea: d,
@@ -77,11 +79,11 @@ function B({
77
79
  },
78
80
  a.id
79
81
  )),
80
- A
82
+ D
81
83
  ]
82
84
  }
83
85
  );
84
86
  }
85
87
  export {
86
- B as LineChart
88
+ J as LineChart
87
89
  };