UNPKG

vue-data-ui

Version:

A user-empowering data visualization Vue 3 components library for eloquent data storytelling

326 lines (325 loc) • 16.3 kB
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-BfwnBQtY.js"; import { u as ve } from "./useNestedProp-04aFeUYu.js"; import { u as pe, c as fe } from "./index-q-LPw2IT.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-DJTYiV9o.js")), VueUi3dBar: o(() => import("./vue-ui-3d-bar-DGu87lcK.js")), VueUiAccordion: o(() => import("./vue-ui-accordion-D46i_gkB.js")), VueUiAgePyramid: o(() => import("./vue-ui-age-pyramid-DeS1T-Bw.js")), VueUiAnnotator: o(() => import("./vue-ui-annotator-CrqM9fa9.js")), VueUiCandlestick: o(() => import("./vue-ui-candlestick-n8koDNMv.js")), VueUiChestnut: o(() => import("./vue-ui-chestnut-HbK7CLPq.js")), VueUiDigits: o(() => import("./vue-ui-digits-BapPpCcj.js")), VueUiDonut: o(() => import("./vue-ui-donut-CdLAu_O5.js")), VueUiDonutEvolution: o(() => import("./vue-ui-donut-evolution-DHYtqqYZ.js")), VueUiDumbbell: o(() => import("./vue-ui-dumbbell-SgiIfwyE.js")), VueUiFlow: o(() => import("./vue-ui-flow-D7dra0Tp.js")), VueUiGalaxy: o(() => import("./vue-ui-galaxy-BnPiyPdD.js")), VueUiGauge: o(() => import("./vue-ui-gauge-B6BeYUW3.js")), VueUiHeatmap: o(() => import("./vue-ui-heatmap-Di-qNaDB.js")), VueUiKpi: o(() => import("./vue-ui-kpi-nZXBg4tm.js")), VueUiMiniLoader: o(() => import("./vue-ui-mini-loader-NoQltPUC.js")), VueUiMolecule: o(() => import("./vue-ui-molecule-kZceITfL.js")), VueUiMoodRadar: o(() => import("./vue-ui-mood-radar-DtoNCs1x.js")), VueUiNestedDonuts: o(() => import("./vue-ui-nested-donuts-BXZ2WcBF.js")), VueUiOnion: o(() => import("./vue-ui-onion-DNP-X1Kr.js")), VueUiParallelCoordinatePlot: o(() => import("./vue-ui-parallel-coordinate-plot-BaMmD1DR.js")), VueUiQuadrant: o(() => import("./vue-ui-quadrant-qQkLdaFk.js")), VueUiQuickChart: o(() => import("./vue-ui-quick-chart-CR-rtVnh.js")), VueUiRadar: o(() => import("./vue-ui-radar-BMAqVZty.js")), VueUiRating: o(() => import("./vue-ui-rating-NQHqua4r.js")), VueUiRelationCircle: o(() => import("./vue-ui-relation-circle-uYPKJzRP.js")), VueUiRings: o(() => import("./vue-ui-rings-C8ofrNp2.js")), VueUiScatter: o(() => import("./vue-ui-scatter-l4Q3KmVI.js")), VueUiSkeleton: o(() => import("./vue-ui-skeleton-DS0KyQM7.js")), VueUiSmiley: o(() => import("./vue-ui-smiley-Dvz9CJOH.js")), VueUiSparkHistogram: o(() => import("./vue-ui-sparkhistogram-CfcpDn_W.js")), VueUiSparkStackbar: o(() => import("./vue-ui-sparkstackbar-XpDLFtos.js")), VueUiSparkTrend: o(() => import("./vue-ui-spark-trend-CZEFnuFC.js")), VueUiSparkbar: o(() => import("./vue-ui-sparkbar-BNoRSCo7.js")), VueUiSparkgauge: o(() => import("./vue-ui-sparkgauge-Dlq3vjoo.js")), VueUiSparkline: o(() => import("./vue-ui-sparkline-ClRCVth4.js")), VueUiStripPlot: o(() => import("./vue-ui-strip-plot-DoRnEXsU.js")), VueUiTable: o(() => import("./vue-ui-table-Cr8fNe8Z.js")), VueUiTableHeatmap: o(() => import("./vue-ui-table-heatmap-ClCYuGAL.js")), VueUiTableSparkline: o(() => import("./vue-ui-table-sparkline-BUzu6v2P.js")), VueUiThermometer: o(() => import("./vue-ui-thermometer-BsJ_z0Nw.js")), VueUiTimer: o(() => import("./vue-ui-timer-0x5nZPEp.js")), VueUiTiremarks: o(() => import("./vue-ui-tiremarks-qT3POAeD.js")), VueUiTreemap: o(() => import("./vue-ui-treemap-B4ezfcLU.js")), VueUiVerticalBar: o(() => import("./vue-ui-vertical-bar-Bwpe58hH.js")), VueUiWaffle: o(() => import("./vue-ui-waffle-CSKAC_dQ.js")), VueUiWheel: o(() => import("./vue-ui-wheel-CVg1L12p.js")), VueUiWordCloud: o(() => import("./vue-ui-word-cloud-DY88UMDD.js")), VueUiXy: o(() => import("./vue-ui-xy-Bsh6AmS0.js")), VueUiXyCanvas: o(() => import("./vue-ui-xy-canvas-D7VaVkKk.js")), VueUiCarouselTable: o(() => import("./vue-ui-carousel-table-BeUapat0.js")), VueUiGizmo: o(() => import("./vue-ui-gizmo-DoTyGRKN.js")), VueUiStackbar: o(() => import("./vue-ui-stackbar-B_2xrLjj.js")), VueUiBullet: o(() => import("./vue-ui-bullet-0TypghaZ.js")), VueUiFunnel: o(() => import("./vue-ui-funnel-CfhMmeX5.js")), VueUiHistoryPlot: o(() => import("./vue-ui-history-plot-D_ax0e1n.js")), VueUiCirclePack: o(() => import("./vue-ui-circle-pack-HrpJA3B3.js")), VueUiWorld: o(() => import("./vue-ui-world-UaCxKRrk.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 };