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

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 (55) hide show
  1. package/dist/index.js +11 -5
  2. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -1
  3. package/dist/lib/Components/Axis/XAxis/XAxis.js +7 -5
  4. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -1
  5. package/dist/lib/Components/Axis/YAxis/YAxis.js +8 -6
  6. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +1 -1
  7. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -1
  8. package/dist/lib/Components/CartesianChart/CartesianChart.js +67 -50
  9. package/dist/lib/Components/CartesianChart/types.d.ts +11 -0
  10. package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
  11. package/dist/lib/Components/ChartTooltip/ChartTooltip.d.ts +23 -0
  12. package/dist/lib/Components/ChartTooltip/ChartTooltip.d.ts.map +1 -0
  13. package/dist/lib/Components/ChartTooltip/ChartTooltip.js +81 -0
  14. package/dist/lib/Components/ChartTooltip/ChartTooltipItem.d.ts +3 -0
  15. package/dist/lib/Components/ChartTooltip/ChartTooltipItem.d.ts.map +1 -0
  16. package/dist/lib/Components/ChartTooltip/ChartTooltipItem.js +46 -0
  17. package/dist/lib/Components/ChartTooltip/constants.d.ts +10 -0
  18. package/dist/lib/Components/ChartTooltip/constants.d.ts.map +1 -0
  19. package/dist/lib/Components/ChartTooltip/constants.js +12 -0
  20. package/dist/lib/Components/ChartTooltip/index.d.ts +3 -0
  21. package/dist/lib/Components/ChartTooltip/index.d.ts.map +1 -0
  22. package/dist/lib/Components/ChartTooltip/types.d.ts +61 -0
  23. package/dist/lib/Components/ChartTooltip/types.d.ts.map +1 -0
  24. package/dist/lib/Components/Line/Line.js +1 -1
  25. package/dist/lib/Components/LineChart/LineChart.d.ts +1 -1
  26. package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
  27. package/dist/lib/Components/LineChart/LineChart.js +38 -34
  28. package/dist/lib/Components/LineChart/types.d.ts +11 -0
  29. package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
  30. package/dist/lib/Components/Scrubber/Scrubber.d.ts +17 -0
  31. package/dist/lib/Components/Scrubber/Scrubber.d.ts.map +1 -0
  32. package/dist/lib/Components/Scrubber/Scrubber.js +134 -0
  33. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts +3 -0
  34. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts.map +1 -0
  35. package/dist/lib/Components/Scrubber/ScrubberProvider.js +122 -0
  36. package/dist/lib/Components/Scrubber/context/index.d.ts +2 -0
  37. package/dist/lib/Components/Scrubber/context/index.d.ts.map +1 -0
  38. package/dist/lib/Components/Scrubber/context/scrubberContext.d.ts +8 -0
  39. package/dist/lib/Components/Scrubber/context/scrubberContext.d.ts.map +1 -0
  40. package/dist/lib/Components/Scrubber/context/scrubberContext.js +9 -0
  41. package/dist/lib/Components/Scrubber/index.d.ts +4 -0
  42. package/dist/lib/Components/Scrubber/index.d.ts.map +1 -0
  43. package/dist/lib/Components/Scrubber/types.d.ts +53 -0
  44. package/dist/lib/Components/Scrubber/types.d.ts.map +1 -0
  45. package/dist/lib/Components/Scrubber/utils.d.ts +30 -0
  46. package/dist/lib/Components/Scrubber/utils.d.ts.map +1 -0
  47. package/dist/lib/Components/Scrubber/utils.js +57 -0
  48. package/dist/lib/Components/index.d.ts +2 -0
  49. package/dist/lib/Components/index.d.ts.map +1 -1
  50. package/dist/lib/utils/scales/scales.d.ts +5 -0
  51. package/dist/lib/utils/scales/scales.d.ts.map +1 -1
  52. package/dist/lib/utils/scales/scales.js +19 -18
  53. package/dist/libs/utils-shared/dist/index.js +13 -13
  54. package/dist/package.json +3 -3
  55. package/package.json +3 -3
@@ -1,10 +1,10 @@
1
- import { jsxs as b, jsx as e } from "react/jsx-runtime";
2
- import { useMemo as E } from "react";
3
- import { DEFAULT_AXIS_WIDTH as H, YAxis as j } from "../Axis/YAxis/YAxis.js";
4
- import { DEFAULT_AXIS_HEIGHT as m, XAxis as F } from "../Axis/XAxis/XAxis.js";
5
- import { CartesianChart as U } from "../CartesianChart/CartesianChart.js";
6
- import { Line as V } from "../Line/Line.js";
7
- function q({
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({
8
8
  series: r,
9
9
  showArea: d = !1,
10
10
  areaType: c = "gradient",
@@ -15,29 +15,31 @@ function q({
15
15
  width: x = "100%",
16
16
  height: y = 160,
17
17
  inset: T,
18
- children: g
18
+ enableScrubbing: g,
19
+ onScrubberPositionChange: u,
20
+ children: A
19
21
  }) {
20
22
  const {
21
- scaleType: u,
22
- data: A,
23
- domain: D,
23
+ scaleType: D,
24
+ data: C,
25
+ domain: I,
24
26
  ...n
25
27
  } = f ?? {}, {
26
- scaleType: C,
27
- data: I,
28
- domain: P,
28
+ scaleType: P,
29
+ data: L,
30
+ domain: S,
29
31
  ...o
30
- } = l ?? {}, L = {
31
- scaleType: u,
32
- data: A,
33
- domain: D
34
- }, S = {
35
- scaleType: C,
36
- data: I,
37
- domain: P
38
- }, _ = E(() => {
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(() => {
39
41
  if (!t && !i) return;
40
- const a = n.position === "top" ? "top" : "bottom", s = o.position === "end" ? "right" : "left", p = o.width ?? H;
42
+ const a = n.position === "top" ? "top" : "bottom", s = o.position === "end" ? "right" : "left", p = o.width ?? F;
41
43
  return {
42
44
  top: t && a === "top" ? m : 0,
43
45
  bottom: t && a === "bottom" ? m : 0,
@@ -51,21 +53,23 @@ function q({
51
53
  o.position,
52
54
  o.width
53
55
  ]);
54
- return /* @__PURE__ */ b(
55
- U,
56
+ return /* @__PURE__ */ H(
57
+ W,
56
58
  {
57
59
  series: r ?? [],
58
- xAxis: L,
59
- yAxis: S,
60
+ xAxis: _,
61
+ yAxis: b,
60
62
  width: x,
61
63
  height: y,
62
64
  inset: T,
63
- axisPadding: _,
65
+ axisPadding: E,
66
+ enableScrubbing: g,
67
+ onScrubberPositionChange: u,
64
68
  children: [
65
- t && /* @__PURE__ */ e(F, { ...n }),
66
- i && /* @__PURE__ */ e(j, { ...o }),
69
+ t && /* @__PURE__ */ e(V, { ...n }),
70
+ i && /* @__PURE__ */ e(U, { ...o }),
67
71
  r?.map((a) => /* @__PURE__ */ e(
68
- V,
72
+ h,
69
73
  {
70
74
  seriesId: a.id,
71
75
  showArea: d,
@@ -73,11 +77,11 @@ function q({
73
77
  },
74
78
  a.id
75
79
  )),
76
- g
80
+ A
77
81
  ]
78
82
  }
79
83
  );
80
84
  }
81
85
  export {
82
- q as LineChart
86
+ B as LineChart
83
87
  };
@@ -59,5 +59,16 @@ export type LineChartProps = {
59
59
  * Additional SVG content rendered inside the chart after lines and axes.
60
60
  */
61
61
  children?: ReactNode;
62
+ /**
63
+ * Enables scrubbing (hover/touch/keyboard) interactions on the chart.
64
+ * When true, add a `<Scrubber>` as a child to visualise the interaction.
65
+ * @default false
66
+ */
67
+ enableScrubbing?: boolean;
68
+ /**
69
+ * Callback fired whenever the scrubber moves to a new data index or is cleared.
70
+ * Receives `undefined` when the scrubber leaves the chart.
71
+ */
72
+ onScrubberPositionChange?: (index: number | undefined) => void;
62
73
  };
63
74
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/LineChart/types.ts"],"names":[],"mappings":"AA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,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC;IAC9C;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC;;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"}
@@ -0,0 +1,17 @@
1
+ import { ScrubberProps } from './types';
2
+ /**
3
+ * Renders the scrubber visuals: vertical reference line, future-data overlay
4
+ * rect, per-series beacon dots, and an optional formatted label above the line.
5
+ *
6
+ * Must be used as a child of `LineChart` (or `CartesianChart`) with
7
+ * `enableScrubbing` enabled. Renders nothing when no scrubber position is active.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * <LineChart series={data} enableScrubbing>
12
+ * <Scrubber label={(i) => data[i].date} />
13
+ * </LineChart>
14
+ * ```
15
+ */
16
+ export declare function Scrubber({ label, hideLine, hideOverlay, showBeacons, }: Readonly<ScrubberProps>): import("react/jsx-runtime").JSX.Element | null;
17
+ //# sourceMappingURL=Scrubber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Scrubber.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/Scrubber.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAa7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,QAAgB,EAChB,WAAmB,EACnB,WAAmB,GACpB,EAAE,QAAQ,CAAC,aAAa,CAAC,kDA0IzB"}
@@ -0,0 +1,134 @@
1
+ import { jsxs as l, jsx as i, Fragment as F } from "react/jsx-runtime";
2
+ import { useId as N, useMemo as c } from "react";
3
+ import { resolvePixelX as R, resolvePixelY as W, LINE_GRADIENT_EDGE_OPACITY as g, OVERLAY_OPACITY as X, LABEL_OFFSET_Y as D, BEACON_STROKE_WIDTH as P, BEACON_RADIUS as G, OVERLAY_OFFSET as f, OVERLAY_LINE_INSET as E } from "./utils.js";
4
+ import { useScrubberContext as V } from "./context/scrubberContext.js";
5
+ import { useCartesianChartContext as H } from "../CartesianChart/context/cartesianChartContext.js";
6
+ import { cssVar as t } from "../../../libs/design-core/dist/lib/cssVar/cssVar.js";
7
+ function K({
8
+ label: a,
9
+ hideLine: A = !1,
10
+ hideOverlay: C = !1,
11
+ showBeacons: d = !1
12
+ }) {
13
+ const u = N(), { scrubberPosition: e } = V(), {
14
+ getXScale: b,
15
+ getXAxisConfig: v,
16
+ getYScale: p,
17
+ drawingArea: O,
18
+ series: x,
19
+ seriesMap: y
20
+ } = H(), o = c(() => {
21
+ if (e !== void 0)
22
+ return R(e, b, v());
23
+ }, [e, b, v]), Y = c(() => e === void 0 || !d ? [] : x.map((r) => {
24
+ const w = y.get(r.id)?.data, h = W(e, w, p);
25
+ return h === void 0 ? null : { id: r.id, stroke: r.stroke, pixelY: h };
26
+ }).filter(
27
+ (r) => r !== null
28
+ ), [e, d, x, y, p]), m = c(() => {
29
+ if (!(e === void 0 || !a))
30
+ return a(e);
31
+ }, [e, a]);
32
+ if (e === void 0 || o === void 0)
33
+ return null;
34
+ const {
35
+ x: _,
36
+ y: s,
37
+ width: S,
38
+ height: n
39
+ } = O, k = o + E, I = s - f, L = Math.max(
40
+ 0,
41
+ _ + S - o - E + f
42
+ ), T = n + f * 2;
43
+ return /* @__PURE__ */ l("g", { "data-testid": "scrubber", children: [
44
+ !A && /* @__PURE__ */ l(F, { children: [
45
+ /* @__PURE__ */ i("defs", { children: /* @__PURE__ */ l(
46
+ "linearGradient",
47
+ {
48
+ id: u,
49
+ gradientUnits: "userSpaceOnUse",
50
+ x1: o,
51
+ y1: s,
52
+ x2: o,
53
+ y2: s + n,
54
+ children: [
55
+ /* @__PURE__ */ i(
56
+ "stop",
57
+ {
58
+ offset: "0%",
59
+ stopColor: t("var(--border-base)"),
60
+ stopOpacity: g
61
+ }
62
+ ),
63
+ /* @__PURE__ */ i("stop", { offset: "20%", stopColor: t("var(--border-base)") }),
64
+ /* @__PURE__ */ i("stop", { offset: "80%", stopColor: t("var(--border-base)") }),
65
+ /* @__PURE__ */ i(
66
+ "stop",
67
+ {
68
+ offset: "100%",
69
+ stopColor: t("var(--border-base)"),
70
+ stopOpacity: g
71
+ }
72
+ )
73
+ ]
74
+ }
75
+ ) }),
76
+ /* @__PURE__ */ i(
77
+ "line",
78
+ {
79
+ "data-testid": "scrubber-line",
80
+ x1: o,
81
+ y1: s,
82
+ x2: o,
83
+ y2: s + n,
84
+ stroke: `url(#${u})`,
85
+ strokeWidth: t("var(--stroke-1)")
86
+ }
87
+ )
88
+ ] }),
89
+ !C && /* @__PURE__ */ i(
90
+ "rect",
91
+ {
92
+ "data-testid": "scrubber-overlay",
93
+ x: k,
94
+ y: I,
95
+ width: L,
96
+ height: T,
97
+ fill: t("var(--background-base)"),
98
+ opacity: X
99
+ }
100
+ ),
101
+ m !== void 0 && /* @__PURE__ */ i(
102
+ "text",
103
+ {
104
+ "data-testid": "scrubber-label",
105
+ x: o,
106
+ y: s - D,
107
+ textAnchor: "middle",
108
+ style: {
109
+ fill: t("var(--text-base)"),
110
+ fontSize: t("var(--font-style-body-4-size)"),
111
+ fontWeight: t("var(--font-style-body-4-weight-medium)"),
112
+ fontFamily: t("var(--font-family-font)")
113
+ },
114
+ children: m
115
+ }
116
+ ),
117
+ d && Y.map((r) => /* @__PURE__ */ i(
118
+ "circle",
119
+ {
120
+ "data-testid": `scrubber-beacon-${r.id}`,
121
+ cx: o,
122
+ cy: r.pixelY,
123
+ r: G,
124
+ fill: r.stroke,
125
+ stroke: t("var(--background-canvas)"),
126
+ strokeWidth: P
127
+ },
128
+ r.id
129
+ ))
130
+ ] });
131
+ }
132
+ export {
133
+ K as Scrubber
134
+ };
@@ -0,0 +1,3 @@
1
+ import { ScrubberProviderProps } from './types';
2
+ export declare function ScrubberProvider({ children, svgRef, enableScrubbing, onScrubberPositionChange, }: Readonly<ScrubberProviderProps>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=ScrubberProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrubberProvider.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/ScrubberProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG3E,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,eAAe,EACf,wBAAwB,GACzB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,2CAiLjC"}
@@ -0,0 +1,122 @@
1
+ import { jsx as D } from "react/jsx-runtime";
2
+ import { useState as w, useRef as y, useCallback as a, useEffect as R, useMemo as T } from "react";
3
+ import { getDataIndexFromPosition as X } from "./utils.js";
4
+ import { useCartesianChartContext as A } from "../CartesianChart/context/cartesianChartContext.js";
5
+ import { ScrubberContextProvider as B } from "./context/scrubberContext.js";
6
+ function N({
7
+ children: k,
8
+ svgRef: L,
9
+ enableScrubbing: o,
10
+ onScrubberPositionChange: x
11
+ }) {
12
+ const { getXScale: M, getXAxisConfig: g, dataLength: s } = A(), [m, C] = w(
13
+ void 0
14
+ ), v = y(m);
15
+ v.current = m;
16
+ const c = a(
17
+ (t) => {
18
+ const e = t === void 0 ? void 0 : Math.max(0, Math.min(t, s - 1));
19
+ C(e), x?.(e);
20
+ },
21
+ [s, x]
22
+ ), i = a(
23
+ (t) => {
24
+ const e = M();
25
+ if (!e || !o || s <= 0) return;
26
+ const n = X(
27
+ t,
28
+ e,
29
+ g(),
30
+ s
31
+ );
32
+ n !== v.current && c(n);
33
+ },
34
+ [
35
+ o,
36
+ M,
37
+ g,
38
+ s,
39
+ c
40
+ ]
41
+ ), r = a(() => {
42
+ o && c(void 0);
43
+ }, [o, c]), h = a(
44
+ (t) => {
45
+ const n = t.currentTarget.getBoundingClientRect();
46
+ i(t.clientX - n.left);
47
+ },
48
+ [i]
49
+ ), f = a(
50
+ (t) => {
51
+ if (!o || !t.touches.length) return;
52
+ const e = t.touches[0], u = t.currentTarget.getBoundingClientRect();
53
+ i(e.clientX - u.left);
54
+ },
55
+ [o, i]
56
+ ), l = a(
57
+ (t) => {
58
+ if (!t.touches.length) return;
59
+ t.preventDefault();
60
+ const e = t.touches[0], u = t.currentTarget.getBoundingClientRect();
61
+ i(e.clientX - u.left);
62
+ },
63
+ [i]
64
+ ), E = a(
65
+ (t) => {
66
+ if (!o || s <= 0) return;
67
+ const e = s - 1, n = v.current ?? e, u = t.shiftKey ? Math.min(10, Math.max(1, Math.floor(e * 0.1))) : 1;
68
+ let d;
69
+ switch (t.key) {
70
+ case "ArrowLeft":
71
+ t.preventDefault(), d = Math.max(0, n - u);
72
+ break;
73
+ case "ArrowRight":
74
+ t.preventDefault(), d = Math.min(e, n + u);
75
+ break;
76
+ case "Home":
77
+ t.preventDefault(), d = 0;
78
+ break;
79
+ case "End":
80
+ t.preventDefault(), d = e;
81
+ break;
82
+ case "Escape":
83
+ t.preventDefault(), d = void 0;
84
+ break;
85
+ default:
86
+ return;
87
+ }
88
+ c(d);
89
+ },
90
+ [o, s, c]
91
+ ), p = a(() => {
92
+ !o || v.current === void 0 || r();
93
+ }, [o, r]);
94
+ R(() => {
95
+ const t = L.current;
96
+ if (!(!t || !o))
97
+ return t.addEventListener("mousemove", h), t.addEventListener("mouseleave", r), t.addEventListener("touchstart", f, { passive: !1 }), t.addEventListener("touchmove", l, { passive: !1 }), t.addEventListener("touchend", r), t.addEventListener("touchcancel", r), t.addEventListener("keydown", E), t.addEventListener("blur", p), () => {
98
+ t.removeEventListener("mousemove", h), t.removeEventListener("mouseleave", r), t.removeEventListener("touchstart", f), t.removeEventListener("touchmove", l), t.removeEventListener("touchend", r), t.removeEventListener("touchcancel", r), t.removeEventListener("keydown", E), t.removeEventListener("blur", p);
99
+ };
100
+ }, [
101
+ L,
102
+ o,
103
+ h,
104
+ r,
105
+ f,
106
+ l,
107
+ E,
108
+ p
109
+ ]);
110
+ const P = T(
111
+ () => ({
112
+ enableScrubbing: o,
113
+ scrubberPosition: m,
114
+ onScrubberPositionChange: c
115
+ }),
116
+ [o, m, c]
117
+ );
118
+ return /* @__PURE__ */ D(B, { value: P, children: k });
119
+ }
120
+ export {
121
+ N as ScrubberProvider
122
+ };
@@ -0,0 +1,2 @@
1
+ export { ScrubberContextProvider, useScrubberContext } from './scrubberContext';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Scrubber/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ScrubberContextValue } from '../types';
2
+ declare const ScrubberContextProvider: import('react').FC<{
3
+ children: import('react').ReactNode;
4
+ value: ScrubberContextValue;
5
+ }>;
6
+ export declare const useScrubberContext: () => ScrubberContextValue;
7
+ export { ScrubberContextProvider };
8
+ //# sourceMappingURL=scrubberContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrubberContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Scrubber/context/scrubberContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,QAAA,MAAO,uBAAuB;;;EACuB,CAAC;AAEtD,eAAO,MAAM,kBAAkB,QAAO,oBAIlC,CAAC;AAEL,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { createSafeContext as e } from "../../../../libs/utils-shared/dist/index.js";
2
+ const [o, r] = e("Scrubber"), u = () => r({
3
+ consumerName: "useScrubberContext",
4
+ contextRequired: !0
5
+ });
6
+ export {
7
+ o as ScrubberContextProvider,
8
+ u as useScrubberContext
9
+ };
@@ -0,0 +1,4 @@
1
+ export { Scrubber } from './Scrubber';
2
+ export { useScrubberContext } from './context';
3
+ export type { ScrubberProps, ScrubberContextValue } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { ReactNode, RefObject } from 'react';
2
+ export type ScrubberContextValue = {
3
+ /**
4
+ * Whether scrubbing interactions are enabled.
5
+ */
6
+ enableScrubbing: boolean;
7
+ /**
8
+ * The current data index of the scrubber, or undefined when idle.
9
+ */
10
+ scrubberPosition: number | undefined;
11
+ /**
12
+ * Callback to update the scrubber position.
13
+ */
14
+ onScrubberPositionChange: (index: number | undefined) => void;
15
+ };
16
+ export type ScrubberProviderProps = {
17
+ children: ReactNode;
18
+ /**
19
+ * Ref to the root SVG element where event listeners will be attached.
20
+ */
21
+ svgRef: RefObject<SVGSVGElement | null>;
22
+ /**
23
+ * Whether scrubbing is enabled.
24
+ */
25
+ enableScrubbing: boolean;
26
+ /**
27
+ * Optional external callback fired whenever the scrubber position changes.
28
+ */
29
+ onScrubberPositionChange?: (index: number | undefined) => void;
30
+ };
31
+ export type ScrubberProps = {
32
+ /**
33
+ * Formats a label string shown above the reference line for a given data index.
34
+ * When omitted, no label is rendered.
35
+ */
36
+ label?: (dataIndex: number) => string;
37
+ /**
38
+ * Hides the vertical reference line.
39
+ * @default false
40
+ */
41
+ hideLine?: boolean;
42
+ /**
43
+ * Hides the semi-transparent overlay that dims data after the scrubber position.
44
+ * @default false
45
+ */
46
+ hideOverlay?: boolean;
47
+ /**
48
+ * Shows the beacon dots on each series at the scrubbed data index.
49
+ * @default false
50
+ */
51
+ showBeacons?: boolean;
52
+ };
53
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;OAEG;IACH,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACxC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { AxisConfigProps, ChartScaleFunction } from '../../utils/types';
2
+ import { useCartesianChartContext } from '../CartesianChart/context';
3
+ export declare const BEACON_RADIUS = 5;
4
+ export declare const BEACON_STROKE_WIDTH = 2;
5
+ export declare const LABEL_OFFSET_Y = 12;
6
+ export declare const OVERLAY_OFFSET = 2;
7
+ export declare const OVERLAY_LINE_INSET = 0.5;
8
+ export declare const OVERLAY_OPACITY = 0.8;
9
+ export declare const LINE_GRADIENT_EDGE_OPACITY = 0.1;
10
+ /**
11
+ * Converts a pixel position along the x-axis into the nearest data index.
12
+ *
13
+ * For band (categorical) scales, finds the band whose center is closest to
14
+ * `pixelX`. For numeric scales, uses `scale.invert()` and rounds to the
15
+ * nearest integer, clamped to the valid index range.
16
+ */
17
+ export declare const getDataIndexFromPosition: (pixelX: number, scale: ChartScaleFunction, axisConfig: Partial<AxisConfigProps> | undefined, dataLength: number) => number;
18
+ /**
19
+ * Resolves the pixel y-coordinate for a given series data point at a data index.
20
+ * Returns undefined when the value is null/missing or the scale is unavailable.
21
+ */
22
+ export declare const resolvePixelY: (dataIndex: number, seriesData: (number | null)[] | undefined, getYScale: ReturnType<typeof useCartesianChartContext>["getYScale"]) => number | undefined;
23
+ /**
24
+ * Resolves the pixel x-coordinate for a given data index using the x-scale.
25
+ * When numeric x-axis data is provided, the corresponding axis value is used;
26
+ * otherwise the data index is used as the x input.
27
+ * Returns undefined when the scale is unavailable or the value cannot be mapped.
28
+ */
29
+ export declare const resolvePixelX: (dataIndex: number, getXScale: ReturnType<typeof useCartesianChartContext>["getXScale"], axisConfig?: AxisConfigProps) => number | undefined;
30
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1E,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAgC9C;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,QAAQ,MAAM,EACd,OAAO,kBAAkB,EACzB,YAAY,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,EAChD,YAAY,MAAM,KACjB,MA2BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,EACzC,WAAW,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,WAAW,CAAC,KAClE,MAAM,GAAG,SASX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EACjB,WAAW,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,WAAW,CAAC,EACnE,aAAa,eAAe,KAC3B,MAAM,GAAG,SAMX,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { getPointOnScale as d, isNumericScale as u, isCategoricalScale as l } from "../../utils/scales/scales.js";
2
+ const v = 5, _ = 2, m = 12, A = 2, I = 0.5, O = 0.8, h = 0.1, f = (o) => typeof o[0] == "number", a = (o, n, r) => {
3
+ let e = 0, t = 1 / 0;
4
+ for (let i = 0; i < o; i++) {
5
+ const s = r(i);
6
+ if (s === void 0) continue;
7
+ const c = Math.abs(n - s);
8
+ c < t && (t = c, e = i);
9
+ }
10
+ return e;
11
+ }, S = (o, n, r, e) => {
12
+ if (l(n)) {
13
+ const t = n.domain(), i = n.bandwidth();
14
+ return a(t.length, o, (s) => {
15
+ const c = n(t[s]);
16
+ return c === void 0 ? void 0 : c + i / 2;
17
+ });
18
+ }
19
+ if (u(n)) {
20
+ const t = r?.data;
21
+ if (t && t.length > 0 && f(t))
22
+ return a(
23
+ t.length,
24
+ o,
25
+ (s) => n(t[s])
26
+ );
27
+ const i = n.invert(o);
28
+ return Math.max(
29
+ 0,
30
+ Math.min(Math.round(i), e - 1)
31
+ );
32
+ }
33
+ return 0;
34
+ }, x = (o, n, r) => {
35
+ const e = r();
36
+ if (!e || !u(e) || !n) return;
37
+ const t = n[o];
38
+ if (t != null)
39
+ return e(t);
40
+ }, N = (o, n, r) => {
41
+ const e = n();
42
+ if (!e) return;
43
+ const t = r?.data?.[o];
44
+ return d(typeof t == "number" ? t : o, e);
45
+ };
46
+ export {
47
+ v as BEACON_RADIUS,
48
+ _ as BEACON_STROKE_WIDTH,
49
+ m as LABEL_OFFSET_Y,
50
+ h as LINE_GRADIENT_EDGE_OPACITY,
51
+ I as OVERLAY_LINE_INSET,
52
+ A as OVERLAY_OFFSET,
53
+ O as OVERLAY_OPACITY,
54
+ S as getDataIndexFromPosition,
55
+ N as resolvePixelX,
56
+ x as resolvePixelY
57
+ };
@@ -1,3 +1,5 @@
1
+ export * from './ChartTooltip';
1
2
  export * from './LineChart';
2
3
  export * from './Point';
4
+ export * from './Scrubber';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/Components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/Components/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -25,6 +25,11 @@ export declare const isCategoricalScale: (scale: ChartScaleFunction) => scale is
25
25
  * Checks if a scale is a numeric scale.
26
26
  */
27
27
  export declare const isNumericScale: (scale: ChartScaleFunction) => scale is NumericScale;
28
+ /**
29
+ * Converts a single data-space value to pixel-space on a given scale.
30
+ * For band scales the result is centered within the band.
31
+ */
32
+ export declare const getPointOnScale: (value: number, scale: ChartScaleFunction) => number;
28
33
  /**
29
34
  * Projects a single data-space coordinate pair into pixel-space.
30
35
  * Handles centering for categorical (band) scales.
@@ -1 +1 @@
1
- {"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/scales/scales.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAC;AAElB;;;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,YAMH,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,6BAIjC;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAA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