@ledgerhq/lumen-ui-react-visualization 0.1.10 → 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.
- package/dist/index.js +10 -8
- package/dist/lib/Components/ChartTooltip/ChartTooltip.d.ts +23 -0
- package/dist/lib/Components/ChartTooltip/ChartTooltip.d.ts.map +1 -0
- package/dist/lib/Components/ChartTooltip/ChartTooltip.js +81 -0
- package/dist/lib/Components/ChartTooltip/ChartTooltipItem.d.ts +3 -0
- package/dist/lib/Components/ChartTooltip/ChartTooltipItem.d.ts.map +1 -0
- package/dist/lib/Components/ChartTooltip/ChartTooltipItem.js +46 -0
- package/dist/lib/Components/ChartTooltip/constants.d.ts +10 -0
- package/dist/lib/Components/ChartTooltip/constants.d.ts.map +1 -0
- package/dist/lib/Components/ChartTooltip/constants.js +12 -0
- package/dist/lib/Components/ChartTooltip/index.d.ts +3 -0
- package/dist/lib/Components/ChartTooltip/index.d.ts.map +1 -0
- package/dist/lib/Components/ChartTooltip/types.d.ts +61 -0
- package/dist/lib/Components/ChartTooltip/types.d.ts.map +1 -0
- package/dist/lib/Components/index.d.ts +1 -0
- package/dist/lib/Components/index.d.ts.map +1 -1
- package/dist/package.json +2 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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";
|
|
4
|
+
import { Scrubber as i } from "./lib/Components/Scrubber/Scrubber.js";
|
|
5
|
+
import { useScrubberContext as a } from "./lib/Components/Scrubber/context/scrubberContext.js";
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
+
t as ChartTooltip,
|
|
8
|
+
p as LineChart,
|
|
7
9
|
b as Point,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
f as PointLabel,
|
|
11
|
+
i as Scrubber,
|
|
12
|
+
a as useScrubberContext
|
|
11
13
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChartTooltipProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Renders a structured tooltip anchored to the scrubber line.
|
|
4
|
+
*
|
|
5
|
+
* Visible at every scrubber position by default. To limit which positions
|
|
6
|
+
* show a tooltip, return an empty array from `items` for unwanted indices.
|
|
7
|
+
*
|
|
8
|
+
* Must be used as a child of `LineChart` (or `CartesianChart`) with
|
|
9
|
+
* `enableScrubbing` enabled.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <LineChart series={series} enableScrubbing>
|
|
14
|
+
* <Scrubber />
|
|
15
|
+
* <ChartTooltip
|
|
16
|
+
* title={(i) => `${count[i]} Transactions`}
|
|
17
|
+
* items={(i) => [{ label: 'Index', value: i }]}
|
|
18
|
+
* />
|
|
19
|
+
* </LineChart>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function ChartTooltip({ title, items, offset, side, tooltipWidth, }: Readonly<ChartTooltipProps>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=ChartTooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ChartTooltip/ChartTooltip.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAwB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAwBvE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,KAAK,EACL,MAAuB,EACvB,IAAa,EACb,YAAoC,GACrC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAqE7B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as l, jsxs as P } from "react/jsx-runtime";
|
|
2
|
+
import { resolvePixelX as b } from "../Scrubber/utils.js";
|
|
3
|
+
import { ChartTooltipItem as A } from "./ChartTooltipItem.js";
|
|
4
|
+
import { TOOLTIP_TRANSITION as L, BORDER_RADIUS as S, DEFAULT_TOOLTIP_WIDTH as C, PADDING_Y as d, ROW_HEIGHT as o, PADDING_X as R, ROW_GAP as I, DEFAULT_OFFSET as F, TITLE_GAP as G } from "./constants.js";
|
|
5
|
+
import { useScrubberContext as H } from "../Scrubber/context/scrubberContext.js";
|
|
6
|
+
import { useCartesianChartContext as X } from "../CartesianChart/context/cartesianChartContext.js";
|
|
7
|
+
import { cssVar as e } from "../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
8
|
+
const p = /* @__PURE__ */ l(
|
|
9
|
+
"g",
|
|
10
|
+
{
|
|
11
|
+
"data-testid": "chart-tooltip",
|
|
12
|
+
role: "tooltip",
|
|
13
|
+
"aria-hidden": "true",
|
|
14
|
+
style: { opacity: 0, pointerEvents: "none", transition: "none" }
|
|
15
|
+
}
|
|
16
|
+
), w = {
|
|
17
|
+
opacity: 1,
|
|
18
|
+
transition: L,
|
|
19
|
+
pointerEvents: "none"
|
|
20
|
+
}, N = {
|
|
21
|
+
fontSize: e("var(--font-style-body-4-size)"),
|
|
22
|
+
fontFamily: e("var(--font-family-font)"),
|
|
23
|
+
fill: e("var(--text-base)"),
|
|
24
|
+
fontWeight: e("var(--font-style-body-4-weight-medium)")
|
|
25
|
+
};
|
|
26
|
+
function V({
|
|
27
|
+
title: s,
|
|
28
|
+
items: g,
|
|
29
|
+
offset: c = F,
|
|
30
|
+
side: f = "auto",
|
|
31
|
+
tooltipWidth: i = C
|
|
32
|
+
}) {
|
|
33
|
+
const { scrubberPosition: n } = H(), { getXScale: v, getXAxisConfig: O, drawingArea: t } = X();
|
|
34
|
+
if (n === void 0) return p;
|
|
35
|
+
const r = b(n, v, O());
|
|
36
|
+
if (r === void 0) return p;
|
|
37
|
+
const a = g(n);
|
|
38
|
+
if (a.length === 0) return p;
|
|
39
|
+
const m = typeof s == "function" ? s(n) : s, h = m != null, _ = f === "left" || f === "auto" && r + c + i > t.x + t.width, T = Math.max(
|
|
40
|
+
t.x,
|
|
41
|
+
_ ? r - c - i : r + c
|
|
42
|
+
), u = h ? o + G : 0, E = d * 2 + u + a.length * o + (a.length - 1) * I, D = t.y + d + u;
|
|
43
|
+
return /* @__PURE__ */ P("g", { "data-testid": "chart-tooltip", role: "tooltip", style: w, children: [
|
|
44
|
+
/* @__PURE__ */ l(
|
|
45
|
+
"rect",
|
|
46
|
+
{
|
|
47
|
+
x: T,
|
|
48
|
+
y: t.y,
|
|
49
|
+
width: i,
|
|
50
|
+
height: E,
|
|
51
|
+
rx: S,
|
|
52
|
+
fill: e("var(--background-muted)")
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
h && /* @__PURE__ */ l(
|
|
56
|
+
"text",
|
|
57
|
+
{
|
|
58
|
+
"data-testid": "chart-tooltip-title",
|
|
59
|
+
x: T + R,
|
|
60
|
+
y: t.y + d + o / 2,
|
|
61
|
+
dominantBaseline: "middle",
|
|
62
|
+
style: N,
|
|
63
|
+
children: m
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
a.map((y, x) => /* @__PURE__ */ l(
|
|
67
|
+
A,
|
|
68
|
+
{
|
|
69
|
+
label: y.label,
|
|
70
|
+
value: y.value,
|
|
71
|
+
x: T,
|
|
72
|
+
y: D + x * (o + I) + o / 2,
|
|
73
|
+
width: i
|
|
74
|
+
},
|
|
75
|
+
x
|
|
76
|
+
))
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
V as ChartTooltip
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartTooltipItem.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ChartTooltip/ChartTooltipItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,KAAK,EACL,CAAK,EACL,CAAK,EACL,KAAK,GACN,EAAE,QAAQ,CAAC,qBAAqB,CAAC,2CA+BjC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsxs as a, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { PADDING_X as n } from "./constants.js";
|
|
3
|
+
import { cssVar as t } from "../../../libs/design-core/dist/lib/cssVar/cssVar.js";
|
|
4
|
+
function y({
|
|
5
|
+
label: r,
|
|
6
|
+
value: l,
|
|
7
|
+
x: e = 0,
|
|
8
|
+
y: o = 0,
|
|
9
|
+
width: f
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ a("g", { children: [
|
|
12
|
+
/* @__PURE__ */ i(
|
|
13
|
+
"text",
|
|
14
|
+
{
|
|
15
|
+
x: e + n,
|
|
16
|
+
y: o,
|
|
17
|
+
dominantBaseline: "middle",
|
|
18
|
+
style: {
|
|
19
|
+
fontSize: t("var(--font-style-body-4-size)"),
|
|
20
|
+
fontFamily: t("var(--font-family-font)"),
|
|
21
|
+
fill: t("var(--text-muted)")
|
|
22
|
+
},
|
|
23
|
+
children: r
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ i(
|
|
27
|
+
"text",
|
|
28
|
+
{
|
|
29
|
+
x: e + f - n,
|
|
30
|
+
y: o,
|
|
31
|
+
dominantBaseline: "middle",
|
|
32
|
+
textAnchor: "end",
|
|
33
|
+
style: {
|
|
34
|
+
fontSize: t("var(--font-style-body-4-size)"),
|
|
35
|
+
fontFamily: t("var(--font-family-font)"),
|
|
36
|
+
fill: t("var(--text-base)"),
|
|
37
|
+
fontWeight: t("var(--font-style-body-4-weight-medium)")
|
|
38
|
+
},
|
|
39
|
+
children: l
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
y as ChartTooltipItem
|
|
46
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const DEFAULT_OFFSET = 10;
|
|
2
|
+
export declare const DEFAULT_TOOLTIP_WIDTH = 120;
|
|
3
|
+
export declare const PADDING_X = 8;
|
|
4
|
+
export declare const PADDING_Y = 8;
|
|
5
|
+
export declare const ROW_HEIGHT = 16;
|
|
6
|
+
export declare const ROW_GAP = 6;
|
|
7
|
+
export declare const TITLE_GAP = 6;
|
|
8
|
+
export declare const BORDER_RADIUS = 4;
|
|
9
|
+
export declare const TOOLTIP_TRANSITION = "opacity 0.15s ease-out 0.05s";
|
|
10
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ChartTooltip/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,OAAO,IAAI,CAAC;AACzB,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,kBAAkB,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const T = 10, o = 120, s = 8, t = 8, c = 16, I = 6, _ = 6, n = 4, D = "opacity 0.15s ease-out 0.05s";
|
|
2
|
+
export {
|
|
3
|
+
n as BORDER_RADIUS,
|
|
4
|
+
T as DEFAULT_OFFSET,
|
|
5
|
+
o as DEFAULT_TOOLTIP_WIDTH,
|
|
6
|
+
s as PADDING_X,
|
|
7
|
+
t as PADDING_Y,
|
|
8
|
+
I as ROW_GAP,
|
|
9
|
+
c as ROW_HEIGHT,
|
|
10
|
+
_ as TITLE_GAP,
|
|
11
|
+
D as TOOLTIP_TRANSITION
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ChartTooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ReactElement, SVGProps } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Valid content for an SVG `<text>` element: a plain string,
|
|
4
|
+
* a number, or a `<tspan>` element.
|
|
5
|
+
*/
|
|
6
|
+
export type SvgTextContent = string | number | ReactElement<SVGProps<SVGTSpanElement>, 'tspan'>;
|
|
7
|
+
export type ChartTooltipItemData = {
|
|
8
|
+
/** Label displayed on the left side of the row. */
|
|
9
|
+
label: SvgTextContent;
|
|
10
|
+
/** Value displayed on the right side of the row. */
|
|
11
|
+
value: SvgTextContent;
|
|
12
|
+
};
|
|
13
|
+
export type ChartTooltipItemProps = ChartTooltipItemData & {
|
|
14
|
+
/**
|
|
15
|
+
* X position in SVG coordinate space.
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
x?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Y midline position in SVG coordinate space.
|
|
21
|
+
* @default 0
|
|
22
|
+
*/
|
|
23
|
+
y?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Width allocated to this row, used to right-align the value text.
|
|
26
|
+
*/
|
|
27
|
+
width: number;
|
|
28
|
+
};
|
|
29
|
+
export type ChartTooltipProps = {
|
|
30
|
+
/**
|
|
31
|
+
* Optional header rendered at the top of the tooltip card.
|
|
32
|
+
* Accepts a static value or a callback receiving the active data index.
|
|
33
|
+
* A callback may return `null` or `undefined` to suppress the title for a
|
|
34
|
+
* specific data index without unmounting the tooltip.
|
|
35
|
+
*/
|
|
36
|
+
title?: SvgTextContent | ((index: number) => SvgTextContent | null | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* Produces tooltip rows from the active data index.
|
|
39
|
+
* Each returned item is rendered as a `<ChartTooltipItem>`.
|
|
40
|
+
* Return an empty array to suppress the tooltip at a given index.
|
|
41
|
+
*/
|
|
42
|
+
items: (index: number) => ChartTooltipItemData[];
|
|
43
|
+
/**
|
|
44
|
+
* Horizontal gap in pixels between the scrubber line and the tooltip box.
|
|
45
|
+
* @default 10
|
|
46
|
+
*/
|
|
47
|
+
offset?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Which side of the scrubber line the tooltip appears on.
|
|
50
|
+
* `'auto'` flips to the left when the right side would overflow.
|
|
51
|
+
* @default 'auto'
|
|
52
|
+
*/
|
|
53
|
+
side?: 'auto' | 'left' | 'right';
|
|
54
|
+
/**
|
|
55
|
+
* Fixed width of the tooltip box in pixels.
|
|
56
|
+
* Used for flip-side detection and for right-aligning value text.
|
|
57
|
+
* @default 120
|
|
58
|
+
*/
|
|
59
|
+
tooltipWidth?: number;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ChartTooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,MAAM,GACN,YAAY,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IACjC,mDAAmD;IACnD,KAAK,EAAE,cAAc,CAAC;IACtB,oDAAoD;IACpD,KAAK,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG;IACzD;;;OAGG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;OAKG;IACH,KAAK,CAAC,EACF,cAAc,GACd,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAC3D;;;;OAIG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,oBAAoB,EAAE,CAAC;IACjD;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -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;AACxB,cAAc,YAAY,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"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-react-visualization",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@ledgerhq/lumen-design-core": "0.1.13",
|
|
37
|
-
"@ledgerhq/lumen-ui-react": "0.1.
|
|
37
|
+
"@ledgerhq/lumen-ui-react": "0.1.31",
|
|
38
38
|
"class-variance-authority": "^0.7.1",
|
|
39
39
|
"clsx": "^2.1.1",
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-react-visualization",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"keywords": [
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@ledgerhq/lumen-design-core": "0.1.
|
|
37
|
-
"@ledgerhq/lumen-ui-react": "0.1.
|
|
36
|
+
"@ledgerhq/lumen-design-core": "0.1.14",
|
|
37
|
+
"@ledgerhq/lumen-ui-react": "0.1.32",
|
|
38
38
|
"class-variance-authority": "^0.7.1",
|
|
39
39
|
"clsx": "^2.1.1",
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|