vue-data-ui 3.3.0 → 3.3.2
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/{Arrow-CKLBHe3L.js → Arrow-DLi6NnGD.js} +1 -1
- package/dist/{BaseDraggableDialog-q3pgSDTz.js → BaseDraggableDialog-CVGErydD.js} +2 -2
- package/dist/{BaseIcon-CtqN7W_g.js → BaseIcon-eZbszQrv.js} +1 -1
- package/dist/{ColorPicker-Cr6rUDTP.js → ColorPicker-BoPM4Ejg.js} +2 -2
- package/dist/{DataTable-BeI6gYJX.js → DataTable-yAMEyP6y.js} +2 -2
- package/dist/{Legend-DsogCeTb.js → Legend-By4rru90.js} +2 -2
- package/dist/{NonSvgPenAndPaper-BDK_ucTG.js → NonSvgPenAndPaper-C7QqIewT.js} +3 -3
- package/dist/{PackageVersion-C9oklnuy.js → PackageVersion-r-Q1R3nV.js} +1 -1
- package/dist/{PenAndPaper-BxbYiPy4.js → PenAndPaper-Bo-lMUik.js} +3 -3
- package/dist/{Shape-DJG2zW7b.js → Shape-BceHSLHf.js} +1 -1
- package/dist/{Slicer-D6T4aUhr.js → Slicer-Znzt0gSE.js} +2 -2
- package/dist/{SparkTooltip-Cp0G9giW.js → SparkTooltip--YwqrrgZ.js} +1 -1
- package/dist/{Title-D17CJXko.js → Title-Camz1Lce.js} +1 -1
- package/dist/{Tooltip-CtVdvbZi.js → Tooltip-VOcQEHa4.js} +1 -1
- package/dist/{UserOptions-B3vCIe-u.js → UserOptions-CSja1SGU.js} +2 -2
- package/dist/components/arrow.js +1 -1
- package/dist/components/vue-ui-3d-bar.js +1 -1
- package/dist/components/vue-ui-accordion.js +1 -1
- package/dist/components/vue-ui-age-pyramid.js +1 -1
- package/dist/components/vue-ui-annotator.js +1 -1
- package/dist/components/vue-ui-bullet.js +1 -1
- package/dist/components/vue-ui-candlestick.js +1 -1
- package/dist/components/vue-ui-carousel-table.js +1 -1
- package/dist/components/vue-ui-chestnut.js +1 -1
- package/dist/components/vue-ui-chord.js +1 -1
- package/dist/components/vue-ui-circle-pack.js +1 -1
- package/dist/components/vue-ui-cursor.js +1 -1
- package/dist/components/vue-ui-dashboard.js +1 -1
- package/dist/components/vue-ui-digits.js +1 -1
- package/dist/components/vue-ui-donut-evolution.js +1 -1
- package/dist/components/vue-ui-donut.js +1 -1
- package/dist/components/vue-ui-dumbbell.js +1 -1
- package/dist/components/vue-ui-flow.js +1 -1
- package/dist/components/vue-ui-funnel.js +1 -1
- package/dist/components/vue-ui-galaxy.js +1 -1
- package/dist/components/vue-ui-gauge.js +1 -1
- package/dist/components/vue-ui-gizmo.js +1 -1
- package/dist/components/vue-ui-heatmap.js +1 -1
- package/dist/components/vue-ui-history-plot.js +1 -1
- package/dist/components/vue-ui-horizontal-bar.js +1 -1
- package/dist/components/vue-ui-icon.js +1 -1
- package/dist/components/vue-ui-kpi.js +1 -1
- package/dist/components/vue-ui-mini-loader.js +1 -1
- package/dist/components/vue-ui-molecule.js +1 -1
- package/dist/components/vue-ui-mood-radar.js +1 -1
- package/dist/components/vue-ui-nested-donuts.js +1 -1
- package/dist/components/vue-ui-onion.js +1 -1
- package/dist/components/vue-ui-parallel-coordinate-plot.js +1 -1
- package/dist/components/vue-ui-quadrant.js +1 -1
- package/dist/components/vue-ui-quick-chart.js +1 -1
- package/dist/components/vue-ui-radar.js +1 -1
- package/dist/components/vue-ui-rating.js +1 -1
- package/dist/components/vue-ui-relation-circle.js +1 -1
- package/dist/components/vue-ui-ridgeline.js +1 -1
- package/dist/components/vue-ui-rings.js +1 -1
- package/dist/components/vue-ui-scatter.js +1 -1
- package/dist/components/vue-ui-skeleton.js +1 -1
- package/dist/components/vue-ui-smiley.js +1 -1
- package/dist/components/vue-ui-spark-trend.js +1 -1
- package/dist/components/vue-ui-sparkbar.js +1 -1
- package/dist/components/vue-ui-sparkgauge.js +1 -1
- package/dist/components/vue-ui-sparkhistogram.js +1 -1
- package/dist/components/vue-ui-sparkline.js +1 -1
- package/dist/components/vue-ui-sparkstackbar.js +1 -1
- package/dist/components/vue-ui-stackbar.js +1 -1
- package/dist/components/vue-ui-strip-plot.js +1 -1
- package/dist/components/vue-ui-table-heatmap.js +1 -1
- package/dist/components/vue-ui-table-sparkline.js +1 -1
- package/dist/components/vue-ui-table.js +1 -1
- package/dist/components/vue-ui-thermometer.js +1 -1
- package/dist/components/vue-ui-timer.js +1 -1
- package/dist/components/vue-ui-tiremarks.js +1 -1
- package/dist/components/vue-ui-treemap.js +1 -1
- package/dist/components/vue-ui-vertical-bar.js +1 -1
- package/dist/components/vue-ui-waffle.js +1 -1
- package/dist/components/vue-ui-wheel.js +1 -1
- package/dist/components/vue-ui-word-cloud.js +1 -1
- package/dist/components/vue-ui-world.js +1 -1
- package/dist/components/vue-ui-xy-canvas.js +1 -1
- package/dist/components/vue-ui-xy.js +1 -1
- package/dist/{dom-to-png-BiyqJA3t.js → dom-to-png-DxyZSvDx.js} +1 -1
- package/dist/{img-6wPuVVtk.js → img-J2dLIr8Y.js} +1 -1
- package/dist/{lib-GIYcnm0E.js → lib-CEjkWSLj.js} +376 -374
- package/dist/{pdf-DjbHsnrb.js → pdf-anN8VbM7.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{useAutoSizeLabelsInsideViewbox-Csv3pVmh.js → useAutoSizeLabelsInsideViewbox-CovTrBjm.js} +1 -1
- package/dist/{useNestedProp-mxyyqd0B.js → useNestedProp-Ce3PwN8T.js} +1 -1
- package/dist/{usePrinter-DYRFiw7X.js → usePrinter-DJ1iH-F_.js} +2 -2
- package/dist/useResizeObserverEffect-DfnWps4W.js +109 -0
- package/dist/useSvgExport-DrjCWun4.js +750 -0
- package/dist/{vue-data-ui-DLU1snC3.js → vue-data-ui-BFdGl7rL.js} +64 -64
- package/dist/vue-data-ui.js +68 -68
- package/dist/{vue-ui-3d-bar-D6xoBrN6.js → vue-ui-3d-bar-kzlIaqHU.js} +7 -7
- package/dist/{vue-ui-accordion-Dch9YrCi.js → vue-ui-accordion-VTP418mC.js} +3 -3
- package/dist/{vue-ui-age-pyramid-D74mAaLA.js → vue-ui-age-pyramid-YFzQ15k1.js} +28 -35
- package/dist/{vue-ui-annotator-DwRwhrgB.js → vue-ui-annotator-CmwDyy9m.js} +7 -7
- package/dist/{vue-ui-bullet-D2qVUqWs.js → vue-ui-bullet-DdjpiM-T.js} +8 -8
- package/dist/{vue-ui-candlestick-C81k1_f9.js → vue-ui-candlestick-x9U5Ni0N.js} +31 -38
- package/dist/{vue-ui-carousel-table-DBIhnEj-.js → vue-ui-carousel-table-CRI_iPLn.js} +4 -4
- package/dist/{vue-ui-chestnut-CSM-_IWw.js → vue-ui-chestnut-YrEA5Gq3.js} +6 -6
- package/dist/{vue-ui-chord-BFW9nnNh.js → vue-ui-chord-D_2DdvpZ.js} +9 -9
- package/dist/{vue-ui-circle-pack-D6mTG5i0.js → vue-ui-circle-pack-xm9-OOAR.js} +7 -7
- package/dist/{vue-ui-cursor-BJmTAMpP.js → vue-ui-cursor-Dt8Zzw22.js} +2 -2
- package/dist/{vue-ui-dashboard-BdFLsK4u.js → vue-ui-dashboard-29ZuFoLn.js} +67 -67
- package/dist/{vue-ui-digits-DXum1rs6.js → vue-ui-digits-nKPRJ9Vz.js} +2 -2
- package/dist/{vue-ui-donut-CqefukGp.js → vue-ui-donut-BQptfVfE.js} +9 -9
- package/dist/{vue-ui-donut-evolution-DFIbK50s.js → vue-ui-donut-evolution-fiqngEFW.js} +76 -83
- package/dist/{vue-ui-dumbbell-DIo2ecGY.js → vue-ui-dumbbell-Cw45EBO0.js} +31 -38
- package/dist/{vue-ui-flow--kiGWaq4.js → vue-ui-flow-DPu9BjPy.js} +8 -8
- package/dist/{vue-ui-funnel-B8UHwj15.js → vue-ui-funnel-CtlDuNjO.js} +7 -7
- package/dist/{vue-ui-galaxy-eQZh_y3l.js → vue-ui-galaxy-BiVjoNHW.js} +8 -8
- package/dist/{vue-ui-gauge-DJ-E6L2T.js → vue-ui-gauge-CoM6Q3Nb.js} +8 -8
- package/dist/{vue-ui-gizmo-DFxlqPz7.js → vue-ui-gizmo-DXG8dS5u.js} +3 -3
- package/dist/{vue-ui-heatmap-CcAe5dDN.js → vue-ui-heatmap-D6n8AnCc.js} +194 -215
- package/dist/{vue-ui-history-plot-CgKvd7Jx.js → vue-ui-history-plot-C8WMHda_.js} +38 -45
- package/dist/{vue-ui-kpi-Ct2iyD49.js → vue-ui-kpi-Dphnwumo.js} +3 -3
- package/dist/{vue-ui-mini-loader-ByjcvXBB.js → vue-ui-mini-loader-DFk9GZ5V.js} +2 -2
- package/dist/{vue-ui-molecule-CGDBEAkX.js → vue-ui-molecule-DC4_vXt_.js} +6 -6
- package/dist/{vue-ui-mood-radar-D9GuK4cI.js → vue-ui-mood-radar-BgT5wMS0.js} +8 -8
- package/dist/{vue-ui-nested-donuts-CGKgOTX2.js → vue-ui-nested-donuts-D2gSqe1f.js} +8 -8
- package/dist/{vue-ui-onion-C5tE1Woz.js → vue-ui-onion-CEbv2ii4.js} +9 -9
- package/dist/{vue-ui-parallel-coordinate-plot-CVhD6IoH.js → vue-ui-parallel-coordinate-plot-budrvcwU.js} +38 -45
- package/dist/{vue-ui-quadrant-BGDCaOXv.js → vue-ui-quadrant-PpymeiXe.js} +9 -9
- package/dist/{vue-ui-quick-chart-CjXSB-2S.js → vue-ui-quick-chart-k6mjTD56.js} +207 -214
- package/dist/{vue-ui-radar-rhxkROX7.js → vue-ui-radar-C5NvYMnv.js} +9 -9
- package/dist/{vue-ui-rating-Bo9gSy-z.js → vue-ui-rating-eKlTJch9.js} +2 -2
- package/dist/{vue-ui-relation-circle-Qo8FKbL2.js → vue-ui-relation-circle-Df33aaUT.js} +8 -8
- package/dist/{vue-ui-ridgeline-ahOApbEC.js → vue-ui-ridgeline-BTw-37RS.js} +38 -45
- package/dist/{vue-ui-rings-DFAVaEBs.js → vue-ui-rings-C_s9xOtZ.js} +9 -9
- package/dist/{vue-ui-scatter-zjlWyvVd.js → vue-ui-scatter-Jd8bQ0S5.js} +9 -9
- package/dist/{vue-ui-skeleton-CKfOnyd_.js → vue-ui-skeleton-Ce7H57o7.js} +3 -3
- package/dist/{vue-ui-smiley-CY7UiJ9C.js → vue-ui-smiley-C4mhT7ZV.js} +2 -2
- package/dist/{vue-ui-spark-trend-DwNYP97M.js → vue-ui-spark-trend-DQy4iSO7.js} +3 -3
- package/dist/{vue-ui-sparkbar-BkdcYrmg.js → vue-ui-sparkbar-CUFTHql0.js} +3 -3
- package/dist/{vue-ui-sparkgauge-C6Kq_OGV.js → vue-ui-sparkgauge-CcykuBps.js} +3 -3
- package/dist/{vue-ui-sparkhistogram-CjB33yXB.js → vue-ui-sparkhistogram-CyGvYpYn.js} +4 -4
- package/dist/{vue-ui-sparkline-DcH4yIEd.js → vue-ui-sparkline-CLWJM6hA.js} +3 -3
- package/dist/{vue-ui-sparkstackbar-MKr2u_pO.js → vue-ui-sparkstackbar-Cln1pduE.js} +3 -3
- package/dist/{vue-ui-stackbar-DKV-exfd.js → vue-ui-stackbar-DIUil9DO.js} +31 -46
- package/dist/{vue-ui-strip-plot-ncTrDlNC.js → vue-ui-strip-plot-C4U0fT5D.js} +106 -113
- package/dist/{vue-ui-table-BdT3lGuv.js → vue-ui-table-DpdP3PDq.js} +5 -5
- package/dist/{vue-ui-table-heatmap-D929cWB0.js → vue-ui-table-heatmap-J29d8nds.js} +5 -5
- package/dist/{vue-ui-table-sparkline-CkZ_ygR1.js → vue-ui-table-sparkline-Chf5YY4A.js} +4 -4
- package/dist/{vue-ui-thermometer-CjBLR6H9.js → vue-ui-thermometer-D6RmaNE6.js} +8 -8
- package/dist/{vue-ui-timer-Bs7eMmiC.js → vue-ui-timer-C5E1kJRt.js} +5 -5
- package/dist/{vue-ui-tiremarks-nGOZKRcz.js → vue-ui-tiremarks-D0erVBnj.js} +7 -7
- package/dist/{vue-ui-treemap-SQ2f5wbN.js → vue-ui-treemap-K8FYxuYz.js} +10 -10
- package/dist/{vue-ui-vertical-bar-Hh9gAN5j.js → vue-ui-vertical-bar-BA3OY8Sh.js} +10 -10
- package/dist/{vue-ui-waffle-C7moVBln.js → vue-ui-waffle-CgLgPuro.js} +9 -9
- package/dist/{vue-ui-wheel-KrGLMCqW.js → vue-ui-wheel-C_cOUhCs.js} +7 -7
- package/dist/{vue-ui-word-cloud-BQSu6kiR.js → vue-ui-word-cloud-uvHNOIpN.js} +7 -7
- package/dist/{vue-ui-world-DdoMFJcV.js → vue-ui-world-DmeNMwpX.js} +7 -7
- package/dist/{vue-ui-xy-canvas-oUXISeU8.js → vue-ui-xy-canvas-BQKR36bd.js} +10 -10
- package/dist/{vue-ui-xy-B2fjTYMJ.js → vue-ui-xy-tWE4H5ij.js} +278 -285
- package/package.json +1 -1
- package/dist/useSvgExport-B7-Vrjtu.js +0 -732
- package/dist/useTimeLabelCollider-CIsgDrl9.js +0 -78
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import { isRef as Lt, ref as Ct, onMounted as Pt, watch as Rt, nextTick as Wt, unref as Vt } from "vue";
|
|
2
|
+
const et = "http://www.w3.org/2000/svg", yt = "http://www.w3.org/1999/xlink", Bt = 'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif';
|
|
3
|
+
let At = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function gt(N) {
|
|
5
|
+
let v = At.get(N);
|
|
6
|
+
return v || (v = getComputedStyle(N), At.set(N, v)), v;
|
|
7
|
+
}
|
|
8
|
+
function Mt() {
|
|
9
|
+
At = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
}
|
|
11
|
+
function P(N) {
|
|
12
|
+
return document.createElementNS(et, N);
|
|
13
|
+
}
|
|
14
|
+
function wt(N) {
|
|
15
|
+
return `${N}, ${Bt}`;
|
|
16
|
+
}
|
|
17
|
+
function Ot({
|
|
18
|
+
svg: N,
|
|
19
|
+
// ref
|
|
20
|
+
title: v,
|
|
21
|
+
// computed
|
|
22
|
+
legend: F,
|
|
23
|
+
// computed
|
|
24
|
+
legendItems: rt,
|
|
25
|
+
// computed
|
|
26
|
+
backgroundColor: ot,
|
|
27
|
+
// computed
|
|
28
|
+
stretchTitle: I = !1,
|
|
29
|
+
// bool (when rotateX is applied on the svg like in VueUiWheel, title transform style needs to be compensated)
|
|
30
|
+
titleEmbedded: at = !1
|
|
31
|
+
// when title is already part of the svg (VueUiChestnut)
|
|
32
|
+
}) {
|
|
33
|
+
const lt = Lt(N) ? N : Ct(N), nt = Ct(!1), W = [
|
|
34
|
+
"fill",
|
|
35
|
+
"fill-opacity",
|
|
36
|
+
"stroke",
|
|
37
|
+
"stroke-width",
|
|
38
|
+
"stroke-opacity",
|
|
39
|
+
"opacity",
|
|
40
|
+
"color",
|
|
41
|
+
"stroke-linecap",
|
|
42
|
+
"stroke-linejoin",
|
|
43
|
+
"stroke-miterlimit",
|
|
44
|
+
"stroke-dasharray",
|
|
45
|
+
"stroke-dashoffset",
|
|
46
|
+
"font-family",
|
|
47
|
+
"font-size",
|
|
48
|
+
"font-style",
|
|
49
|
+
"font-weight",
|
|
50
|
+
"font-variant",
|
|
51
|
+
"letter-spacing",
|
|
52
|
+
"word-spacing",
|
|
53
|
+
"text-anchor",
|
|
54
|
+
"dominant-baseline",
|
|
55
|
+
"shape-rendering",
|
|
56
|
+
"vector-effect",
|
|
57
|
+
"paint-order",
|
|
58
|
+
"mix-blend-mode",
|
|
59
|
+
"isolation",
|
|
60
|
+
"filter",
|
|
61
|
+
"clip-path",
|
|
62
|
+
"mask",
|
|
63
|
+
"transform",
|
|
64
|
+
"transform-origin",
|
|
65
|
+
"visibility",
|
|
66
|
+
"display"
|
|
67
|
+
], j = /* @__PURE__ */ new Set(["font-family"]);
|
|
68
|
+
async function b({ timeoutMs: e = 4e3, log: o = "warn" } = {}) {
|
|
69
|
+
if (typeof window > "u" || typeof document > "u")
|
|
70
|
+
return console.warn("SVG export only works in the browser."), null;
|
|
71
|
+
const h = performance.now() + e, u = () => {
|
|
72
|
+
const C = Vt(lt);
|
|
73
|
+
return C && document.contains(C) ? C : null;
|
|
74
|
+
};
|
|
75
|
+
let c = u();
|
|
76
|
+
if (c)
|
|
77
|
+
return c;
|
|
78
|
+
let t = !1;
|
|
79
|
+
const S = (C) => {
|
|
80
|
+
if (!t && C)
|
|
81
|
+
try {
|
|
82
|
+
C.disconnect();
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
t = !0;
|
|
86
|
+
};
|
|
87
|
+
let w;
|
|
88
|
+
const A = new Promise((C) => {
|
|
89
|
+
try {
|
|
90
|
+
w = new MutationObserver(() => {
|
|
91
|
+
const M = u();
|
|
92
|
+
M && (S(w), C(M));
|
|
93
|
+
}), w.observe(document.documentElement, { childList: !0, subtree: !0 });
|
|
94
|
+
} catch {
|
|
95
|
+
C(null);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
for (; performance.now() < h; ) {
|
|
99
|
+
const C = await Promise.race([
|
|
100
|
+
A,
|
|
101
|
+
new Promise((M) => requestAnimationFrame(M))
|
|
102
|
+
]);
|
|
103
|
+
if (await Wt(), c = u() || C, c)
|
|
104
|
+
return S(w), c;
|
|
105
|
+
}
|
|
106
|
+
return S(w), console.warn("SVG element not found or not mounted (timed out)."), null;
|
|
107
|
+
}
|
|
108
|
+
Pt(async () => {
|
|
109
|
+
try {
|
|
110
|
+
await b(), nt.value = !0;
|
|
111
|
+
} catch {
|
|
112
|
+
nt.value = !1;
|
|
113
|
+
}
|
|
114
|
+
}), Rt(lt, async () => {
|
|
115
|
+
try {
|
|
116
|
+
await b(), nt.value = !0;
|
|
117
|
+
} catch {
|
|
118
|
+
nt.value = !1;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const f = /* @__PURE__ */ new Map();
|
|
122
|
+
function y(e) {
|
|
123
|
+
if (f.has(e))
|
|
124
|
+
return f.get(e);
|
|
125
|
+
const o = P("svg");
|
|
126
|
+
o.setAttribute("width", "0"), o.setAttribute("height", "0"), o.style.position = "absolute", o.style.left = "-99999px", o.style.top = "-99999px";
|
|
127
|
+
const h = P(e);
|
|
128
|
+
o.appendChild(h), document.body.appendChild(o);
|
|
129
|
+
const u = window.getComputedStyle(h), c = {};
|
|
130
|
+
for (const t of W)
|
|
131
|
+
c[t] = u.getPropertyValue(t);
|
|
132
|
+
return document.body.removeChild(o), f.set(e, c), c;
|
|
133
|
+
}
|
|
134
|
+
function $(e) {
|
|
135
|
+
const o = gt(e), h = y(e.tagName.toLowerCase()), u = [];
|
|
136
|
+
for (const c of W) {
|
|
137
|
+
let t = o.getPropertyValue(c) || "";
|
|
138
|
+
const S = h[c] || "";
|
|
139
|
+
if (j.has(c)) {
|
|
140
|
+
c === "font-family" && t && (t = wt(t)), t && u.push(`${c}:${t};`);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
t && t !== S && u.push(`${c}:${t};`);
|
|
144
|
+
}
|
|
145
|
+
return u.join("");
|
|
146
|
+
}
|
|
147
|
+
function z(e, o) {
|
|
148
|
+
e.getAttribute("width") && o.setAttribute("width", e.getAttribute("width")), e.getAttribute("height") && o.setAttribute("height", e.getAttribute("height")), e.getAttribute("viewBox") && o.setAttribute("viewBox", e.getAttribute("viewBox"));
|
|
149
|
+
const h = [e, ...Array.from(e.querySelectorAll("*"))], u = [o, ...Array.from(o.querySelectorAll("*"))];
|
|
150
|
+
for (let c = 0; c < h.length; c += 1) {
|
|
151
|
+
const t = h[c], S = u[c], w = $(t);
|
|
152
|
+
w && S.setAttribute("style", w), ["fill", "stroke", "filter", "clip-path", "mask"].forEach((A) => {
|
|
153
|
+
const C = t.getAttribute(A);
|
|
154
|
+
C && S.setAttribute(A, C);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function L(e) {
|
|
159
|
+
const o = e.getAttribute("viewBox");
|
|
160
|
+
if (!o)
|
|
161
|
+
return null;
|
|
162
|
+
const [h, u, c, t] = o.split(/\s+|,/).map(Number);
|
|
163
|
+
return [h, u, c, t].some((S) => Number.isNaN(S)) ? null : { minX: h, minY: u, width: c, height: t };
|
|
164
|
+
}
|
|
165
|
+
function O(e) {
|
|
166
|
+
e.getAttribute("xmlns") || e.setAttribute("xmlns", et), e.getAttribute("xmlns:xlink") || e.setAttribute("xmlns:xlink", yt), e.getAttribute("xml:space") || e.setAttribute("xml:space", "preserve");
|
|
167
|
+
}
|
|
168
|
+
function it(e) {
|
|
169
|
+
const o = document.createElement("div");
|
|
170
|
+
return o.style.position = "absolute", o.style.left = "-99999px", o.style.top = "-99999px", o.style.width = "0", o.style.height = "0", document.body.appendChild(o), o.appendChild(e), o;
|
|
171
|
+
}
|
|
172
|
+
function st(e) {
|
|
173
|
+
try {
|
|
174
|
+
e.remove();
|
|
175
|
+
} catch {
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function dt(e, o, h, u, c) {
|
|
179
|
+
if (!v.value || !v.value.text)
|
|
180
|
+
return 0;
|
|
181
|
+
const t = {
|
|
182
|
+
text: v.value.text || "",
|
|
183
|
+
color: v.value.color || "#111",
|
|
184
|
+
fontSize: v.value.fontSize || 20,
|
|
185
|
+
bold: !!v.value.bold,
|
|
186
|
+
textAlign: (v.value?.textAlign || "center").toLowerCase(),
|
|
187
|
+
paddingLeft: v.value.paddingLeft ?? 0,
|
|
188
|
+
paddingRight: v.value.paddingRight ?? 0,
|
|
189
|
+
subtitle: v.value.subtitle || null
|
|
190
|
+
}, S = P("g");
|
|
191
|
+
S.setAttribute("id", "__vdu_export_title"), e.appendChild(S);
|
|
192
|
+
const w = h + t.paddingLeft, A = h + o - (t.paddingRight || 0), C = h + o / 2;
|
|
193
|
+
let M = "start", X = w;
|
|
194
|
+
t.textAlign === "center" ? (M = "middle", X = C) : t.textAlign === "right" && (M = "end", X = A);
|
|
195
|
+
const D = u, T = Math.round(t.fontSize * 0.4), R = P("text");
|
|
196
|
+
R.setAttribute("x", String(X)), R.setAttribute("y", String(D + t.fontSize)), R.setAttribute("text-anchor", M), R.setAttribute("dominant-baseline", "ideographic"), R.setAttribute("style", `font-family:${c}; font-size:${t.fontSize}px; font-weight:${t.bold ? "700" : "400"}; fill:${t.color}; ${I ? "transform: scale(0.65, 1); transform-origin: center;" : ""}`), R.textContent = t.text, S.appendChild(R);
|
|
197
|
+
let J = t.fontSize;
|
|
198
|
+
if (t.subtitle && t.subtitle.text) {
|
|
199
|
+
const E = {
|
|
200
|
+
color: t.subtitle.color || "#666",
|
|
201
|
+
text: t.subtitle.text,
|
|
202
|
+
fontSize: t.subtitle.fontSize || Math.max(12, Math.round(t.fontSize * 0.8)),
|
|
203
|
+
bold: !!t.subtitle.bold
|
|
204
|
+
}, V = P("text");
|
|
205
|
+
V.setAttribute("x", String(X)), V.setAttribute("y", String(D + t.fontSize + T + E.fontSize)), V.setAttribute("text-anchor", M), V.setAttribute("dominant-baseline", "ideographic"), V.setAttribute("style", `font-family:${c}; font-size:${E.fontSize}px; font-weight:${E.bold ? "600" : "400"}; fill:${E.color}; ${I ? "transform: scale(0.65, 1); transform-origin: center;" : ""}`), V.textContent = E.text, S.appendChild(V), J += T + E.fontSize;
|
|
206
|
+
}
|
|
207
|
+
return J + Math.round(t.fontSize * 0.4);
|
|
208
|
+
}
|
|
209
|
+
function q(e, o, h, u, c) {
|
|
210
|
+
if (!F.value || !F.value.show || !Array.isArray(rt.value) || !rt.value.length)
|
|
211
|
+
return 0;
|
|
212
|
+
const t = {
|
|
213
|
+
bold: !!F.value.bold,
|
|
214
|
+
backgroundColor: F.value.backgroundColor || "transparent",
|
|
215
|
+
color: F.value.color || "#111",
|
|
216
|
+
fontSize: F.value.fontSize || 14,
|
|
217
|
+
paddingX: 14,
|
|
218
|
+
paddingY: 10,
|
|
219
|
+
itemGapX: 18,
|
|
220
|
+
itemGapY: 12,
|
|
221
|
+
markerSize: Math.max(8, Math.round((F.value.fontSize || 14) * 0.9)),
|
|
222
|
+
markerTextGap: 8,
|
|
223
|
+
lineHeight: Math.round((F.value.fontSize || 14) * 1.2),
|
|
224
|
+
maxWidth: o
|
|
225
|
+
}, S = P("g");
|
|
226
|
+
S.setAttribute("id", "__vdu_export_legend"), S.setAttribute("transform", `translate(${h}, ${u})`), e.appendChild(S);
|
|
227
|
+
const w = P("rect");
|
|
228
|
+
w.setAttribute("rx", "6"), w.setAttribute("ry", "6"), w.setAttribute("fill", t.backgroundColor), S.appendChild(w);
|
|
229
|
+
const A = P("g");
|
|
230
|
+
S.appendChild(A);
|
|
231
|
+
const C = P("text");
|
|
232
|
+
C.setAttribute("x", "0"), C.setAttribute("y", "0"), C.setAttribute("style", `font-family:${c}; font-size:${t.fontSize}px; font-weight:${t.bold ? "600" : "400"}; opacity:0;`), A.appendChild(C);
|
|
233
|
+
const M = (s) => (C.textContent = s || "", C.getComputedTextLength()), X = Math.max(1, t.maxWidth - t.paddingX * 2);
|
|
234
|
+
function D(s, a) {
|
|
235
|
+
const l = String(s || "").split(/\s+/).filter(Boolean), m = [];
|
|
236
|
+
if (!l.length)
|
|
237
|
+
return [""];
|
|
238
|
+
let d = l.shift();
|
|
239
|
+
for (; l.length; ) {
|
|
240
|
+
const g = `${d} ${l[0]}`;
|
|
241
|
+
if (M(g) <= a)
|
|
242
|
+
d = g, l.shift();
|
|
243
|
+
else if (M(d) > a && d.length > 1) {
|
|
244
|
+
let x = "";
|
|
245
|
+
for (const H of d) {
|
|
246
|
+
const Q = x + H;
|
|
247
|
+
if (M(Q) <= a)
|
|
248
|
+
x = Q;
|
|
249
|
+
else break;
|
|
250
|
+
}
|
|
251
|
+
const _ = d.slice(x.length);
|
|
252
|
+
m.push(x), d = _.length ? _ : l.shift() || "";
|
|
253
|
+
} else
|
|
254
|
+
m.push(d), d = l.shift() || "";
|
|
255
|
+
}
|
|
256
|
+
d && m.push(d);
|
|
257
|
+
const k = m[m.length - 1] || "";
|
|
258
|
+
if (M(k) > a && k.length > 1) {
|
|
259
|
+
let g = "";
|
|
260
|
+
for (const _ of k) {
|
|
261
|
+
const H = g + _;
|
|
262
|
+
if (M(H) <= a)
|
|
263
|
+
g = H;
|
|
264
|
+
else break;
|
|
265
|
+
}
|
|
266
|
+
const x = k.slice(g.length);
|
|
267
|
+
m[m.length - 1] = g, x && m.push(x);
|
|
268
|
+
}
|
|
269
|
+
return m;
|
|
270
|
+
}
|
|
271
|
+
const T = Math.PI / 180;
|
|
272
|
+
function R(s, a, l, m, d = -90) {
|
|
273
|
+
const k = d * T;
|
|
274
|
+
let g = "";
|
|
275
|
+
for (let x = 0; x < l; x += 1) {
|
|
276
|
+
const _ = k + x * 2 * Math.PI / l, H = s + Math.cos(_) * m, Q = a + Math.sin(_) * m;
|
|
277
|
+
g += (x === 0 ? "M" : "L") + H + "," + Q;
|
|
278
|
+
}
|
|
279
|
+
return g + "Z";
|
|
280
|
+
}
|
|
281
|
+
function J(s, a, l = 5, m, d) {
|
|
282
|
+
const k = -90 * T;
|
|
283
|
+
let g = "";
|
|
284
|
+
for (let x = 0; x < l * 2; x += 1) {
|
|
285
|
+
const _ = x % 2 === 0 ? m : d, H = k + x * Math.PI / l, Q = s + Math.cos(H) * _, Y = a + Math.sin(H) * _;
|
|
286
|
+
g += (x === 0 ? "M" : "L") + Q + "," + Y;
|
|
287
|
+
}
|
|
288
|
+
return g + "Z";
|
|
289
|
+
}
|
|
290
|
+
const E = rt.value.map((s) => {
|
|
291
|
+
const a = Math.max(1, X - (t.markerSize + t.markerTextGap)), l = D(s.name || "", a), m = Math.max(...l.map(M), 0), d = t.markerSize + t.markerTextGap + m, k = Math.max(t.markerSize, l.length * t.lineHeight);
|
|
292
|
+
return {
|
|
293
|
+
...s,
|
|
294
|
+
lines: l,
|
|
295
|
+
itemW: d,
|
|
296
|
+
itemH: k
|
|
297
|
+
};
|
|
298
|
+
}), V = [];
|
|
299
|
+
let n = {
|
|
300
|
+
items: [],
|
|
301
|
+
width: 0,
|
|
302
|
+
height: 0
|
|
303
|
+
};
|
|
304
|
+
for (const s of E) {
|
|
305
|
+
const a = (n.items.length ? t.itemGapX : 0) + s.itemW;
|
|
306
|
+
n.items.length && n.width + a > X ? (V.push(n), n = {
|
|
307
|
+
items: [s],
|
|
308
|
+
width: s.itemW,
|
|
309
|
+
height: s.itemH
|
|
310
|
+
}) : (n.items.push(s), n.width += a, n.height = Math.max(n.height, s.itemH));
|
|
311
|
+
}
|
|
312
|
+
n.items.length && V.push(n);
|
|
313
|
+
let r = t.paddingY;
|
|
314
|
+
for (const s of V) {
|
|
315
|
+
let l = Math.max(t.paddingX, (t.maxWidth - s.width) / 2);
|
|
316
|
+
for (let m = 0; m < s.items.length; m += 1) {
|
|
317
|
+
const d = s.items[m], k = l + t.markerSize / 2, g = r + s.height / 2.5, x = t.markerSize / 2, _ = String(d.shape || "rect").toLowerCase();
|
|
318
|
+
if (_ === "circle") {
|
|
319
|
+
const p = P("circle");
|
|
320
|
+
p.setAttribute("cx", String(k)), p.setAttribute("cy", String(g)), p.setAttribute("r", String(x * 0.8)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
321
|
+
} else if (_ === "rect" || _ === "square") {
|
|
322
|
+
const p = P("path");
|
|
323
|
+
p.setAttribute("d", R(k, g, 4, x, -45)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
324
|
+
} else if (_ === "diamond") {
|
|
325
|
+
const p = P("path");
|
|
326
|
+
p.setAttribute("d", R(k, g, 4, x, 45)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
327
|
+
} else if (_ === "triangle") {
|
|
328
|
+
const p = P("path");
|
|
329
|
+
p.setAttribute("d", R(k, g, 3, x, -90)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
330
|
+
} else if (_ === "pentagon") {
|
|
331
|
+
const p = P("path");
|
|
332
|
+
p.setAttribute("d", R(k, g, 5, x, -90)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
333
|
+
} else if (_ === "hexagon") {
|
|
334
|
+
const p = P("path");
|
|
335
|
+
p.setAttribute("d", R(k, g, 6, x, 0)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
336
|
+
} else if (_ === "star") {
|
|
337
|
+
const p = P("path"), tt = x, pt = x * 0.5;
|
|
338
|
+
p.setAttribute("d", J(k, g, 5, tt, pt)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
339
|
+
} else {
|
|
340
|
+
const p = P("rect");
|
|
341
|
+
p.setAttribute("x", String(l)), p.setAttribute("y", String(r + (s.height - t.markerSize) / 2)), p.setAttribute("width", String(t.markerSize)), p.setAttribute("height", String(t.markerSize)), p.setAttribute("fill", d.color || "#000"), A.appendChild(p);
|
|
342
|
+
}
|
|
343
|
+
const H = l + t.markerSize + t.markerTextGap, Q = r + (s.height - d.lines.length * t.lineHeight) / 2 + t.fontSize, Y = P("text");
|
|
344
|
+
Y.setAttribute("x", String(H)), Y.setAttribute("y", String(Q)), Y.setAttribute("style", `font-family:${c}; font-size:${t.fontSize}px; font-weight:${t.bold ? "600" : "400"}; fill:${t.color};`), Y.setAttribute("dominant-baseline", "ideographic");
|
|
345
|
+
let mt = !0;
|
|
346
|
+
for (const p of d.lines) {
|
|
347
|
+
const tt = P("tspan");
|
|
348
|
+
mt || tt.setAttribute("dy", String(t.lineHeight)), tt.setAttribute("x", String(H)), tt.textContent = p, Y.appendChild(tt), mt = !1;
|
|
349
|
+
}
|
|
350
|
+
A.appendChild(Y), l += d.itemW + (m < s.items.length - 1 ? t.itemGapX : 0);
|
|
351
|
+
}
|
|
352
|
+
r += s.height + t.itemGapY;
|
|
353
|
+
}
|
|
354
|
+
V.length && (r -= t.itemGapY);
|
|
355
|
+
const i = r + t.paddingY;
|
|
356
|
+
return w.setAttribute("x", "0"), w.setAttribute("y", "0"), w.setAttribute("width", String(t.maxWidth)), w.setAttribute("height", String(i)), C.remove(), i + Math.round(t.fontSize * 0.4);
|
|
357
|
+
}
|
|
358
|
+
function ht(e) {
|
|
359
|
+
const o = e.cloneNode(!0);
|
|
360
|
+
return o.querySelectorAll("script").forEach((h) => h.remove()), z(e, o), O(o), o;
|
|
361
|
+
}
|
|
362
|
+
function B(e) {
|
|
363
|
+
const o = Array.from(e.childNodes).filter((c) => c.nodeType === 1 && c.nodeName.toLowerCase() === "defs"), h = Array.from(e.childNodes).filter((c) => !(c.nodeType === 1 && c.nodeName.toLowerCase() === "defs")), u = document.createElementNS(et, "g");
|
|
364
|
+
u.setAttribute("id", "__vdu_export_content");
|
|
365
|
+
for (const c of h) u.appendChild(c);
|
|
366
|
+
for (const c of o) e.appendChild(c);
|
|
367
|
+
return e.appendChild(u), u;
|
|
368
|
+
}
|
|
369
|
+
function K(e, o) {
|
|
370
|
+
o <= 0 || e.setAttribute("transform", `translate(0, ${o})`);
|
|
371
|
+
}
|
|
372
|
+
function ct(e, o) {
|
|
373
|
+
if (o <= 0) return;
|
|
374
|
+
const h = L(e), u = e.getAttribute("height");
|
|
375
|
+
if (h)
|
|
376
|
+
e.setAttribute("viewBox", `${h.minX} ${h.minY} ${h.width} ${h.height + o}`), u && e.setAttribute("height", String(Number(u) + o));
|
|
377
|
+
else if (u)
|
|
378
|
+
e.setAttribute("height", String(Number(u) + o));
|
|
379
|
+
else {
|
|
380
|
+
const c = e.getBBox();
|
|
381
|
+
e.setAttribute("viewBox", `0 0 ${Math.max(1, c.width)} ${Math.max(1, c.height + o)}`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function U(e) {
|
|
385
|
+
const o = L(e);
|
|
386
|
+
if (o)
|
|
387
|
+
return o.width;
|
|
388
|
+
const h = Number(e.getAttribute("width"));
|
|
389
|
+
return !Number.isNaN(h) && h > 0 ? h : e.getBBox().width || 0;
|
|
390
|
+
}
|
|
391
|
+
function G(e) {
|
|
392
|
+
const o = L(e);
|
|
393
|
+
if (o) return o.height;
|
|
394
|
+
const h = Number(e.getAttribute("height"));
|
|
395
|
+
return !Number.isNaN(h) && h > 0 ? h : e.getBBox().height || 0;
|
|
396
|
+
}
|
|
397
|
+
async function ut(e) {
|
|
398
|
+
const o = it(e);
|
|
399
|
+
Mt();
|
|
400
|
+
try {
|
|
401
|
+
if (document.fonts?.ready)
|
|
402
|
+
try {
|
|
403
|
+
await Promise.race([document.fonts.ready, new Promise((T) => setTimeout(T, 4e3))]);
|
|
404
|
+
} catch {
|
|
405
|
+
}
|
|
406
|
+
const h = B(e), u = L(e), c = u ? u.minX : 0, t = u ? u.minY : 0, S = Math.max(1, U(e)), w = Math.max(1, G(e)), A = wt(gt(e).getPropertyValue("font-family") || "");
|
|
407
|
+
let M = (at ? null : dt(e, S, c, t, A)) ?? 0;
|
|
408
|
+
const X = F && F.value && F.value.position ? String(F.value.position).toLowerCase() : "top";
|
|
409
|
+
F && F.value && F.value.show && X === "top" && (M += q(e, S, c, t + M, A)), K(h, M);
|
|
410
|
+
let D = 0;
|
|
411
|
+
F && F.value && F.value.show && X === "bottom" && (D += q(e, S, c, t + M + w, A)), ct(e, M + D), e.style.backgroundColor = ot.value ?? "#FFF", await Et(e, { mode: "raster" }), Tt(e, v.value.text ? -6 : -48);
|
|
412
|
+
} finally {
|
|
413
|
+
st(o), Mt();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
async function Z() {
|
|
417
|
+
const e = await b(), o = ht(e);
|
|
418
|
+
await ut(o);
|
|
419
|
+
const u = `<?xml version="1.0" standalone="no"?>
|
|
420
|
+
${new XMLSerializer().serializeToString(o)}`, c = new Blob([u], { type: "image/svg+xml;charset=utf-8" }), t = URL.createObjectURL(c), S = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(u)}`;
|
|
421
|
+
return { blob: c, url: t, text: u, dataUrl: S };
|
|
422
|
+
}
|
|
423
|
+
async function ft(e) {
|
|
424
|
+
const { url: o } = await Z(), h = e || v.value?.text || "chart", u = document.createElement("a");
|
|
425
|
+
u.href = o, u.download = h.endsWith(".svg") ? h : `${h}.svg`, document.body.appendChild(u), u.click(), document.body.removeChild(u), URL.revokeObjectURL(o);
|
|
426
|
+
}
|
|
427
|
+
return { ready: nt, getSvg: Z, exportSvg: ft };
|
|
428
|
+
}
|
|
429
|
+
function Tt(N, v = -50) {
|
|
430
|
+
if (!v) return;
|
|
431
|
+
const F = N.getAttribute("viewBox"), rt = (W) => {
|
|
432
|
+
if (!W) return;
|
|
433
|
+
const j = N.getAttribute("height");
|
|
434
|
+
if (!j) return;
|
|
435
|
+
const b = /^(\d+(\.\d+)?)(px)?$/.exec(j.trim());
|
|
436
|
+
if (!b) return;
|
|
437
|
+
const f = parseFloat(b[1]) || 0, y = Math.max(1, f + W);
|
|
438
|
+
N.setAttribute("height", String(y));
|
|
439
|
+
};
|
|
440
|
+
if (F) {
|
|
441
|
+
const W = F.trim().split(/\s+|,/).map(Number);
|
|
442
|
+
if (W.length !== 4 || W.some((O) => !Number.isFinite(O))) return;
|
|
443
|
+
const [j, b, f, y] = W, $ = b + v, z = -v, L = Math.max(1, y + z);
|
|
444
|
+
N.setAttribute("viewBox", `${j} ${$} ${f} ${L}`), rt(z);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
let ot = Number(N.getAttribute("width")), I = Number(N.getAttribute("height"));
|
|
448
|
+
if (!(ot > 0 && I > 0)) {
|
|
449
|
+
const W = N.getBBox();
|
|
450
|
+
ot = Math.max(1, W.width || 1), I = Math.max(1, W.height || 1);
|
|
451
|
+
}
|
|
452
|
+
const at = v, lt = -v, nt = Math.max(1, I + lt);
|
|
453
|
+
N.setAttribute("viewBox", `0 ${at} ${ot} ${nt}`), function() {
|
|
454
|
+
const j = N.getAttribute("height");
|
|
455
|
+
if (!j) return;
|
|
456
|
+
const b = /^(\d+(\.\d+)?)(px)?$/.exec(j.trim());
|
|
457
|
+
if (!b) return;
|
|
458
|
+
const f = parseFloat(b[1]) || 0, y = Math.max(1, f + lt);
|
|
459
|
+
N.setAttribute("height", String(y));
|
|
460
|
+
}();
|
|
461
|
+
}
|
|
462
|
+
async function Et(N, { mode: v = "raster" } = {}) {
|
|
463
|
+
const F = Array.from(N.querySelectorAll("foreignObject"));
|
|
464
|
+
if (!F.length) return { converted: 0, rasterized: 0, skipped: 0, errors: 0 };
|
|
465
|
+
let rt = 0, ot = 0, I = 0, at = 0;
|
|
466
|
+
const lt = (b) => ["div", "p", "span", "strong", "em", "b", "i", "br"].includes(b), nt = (b) => {
|
|
467
|
+
try {
|
|
468
|
+
const f = b.firstElementChild;
|
|
469
|
+
if (!f) return !1;
|
|
470
|
+
const y = [f];
|
|
471
|
+
for (; y.length; ) {
|
|
472
|
+
const $ = y.pop();
|
|
473
|
+
if ($.nodeType === 3)
|
|
474
|
+
continue;
|
|
475
|
+
if ($.nodeType !== 1)
|
|
476
|
+
return !1;
|
|
477
|
+
const z = ($.tagName || "").toLowerCase();
|
|
478
|
+
if (!lt(z) || $.querySelector?.("img,svg,canvas,video,foreignObject"))
|
|
479
|
+
return !1;
|
|
480
|
+
for (const L of Array.from($.childNodes))
|
|
481
|
+
y.push(L);
|
|
482
|
+
}
|
|
483
|
+
return !0;
|
|
484
|
+
} catch {
|
|
485
|
+
return !1;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
function W(b) {
|
|
489
|
+
try {
|
|
490
|
+
const f = b.firstElementChild;
|
|
491
|
+
if (!f) return null;
|
|
492
|
+
const y = (n, r = 0) => Number.isFinite(+n) ? +n : r, $ = y(b.getAttribute("x"), 0), z = y(b.getAttribute("y"), 0);
|
|
493
|
+
let L = y(b.getAttribute("width"), NaN);
|
|
494
|
+
if (!Number.isFinite(L) || L <= 0) {
|
|
495
|
+
const n = b.getBBox?.();
|
|
496
|
+
L = Math.max(1, y(n?.width, 0));
|
|
497
|
+
}
|
|
498
|
+
const O = (n, r) => {
|
|
499
|
+
if (!n) return Math.round(r * 1.2);
|
|
500
|
+
const i = n.trim().toLowerCase();
|
|
501
|
+
if (i === "normal") return Math.round(r * 1.2);
|
|
502
|
+
if (i.endsWith("px")) return parseFloat(i) || Math.round(r * 1.2);
|
|
503
|
+
if (i.endsWith("%")) return parseFloat(i) / 100 * r || Math.round(r * 1.2);
|
|
504
|
+
if (i.endsWith("em")) return (parseFloat(i) || 1) * r;
|
|
505
|
+
if (i.endsWith("rem")) {
|
|
506
|
+
const a = parseFloat(getComputedStyle(document.documentElement).fontSize) || r;
|
|
507
|
+
return (parseFloat(i) || 1) * a;
|
|
508
|
+
}
|
|
509
|
+
const s = Number(i);
|
|
510
|
+
return Number.isFinite(s) ? s * r : Math.round(r * 1.2);
|
|
511
|
+
}, it = (n) => {
|
|
512
|
+
const r = (s) => {
|
|
513
|
+
const a = (s || "").trim().toLowerCase();
|
|
514
|
+
if (a.endsWith("px")) return parseFloat(a) || 0;
|
|
515
|
+
if (a.endsWith("rem")) {
|
|
516
|
+
const m = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
|
|
517
|
+
return (parseFloat(a) || 0) * m;
|
|
518
|
+
}
|
|
519
|
+
if (a.endsWith("em")) {
|
|
520
|
+
const m = parseFloat(getComputedStyle(document.body).fontSize) || 16;
|
|
521
|
+
return (parseFloat(a) || 0) * m;
|
|
522
|
+
}
|
|
523
|
+
const l = Number(a);
|
|
524
|
+
return Number.isFinite(l) ? l : 0;
|
|
525
|
+
}, i = (n || "").split(/\s+/).map(r).filter(Number.isFinite);
|
|
526
|
+
return i.length ? i.length === 1 ? [i[0], i[0], i[0], i[0]] : i.length === 2 ? [i[0], i[1], i[0], i[1]] : i.length === 3 ? [i[0], i[1], i[2], i[1]] : [i[0], i[1], i[2], i[3]] : [0, 0, 0, 0];
|
|
527
|
+
}, st = (n, r) => {
|
|
528
|
+
const i = gt(n);
|
|
529
|
+
let s = i.getPropertyValue("font-family") || r?.ff || "system-ui";
|
|
530
|
+
s = wt(s);
|
|
531
|
+
let a = parseFloat(i.getPropertyValue("font-size"));
|
|
532
|
+
Number.isFinite(a) || (a = r?.fs || 14);
|
|
533
|
+
const l = i.getPropertyValue("font-weight") || r?.fw || "400", m = i.getPropertyValue("font-style") || r?.fsty || "normal", d = i.getPropertyValue("font-stretch") || r?.fstc || "normal", k = i.getPropertyValue("letter-spacing") || r?.lsp || "normal", g = i.getPropertyValue("word-spacing") || r?.wsp || "0px", x = i.getPropertyValue("font-kerning") || r?.kern || "auto", _ = i.getPropertyValue("font-variant-ligatures") || r?.liga || "normal", H = i.getPropertyValue("text-transform") || r?.ttfm || "none", Q = i.getPropertyValue("color") || r?.fill || "#000", Y = i.getPropertyValue("line-height"), mt = !Y || Y.trim().toLowerCase() === "normal" ? r?.lh ?? Math.round(a * 1.2) : O(Y, a), p = (i.getPropertyValue("text-align") || r?.ta || "start").trim().toLowerCase();
|
|
534
|
+
let tt = parseFloat(i.getPropertyValue("padding-top")) || 0, pt = parseFloat(i.getPropertyValue("padding-right")) || 0, bt = parseFloat(i.getPropertyValue("padding-bottom")) || 0, xt = parseFloat(i.getPropertyValue("padding-left")) || 0;
|
|
535
|
+
const St = i.getPropertyValue("padding");
|
|
536
|
+
if (St && tt === 0 && pt === 0 && bt === 0 && xt === 0) {
|
|
537
|
+
const [kt, Ft, _t, zt] = it(St);
|
|
538
|
+
tt = kt, pt = Ft, bt = _t, xt = zt;
|
|
539
|
+
}
|
|
540
|
+
const Nt = parseFloat(i.getPropertyValue("border-left-width")) || 0, vt = parseFloat(i.getPropertyValue("border-right-width")) || 0, $t = i.getPropertyValue("box-sizing") || "content-box";
|
|
541
|
+
return { ff: s, fs: a, fw: l, fsty: m, fstc: d, lsp: k, wsp: g, kern: x, liga: _, ttfm: H, fill: Q, lh: mt, ta: p, padL: xt, padR: pt, padT: tt, padB: bt, bL: Nt, bR: vt, box: $t };
|
|
542
|
+
}, dt = (n) => /^(div|p|section|article|ul|ol|li|h[1-6])$/.test(n), q = { __para__: !0 }, ht = { __br__: !0 }, B = [], K = st(f), ct = (n, r, i) => {
|
|
543
|
+
if (n.nodeType === 3) {
|
|
544
|
+
const m = (n.nodeValue || "").replace(/\s+/g, " ").trim();
|
|
545
|
+
m && B.push({ text: m, style: r, path: i.slice() });
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (n.nodeType !== 1) return;
|
|
549
|
+
const s = n.tagName.toLowerCase();
|
|
550
|
+
if (s === "br") {
|
|
551
|
+
B.push({ ...ht, path: i.slice() });
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
const a = st(n, r);
|
|
555
|
+
i.push(n);
|
|
556
|
+
for (const l of Array.from(n.childNodes)) ct(l, a, i);
|
|
557
|
+
i.pop(), dt(s) && B.push({ ...q, path: i.slice() });
|
|
558
|
+
};
|
|
559
|
+
for (ct(f, K, [f]); B.length && (B.at(-1).__para__ || B.at(-1).__br__); ) B.pop();
|
|
560
|
+
if (!B.length) return null;
|
|
561
|
+
const U = B.filter((n) => !n.__para__ && !n.__br__), G = (() => {
|
|
562
|
+
if (!U.length) return [f];
|
|
563
|
+
const n = U.map((s) => s.path), r = Math.min(...n.map((s) => s.length));
|
|
564
|
+
let i = 0;
|
|
565
|
+
for (; i < r; ) {
|
|
566
|
+
const s = n[0][i];
|
|
567
|
+
if (n.every((a) => a[i] === s)) i += 1;
|
|
568
|
+
else break;
|
|
569
|
+
}
|
|
570
|
+
return n[0].slice(0, Math.max(1, i));
|
|
571
|
+
})(), ut = G[G.length - 1] || f, Z = st(ut);
|
|
572
|
+
let ft = 0, e = 0, o = 0;
|
|
573
|
+
for (const n of G) {
|
|
574
|
+
const r = st(n);
|
|
575
|
+
ft += r.padL, e += r.padR, o += r.padT;
|
|
576
|
+
}
|
|
577
|
+
const h = [Math.max(1, L - ft - e)];
|
|
578
|
+
for (const n of G)
|
|
579
|
+
try {
|
|
580
|
+
const r = gt(n);
|
|
581
|
+
if (n.clientWidth && n.clientWidth > 0) {
|
|
582
|
+
const a = parseFloat(r.paddingLeft) || 0, l = parseFloat(r.paddingRight) || 0, m = Math.max(1, n.clientWidth - a - l);
|
|
583
|
+
h.push(m);
|
|
584
|
+
}
|
|
585
|
+
const i = r.width, s = parseFloat(i);
|
|
586
|
+
if (Number.isFinite(s) && s > 0) {
|
|
587
|
+
const a = r.boxSizing || r.getPropertyValue("box-sizing") || "content-box", l = parseFloat(r.paddingLeft) || 0, m = parseFloat(r.paddingRight) || 0, d = parseFloat(r.borderLeftWidth) || 0, k = parseFloat(r.borderRightWidth) || 0, g = a === "border-box" ? Math.max(1, s - l - m - d - k) : Math.max(1, s);
|
|
588
|
+
h.push(g);
|
|
589
|
+
}
|
|
590
|
+
} catch {
|
|
591
|
+
}
|
|
592
|
+
let u = Math.floor(Math.min(...h.filter(Number.isFinite))) - 1;
|
|
593
|
+
u > 0 || (u = 1);
|
|
594
|
+
let c = "start", t = $ + ft;
|
|
595
|
+
Z.ta === "center" ? (c = "middle", t = $ + ft + u / 2) : (Z.ta === "right" || Z.ta === "end") && (c = "end", t = $ + (L - e));
|
|
596
|
+
const S = b.ownerSVGElement || b.closest("svg"), w = document.createElementNS(et, "text");
|
|
597
|
+
w.setAttribute("x", String(t)), w.setAttribute("y", String(z + o)), w.setAttribute("text-anchor", c), w.setAttribute("dominant-baseline", "text-before-edge"), w.setAttribute("xml:space", "preserve");
|
|
598
|
+
const A = document.createElementNS(et, "text");
|
|
599
|
+
A.setAttribute("x", "0"), A.setAttribute("y", "0"), A.setAttribute("opacity", "0"), (S || b).appendChild(A);
|
|
600
|
+
const C = (n) => `font-family:${n.ff}; font-size:${n.fs}px; font-weight:${n.fw}; font-style:${n.fsty}; font-stretch:${n.fstc}; letter-spacing:${n.lsp}; word-spacing:${n.wsp}; font-kerning:${n.kern}; font-variant-ligatures:${n.liga}; text-transform:${n.ttfm};`, M = (n, r) => (A.textContent = n || "", A.setAttribute("style", C(r)), A.getComputedTextLength()), X = (n) => M(" ", n), D = [];
|
|
601
|
+
let T = [], R = 0;
|
|
602
|
+
const J = () => {
|
|
603
|
+
T.length && D.push({ segs: T.slice() }), T = [], R = 0;
|
|
604
|
+
}, E = (n, r, i) => {
|
|
605
|
+
let s = M(n, r);
|
|
606
|
+
if (i) {
|
|
607
|
+
const a = X(r);
|
|
608
|
+
s += a, T.push({ text: " ", ...r, w: a, isSpace: !0 });
|
|
609
|
+
}
|
|
610
|
+
T.push({ text: n, ...r, w: s }), R += s;
|
|
611
|
+
}, V = (n, r, i) => {
|
|
612
|
+
let s = "";
|
|
613
|
+
for (const a of n) {
|
|
614
|
+
const l = s + a;
|
|
615
|
+
if (M(l, r) <= i) s = l;
|
|
616
|
+
else break;
|
|
617
|
+
}
|
|
618
|
+
return s || n[0] || "";
|
|
619
|
+
};
|
|
620
|
+
for (const n of B) {
|
|
621
|
+
if (n.__para__ || n.__br__) {
|
|
622
|
+
J();
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
const r = n.style, i = n.text.split(/(\s+)/).filter((l) => l.length > 0), s = (l, m) => {
|
|
626
|
+
if (!l) return;
|
|
627
|
+
const d = Math.max(1, u), k = M(l, r) + (m ? X(r) : 0);
|
|
628
|
+
if (T.length === 0)
|
|
629
|
+
if (k <= d)
|
|
630
|
+
E(l, r, !1);
|
|
631
|
+
else {
|
|
632
|
+
let g = l;
|
|
633
|
+
for (; g; ) {
|
|
634
|
+
const x = V(g, r, d);
|
|
635
|
+
E(x, r, !1), g = g.slice(x.length), g && J();
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
else if (R + k <= d)
|
|
639
|
+
E(l, r, m);
|
|
640
|
+
else if (J(), M(l, r) <= d)
|
|
641
|
+
E(l, r, !1);
|
|
642
|
+
else {
|
|
643
|
+
let g = l;
|
|
644
|
+
for (; g; ) {
|
|
645
|
+
const x = V(g, r, d);
|
|
646
|
+
E(x, r, !1), g = g.slice(x.length), g && J();
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
let a = !1;
|
|
651
|
+
for (const l of i) {
|
|
652
|
+
if (/^\s+$/.test(l)) {
|
|
653
|
+
a = !0;
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
s(l, a), a = !1;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
J();
|
|
660
|
+
for (let n = 0; n < D.length; n += 1) {
|
|
661
|
+
const r = D[n].segs, i = Math.max(...r.map((a) => a.fs || Z.fs), Z.fs);
|
|
662
|
+
let s = !0;
|
|
663
|
+
for (const a of r) {
|
|
664
|
+
const l = document.createElementNS(et, "tspan");
|
|
665
|
+
s && (l.setAttribute("x", String(t)), n > 0 && l.setAttribute("dy", String(i)), s = !1), l.setAttribute("style", `${C(a)} fill:${a.fill};`), l.textContent = a.text, w.appendChild(l);
|
|
666
|
+
}
|
|
667
|
+
if (!r.length && n > 0) {
|
|
668
|
+
const a = document.createElementNS(et, "tspan");
|
|
669
|
+
a.setAttribute("x", String(t)), a.setAttribute("dy", String(i)), a.textContent = "", w.appendChild(a);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
try {
|
|
673
|
+
A.remove();
|
|
674
|
+
} catch {
|
|
675
|
+
}
|
|
676
|
+
return w;
|
|
677
|
+
} catch {
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
const j = (b) => {
|
|
682
|
+
try {
|
|
683
|
+
const f = document.createElement("div");
|
|
684
|
+
f.style.position = "absolute", f.style.left = "-99999px", f.style.top = "-99999px", f.style.visibility = "hidden", f.style.pointerEvents = "none", f.style.width = "auto", f.style.height = "auto";
|
|
685
|
+
const y = b.cloneNode(!0);
|
|
686
|
+
y.style.width = "auto", y.style.height = "auto", y.style.display = "inline-block", y.style.maxWidth = "none", y.style.maxHeight = "none", y.style.boxSizing = "content-box", document.body.appendChild(f), f.appendChild(y);
|
|
687
|
+
const $ = y.getBoundingClientRect(), z = Math.ceil($.width || y.scrollWidth || 0), L = Math.ceil($.height || y.scrollHeight || 0);
|
|
688
|
+
return f.remove(), { w: Math.max(1, z), h: Math.max(1, L) };
|
|
689
|
+
} catch {
|
|
690
|
+
return { w: 0, h: 0 };
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
for (const b of F)
|
|
694
|
+
try {
|
|
695
|
+
if (b.hasAttribute("data-no-svg-export")) {
|
|
696
|
+
b.remove(), I += 1;
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
if (nt(b)) {
|
|
700
|
+
const f = W(b);
|
|
701
|
+
if (f) {
|
|
702
|
+
b.parentNode.replaceChild(f, b), rt += 1;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
I += 1;
|
|
707
|
+
} catch {
|
|
708
|
+
at += 1;
|
|
709
|
+
}
|
|
710
|
+
if (v === "raster") {
|
|
711
|
+
const b = Array.from(N.querySelectorAll("foreignObject"));
|
|
712
|
+
for (const f of b)
|
|
713
|
+
try {
|
|
714
|
+
if (f.hasAttribute("data-no-svg-export")) {
|
|
715
|
+
f.remove(), I += 1;
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
await new Promise((G) => requestAnimationFrame(G));
|
|
719
|
+
const y = f.getBBox();
|
|
720
|
+
let $ = Math.max(1, Math.ceil(y.width)), z = Math.max(1, Math.ceil(y.height));
|
|
721
|
+
const L = f.firstElementChild;
|
|
722
|
+
if (L) {
|
|
723
|
+
const G = j(L), ut = parseFloat(f.getAttribute("width") || "0") || 0, Z = parseFloat(f.getAttribute("height") || "0") || 0;
|
|
724
|
+
$ = Math.max($, ut, G.w), z = Math.max(z, Z, G.h);
|
|
725
|
+
}
|
|
726
|
+
if (!($ > 0 && z > 0)) {
|
|
727
|
+
I += 1;
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
const O = document.createElementNS(et, "svg");
|
|
731
|
+
O.setAttribute("xmlns", et), O.setAttribute("xmlns:xlink", yt), O.setAttribute("width", String($)), O.setAttribute("height", String(z)), O.setAttribute("viewBox", `0 0 ${$} ${z}`);
|
|
732
|
+
const it = f.cloneNode(!0);
|
|
733
|
+
it.setAttribute("x", "0"), it.setAttribute("y", "0"), it.setAttribute("width", String($)), it.setAttribute("height", String(z)), O.appendChild(it);
|
|
734
|
+
const st = new XMLSerializer().serializeToString(O), dt = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(st), q = document.createElement("canvas"), ht = 2;
|
|
735
|
+
q.width = Math.max(1, Math.floor($ * ht)), q.height = Math.max(1, Math.floor(z * ht));
|
|
736
|
+
const B = q.getContext("2d"), K = new Image();
|
|
737
|
+
K.decoding = "sync", K.crossOrigin = "anonymous", await new Promise((G, ut) => {
|
|
738
|
+
K.onload = G, K.onerror = ut, K.src = dt;
|
|
739
|
+
}), B.drawImage(K, 0, 0, q.width, q.height);
|
|
740
|
+
const ct = q.toDataURL("image/png"), U = document.createElementNS(et, "image");
|
|
741
|
+
U.setAttributeNS(yt, "href", ct), U.setAttribute("href", ct), U.setAttribute("x", f.getAttribute("x") || String(y.x)), U.setAttribute("y", f.getAttribute("y") || String(y.y)), U.setAttribute("width", String($)), U.setAttribute("height", String(z)), f.parentNode.replaceChild(U, f), ot += 1;
|
|
742
|
+
} catch {
|
|
743
|
+
at += 1;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
return { converted: rt, rasterized: ot, skipped: I, errors: at };
|
|
747
|
+
}
|
|
748
|
+
export {
|
|
749
|
+
Ot as u
|
|
750
|
+
};
|