UNPKG

gepic

Version:

基于vue3的设计器,可视化开发页面表单

79 lines (78 loc) 3.35 kB
import { defineComponent as H, useAttrs as I, inject as d, ref as S, provide as M, computed as k, watch as P, onUnmounted as w, resolveComponent as A, createBlock as l, openBlock as c, unref as _, createSlots as F, withCtx as y, createElementBlock as R, Fragment as T, renderList as U, createCommentVNode as b } from "vue"; import j from "../../../../node/src/node.vue.js"; import V from "./editNodeItem.vue.js"; import { pluginManager as C } from "../../../../../../utils/manager/pluginManager.js"; import "@vueuse/core"; import "../../../../../../hooks/store/index.js"; const O = /* @__PURE__ */ H({ name: "ENodeItem", __name: "nodeItem", props: { schema: {}, name: {} }, setup(N) { const L = I(), i = d("designer"), E = d("pageManager", {}), B = d("pageSchema", {}), $ = S(null); M("nodeAttrs", L); const o = N, x = k(() => !o.schema.children), m = k(() => { var a, r, h, v, g; const e = E.componentInstances.value, t = (a = o.schema) == null ? void 0 : a.id, n = C.getComponentConfingByType((r = o.schema) == null ? void 0 : r.type) ?? null; if (!t || !(e != null && e[t])) return null; if (n != null && n.defaultSchema.input && ((h = o.schema) == null ? void 0 : h.noFormItem) !== !0) return (v = e[t + "formItem"]) == null ? void 0 : v.$el; const s = e[t]; return ((g = s == null ? void 0 : s.$el) == null ? void 0 : g.nodeName) === "#text" ? null : s == null ? void 0 : s.$el; }); P(() => m.value, (e) => { var t, n; e && (e.addEventListener("click", u, !1), e.addEventListener("mouseover", f, !1), e.addEventListener("mouseout", p, !1), x.value ? (t = e.classList) == null || t.add("epic-node-mask") : (n = e.classList) == null || n.remove("epic-node-mask")); }), w(() => { var e, t, n; (e = m.value) == null || e.removeEventListener("click", u, !1), (t = m.value) == null || t.removeEventListener("mouseover", f, !1), (n = m.value) == null || n.removeEventListener("mouseout", p, !1); }); function u(e) { e.stopPropagation(), i.setCheckedNode(o.schema); } function f(e) { var t; o.schema.id !== ((t = B.schemas[0]) == null ? void 0 : t.id) && (e.stopPropagation(), i.setHoverNode(o.schema)); } function p(e) { e.stopPropagation(), i.setHoverNode(null); } return (e, t) => { var s, a; const n = A("ENodeItem"); return c(), l(_(j), { ref_key: "nodeRef", ref: $, "component-schema": o.schema }, F({ _: 2 }, [ (a = (s = _(C).getComponentConfingByType(o.schema.type)) == null ? void 0 : s.editConstraints) != null && a.childImmovable ? { name: "edit-node", fn: y(() => [ (c(!0), R(T, null, U(o.schema.children, (r) => (c(), l(n, { key: r.id, schema: r }, null, 8, ["schema"]))), 128)) ]), key: "0" } : { name: "edit-node", fn: y(() => [ o.schema.children ? (c(), l(V, { key: 0, schemas: o.schema.children, "onUpdate:schemas": t[0] || (t[0] = (r) => o.schema.children = r) }, null, 8, ["schemas"])) : b("", !0) ]), key: "1" } ]), 1032, ["component-schema"]); }; } }); export { O as default };