@validationcloud/fractal-ui 1.77.0 → 1.78.0
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/README.md +22 -0
- package/dist/charts.d.ts +2 -0
- package/dist/charts.js +29 -20
- package/dist/components/dropdown-menu/dropdown-menu.js +34 -26
- package/dist/components/echarts-renderer/geo/africa-countries.json.d.ts +2463 -0
- package/dist/components/echarts-renderer/geo/africa-countries.json.js +9 -0
- package/dist/components/echarts-renderer/geo/americas-countries.json.d.ts +4160 -0
- package/dist/components/echarts-renderer/geo/americas-countries.json.js +9 -0
- package/dist/components/echarts-renderer/geo/asia-countries.json.d.ts +4275 -0
- package/dist/components/echarts-renderer/geo/asia-countries.json.js +9 -0
- package/dist/components/echarts-renderer/geo/europe-countries.json.d.ts +2407 -0
- package/dist/components/echarts-renderer/geo/europe-countries.json.js +9 -0
- package/dist/components/echarts-renderer/geo/us-states.json.d.ts +1338 -0
- package/dist/components/echarts-renderer/geo/us-states.json.js +9 -0
- package/dist/components/echarts-renderer/geo/world-continents.json.d.ts +10639 -0
- package/dist/components/echarts-renderer/geo/world-continents.json.js +9 -0
- package/dist/components/echarts-renderer/geo/world-countries.json.d.ts +14549 -0
- package/dist/components/echarts-renderer/geo/world-countries.json.js +9 -0
- package/dist/components/echarts-renderer/geo/world-regions.json.d.ts +10621 -0
- package/dist/components/echarts-renderer/geo/world-regions.json.js +9 -0
- package/dist/components/echarts-renderer/map-centers.d.ts +2 -0
- package/dist/components/echarts-renderer/map-centers.js +13 -0
- package/dist/components/echarts-renderer/map-style.d.ts +12 -0
- package/dist/components/echarts-renderer/map-style.js +12 -0
- package/dist/components/echarts-renderer/natural-earth-projection.d.ts +29 -0
- package/dist/components/echarts-renderer/natural-earth-projection.js +64 -0
- package/dist/components/echarts-renderer/register-map.d.ts +24 -0
- package/dist/components/echarts-renderer/register-map.js +62 -0
- package/dist/components/echarts-renderer/use-chart-instance.js +38 -36
- package/dist/hooks/use-scroll-to-bottom.d.ts +4 -3
- package/dist/lib/render-chart-to-image.js +72 -43
- package/dist/maps.json +438 -0
- package/package.json +19 -4
|
@@ -1,56 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as f, useState as T, useEffect as I, useCallback as S } from "react";
|
|
3
3
|
import { calculateTitleLayout as m } from "./calculate-title-layout.js";
|
|
4
4
|
import { replaceFormatterTokens as O } from "./formatters/replace-formatter-tokens.js";
|
|
5
5
|
import { mergeThemeGraphicIntoOptions as R } from "./merge-theme-graphic-into-options.js";
|
|
6
|
+
import { getRequiredMapName as j, registerMapAsync as x } from "./register-map.js";
|
|
6
7
|
import { sanitizeChartOptions as w } from "./sanitize-chart-options.js";
|
|
7
8
|
const W = /* @__PURE__ */ new Set();
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
y.current =
|
|
11
|
-
const s =
|
|
9
|
+
function B({ options: i, theme: t }) {
|
|
10
|
+
const e = f(null), o = f(null), y = f(i), C = f(t?.config), z = f(t?.config.graphic), [b, v] = T(!1);
|
|
11
|
+
y.current = i, C.current = t?.config, z.current = t?.config.graphic, I(() => {
|
|
12
|
+
const s = e.current;
|
|
12
13
|
if (!s) return;
|
|
13
|
-
let r = !0,
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
const p =
|
|
18
|
-
|
|
14
|
+
let r = !0, n;
|
|
15
|
+
const d = new ResizeObserver((c) => {
|
|
16
|
+
const u = c[0], a = o.current;
|
|
17
|
+
if (!u || !a) return;
|
|
18
|
+
const p = u.contentRect.width, g = w(y.current), l = O(g), h = m(l, p, C.current);
|
|
19
|
+
a.setOption(R(h, z.current), {
|
|
19
20
|
replaceMerge: ["graphic"]
|
|
20
|
-
}),
|
|
21
|
+
}), a.resize();
|
|
21
22
|
});
|
|
22
|
-
return
|
|
23
|
+
return d.observe(s), (async () => {
|
|
23
24
|
try {
|
|
24
|
-
const
|
|
25
|
-
if (!r || !
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const c = await import("echarts");
|
|
26
|
+
if (!r || !e.current) return;
|
|
27
|
+
const u = j(i);
|
|
28
|
+
if (u && await x(c, u), t && !W.has(t.name)) {
|
|
29
|
+
const { graphic: F, ...M } = t.config;
|
|
30
|
+
c.registerTheme(t.name, M), W.add(t.name);
|
|
29
31
|
}
|
|
30
|
-
const a =
|
|
31
|
-
a && a.dispose(),
|
|
32
|
+
const a = c.getInstanceByDom(e.current);
|
|
33
|
+
a && a.dispose(), n = c.init(e.current, t?.name, {
|
|
32
34
|
renderer: "svg"
|
|
33
|
-
}),
|
|
34
|
-
const
|
|
35
|
-
|
|
35
|
+
}), o.current = n;
|
|
36
|
+
const p = e.current.clientWidth, g = w(i), l = O(g), h = m(l, p, t?.config);
|
|
37
|
+
n.setOption(R(h, t?.config.graphic), {
|
|
36
38
|
replaceMerge: ["graphic"]
|
|
37
|
-
}),
|
|
38
|
-
} catch (
|
|
39
|
-
console.error("Failed to load echarts",
|
|
39
|
+
}), n.resize(), v(!0);
|
|
40
|
+
} catch (c) {
|
|
41
|
+
console.error("Failed to load echarts", c);
|
|
40
42
|
}
|
|
41
43
|
})(), () => {
|
|
42
|
-
r = !1,
|
|
44
|
+
r = !1, d.disconnect(), n && n.dispose(), o.current = null, v(!1);
|
|
43
45
|
};
|
|
44
|
-
}, [t,
|
|
45
|
-
if (!b || !
|
|
46
|
-
const s =
|
|
47
|
-
|
|
46
|
+
}, [t, i]), I(() => {
|
|
47
|
+
if (!b || !o.current || !e.current) return;
|
|
48
|
+
const s = e.current.clientWidth, r = w(i), n = O(r), d = m(n, s, t?.config);
|
|
49
|
+
o.current.setOption(R(d, t?.config.graphic), {
|
|
48
50
|
replaceMerge: ["graphic"]
|
|
49
51
|
});
|
|
50
|
-
}, [b,
|
|
52
|
+
}, [b, i, t?.config, t?.config.graphic]);
|
|
51
53
|
const k = S(async () => {
|
|
52
|
-
if (!
|
|
53
|
-
const s =
|
|
54
|
+
if (!o.current) return;
|
|
55
|
+
const s = o.current.getDataURL({
|
|
54
56
|
type: "png",
|
|
55
57
|
pixelRatio: 2,
|
|
56
58
|
backgroundColor: "#fff"
|
|
@@ -58,10 +60,10 @@ function L({ options: o, theme: t }) {
|
|
|
58
60
|
r.download = `chart-${(/* @__PURE__ */ new Date()).toISOString()}.png`, r.href = s, document.body.appendChild(r), r.click(), document.body.removeChild(r);
|
|
59
61
|
}, []);
|
|
60
62
|
return {
|
|
61
|
-
containerRef:
|
|
63
|
+
containerRef: e,
|
|
62
64
|
downloadChart: k
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
export {
|
|
66
|
-
|
|
68
|
+
B as useChartInstance
|
|
67
69
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
type UseScrollToBottomOptions = {
|
|
2
2
|
readonly threshold?: number;
|
|
3
3
|
};
|
|
4
|
-
|
|
5
|
-
containerRef:
|
|
6
|
-
endRef:
|
|
4
|
+
type UseScrollToBottomReturn = {
|
|
5
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
6
|
+
endRef: React.RefObject<HTMLDivElement | null>;
|
|
7
7
|
isAtBottom: boolean;
|
|
8
8
|
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
9
9
|
onViewportEnter: () => void;
|
|
10
10
|
onViewportLeave: () => void;
|
|
11
11
|
};
|
|
12
|
+
export declare function useScrollToBottom({ threshold }?: UseScrollToBottomOptions): UseScrollToBottomReturn;
|
|
12
13
|
export {};
|
|
@@ -1,33 +1,51 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import * as d from "echarts";
|
|
2
|
+
import { writeFileSync as w, mkdtempSync as N } from "node:fs";
|
|
3
|
+
import { tmpdir as T } from "node:os";
|
|
4
|
+
import y from "node:path";
|
|
5
|
+
import { Image as C, Canvas as S, FontLibrary as G } from "skia-canvas";
|
|
6
|
+
import { calculateTitleLayout as F } from "../components/echarts-renderer/calculate-title-layout.js";
|
|
7
|
+
import { isChartTheme as b } from "../components/echarts-renderer/chart-theme.js";
|
|
8
|
+
import { replaceFormatterTokens as J } from "../components/echarts-renderer/formatters/replace-formatter-tokens.js";
|
|
9
|
+
import A from "../components/echarts-renderer/geo/africa-countries.json.js";
|
|
10
|
+
import I from "../components/echarts-renderer/geo/americas-countries.json.js";
|
|
11
|
+
import j from "../components/echarts-renderer/geo/asia-countries.json.js";
|
|
12
|
+
import E from "../components/echarts-renderer/geo/europe-countries.json.js";
|
|
13
|
+
import M from "../components/echarts-renderer/geo/us-states.json.js";
|
|
14
|
+
import R from "../components/echarts-renderer/geo/world-continents.json.js";
|
|
15
|
+
import P from "../components/echarts-renderer/geo/world-countries.json.js";
|
|
16
|
+
import k from "../components/echarts-renderer/geo/world-regions.json.js";
|
|
17
|
+
import { mergeThemeGraphicIntoOptions as v } from "../components/echarts-renderer/merge-theme-graphic-into-options.js";
|
|
18
|
+
import { getRequiredMapName as x, isMapName as D, registerMapSync as _ } from "../components/echarts-renderer/register-map.js";
|
|
19
|
+
const $ = {
|
|
20
|
+
"world-countries": P,
|
|
21
|
+
"world-continents": R,
|
|
22
|
+
"world-regions": k,
|
|
23
|
+
"us-states": M,
|
|
24
|
+
"europe-countries": E,
|
|
25
|
+
"americas-countries": I,
|
|
26
|
+
"asia-countries": j,
|
|
27
|
+
"africa-countries": A
|
|
28
|
+
};
|
|
29
|
+
globalThis.Image = C;
|
|
30
|
+
const g = /* @__PURE__ */ new Set();
|
|
31
|
+
let f;
|
|
32
|
+
function z() {
|
|
33
|
+
return f || (f = N(y.join(T(), "chart-fonts-"))), f;
|
|
16
34
|
}
|
|
17
|
-
function
|
|
35
|
+
function L(r) {
|
|
18
36
|
for (const t of r)
|
|
19
|
-
if (!
|
|
37
|
+
if (!g.has(t.family))
|
|
20
38
|
try {
|
|
21
|
-
const e =
|
|
22
|
-
const
|
|
23
|
-
return
|
|
39
|
+
const e = z(), o = t.data.map((a, m) => {
|
|
40
|
+
const n = y.join(e, `${t.family}-${String(m)}.ttf`);
|
|
41
|
+
return w(n, a), n;
|
|
24
42
|
});
|
|
25
|
-
|
|
43
|
+
G.use(t.family, o), g.add(t.family);
|
|
26
44
|
} catch (e) {
|
|
27
45
|
console.warn(`Failed to register ${t.family} fonts, charts will use fallback font:`, e);
|
|
28
46
|
}
|
|
29
47
|
}
|
|
30
|
-
const
|
|
48
|
+
const V = /* @__PURE__ */ new Set([
|
|
31
49
|
"aria",
|
|
32
50
|
// Tries to set DOM attributes which node-canvas doesn't implement
|
|
33
51
|
"toolbox",
|
|
@@ -39,41 +57,52 @@ const P = /* @__PURE__ */ new Set([
|
|
|
39
57
|
"axisPointer"
|
|
40
58
|
// Crosshair on hover
|
|
41
59
|
]);
|
|
42
|
-
function
|
|
60
|
+
function q(r) {
|
|
43
61
|
if (!r || typeof r != "object" || Array.isArray(r))
|
|
44
62
|
return { animation: !1 };
|
|
45
63
|
const t = Object.fromEntries(
|
|
46
|
-
Object.entries(r).filter(([e]) => !
|
|
64
|
+
Object.entries(r).filter(([e]) => !V.has(e))
|
|
47
65
|
);
|
|
48
66
|
return t.animation = !1, t;
|
|
49
67
|
}
|
|
50
|
-
function
|
|
68
|
+
function B(r) {
|
|
69
|
+
const t = new S(r.width, r.height);
|
|
70
|
+
return t.getContext("2d").drawImage(r, 0, 0), t;
|
|
71
|
+
}
|
|
72
|
+
function U({
|
|
51
73
|
option: r,
|
|
52
74
|
theme: t,
|
|
53
75
|
fonts: e,
|
|
54
|
-
width:
|
|
55
|
-
height:
|
|
56
|
-
devicePixelRatio:
|
|
76
|
+
width: o = 800,
|
|
77
|
+
height: a = 600,
|
|
78
|
+
devicePixelRatio: m = 2
|
|
57
79
|
}) {
|
|
58
|
-
e?.length &&
|
|
59
|
-
let
|
|
80
|
+
e?.length && L(e);
|
|
81
|
+
let n, s, p;
|
|
60
82
|
if (t) {
|
|
61
|
-
|
|
62
|
-
const { graphic:
|
|
63
|
-
|
|
83
|
+
s = b(t) ? t.config : t, p = s.graphic;
|
|
84
|
+
const { graphic: h, ...c } = s;
|
|
85
|
+
n = c;
|
|
64
86
|
}
|
|
65
|
-
const
|
|
87
|
+
const i = x(r);
|
|
88
|
+
i && (D(i) ? _(d, i, $[i]) : console.warn(`Unknown map name for server-side rendering: "${i}"`));
|
|
89
|
+
const l = new S(o, a), u = d.init(l, n, {
|
|
66
90
|
renderer: "canvas",
|
|
67
|
-
devicePixelRatio:
|
|
68
|
-
width:
|
|
69
|
-
height:
|
|
70
|
-
})
|
|
71
|
-
|
|
91
|
+
devicePixelRatio: m,
|
|
92
|
+
width: o,
|
|
93
|
+
height: a
|
|
94
|
+
});
|
|
95
|
+
try {
|
|
96
|
+
const h = q(r), c = J(h), O = F(c, o, s);
|
|
97
|
+
return u.setOption(v(O, p), { replaceMerge: ["graphic"] }), B(l);
|
|
98
|
+
} finally {
|
|
99
|
+
u.dispose();
|
|
100
|
+
}
|
|
72
101
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
102
|
+
function ft(r) {
|
|
103
|
+
return U(r).toBufferSync("png");
|
|
75
104
|
}
|
|
76
105
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
U as renderChartToCanvas,
|
|
107
|
+
ft as renderChartToImage
|
|
79
108
|
};
|