vue3-tree-org.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. import "./chunk-MKUMB4YM.js";
  2. import {
  3. Transition,
  4. vModelText,
  5. vShow
  6. } from "./chunk-S6VK5PVK.js";
  7. import {
  8. Fragment,
  9. Teleport,
  10. computed,
  11. createBaseVNode,
  12. createBlock,
  13. createCommentVNode,
  14. createElementBlock,
  15. createSlots,
  16. createVNode,
  17. defineComponent,
  18. h,
  19. nextTick,
  20. onBeforeMount,
  21. onBeforeUnmount,
  22. onMounted,
  23. onUnmounted,
  24. openBlock,
  25. reactive,
  26. ref,
  27. renderList,
  28. renderSlot,
  29. resolveComponent,
  30. resolveDirective,
  31. warn,
  32. watch,
  33. withCtx,
  34. withDirectives
  35. } from "./chunk-YVHZHMSQ.js";
  36. import {
  37. normalizeClass,
  38. normalizeStyle,
  39. toDisplayString
  40. } from "./chunk-VNBICN6T.js";
  41. import "./chunk-2LSFTFF7.js";
  42. // node_modules/.pnpm/vue3-tree-org@4.2.2_vue@3.4.27/node_modules/vue3-tree-org/lib/index.esm.js
  43. var R = "vue3-tree-org";
  44. var F = "4.2.2";
  45. var A = function(e) {
  46. return "[object Object]" === Object.prototype.toString.call(e);
  47. };
  48. var B = function(e) {
  49. return "string" == typeof e;
  50. };
  51. var L = function(e) {
  52. return "number" == typeof e;
  53. };
  54. var T = { print: (e, n, t) => B(n) || "boolean" == typeof t, pretty: (e, n, t) => B(n) && B(e) || "string" == typeof t, primary: (e, n) => B(e) || "boolean" == typeof n, success: (e, n) => B(e) || "boolean" == typeof n, info: (e, n) => B(e) || "boolean" == typeof n, warning: (e, n) => B(e) || "boolean" == typeof n, danger: (e, n) => B(e) || "boolean" == typeof n };
  55. function j(e = "default") {
  56. let n = "";
  57. switch (e) {
  58. case "primary":
  59. n = "#2d8cf0";
  60. break;
  61. case "success":
  62. n = "#19be6b";
  63. break;
  64. case "info":
  65. n = "#909399";
  66. break;
  67. case "warning":
  68. n = "#ff9900";
  69. break;
  70. case "danger":
  71. n = "#ff4d4f";
  72. break;
  73. case "default":
  74. n = "#35495E";
  75. break;
  76. default:
  77. n = e;
  78. }
  79. return n;
  80. }
  81. T.print = function(e, n = "default", t = false) {
  82. return "object" == typeof e ? (console.dir(e), true) : (t ? console.log(`%c ${e} `, `background:${j(n)}; padding: 2px; border-radius: 4px;color: #fff;`) : console.log(`%c ${e} `, `color: ${j(n)};`), true);
  83. }, T.pretty = function(e, n, t = "primary") {
  84. return console.log(`%c ${e} %c ${n} %c`, `background:${j(t)};border:1px solid ${j(t)}; padding: 1px; border-radius: 4px 0 0 4px; color: #fff;`, `border:1px solid ${j(t)}; padding: 1px; border-radius: 0 4px 4px 0; color: ${j(t)};`, "background:transparent"), true;
  85. }, T.primary = function(e, n = false) {
  86. return this.print && this.print(e, "primary", n), true;
  87. }, T.success = function(e, n = false) {
  88. return this.print && this.print(e, "success", n), true;
  89. }, T.info = function(e, n = false) {
  90. return this.print && this.print(e, "info", n), true;
  91. }, T.warning = function(e, n = false) {
  92. return this.print && this.print(e, "warning", n), true;
  93. }, T.danger = function(e, n = false) {
  94. return this.print && this.print(e, "danger", n), true;
  95. };
  96. var V = { async install(e) {
  97. e.config.globalProperties.$log = T, T.pretty("[" + R + "] " + F, "success");
  98. } };
  99. var Y = function() {
  100. let e = false;
  101. return { get: () => e, set: (n) => {
  102. e = n;
  103. } };
  104. }();
  105. var P = function(e, n, t) {
  106. const { id: o, children: a } = n;
  107. if (e[o] === t)
  108. return e;
  109. if (Array.isArray(e[a])) {
  110. const o2 = e[a];
  111. for (let e2 = 0, a2 = o2.length; e2 < a2; e2++) {
  112. const a3 = o2[e2], l = P(a3, n, t);
  113. if (l)
  114. return l;
  115. }
  116. }
  117. };
  118. var X = function(e, n) {
  119. const { parenNode: t, onlyOneNode: o, cloneNodeDrag: a } = n;
  120. if (t.value) {
  121. const { keys: l } = n, { id: r, pid: d, children: s } = l, c = t.value.$$data, u = JSON.parse(JSON.stringify(e.$$data));
  122. a ? (!function(e2, n2, t2) {
  123. const { children: o2 } = n2;
  124. if (A(e2))
  125. a2(e2);
  126. else if (Array.isArray(e2))
  127. for (let n3 = 0, t3 = e2.length; n3 < t3; n3++)
  128. a2(e2[n3]);
  129. function a2(e3) {
  130. if (t2(e3), Array.isArray(e3[o2])) {
  131. const n3 = e3[o2];
  132. for (let e4 = 0, t3 = n3.length; e4 < t3; e4++)
  133. a2(n3[e4]);
  134. }
  135. }
  136. }(u, l, function(e2) {
  137. "string" == typeof e2[r] && -1 !== e2[r].indexOf("clone-node") && (e2[r] = `clone-node-${e2[r]}`);
  138. }), o && Array.isArray(u[s]) && (u[s] = []), u[l.pid] = c[l.id], c[s] ? c[s].push(u) : c[s] = [u]) : (!function(e2, n2) {
  139. const { keys: t2, data: o2, onlyOneNode: a2 } = n2, { id: l2, pid: r2, children: d2 } = t2, s2 = P(o2, t2, e2[r2]), c2 = s2[d2];
  140. let u2;
  141. for (let n3 = 0, t3 = c2.length; n3 < t3; n3++)
  142. if (c2[n3][l2] === e2[l2]) {
  143. c2.splice(n3, 1), u2 = n3;
  144. break;
  145. }
  146. const i = e2[d2];
  147. a2 && void 0 !== u2 && i && (e2[d2] = [], i.forEach((e3) => {
  148. e3[r2] = s2[l2];
  149. }), s2[d2].splice(u2, 0, ...i));
  150. }(u, n), u[d] = c[r], c[s] ? c[s].push(u) : c[s] = [].concat(u));
  151. }
  152. };
  153. var K = { beforeMount(e, n) {
  154. const { l: t, t: o } = n.modifiers, { drag: a, dragData: l, node: r, emit: d, beforeDragEnd: s, initNodes: c } = n.value, { value: u } = n, i = { ...l };
  155. e.addEventListener("mousedown", function(e2) {
  156. const n2 = e2.target;
  157. if (false === a || 0 !== e2.button || r.focused || r.$$data.noDragging || n2.className.indexOf("tree-org-node-btn") > -1)
  158. return false;
  159. (function(e3) {
  160. e3.stopPropagation(), v = e3.screenX, g = e3.screenY, f = 0, i.contextmenu.value = false;
  161. const { keys: n3, onlyOneNode: t2 } = i;
  162. if (t2) {
  163. const { children: e4 } = n3, t3 = { ...r.$$data };
  164. t3[e4] = [], i.cloneData.value = c(t3);
  165. } else
  166. i.cloneData.value = c(r.$$data);
  167. })(e2), document.addEventListener("mousemove", y), document.addEventListener("mouseup", h2), x("start");
  168. });
  169. let p, f = 0, m = false, v = 0, g = 0;
  170. function y(n2) {
  171. return n2.preventDefault(), !(Math.abs(n2.screenX - v) < 5 && Math.abs(n2.screenY - g) < 5) && (m || (m = true, function(n3) {
  172. Y.set(true), i.nodeMoving.value = true, r.moving = true;
  173. let t2 = e;
  174. for (; !t2.classList.contains("tree-org-node"); )
  175. f += t2.offsetLeft, t2 = t2.offsetParent;
  176. f += 2, p = document.querySelector("#clone-tree-org"), p && (p.style.width = `${t2.clientWidth}px`, p.style.opacity = "0.8", p.style.left = n3.clientX - f + "px", p.style.top = n3.clientY + 2 + "px");
  177. }(n2)), t && o && u ? (p && (p.style.left = n2.clientX - f + "px", p.style.top = n2.clientY + 2 + "px"), void x("move")) : t && u ? (e.style.left = n2.clientX - f + "px", void x("move")) : void (o && u && (e.style.top = n2.clientY + "px", x("move"))));
  178. }
  179. function h2(e2) {
  180. if (document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", h2), m) {
  181. if ("function" == typeof s) {
  182. const n2 = s(r, i.parenNode.value);
  183. n2 && n2.then ? n2.then(() => {
  184. b(e2);
  185. }, () => {
  186. }) : false !== n2 && b(e2);
  187. } else
  188. b(e2);
  189. m = false, p = null, r.moving = false, i.nodeMoving.value = false, setTimeout(() => {
  190. Y.set(false);
  191. }, 200);
  192. }
  193. }
  194. function b(e2) {
  195. const n2 = document.querySelector(".tree-org-node__moving");
  196. if (n2 && n2.contains(e2.target))
  197. return x("end"), false;
  198. X(r, i), x("end");
  199. }
  200. function x(e2) {
  201. "start" !== e2 ? "move" !== e2 ? "end" === e2 && d("on-node-drag-end", r, i.parenNode.value) : d("on-node-drag", r) : d("on-node-drag-start", r);
  202. }
  203. } };
  204. var W = { onClick: "onNodeClick", onDblclick: "onNodeDblclick", onContextmenu: "onNodeContextmenu", onMouseenter: "onNodeMouseenter", onMouseleave: "onNodeMouseleave" };
  205. function q(e, n) {
  206. if ("function" == typeof e)
  207. return function(t) {
  208. t.target.className.indexOf("org-tree-node-btn") > -1 || e(t, n);
  209. };
  210. }
  211. var U = (e, n, t) => !(Array.isArray(e[n]) && e[n].length > 0) && !t || e.isLeaf;
  212. var I = (e, o, a) => {
  213. const { attrs: l } = a, r = ["tree-org-node"], d = [], { expand: s, children: c, id: u } = o;
  214. return U(o, "children", l.lazy) ? r.push("is-leaf") : l.collapsable && !s && r.push("collapsed"), o.moving && r.push("tree-org-node__moving"), d.push(J(e, o, a)), l.collapsable && !s || d.push(H(e, c, a)), withDirectives(e("div", { class: r, key: u }, d), [[vShow, !o.hidden]]);
  215. };
  216. var J = (e, a, l) => {
  217. const { attrs: r } = l, d = r.props, s = r.renderContent, { label: c } = a, u = [];
  218. if (l.slots.default)
  219. u.push(l.slots.default({ node: a }));
  220. else if ("function" == typeof s) {
  221. T.warning("scoped-slot header is easier to use. We recommend users to use scoped-slot header.");
  222. const n = s(e, a);
  223. n && u.push(n);
  224. } else
  225. u.push(e("div", { class: "tree-org-node__text" }, c));
  226. r.collapsable && !U(a, "children", r.lazy) && u.push(((e2, n, t) => {
  227. const { attrs: o } = t, a2 = o.onOnExpand, l2 = ["tree-org-node__expand"];
  228. n.expand && l2.push("expanded");
  229. const r2 = [];
  230. return t.slots.expand ? r2.push(t.slots.expand({ node: n })) : r2.push(e2("span", { class: "tree-org-node__expand-btn" })), e2("span", { class: l2, onMousedown: (e3) => {
  231. e3.stopPropagation();
  232. }, onDblclick: (e3) => {
  233. e3.stopPropagation();
  234. }, onClick: (e3) => {
  235. e3.stopPropagation(), a2 && a2(e3, n);
  236. } }, r2);
  237. })(e, a, l));
  238. const i = ["tree-org-node__inner"];
  239. let { labelStyle: p, labelClassName: f, selectedClassName: m, selectedKey: v } = r;
  240. "function" == typeof f && (f = f(a)), f && i.push(f), a.className && i.push(a.className), "function" == typeof m && (m = m(a)), void 0 !== v && (v = Array.isArray(v) ? v : [v]), m && v && v.includes(a.id) && i.push(m);
  241. const g = ["tree-org-node__content"];
  242. a.$$root && g.push(`is-root_${r.suffix}`), a.label || g.push("is-empty"), a.$$focused && g.push("is-edit");
  243. const y = resolveDirective("nodedrag"), h2 = [];
  244. r.vNodedrag && y && !a.$$root && h2.push([y, Object.assign({ node: a }, r.vNodedrag), "", { l: true, t: true }]);
  245. const b = {};
  246. for (const e2 in W)
  247. if (Object.prototype.hasOwnProperty.call(W, e2)) {
  248. const n = r[W[e2]];
  249. n && (b[e2] = q(n, a));
  250. }
  251. const x = r.onNodeFocus, $ = r.onNodeBlur, N = resolveDirective("focus"), S = [[vShow, a.$$focused]];
  252. return N && S.push([N, a.$$focused]), e("div", { class: g }, [withDirectives(e("div", { class: i, style: a.style ? a.style : p, ...b }, u), h2), withDirectives(e("textarea", { class: "tree-org-node__textarea", placeholder: "请输入节点名称", value: a.label, onFocus: (e2) => {
  253. x && x(e2, a.$$data, a);
  254. }, onInput: (e2) => {
  255. a.label = e2.target.value;
  256. }, onBlur: (e2) => {
  257. void 0 !== a.$$data.focused && (a.$$data.focused = false), a.$$data[d.label] = e2.target.value, a.$$focused = false, $ && $(e2, a.$$data, a);
  258. }, onClick: (e2) => e2.stopPropagation() }), S)]);
  259. };
  260. var H = (e, n, t) => {
  261. if (Array.isArray(n) && n.length) {
  262. const o = n.filter((e2) => !e2.$$hidden).map((n2) => I(e, n2, t));
  263. return e("div", { class: "tree-org-node__children" }, o);
  264. }
  265. return "";
  266. };
  267. var G = (n, t) => n.data && 0 !== Object.keys(n.data).length ? (n.data.$$root = !n.isClone, I(h, n.data, t)) : "";
  268. G.directives = { focus: { mounted(e, { value: n }) {
  269. n && e.focus();
  270. }, updated(e, { value: n }) {
  271. n && e.focus();
  272. } }, nodedrag: K };
  273. var Q = defineComponent({ props: { scale: String, tools: Object }, setup(e, { emit: n }) {
  274. const t = ref(false), o = ref(false);
  275. function a(e2) {
  276. o.value = !o.value, n("onFullscreen", e2);
  277. }
  278. function c() {
  279. document.isFullScreen || document.mozIsFullScreen || document.webkitIsFullScreen || !o.value || a("esc");
  280. }
  281. const u = computed(() => t.value ? "全部收起" : "全部展开"), i = computed(() => o.value ? "退出全屏" : "全屏");
  282. return onMounted(() => {
  283. window.addEventListener("resize", c);
  284. }), onBeforeUnmount(() => {
  285. window.removeEventListener("resize", c);
  286. }), { expanded: t, fullscreen: o, expandTitle: u, fullTiltle: i, handleExpand: function() {
  287. t.value = !t.value, n("onExpand");
  288. }, handleScale: function(e2) {
  289. "out" === e2 ? n("onScale", 0.1) : "in" === e2 ? n("onScale", -0.1) : n("onRestore");
  290. }, handleFullscreen: a };
  291. } });
  292. var Z = { class: "zm-tree-handle" };
  293. var ee = { key: 0, class: "zm-tree-percent" };
  294. var ne = ["title"];
  295. var te = { class: "zm-tree-svg" };
  296. var oe = [createBaseVNode("span", { class: "zm-tree-icon" }, "+", -1)];
  297. var ae = [createBaseVNode("span", { class: "zm-tree-icon" }, "-", -1)];
  298. var le = [createBaseVNode("span", { class: "zm-tree-restore" }, null, -1)];
  299. var re = ["title"];
  300. var de = { class: "zm-tree-svg" };
  301. function se(e) {
  302. return "function" == typeof e || "[object Function]" === Object.prototype.toString.call(e);
  303. }
  304. function ce(e, n, t, o = 1) {
  305. return { deltaX: Math.round(n / o / e[0]) * e[0], deltaY: Math.round(t / o / e[1]) * e[1] };
  306. }
  307. function ue(e, n, t) {
  308. return e < n ? n : t < e ? t : e;
  309. }
  310. Q.render = function(e, n, t, o, a, l) {
  311. return openBlock(), createElementBlock("div", Z, [e.tools.scale ? (openBlock(), createElementBlock("div", ee, toDisplayString(e.scale), 1)) : createCommentVNode("v-if", true), e.tools.expand ? (openBlock(), createElementBlock("div", { key: 1, onClick: n[0] || (n[0] = (...n2) => e.handleExpand && e.handleExpand(...n2)), title: e.expandTitle, class: "zm-tree-handle-item" }, [createBaseVNode("span", te, [createBaseVNode("i", { class: normalizeClass(["treefont", e.expanded ? "icon-collapse" : "icon-expand"]) }, null, 2)])], 8, ne)) : createCommentVNode("v-if", true), e.tools.zoom ? (openBlock(), createElementBlock("div", { key: 2, onClick: n[1] || (n[1] = (n2) => e.handleScale("out")), title: "放大", class: "zm-tree-handle-item zoom-out" }, oe)) : createCommentVNode("v-if", true), e.tools.zoom ? (openBlock(), createElementBlock("div", { key: 3, onClick: n[2] || (n[2] = (n2) => e.handleScale("in")), title: "缩小", class: "zm-tree-handle-item zoom-in" }, ae)) : createCommentVNode("v-if", true), e.tools.restore ? (openBlock(), createElementBlock("div", { key: 4, onClick: n[3] || (n[3] = (n2) => e.handleScale("restore")), title: "还原", class: "zm-tree-handle-item" }, le)) : createCommentVNode("v-if", true), e.tools.fullscreen ? (openBlock(), createElementBlock("div", { key: 5, onClick: n[4] || (n[4] = (...n2) => e.handleFullscreen && e.handleFullscreen(...n2)), title: e.fullTiltle, class: "zm-tree-handle-item" }, [createBaseVNode("span", de, [createBaseVNode("i", { class: normalizeClass(["treefont", e.fullscreen ? "icon-unfullscreen" : "icon-fullscreen"]) }, null, 2)])], 8, re)) : createCommentVNode("v-if", true)]);
  312. }, Q.__file = "src/components/tools/tools.vue";
  313. var ie = function(e, n, t, o = false) {
  314. e && n && t && e.addEventListener(n, t, o);
  315. };
  316. var pe = function(e, n, t, o = false) {
  317. e && n && t && e.removeEventListener(n, t, o);
  318. };
  319. var fe = (e, { emit: n }, t) => {
  320. const o = { start: "mousedown", move: "mousemove", stop: "mouseup" }, a = { start: "touchstart", move: "touchmove", stop: "touchend" }, s = { userSelect: "none", MozUserSelect: "none", WebkitUserSelect: "none", MsUserSelect: "none" }, c = { userSelect: "auto", MozUserSelect: "auto", WebkitUserSelect: "auto", MsUserSelect: "auto" };
  321. let u = o;
  322. const i = ref(e.x), p = ref(e.y), f = ref(e.z), m = ref(e.active), h2 = ref(false), b = ref(0), x = ref(0), $ = ref(0), N = ref(0), S = ref(0), z = ref(0);
  323. let E = {}, D = {};
  324. function C() {
  325. E = { mouseX: 0, mouseY: 0, x: 0, y: 0, w: 0, h: 0 }, D = { minLeft: -1 / 0, maxLeft: 1 / 0, minRight: -1 / 0, maxRight: 1 / 0, minTop: -1 / 0, maxTop: 1 / 0, minBottom: -1 / 0, maxBottom: 1 / 0 };
  326. }
  327. function k() {
  328. if (e.parent) {
  329. const [e2, n2] = M();
  330. S.value = e2 || 0, z.value = n2 || 0;
  331. }
  332. }
  333. function M() {
  334. if (e.parent && t.eleRef.value) {
  335. const e2 = window.getComputedStyle(t.eleRef.value.parentNode, null);
  336. return [parseInt(e2.getPropertyValue("width"), 10), parseInt(e2.getPropertyValue("height"), 10)];
  337. }
  338. return [0, 0];
  339. }
  340. function O(o2) {
  341. if (o2 instanceof MouseEvent && 1 !== o2.which)
  342. return;
  343. const a2 = o2.target || o2.srcElement;
  344. if (a2 && t.eleRef.value && t.eleRef.value.contains(a2)) {
  345. if (e.dragCancel && function(e2, n2, t2) {
  346. let o3 = e2;
  347. const a3 = ["matches", "webkitMatchesSelector", "mozMatchesSelector", "msMatchesSelector", "oMatchesSelector"].find((e3) => o3 && se(o3[e3])) || "";
  348. if (!se(o3[a3]))
  349. return false;
  350. do {
  351. if (o3[a3](n2))
  352. return true;
  353. if (o3 === t2)
  354. return false;
  355. o3 = o3.parentNode;
  356. } while (o3);
  357. return false;
  358. }(a2, e.dragCancel, t.eleRef.value))
  359. return void (h2.value = false);
  360. m.value || (m.value = true, n("activated"), n("update:active", true)), e.draggable && (h2.value = true), o2 instanceof MouseEvent ? (E.mouseX = o2.pageX, E.mouseY = o2.pageY) : (E.mouseX = o2.touches[0].pageX, E.mouseY = o2.touches[0].pageY), E.left = i.value, E.right = b.value, E.top = p.value, E.bottom = x.value, e.parent && (D = w()), ie(document.documentElement, u.move, R2), ie(document.documentElement, u.stop, F2);
  361. }
  362. }
  363. function w() {
  364. const n2 = e.grid;
  365. return { minLeft: i.value % n2[0], maxLeft: Math.floor((S.value - $.value - i.value) / n2[0]) * n2[0] + i.value, minRight: b.value % n2[0], maxRight: Math.floor((S.value - $.value - b.value) / n2[0]) * n2[0] + b.value, minTop: p.value % n2[1], maxTop: Math.floor((z.value - N.value - p.value) / n2[1]) * n2[1] + p.value, minBottom: x.value % n2[1], maxBottom: Math.floor((z.value - N.value - x.value) / n2[1]) * n2[1] + x.value };
  366. }
  367. function _(o2) {
  368. const a2 = o2.target || o2.srcElement;
  369. t.eleRef.value && !t.eleRef.value.contains(a2) && m.value && !e.preventDeactivation && (m.value = false, n("deactivated"), n("update:active", false));
  370. }
  371. function R2(t2) {
  372. h2.value && function(t3) {
  373. const o2 = e.axis, a2 = e.grid;
  374. let l = 0, r = 0;
  375. t3 instanceof MouseEvent ? (l = t3.pageX, r = t3.pageY) : (l = t3.touches[0].pageX, r = t3.touches[0].pageY);
  376. const d = o2 && "y" !== o2 ? E.mouseX - l : 0, s2 = o2 && "x" !== o2 ? E.mouseY - r : 0, { deltaX: c2, deltaY: u2 } = ce(a2, d, s2, e.scale), f2 = ue(E.left - c2, D.minLeft, D.maxLeft), m2 = ue(E.top - u2, D.minTop, D.maxTop), v = ue(E.right + c2, D.minRight, D.maxRight), g = ue(E.bottom + u2, D.minBottom, D.maxBottom);
  377. i.value = f2, p.value = m2, b.value = v, x.value = g, n("dragging", i.value, p.value);
  378. }(t2);
  379. }
  380. function F2() {
  381. C(), h2.value && (h2.value = false, n("dragstop", i.value, p.value));
  382. }
  383. onBeforeMount(() => {
  384. C();
  385. }), onMounted(() => {
  386. !e.enableNativeDrag && t.eleRef.value && (t.eleRef.value.ondragstart = () => false);
  387. const [n2, o2] = M();
  388. if (S.value = n2, z.value = o2, t.eleRef.value) {
  389. const [e2, n3] = function(e3) {
  390. const n4 = window.getComputedStyle(e3);
  391. return [parseFloat(n4.getPropertyValue("width")), parseFloat(n4.getPropertyValue("height"))];
  392. }(t.eleRef.value);
  393. $.value = e2, N.value = n3, b.value = S.value - $.value - i.value, x.value = z.value - N.value - p.value;
  394. }
  395. ie(document.documentElement, "mousedown", _), ie(document.documentElement, "touchend touchcancel", _), ie(window, "resize", k);
  396. }), onUnmounted(() => {
  397. pe(document.documentElement, "mousedown", _), pe(document.documentElement, "touchstart", F2), pe(document.documentElement, "mousemove", R2), pe(document.documentElement, "touchmove", R2), pe(document.documentElement, "mouseup", F2), pe(document.documentElement, "touchend touchcancel", _), pe(window, "resize", k);
  398. });
  399. const A2 = computed(() => ({ transform: `translate(${i.value}px, ${p.value}px)`, zIndex: f.value, ...h2.value && e.disableUserSelect ? s : c }));
  400. return watch(() => e.active, (e2) => {
  401. m.value = e2, n(e2 ? "activated" : "deactivated");
  402. }), watch(() => e.z, (e2) => {
  403. (e2 >= 0 || "auto" === e2) && (f.value = e2);
  404. }), watch(() => e.x, (n2) => {
  405. h2.value || (e.parent && (D = w()), function(n3) {
  406. const { deltaX: t2 } = ce(e.grid, n3, p.value, e.scale), o2 = ue(t2, D.minLeft, D.maxLeft);
  407. i.value = o2, b.value = S.value - $.value - o2;
  408. }(n2));
  409. }), watch(() => e.y, (n2) => {
  410. h2.value || (e.parent && (D = w()), function(n3) {
  411. const { deltaY: t2 } = ce(e.grid, i.value, n3, e.scale), o2 = ue(t2, D.minTop, D.maxTop);
  412. p.value = o2, x.value = z.value - N.value - o2;
  413. }(n2));
  414. }), { enabled: m, dragging: h2, style: A2, resetBoundsAndMouseState: C, elementTouchDown: function(e2) {
  415. u = a, O(e2);
  416. }, elementMouseDown: function(e2) {
  417. u = o, O(e2);
  418. } };
  419. };
  420. Object.freeze({}), Object.freeze([]);
  421. var me = Symbol("wrapper");
  422. function ve(e, n) {
  423. if (null === (t = e) || "object" != typeof t || e.__elPropsReservedKey)
  424. return e;
  425. var t;
  426. const { values: o, required: a, default: l, type: r, validator: d } = e, s = o || d ? (e2) => {
  427. let t2 = false, a2 = [];
  428. if (o && (a2 = [...o, l], t2 = t2 || a2.includes(e2)), d && (t2 = t2 || d(e2)), !t2 && a2.length > 0) {
  429. const t3 = [...new Set(a2)].map((e3) => JSON.stringify(e3)).join(", ");
  430. warn(`Invalid prop: validation failed${n ? ` for prop "${n}"` : ""}. Expected one of [${t3}], got value ${JSON.stringify(e2)}.`);
  431. }
  432. return t2;
  433. } : void 0;
  434. return { type: "object" == typeof r && Object.getOwnPropertySymbols(r).includes(me) ? r[me] : r, validator: s, __elPropsReservedKey: true, default: l, required: !!a };
  435. }
  436. var ge = (e) => function(e2) {
  437. let n = -1;
  438. const t = e2 ? e2.length : 0, o = {};
  439. for (; ++n < t; ) {
  440. const t2 = e2[n];
  441. o[t2[0]] = t2[1];
  442. }
  443. return o;
  444. }(Object.entries(e).map(([e2, n]) => [e2, ve(n, e2)]));
  445. var ye = (e) => ({ [me]: e });
  446. var he = defineComponent({ replace: true, name: "Draggable", props: ge({ className: { type: String, default: "zm-draggable" }, classNameDraggable: { type: String, default: "draggable" }, classNameDragging: { type: String, default: "dragging" }, classNameActive: { type: String, default: "active" }, disableUserSelect: { type: Boolean, default: true }, enableNativeDrag: { type: Boolean, default: false }, preventDeactivation: { type: Boolean, default: false }, active: { type: Boolean, default: false }, draggable: { type: Boolean, default: true }, x: { type: Number, default: 0 }, y: { type: Number, default: 0 }, z: { type: [String, Number], default: "auto", validator: (e) => "string" == typeof e ? "auto" === e : e >= 0 }, dragCancel: String, axis: { type: String, default: "both", validator: (e) => ["x", "y", "both"].includes(e) }, grid: { type: Array, default: () => [1, 1] }, parent: { type: Boolean, default: false }, scale: { type: Number, default: 1, validator: (e) => e > 0 } }), emits: { activated: () => true, deactivated: () => true, dragging: (e, n) => L(e) && L(n), dragstop: (e, n) => L(e) && L(n), "update:active": (e) => "boolean" == typeof e }, setup(e, n) {
  447. const t = ref(), o = fe(e, n, { eleRef: t });
  448. return { top, eleRef: t, ...o };
  449. } });
  450. he.render = function(e, n, t, o, a, l) {
  451. return openBlock(), createElementBlock("div", { style: normalizeStyle(e.style), class: normalizeClass([{ [e.classNameActive]: e.enabled, [e.classNameDragging]: e.dragging, [e.classNameDraggable]: e.draggable }, e.className]), ref: "eleRef", onMousedown: n[0] || (n[0] = (...n2) => e.elementMouseDown && e.elementMouseDown(...n2)), onTouchstart: n[1] || (n[1] = (...n2) => e.elementTouchDown && e.elementTouchDown(...n2)) }, [renderSlot(e.$slots, "default")], 38);
  452. }, he.__file = "src/components/draggable/src/draggable.vue";
  453. var be = defineComponent({ components: { TreeOrgNode: G }, props: ge({ data: { type: Object, required: true }, props: { type: ye(Object) }, modelValue: Boolean, horizontal: Boolean, selectedKey: String, collapsable: Boolean, renderContent: Function, labelStyle: Object, labelClassName: { type: [Function, String] } }), setup: (e, n) => ({ defaultSlot: !!n.slots.default, expandSlot: !!n.slots.expand }) });
  454. be.render = function(e, o, a, l, r, d) {
  455. const s = resolveComponent("tree-org-node");
  456. return openBlock(), createBlock(Teleport, { to: "body" }, [withDirectives(createBaseVNode("div", { id: "clone-tree-org", class: normalizeClass(["clone-tree-org tree-org", { horizontal: e.horizontal, collapsable: e.collapsable }]) }, [createVNode(s, { data: e.data, props: e.props, isClone: false, horizontal: e.horizontal, labelStyle: e.labelStyle, collapsable: e.collapsable, renderContent: e.renderContent, labelClassName: e.labelClassName }, createSlots({ _: 2 }, [e.defaultSlot ? { name: "default", fn: withCtx(({ node: n }) => [renderSlot(e.$slots, "default", { node: n })]) } : void 0, e.expandSlot ? { name: "expand", fn: withCtx(({ node: n }) => [renderSlot(e.$slots, "expand", { node: n })]) } : void 0]), 1032, ["data", "props", "horizontal", "labelStyle", "collapsable", "renderContent", "labelClassName"])], 2), [[vShow, e.modelValue]])]);
  457. }, be.__file = "src/components/clone-org/clone-org.vue";
  458. var xe = (e, { emit: n }, t) => {
  459. const o = ref("");
  460. function a(e2, n2, t2) {
  461. if (e2[n2.id] === t2)
  462. return e2;
  463. if (Array.isArray(e2[n2.children])) {
  464. const o2 = e2[n2.children];
  465. for (let e3 = 0, l = o2.length; e3 < l; e3++) {
  466. const l2 = a(o2[e3], n2, t2);
  467. if (l2)
  468. return l2;
  469. }
  470. }
  471. }
  472. function s() {
  473. const { props: t2, data: o2, node: l } = e;
  474. if (e.nodeDelete)
  475. return void e.nodeDelete(l.$$data);
  476. if (l.$$root)
  477. return void T.pretty("[提示] ", "根节点不允许删除", "danger");
  478. const { id: r, children: d } = t2, s2 = a(o2, t2, l.pid);
  479. if (s2) {
  480. const e2 = s2[d];
  481. for (let t3 = 0, o3 = e2.length; t3 < o3; t3++)
  482. if (e2[t3][r] === l.id) {
  483. e2.splice(t3, 1), n("onNodeDelete", l.$$data, l);
  484. break;
  485. }
  486. }
  487. }
  488. function c() {
  489. const { nodeEdit: t2, node: o2 } = e;
  490. t2 ? t2(o2.$$data) : (o2.$$focused = true, n("onNodeFocus", o2.$$data));
  491. }
  492. function u(o2) {
  493. if (e.modelValue) {
  494. if (t.eleRef.value && t.eleRef.value.contains(o2.target))
  495. return false;
  496. n("update:modelValue", false);
  497. }
  498. }
  499. const i = computed(() => ({ left: `${e.x}px`, top: `${e.y}px` })), p = computed(() => !e.disabled && !e.node.disabled);
  500. return onMounted(() => {
  501. document.addEventListener("mousedown", u);
  502. }), onUnmounted(() => {
  503. document.removeEventListener("mousedown", u);
  504. }), { position: i, editable: p, handleMenu: function(a2) {
  505. const l = a2.target;
  506. if ("zm-tree-menu-item" === l.className) {
  507. const a3 = l.getAttribute("action");
  508. switch (a3) {
  509. case "copy":
  510. !function() {
  511. if (e.nodeCopy)
  512. return void e.nodeCopy(e.node.$$data);
  513. o.value = e.node.label, nextTick(() => {
  514. t.inputRef && t.inputRef.value && (t.inputRef && t.inputRef.value.select(), navigator.clipboard.writeText(o.value).then(function() {
  515. T.pretty("[提示] ", "文本复制成功", "success");
  516. }, function() {
  517. T.pretty("[错误] ", "浏览器不支持", "danger");
  518. }), n("onNodeCopy", o.value));
  519. });
  520. }();
  521. break;
  522. case "add":
  523. !function() {
  524. if (e.nodeAdd)
  525. return void e.nodeAdd(e.node.$$data);
  526. const { id: t2, pid: o2, label: a4, expand: l2, children: r } = e.props, { node: d } = e, s2 = { [t2]: String((/* @__PURE__ */ new Date()).getTime()), [o2]: d.id, [a4]: "", [l2]: false, [r]: [], newNode: true, focused: true };
  527. Array.isArray(d.children) ? d.$$data[r].push(s2) : d.$$data[r] = [s2];
  528. n("onNodeFocus", s2);
  529. }();
  530. break;
  531. case "edit":
  532. c();
  533. break;
  534. case "delete":
  535. s();
  536. }
  537. n("contextmenu", { command: a3, node: e.node, data: e.node.$$data }), n("update:modelValue", false);
  538. }
  539. }, handleEdit: c, handleClose: u, afterEnter: function() {
  540. n("opened");
  541. }, afterLeave: function() {
  542. n("closed");
  543. } };
  544. };
  545. var $e = defineComponent({ name: "Contextmenu", props: ge({ modelValue: { type: Boolean, required: true }, data: { type: Object, required: true }, node: { type: ye(Object), required: true }, props: { type: ye(Object) }, x: Number, y: Number, menus: { type: ye(Array) }, nodeAdd: Function, nodeDelete: Function, nodeEdit: Function, nodeCopy: Function, disabled: Boolean }), emits: { onNodeDelete: (e, n) => A(e) && A(n), onNodeCopy: (e) => B(e), contextmenu: (e) => A(e), onNodeFocus: (e) => A(e), opened: () => true, closed: () => true, "update:modelValue": (e) => "boolean" == typeof e }, setup(e, n) {
  546. const t = ref(), o = ref();
  547. return { eleRef: o, inputRef: t, copyText: ref(""), oldData: reactive({}), ...xe(e, n, { inputRef: t, eleRef: o }) };
  548. } });
  549. var Ne = ["action"];
  550. $e.render = function(e, o, a, l, r, d) {
  551. return openBlock(), createBlock(Teleport, { to: "body" }, [createVNode(Transition, { name: "dialog-fade", onAfterEnter: e.afterEnter, onAfterLeave: e.afterLeave, persisted: "" }, { default: withCtx(() => [withDirectives(createBaseVNode("div", { style: normalizeStyle(e.position), onClick: o[1] || (o[1] = (...n) => e.handleMenu && e.handleMenu(...n)), ref: "eleRef", class: "zm-tree-contextmenu" }, [createBaseVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(e.menus, (n) => (openBlock(), createElementBlock(Fragment, null, [e.editable || !["add", "edit", "delete"].includes(n.command) ? (openBlock(), createElementBlock("li", { class: "zm-tree-menu-item", action: n.command, key: n.command }, toDisplayString(n.name), 9, Ne)) : createCommentVNode("v-if", true)], 64))), 256))]), withDirectives(createBaseVNode("textarea", { class: "copy-textarea", ref: "inputRef", "onUpdate:modelValue": o[0] || (o[0] = (n) => e.copyText = n) }, null, 512), [[vModelText, e.copyText]])], 4), [[vShow, e.modelValue]])]), _: 1 }, 8, ["onAfterEnter", "onAfterLeave"])]);
  552. }, $e.__file = "src/components/contextmenu/src/contextmenu.vue";
  553. var Se = [{ name: "复制文本", command: "copy" }, { name: "新增节点", command: "add" }, { name: "编辑节点", command: "edit" }, { name: "删除节点", command: "delete" }];
  554. var ze = ge({ data: { type: Object, required: true }, center: Boolean, props: { type: ye(Object), default: () => ({ id: "id", pid: "pid", label: "label", expand: "expand", children: "children" }) }, toolBar: { type: [Object, Boolean], default: () => ({ expand: true, scale: true, zoom: true, restore: true, fullscreen: true }) }, disabled: { type: Boolean, default: false }, scalable: { type: Boolean, default: true }, draggable: { type: Boolean, default: true }, draggableOnNode: { type: Boolean, default: false }, nodeDraggable: { type: Boolean, default: true }, cloneNodeDrag: { type: Boolean, default: true }, onlyOneNode: { type: Boolean, default: true }, clickDelay: { type: Number, default: 260 }, lazy: Boolean, load: { type: ye(Function) }, defaultExpandLevel: Number, defaultExpandKeys: { type: Array, default: () => [] }, beforeDragEnd: Function, horizontal: Boolean, selectedKey: { type: [Array, String, Number] }, collapsable: Boolean, renderContent: Function, labelStyle: Object, labelClassName: { type: [Function, String] }, selectedClassName: { type: [Function, String] }, defineMenus: { type: ye([Array, Function]), default: () => Se }, nodeAdd: Function, nodeDelete: Function, nodeEdit: Function, nodeCopy: Function, filterNodeMethod: Function });
  555. var Ee = (e, { emit: n }, t) => {
  556. const o = ref(0), a = ref(0), d = ref(false);
  557. function s(n2, l) {
  558. const r = t.zoomRef.value, d2 = t.treeRef.value;
  559. let s2 = r.clientWidth / 2;
  560. const c2 = r.clientHeight / 2;
  561. let u2 = r.clientHeight - d2.clientHeight, i2 = r.clientWidth - d2.clientWidth;
  562. if (u2 > 0 && (u2 = 0), i2 > 0 && (i2 = 0), e.center) {
  563. const e2 = (r.clientWidth - d2.clientWidth) / 2;
  564. i2 -= e2, s2 -= e2;
  565. }
  566. o.value = n2 > s2 ? s2 : n2 < i2 ? i2 : n2, a.value = l < u2 ? u2 : l > c2 ? c2 : l;
  567. }
  568. function c(e2, t2) {
  569. s(e2, t2), setTimeout(() => {
  570. Y.set(false);
  571. }, 200), n("on-drag-stop", { x: e2, y: t2 });
  572. }
  573. const u = ref(false), i = reactive({ value: {} });
  574. const p = ref(false), f = ref(0), m = ref(0), g = ref({}), h2 = ref([]);
  575. const b = ref(1);
  576. function x(n2) {
  577. if (!e.scalable)
  578. return;
  579. const t2 = Number((Number(b.value) + n2).toFixed(1));
  580. b.value = n2 > 0 ? Math.min(3, t2) : Math.max(0.3, t2);
  581. }
  582. function $(n2, t2, l) {
  583. if (d.value = true, console.log(e.center, e.horizontal, n2.offsetLeft, t2), !e.center || e.horizontal) {
  584. const e2 = n2.offsetLeft - t2;
  585. o.value -= e2;
  586. }
  587. const r = n2.offsetTop - l;
  588. a.value -= r, s(o.value, a.value);
  589. }
  590. let N;
  591. const S = reactive(Object.assign({ id: "id", pid: "pid", label: "label", expand: "expand", children: "children", isLeaf: "isLeaf" }, e.props));
  592. const z = ref(false);
  593. function E(e2) {
  594. e2.forEach((e3) => {
  595. e3.expand && (e3.expand = false, T2.delete(e3.id)), e3.children && E(e3.children);
  596. });
  597. }
  598. const D = ref(false);
  599. function M(e2, n2) {
  600. Array.isArray(e2) ? e2.forEach((e3) => {
  601. n2 && T2.add(e3.id), e3.expand = n2, n2 && T2.add(e3.id), e3.children && M(e3.children, n2);
  602. }) : (n2 && T2.add(e2.id), e2.expand = n2, n2 && T2.add(e2.id), e2.children && M(e2.children, n2));
  603. }
  604. function O(e2) {
  605. V2.value = j2(e2);
  606. }
  607. const w = computed(() => ({ width: 100 / b.value + "%", height: 100 / b.value + "%", transform: `scale(${b.value})` })), _ = computed(() => `${Math.round(100 * b.value)}%`), R2 = computed(() => e.draggableOnNode && !e.nodeDraggable ? "" : `.tree-org-node__content:not(.is-root_${X2})>.tree-org-node__inner`), F2 = computed(() => D.value ? "收起全部节点" : "展开全部节点"), A2 = computed(() => D.value ? "收起全部节点" : "展开全部节点"), B2 = ref({}), L2 = computed(() => {
  608. const { cloneNodeDrag: t2, onlyOneNode: o2, data: a2 } = e;
  609. return { drag: e.nodeDraggable, dragData: { keys: S, nodeMoving: u, stopClick: Y, parenNode: i, cloneNodeDrag: t2, onlyOneNode: o2, contextmenu: p, cloneData: B2, data: a2 }, beforeDragEnd: e.beforeDragEnd, initNodes: j2, emit: n };
  610. });
  611. watch(() => e.horizontal, () => {
  612. nextTick(() => {
  613. c(o.value, a.value);
  614. });
  615. });
  616. let T2 = new Set(e.defaultExpandKeys);
  617. function j2(n2) {
  618. const { defaultExpandLevel: t2 = 0 } = e, o2 = (e2, n3) => {
  619. const { id: a2, label: l, pid: r, expand: d2, children: s2, isLeaf: c2 } = S, u2 = {};
  620. Object.keys(e2).map((n4) => {
  621. ["hidden", "disabled", "className", "style"].includes(n4) && (u2[n4] = e2[n4]);
  622. });
  623. const i2 = e2[s2], p2 = n3 + 1, f2 = e2[d2], m2 = e2[a2];
  624. return (f2 || void 0 === f2 && n3 < t2) && T2.add(m2), { ...u2, id: m2, label: e2[l], pid: e2[r], expand: T2.has(m2), children: i2 ? i2.map((e3) => o2(e3, p2)) : void 0, isLeaf: e2[c2], $$level: n3, $$data: e2, $$focused: e2.focused || false };
  625. };
  626. return o2(n2, 0);
  627. }
  628. const V2 = ref(j2(e.data));
  629. watch(() => e.data, (n2, t2) => {
  630. n2 !== t2 && (T2 = new Set(e.defaultExpandKeys)), O(e.data);
  631. }, { deep: true });
  632. const P2 = reactive({ visible: true, data: { expand: true, scale: true, zoom: true, restore: true, fullscreen: true } });
  633. onBeforeMount(() => {
  634. "object" == typeof e.toolBar ? Object.assign(P2.data, e.toolBar) : e.toolBar || (P2.visible = false);
  635. });
  636. const X2 = function(e2) {
  637. e2 = e2 || 32;
  638. const n2 = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678", t2 = n2.length;
  639. let o2 = "";
  640. for (let a2 = 0; a2 < e2; a2++)
  641. o2 += n2.charAt(Math.floor(Math.random() * t2));
  642. return o2;
  643. }(6);
  644. return { keys: S, left: o, top: a, menuX: f, menuY: m, suffix: X2, nodeMoving: u, zoomStyle: w, tools: P2, zoomPercent: _, dragCancel: R2, expandTitle: F2, fullTiltle: A2, nodeargs: L2, expanded: D, fullscreen: z, treeData: V2, autoDragging: d, contextmenu: p, nodeMenus: h2, menuData: g, cloneData: B2, filter: function(n2) {
  645. const t2 = e.filterNodeMethod;
  646. if (!t2)
  647. throw new Error("[Tree] filterNodeMethod is required when filter");
  648. const o2 = function(e2) {
  649. const a2 = e2.children || [];
  650. if (a2.forEach((e3) => {
  651. e3.$$hidden = !t2.call(e3, n2, e3), o2(e3);
  652. }), e2.$$hidden && a2.length) {
  653. let n3 = true;
  654. n3 = a2.some((e3) => !e3.$$hidden), e2.$$hidden = !n3;
  655. }
  656. n2 && !e2.$$hidden && e2.children && (e2.expand = true);
  657. };
  658. o2(V2.value);
  659. }, setData: O, zoomWheel: function(t2) {
  660. e.scalable && (t2.preventDefault(), t2.deltaY < 0 ? x(0.1) : x(-0.1), n("on-zoom", b.value));
  661. }, onDrag: function(e2, t2) {
  662. Y.set(true), d.value = false, o.value = e2, a.value = t2, n("on-drag", { x: e2, y: t2 });
  663. }, onDragStop: c, expandChange: function() {
  664. D.value = !D.value, D.value || (T2.clear(), nextTick(() => {
  665. c(o.value, a.value);
  666. })), M(V2.value, D.value), n("on-expand-all", D.value);
  667. }, handleFullscreen: function(e2) {
  668. z.value = !z.value, "esc" !== e2 && (z.value ? function() {
  669. const e3 = t.eleRef.value;
  670. e3.requestFullscreen && e3.requestFullscreen();
  671. }() : document.exitFullscreen && document.exitFullscreen());
  672. }, zoomOrgchart: x, restoreOrgchart: function() {
  673. b.value = 1, o.value = 0, a.value = 0, n("on-restore");
  674. }, handleExpand: function(t2, o2) {
  675. t2.stopPropagation();
  676. const a2 = document.querySelector(`.is-root_${X2}`);
  677. if (a2) {
  678. const l = a2.offsetLeft, r = a2.offsetTop;
  679. o2.expand = !o2.expand;
  680. let d2 = true;
  681. o2.expand ? (T2.add(o2.id), e.lazy && e.load && (d2 = false, function(e2, n2, t3) {
  682. n2(e2, (n3, o3) => {
  683. const { children: a3 } = S;
  684. e2.isLeaf = !n3.length, n3.length && (e2.$$data[a3] = n3, o3 && t3());
  685. });
  686. }(o2, e.load, () => {
  687. nextTick(() => {
  688. $(a2, l, r);
  689. });
  690. }))) : !o2.expand && o2.children && (T2.delete(o2.id), E(o2.children)), nextTick(() => {
  691. d2 && $(a2, l, r);
  692. }), n("on-expand", t2, o2.$$data, o2);
  693. }
  694. }, getExpandKeys: function() {
  695. return [...T2];
  696. }, setExpandKeys: function(n2) {
  697. T2 = new Set(n2), O(e.data);
  698. }, nodeMouseenter: function(e2, t2) {
  699. return u.value && (i.value = t2), n("on-node-mouseenter", e2, t2.$$data, t2), true;
  700. }, nodeMouseleave: function(e2, t2) {
  701. return u.value && (i.value = null), n("on-node-mouseleave", e2, t2.$$data, t2), true;
  702. }, nodeContextmenu: function(n2, t2) {
  703. n2.stopPropagation(), n2.preventDefault();
  704. const { defineMenus: o2 } = e;
  705. Array.isArray(o2) ? h2.value = o2 : "function" == typeof o2 && (h2.value = o2(n2, t2) || []), p.value = true, f.value = n2.clientX, m.value = n2.clientY, g.value = t2;
  706. }, handleFocus: function(e2, t2, o2) {
  707. n("on-node-focus", e2, t2, o2);
  708. }, handleBlur: function(e2, t2, o2) {
  709. const { id: a2, label: l } = S, r = g.value.children || [];
  710. for (let e3 = r.length; e3 > 0; e3--) {
  711. const n2 = r[e3 - 1];
  712. if ("" === n2[a2] && "" === n2[l]) {
  713. r.splice(e3 - 1, 1);
  714. break;
  715. }
  716. }
  717. n("on-node-blur", e2, t2, o2);
  718. }, handleClick: function(t2, o2) {
  719. Y.get() || (clearTimeout(N), N = setTimeout(() => {
  720. n("on-node-click", t2, o2.$$data, o2);
  721. }, e.clickDelay));
  722. }, handleDblclick: function(e2, t2) {
  723. clearTimeout(N), n("on-node-dblclick", e2, t2.$$data, t2);
  724. } };
  725. };
  726. var De = defineComponent({ name: "vue3TreeOrg", components: { Tools: Q, CloneOrg: be, Draggable: he, Contextmenu: $e, TreeOrgNode: G }, directives: { nodedrag: K }, props: ze, emits: { "on-drag": ({ x: e, y: n }) => L(e) && L(n), "on-drag-stop": ({ x: e, y: n }) => L(e) && L(n), "on-restore": () => true, "on-zoom": (e) => L(e), "on-expand": (e, n, t) => e instanceof MouseEvent && A(t) && A(n), "on-expand-all": (e) => "boolean" == typeof e, "on-node-blur": (e, n, t) => e instanceof FocusEvent && A(t) && A(n), "on-node-click": (e, n, t) => e instanceof MouseEvent && A(t) && A(n), "on-node-dblclick": (e, n, t) => e instanceof MouseEvent && A(t) && A(n), "on-node-mouseenter": (e, n, t) => e instanceof MouseEvent && A(t) && A(n), "on-node-mouseleave": (e, n, t) => e instanceof MouseEvent && A(t) && A(n), "on-contextmenu": (e) => A(e), "on-node-copy": (e) => B(e), "on-node-delete": (e) => A(e), "on-node-drag-start": (e) => A(e), "on-node-drag": (e) => A(e), "on-node-drag-end": (e, n) => A(e) && A(n), "on-node-focus": (e, n, t) => e instanceof FocusEvent && A(t) && A(n) }, setup(e, n) {
  727. const t = !!n.slots.default, o = !!n.slots.expand, a = ref(), r = ref(), d = ref();
  728. return { eleRef: a, treeRef: r, zoomRef: d, defaultSlot: t, expandSlot: o, ...Ee(e, n, { eleRef: a, treeRef: r, zoomRef: d }) };
  729. } });
  730. var Ce = { ref: "eleRef", class: "zm-tree-org" };
  731. var ke = { class: "tree-org-node__text" };
  732. var Me = createBaseVNode("span", { class: "tree-org-node__expand-btn" }, null, -1);
  733. var Oe = { class: "tree-org-node__text" };
  734. var we = createBaseVNode("span", { class: "tree-org-node__expand-btn" }, null, -1);
  735. De.render = function(e, n, t, o, a, l) {
  736. const r = resolveComponent("tree-org-node"), d = resolveComponent("Draggable"), s = resolveComponent("Tools"), v = resolveComponent("clone-org"), g = resolveComponent("Contextmenu");
  737. return openBlock(), createElementBlock("div", Ce, [createBaseVNode("div", { ref: "zoomRef", class: normalizeClass(["zoom-container", { "is-center": e.center && !e.horizontal }]), style: normalizeStyle(e.zoomStyle), onWheel: n[0] || (n[0] = (...n2) => e.zoomWheel && e.zoomWheel(...n2)) }, [createVNode(d, { x: e.left, y: e.top, class: normalizeClass({ dragging: e.autoDragging }), onDragging: e.onDrag, onDragstop: e.onDragStop, draggable: e.draggable, "drag-cancel": e.dragCancel }, { default: withCtx(() => [createBaseVNode("div", { ref: "treeRef", class: normalizeClass(["tree-org", { horizontal: e.horizontal, collapsable: e.collapsable }]) }, [createVNode(r, { data: e.treeData, props: e.keys, lazy: e.lazy, suffix: e.suffix, horizontal: e.horizontal, labelStyle: e.labelStyle, collapsable: e.collapsable, renderContent: e.renderContent, selectedKey: e.selectedKey, defaultExpandLevel: e.defaultExpandLevel, selectedClassName: e.selectedClassName, labelClassName: e.labelClassName, vNodedrag: e.nodeargs, onOnExpand: e.handleExpand, onNodeClick: e.handleClick, onNodeDblclick: e.handleDblclick, onNodeMouseenter: e.nodeMouseenter, onNodeMouseleave: e.nodeMouseleave, onNodeContextmenu: e.nodeContextmenu, onNodeFocus: e.handleFocus, onNodeBlur: e.handleBlur }, createSlots({ _: 2 }, [e.defaultSlot ? { name: "default", fn: withCtx(({ node: n2 }) => [renderSlot(e.$slots, "default", { node: n2 }, () => [createBaseVNode("div", ke, [createBaseVNode("span", null, toDisplayString(n2.label), 1)])])]) } : void 0, e.expandSlot ? { name: "expand", fn: withCtx(({ node: n2 }) => [renderSlot(e.$slots, "expand", { node: n2 }, () => [Me])]) } : void 0]), 1032, ["data", "props", "lazy", "suffix", "horizontal", "labelStyle", "collapsable", "renderContent", "selectedKey", "defaultExpandLevel", "selectedClassName", "labelClassName", "vNodedrag", "onOnExpand", "onNodeClick", "onNodeDblclick", "onNodeMouseenter", "onNodeMouseleave", "onNodeContextmenu", "onNodeFocus", "onNodeBlur"])], 2)]), _: 3 }, 8, ["x", "y", "class", "onDragging", "onDragstop", "draggable", "drag-cancel"])], 38), e.tools.visible ? (openBlock(), createBlock(s, { key: 0, tools: e.tools.data, scale: e.zoomPercent, onOnExpand: e.expandChange, onOnScale: e.zoomOrgchart, onOnRestore: e.restoreOrgchart, onOnFullscreen: e.handleFullscreen }, null, 8, ["tools", "scale", "onOnExpand", "onOnScale", "onOnRestore", "onOnFullscreen"])) : createCommentVNode("v-if", true), e.nodeDraggable ? (openBlock(), createBlock(v, { key: 1, modelValue: e.nodeMoving, "onUpdate:modelValue": n[1] || (n[1] = (n2) => e.nodeMoving = n2), props: e.keys, data: e.cloneData, horizontal: e.horizontal, "label-style": e.labelStyle, collapsable: e.collapsable, "render-content": e.renderContent, "label-class-name": e.labelClassName }, createSlots({ _: 2 }, [e.defaultSlot ? { name: "default", fn: withCtx(({ node: n2 }) => [renderSlot(e.$slots, "default", { node: n2 }, () => [createBaseVNode("div", Oe, [createBaseVNode("span", null, toDisplayString(n2[e.keys.label]), 1)])])]) } : void 0, e.expandSlot ? { name: "expand", fn: withCtx(({ node: n2 }) => [renderSlot(e.$slots, "expand", { node: n2 }, () => [we])]) } : void 0]), 1032, ["modelValue", "props", "data", "horizontal", "label-style", "collapsable", "render-content", "label-class-name"])) : createCommentVNode("v-if", true), e.nodeMenus.length ? (openBlock(), createBlock(g, { key: 2, modelValue: e.contextmenu, "onUpdate:modelValue": n[2] || (n[2] = (n2) => e.contextmenu = n2), x: e.menuX, y: e.menuY, node: e.menuData, data: e.data, props: e.keys, menus: e.nodeMenus, disabled: e.disabled, "node-add": e.nodeAdd, "node-delete": e.nodeDelete, "node-edit": e.nodeEdit, "node-copy": e.nodeCopy, onContextmenu: n[3] || (n[3] = (n2) => {
  738. e.$emit("on-contextmenu", n2);
  739. }), onOnNodeCopy: n[4] || (n[4] = (n2) => {
  740. e.$emit("on-node-copy", n2);
  741. }), onOnNodeDelete: n[5] || (n[5] = (n2) => {
  742. e.$emit("on-node-delete", n2);
  743. }) }, null, 8, ["modelValue", "x", "y", "node", "data", "props", "menus", "disabled", "node-add", "node-delete", "node-edit", "node-copy"])) : createCommentVNode("v-if", true)], 512);
  744. }, De.__file = "src/components/tree-org/src/tree.vue", De.install = function(e) {
  745. e.component(De.name, De);
  746. };
  747. var _e = [De];
  748. var Re = { install: function(e) {
  749. _e.forEach((n) => {
  750. e.component(n.name, n);
  751. }), e.use(V);
  752. }, Vue3TreeOrg: De };
  753. export {
  754. De as Vue3TreeOrg,
  755. Re as default
  756. };
  757. //# sourceMappingURL=vue3-tree-org.js.map