UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

238 lines (237 loc) 7 kB
import { defineComponent as F, ref as D, onMounted as N, createVNode as u, resolveComponent as y, createTextVNode as x, Fragment as R } from "vue"; import { isPlainObject as O, cloneDeep as $ } from "lodash-es"; const T = {}, w = {}; function C(e) { const { properties: t, title: l, ignore: r } = e, s = r && Array.isArray(r), d = Object.keys(t).reduce((a, p) => ((!s || !r.find((m) => m === p)) && (a[p] = t[p].type === "object" && t[p].properties ? C(t[p]) : $(t[p].default)), a), {}); if (l && (!s || !r.find((a) => a === "id"))) { const a = l.toLowerCase().replace(/-/g, "_"); d.id = `${a}_${Math.random().toString().slice(2, 6)}`; } return d; } function v(e, t) { const l = C(t); return Object.keys(l).reduce((r, s) => (Object.prototype.hasOwnProperty.call(e, s) && (r[s] && O(r[s]) && O(e[s] || !e[s]) ? Object.assign(r[s], e[s] || {}) : r[s] = e[s]), r), l), l; } function M(e, t) { return Object.keys(e).filter((r) => e[r] != null).reduce((r, s) => { if (t.has(s)) { const d = t.get(s); if (typeof d == "string") r[d] = e[s]; else { const a = d(s, e[s], e); Object.assign(r, a); } } else r[s] = e[s]; return r; }, {}); } function k(e, t, l = /* @__PURE__ */ new Map()) { const r = v(e, t); return M(r, l); } function V(e = {}) { function t(n, i, o, c) { if (typeof o == "number") return c[n].length === o; if (typeof o == "object") { const f = Object.keys(o)[0], g = o[f]; if (f === "not") return Number(c[n].length) !== Number(g); if (f === "moreThan") return Number(c[n].length) >= Number(g); if (f === "lessThan") return Number(c[n].length) <= Number(g); } return !1; } function l(n, i, o, c) { return c[n] && c[n].propertyValue && String(c[n].propertyValue.value) === String(o); } const r = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", l] ]); Object.keys(e).reduce((n, i) => (n.set(i, e[i]), n), r); function s(n, i) { const o = n; return typeof i == "number" ? [{ target: o, operator: "length", param: null, value: Number(i) }] : typeof i == "boolean" ? [{ target: o, operator: "getProperty", param: n, value: !!i }] : typeof i == "object" ? Object.keys(i).map((c) => { if (c === "length") return { target: o, operator: "length", param: null, value: i[c] }; const f = c, g = i[c]; return { target: o, operator: "getProperty", param: f, value: g }; }) : []; } function d(n) { return Object.keys(n).reduce((o, c) => { const f = s(c, n[c]); return o.push(...f), o; }, []); } function a(n, i) { if (r.has(n.operator)) { const o = r.get(n.operator); return o && o(n.target, n.param, n.value, i) || !1; } return !1; } function p(n, i) { return d(n).reduce((f, g) => f && a(g, i), !0); } function m(n, i) { const o = Object.keys(n), c = o.includes("allOf"), f = o.includes("anyOf"), g = c || f, h = (g ? n[g ? c ? "allOf" : "anyOf" : "allOf"] : [n]).map((P) => p(P, i)); return c ? !h.includes(!1) : h.includes(!0); } return { parseValueSchema: m }; } const q = {}, z = {}; V(); function B(e, t, l = /* @__PURE__ */ new Map(), r = (a, p, m, n) => p, s = {}, d = (a) => a) { return T[t.title] = t, w[t.title] = r, q[t.title] = s, z[t.title] = d, (a = {}, p = !0) => { if (!p) return M(a, l); const m = k(a, t, l), n = Object.keys(e).reduce((i, o) => (i[o] = e[o].default, i), {}); return Object.assign(n, m); }; } function I(e, t) { return { customClass: t.class, customStyle: t.style }; } const L = /* @__PURE__ */ new Map([ ["appearance", I] ]); function H(e, t, l) { return t; } const _ = "https://json-schema.org/draft/2020-12/schema", W = "https://farris-design.gitee.io/expression-editor.schema.json", G = "expression-editor", J = "A Farris Expression Editor Component", Q = "object", S = { id: { description: "The unique identifier for a Expression Editor", type: "string" }, type: { description: "The type string of Expression Editor component", type: "string", default: "expression-editor" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} } }, U = [ "id", "type" ], X = { $schema: _, $id: W, title: G, description: J, type: Q, properties: S, required: U }, Y = "expression-editor", Z = "A Farris Component", K = "object", ee = { basic: { description: "Basic Infomation", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "类型", title: "类型", type: "string", readonly: !0 } } } }, te = { title: Y, description: Z, type: K, categories: ee }, E = {}, j = B(E, X, L, H, te), b = /* @__PURE__ */ F({ name: "FExpressionEditor", props: E, emits: [], setup(e, t) { const l = D(); return N(() => { }), () => u("div", { ref: l, class: "d-flex h-100 f-utils-flex-column", style: "min-height:450px" }, [u(y("f-layout"), { class: "flex-column" }, { default: () => [u(y("f-layout-pane"), { "custom-class": "position-relative", position: "top", minHeight: 120 }, { default: () => [u("div", { class: "f-utils-absolute-all bg-info", style: "opacity:0.2;z-index: -1;" }, null), u("p", null, [x("头部区域")])] }), u(y("f-layout-pane"), { position: "center" }, { default: () => [u(y("f-layout"), null, { default: () => [u(y("f-layout-pane"), { position: "left", minWidth: 200, width: 400 }, { default: () => [u("div", { class: "f-utils-absolute-all bg-info", style: "opacity:0.2;z-index: -1;" }, null), u("p", null, [x("左侧区域")])] }), u(y("f-layout-pane"), { position: "center" }, { default: () => [u("div", { class: "f-utils-absolute-all bg-danger", style: "opacity:0.2;z-index:-1" }, null), u("p", null, [x("右侧区域")])] })] })] })] })]); } }), ne = /* @__PURE__ */ F({ name: "FExpressionEditorDesign", props: E, emits: [], setup(e, t) { return () => u(R, null, [x("expression editor design")]); } }), ce = { install(e) { e.component(b.name, b); }, register(e, t, l, r) { e["expression-editor"] = b, t["expression-editor"] = j; }, registerDesigner(e, t, l) { e["expression-editor"] = ne, t["expression-editor"] = j; } }; export { b as ExpressionEditor, ce as default, E as expressionEditorProps, j as propsResolver };