UNPKG

epic-designer-cjh

Version:

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

649 lines (648 loc) 19.1 kB
import { onMounted as me, watchEffect as De, onBeforeUnmount as Me, isRef as _e, watch as G, onScopeDispose as Ne, defineComponent as H, createVNode as Y, renderSlot as C, h as Be, inject as se, computed as L, openBlock as A, createElementBlock as q, unref as s, normalizeClass as k, normalizeStyle as pe, createElementVNode as W, toDisplayString as Ie, withCtx as N, createBlock as K, resolveDynamicComponent as Fe, createCommentVNode as J, getCurrentInstance as Oe, ref as B, nextTick as Ae, useSlots as Le, provide as $e, Teleport as Pe, Transition as Re, withDirectives as Ve, mergeProps as ze, createSlots as Ye, vShow as He } from "vue"; import { ai as ve, aA as Z, bF as We, as as X, a4 as Xe, bG as ye, aO as je, a9 as te, av as he, aG as ne, aj as Ue, bH as qe, bI as xe, a5 as oe, a6 as Q, bJ as x, af as Ge, ag as ge, at as be, aw as Ke, bi as le, bk as Je, bz as ae, aQ as ie, aF as Ze } from "./index-97ce4605.js"; import { i as Qe, u as et, C as tt, c as ot } from "./index-da336cb2.js"; import { g as st, F as nt, E as lt } from "./focus-trap-06d2e133.js"; import { a as at } from "./use-global-config-0bac757e.js"; const it = (...e) => (t) => { e.forEach((o) => { ve(o) ? o(t) : o.value = t; }); }, rt = (e, t, o) => { let n = { offsetX: 0, offsetY: 0 }; const l = (r) => { const d = r.clientX, v = r.clientY, { offsetX: f, offsetY: y } = n, i = e.value.getBoundingClientRect(), m = i.left, T = i.top, $ = i.width, P = i.height, R = document.documentElement.clientWidth, I = document.documentElement.clientHeight, V = -m + f, F = -T + y, S = R - m - $ + f, D = I - T - P + y, O = (E) => { const c = Math.min(Math.max(f + E.clientX - d, V), S), b = Math.min(Math.max(y + E.clientY - v, F), D); n = { offsetX: c, offsetY: b }, e.value.style.transform = `translate(${Z(c)}, ${Z(b)})`; }, h = () => { document.removeEventListener("mousemove", O), document.removeEventListener("mouseup", h); }; document.addEventListener("mousemove", O), document.addEventListener("mouseup", h); }, u = () => { t.value && e.value && t.value.addEventListener("mousedown", l); }, a = () => { t.value && e.value && t.value.removeEventListener("mousedown", l); }; me(() => { De(() => { o.value ? u() : a(); }); }), Me(() => { a(); }); }; let ct; function ut(e, t = ct) { t && t.active && t.effects.push(e); } const re = (e) => { const t = new Set(e); return t.w = 0, t.n = 0, t; }, Ce = (e) => (e.w & w) > 0, Ee = (e) => (e.n & w) > 0, dt = ({ deps: e }) => { if (e.length) for (let t = 0; t < e.length; t++) e[t].w |= w; }, ft = (e) => { const { deps: t } = e; if (t.length) { let o = 0; for (let n = 0; n < t.length; n++) { const l = t[n]; Ce(l) && !Ee(l) ? l.delete(e) : t[o++] = l, l.w &= ~w, l.n &= ~w; } t.length = o; } }; let z = 0, w = 1; const ee = 30; let p; Symbol(process.env.NODE_ENV !== "production" ? "iterate" : ""); Symbol(process.env.NODE_ENV !== "production" ? "Map key iterate" : ""); class mt { constructor(t, o = null, n) { this.fn = t, this.scheduler = o, this.active = !0, this.deps = [], this.parent = void 0, ut(this, n); } run() { if (!this.active) return this.fn(); let t = p, o = j; for (; t; ) { if (t === this) return; t = t.parent; } try { return this.parent = p, p = this, j = !0, w = 1 << ++z, z <= ee ? dt(this) : ce(this), this.fn(); } finally { z <= ee && ft(this), w = 1 << --z, p = this.parent, j = o, this.parent = void 0, this.deferStop && this.stop(); } } stop() { p === this ? this.deferStop = !0 : this.active && (ce(this), this.onStop && this.onStop(), this.active = !1); } } function ce(e) { const { deps: t } = e; if (t.length) { for (let o = 0; o < t.length; o++) t[o].delete(e); t.length = 0; } } let j = !0; function ue(e, t) { let o = !1; z <= ee ? Ee(e) || (e.n |= w, o = !Ce(e)) : o = !e.has(p), o && (e.add(p), p.deps.push(e), process.env.NODE_ENV !== "production" && p.onTrack && p.onTrack( ye( { effect: p }, t ) )); } function de(e, t) { const o = Xe(e) ? e : [...e]; for (const n of o) n.computed && fe(n, t); for (const n of o) n.computed || fe(n, t); } function fe(e, t) { (e !== p || e.allowRecurse) && (process.env.NODE_ENV !== "production" && e.onTrigger && e.onTrigger(ye({ effect: e }, t)), e.scheduler ? e.scheduler() : e.run()); } new Set( /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(We) ); function U(e) { const t = e && e.__v_raw; return t ? U(t) : e; } function pt(e) { j && p && (e = U(e), process.env.NODE_ENV !== "production" ? ue(e.dep || (e.dep = re()), { target: e, type: "get", key: "value" }) : ue(e.dep || (e.dep = re()))); } function vt(e, t) { e = U(e); const o = e.dep; o && (process.env.NODE_ENV !== "production" ? de(o, { target: e, type: "set", key: "value", newValue: t }) : de(o)); } class yt { constructor(t, o, n, l) { this._setter = o, this.dep = void 0, this.__v_isRef = !0, this.__v_isReadonly = !1, this._dirty = !0, this.effect = new mt(t, () => { this._dirty || (this._dirty = !0, vt(this)); }), this.effect.computed = this, this.effect.active = this._cacheable = !l, this.__v_isReadonly = n; } get value() { const t = U(this); return pt(t), (t._dirty || !t._cacheable) && (t._dirty = !1, t._value = t.effect.run()), t._value; } set value(t) { this._setter(t); } } function ht(e, t, o = !1) { let n, l; const u = ve(e); u ? (n = e, l = process.env.NODE_ENV !== "production" ? () => { console.warn("Write operation failed: computed value is readonly"); } : X) : (n = e.get, l = e.set); const a = new yt(n, l, u || !l, o); return process.env.NODE_ENV !== "production" && t && !o && (a.effect.onTrack = t.onTrack, a.effect.onTrigger = t.onTrigger), a; } const gt = (e, t = {}) => { _e(e) || je("[useLockscreen]", "You need to pass a ref param to this function"); const o = t.ns || te("popup"), n = ht(() => o.bm("parent", "hidden")); if (!he || ne(document.body, n.value)) return; let l = 0, u = !1, a = "0"; const r = () => { setTimeout(() => { xe(document == null ? void 0 : document.body, n.value), u && document && (document.body.style.width = a); }, 200); }; G(e, (d) => { if (!d) { r(); return; } u = !ne(document.body, n.value), u && (a = document.body.style.width), l = st(o.namespace.value); const v = document.documentElement.clientHeight < document.body.scrollHeight, f = Ue(document.body, "overflowY"); l > 0 && (v || f === "scroll") && u && (document.body.style.width = `calc(100% - ${l}px)`), qe(document.body, n.value); }), Ne(() => r()); }, ke = (e) => { if (!e) return { onClick: X, onMousedown: X, onMouseup: X }; let t = !1, o = !1; return { onClick: (a) => { t && o && e(a), t = o = !1; }, onMousedown: (a) => { t = a.target === a.currentTarget; }, onMouseup: (a) => { o = a.target === a.currentTarget; } }; }, bt = oe({ mask: { type: Boolean, default: !0 }, customMaskEvent: { type: Boolean, default: !1 }, overlayClass: { type: Q([ String, Array, Object ]) }, zIndex: { type: Q([String, Number]) } }), Ct = { click: (e) => e instanceof MouseEvent }, Et = "overlay"; var kt = H({ name: "ElOverlay", props: bt, emits: Ct, setup(e, { slots: t, emit: o }) { const n = te(Et), l = (d) => { o("click", d); }, { onClick: u, onMousedown: a, onMouseup: r } = ke(e.customMaskEvent ? void 0 : l); return () => e.mask ? Y("div", { class: [n.b(), e.overlayClass], style: { zIndex: e.zIndex }, onClick: u, onMousedown: a, onMouseup: r }, [C(t, "default")], x.STYLE | x.CLASS | x.PROPS, ["onClick", "onMouseup", "onMousedown"]) : Be("div", { class: e.overlayClass, style: { zIndex: e.zIndex, position: "fixed", top: "0px", right: "0px", bottom: "0px", left: "0px" } }, [C(t, "default")]); } }); const wt = kt, we = Symbol("dialogInjectionKey"), Te = oe({ center: { type: Boolean, default: !1 }, alignCenter: { type: Boolean, default: !1 }, closeIcon: { type: Qe }, customClass: { type: String, default: "" }, draggable: { type: Boolean, default: !1 }, fullscreen: { type: Boolean, default: !1 }, showClose: { type: Boolean, default: !0 }, title: { type: String, default: "" } }), Tt = { close: () => !0 }, St = ["aria-label"], Dt = ["id"], Mt = H({ name: "ElDialogContent" }), _t = /* @__PURE__ */ H({ ...Mt, props: Te, emits: Tt, setup(e) { const t = e, { t: o } = et(), { Close: n } = tt, { dialogRef: l, headerRef: u, bodyId: a, ns: r, style: d } = se(we), { focusTrapRef: v } = se(nt), f = it(v, l), y = L(() => t.draggable); return rt(l, u, y), (i, m) => (A(), q("div", { ref: s(f), class: k([ s(r).b(), s(r).is("fullscreen", i.fullscreen), s(r).is("draggable", s(y)), s(r).is("align-center", i.alignCenter), { [s(r).m("center")]: i.center }, i.customClass ]), style: pe(s(d)), tabindex: "-1" }, [ W("header", { ref_key: "headerRef", ref: u, class: k(s(r).e("header")) }, [ C(i.$slots, "header", {}, () => [ W("span", { role: "heading", class: k(s(r).e("title")) }, Ie(i.title), 3) ]), i.showClose ? (A(), q("button", { key: 0, "aria-label": s(o)("el.dialog.close"), class: k(s(r).e("headerbtn")), type: "button", onClick: m[0] || (m[0] = (T) => i.$emit("close")) }, [ Y(s(Ge), { class: k(s(r).e("close")) }, { default: N(() => [ (A(), K(Fe(i.closeIcon || s(n)))) ]), _: 1 }, 8, ["class"]) ], 10, St)) : J("v-if", !0) ], 2), W("div", { id: s(a), class: k(s(r).e("body")) }, [ C(i.$slots, "default") ], 10, Dt), i.$slots.footer ? (A(), q("footer", { key: 0, class: k(s(r).e("footer")) }, [ C(i.$slots, "footer") ], 2)) : J("v-if", !0) ], 6)); } }); var Nt = /* @__PURE__ */ ge(_t, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/dialog/src/dialog-content.vue"]]); const Bt = oe({ ...Te, appendToBody: { type: Boolean, default: !1 }, beforeClose: { type: Q(Function) }, destroyOnClose: { type: Boolean, default: !1 }, closeOnClickModal: { type: Boolean, default: !0 }, closeOnPressEscape: { type: Boolean, default: !0 }, lockScroll: { type: Boolean, default: !0 }, modal: { type: Boolean, default: !0 }, openDelay: { type: Number, default: 0 }, closeDelay: { type: Number, default: 0 }, top: { type: String }, modelValue: { type: Boolean, default: !1 }, modalClass: String, width: { type: [String, Number] }, zIndex: { type: Number }, trapFocus: { type: Boolean, default: !1 } }), It = { open: () => !0, opened: () => !0, close: () => !0, closed: () => !0, [be]: (e) => Ke(e), openAutoFocus: () => !0, closeAutoFocus: () => !0 }, Ft = (e, t) => { const n = Oe().emit, { nextZIndex: l } = ot(); let u = ""; const a = le(), r = le(), d = B(!1), v = B(!1), f = B(!1), y = B(e.zIndex || l()); let i, m; const T = at("namespace", Je), $ = L(() => { const g = {}, _ = `--${T.value}-dialog`; return e.fullscreen || (e.top && (g[`${_}-margin-top`] = e.top), e.width && (g[`${_}-width`] = Z(e.width))), g; }), P = L(() => e.alignCenter ? { display: "flex" } : {}); function R() { n("opened"); } function I() { n("closed"), n(be, !1), e.destroyOnClose && (f.value = !1); } function V() { n("close"); } function F() { m == null || m(), i == null || i(), e.openDelay && e.openDelay > 0 ? { stop: i } = ae(() => h(), e.openDelay) : h(); } function S() { i == null || i(), m == null || m(), e.closeDelay && e.closeDelay > 0 ? { stop: m } = ae(() => E(), e.closeDelay) : E(); } function D() { function g(_) { _ || (v.value = !0, d.value = !1); } e.beforeClose ? e.beforeClose(g) : S(); } function O() { e.closeOnClickModal && D(); } function h() { he && (d.value = !0); } function E() { d.value = !1; } function c() { n("openAutoFocus"); } function b() { n("closeAutoFocus"); } function M(g) { var _; ((_ = g.detail) == null ? void 0 : _.focusReason) === "pointer" && g.preventDefault(); } e.lockScroll && gt(d); function Se() { e.closeOnPressEscape && D(); } return G(() => e.modelValue, (g) => { g ? (v.value = !1, F(), f.value = !0, y.value = e.zIndex ? y.value++ : l(), Ae(() => { n("open"), t.value && (t.value.scrollTop = 0); })) : d.value && S(); }), G(() => e.fullscreen, (g) => { t.value && (g ? (u = t.value.style.transform, t.value.style.transform = "") : t.value.style.transform = u); }), me(() => { e.modelValue && (d.value = !0, f.value = !0, F()); }), { afterEnter: R, afterLeave: I, beforeLeave: V, handleClose: D, onModalClick: O, close: S, doClose: E, onOpenAutoFocus: c, onCloseAutoFocus: b, onCloseRequested: Se, onFocusoutPrevented: M, titleId: a, bodyId: r, closed: v, style: $, overlayDialogStyle: P, rendered: f, visible: d, zIndex: y }; }, Ot = ["aria-label", "aria-labelledby", "aria-describedby"], At = H({ name: "ElDialog", inheritAttrs: !1 }), Lt = /* @__PURE__ */ H({ ...At, props: Bt, emits: It, setup(e, { expose: t }) { const o = e, n = Le(); ie({ scope: "el-dialog", from: "the title slot", replacement: "the header slot", version: "3.0.0", ref: "https://element-plus.org/en-US/component/dialog.html#slots" }, L(() => !!n.title)), ie({ scope: "el-dialog", from: "custom-class", replacement: "class", version: "2.3.0", ref: "https://element-plus.org/en-US/component/dialog.html#attributes", type: "Attribute" }, L(() => !!o.customClass)); const l = te("dialog"), u = B(), a = B(), r = B(), { visible: d, titleId: v, bodyId: f, style: y, overlayDialogStyle: i, rendered: m, zIndex: T, afterEnter: $, afterLeave: P, beforeLeave: R, handleClose: I, onModalClick: V, onOpenAutoFocus: F, onCloseAutoFocus: S, onCloseRequested: D, onFocusoutPrevented: O } = Ft(o, u); $e(we, { dialogRef: u, headerRef: a, bodyId: f, ns: l, rendered: m, style: y }); const h = ke(V), E = L(() => o.draggable && !o.fullscreen); return t({ visible: d, dialogContentRef: r }), (c, b) => (A(), K(Pe, { to: "body", disabled: !c.appendToBody }, [ Y(Re, { name: "dialog-fade", onAfterEnter: s($), onAfterLeave: s(P), onBeforeLeave: s(R), persisted: "" }, { default: N(() => [ Ve(Y(s(wt), { "custom-mask-event": "", mask: c.modal, "overlay-class": c.modalClass, "z-index": s(T) }, { default: N(() => [ W("div", { role: "dialog", "aria-modal": "true", "aria-label": c.title || void 0, "aria-labelledby": c.title ? void 0 : s(v), "aria-describedby": s(f), class: k(`${s(l).namespace.value}-overlay-dialog`), style: pe(s(i)), onClick: b[0] || (b[0] = (...M) => s(h).onClick && s(h).onClick(...M)), onMousedown: b[1] || (b[1] = (...M) => s(h).onMousedown && s(h).onMousedown(...M)), onMouseup: b[2] || (b[2] = (...M) => s(h).onMouseup && s(h).onMouseup(...M)) }, [ Y(s(lt), { loop: "", trapped: s(d), "focus-start-el": "container", onFocusAfterTrapped: s(F), onFocusAfterReleased: s(S), onFocusoutPrevented: s(O), onReleaseRequested: s(D) }, { default: N(() => [ s(m) ? (A(), K(Nt, ze({ key: 0, ref_key: "dialogContentRef", ref: r }, c.$attrs, { "custom-class": c.customClass, center: c.center, "align-center": c.alignCenter, "close-icon": c.closeIcon, draggable: s(E), fullscreen: c.fullscreen, "show-close": c.showClose, title: c.title, onClose: s(I) }), Ye({ header: N(() => [ c.$slots.title ? C(c.$slots, "title", { key: 1 }) : C(c.$slots, "header", { key: 0, close: s(I), titleId: s(v), titleClass: s(l).e("title") }) ]), default: N(() => [ C(c.$slots, "default") ]), _: 2 }, [ c.$slots.footer ? { name: "footer", fn: N(() => [ C(c.$slots, "footer") ]) } : void 0 ]), 1040, ["custom-class", "center", "align-center", "close-icon", "draggable", "fullscreen", "show-close", "title", "onClose"])) : J("v-if", !0) ]), _: 3 }, 8, ["trapped", "onFocusAfterTrapped", "onFocusAfterReleased", "onFocusoutPrevented", "onReleaseRequested"]) ], 46, Ot) ]), _: 3 }, 8, ["mask", "overlay-class", "z-index"]), [ [He, s(d)] ]) ]), _: 3 }, 8, ["onAfterEnter", "onAfterLeave", "onBeforeLeave"]) ], 8, ["disabled"])); } }); var $t = /* @__PURE__ */ ge(Lt, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/dialog/src/dialog.vue"]]); const Ht = Ze($t); export { Ht as E, Bt as a, we as b, bt as c, It as d, wt as e, rt as f, gt as g, ke as h, Ct as o, Ft as u };