@validationcloud/fractal-ui 1.57.0 → 1.59.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/dist/charts.d.ts +2 -2
- package/dist/charts.js +18 -22
- package/dist/components/echarts-renderer/chart-theme.d.ts +6 -0
- package/dist/components/echarts-renderer/chart-theme.js +8 -0
- package/dist/components/echarts-renderer/echarts-renderer.d.ts +3 -8
- package/dist/components/echarts-renderer/echarts-theme-option.d.ts +4 -4
- package/dist/components/echarts-renderer/mavrik-theme-horizontal.json.d.ts +13 -0
- package/dist/components/echarts-renderer/mavrik-theme-horizontal.json.js +34 -32
- package/dist/components/echarts-renderer/mavrik-theme.d.ts +4 -493
- package/dist/components/echarts-renderer/mavrik-theme.js +12 -19
- package/dist/components/echarts-renderer/mavrik-theme.json.d.ts +13 -0
- package/dist/components/echarts-renderer/mavrik-theme.json.js +34 -32
- package/dist/components/echarts-renderer/merge-theme-graphic-into-options.d.ts +9 -0
- package/dist/components/echarts-renderer/merge-theme-graphic-into-options.js +10 -0
- package/dist/components/echarts-renderer/use-chart-instance.d.ts +2 -5
- package/dist/components/echarts-renderer/use-chart-instance.js +46 -43
- package/dist/lib/font-data.d.ts +17 -0
- package/dist/lib/font-data.js +19 -0
- package/dist/lib/render-chart-to-image.d.ts +14 -7
- package/dist/lib/render-chart-to-image.js +57 -55
- package/dist/lib/render-mavrik-chart-to-image.d.ts +1 -2
- package/dist/lib/render-mavrik-chart-to-image.js +19 -15
- package/dist/lib/render-mavrik-chart-to-image.test.d.ts +1 -0
- package/package.json +4 -3
- package/dist/assets/vc-logo.svg.js +0 -4
- package/dist/components/echarts-renderer/echarts-theme-option.js +0 -9
- package/dist/components/echarts-renderer/watermark-graphic.d.ts +0 -12
- package/dist/components/echarts-renderer/watermark-graphic.js +0 -25
- package/dist/fonts/Poppins-Bold.ttf +0 -0
- package/dist/fonts/Poppins-Medium.ttf +0 -0
- package/dist/fonts/Poppins-Regular.ttf +0 -0
- package/dist/fonts/Poppins-SemiBold.ttf +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function g(r, a) {
|
|
2
|
+
const c = r.graphic === void 0 ? [] : Array.isArray(r.graphic) ? r.graphic : [r.graphic], i = a === void 0 ? [] : Array.isArray(a) ? a : [a];
|
|
3
|
+
return {
|
|
4
|
+
...r,
|
|
5
|
+
graphic: [...c, ...i]
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
g as mergeThemeGraphicIntoOptions
|
|
10
|
+
};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { EChartsOption } from 'echarts';
|
|
2
|
-
import {
|
|
2
|
+
import { ChartTheme } from './chart-theme';
|
|
3
3
|
export type UseChartInstanceProps = {
|
|
4
4
|
options: EChartsOption;
|
|
5
|
-
theme?:
|
|
6
|
-
name: string;
|
|
7
|
-
config: EChartsThemeOption;
|
|
8
|
-
};
|
|
5
|
+
theme?: ChartTheme;
|
|
9
6
|
};
|
|
10
7
|
export type UseChartInstanceReturn = {
|
|
11
8
|
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
@@ -1,63 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as d, useState as
|
|
3
|
-
import { calculateTitleLayout as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const s =
|
|
2
|
+
import { useRef as d, useState as k, useEffect as b, useCallback as S } from "react";
|
|
3
|
+
import { calculateTitleLayout as l } from "./calculate-title-layout.js";
|
|
4
|
+
import { mergeThemeGraphicIntoOptions as h } from "./merge-theme-graphic-into-options.js";
|
|
5
|
+
import { sanitizeChartOptions as O } from "./sanitize-chart-options.js";
|
|
6
|
+
const v = /* @__PURE__ */ new Set();
|
|
7
|
+
function M({ options: o, theme: n }) {
|
|
8
|
+
const r = d(null), c = d(null), R = d(o), y = d(n?.config), m = d(n?.config.graphic), [C, w] = k(!1);
|
|
9
|
+
R.current = o, y.current = n?.config, m.current = n?.config.graphic, b(() => {
|
|
10
|
+
const s = r.current;
|
|
11
11
|
if (!s) return;
|
|
12
|
-
let
|
|
13
|
-
const
|
|
14
|
-
const a =
|
|
12
|
+
let t = !0, e;
|
|
13
|
+
const z = new ResizeObserver((i) => {
|
|
14
|
+
const a = i[0], u = c.current;
|
|
15
15
|
if (!a || !u) return;
|
|
16
|
-
const f = a.contentRect.width,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const f = a.contentRect.width, g = O(R.current), p = l(g, f, y.current);
|
|
17
|
+
u.setOption(h(p, m.current), {
|
|
18
|
+
replaceMerge: ["graphic"]
|
|
19
|
+
}), u.resize();
|
|
20
20
|
});
|
|
21
|
-
return
|
|
21
|
+
return z.observe(s), (async () => {
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const i = await import("echarts");
|
|
24
|
+
if (!t || !r.current) return;
|
|
25
|
+
if (n && !v.has(n.name)) {
|
|
26
|
+
const { graphic: p, ...W } = n.config;
|
|
27
|
+
i.registerTheme(n.name, W), v.add(n.name);
|
|
28
|
+
}
|
|
29
|
+
const a = i.getInstanceByDom(r.current);
|
|
30
|
+
a && a.dispose(), e = i.init(r.current, n?.name, {
|
|
28
31
|
renderer: "svg"
|
|
29
|
-
}), c.current =
|
|
30
|
-
const u =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} catch (
|
|
35
|
-
console.error("Failed to load echarts",
|
|
32
|
+
}), c.current = e;
|
|
33
|
+
const u = r.current.clientWidth, f = O(o), g = l(f, u, n?.config);
|
|
34
|
+
e.setOption(h(g, n?.config.graphic), {
|
|
35
|
+
replaceMerge: ["graphic"]
|
|
36
|
+
}), e.resize(), w(!0);
|
|
37
|
+
} catch (i) {
|
|
38
|
+
console.error("Failed to load echarts", i);
|
|
36
39
|
}
|
|
37
40
|
})(), () => {
|
|
38
|
-
|
|
41
|
+
t = !1, z.disconnect(), e && e.dispose(), c.current = null, w(!1);
|
|
39
42
|
};
|
|
40
|
-
}, [
|
|
41
|
-
if (!
|
|
42
|
-
const s =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
const
|
|
43
|
+
}, [n, o]), b(() => {
|
|
44
|
+
if (!C || !c.current || !r.current) return;
|
|
45
|
+
const s = r.current.clientWidth, t = O(o), e = l(t, s, n?.config);
|
|
46
|
+
c.current.setOption(h(e, n?.config.graphic), {
|
|
47
|
+
replaceMerge: ["graphic"]
|
|
48
|
+
});
|
|
49
|
+
}, [C, o, n?.config, n?.config.graphic]);
|
|
50
|
+
const I = S(async () => {
|
|
48
51
|
if (!c.current) return;
|
|
49
52
|
const s = c.current.getDataURL({
|
|
50
53
|
type: "png",
|
|
51
54
|
pixelRatio: 2,
|
|
52
55
|
backgroundColor: "#fff"
|
|
53
|
-
}),
|
|
54
|
-
|
|
56
|
+
}), t = document.createElement("a");
|
|
57
|
+
t.download = `chart-${(/* @__PURE__ */ new Date()).toISOString()}.png`, t.href = s, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
55
58
|
}, []);
|
|
56
59
|
return {
|
|
57
|
-
containerRef:
|
|
58
|
-
downloadChart:
|
|
60
|
+
containerRef: r,
|
|
61
|
+
downloadChart: I
|
|
59
62
|
};
|
|
60
63
|
}
|
|
61
64
|
export {
|
|
62
|
-
|
|
65
|
+
M as useChartInstance
|
|
63
66
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Poppins font files embedded as base64 buffers.
|
|
3
|
+
*
|
|
4
|
+
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
5
|
+
* Run `pnpm generate:fonts` to regenerate.
|
|
6
|
+
*
|
|
7
|
+
* These embedded fonts ensure server-side chart rendering works in serverless
|
|
8
|
+
* environments (Vercel, AWS Lambda) where file system paths are not available.
|
|
9
|
+
*/
|
|
10
|
+
/** Poppins-Regular.ttf embedded as base64 buffer */
|
|
11
|
+
export declare const PoppinsRegular: Buffer<ArrayBuffer>;
|
|
12
|
+
/** Poppins-Medium.ttf embedded as base64 buffer */
|
|
13
|
+
export declare const PoppinsMedium: Buffer<ArrayBuffer>;
|
|
14
|
+
/** Poppins-SemiBold.ttf embedded as base64 buffer */
|
|
15
|
+
export declare const PoppinsSemiBold: Buffer<ArrayBuffer>;
|
|
16
|
+
/** Poppins-Bold.ttf embedded as base64 buffer */
|
|
17
|
+
export declare const PoppinsBold: Buffer<ArrayBuffer>;
|