UNPKG

epic-designer-cjh

Version:

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

417 lines (415 loc) 10.8 kB
import { inject as M } from "vue"; function q(n) { let e = 0; for (let t = 0; t < n.length; ++t) n[t] === "&" && ++e; return e; } const P = /\s*,(?![^(]*\))\s*/g, N = /\s+/g; function z(n, e) { const t = []; return e.split(P).forEach((r) => { let f = q(r); if (f) { if (f === 1) { n.forEach((u) => { t.push(r.replace("&", u)); }); return; } } else { n.forEach((u) => { t.push( // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions (u && u + " ") + r ); }); return; } let o = [ r ]; for (; f--; ) { const u = []; o.forEach((s) => { n.forEach((b) => { u.push(s.replace("&", b)); }); }), o = u; } o.forEach((u) => t.push(u)); }), t; } function T(n, e) { const t = []; return e.split(P).forEach((r) => { n.forEach((f) => { t.push((f && f + " ") + r); }); }), t; } function L(n) { let e = [""]; return n.forEach((t) => { t = t && t.trim(), // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions t && (t.includes("&") ? e = z(e, t) : e = T(e, t)); }), e.join(", ").replace(N, " "); } function A(n) { if (!n) return; const e = n.parentElement; e && e.removeChild(n); } function C(n) { return document.querySelector(`style[cssr-id="${n}"]`); } function D(n) { const e = document.createElement("style"); return e.setAttribute("cssr-id", n), e; } function y(n) { return n ? /^\s*@(s|m)/.test(n) : !1; } const V = /[A-Z]/g; function O(n) { return n.replace(V, (e) => "-" + e.toLowerCase()); } function W(n, e = " ") { return typeof n == "object" && n !== null ? ` { ` + Object.entries(n).map((t) => e + ` ${O(t[0])}: ${t[1]};`).join(` `) + ` ` + e + "}" : `: ${n};`; } function K(n, e, t) { return typeof n == "function" ? n({ context: e.context, props: t }) : n; } function g(n, e, t, r) { if (!e) return ""; const f = K(e, t, r); if (!f) return ""; if (typeof f == "string") return `${n} { ${f} }`; const o = Object.keys(f); if (o.length === 0) return t.config.keepEmptyBlock ? n + ` { }` : ""; const u = n ? [ n + " {" ] : []; return o.forEach((s) => { const b = f[s]; if (s === "raw") { u.push(` ` + b + ` `); return; } s = O(s), b != null && u.push(` ${s}${W(b)}`); }), n && u.push("}"), u.join(` `); } function _(n, e, t) { n && n.forEach((r) => { if (Array.isArray(r)) _(r, e, t); else if (typeof r == "function") { const f = r(e); Array.isArray(f) ? _(f, e, t) : f && t(f); } else r && t(r); }); } function k(n, e, t, r, f, o) { const u = n.$; let s = ""; if (!u || typeof u == "string") y(u) ? s = u : e.push(u); else if (typeof u == "function") { const d = u({ context: r.context, props: f }); y(d) ? s = d : e.push(d); } else if (u.before && u.before(r.context), !u.$ || typeof u.$ == "string") y(u.$) ? s = u.$ : e.push(u.$); else if (u.$) { const d = u.$({ context: r.context, props: f }); y(d) ? s = d : e.push(d); } const b = L(e), m = g(b, n.props, r, f); s ? (t.push(`${s} {`), o && m && o.insertRule(`${s} { ${m} } `)) : (o && m && o.insertRule(m), !o && m.length && t.push(m)), n.children && _(n.children, { context: r.context, props: f }, (d) => { if (typeof d == "string") { const h = g(b, { raw: d }, r, f); o ? o.insertRule(h) : t.push(h); } else k(d, e, t, r, f, o); }), e.pop(), s && t.push("}"), u && u.after && u.after(r.context); } function B(n, e, t, r = !1) { const f = []; return k(n, [], f, e, t, r ? n.instance.__styleSheet : void 0), r ? "" : f.join(` `); } function U(n) { for (var e = 0, t, r = 0, f = n.length; f >= 4; ++r, f -= 4) t = n.charCodeAt(r) & 255 | (n.charCodeAt(++r) & 255) << 8 | (n.charCodeAt(++r) & 255) << 16 | (n.charCodeAt(++r) & 255) << 24, t = /* Math.imul(k, m): */ (t & 65535) * 1540483477 + ((t >>> 16) * 59797 << 16), t ^= /* k >>> r: */ t >>> 24, e = /* Math.imul(k, m): */ (t & 65535) * 1540483477 + ((t >>> 16) * 59797 << 16) ^ /* Math.imul(h, m): */ (e & 65535) * 1540483477 + ((e >>> 16) * 59797 << 16); switch (f) { case 3: e ^= (n.charCodeAt(r + 2) & 255) << 16; case 2: e ^= (n.charCodeAt(r + 1) & 255) << 8; case 1: e ^= n.charCodeAt(r) & 255, e = /* Math.imul(h, m): */ (e & 65535) * 1540483477 + ((e >>> 16) * 59797 << 16); } return e ^= e >>> 13, e = /* Math.imul(h, m): */ (e & 65535) * 1540483477 + ((e >>> 16) * 59797 << 16), ((e ^ e >>> 15) >>> 0).toString(36); } typeof window < "u" && (window.__cssrContext = {}); function Z(n, e, t) { const { els: r } = e; if (t === void 0) r.forEach(A), e.els = []; else { const f = C(t); f && r.includes(f) && (A(f), e.els = r.filter((o) => o !== f)); } } function j(n, e) { n.push(e); } function F(n, e, t, r, f, o, u, s, b) { if (o && !b) { if (t === void 0) { console.error("[css-render/mount]: `id` is required in `silent` mode."); return; } const $ = window.__cssrContext; $[t] || ($[t] = !0, B(e, n, r, o)); return; } let m; if (t === void 0 && (m = e.render(r), t = U(m)), b) { b.adapter(t, m ?? e.render(r)); return; } const d = C(t); if (d !== null && !u) return d; const h = d ?? D(t); if (m === void 0 && (m = e.render(r)), h.textContent = m, d !== null) return d; if (s) { const $ = document.head.querySelector(`meta[name="${s}"]`); if ($) return document.head.insertBefore(h, $), j(e.els, h), h; } return f ? document.head.insertBefore(h, document.head.querySelector("style, link")) : document.head.appendChild(h), j(e.els, h), h; } function G(n) { return B(this, this.instance, n); } function H(n = {}) { const { id: e, ssr: t, props: r, head: f = !1, silent: o = !1, force: u = !1, anchorMetaName: s } = n; return F(this.instance, this, e, r, f, o, u, s, t); } function I(n = {}) { const { id: e } = n; Z(this.instance, this, e); } const E = function(n, e, t, r) { return { instance: n, $: e, props: t, children: r, els: [], render: G, mount: H, unmount: I }; }, J = function(n, e, t, r) { return Array.isArray(e) ? E(n, { $: null }, null, e) : Array.isArray(t) ? E(n, e, null, t) : Array.isArray(r) ? E(n, e, t, r) : E(n, e, t, null); }; function ie(n = {}) { let e = null; const t = { c: (...r) => J(t, ...r), use: (r, ...f) => r.install(t, ...f), find: C, context: {}, config: n, get __styleSheet() { if (!e) { const r = document.createElement("style"); return document.head.appendChild(r), e = document.styleSheets[document.styleSheets.length - 1], e; } return e; } }; return t; } function fe(n, e) { if (n === void 0) return !1; if (e) { const { context: { ids: t } } = e; return t.has(n); } return C(n) !== null; } function S(n) { let e = ".", t = "__", r = "--", f; if (n) { let i = n.blockPrefix; i && (e = i), i = n.elementPrefix, i && (t = i), i = n.modifierPrefix, i && (r = i); } const o = { install(i) { f = i.c; const a = i.context; a.bem = {}, a.bem.b = null, a.bem.els = null; } }; function u(i) { let a, c; return { before(l) { a = l.bem.b, c = l.bem.els, l.bem.els = null; }, after(l) { l.bem.b = a, l.bem.els = c; }, $({ context: l, props: x }) { return i = typeof i == "string" ? i : i({ context: l, props: x }), l.bem.b = i, `${(x == null ? void 0 : x.bPrefix) || e}${l.bem.b}`; } }; } function s(i) { let a; return { before(c) { a = c.bem.els; }, after(c) { c.bem.els = a; }, $({ context: c, props: l }) { return i = typeof i == "string" ? i : i({ context: c, props: l }), c.bem.els = i.split(",").map((x) => x.trim()), c.bem.els.map((x) => `${(l == null ? void 0 : l.bPrefix) || e}${c.bem.b}${t}${x}`).join(", "); } }; } function b(i) { return { $({ context: a, props: c }) { i = typeof i == "string" ? i : i({ context: a, props: c }); const l = i.split(",").map((p) => p.trim()); function x(p) { return l.map((R) => `&${(c == null ? void 0 : c.bPrefix) || e}${a.bem.b}${p !== void 0 ? `${t}${p}` : ""}${r}${R}`).join(", "); } const v = a.bem.els; if (v !== null) { if (process.env.NODE_ENV !== "production" && v.length >= 2) throw Error(`[css-render/plugin-bem]: m(${i}) is invalid, using modifier inside multiple elements is not allowed`); return x(v[0]); } else return x(); } }; } function m(i) { return { $({ context: a, props: c }) { i = typeof i == "string" ? i : i({ context: a, props: c }); const l = a.bem.els; if (process.env.NODE_ENV !== "production" && l !== null && l.length >= 2) throw Error(`[css-render/plugin-bem]: notM(${i}) is invalid, using modifier inside multiple elements is not allowed`); return `&:not(${(c == null ? void 0 : c.bPrefix) || e}${a.bem.b}${l !== null && l.length > 0 ? `${t}${l[0]}` : ""}${r}${i})`; } }; } return Object.assign(o, { cB: (...i) => f(u(i[0]), i[1], i[2]), cE: (...i) => f(s(i[0]), i[1], i[2]), cM: (...i) => f(b(i[0]), i[1], i[2]), cNotM: (...i) => f(m(i[0]), i[1], i[2]) }), o; } const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: S, plugin: S }, Symbol.toStringTag, { value: "Module" })), w = Symbol("@css-render/vue3-ssr"); function Q(n, e) { return `<style cssr-id="${n}"> ${e} </style>`; } function X(n, e) { const t = M(w, null); if (t === null) { console.error("[css-render/vue3-ssr]: no ssr context found."); return; } const { styles: r, ids: f } = t; f.has(n) || r !== null && (f.add(n), r.push(Q(n, e))); } const Y = typeof document < "u"; function ee() { if (Y) return; const n = M(w, null); if (n !== null) return { adapter: X, context: n }; } function ne(n) { const e = [], t = { styles: e, ids: /* @__PURE__ */ new Set() }; return n.provide(w, t), { collect() { const r = e.join(` `); return e.length = 0, r; } }; } const oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, setup: ne, useSsrAdapter: ee }, Symbol.toStringTag, { value: "Module" })); export { ie as C, ue as a, oe as b, fe as e, U as m, S as p, ee as u };