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