vue-data-ui
Version:
A user-empowering data visualization Vue 3 components library for eloquent data storytelling
1,038 lines (1,037 loc) • 43.5 kB
JavaScript
import { defineAsyncComponent as j, ref as u, computed as f, onMounted as Bo, toRefs as Do, watch as xe, createElementBlock as m, openBlock as c, unref as r, normalizeStyle as U, normalizeClass as Ht, createBlock as Q, createCommentVNode as $, createElementVNode as W, createVNode as Oe, withCtx as v, renderSlot as h, normalizeProps as P, guardReactiveProps as I, createSlots as jt, Fragment as he, renderList as ge, withKeys as Je, withModifiers as Qe, toDisplayString as pe, Teleport as Po, resolveDynamicComponent as Io, mergeProps as Mo, createTextVNode as Ut, nextTick as Wt } from "vue";
import { c as _e, t as zo, o as Gt, g as Lo, i as Ro, j as R, k as Yo, U as T, m as Ho, d as le, X as jo, a as Ne, x as Vt, G as Uo, v as Wo, r as Go, y as Vo } from "./lib-2iaAPQ_c.js";
import { t as Xo, u as qo } from "./useResponsive-DfdjqQps.js";
import { u as Ko, a as et } from "./useNestedProp-2p4Tjzc8.js";
import { u as Zo } from "./usePrinter-ChVMpU2f.js";
import { u as Jo, B as Qo } from "./BaseScanner-BMpwQAfz.js";
import { u as el } from "./useSvgExport-ByUukOZt.js";
import { u as tl } from "./useThemeCheck-DGJ31Vi5.js";
import { u as ol } from "./useUserOptionState-BIvW1Kz7.js";
import { u as ll } from "./useChartAccessibility-9icAAmYg.js";
import al from "./Legend-D2xmnFPH.js";
import nl from "./Title-DSOZzIrU.js";
import sl from "./img-CqYIrJ8I.js";
import { _ as rl } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const Xt = { style: { chart: { backgroundColor: "#1A1A1A", color: "#CCCCCC", tooltip: { backgroundColor: "#1A1A1A", backgroundOpacity: 70, color: "#CCCCCC", borderColor: "#5A5A5A" }, legend: { backgroundColor: "#1A1A1A", color: "#CCCCCC" }, title: { color: "#CCCCCC", subtitle: { color: "#757575" } }, nodes: { stroke: "#1A1A1A" }, links: { stroke: "#5A5A5A" } } }, table: { th: { backgroundColor: "#1A1A1A", color: "#CCCCCC" }, td: { backgroundColor: "#1A1A1A", color: "#CCCCCC" } } }, qt = { style: { chart: { backgroundColor: "#FFF8E1", color: "#424242", tooltip: { backgroundColor: "#FFECB3", backgroundOpacity: 30, color: "#424242", borderColor: "#FF8A65" }, legend: { backgroundColor: "#FFF8E1", color: "#424242" }, title: { color: "#424242", subtitle: { color: "#757575" } }, nodes: { stroke: "#3A3A3A" }, links: { stroke: "#3A3A3A" } } }, table: { th: { backgroundColor: "#FFF8E1", color: "#424242" }, td: { backgroundColor: "#FFF8E1", color: "#424242" } } }, Kt = { style: { chart: { backgroundColor: "#1E1E1E", color: "#BDBDBD", tooltip: { backgroundColor: "#1E1E1E", backgroundOpacity: 30, color: "#FFF8E1", borderColor: "#FF8A65" }, title: { color: "#FFF8E1", subtitle: { color: "#BDBDBD" } }, legend: { backgroundColor: "#1E1E1E", color: "#BDBDBD" }, nodes: { stroke: "#1E1E1E" }, links: { stroke: "#1E1E1E" } } }, table: { th: { backgroundColor: "#1E1E1E", color: "#BDBDBD" }, td: { backgroundColor: "#1E1E1E", color: "#BDBDBD" } } }, Zt = { style: { chart: { backgroundColor: "#1A1A1A", color: "#99AA99", tooltip: { backgroundColor: "#2A2F2A", color: "#AACCAA", borderColor: "#66CC66" }, title: { color: "#66CC66", subtitle: { color: "#99AA99" } }, legend: { backgroundColor: "#1A1A1A", color: "#99AA99" }, nodes: { stroke: "#1A1A1A" }, links: { stroke: "#1A1A1A" } } }, table: { th: { backgroundColor: "#1A1A1A", color: "#99AA99" }, td: { backgroundColor: "#1A1A1A", color: "#AACCAA" } } }, Jt = { style: { chart: { backgroundColor: "#fbfafa", color: "#8A9892", tooltip: { backgroundColor: "#fbfafa", color: "#8A9892" }, title: { color: "#8A9892", subtitle: { color: "#99AA99" } }, legend: { backgroundColor: "#fbfafa", color: "#99AA99" }, nodes: { stroke: "#fbfafa" }, links: { stroke: "#fbfafa" } } }, table: { th: { backgroundColor: "#fbfafa", color: "#8F837A" }, td: { backgroundColor: "#fbfafa", color: "#8F837A" } } }, Qt = { style: { chart: { backgroundColor: "#f6f6fb", color: "#50606C", tooltip: { backgroundColor: "#f6f6fb", color: "#50606C" }, title: { color: "#50606C", subtitle: { color: "#718890" } }, legend: { backgroundColor: "#f6f6fb", color: "#61747E" }, nodes: { stroke: "#f6f6fb" }, links: { stroke: "#f6f6fb" } } }, table: { th: { backgroundColor: "#f6f6fb", color: "#50606C" }, td: { backgroundColor: "#f6f6fb", color: "#50606C" } } }, eo = {
default: {},
dark: Xt,
celebration: qt,
celebrationNight: Kt,
hack: Zt,
zen: Jt,
concrete: Qt
}, Yl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
celebration: qt,
celebrationNight: Kt,
concrete: Qt,
dark: Xt,
default: eo,
hack: Zt,
zen: Jt
}, Symbol.toStringTag, { value: "Module" })), ul = ["id"], il = {
key: 1,
ref: "noTitle",
class: "vue-data-ui-no-title-space",
style: "height:36px; width: 100%;background:transparent"
}, cl = ["id"], dl = ["xmlns", "viewBox"], vl = ["width", "height"], fl = ["id"], hl = ["stop-color"], gl = ["stop-color"], pl = ["d", "fill", "stroke", "stroke-width"], bl = ["x", "y", "height", "width", "fill", "stroke", "stroke-width", "rx", "aria-label", "onMouseenter", "onMouseleave", "onClick", "onKeydown", "onFocus", "onBlur"], ml = { key: 1 }, yl = ["x", "y", "font-size", "fill"], Cl = ["x", "y", "font-size", "fill"], kl = {
key: 4,
class: "vue-data-ui-watermark"
}, Al = ["id"], wl = ["onClick"], $l = ["innerHTML"], Tl = {
__name: "vue-ui-flow",
props: {
config: {
type: Object,
default() {
return {};
}
},
dataset: {
type: Array,
default() {
return [];
}
}
},
setup(to, { expose: oo }) {
const lo = j(() => import("./Tooltip-D0pGX8qz.js")), ao = j(() => import("./BaseIcon-CbVDYv89.js")), no = j(() => import("./vue-ui-accordion-Dm0mNNKQ.js")), so = j(() => import("./DataTable-BT_IeqPe.js")), ro = j(() => import("./PenAndPaper-CvyKWfNl.js")), uo = j(() => import("./UserOptions-BQO4YFrn.js")), io = j(() => import("./PackageVersion-Br3DrrFh.js")), co = j(() => import("./BaseDraggableDialog-Z5LfhW87.js")), { vue_ui_flow: vo } = Ko(), { isThemeValid: fo, warnInvalidTheme: ho } = tl(), F = to, G = u(_e()), B = u(null), tt = u(0), ot = u(0), Be = u(!1), De = u(""), lt = u(null), at = u(null), nt = u(null), ae = u(null), be = u(null), st = u(!1), ne = u(null), Pe = u(null), Ie = u(null), rt = f(() => !!F.dataset && F.dataset.length);
Bo(() => {
st.value = !0, it();
});
const V = u(!1);
function ut(o) {
V.value = o, tt.value += 1;
}
const e = u(Ye()), { loading: Me, FINAL_DATASET: me, manualLoading: ze } = Jo({
...Do(F),
FINAL_CONFIG: e,
prepareConfig: Ye,
skeletonDataset: [
["A", "B", 2, "#CACACA"],
["B", "C", 1, "#CACACA"],
["C", "D", 0.5, "#CACACA"],
["E", "F", 1, "#AAAAAA"],
["F", "G", 0.5, "#AAAAAA"],
["G", "H", 0.25, "#AAAAAA"]
],
skeletonConfig: zo({
defaultConfig: e.value,
userConfig: {
userOptions: { show: !1 },
nodeCategories: {
B: "A",
C: "B"
},
nodeCategoryColors: {
A: "#CACACA",
B: "#AAAAAA"
},
table: { show: !1 },
style: {
chart: {
backgroundColor: "#99999930",
legend: {
backgroundColor: "transparent"
},
nodes: {
labels: {
show: !1
},
stroke: "#666666"
},
links: {
stroke: "#666666"
}
}
}
}
})
}), go = f(() => !!e.value.debug);
function it() {
if (Gt(F.dataset) && (Lo({
componentName: "VueUiFlow",
type: "dataset",
debug: go.value
}), ze.value = !0), Gt(F.dataset) || (ze.value = e.value.loading), e.value.responsive) {
const o = Xo(() => {
const { width: l, height: t } = qo({
chart: B.value,
title: e.value.style.chart.title.text ? at.value : null,
legend: e.value.style.chart.legend.show ? lt.value : null,
source: nt.value
});
requestAnimationFrame(() => {
vt.value = l, ft.value = t;
});
});
ae.value && (be.value && ae.value.unobserve(be.value), ae.value.disconnect()), ae.value = new ResizeObserver(o), be.value = B.value.parentNode, ae.value.observe(be.value);
}
}
const { userOptionsVisible: Le, setUserOptionsVisibility: ct, keepUserOptionState: dt } = ol({ config: e.value }), { svgRef: Re } = ll({
config: e.value.style.chart.title
});
function Ye() {
const o = et({
userConfig: F.config,
defaultConfig: vo
});
let l = o;
const t = o.theme;
if (t)
if (!fo.value(o))
ho(o), l = o;
else {
const a = et({
userConfig: eo[t] || F.config,
defaultConfig: o
});
l = {
...et({
userConfig: F.config,
defaultConfig: a
}),
customPalette: o.customPalette.length ? o.customPalette : Ro[t] || R
};
}
else
l = o;
return l.nodeCategories = F.config.nodeCategories || {}, l.nodeCategoryColors = F.config.nodeCategoryColors || {}, l;
}
const vt = u(e.value.style.chart.width), ft = u(e.value.style.chart.height);
xe(
() => F.config,
(o) => {
Me.value || (e.value = Ye()), Le.value = !e.value.userOptions.showOnChartHover, it(), ot.value += 1, S.value.showTable = e.value.table.show;
},
{ deep: !0 }
), xe(() => F.dataset, (o) => {
Array.isArray(o) && o.length > 0 && (ze.value = !1);
}, { deep: !0 });
const { isPrinting: ht, isImaging: gt, generatePdf: pt, generateImage: bt } = Zo({
elementId: `flow_${G.value}`,
fileName: e.value.style.chart.title.text || "vue-ui-flow",
options: e.value.userOptions.print
}), po = f(() => e.value.userOptions.show && !e.value.style.chart.title.text), ye = f(() => Yo(e.value.customPalette)), Ce = f(() => e.value.style.chart.nodes.width), S = u({
showTable: e.value.table.show,
showTooltip: e.value.style.chart.tooltip.show
});
xe(e, () => {
S.value = {
showTable: e.value.table.show,
showTooltip: e.value.style.chart.tooltip.show
};
}, { immediate: !0 });
const mt = f(() => !me.value || !me.value.length ? [] : me.value.map((o, l) => [
o[0],
o[1],
T(o[2]),
o[3] ? Ho(o[3]) : ye.value[l] || ye.value[l % ye.value.length] || R[l] || R[l % R.length]
]));
function bo(o) {
const l = {}, t = {};
function a(n, i) {
l[n] || (l[n] = {
level: null,
inflow: 0,
outflow: 0,
children: [],
color: null,
uid: _e()
}), l[n].level === null && (l[n].level = i), t[i] || (t[i] = []), t[i].includes(n) || t[i].push(n);
}
o.forEach(([n, i, g]) => {
const p = l[n]?.level ?? 0, D = p + 1;
a(n, p), a(i, D), l[n].children.push({ target: i, value: g }), l[n].outflow += g, l[i].inflow += g;
});
const s = new Set(o.map(([n]) => n)), w = new Set(o.map(([, n]) => n)), te = Array.from(s).filter((n) => !w.has(n)), ce = {};
te.forEach((n, i) => {
ce[n] = ye.value[i] || R[i % R.length];
});
const de = {};
o.forEach(([n, i, g, p]) => {
p && (de[n] = p, de[i] = p);
}), Object.keys(l).forEach((n, i) => {
const g = e.value.nodeCategories?.[n], p = g ? e.value.nodeCategoryColors?.[g] : null;
l[n].color = de[n] || p || (te.includes(n) ? ce[n] : null) || R[i % R.length];
}), Object.keys(l).forEach((n) => {
l[n].value = Math.max(l[n].inflow, l[n].outflow);
});
const Fe = se.value, Ve = kt.value.width, oe = kt.value.height, z = Object.keys(t).map(Number).sort((n, i) => n - i), Se = z.length || 1, Xe = Se > 1 ? Ve / (Se - 1) : 0, x = Number(Ce.value), M = Number(
e.value.style.chart.nodes.gapPx ?? e.value.style.chart.nodes.gap ?? 8
), ve = Number(
e.value.style.chart.nodes.minHeight || 0
);
function d(n) {
const i = t[n], g = i.length;
if (!g) return 1 / 0;
const p = Math.max(0, (g - 1) * M), D = Math.max(0, oe - p), Y = Math.min(ve, g ? D / g : 0);
let C = 0, O = i.map((b) => l[b].value || 0), k = O.reduce((b, _) => b + _, 0);
for (let b = 0; b < 12; b += 1) {
const _ = k > 0 ? (D - C) / k : 0, H = [];
for (let N = 0; N < O.length; N += 1) {
const L = O[N];
L < 0 || L * _ < Y && H.push(N);
}
if (!H.length) return Math.max(0, _);
for (const N of H)
C += Y, k -= O[N], O[N] = -1;
if (k <= 0) return 0;
}
return k > 0 ? Math.max(0, (D - C) / k) : 0;
}
const y = z.map(d), q = y.length ? Math.min(...y) : 0, K = {};
z.forEach((n) => {
const i = t[n], g = i.length, p = Math.max(0, (g - 1) * M), D = Math.max(0, oe - p), Y = Math.min(ve, g ? D / g : 0), C = i.map(
(b) => Math.max(Y, (l[b].value || 0) * q)
), O = C.reduce((b, _) => b + _, 0) + p;
let k = Math.max(0, (oe - O) / 2);
i.forEach((b, _) => {
const H = C[_], N = Fe.left + n * Xe, L = k;
K[b] = {
x: N,
y: L,
absoluteY: L,
height: H,
i: _,
color: l[b].color,
value: l[b].value,
id: _e()
}, k += H, _ < g - 1 && (k += M);
});
});
const xt = [], fe = Fe.top, qe = {}, Ke = {};
Object.keys(l).forEach((n) => {
qe[n] = K[n]?.y ?? 0, Ke[n] = 0;
});
const xo = 1e-6, Oo = 0.25, _o = !!e.value.style.chart.links.smooth, Ot = 0.5;
return z.forEach((n) => {
t[n].forEach((g) => {
const p = l[g], D = K[g];
if (!p.children || !p.children.length) return;
let Y = D.y;
p.children.forEach(({ target: C, value: O }) => {
const k = K[C], b = l[C], _ = p.outflow > 0 ? O / p.outflow : 0, H = b.inflow > 0 ? O / b.inflow : 0, N = T(Y + fe), L = T(
Y + _ * D.height + fe
), _t = qe[C];
let Ee = _t + H * k.height;
Ke[C] += O;
const No = b.inflow > 0 && Ke[C] >= b.inflow - xo, Nt = k.y + k.height;
(No || Ee > Nt - Oo) && (Ee = Nt);
const Bt = T(_t + fe), Dt = T(Ee + fe), Z = T(D.x + x), J = T(k.x);
let Ze;
if (!_o || J <= Z)
Ze = `M ${Z} ${N} L ${Z} ${L} L ${J} ${Dt} L ${J} ${Bt} Z`;
else {
const Pt = J - Z, It = T(Z + Pt * Ot), Mt = T(J - Pt * Ot), zt = N, Lt = Bt, Rt = L, Yt = Dt;
Ze = `M ${Z} ${zt} C ${It} ${zt}, ${Mt} ${Lt}, ${J} ${Lt} L ${J} ${Yt} C ${Mt} ${Yt}, ${It} ${Rt}, ${Z} ${Rt} Z`;
}
xt.push({
id: _e(),
source: g,
target: C,
path: Ze,
value: O,
sourceColor: p.color,
targetColor: l[C].color
}), Y = L - fe, qe[C] = Ee;
});
});
}), { nodeCoordinates: K, links: xt };
}
const E = f(() => {
const o = bo(me.value);
return {
nodes: Object.keys(o.nodeCoordinates).map((l, t) => ({
...o.nodeCoordinates[l],
name: l
})),
links: o.links
};
}), yt = f(() => vt.value), Ct = f(() => ft.value), se = f(() => e.value.style.chart.padding), kt = f(() => ({
width: Math.max(0, yt.value - 40 - se.value.right - se.value.left),
height: Math.max(0, Ct.value - se.value.top - se.value.bottom)
})), re = f(() => ({
width: yt.value,
height: Ct.value
}));
function mo(o) {
const l = {}, t = {}, a = /* @__PURE__ */ new Set();
return mt.value.forEach(([s, w, te]) => {
l[s] || (l[s] = []), t[w] || (t[w] = []), l[s].push(w), t[w].push(s);
}), l[o] && l[o].forEach((s) => a.add(s)), t[o] && t[o].forEach((s) => a.add(s)), Array.from(a).concat(o);
}
const A = u(null), ee = u(null), ue = u(null), ke = u(!1), Ae = u(null);
function At(o, l) {
X.value = [], A.value = mo(o.name), ee.value = o.name, Ae.value = o.id;
const t = o.name, a = mt.value;
let s = 0, w = 0, te = [], ce = [];
const de = new Set(a.map(([d]) => d)), Fe = new Set(a.map(([, d]) => d)), Ve = Array.from(de).filter((d) => !Fe.has(d)), oe = a.filter(([d]) => Ve.includes(d)).reduce((d, [y, q, K]) => d + K, 0), z = {};
E.value.nodes.forEach((d) => {
z[d.name] = d.color;
}), a.forEach(([d, y, q]) => {
y === t && (s += q, te.push({ source: d, value: q, color: z[d] })), d === t && (w += q, ce.push({ target: y, value: q, color: z[y] }));
});
const Se = Math.max(s, w), Xe = oe > 0 ? Se / oe * 100 : 0, x = {
name: t,
inflow: s,
outflow: w,
from: te,
to: ce,
percentOfTotal: Xe,
color: z[t] || "#000000"
};
e.value.events.datapointEnter && e.value.events.datapointEnter({ datapoint: x, seriesIndex: l }), ue.value = { datapoint: x }, Be.value = !0;
let M = "";
const ve = e.value.style.chart.tooltip.customFormat;
if (ke.value = !1, Vo(ve))
try {
const d = ve({
datapoint: x,
series: E.value,
config: e.value
});
typeof d == "string" && (De.value = d, ke.value = !0);
} catch {
console.warn("Custom format cannot be applied.");
}
if (!ke.value) {
const d = e.value.style.chart.tooltip.showPercentage ? `<div>${le({
p: e.value.style.chart.tooltip.translations.percentOfTotal,
v: x.percentOfTotal,
s: "%",
r: e.value.style.chart.tooltip.roundingPercentage
})}</div>` : "";
M += `<div style="width:100%;text-align:center;border-bottom:1px solid ${e.value.style.chart.tooltip.borderColor};padding-bottom:6px;margin-bottom:3px;"><span style="margin-right:4px; color:${x.color}">⏹</span>${x.name}${d}</div>`, x.from.length && (M += `<div>${e.value.style.chart.tooltip.translations.from}</div>`, x.from.forEach((y) => {
M += `<div><span style="color:${y.color}">⏹←</span> ${y.source}: ${Ne(
e.value.style.chart.nodes.labels.formatter,
y.value,
le({
p: e.value.style.chart.nodes.labels.prefix,
v: y.value,
s: e.value.style.chart.nodes.labels.suffix,
r: e.value.style.chart.nodes.labels.rounding
})
)}</div>`;
})), x.to.length && (M += `<div style="margin-top:6px;">${e.value.style.chart.tooltip.translations.to}</div>`, x.to.forEach((y) => {
M += `<div><span style="color:${y.color}">⏹→</span> ${y.target}: ${Ne(
e.value.style.chart.nodes.labels.formatter,
y.value,
le({
p: e.value.style.chart.nodes.labels.prefix,
v: y.value,
s: e.value.style.chart.nodes.labels.suffix,
r: e.value.style.chart.nodes.labels.rounding
})
)}</div>`;
})), De.value = M;
}
}
function we(o) {
Ae.value = null;
const l = ue.value;
e.value.events.datapointLeave && e.value.events.datapointLeave({ datapoint: l, seriesIndex: o }), A.value = null, ee.value = null, Be.value = !1;
}
function He(o) {
const l = ue.value;
e.value.events.datapointClick && e.value.events.datapointClick({ datapoint: l, seriesIndex: o });
}
const wt = f(() => E.value.links.map(
({ source: o, target: l, sourceColor: t, targetColor: a, value: s }) => ({
source: o,
target: l,
sourceColor: t,
targetColor: a,
value: s
})
));
function je(o = null) {
Wt(() => {
const l = wt.value.map((s, w) => [[s.source], [s.target], [s.value]]), t = [
[e.value.style.chart.title.text],
[e.value.style.chart.title.subtitle.text],
[
[e.value.table.columnNames.source],
[e.value.table.columnNames.target],
[e.value.table.columnNames.value]
]
].concat(l), a = Wo(t);
o ? o(a) : Go({
csvContent: a,
title: e.value.style.chart.title.text || "vue-ui-flow"
});
});
}
const $e = f(() => {
const o = [
e.value.table.columnNames.source,
e.value.table.columnNames.target,
e.value.table.columnNames.value
], l = wt.value.map((s, w) => [
{
color: s.sourceColor,
name: s.source,
shape: "square"
},
{
color: s.targetColor,
name: s.target,
shape: "square"
},
le({
p: e.value.style.chart.nodes.labels.prefix,
v: s.value,
s: e.value.style.chart.nodes.labels.suffix,
r: e.value.style.chart.nodes.labels.rounding
})
]), t = {
th: {
backgroundColor: e.value.table.th.backgroundColor,
color: e.value.table.th.color,
outline: e.value.table.th.outline
},
td: {
backgroundColor: e.value.table.td.backgroundColor,
color: e.value.table.td.color,
outline: e.value.table.td.outline
},
breakpoint: e.value.table.responsiveBreakpoint
};
return {
colNames: [
e.value.table.columnNames.source,
e.value.table.columnNames.target,
e.value.table.columnNames.value
],
head: o,
body: l,
config: t
};
});
function yo() {
return E.value;
}
function $t() {
S.value.showTable = !S.value.showTable;
}
const Te = u(!1);
function Ue() {
Te.value = !Te.value;
}
function Tt() {
S.value.showTooltip = !S.value.showTooltip;
}
const Ft = f(() => {
const o = new Set(
E.value.nodes.map(
(l) => e.value.nodeCategories[l.name] || "__uncategorized__"
)
);
return Array.from(o).map((l) => ({
name: l,
color: e.value.nodeCategoryColors[l] || R[0],
shape: "square",
count: E.value.nodes.filter(
(t) => (e.value.nodeCategories[t.name] || "__uncategorized__") === l
).length
})).map((l, t) => ({
...l,
segregate: () => Ge({ legend: l, i: t }),
opacity: X.value.length ? X.value.includes(t) ? 1 : 0.5 : 1,
display: `${l.name} (${l.count})`
}));
}), We = f(
() => Ft.value.filter((o) => o.name !== "__uncategorized__")
), X = u([]);
function Ge({ legend: o, i: l }) {
const t = o.name;
if (A.value?.every(
(a) => e.value.nodeCategories[a] === t
)) {
A.value = null, ee.value = null, X.value = [];
return;
}
X.value = [l], A.value = E.value.nodes.filter((a) => e.value.nodeCategories[a.name] === t).map((a) => a.name), ee.value = null;
}
const Co = f(() => ({
cy: "flow-legend",
backgroundColor: e.value.style.chart.legend.backgroundColor,
color: e.value.style.chart.legend.color,
fontSize: e.value.style.chart.legend.fontSize,
paddingBottom: e.value.style.chart.legend.paddingBottom,
fontWeight: e.value.style.chart.legend.bold ? "bold" : "normal"
}));
async function ko({ scale: o = 2 } = {}) {
if (!B.value) return;
const { width: l, height: t } = B.value.getBoundingClientRect(), a = l / t, { imageUri: s, base64: w } = await sl({ domElement: B.value, base64: !0, img: !0, scale: o });
return {
imageUri: s,
base64: w,
title: e.value.style.chart.title.text,
width: l,
height: t,
aspectRatio: a
};
}
const ie = f(() => {
const o = e.value.table.useDialog && !e.value.table.show, l = S.value.showTable;
return {
component: o ? co : no,
title: `${e.value.style.chart.title.text}${e.value.style.chart.title.subtitle.text ? `: ${e.value.style.chart.title.subtitle.text}` : ""}`,
props: o ? {
backgroundColor: e.value.table.th.backgroundColor,
color: e.value.table.th.color,
headerColor: e.value.table.th.color,
headerBg: e.value.table.th.backgroundColor,
isFullscreen: V.value,
fullscreenParent: B.value,
forcedWidth: Math.min(800, window.innerWidth * 0.8)
} : {
hideDetails: !0,
config: {
open: l,
maxHeight: 1e4,
body: {
backgroundColor: e.value.style.chart.backgroundColor,
color: e.value.style.chart.color
},
head: {
backgroundColor: e.value.style.chart.backgroundColor,
color: e.value.style.chart.color
}
}
}
};
});
xe(() => S.value.showTable, (o) => {
e.value.table.show || (o && e.value.table.useDialog && ne.value ? ne.value.open() : "close" in ne.value && ne.value.close());
});
function St() {
S.value.showTable = !1, Pe.value && Pe.value.setTableIconState(!1);
}
const Ao = f(() => We.value.map((o) => ({
...o,
name: o.display
}))), wo = f(() => e.value.style.chart.backgroundColor), $o = f(() => e.value.style.chart.legend), To = f(() => e.value.style.chart.title), { exportSvg: Fo, getSvg: So } = el({
svg: Re,
title: To,
legend: $o,
legendItems: Ao,
backgroundColor: wo
});
async function Et({ isCb: o }) {
if (o) {
const { blob: l, url: t, text: a, dataUrl: s } = await So();
e.value.userOptions.callbacks.svg({ blob: l, url: t, text: a, dataUrl: s });
} else
Fo();
}
async function Eo(o, l) {
if (At(o, l), S.value.showTooltip && (await Wt(), B.value && Ie.value)) {
const { left: t, top: a } = B.value.getBoundingClientRect();
Ie.value.placeTooltip({ x: (t ?? 0) + 12, y: (a ?? 0) + 12 });
}
}
return oo({
getData: yo,
getImage: ko,
generateCsv: je,
generateImage: bt,
generateSvg: Et,
generatePdf: pt,
toggleTable: $t,
toggleAnnotator: Ue,
toggleTooltip: Tt,
drillCategory: Ge,
unselectNode: we,
toggleFullscreen: ut
}), (o, l) => (c(), m("div", {
ref_key: "flowChart",
ref: B,
class: Ht(`vue-data-ui-component vue-ui-flow ${V.value ? "vue-data-ui-wrapper-fullscreen" : ""}`),
style: U(`font-family:${e.value.style.fontFamily};width:100%; text-align:center;background:${e.value.style.chart.backgroundColor}`),
id: `flow_${G.value}`,
onMouseenter: l[2] || (l[2] = () => r(ct)(!0)),
onMouseleave: l[3] || (l[3] = () => r(ct)(!1))
}, [
e.value.userOptions.buttons.annotator ? (c(), Q(r(ro), {
key: 0,
svgRef: r(Re),
backgroundColor: e.value.style.chart.backgroundColor,
color: e.value.style.chart.color,
active: Te.value,
onClose: Ue
}, {
"annotator-action-close": v(() => [
h(o.$slots, "annotator-action-close", {}, void 0, !0)
]),
"annotator-action-color": v(({ color: t }) => [
h(o.$slots, "annotator-action-color", P(I({ color: t })), void 0, !0)
]),
"annotator-action-draw": v(({ mode: t }) => [
h(o.$slots, "annotator-action-draw", P(I({ mode: t })), void 0, !0)
]),
"annotator-action-undo": v(({ disabled: t }) => [
h(o.$slots, "annotator-action-undo", P(I({ disabled: t })), void 0, !0)
]),
"annotator-action-redo": v(({ disabled: t }) => [
h(o.$slots, "annotator-action-redo", P(I({ disabled: t })), void 0, !0)
]),
"annotator-action-delete": v(({ disabled: t }) => [
h(o.$slots, "annotator-action-delete", P(I({ disabled: t })), void 0, !0)
]),
_: 3
}, 8, ["svgRef", "backgroundColor", "color", "active"])) : $("", !0),
po.value ? (c(), m("div", il, null, 512)) : $("", !0),
e.value.style.chart.title.text ? (c(), m("div", {
key: 2,
ref_key: "chartTitle",
ref: at,
style: "width:100%;background:transparent;padding-bottom:24px"
}, [
(c(), Q(nl, {
key: `title_${ot.value}`,
config: {
title: {
cy: "flow-title",
...e.value.style.chart.title
},
subtitle: {
cy: "flow-subtitle",
...e.value.style.chart.title.subtitle
}
}
}, null, 8, ["config"]))
], 512)) : $("", !0),
W("div", {
id: `legend-top-${G.value}`
}, null, 8, cl),
e.value.userOptions.show && rt.value && (r(dt) || r(Le)) ? (c(), Q(r(uo), {
ref_key: "userOptionsRef",
ref: Pe,
key: `user_option_${tt.value}`,
backgroundColor: e.value.style.chart.backgroundColor,
color: e.value.style.chart.color,
isPrinting: r(ht),
isImaging: r(gt),
uid: G.value,
hasPdf: e.value.userOptions.buttons.pdf,
hasXls: e.value.userOptions.buttons.csv,
hasImg: e.value.userOptions.buttons.img,
hasSvg: e.value.userOptions.buttons.svg,
hasTable: e.value.userOptions.buttons.table,
callbacks: e.value.userOptions.callbacks,
hasFullscreen: e.value.userOptions.buttons.fullscreen,
isFullscreen: V.value,
titles: { ...e.value.userOptions.buttonTitles },
chartElement: B.value,
position: e.value.userOptions.position,
hasAnnotator: e.value.userOptions.buttons.annotator,
printScale: e.value.userOptions.print.scale,
isAnnotation: Te.value,
hasTooltip: e.value.style.chart.tooltip.show && e.value.userOptions.buttons.tooltip,
isTooltip: S.value.showTooltip,
tableDialog: e.value.table.useDialog,
onToggleTooltip: Tt,
onToggleFullscreen: ut,
onGeneratePdf: r(pt),
onGenerateCsv: je,
onGenerateImage: r(bt),
onGenerateSvg: Et,
onToggleTable: $t,
onToggleAnnotator: Ue,
style: U({
visibility: r(dt) ? r(Le) ? "visible" : "hidden" : "visible"
})
}, jt({ _: 2 }, [
o.$slots.menuIcon ? {
name: "menuIcon",
fn: v(({ isOpen: t, color: a }) => [
h(o.$slots, "menuIcon", P(I({ isOpen: t, color: a })), void 0, !0)
]),
key: "0"
} : void 0,
o.$slots.optionTooltip ? {
name: "optionTooltip",
fn: v(() => [
h(o.$slots, "optionTooltip", {}, void 0, !0)
]),
key: "1"
} : void 0,
o.$slots.optionPdf ? {
name: "optionPdf",
fn: v(() => [
h(o.$slots, "optionPdf", {}, void 0, !0)
]),
key: "2"
} : void 0,
o.$slots.optionCsv ? {
name: "optionCsv",
fn: v(() => [
h(o.$slots, "optionCsv", {}, void 0, !0)
]),
key: "3"
} : void 0,
o.$slots.optionImg ? {
name: "optionImg",
fn: v(() => [
h(o.$slots, "optionImg", {}, void 0, !0)
]),
key: "4"
} : void 0,
o.$slots.optionSvg ? {
name: "optionSvg",
fn: v(() => [
h(o.$slots, "optionSvg", {}, void 0, !0)
]),
key: "5"
} : void 0,
o.$slots.optionTable ? {
name: "optionTable",
fn: v(() => [
h(o.$slots, "optionTable", {}, void 0, !0)
]),
key: "6"
} : void 0,
o.$slots.optionFullscreen ? {
name: "optionFullscreen",
fn: v(({ toggleFullscreen: t, isFullscreen: a }) => [
h(o.$slots, "optionFullscreen", P(I({ toggleFullscreen: t, isFullscreen: a })), void 0, !0)
]),
key: "7"
} : void 0,
o.$slots.optionAnnotator ? {
name: "optionAnnotator",
fn: v(({ toggleAnnotator: t, isAnnotator: a }) => [
h(o.$slots, "optionAnnotator", P(I({ toggleAnnotator: t, isAnnotator: a })), void 0, !0)
]),
key: "8"
} : void 0
]), 1032, ["backgroundColor", "color", "isPrinting", "isImaging", "uid", "hasPdf", "hasXls", "hasImg", "hasSvg", "hasTable", "callbacks", "hasFullscreen", "isFullscreen", "titles", "chartElement", "position", "hasAnnotator", "printScale", "isAnnotation", "hasTooltip", "isTooltip", "tableDialog", "onGeneratePdf", "onGenerateImage", "style"])) : $("", !0),
(c(), m("svg", {
ref_key: "svgRef",
ref: Re,
xmlns: r(jo),
viewBox: `0 0 ${re.value.width} ${re.value.height}`,
class: Ht({
"vue-data-ui-fullscreen--on": V.value,
"vue-data-ui-fulscreen--off": !V.value
}),
style: U({
maxWidth: "100%",
overflow: "visible",
background: "transparent",
color: e.value.style.chart.color
})
}, [
Oe(r(io)),
o.$slots["chart-background"] ? (c(), m("foreignObject", {
key: 0,
x: 0,
y: 0,
width: re.value.width,
height: re.value.height,
style: {
pointerEvents: "none"
}
}, [
h(o.$slots, "chart-background", {}, void 0, !0)
], 8, vl)) : $("", !0),
W("defs", null, [
(c(!0), m(he, null, ge(E.value.links, (t, a) => (c(), m("linearGradient", {
id: t.id,
x1: "0%",
y1: "0%",
x2: "100%",
y2: "0%"
}, [
W("stop", {
offset: "0%",
"stop-color": t.sourceColor
}, null, 8, hl),
W("stop", {
offset: "100%",
"stop-color": t.targetColor
}, null, 8, gl)
], 8, fl))), 256))
]),
(c(!0), m(he, null, ge(E.value.links, (t) => (c(), m("path", {
class: "vue-ui-flow-link",
d: t.path,
"stroke-linejoin": "round",
"stroke-miterlimit": "1",
fill: `url(#${t.id})`,
stroke: e.value.style.chart.links.stroke,
"stroke-width": e.value.style.chart.links.strokeWidth,
style: U(`
opacity:${A.value ? A.value.includes(t.source) && A.value.includes(t.target) ? 1 : 0.3 : ee.value ? [t.target, t.source].includes(ee.value) ? 1 : 0.3 : e.value.style.chart.links.opacity}
`)
}, null, 12, pl))), 256)),
(c(!0), m(he, null, ge(E.value.nodes, (t, a) => (c(), m("rect", {
class: "vue-ui-flow-node",
x: t.x,
y: r(T)(t.absoluteY) + e.value.style.chart.padding.top,
height: r(T)(t.height),
width: Ce.value,
fill: t.color,
stroke: e.value.style.chart.nodes.stroke,
"stroke-width": e.value.style.chart.nodes.strokeWidth,
rx: e.value.style.chart.nodes.borderRadius,
style: U({
opacity: A.value ? A.value.includes(t.name) ? 1 : 0.3 : 1,
outline: Ae.value !== null && Ae.value === t.id ? "2px solid currentColor" : void 0
}),
role: "button",
tabindex: "0",
"aria-label": `${t.name}: ${r(Ne)(
e.value.style.chart.nodes.labels.formatter,
t.value,
r(le)({
p: e.value.style.chart.nodes.labels.prefix,
v: t.value,
s: e.value.style.chart.nodes.labels.suffix,
r: e.value.style.chart.nodes.labels.rounding
})
)}`,
onMouseenter: (s) => At(t, a),
onMouseleave: (s) => we(a),
onClick: (s) => He(a),
onKeydown: [
Je(Qe((s) => He(a), ["prevent"]), ["enter"]),
Je(Qe((s) => He(a), ["prevent"]), ["space"]),
Je(Qe((s) => we(a), ["prevent"]), ["esc"])
],
onFocus: (s) => Eo(t, a),
onBlur: (s) => we(a)
}, null, 44, bl))), 256)),
e.value.style.chart.nodes.labels.show ? (c(), m("g", ml, [
(c(!0), m(he, null, ge(E.value.nodes, (t, a) => (c(), m("text", {
x: t.x + Ce.value / 2,
y: (e.value.style.chart.nodes.labels.showValue ? r(T)(
t.absoluteY + t.height / 2 - e.value.style.chart.nodes.labels.fontSize / 4
) : t.absoluteY + t.height / 2 + e.value.style.chart.nodes.labels.fontSize / 3) + e.value.style.chart.padding.top,
"font-size": e.value.style.chart.nodes.labels.fontSize,
fill: r(Vt)(t.color),
"text-anchor": "middle",
style: U(`pointer-events: none; opacity:${A.value ? A.value.includes(t.name) ? 1 : 0 : 1}`)
}, pe(e.value.style.chart.nodes.labels.abbreviation.use ? r(Uo)({
source: t.name,
length: e.value.style.chart.nodes.labels.abbreviation.length
}) : t.name), 13, yl))), 256)),
e.value.style.chart.nodes.labels.showValue ? (c(!0), m(he, { key: 0 }, ge(E.value.nodes, (t, a) => (c(), m("text", {
x: t.x + Ce.value / 2,
y: r(T)(
t.absoluteY + t.height / 2 + e.value.style.chart.nodes.labels.fontSize / 1.3
) + e.value.style.chart.padding.top,
"font-size": e.value.style.chart.nodes.labels.fontSize,
fill: r(Vt)(t.color),
"text-anchor": "middle",
style: U(`pointer-events: none; opacity:${A.value ? A.value.includes(t.name) ? 1 : 0 : 1}`)
}, pe(r(Ne)(
e.value.style.chart.nodes.labels.formatter,
t.value,
r(le)({
p: e.value.style.chart.nodes.labels.prefix,
v: t.value,
s: e.value.style.chart.nodes.labels.suffix,
r: e.value.style.chart.nodes.labels.rounding
}),
{ datapoint: t, seriesIndex: a }
)), 13, Cl))), 256)) : $("", !0)
])) : $("", !0),
h(o.$slots, "svg", { svg: re.value }, void 0, !0)
], 14, dl)),
o.$slots.watermark ? (c(), m("div", kl, [
h(o.$slots, "watermark", P(I({ isPrinting: r(ht) || r(gt) })), void 0, !0)
])) : $("", !0),
W("div", {
id: `legend-bottom-${G.value}`
}, null, 8, Al),
st.value ? (c(), Q(Po, {
key: 5,
to: e.value.style.chart.legend.position === "top" ? `#legend-top-${G.value}` : `#legend-bottom-${G.value}`
}, [
W("div", {
ref_key: "chartLegend",
ref: lt
}, [
e.value.style.chart.legend.show && We.value.length ? (c(), Q(al, {
key: 0,
legendSet: We.value,
config: Co.value,
onClickMarker: l[0] || (l[0] = (t) => Ge(t))
}, {
item: v(({ legend: t, index: a }) => [
r(Me) ? $("", !0) : (c(), m("div", {
key: 0,
onClick: (s) => t.segregate(),
style: U(`opacity:${X.value.length ? X.value.includes(a) ? 1 : 0.5 : 1}`)
}, pe(t.display), 13, wl))
]),
_: 1
}, 8, ["legendSet", "config"])) : $("", !0),
h(o.$slots, "legend", { legend: Ft.value }, void 0, !0)
], 512)
], 8, ["to"])) : $("", !0),
o.$slots.source ? (c(), m("div", {
key: 6,
ref_key: "source",
ref: nt,
dir: "auto"
}, [
h(o.$slots, "source", {}, void 0, !0)
], 512)) : $("", !0),
Oe(r(lo), {
ref_key: "tooltip",
ref: Ie,
show: S.value.showTooltip && Be.value,
backgroundColor: e.value.style.chart.tooltip.backgroundColor,
color: e.value.style.chart.tooltip.color,
fontSize: e.value.style.chart.tooltip.fontSize,
borderRadius: e.value.style.chart.tooltip.borderRadius,
borderColor: e.value.style.chart.tooltip.borderColor,
borderWidth: e.value.style.chart.tooltip.borderWidth,
backgroundOpacity: e.value.style.chart.tooltip.backgroundOpacity,
position: e.value.style.chart.tooltip.position,
offsetY: e.value.style.chart.tooltip.offsetY,
parent: B.value,
content: De.value,
isCustom: ke.value,
isFullscreen: V.value,
smooth: e.value.style.chart.tooltip.smooth,
backdropFilter: e.value.style.chart.tooltip.backdropFilter,
smoothForce: e.value.style.chart.tooltip.smoothForce,
smoothSnapThreshold: e.value.style.chart.tooltip.smoothSnapThreshold
}, {
"tooltip-before": v(() => [
h(o.$slots, "tooltip-before", P(I({ ...ue.value })), void 0, !0)
]),
"tooltip-after": v(() => [
h(o.$slots, "tooltip-after", P(I({ ...ue.value })), void 0, !0)
]),
_: 3
}, 8, ["show", "backgroundColor", "color", "fontSize", "borderRadius", "borderColor", "borderWidth", "backgroundOpacity", "position", "offsetY", "parent", "content", "isCustom", "isFullscreen", "smooth", "backdropFilter", "smoothForce", "smoothSnapThreshold"]),
rt.value && e.value.userOptions.buttons.table ? (c(), Q(Io(ie.value.component), Mo({ key: 7 }, ie.value.props, {
ref_key: "tableUnit",
ref: ne,
onClose: St
}), jt({
content: v(() => [
Oe(r(so), {
colNames: $e.value.colNames,
head: $e.value.head,
body: $e.value.body,
config: $e.value.config,
title: e.value.table.useDialog ? "" : ie.value.title,
withCloseButton: !e.value.table.useDialog,
onClose: St
}, {
th: v(({ th: t }) => [
W("div", {
innerHTML: t,
style: { display: "flex", "align-items": "center" }
}, null, 8, $l)
]),
td: v(({ td: t }) => [
Ut(pe(t.name || t), 1)
]),
_: 1
}, 8, ["colNames", "head", "body", "config", "title", "withCloseButton"])
]),
_: 2
}, [
e.value.table.useDialog ? {
name: "title",
fn: v(() => [
Ut(pe(ie.value.title), 1)
]),
key: "0"
} : void 0,
e.value.table.useDialog ? {
name: "actions",
fn: v(() => [
W("button", {
tabindex: "0",
class: "vue-ui-user-options-button",
onClick: l[1] || (l[1] = (t) => je(e.value.userOptions.callbacks.csv))
}, [
Oe(r(ao), {
name: "excel",
stroke: ie.value.props.color
}, null, 8, ["stroke"])
])
]),
key: "1"
} : void 0
]), 1040)) : $("", !0),
r(Me) ? (c(), Q(Qo, { key: 8 })) : $("", !0)
], 46, ul));
}
}, Fl = /* @__PURE__ */ rl(Tl, [["__scopeId", "data-v-b23619de"]]), Hl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Fl
}, Symbol.toStringTag, { value: "Module" }));
export {
Yl as a,
Hl as b,
Fl as v
};