vue-data-ui
Version:
A user-empowering data visualization Vue 3 components library for eloquent data storytelling
326 lines (325 loc) • 16.3 kB
JavaScript
import { useCssVars as ae, computed as V, defineAsyncComponent as o, ref as r, watch as ie, createElementBlock as y, openBlock as g, createCommentVNode as N, createElementVNode as b, normalizeStyle as S, createStaticVNode as ne, Fragment as W, renderList as le, normalizeClass as re, renderSlot as z, createBlock as se, resolveDynamicComponent as de, mergeProps as ce } from "vue";
import he from "./pdf-DflC6mtT.js";
import { u as ve } from "./useNestedProp-D8sa_wYF.js";
import { u as pe, c as fe } from "./index-CO-5OgQA.js";
import { _ as me } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const ge = {
key: 0,
"data-dom-to-png-ignore": "",
style: { width: "100%", display: "flex", "justify-content": "end" }
}, be = ["disabled"], Ue = ["stroke"], Ve = { key: 1 }, ye = ["id"], we = ["onMousedown", "onTouchstart"], ke = ["onMousedown", "onTouchstart"], Te = ["onMousedown", "onTouchstart"], Me = ["onMousedown", "onTouchstart"], Ce = ["onMousedown", "onTouchstart"], $ = 1, _e = {
__name: "vue-ui-dashboard",
props: {
dataset: Array,
config: Object
},
emits: ["change"],
setup(R, { expose: B, emit: E }) {
ae((e) => ({
"56f02d00": J.value,
"2fbe8dda": Z.value
}));
const L = {
VueDataUi: o(() => import("./vue-data-ui-DaG_fJyV.js")),
VueUi3dBar: o(() => import("./vue-ui-3d-bar-CKaPvMis.js")),
VueUiAccordion: o(() => import("./vue-ui-accordion-RRHvINsj.js")),
VueUiAgePyramid: o(() => import("./vue-ui-age-pyramid-BsfpBP5o.js")),
VueUiAnnotator: o(() => import("./vue-ui-annotator-CSSRY4KB.js")),
VueUiCandlestick: o(() => import("./vue-ui-candlestick-DLPBk-z0.js")),
VueUiChestnut: o(() => import("./vue-ui-chestnut-D_GtQRUL.js")),
VueUiDigits: o(() => import("./vue-ui-digits-B3J16TA3.js")),
VueUiDonut: o(() => import("./vue-ui-donut-DUAbkhZV.js")),
VueUiDonutEvolution: o(() => import("./vue-ui-donut-evolution-BlMjAI3c.js")),
VueUiDumbbell: o(() => import("./vue-ui-dumbbell-B_88Pzkq.js")),
VueUiFlow: o(() => import("./vue-ui-flow-CGYd2Iko.js")),
VueUiGalaxy: o(() => import("./vue-ui-galaxy-C5XKP863.js")),
VueUiGauge: o(() => import("./vue-ui-gauge-CnS0ZVac.js")),
VueUiHeatmap: o(() => import("./vue-ui-heatmap-DdbtuK1j.js")),
VueUiKpi: o(() => import("./vue-ui-kpi-T-hxtGRX.js")),
VueUiMiniLoader: o(() => import("./vue-ui-mini-loader-BUdcns7l.js")),
VueUiMolecule: o(() => import("./vue-ui-molecule-9zI34I22.js")),
VueUiMoodRadar: o(() => import("./vue-ui-mood-radar-3FsJtJ1q.js")),
VueUiNestedDonuts: o(() => import("./vue-ui-nested-donuts-D5-RAGOC.js")),
VueUiOnion: o(() => import("./vue-ui-onion-DyNY3aLe.js")),
VueUiParallelCoordinatePlot: o(() => import("./vue-ui-parallel-coordinate-plot-D3C5xDkx.js")),
VueUiQuadrant: o(() => import("./vue-ui-quadrant-Oyf18Bj4.js")),
VueUiQuickChart: o(() => import("./vue-ui-quick-chart-TbLTi-d3.js")),
VueUiRadar: o(() => import("./vue-ui-radar-BfHQxjpG.js")),
VueUiRating: o(() => import("./vue-ui-rating-BDM0NHP6.js")),
VueUiRelationCircle: o(() => import("./vue-ui-relation-circle-DpwaksSx.js")),
VueUiRings: o(() => import("./vue-ui-rings-Bsvdt8jo.js")),
VueUiScatter: o(() => import("./vue-ui-scatter-qQ-795VY.js")),
VueUiSkeleton: o(() => import("./vue-ui-skeleton-BeEBd4CC.js")),
VueUiSmiley: o(() => import("./vue-ui-smiley-Bba04Gln.js")),
VueUiSparkHistogram: o(() => import("./vue-ui-sparkhistogram-Cv-hyUbF.js")),
VueUiSparkStackbar: o(() => import("./vue-ui-sparkstackbar-8WSy0M8S.js")),
VueUiSparkTrend: o(() => import("./vue-ui-spark-trend-DB2vKJ0m.js")),
VueUiSparkbar: o(() => import("./vue-ui-sparkbar-DjsNBWGs.js")),
VueUiSparkgauge: o(() => import("./vue-ui-sparkgauge-BJ0vTnKL.js")),
VueUiSparkline: o(() => import("./vue-ui-sparkline-tnMT43CD.js")),
VueUiStripPlot: o(() => import("./vue-ui-strip-plot-CN06Oh8m.js")),
VueUiTable: o(() => import("./vue-ui-table-B-sy0kOZ.js")),
VueUiTableHeatmap: o(() => import("./vue-ui-table-heatmap-Dur8rhk6.js")),
VueUiTableSparkline: o(() => import("./vue-ui-table-sparkline-Ccw_ekS8.js")),
VueUiThermometer: o(() => import("./vue-ui-thermometer-BOw4FvGD.js")),
VueUiTimer: o(() => import("./vue-ui-timer-B2gMYwCj.js")),
VueUiTiremarks: o(() => import("./vue-ui-tiremarks-BlfDeAAZ.js")),
VueUiTreemap: o(() => import("./vue-ui-treemap-meoOt_AQ.js")),
VueUiVerticalBar: o(() => import("./vue-ui-vertical-bar-8EaYa2I2.js")),
VueUiWaffle: o(() => import("./vue-ui-waffle-ThNptuVQ.js")),
VueUiWheel: o(() => import("./vue-ui-wheel-B_DSO7Ko.js")),
VueUiWordCloud: o(() => import("./vue-ui-word-cloud-tsIW_o0M.js")),
VueUiXy: o(() => import("./vue-ui-xy-CKNq6i3B.js")),
VueUiXyCanvas: o(() => import("./vue-ui-xy-canvas-DgLV6VWJ.js")),
VueUiCarouselTable: o(() => import("./vue-ui-carousel-table-B-FxYow7.js")),
VueUiGizmo: o(() => import("./vue-ui-gizmo-w7f-RuqD.js")),
VueUiStackbar: o(() => import("./vue-ui-stackbar-BfkOVox7.js")),
VueUiBullet: o(() => import("./vue-ui-bullet-wcXiBQsu.js")),
VueUiFunnel: o(() => import("./vue-ui-funnel-D8Ql3Fu9.js")),
VueUiHistoryPlot: o(() => import("./vue-ui-history-plot-DJ5eSSra.js")),
VueUiCirclePack: o(() => import("./vue-ui-circle-pack-IFKy_EXs.js")),
VueUiWorld: o(() => import("./vue-ui-world-DizUMTdP.js"))
}, { vue_ui_dashboard: F } = pe(), D = R, s = V(() => ve({
userConfig: D.config,
defaultConfig: F
})), P = r(fe()), h = r(s.value.locked);
function A() {
h.value = !h.value;
}
const l = r(D.dataset.map((e, t) => ({
...e,
index: t
}))), X = V(
() => l.value.map((e) => ({
...e,
resolvedComponent: typeof e.component == "string" ? L[e.component] : e.component
}))
), v = r(null), n = r(null), p = r({ x: 0, y: 0 }), f = r({ x: 0, y: 0 }), d = r(null), c = r(!1), m = r(null), T = r(!1), w = r(!1);
function x(e) {
const t = e.target;
(t.tagName === "INPUT" && t.type === "range" || t.classList.contains("range-handle")) && (w.value = !0);
}
function H(e) {
const t = e.target;
t.tagName === "INPUT" && t.type === "range" && (w.value = !1);
}
function I() {
T.value = !0, he({
domElement: document.getElementById(`vue-ui-dashboard_${P.value}`),
fileName: "vue-ui-dashboard"
}).finally(() => {
T.value = !1;
});
}
function G(e) {
if (!h.value && (c.value = !0, m.value = e, n.value === null)) {
v.value = e, p.value = { x: event.clientX, y: event.clientY };
const t = l.value[e], a = 100 - t.width, u = 100 - t.height;
t.left < 0 && (t.left = 0), t.top < 0 && (t.top = 0), t.left > a && (t.left = a), t.top > u && (t.top = u), t.left < 0 && (t.left = 0), t.top < 0 && (t.top = 0), t.left + t.width > 100 && (t.left = 100 - t.width), t.top + t.height > 100 && (t.top = 100 - t.height);
}
}
function M(e, t) {
c.value = !0, m.value = e, n.value = { index: e, direction: t };
const a = l.value[e];
f.value = { x: event.clientX, y: event.clientY, initialWidth: a.width, initialHeight: a.height };
}
function Y(e, t, a) {
if (n.value.direction.includes("top")) {
const u = e.height - a / d.value.offsetHeight * 100;
u >= $ && (e.top += a / d.value.offsetHeight * 100, e.height = u);
}
if (n.value.direction.includes("bottom")) {
const u = e.height + a / d.value.offsetHeight * 100;
u >= $ && (e.height = u);
}
if (n.value.direction.includes("left")) {
const u = e.width - t / d.value.offsetWidth * 100;
u >= $ && (e.left += t / d.value.offsetWidth * 100, e.width = u);
}
if (n.value.direction.includes("right")) {
const u = e.width + t / d.value.offsetWidth * 100;
u >= $ && (e.width = u);
}
}
function O(e) {
if (!(h.value || w.value)) {
if (c.value = !0, v.value !== null) {
const t = l.value[v.value], a = e.clientX - p.value.x, u = e.clientY - p.value.y, i = t.left + a / d.value.offsetWidth * 100, U = t.top + u / d.value.offsetHeight * 100;
i >= 0 && U >= 0 && i + t.width <= 100 && U + t.height <= 100 && (t.left = i, t.top = U), p.value = { x: e.clientX, y: e.clientY };
}
if (n.value !== null) {
const t = l.value[n.value.index], a = e.clientX - f.value.x, u = e.clientY - f.value.y;
Y(t, a, u), f.value = { x: e.clientX, y: e.clientY };
}
}
}
const j = E;
ie(
l,
(e) => {
e && !c.value && j("change", l.value);
},
{ deep: !0 }
);
function Q() {
v.value = null, n.value = null, c.value = !1, m.value = null, l.value.forEach((e) => {
e.left = Math.round(e.left / 100 * 100), e.top = Math.round(e.top / 100 * 100), e.width = Math.round(e.width / 100 * 100), e.height = Math.round(e.height / 100 * 100);
});
}
function K(e) {
h.value || w.value || (c.value = !0, m.value = e, n.value === null && (v.value = e, p.value = { x: event.touches[0].clientX, y: event.touches[0].clientY }));
}
function C(e, t, a) {
if (c.value = !0, m.value = e, n.value === null) {
n.value = { index: e, direction: t };
const u = l.value[e];
f.value = { x: a.touches[0].clientX, y: a.touches[0].clientY, initialWidth: u.width, initialHeight: u.height };
}
}
function _(e) {
if (c.value = !0, e.preventDefault(), n.value !== null) {
const t = l.value[n.value.index], a = e.touches[0].clientX - f.value.x, u = e.touches[0].clientY - f.value.y;
Y(t, a, u), f.value = { x: e.touches[0].clientX, y: e.touches[0].clientY };
}
}
function q(e) {
if (!(h.value || w.value) && (c.value = !0, e.preventDefault(), v.value !== null)) {
const t = l.value[v.value], a = e.touches[0].clientX - p.value.x, u = e.touches[0].clientY - p.value.y, i = t.left + a / d.value.offsetWidth * 100, U = t.top + u / d.value.offsetHeight * 100;
i >= 0 && U >= 0 && i + t.width <= 100 && U + t.height <= 100 && (t.left = i, t.top = U), p.value = { x: e.touches[0].clientX, y: e.touches[0].clientY };
}
}
function k() {
c.value = !1, m.value = null, v.value = null, n.value = null, l.value.forEach((e) => {
e.left = Math.round(e.left / 100 * 100), e.top = Math.round(e.top / 100 * 100), e.width = Math.round(e.width / 100 * 100), e.height = Math.round(e.height / 100 * 100);
});
}
const J = V(() => s.value.style.item.borderColor), Z = V(() => s.value.style.resizeHandles.backgroundColor), ee = V(() => s.value.style.board.aspectRatio), te = V(() => s.value.style.board.backgroundColor), oe = V(() => s.value.style.board.border);
function ue() {
return l.value;
}
return B({
generatePdf: I,
getItemsPositions: ue,
toggleLock: A
}), (e, t) => (g(), y("div", {
onMousedown: x,
onMouseup: H,
onTouchstart: x,
onTouchend: H
}, [
s.value.allowPrint ? (g(), y("div", ge, [
b("button", {
class: "vue-ui-dashboard-button",
onClick: I,
disabled: T.value,
style: S([{ "margin-top": "12px" }, `color:${s.value.style.board.color}`])
}, [
T.value ? (g(), y("svg", {
key: 0,
class: "vue-ui-dashboard-print-icon",
xmlns: "http://www.w3.org/2000/svg",
width: "20",
height: "20",
viewBox: "0 0 24 24",
"stroke-width": "1.5",
stroke: s.value.style.board.color,
fill: "none",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}, t[4] || (t[4] = [
ne('<path stroke="none" d="M0 0h24v24H0z" fill="none" data-v-f5946722></path><path d="M18 16v.01" data-v-f5946722></path><path d="M6 16v.01" data-v-f5946722></path><path d="M12 5v.01" data-v-f5946722></path><path d="M12 12v.01" data-v-f5946722></path><path d="M12 1a4 4 0 0 1 2.001 7.464l.001 .072a3.998 3.998 0 0 1 1.987 3.758l.22 .128a3.978 3.978 0 0 1 1.591 -.417l.2 -.005a4 4 0 1 1 -3.994 3.77l-.28 -.16c-.522 .25 -1.108 .39 -1.726 .39c-.619 0 -1.205 -.14 -1.728 -.391l-.279 .16l.007 .231a4 4 0 1 1 -2.212 -3.579l.222 -.129a3.998 3.998 0 0 1 1.988 -3.756l.002 -.071a4 4 0 0 1 -1.995 -3.265l-.005 -.2a4 4 0 0 1 4 -4z" data-v-f5946722></path>', 6)
]), 8, Ue)) : (g(), y("span", Ve, "PDF"))
], 12, be)
])) : N("", !0),
b("div", {
class: "vue-ui-dashboard-container",
ref_key: "dashboardContainer",
ref: d,
id: `vue-ui-dashboard_${P.value}`,
style: S(`border:${oe.value}; background:${te.value}; aspect-ratio:${ee.value}`)
}, [
b("div", {
class: "vue-ui-dashboard-grid-container",
ref: "container",
onMousemove: O,
onMouseup: Q,
onTouchmove: q,
onTouchend: k,
style: S(`background:${s.value.style.board.backgroundColor}`)
}, [
t[5] || (t[5] = b("div", { class: "vue-ui-dashboard-grid" }, null, -1)),
(g(!0), y(W, null, le(X.value, (a, u) => (g(), y("div", {
key: a.id,
class: re({ "vue-ui-dashboard-grid-item": !0, "vue-ui-dashboard-grid-item--locked": h.value }),
style: S({
width: `${a.width}%`,
height: `${a.height}%`,
left: `${a.left}%`,
top: `${a.top}%`,
cursor: "move",
boxShadow: m.value === u ? "0 6px 12px -3px rgba(0,0,0,0.3)" : "",
zIndex: m.value === u ? X.value.length + 1 : a.index,
backgroundColor: s.value.style.item.backgroundColor
}),
onMousedown: (i) => G(u),
onTouchstart: (i) => K(u)
}, [
h.value ? N("", !0) : (g(), y(W, { key: 0 }, [
b("div", {
class: "vue-ui-dashboard-resize-handle vue-ui-dashboard-top-left",
onMousedown: (i) => M(u, "top-left"),
onTouchstart: (i) => C(u, "top-left", i),
onTouchmove: t[0] || (t[0] = (i) => _(i)),
onTouchend: k
}, null, 40, ke),
b("div", {
class: "vue-ui-dashboard-resize-handle vue-ui-dashboard-top-right",
onMousedown: (i) => M(u, "top-right"),
onTouchstart: (i) => C(u, "top-right", i),
onTouchmove: t[1] || (t[1] = (i) => _(i)),
onTouchend: k
}, null, 40, Te),
b("div", {
class: "vue-ui-dashboard-resize-handle vue-ui-dashboard-bottom-left",
onMousedown: (i) => M(u, "bottom-left"),
onTouchstart: (i) => C(u, "bottom-left", i),
onTouchmove: t[2] || (t[2] = (i) => _(i)),
onTouchend: k
}, null, 40, Me),
b("div", {
class: "vue-ui-dashboard-resize-handle vue-ui-dashboard-bottom-right",
onMousedown: (i) => M(u, "bottom-right"),
onTouchstart: (i) => C(u, "bottom-right", i),
onTouchmove: t[3] || (t[3] = (i) => _(i)),
onTouchend: k
}, null, 40, Ce)
], 64)),
z(e.$slots, "top", {
item: a,
index: u
}, void 0, !0),
a.resolvedComponent ? (g(), se(de(a.resolvedComponent), ce({
key: 1,
ref_for: !0
}, a.props), null, 16)) : z(e.$slots, "content", {
key: 2,
item: a,
index: u,
left: a.left,
top: a.top,
height: a.height,
width: a.width
}, void 0, !0),
z(e.$slots, "bottom", {
item: a,
index: u
}, void 0, !0)
], 46, we))), 128))
], 36)
], 12, ye)
], 32));
}
}, Xe = /* @__PURE__ */ me(_e, [["__scopeId", "data-v-f5946722"]]);
export {
Xe as default
};