@edgarjuvianno/vue-sb-components
Advanced tools
Comparing version 2.0.8 to 2.0.9
import { IConnection, ICoordinates } from '../../interface'; | ||
export declare const doSortPoints: (points: ICoordinates[], endLine: ICoordinates) => ICoordinates[]; | ||
export declare const getConnectionPath: (connection: IConnection, orgUID: string, canvasRect: Record<string, any>) => string | undefined; | ||
export declare const getConnectionPathItem: (itemIndex: number, connection: IConnection, connectionElem: HTMLCollectionOf<SVGPathElement> | undefined, orgUID: string, canvasRect: Record<string, any>) => string | undefined; | ||
export declare const getConnectionPathItem: (movedItem: number, connection: IConnection, connectionElem: HTMLCollectionOf<SVGPathElement> | undefined, orgUID: string, canvasRect: Record<string, any>) => string | undefined; | ||
export declare const getConnectionPathPoint: (points: ICoordinates[], connectionElem: HTMLCollectionOf<SVGPathElement> | undefined) => string | undefined; |
@@ -35,3 +35,3 @@ import { PropType } from 'vue'; | ||
doSetTempConnectionPath(): void; | ||
doUpdateItemMovedConnections(triggerIndex: number, list: IOrganizationTreeItem[]): void; | ||
doUpdateItemMovedConnections(triggerIndex: number): void; | ||
doUpdatePointMovedConnection(points: ICoordinates[], connectionIndex: number, itemIndex: number): void; | ||
@@ -43,3 +43,3 @@ getCanvasRect(): any; | ||
}; | ||
getCoordinatesMove(ev: MouseEvent | TouchEvent, isPullConnection?: boolean): ICoordinates; | ||
getCoordinatesMove(ev: MouseEvent | TouchEvent, treshold?: number): ICoordinates; | ||
getMinMaxXY(): { | ||
@@ -46,0 +46,0 @@ maxX: number; |
import "./organization-tree.css"; | ||
import { defineComponent as st, openBlock as g, createElementBlock as y, Fragment as x, normalizeClass as A, normalizeStyle as X, withModifiers as f, renderList as L, createElementVNode as I, toDisplayString as j, createCommentVNode as O, resolveComponent as gt, mergeProps as G, createBlock as N, Teleport as ft } from "vue"; | ||
import { defineComponent as st, openBlock as g, createElementBlock as y, Fragment as x, normalizeClass as A, normalizeStyle as X, withModifiers as f, renderList as L, createElementVNode as T, toDisplayString as j, createCommentVNode as O, resolveComponent as gt, mergeProps as G, createBlock as N, Teleport as ft } from "vue"; | ||
import { _ as rt } from "../../_plugin-vue_export-helper-dad06003.js"; | ||
@@ -11,4 +11,4 @@ function pt(t, e) { | ||
return t; | ||
const n = document.implementation.createHTMLDocument(), o = n.createElement("base"), s = n.createElement("a"); | ||
return n.head.appendChild(o), n.body.appendChild(s), e && (o.href = e), s.href = t, s.href; | ||
const n = document.implementation.createHTMLDocument(), o = n.createElement("base"), i = n.createElement("a"); | ||
return n.head.appendChild(o), n.body.appendChild(i), e && (o.href = e), i.href = t, i.href; | ||
} | ||
@@ -54,5 +54,5 @@ const yt = (() => { | ||
} | ||
const w = 16384; | ||
const v = 16384; | ||
function Ct(t) { | ||
(t.width > w || t.height > w) && (t.width > w && t.height > w ? t.width > t.height ? (t.height *= w / t.width, t.width = w) : (t.width *= w / t.height, t.height = w) : t.width > w ? (t.height *= w / t.width, t.width = w) : (t.width *= w / t.height, t.height = w)); | ||
(t.width > v || t.height > v) && (t.width > v && t.height > v ? t.width > t.height ? (t.height *= v / t.width, t.width = v) : (t.width *= v / t.height, t.height = v) : t.width > v ? (t.height *= v / t.width, t.width = v) : (t.width *= v / t.height, t.height = v)); | ||
} | ||
@@ -69,10 +69,10 @@ function B(t) { | ||
async function vt(t, e, n) { | ||
const o = "http://www.w3.org/2000/svg", s = document.createElementNS(o, "svg"), r = document.createElementNS(o, "foreignObject"); | ||
return s.setAttribute("width", `${e}`), s.setAttribute("height", `${n}`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), r.setAttribute("width", "100%"), r.setAttribute("height", "100%"), r.setAttribute("x", "0"), r.setAttribute("y", "0"), r.setAttribute("externalResourcesRequired", "true"), s.appendChild(r), r.appendChild(t), wt(s); | ||
const o = "http://www.w3.org/2000/svg", i = document.createElementNS(o, "svg"), r = document.createElementNS(o, "foreignObject"); | ||
return i.setAttribute("width", `${e}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${e} ${n}`), r.setAttribute("width", "100%"), r.setAttribute("height", "100%"), r.setAttribute("x", "0"), r.setAttribute("y", "0"), r.setAttribute("externalResourcesRequired", "true"), i.appendChild(r), r.appendChild(t), wt(i); | ||
} | ||
const P = (t, e) => { | ||
const C = (t, e) => { | ||
if (t instanceof e) | ||
return !0; | ||
const n = Object.getPrototypeOf(t); | ||
return n === null ? !1 : n.constructor.name === e.name || P(n, e); | ||
return n === null ? !1 : n.constructor.name === e.name || C(n, e); | ||
}; | ||
@@ -90,8 +90,8 @@ function bt(t) { | ||
function Et(t, e, n) { | ||
const o = `.${t}:${e}`, s = n.cssText ? bt(n) : kt(n); | ||
return document.createTextNode(`${o}{${s}}`); | ||
const o = `.${t}:${e}`, i = n.cssText ? bt(n) : kt(n); | ||
return document.createTextNode(`${o}{${i}}`); | ||
} | ||
function Q(t, e, n) { | ||
const o = window.getComputedStyle(t, n), s = o.getPropertyValue("content"); | ||
if (s === "" || s === "none") | ||
const o = window.getComputedStyle(t, n), i = o.getPropertyValue("content"); | ||
if (i === "" || i === "none") | ||
return; | ||
@@ -110,3 +110,3 @@ const r = yt(); | ||
} | ||
const _ = "application/font-woff", tt = "image/jpeg", It = { | ||
const _ = "application/font-woff", tt = "image/jpeg", Tt = { | ||
woff: _, | ||
@@ -124,3 +124,3 @@ woff2: _, | ||
}; | ||
function Tt(t) { | ||
function It(t) { | ||
const e = /\.([^./]*?)$/g.exec(t); | ||
@@ -130,4 +130,4 @@ return e ? e[1] : ""; | ||
function V(t) { | ||
const e = Tt(t).toLowerCase(); | ||
return It[e] || ""; | ||
const e = It(t).toLowerCase(); | ||
return Tt[e] || ""; | ||
} | ||
@@ -147,12 +147,12 @@ function Mt(t) { | ||
throw new Error(`Resource "${o.url}" not found`); | ||
const s = await o.blob(); | ||
const i = await o.blob(); | ||
return new Promise((r, a) => { | ||
const i = new FileReader(); | ||
i.onerror = a, i.onloadend = () => { | ||
const s = new FileReader(); | ||
s.onerror = a, s.onloadend = () => { | ||
try { | ||
r(n({ res: o, result: i.result })); | ||
r(n({ res: o, result: s.result })); | ||
} catch (c) { | ||
a(c); | ||
} | ||
}, i.readAsDataURL(s); | ||
}, s.readAsDataURL(i); | ||
}); | ||
@@ -170,12 +170,12 @@ } | ||
n.cacheBust && (t += (/\?/.test(t) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime()); | ||
let s; | ||
let i; | ||
try { | ||
const r = await lt(t, n.fetchRequestInit, ({ res: a, result: i }) => (e || (e = a.headers.get("Content-Type") || ""), Mt(i))); | ||
s = ct(r, e); | ||
const r = await lt(t, n.fetchRequestInit, ({ res: a, result: s }) => (e || (e = a.headers.get("Content-Type") || ""), Mt(s))); | ||
i = ct(r, e); | ||
} catch (r) { | ||
s = n.imagePlaceholder || ""; | ||
i = n.imagePlaceholder || ""; | ||
let a = `Failed to fetch resource: ${t}`; | ||
r && (a = typeof r == "string" ? r : r.message), a && console.warn(a); | ||
} | ||
return Z[o] = s, s; | ||
return Z[o] = i, i; | ||
} | ||
@@ -190,7 +190,7 @@ async function Dt(t) { | ||
r.width = t.clientWidth, r.height = t.clientHeight, a == null || a.drawImage(t, 0, 0, r.width, r.height); | ||
const i = r.toDataURL(); | ||
return B(i); | ||
const s = r.toDataURL(); | ||
return B(s); | ||
} | ||
const n = t.poster, o = V(n), s = await K(n, o, e); | ||
return B(s); | ||
const n = t.poster, o = V(n), i = await K(n, o, e); | ||
return B(i); | ||
} | ||
@@ -207,9 +207,9 @@ async function Xt(t) { | ||
async function Ot(t, e) { | ||
return P(t, HTMLCanvasElement) ? Dt(t) : P(t, HTMLVideoElement) ? Lt(t, e) : P(t, HTMLIFrameElement) ? Xt(t) : t.cloneNode(!1); | ||
return C(t, HTMLCanvasElement) ? Dt(t) : C(t, HTMLVideoElement) ? Lt(t, e) : C(t, HTMLIFrameElement) ? Xt(t) : t.cloneNode(!1); | ||
} | ||
const Yt = (t) => t.tagName != null && t.tagName.toUpperCase() === "SLOT"; | ||
async function At(t, e, n) { | ||
var o, s; | ||
var o, i; | ||
let r = []; | ||
return Yt(t) && t.assignedNodes ? r = E(t.assignedNodes()) : P(t, HTMLIFrameElement) && (!((o = t.contentDocument) === null || o === void 0) && o.body) ? r = E(t.contentDocument.body.childNodes) : r = E(((s = t.shadowRoot) !== null && s !== void 0 ? s : t).childNodes), r.length === 0 || P(t, HTMLVideoElement) || await r.reduce((a, i) => a.then(() => U(i, n)).then((c) => { | ||
return Yt(t) && t.assignedNodes ? r = E(t.assignedNodes()) : C(t, HTMLIFrameElement) && (!((o = t.contentDocument) === null || o === void 0) && o.body) ? r = E(t.contentDocument.body.childNodes) : r = E(((i = t.shadowRoot) !== null && i !== void 0 ? i : t).childNodes), r.length === 0 || C(t, HTMLVideoElement) || await r.reduce((a, s) => a.then(() => U(s, n)).then((c) => { | ||
c && e.appendChild(c); | ||
@@ -223,13 +223,13 @@ }), Promise.resolve()), e; | ||
const o = window.getComputedStyle(t); | ||
o.cssText ? (n.cssText = o.cssText, n.transformOrigin = o.transformOrigin) : E(o).forEach((s) => { | ||
let r = o.getPropertyValue(s); | ||
s === "font-size" && r.endsWith("px") && (r = `${Math.floor(parseFloat(r.substring(0, r.length - 2))) - 0.1}px`), P(t, HTMLIFrameElement) && s === "display" && r === "inline" && (r = "block"), s === "d" && e.getAttribute("d") && (r = `path(${e.getAttribute("d")})`), n.setProperty(s, r, o.getPropertyPriority(s)); | ||
o.cssText ? (n.cssText = o.cssText, n.transformOrigin = o.transformOrigin) : E(o).forEach((i) => { | ||
let r = o.getPropertyValue(i); | ||
i === "font-size" && r.endsWith("px") && (r = `${Math.floor(parseFloat(r.substring(0, r.length - 2))) - 0.1}px`), C(t, HTMLIFrameElement) && i === "display" && r === "inline" && (r = "block"), i === "d" && e.getAttribute("d") && (r = `path(${e.getAttribute("d")})`), n.setProperty(i, r, o.getPropertyPriority(i)); | ||
}); | ||
} | ||
function Bt(t, e) { | ||
P(t, HTMLTextAreaElement) && (e.innerHTML = t.value), P(t, HTMLInputElement) && e.setAttribute("value", t.value); | ||
C(t, HTMLTextAreaElement) && (e.innerHTML = t.value), C(t, HTMLInputElement) && e.setAttribute("value", t.value); | ||
} | ||
function Ht(t, e) { | ||
if (P(t, HTMLSelectElement)) { | ||
const n = e, o = Array.from(n.children).find((s) => t.value === s.getAttribute("value")); | ||
if (C(t, HTMLSelectElement)) { | ||
const n = e, o = Array.from(n.children).find((i) => t.value === i.getAttribute("value")); | ||
o && o.setAttribute("selected", ""); | ||
@@ -239,3 +239,3 @@ } | ||
function Ut(t, e) { | ||
return P(e, Element) && (Ft(t, e), xt(t, e), Bt(t, e), Ht(t, e)), e; | ||
return C(e, Element) && (Ft(t, e), xt(t, e), Bt(t, e), Ht(t, e)), e; | ||
} | ||
@@ -248,16 +248,16 @@ async function Wt(t, e) { | ||
for (let r = 0; r < n.length; r++) { | ||
const i = n[r].getAttribute("xlink:href"); | ||
if (i) { | ||
const c = t.querySelector(i), l = document.querySelector(i); | ||
!c && l && !o[i] && (o[i] = await U(l, e, !0)); | ||
const s = n[r].getAttribute("xlink:href"); | ||
if (s) { | ||
const c = t.querySelector(s), l = document.querySelector(s); | ||
!c && l && !o[s] && (o[s] = await U(l, e, !0)); | ||
} | ||
} | ||
const s = Object.values(o); | ||
if (s.length) { | ||
const i = Object.values(o); | ||
if (i.length) { | ||
const r = "http://www.w3.org/1999/xhtml", a = document.createElementNS(r, "svg"); | ||
a.setAttribute("xmlns", r), a.style.position = "absolute", a.style.width = "0", a.style.height = "0", a.style.overflow = "hidden", a.style.display = "none"; | ||
const i = document.createElementNS(r, "defs"); | ||
a.appendChild(i); | ||
for (let c = 0; c < s.length; c++) | ||
i.appendChild(s[c]); | ||
const s = document.createElementNS(r, "defs"); | ||
a.appendChild(s); | ||
for (let c = 0; c < i.length; c++) | ||
s.appendChild(i[c]); | ||
t.appendChild(a); | ||
@@ -277,14 +277,14 @@ } | ||
const e = []; | ||
return t.replace(ht, (n, o, s) => (e.push(s), n)), e.filter((n) => !J(n)); | ||
return t.replace(ht, (n, o, i) => (e.push(i), n)), e.filter((n) => !J(n)); | ||
} | ||
async function Jt(t, e, n, o, s) { | ||
async function Jt(t, e, n, o, i) { | ||
try { | ||
const r = n ? pt(e, n) : e, a = V(e); | ||
let i; | ||
if (s) { | ||
const c = await s(r); | ||
i = ct(c, a); | ||
let s; | ||
if (i) { | ||
const c = await i(r); | ||
s = ct(c, a); | ||
} else | ||
i = await K(r, a, o); | ||
return t.replace(jt(e), `$1${i}$3`); | ||
s = await K(r, a, o); | ||
return t.replace(jt(e), `$1${s}$3`); | ||
} catch { | ||
@@ -297,6 +297,6 @@ } | ||
for (; ; ) { | ||
const [o, , s] = zt.exec(n) || []; | ||
if (!s) | ||
const [o, , i] = zt.exec(n) || []; | ||
if (!i) | ||
return ""; | ||
if (s === e) | ||
if (i === e) | ||
return `src: ${o};`; | ||
@@ -313,9 +313,9 @@ } | ||
const o = Vt(t, n); | ||
return Zt(o).reduce((r, a) => r.then((i) => Jt(i, a, e, n)), Promise.resolve(o)); | ||
return Zt(o).reduce((r, a) => r.then((s) => Jt(s, a, e, n)), Promise.resolve(o)); | ||
} | ||
async function Y(t, e, n) { | ||
var o; | ||
const s = (o = e.style) === null || o === void 0 ? void 0 : o.getPropertyValue(t); | ||
if (s) { | ||
const r = await ut(s, null, n); | ||
const i = (o = e.style) === null || o === void 0 ? void 0 : o.getPropertyValue(t); | ||
if (i) { | ||
const r = await ut(i, null, n); | ||
return e.style.setProperty(t, r, e.style.getPropertyPriority(t)), !0; | ||
@@ -329,18 +329,18 @@ } | ||
async function Gt(t, e) { | ||
const n = P(t, HTMLImageElement); | ||
if (!(n && !J(t.src)) && !(P(t, SVGImageElement) && !J(t.href.baseVal))) | ||
const n = C(t, HTMLImageElement); | ||
if (!(n && !J(t.src)) && !(C(t, SVGImageElement) && !J(t.href.baseVal))) | ||
return; | ||
const o = n ? t.src : t.href.baseVal, s = await K(o, V(o), e); | ||
const o = n ? t.src : t.href.baseVal, i = await K(o, V(o), e); | ||
await new Promise((r, a) => { | ||
t.onload = r, t.onerror = a; | ||
const i = t; | ||
i.decode && (i.decode = r), i.loading === "lazy" && (i.loading = "eager"), n ? (t.srcset = "", t.src = s) : t.href.baseVal = s; | ||
const s = t; | ||
s.decode && (s.decode = r), s.loading === "lazy" && (s.loading = "eager"), n ? (t.srcset = "", t.src = i) : t.href.baseVal = i; | ||
}); | ||
} | ||
async function Nt(t, e) { | ||
const o = E(t.childNodes).map((s) => mt(s, e)); | ||
const o = E(t.childNodes).map((i) => mt(i, e)); | ||
await Promise.all(o).then(() => t); | ||
} | ||
async function mt(t, e) { | ||
P(t, Element) && (await Kt(t, e), await Gt(t, e), await Nt(t, e)); | ||
C(t, Element) && (await Kt(t, e), await Gt(t, e), await Nt(t, e)); | ||
} | ||
@@ -351,4 +351,4 @@ function Qt(t, e) { | ||
const o = e.style; | ||
return o != null && Object.keys(o).forEach((s) => { | ||
n[s] = o[s]; | ||
return o != null && Object.keys(o).forEach((i) => { | ||
n[i] = o[i]; | ||
}), t; | ||
@@ -367,4 +367,4 @@ } | ||
const o = /url\(["']?([^"')]+)["']?\)/g, r = (n.match(/url\([^)]+\)/g) || []).map(async (a) => { | ||
let i = a.replace(o, "$1"); | ||
return i.startsWith("https://") || (i = new URL(i, t.url).href), lt(i, e.fetchRequestInit, ({ result: c }) => (n = n.replace(a, `url(${c})`), [a, c])); | ||
let s = a.replace(o, "$1"); | ||
return s.startsWith("https://") || (s = new URL(s, t.url).href), lt(s, e.fetchRequestInit, ({ result: c }) => (n = n.replace(a, `url(${c})`), [a, c])); | ||
}); | ||
@@ -378,5 +378,5 @@ return Promise.all(r).then(() => n); | ||
let o = t.replace(n, ""); | ||
const s = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi"); | ||
const i = new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi"); | ||
for (; ; ) { | ||
const c = s.exec(o); | ||
const c = i.exec(o); | ||
if (c === null) | ||
@@ -386,12 +386,12 @@ break; | ||
} | ||
o = o.replace(s, ""); | ||
const r = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", i = new RegExp(a, "gi"); | ||
o = o.replace(i, ""); | ||
const r = /@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi, a = "((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})", s = new RegExp(a, "gi"); | ||
for (; ; ) { | ||
let c = r.exec(o); | ||
if (c === null) { | ||
if (c = i.exec(o), c === null) | ||
if (c = s.exec(o), c === null) | ||
break; | ||
r.lastIndex = i.lastIndex; | ||
r.lastIndex = s.lastIndex; | ||
} else | ||
i.lastIndex = r.lastIndex; | ||
s.lastIndex = r.lastIndex; | ||
e.push(c[0]); | ||
@@ -403,15 +403,15 @@ } | ||
const n = [], o = []; | ||
return t.forEach((s) => { | ||
if ("cssRules" in s) | ||
return t.forEach((i) => { | ||
if ("cssRules" in i) | ||
try { | ||
E(s.cssRules || []).forEach((r, a) => { | ||
E(i.cssRules || []).forEach((r, a) => { | ||
if (r.type === CSSRule.IMPORT_RULE) { | ||
let i = a + 1; | ||
const c = r.href, l = nt(c).then((h) => ot(h, e)).then((h) => it(h).forEach((m) => { | ||
let s = a + 1; | ||
const c = r.href, l = nt(c).then((h) => ot(h, e)).then((h) => it(h).forEach((u) => { | ||
try { | ||
s.insertRule(m, m.startsWith("@import") ? i += 1 : s.cssRules.length); | ||
} catch (p) { | ||
i.insertRule(u, u.startsWith("@import") ? s += 1 : i.cssRules.length); | ||
} catch (m) { | ||
console.error("Error inserting rule from remote css", { | ||
rule: m, | ||
error: p | ||
rule: u, | ||
error: m | ||
}); | ||
@@ -426,17 +426,17 @@ } | ||
} catch (r) { | ||
const a = t.find((i) => i.href == null) || document.styleSheets[0]; | ||
s.href != null && o.push(nt(s.href).then((i) => ot(i, e)).then((i) => it(i).forEach((c) => { | ||
a.insertRule(c, s.cssRules.length); | ||
})).catch((i) => { | ||
console.error("Error loading remote stylesheet", i); | ||
const a = t.find((s) => s.href == null) || document.styleSheets[0]; | ||
i.href != null && o.push(nt(i.href).then((s) => ot(s, e)).then((s) => it(s).forEach((c) => { | ||
a.insertRule(c, i.cssRules.length); | ||
})).catch((s) => { | ||
console.error("Error loading remote stylesheet", s); | ||
})), console.error("Error inlining remote css file", r); | ||
} | ||
}), Promise.all(o).then(() => (t.forEach((s) => { | ||
if ("cssRules" in s) | ||
}), Promise.all(o).then(() => (t.forEach((i) => { | ||
if ("cssRules" in i) | ||
try { | ||
E(s.cssRules || []).forEach((r) => { | ||
E(i.cssRules || []).forEach((r) => { | ||
n.push(r); | ||
}); | ||
} catch (r) { | ||
console.error(`Error while reading CSS rules from ${s.href}`, r); | ||
console.error(`Error while reading CSS rules from ${i.href}`, r); | ||
} | ||
@@ -456,5 +456,5 @@ }), n)); | ||
const n = await ee(t, e); | ||
return (await Promise.all(n.map((s) => { | ||
const r = s.parentStyleSheet ? s.parentStyleSheet.href : null; | ||
return ut(s.cssText, r, e); | ||
return (await Promise.all(n.map((i) => { | ||
const r = i.parentStyleSheet ? i.parentStyleSheet.href : null; | ||
return ut(i.cssText, r, e); | ||
}))).join(` | ||
@@ -466,13 +466,13 @@ `); | ||
if (n) { | ||
const o = document.createElement("style"), s = document.createTextNode(n); | ||
o.appendChild(s), t.firstChild ? t.insertBefore(o, t.firstChild) : t.appendChild(o); | ||
const o = document.createElement("style"), i = document.createTextNode(n); | ||
o.appendChild(i), t.firstChild ? t.insertBefore(o, t.firstChild) : t.appendChild(o); | ||
} | ||
} | ||
async function ie(t, e = {}) { | ||
const { width: n, height: o } = at(t, e), s = await U(t, e, !0); | ||
return await oe(s, e), await mt(s, e), Qt(s, e), await vt(s, n, o); | ||
const { width: n, height: o } = at(t, e), i = await U(t, e, !0); | ||
return await oe(i, e), await mt(i, e), Qt(i, e), await vt(i, n, o); | ||
} | ||
async function se(t, e = {}) { | ||
const { width: n, height: o } = at(t, e), s = await ie(t, e), r = await B(s), a = document.createElement("canvas"), i = a.getContext("2d"), c = e.pixelRatio || Pt(), l = e.canvasWidth || n, h = e.canvasHeight || o; | ||
return a.width = l * c, a.height = h * c, e.skipAutoScale || Ct(a), a.style.width = `${l}`, a.style.height = `${h}`, e.backgroundColor && (i.fillStyle = e.backgroundColor, i.fillRect(0, 0, a.width, a.height)), i.drawImage(r, 0, 0, a.width, a.height), a; | ||
const { width: n, height: o } = at(t, e), i = await ie(t, e), r = await B(i), a = document.createElement("canvas"), s = a.getContext("2d"), c = e.pixelRatio || Pt(), l = e.canvasWidth || n, h = e.canvasHeight || o; | ||
return a.width = l * c, a.height = h * c, e.skipAutoScale || Ct(a), a.style.width = `${l}`, a.style.height = `${h}`, e.backgroundColor && (s.fillStyle = e.backgroundColor, s.fillRect(0, 0, a.width, a.height)), s.drawImage(r, 0, 0, a.width, a.height), a; | ||
} | ||
@@ -495,9 +495,9 @@ async function re(t, e = {}) { | ||
}, ae = (t, e) => [...t].sort( | ||
(s, r) => { | ||
(i, r) => { | ||
const a = Math.sqrt( | ||
(s.x - e.x) * (s.x - e.x) + (s.y - e.y) * (s.y - e.y) | ||
), i = Math.sqrt( | ||
(i.x - e.x) * (i.x - e.x) + (i.y - e.y) * (i.y - e.y) | ||
), s = Math.sqrt( | ||
(r.x - e.x) * (r.x - e.x) + (r.y - e.y) * (r.y - e.y) | ||
); | ||
return a - i; | ||
return a - s; | ||
} | ||
@@ -507,23 +507,23 @@ ).reverse(), ce = (t, e, n) => { | ||
canvasHeight: o, | ||
canvasWidth: s, | ||
canvasWidth: i, | ||
x: r, | ||
y: a | ||
} = n, { from: i, points: c, to: l } = t, h = document.querySelector( | ||
`#org-${e} #org-${e}-item-${i.item}-io-${i.io}` | ||
), m = document.querySelector( | ||
} = n, { from: s, points: c, to: l } = t, h = document.querySelector( | ||
`#org-${e} #org-${e}-item-${s.item}-io-${s.io}` | ||
), u = document.querySelector( | ||
`#org-${e} #org-${e}-item-${l.item}-io-${l.io}` | ||
); | ||
if (h && m) { | ||
if (h && u) { | ||
const { | ||
height: p, | ||
height: m, | ||
width: d, | ||
x: u, | ||
y: S | ||
x: S, | ||
y: p | ||
} = h.getBoundingClientRect().toJSON(), { | ||
height: $, | ||
width: v, | ||
x: T, | ||
width: P, | ||
x: I, | ||
y: M | ||
} = m.getBoundingClientRect().toJSON(), b = d / 2 + (u - r) * s, k = p / 2 + (S - a) * o, C = v / 2 + (T - r) * s, W = $ / 2 + (M - a) * o, R = { | ||
...H(i.io, { | ||
} = u.getBoundingClientRect().toJSON(), b = d / 2 + (S - r) * i, k = m / 2 + (p - a) * o, w = P / 2 + (I - r) * i, W = $ / 2 + (M - a) * o, R = { | ||
...H(s.io, { | ||
x: Math.round(b / 5) * 5, | ||
@@ -534,3 +534,3 @@ y: Math.round(k / 5) * 5 | ||
...H(l.io, { | ||
x: Math.round(C / 5) * 5, | ||
x: Math.round(w / 5) * 5, | ||
y: Math.round(W / 5) * 5 | ||
@@ -545,22 +545,22 @@ }) | ||
} | ||
}, le = (t, e, n, o, s) => { | ||
}, le = (t, e, n, o, i) => { | ||
const { | ||
canvasHeight: r, | ||
canvasWidth: a, | ||
x: i, | ||
x: s, | ||
y: c | ||
} = s, l = e.from.item === t, { from: h, to: m } = e, p = document.querySelector( | ||
} = i, l = e.from.item === t, { from: h, to: u } = e, m = document.querySelector( | ||
`#org-${o} #org-${o}-item-${h.item}-io-${h.io}` | ||
), d = document.querySelector( | ||
`#org-${o} #org-${o}-item-${m.item}-io-${m.io}` | ||
`#org-${o} #org-${o}-item-${u.item}-io-${u.io}` | ||
); | ||
if (l && d && n && n[0]) { | ||
if (!l && d && n && n[0]) { | ||
const { | ||
height: u, | ||
width: S, | ||
height: S, | ||
width: p, | ||
x: $, | ||
y: v | ||
} = d.getBoundingClientRect().toJSON(), T = S / 2 + ($ - i) * a, M = u / 2 + (v - c) * r, b = { | ||
...H(m.io, { | ||
x: Math.round(T / 5) * 5, | ||
y: P | ||
} = d.getBoundingClientRect().toJSON(), I = p / 2 + ($ - s) * a, M = S / 2 + (P - c) * r, b = { | ||
...H(u.io, { | ||
x: Math.round(I / 5) * 5, | ||
y: Math.round(M / 5) * 5 | ||
@@ -570,14 +570,14 @@ }) | ||
if (k) { | ||
const C = k.split(" "); | ||
return C[C.length - 2] = String(b.x), C[C.length - 1] = String(b.y), C.join(" "); | ||
const w = k.split(" "); | ||
return w[w.length - 2] = String(b.x), w[w.length - 1] = String(b.y), w.join(" "); | ||
} | ||
} else if (p && n && n[0]) { | ||
} else if (m && n && n[0]) { | ||
const { | ||
height: u, | ||
width: S, | ||
height: S, | ||
width: p, | ||
x: $, | ||
y: v | ||
} = p.getBoundingClientRect().toJSON(), T = S / 2 + ($ - i) * a, M = u / 2 + (v - c) * r, b = { | ||
y: P | ||
} = m.getBoundingClientRect().toJSON(), I = p / 2 + ($ - s) * a, M = S / 2 + (P - c) * r, b = { | ||
...H(h.io, { | ||
x: Math.round(T / 5) * 5, | ||
x: Math.round(I / 5) * 5, | ||
y: Math.round(M / 5) * 5 | ||
@@ -587,4 +587,4 @@ }) | ||
if (k) { | ||
const C = k.split(" "); | ||
return C[1] = String(b.x), C[2] = String(b.y), C.join(" "); | ||
const w = k.split(" "); | ||
return w[1] = String(b.x), w[2] = String(b.y), w.join(" "); | ||
} | ||
@@ -596,8 +596,8 @@ } | ||
if (n) { | ||
const o = n.split(" "), s = `L ${o[o.length - 2]} ${o[o.length - 1]}`, r = `M ${o[1]} ${o[2]}`; | ||
const o = n.split(" "), i = `L ${o[o.length - 2]} ${o[o.length - 1]}`, r = `M ${o[1]} ${o[2]}`; | ||
if (t != null && t.length) { | ||
const a = t.map((c) => `L ${c.x} ${c.y}`).join(" "); | ||
return `${r} ${a} ${s}`; | ||
return `${r} ${a} ${i}`; | ||
} | ||
return `${r} ${s}`; | ||
return `${r} ${i}`; | ||
} | ||
@@ -659,3 +659,3 @@ } | ||
if (this.canvasState.elem) { | ||
const e = String(this.$.vnode.key).split("-item-")[0].replace("org-", ""), n = this.canvasState.elem.getBoundingClientRect().toJSON(), o = n.height || 0, s = n.width || 0, r = s / (s * this.canvasState.zoom) || 0, a = o / (o * this.canvasState.zoom) || 0; | ||
const e = String(this.$.vnode.key).split("-item-")[0].replace("org-", ""), n = this.canvasState.elem.getBoundingClientRect().toJSON(), o = n.height || 0, i = n.width || 0, r = i / (i * this.canvasState.zoom) || 0, a = o / (o * this.canvasState.zoom) || 0; | ||
return ce(t, e, { | ||
@@ -686,8 +686,8 @@ canvasHeight: a, | ||
...this.item.connections || [] | ||
], s = [ | ||
], i = [ | ||
...((n = o[t]) == null ? void 0 : n.points) || [] | ||
]; | ||
s.splice(e, 1), o[t] = { | ||
i.splice(e, 1), o[t] = { | ||
...o[t], | ||
points: [...s] | ||
points: [...i] | ||
}; | ||
@@ -721,3 +721,3 @@ const r = Number( | ||
if (o && this.isEditable) { | ||
const s = o.getBoundingClientRect(); | ||
const i = o.getBoundingClientRect(); | ||
this.$emit( | ||
@@ -732,3 +732,3 @@ "dragPoint", | ||
}, | ||
s | ||
i | ||
); | ||
@@ -752,21 +752,21 @@ } | ||
...this.item.connections || [] | ||
], { elem: o, zoom: s } = this.canvasState; | ||
], { elem: o, zoom: i } = this.canvasState; | ||
if (o && this.isEditable) { | ||
const { height: r, width: a, x: i, y: c } = o.getBoundingClientRect().toJSON(), l = t.clientX, h = t.clientY, m = l * (a / (a * s)) - i * (a / (a * s)), p = h * (r / (r * s)) - c * (r / (r * s)), d = String(this.$.vnode.key).split( | ||
const { height: r, width: a, x: s, y: c } = o.getBoundingClientRect().toJSON(), l = t.clientX, h = t.clientY, u = l * (a / (a * i)) - s * (a / (a * i)), m = h * (r / (r * i)) - c * (r / (r * i)), d = String(this.$.vnode.key).split( | ||
"-item-" | ||
)[0], u = document.getElementById( | ||
)[0], S = document.getElementById( | ||
`${d}-item-${n[e].to.item}-io-${n[e].to.io}` | ||
); | ||
if (u && this.canvasState.elem) { | ||
if (S && this.canvasState.elem) { | ||
const { | ||
height: S, | ||
height: p, | ||
width: $, | ||
x: v, | ||
y: T | ||
} = u.getBoundingClientRect().toJSON(), { | ||
x: P, | ||
y: I | ||
} = S.getBoundingClientRect().toJSON(), { | ||
height: M, | ||
width: b, | ||
x: k, | ||
y: C | ||
} = this.canvasState.elem.getBoundingClientRect().toJSON(), W = $ / 2 + (v - k) * b, R = S / 2 + (T - C) * M, D = [ | ||
y: w | ||
} = this.canvasState.elem.getBoundingClientRect().toJSON(), W = $ / 2 + (P - k) * b, R = p / 2 + (I - w) * M, D = [ | ||
...ae( | ||
@@ -776,4 +776,4 @@ [ | ||
{ | ||
x: m, | ||
y: p | ||
x: u, | ||
y: m | ||
} | ||
@@ -833,3 +833,3 @@ ], | ||
(r) => `${String(this.$.vnode.key)}-connection-${r.from.item}-${r.from.io}-${r.to.item}-${r.to.io}` | ||
), s = [...e].map( | ||
), i = [...e].map( | ||
(r) => `${String(this.$.vnode.key)}-connection-${r.from.item}-${r.from.io}-${r.to.item}-${r.to.io}` | ||
@@ -839,3 +839,3 @@ ).find( | ||
); | ||
s && delete this.connectionsPath[s]; | ||
i && delete this.connectionsPath[i]; | ||
} else if (t.length > e.length) { | ||
@@ -850,3 +850,3 @@ const n = t[t.length - 1], o = this.getConnectionPath(n); | ||
}), ue = ["id"], me = ["id", "onMousedown", "onTouchstart"], ge = { class: "text" }, fe = ["id"], pe = ["id", "onMousedown", "onTouchstart"], ye = { class: "data-wrapper" }, Se = { class: "name" }, $e = { class: "position" }, Pe = ["innerHTML"], Ce = ["id"], we = ["d", "onClick", "onDblclick"], ve = ["cx", "cy", "onDblclick", "onMousedown", "onTouchstart"]; | ||
function be(t, e, n, o, s, r) { | ||
function be(t, e, n, o, i, r) { | ||
return g(), y(x, null, [ | ||
@@ -869,6 +869,6 @@ t.item.department ? (g(), y("div", { | ||
key: `io-${a}`, | ||
onMousedown: f((i) => t.handleClickIO(i, a), ["stop"]), | ||
onTouchstart: f((i) => t.handleClickIO(i, a), ["stop"]) | ||
onMousedown: f((s) => t.handleClickIO(s, a), ["stop"]), | ||
onTouchstart: f((s) => t.handleClickIO(s, a), ["stop"]) | ||
}, null, 40, me))), 128)), | ||
I("div", ge, j(t.item.department), 1) | ||
T("div", ge, j(t.item.department), 1) | ||
], 46, ue)) : (g(), y("div", { | ||
@@ -890,4 +890,4 @@ key: 1, | ||
key: `io-${a}`, | ||
onMousedown: f((i) => t.handleClickIO(i, a), ["stop"]), | ||
onTouchstart: f((i) => t.handleClickIO(i, a), ["stop"]) | ||
onMousedown: f((s) => t.handleClickIO(s, a), ["stop"]), | ||
onTouchstart: f((s) => t.handleClickIO(s, a), ["stop"]) | ||
}, null, 40, pe))), 128)), | ||
@@ -901,5 +901,5 @@ t.item.photo ? (g(), y("div", { | ||
}, null, 4)) : O("", !0), | ||
I("div", ye, [ | ||
I("p", Se, j(t.item.name), 1), | ||
I("p", $e, j(t.item.position), 1), | ||
T("div", ye, [ | ||
T("p", Se, j(t.item.name), 1), | ||
T("p", $e, j(t.item.position), 1), | ||
t.item.additionalInfo ? (g(), y("div", { | ||
@@ -911,15 +911,15 @@ key: 0, | ||
], 46, fe)), | ||
(g(!0), y(x, null, L(t.item.connections || [], (a, i) => (g(), y("svg", { | ||
(g(!0), y(x, null, L(t.item.connections || [], (a, s) => (g(), y("svg", { | ||
class: A(["connection", { | ||
editable: t.isEditable, | ||
selected: t.isConnectionSelected(i) | ||
selected: t.isConnectionSelected(s) | ||
}]), | ||
xmlns: "http://www.w3.org/2000/svg", | ||
id: `${String(t.$.vnode.key)}-connection-${i}`, | ||
key: `${String(t.$.vnode.key)}-connection-${i}` | ||
id: `${String(t.$.vnode.key)}-connection-${s}`, | ||
key: `${String(t.$.vnode.key)}-connection-${s}` | ||
}, [ | ||
I("path", { | ||
T("path", { | ||
d: t.getConnectionPathString(a), | ||
onClick: f((c) => t.handleConnectionClick(c, i), ["stop"]), | ||
onDblclick: f((c) => t.handleConnectionDoubleClick(c, i), ["stop"]) | ||
onClick: f((c) => t.handleConnectionClick(c, s), ["stop"]), | ||
onDblclick: f((c) => t.handleConnectionDoubleClick(c, s), ["stop"]) | ||
}, null, 40, we), | ||
@@ -933,6 +933,6 @@ (g(!0), y(x, null, L(a.points || [], (c, l) => (g(), y("circle", { | ||
t.$.vnode.key | ||
)}-connection-${i}-circle-${l}`, | ||
onDblclick: f((h) => t.handleCircleDoubleClick(i, l), ["stop"]), | ||
onMousedown: f((h) => t.handleClickPoint(h, i, l), ["stop"]), | ||
onTouchstart: f((h) => t.handleClickPoint(h, i, l), ["stop"]) | ||
)}-connection-${s}-circle-${l}`, | ||
onDblclick: f((h) => t.handleCircleDoubleClick(s, l), ["stop"]), | ||
onMousedown: f((h) => t.handleClickPoint(h, s, l), ["stop"]), | ||
onTouchstart: f((h) => t.handleClickPoint(h, s, l), ["stop"]) | ||
}, null, 40, ve))), 128)) | ||
@@ -1026,15 +1026,15 @@ ], 10, Ce))), 128)) | ||
this.isExporting = !0, await new Promise( | ||
(i) => setTimeout(() => { | ||
i(!0); | ||
(s) => setTimeout(() => { | ||
s(!0); | ||
}, 200) | ||
); | ||
const { maxX: t, minX: e, maxY: n, minY: o } = this.getMinMaxXY(), s = Math.abs(o) + n, r = Math.abs(e) + t, a = this.canvasState.elem; | ||
const { maxX: t, minX: e, maxY: n, minY: o } = this.getMinMaxXY(), i = Math.abs(o) + n, r = Math.abs(e) + t, a = this.canvasState.elem; | ||
if (this.exportAreaStyle = { | ||
height: `${s + 40}px`, | ||
height: `${i + 40}px`, | ||
width: `${r + 40}px` | ||
}, a) { | ||
const i = a.cloneNode( | ||
const s = a.cloneNode( | ||
!0 | ||
); | ||
i.classList.remove("connection-selected"), i.style.transform = "none", i.style.background = "transparent", i.style.height = `${s}px`, i.style.position = "relative", i.style.width = `${r}px`; | ||
s.classList.remove("connection-selected"), s.style.transform = "none", s.style.background = "transparent", s.style.height = `${i}px`, s.style.position = "relative", s.style.width = `${r}px`; | ||
const c = document.getElementById( | ||
@@ -1044,3 +1044,3 @@ `org-${this.$.uid}-export-area` | ||
if (c) { | ||
c.appendChild(i); | ||
c.appendChild(s); | ||
const l = await re( | ||
@@ -1054,3 +1054,3 @@ c, | ||
).catch(() => null); | ||
return i.remove(), this.isExporting = !1, l; | ||
return s.remove(), this.isExporting = !1, l; | ||
} | ||
@@ -1064,5 +1064,5 @@ } | ||
doParentZoomRefresh() { | ||
const { coordinates: t, lastZoom: e, zoom: n } = this.canvasState, o = t.x / e * n, s = t.y / e * n; | ||
const { coordinates: t, lastZoom: e, zoom: n } = this.canvasState, o = t.x / e * n, i = t.y / e * n; | ||
this.canvasState.lastZoom = n, this.canvasStyle = { | ||
transform: `translate(${o}px, ${s}px) scale(${n})` | ||
transform: `translate(${o}px, ${i}px) scale(${n})` | ||
}; | ||
@@ -1075,48 +1075,54 @@ }, | ||
width: o, | ||
x: s, | ||
x: i, | ||
y: r | ||
} = this.connectorState.fromRect, { zoom: a } = this.canvasState, i = this.getCanvasRect(), c = (i == null ? void 0 : i.height) || 0, l = (i == null ? void 0 : i.width) || 0, h = l / (l * a) || 0, m = c / (c * a) || 0, p = (i == null ? void 0 : i.x) || 0, d = (i == null ? void 0 : i.y) || 0, u = o / 2 + (s - p) * h, S = n / 2 + (r - d) * m, $ = t * (l / (l * a)) - p * (l / (l * a)), v = e * (c / (c * a)) - d * (c / (c * a)); | ||
} = this.connectorState.fromRect, { zoom: a } = this.canvasState, s = this.getCanvasRect(), c = (s == null ? void 0 : s.height) || 0, l = (s == null ? void 0 : s.width) || 0, h = l / (l * a) || 0, u = c / (c * a) || 0, m = (s == null ? void 0 : s.x) || 0, d = (s == null ? void 0 : s.y) || 0, S = o / 2 + (i - m) * h, p = n / 2 + (r - d) * u, $ = t * (l / (l * a)) - m * (l / (l * a)), P = e * (c / (c * a)) - d * (c / (c * a)); | ||
this.connectorState.pathObject = { | ||
from: { | ||
x: u, | ||
y: S | ||
x: S, | ||
y: p | ||
}, | ||
to: { | ||
x: $, | ||
y: v | ||
y: P | ||
} | ||
}, this.connectorState.path = `M ${u} ${S} L ${$} ${v}`; | ||
}, this.connectorState.path = `M ${S} ${p} L ${$} ${P}`; | ||
} else | ||
this.connectorState.pathObject = void 0, this.connectorState.path = void 0; | ||
}, | ||
doUpdateItemMovedConnections(t, e) { | ||
e.forEach((n, o) => { | ||
[...n.connections || []].some( | ||
(s) => s.from.item === t || s.to.item === t | ||
) && [...n.connections || []].forEach( | ||
(s, r) => { | ||
if (s.from.item === t || s.to.item === t) { | ||
const a = document.getElementById( | ||
`org-${this.$.uid}-item-${o}-connection-${r}` | ||
), i = a == null ? void 0 : a.getElementsByTagName("path"), c = String(this.$.uid), l = this.getCanvasRect(), h = l.height || 0, m = l.width || 0, p = m / (m * this.canvasState.zoom) || 0, d = h / (h * this.canvasState.zoom) || 0, u = le( | ||
o, | ||
s, | ||
i, | ||
c, | ||
{ | ||
canvasHeight: d, | ||
canvasWidth: p, | ||
x: l.x, | ||
y: l.y | ||
} | ||
); | ||
u && i && i[0].setAttributeNS( | ||
null, | ||
"d", | ||
u | ||
); | ||
doUpdateItemMovedConnections(t) { | ||
this.localList.forEach( | ||
(e, n) => { | ||
[...e.connections || []].some( | ||
(o) => o.from.item === t || o.to.item === t | ||
) && [...e.connections || []].forEach( | ||
(o, i) => { | ||
if (o.from.item === t || o.to.item === t) { | ||
const r = document.getElementById( | ||
`org-${this.$.uid}-item-${n}-connection-${i}` | ||
), a = r == null ? void 0 : r.getElementsByTagName( | ||
"path" | ||
), s = String( | ||
this.$.uid | ||
), c = this.getCanvasRect(), l = c.height || 0, h = c.width || 0, u = h / (h * this.canvasState.zoom) || 0, m = l / (l * this.canvasState.zoom) || 0, d = le( | ||
t, | ||
o, | ||
a, | ||
s, | ||
{ | ||
canvasHeight: m, | ||
canvasWidth: u, | ||
x: c.x, | ||
y: c.y | ||
} | ||
); | ||
d && a && a[0].setAttributeNS( | ||
null, | ||
"d", | ||
d | ||
); | ||
} | ||
} | ||
} | ||
); | ||
}); | ||
); | ||
} | ||
); | ||
}, | ||
@@ -1126,7 +1132,7 @@ doUpdatePointMovedConnection(t, e, n) { | ||
`org-${this.$.uid}-item-${n}-connection-${e}` | ||
), s = o == null ? void 0 : o.getElementsByTagName("path"), r = he( | ||
), i = o == null ? void 0 : o.getElementsByTagName("path"), r = he( | ||
t, | ||
s | ||
i | ||
); | ||
r && s && s[0].setAttributeNS(null, "d", r); | ||
r && i && i[0].setAttributeNS(null, "d", r); | ||
}, | ||
@@ -1148,3 +1154,3 @@ getCanvasRect() { | ||
getCoordinatesMove(t, e) { | ||
const n = e ? 5 : 10, s = (() => t.type === "touchmove" || t.type === "touchstart" ? { | ||
const n = e || 10, i = (() => t.type === "touchmove" || t.type === "touchstart" ? { | ||
x: t.touches[0].clientX, | ||
@@ -1156,5 +1162,5 @@ y: t.touches[0].clientY | ||
})(); | ||
return Math.abs(s.x - this.parentState.position.x) >= n || Math.abs(s.y - this.parentState.position.y) >= n ? { | ||
x: Math.round(s.x / n) * n, | ||
y: Math.round(s.y / n) * n | ||
return e && e < 2 ? i : Math.abs(i.x - this.parentState.position.x) >= n || Math.abs(i.y - this.parentState.position.y) >= n ? { | ||
x: Math.round(i.x / n) * n, | ||
y: Math.round(i.y / n) * n | ||
} : this.parentState.position; | ||
@@ -1171,3 +1177,3 @@ }, | ||
(d) => d.x | ||
), s = [...n].map( | ||
), i = [...n].map( | ||
(d) => d.x + 220 | ||
@@ -1178,6 +1184,6 @@ ), r = [...n].map( | ||
(d) => d.y + 100 | ||
), i = [ | ||
), s = [ | ||
...[...e].map((d) => d.x), | ||
...o, | ||
...s | ||
...i | ||
], c = [ | ||
@@ -1187,8 +1193,8 @@ ...[...e].map((d) => d.y), | ||
...a | ||
], l = Math.max.apply(null, i), h = Math.min.apply(null, i), m = Math.max.apply(null, c), p = Math.min.apply(null, c); | ||
], l = Math.max.apply(null, s), h = Math.min.apply(null, s), u = Math.max.apply(null, c), m = Math.min.apply(null, c); | ||
return { | ||
maxX: l, | ||
minX: h, | ||
maxY: m, | ||
minY: p | ||
maxY: u, | ||
minY: m | ||
}; | ||
@@ -1208,21 +1214,25 @@ }, | ||
...this.localList | ||
]; | ||
n[e] = { | ||
], o = { | ||
...n[e].coordinates | ||
}; | ||
(o.x !== t.x || o.y !== t.y) && (n[e] = { | ||
...this.localList[e], | ||
coordinates: t | ||
}, this.doUpdateItemMovedConnections(e, n), this.localList = [...n]; | ||
}, this.localList = [...n], this.$nextTick( | ||
() => this.doUpdateItemMovedConnections(e) | ||
)); | ||
} | ||
}, | ||
handleItemDragged(t) { | ||
this.draggedItem = { ...t }, this.mouseState.position = { ...t.coordinates }, this.selectedConnection = null; | ||
this.draggedItem = { ...t }, this.mouseState.position = { ...t.coordinates }, this.parentState.position = { ...t.coordinates }, this.selectedConnection = null; | ||
}, | ||
handleParentClick(t) { | ||
const e = this.getCoordinatesMove(t); | ||
const e = this.getCoordinatesMove(t, 1); | ||
this.selectedConnection = null, this.mouseState.mouse = { ...e }, this.mouseState.position = { ...e }, this.mouseState.positionStart = { ...e }, this.parentState.isDrag = !0; | ||
}, | ||
handleParentDragEnd(t) { | ||
const { x: e, y: n } = this.getCoordinatesEnd(t), { coordinates: o } = this.canvasState, s = o.x + -(this.mouseState.position.x - e), r = o.y + -(this.mouseState.position.y - n); | ||
const { x: e, y: n } = this.getCoordinatesEnd(t), { coordinates: o } = this.canvasState, i = o.x + -(this.mouseState.position.x - e), r = o.y + -(this.mouseState.position.y - n); | ||
if (this.parentState.isDrag) | ||
this.canvasState.coordinates = { | ||
x: s, | ||
x: i, | ||
y: r | ||
@@ -1240,13 +1250,13 @@ }; | ||
c.split("-item-")[1] | ||
), m = a.id.split("-io-")[0], p = Number( | ||
), u = a.id.split("-io-")[0], m = Number( | ||
a.id.split("-io-")[1] | ||
), d = Number( | ||
m.split("-item-")[1] | ||
u.split("-item-")[1] | ||
); | ||
if (this.localList[h] && this.localList[d] && this.connectorState.fromRect) { | ||
const u = [ | ||
const S = [ | ||
...this.localList | ||
]; | ||
u[h].connections = [ | ||
...u[h].connections || [], | ||
S[h].connections = [ | ||
...S[h].connections || [], | ||
{ | ||
@@ -1258,7 +1268,7 @@ from: { | ||
to: { | ||
io: p, | ||
io: m, | ||
item: d | ||
} | ||
} | ||
], this.localList = [...u]; | ||
], this.localList = [...S]; | ||
} | ||
@@ -1291,6 +1301,6 @@ } | ||
if (this.localList[n]) { | ||
const s = [ | ||
const i = [ | ||
...this.localList[n].connections || [] | ||
]; | ||
this.localList[n].connections = s.filter( | ||
this.localList[n].connections = i.filter( | ||
(r, a) => a !== o | ||
@@ -1326,17 +1336,17 @@ ), this.$nextTick(() => { | ||
handleParentPosition(t) { | ||
const { x: e, y: n } = this.getCoordinatesMove( | ||
const e = this.pointState.target || this.connectorState.from ? 5 : 10, { x: n, y: o } = this.getCoordinatesMove( | ||
t, | ||
!!this.connectorState.from || !!this.pointState.target | ||
), { x: o, y: s } = this.parentState.position, { coordinates: r, zoom: a } = this.canvasState, i = this.getCanvasRect(); | ||
e | ||
), { x: i, y: r } = this.parentState.position, { coordinates: a, zoom: s } = this.canvasState, c = this.getCanvasRect(); | ||
if (this.parentState.isDrag) { | ||
const c = r.x + -(this.mouseState.position.x - e), l = r.y + -(this.mouseState.position.y - n); | ||
const l = a.x + -(this.mouseState.position.x - n), h = a.y + -(this.mouseState.position.y - o); | ||
this.canvasStyle = { | ||
transform: `translate(${c}px, ${l}px) scale(${a})` | ||
transform: `translate(${l}px, ${h}px) scale(${s})` | ||
}; | ||
} else if (this.draggedItem) { | ||
t.preventDefault(); | ||
const { x: c, y: l } = this.mouseState.position, h = (c - e) * ((i == null ? void 0 : i.width) || 0) / (((i == null ? void 0 : i.width) || 0) * a), m = (l - n) * ((i == null ? void 0 : i.height) || 0) / (((i == null ? void 0 : i.height) || 0) * a); | ||
const { x: l, y: h } = this.mouseState.position, u = (l - n) * ((c == null ? void 0 : c.width) || 0) / (((c == null ? void 0 : c.width) || 0) * s), m = (h - o) * ((c == null ? void 0 : c.height) || 0) / (((c == null ? void 0 : c.height) || 0) * s); | ||
this.handleItemChangePosition({ | ||
x: Math.round( | ||
(this.draggedItem.elem.offsetLeft - h) / 10 | ||
(this.draggedItem.elem.offsetLeft - u) / 10 | ||
) * 10, | ||
@@ -1346,39 +1356,39 @@ y: Math.round( | ||
) * 10 | ||
}), this.$nextTick(() => this.mouseState.position = { x: e, y: n }); | ||
}), this.$nextTick(() => this.mouseState.position = { x: n, y: o }); | ||
} else if (this.connectorState.from) | ||
this.connectorState.toCoordinates = { | ||
x: e, | ||
y: n | ||
x: n, | ||
y: o | ||
}, this.$nextTick(() => this.doSetTempConnectionPath()); | ||
else if (this.pointState.target && this.canvasState.elem && (e !== o || n !== s)) { | ||
else if (this.pointState.target && this.canvasState.elem && (n !== i || o !== r)) { | ||
const { | ||
height: c, | ||
width: l, | ||
x: h, | ||
height: l, | ||
width: h, | ||
x: u, | ||
y: m | ||
} = this.canvasState.elem.getBoundingClientRect().toJSON(), p = e * (l / (l * a)) - h * (l / (l * a)), d = n * (c / (c * a)) - m * (c / (c * a)), { target: u } = this.pointState, S = [ | ||
...this.localList[u.item].connections || [] | ||
], $ = [ | ||
...S[u.connection].points || [] | ||
} = this.canvasState.elem.getBoundingClientRect().toJSON(), d = n * (h / (h * s)) - u * (h / (h * s)), S = o * (l / (l * s)) - m * (l / (l * s)), { target: p } = this.pointState, $ = [ | ||
...this.localList[p.item].connections || [] | ||
], P = [ | ||
...$[p.connection].points || [] | ||
]; | ||
$[u.point] = { | ||
x: Math.round(p / 5) * 5, | ||
y: Math.round(d / 5) * 5 | ||
P[p.point] = { | ||
x: Math.round(d / 5) * 5, | ||
y: Math.round(S / 5) * 5 | ||
}, this.doUpdatePointMovedConnection( | ||
[...$], | ||
u.connection, | ||
u.item | ||
), S[u.connection] = { | ||
...S[u.connection], | ||
points: [...$] | ||
}, this.localList[u.item].connections = [ | ||
...S | ||
[...P], | ||
p.connection, | ||
p.item | ||
), $[p.connection] = { | ||
...$[p.connection], | ||
points: [...P] | ||
}, this.localList[p.item].connections = [ | ||
...$ | ||
]; | ||
} | ||
this.parentState.position = { | ||
x: e, | ||
y: n | ||
x: n, | ||
y: o | ||
}, t.type === "touchmove" && (this.mouseState.mouse = { | ||
x: e, | ||
y: n | ||
x: n, | ||
y: o | ||
}); | ||
@@ -1399,4 +1409,4 @@ }, | ||
).some((o) => { | ||
const s = `org-${this.$.uid}-item-${o.from.item}-io-${o.from.io}`, r = `org-${this.$.uid}-item-${o.to.item}-io-${o.to.io}`; | ||
return t === s && e === r || t === r && e === s; | ||
const i = `org-${this.$.uid}-item-${o.from.item}-io-${o.from.io}`, r = `org-${this.$.uid}-item-${o.to.item}-io-${o.to.io}`; | ||
return t === i && e === r || t === r && e === i; | ||
}); | ||
@@ -1426,11 +1436,11 @@ }, | ||
}); | ||
const xe = ["id"], Ie = { | ||
const xe = ["id"], Te = { | ||
key: 0, | ||
class: "connection connecting", | ||
xmlns: "http://www.w3.org/2000/svg" | ||
}, Te = ["d"], Me = ["id"]; | ||
function Re(t, e, n, o, s, r) { | ||
}, Ie = ["d"], Me = ["id"]; | ||
function Re(t, e, n, o, i, r) { | ||
const a = gt("sb-org-tree-item"); | ||
return g(), y(x, null, [ | ||
I("div", G({ | ||
T("div", G({ | ||
class: [{ | ||
@@ -1442,17 +1452,17 @@ connecting: t.connectorState.from, | ||
}, { ...t.$attrs }, { | ||
onMousedown: e[0] || (e[0] = f((...i) => t.handleParentClick && t.handleParentClick(...i), ["stop"])), | ||
onMousemove: e[1] || (e[1] = f((...i) => t.handleParentPosition && t.handleParentPosition(...i), ["stop"])), | ||
onMouseup: e[2] || (e[2] = f((...i) => t.handleParentDragEnd && t.handleParentDragEnd(...i), ["stop"])), | ||
onPointercancel: e[3] || (e[3] = (...i) => t.handleParentPointerUp && t.handleParentPointerUp(...i)), | ||
onPointerdown: e[4] || (e[4] = (...i) => t.handleParentPointerDown && t.handleParentPointerDown(...i)), | ||
onPointerleave: e[5] || (e[5] = (...i) => t.handleParentPointerUp && t.handleParentPointerUp(...i)), | ||
onPointermove: e[6] || (e[6] = (...i) => t.handleParentPointerMove && t.handleParentPointerMove(...i)), | ||
onPointerout: e[7] || (e[7] = (...i) => t.handleParentPointerUp && t.handleParentPointerUp(...i)), | ||
onPointerup: e[8] || (e[8] = (...i) => t.handleParentPointerUp && t.handleParentPointerUp(...i)), | ||
onTouchend: e[9] || (e[9] = f((...i) => t.handleParentDragEnd && t.handleParentDragEnd(...i), ["stop"])), | ||
onTouchmove: e[10] || (e[10] = f((...i) => t.handleParentPosition && t.handleParentPosition(...i), ["stop"])), | ||
onTouchstart: e[11] || (e[11] = f((...i) => t.handleParentClick && t.handleParentClick(...i), ["stop"])), | ||
onWheel: e[12] || (e[12] = f((...i) => t.handleParentZoom && t.handleParentZoom(...i), ["stop"])) | ||
onMousedown: e[0] || (e[0] = f((...s) => t.handleParentClick && t.handleParentClick(...s), ["stop"])), | ||
onMousemove: e[1] || (e[1] = f((...s) => t.handleParentPosition && t.handleParentPosition(...s), ["stop"])), | ||
onMouseup: e[2] || (e[2] = f((...s) => t.handleParentDragEnd && t.handleParentDragEnd(...s), ["stop"])), | ||
onPointercancel: e[3] || (e[3] = (...s) => t.handleParentPointerUp && t.handleParentPointerUp(...s)), | ||
onPointerdown: e[4] || (e[4] = (...s) => t.handleParentPointerDown && t.handleParentPointerDown(...s)), | ||
onPointerleave: e[5] || (e[5] = (...s) => t.handleParentPointerUp && t.handleParentPointerUp(...s)), | ||
onPointermove: e[6] || (e[6] = (...s) => t.handleParentPointerMove && t.handleParentPointerMove(...s)), | ||
onPointerout: e[7] || (e[7] = (...s) => t.handleParentPointerUp && t.handleParentPointerUp(...s)), | ||
onPointerup: e[8] || (e[8] = (...s) => t.handleParentPointerUp && t.handleParentPointerUp(...s)), | ||
onTouchend: e[9] || (e[9] = f((...s) => t.handleParentDragEnd && t.handleParentDragEnd(...s), ["stop"])), | ||
onTouchmove: e[10] || (e[10] = f((...s) => t.handleParentPosition && t.handleParentPosition(...s), ["stop"])), | ||
onTouchstart: e[11] || (e[11] = f((...s) => t.handleParentClick && t.handleParentClick(...s), ["stop"])), | ||
onWheel: e[12] || (e[12] = f((...s) => t.handleParentZoom && t.handleParentZoom(...s), ["stop"])) | ||
}), [ | ||
I("div", { | ||
T("div", { | ||
class: A(["canvas", { | ||
@@ -1465,3 +1475,3 @@ "connection-selected": t.selectedConnection | ||
t.canvasState.elem ? (g(), y(x, { key: 0 }, [ | ||
(g(!0), y(x, null, L(t.localList, (i, c) => (g(), N(a, G({ | ||
(g(!0), y(x, null, L(t.localList, (s, c) => (g(), N(a, G({ | ||
"canvas-state": t.canvasState, | ||
@@ -1474,3 +1484,3 @@ "connector-state": t.connectorState, | ||
isEditable: t.isEditable, | ||
item: i | ||
item: s | ||
}, { | ||
@@ -1483,6 +1493,6 @@ onChangePoint: t.handleChangeItemPoint, | ||
}), null, 16, ["canvas-state", "connector-state", "is-dragged", "selected-connection", "onChangePoint", "onDragConnection", "onDragItem", "onDragPoint", "onSelectConnection"]))), 128)), | ||
t.connectorState.from ? (g(), y("svg", Ie, [ | ||
I("path", { | ||
t.connectorState.from ? (g(), y("svg", Te, [ | ||
T("path", { | ||
d: t.connectorState.path | ||
}, null, 8, Te) | ||
}, null, 8, Ie) | ||
])) : O("", !0) | ||
@@ -1489,0 +1499,0 @@ ], 64)) : O("", !0) |
@@ -5,3 +5,3 @@ { | ||
"homepage": "http://edgarjuvianno.github.io/vue-sb-components", | ||
"version": "2.0.8", | ||
"version": "2.0.9", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "module": "./main.js", |
1290804
27240