UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,384 lines (1,383 loc) 47.6 kB
var ve = Object.defineProperty; var ge = (n, e, t) => e in n ? ve(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var F = (n, e, t) => ge(n, typeof e != "symbol" ? e + "" : e, t); import { ref as H, computed as Q, defineComponent as X, inject as G, onMounted as he, createVNode as be } from "vue"; import { cloneDeep as _, isPlainObject as J } from "lodash-es"; import { withInstall as ye } from "../common/index.esm.js"; import { getSchemaByTypeForDesigner as Se } from "../dynamic-resolver/index.esm.js"; function Y(n, e) { let t; function r(s) { const { properties: p, title: b, ignore: l } = s, f = l && Array.isArray(l), v = Object.keys(p).reduce((M, T) => ((!f || !l.find((V) => V === T)) && (M[T] = p[T].type === "object" && p[T].properties ? r(p[T]) : _(p[T].default)), M), {}); if (b && (!f || !l.find((M) => M === "id"))) { const M = b.toLowerCase().replace(/-/g, "_"); v.id = `${M}_${Math.random().toString().slice(2, 6)}`; } return v; } function i(s) { const { properties: p, title: b, required: l } = s; if (l && Array.isArray(l)) { const f = l.reduce((v, M) => (v[M] = p[M].type === "object" && p[M].properties ? r(p[M]) : _(p[M].default), v), {}); if (b && l.find((v) => v === "id")) { const v = b.toLowerCase().replace(/-/g, "_"); f.id = `${v}_${Math.random().toString().slice(2, 6)}`; } return f; } return { type: b }; } function a(s, p = {}, b) { const l = n[s]; if (l) { let f = i(l); const v = e[s]; return f = v ? v({ getSchemaByType: a }, f, p, b) : f, t != null && t.appendIdentifyForNewControl && t.appendIdentifyForNewControl(f), f; } return null; } function o(s, p) { const b = r(p); return Object.keys(b).reduce((l, f) => (Object.prototype.hasOwnProperty.call(s, f) && (l[f] && J(l[f]) && J(s[f] || !s[f]) ? Object.assign(l[f], s[f] || {}) : l[f] = s[f]), l), b), b; } function g(s, p) { return Object.keys(s).filter((l) => s[l] != null).reduce((l, f) => { if (p.has(f)) { const v = p.get(f); if (typeof v == "string") l[v] = s[f]; else { const M = v(f, s[f], s); Object.assign(l, M); } } else l[f] = s[f]; return l; }, {}); } function u(s, p, b = /* @__PURE__ */ new Map()) { const l = o(s, p); return g(l, b); } function c(s) { var b; const p = s.type; if (p) { const l = n[p]; if (!l) return s; const f = o(s, l), v = ((b = s.editor) == null ? void 0 : b.type) || ""; if (v) { const M = n[v], T = o(s.editor, M); f.editor = T; } return f; } return s; } function d(s) { t = s; } return { getSchemaByType: a, resolveSchemaWithDefaultValue: c, resolveSchemaToProps: u, mappingSchemaToProps: g, setDesignerContext: d }; } const Z = {}, I = {}, { getSchemaByType: bt, resolveSchemaWithDefaultValue: Me, resolveSchemaToProps: Ee, mappingSchemaToProps: Te, setDesignerContext: yt } = Y(Z, I); function we(n = {}) { function e(c, d, s, p) { if (typeof s == "number") return p[c].length === s; if (typeof s == "object") { const b = Object.keys(s)[0], l = s[b]; if (b === "not") return Number(p[c].length) !== Number(l); if (b === "moreThan") return Number(p[c].length) >= Number(l); if (b === "lessThan") return Number(p[c].length) <= Number(l); } return !1; } function t(c, d, s, p) { return p[c] && p[c].propertyValue && String(p[c].propertyValue.value) === String(s); } const r = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(n).reduce((c, d) => (c.set(d, n[d]), c), r); function i(c, d) { const s = c; return typeof d == "number" ? [{ target: s, operator: "length", param: null, value: Number(d) }] : typeof d == "boolean" ? [{ target: s, operator: "getProperty", param: c, value: !!d }] : typeof d == "object" ? Object.keys(d).map((p) => { if (p === "length") return { target: s, operator: "length", param: null, value: d[p] }; const b = p, l = d[p]; return { target: s, operator: "getProperty", param: b, value: l }; }) : []; } function a(c) { return Object.keys(c).reduce((s, p) => { const b = i(p, c[p]); return s.push(...b), s; }, []); } function o(c, d) { if (r.has(c.operator)) { const s = r.get(c.operator); return s && s(c.target, c.param, c.value, d) || !1; } return !1; } function g(c, d) { return a(c).reduce((b, l) => b && o(l, d), !0); } function u(c, d) { const s = Object.keys(c), p = s.includes("allOf"), b = s.includes("anyOf"), l = p || b, M = (l ? c[l ? p ? "allOf" : "anyOf" : "allOf"] : [c]).map((V) => g(V, d)); return p ? !M.includes(!1) : M.includes(!0); } return { parseValueSchema: u }; } const Pe = { convertTo: (n, e, t, r) => { n.appearance || (n.appearance = {}), n.appearance[e] = t; }, convertFrom: (n, e, t) => n.appearance ? n.appearance[e] : n[e] }, Fe = { convertFrom: (n, e, t) => n.buttons && n.buttons.length ? `共 ${n.buttons.length} 项` : "无" }, Ce = { convertTo: (n, e, t, r) => { n.editor && (n.editor[e] = t); }, convertFrom: (n, e, t) => n.editor && Object.prototype.hasOwnProperty.call(n.editor, e) ? n.editor[e] : n[e] }, L = { button: { type: "button", name: "按钮" }, "response-toolbar": { type: "response-toolbar", name: "工具栏" }, "response-toolbar-item": { type: "response-toolbar-item", name: "按钮" }, "content-container": { type: "content-container", name: "容器" }, "input-group": { type: "input-group", name: "文本" }, textarea: { type: "textarea", name: "多行文本" }, lookup: { type: "lookup", name: "帮助" }, "number-spinner": { type: "number-spinner", name: "数值" }, "date-picker": { type: "date-picker", name: "日期" }, switch: { type: "switch", name: "开关" }, "radio-group": { type: "radio-group", name: "单选组" }, "check-box": { type: "check-box", name: "复选框" }, "check-group": { type: "check-group", name: "复选框组" }, "combo-list": { type: "combo-list", name: "下拉列表" }, "response-form": { type: "response-form", name: "卡片面板" }, "response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" }, "response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" }, "tree-grid": { type: "tree-grid", name: "树表格" }, "tree-grid-column": { type: "tree-grid-column", name: "树表格列" }, "data-grid": { type: "data-grid", name: "表格" }, "data-grid-column": { type: "data-grid-column", name: "表格列" }, module: { type: "Module", name: "模块" }, component: { type: "component", name: "组件" }, tabs: { type: "tabs", name: "标签页" }, "tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" }, "tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" }, "html-template": { type: "html-template", name: "模板容器" }, "time-picker": { type: "time-picker", name: "时间选择" }, section: { type: "section", name: "分组面板" }, "section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" }, "section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" }, splitter: { type: "splitter", name: "分栏面板" }, "splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" }, "component-ref": { type: "component-ref", name: "组件引用节点" }, uploader: { type: "uploader", name: "附件上传" }, "page-header": { type: "page-header", name: "页头" }, "page-footer": { type: "page-footer", name: "页脚" }, "tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" }, fieldset: { type: "fieldset", name: "分组" }, "query-solution": { type: "query-solution", name: "筛选方案" }, drawer: { type: "drawer", name: "抽屉" }, "external-container": { type: "external-container", name: "外部容器", icon: "content-container" }, "list-nav": { type: "list-nav", name: "列表导航" }, "list-view": { type: "list-view", name: "列表" }, "filter-bar": { type: "filter-bar", name: "筛选条" }, "language-textbox": { type: "language-textbox", name: "多语输入框" } }, Ve = { convertFrom: (n, e, t) => { var i; const r = n.editor && n.editor[e] ? n.editor[e] : n[e]; return ((i = L[r]) == null ? void 0 : i.name) || r; } }, Ne = { convertTo: (n, e, t, r) => { n[e] = n[e]; }, convertFrom: (n, e, t) => n.editor ? t.getRealEditorType(n.editor.type) : "" }, Oe = { convertTo: (n, e, t, r) => { (n.type === "data-grid-column" || n.type === "tree-grid-column") && (n.formatter ? n.formatter[e] = t : n.formatter = { [e]: t }); }, convertFrom: (n, e, t) => { if (n.formatter) { if (e === "trueText") return n.formatter.trueText; if (e === "falseText") return n.formatter.falseText; if (e === "prefix") return n.formatter.prefix; if (e === "suffix") return n.formatter.suffix; if (e === "precision") return n.formatter.precision; if (e === "decimal") return n.formatter.decimal; if (e === "thousand") return n.formatter.thousand; if (e === "tempDateFormat") return n.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : n.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : n.formatter.tempDateFormat || n.formatter.dateFormat || "yyyy-MM-dd"; if (e === "customFormat") return n.formatter.customFormat; if (e === "type") return n.formatter.type || "none"; } return "none"; } }, ke = { convertTo: (n, e, t, r) => { n.command ? n.command[e] = t : n.command = { [e]: t }, e === "enable" && t && (n.command.commands || (n.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ])); }, convertFrom: (n, e, t) => n.command && e === "enable" ? n.command.enable : "" }, xe = { convertTo: (n, e, t, r) => { n.column ? n.column[e] = t : n.column = { [e]: t }, e === "fitColumns" && t && (n.column.fitMode || (n.column.fitMode = "average")); }, convertFrom: (n, e, t) => { if (n.column) { if (e === "fitColumns") return n.column.fitColumns; if (e === "fitMode") return n.column.fitMode; } return ""; } }, Be = { convertTo: (n, e, t, r) => { n.summary ? n.summary[e] = t : n.summary = { [e]: t }, e === "enable" && t && (n.summary ? n.summary.groupFields || (n.summary.groupFields = []) : n.summary = { enable: t, groupFields: [] }); }, convertFrom: (n, e, t) => n.summary && e === "enable" ? n.summary.enable : n.type === "data-grid-column" ? n.enableSummary === void 0 ? !1 : n.enableSummary : "" }, De = { convertTo: (n, e, t, r) => { n.group ? n.group[e] = t : n.group = { [e]: t }, e === "enable" && t && (n.group ? n.group.groupFields || (n.group.groupFields = []) : n.group = { enable: t, groupFields: [], showSummary: !1 }); }, convertFrom: (n, e, t) => { if (n.group) { if (e === "enable") return n.group.enable; if (e === "showSummary") return n.group.showSummary; } } }, $e = { convertFrom: (n, e) => n.binding ? n.binding.path : "", convertTo: (n, e, t) => { if (t && t.length > 0) { const r = t[0]; n.binding || (n.binding = {}), n.binding.type = "Form", n.binding.path = r.bindingField, n.binding.field = r.id, n.binding.fullPath = r.path, n.path = r.bindingPath; } } }, Ue = { convertTo: (n, e, t, r) => { n.pagination || (n.pagination = {}), n.pagination[e] = t; }, convertFrom: (n, e, t) => n.pagination ? n.pagination[e] : n[e] }, je = { convertTo: (n, e, t, r) => { n.rowNumber || (n.rowNumber = {}), n.rowNumber[e] = t; }, convertFrom: (n, e, t) => n.rowNumber ? n.rowNumber[e] : n[e] }, Ae = { convertTo: (n, e, t, r) => { n.selection || (n.selection = {}), n.selection[e] = t; }, convertFrom: (n, e, t) => n.selection ? n.selection[e] : n[e] }, He = { convertFrom: (n, e, t) => n[e] && n[e].length ? `共 ${n[e].length} 项` : "" }, qe = { convertFrom: (n, e) => n[e] || "", convertTo: (n, e, t) => { n[e] = t; } }, Le = { convertTo: (n, e, t, r) => { n.size || (n.size = {}), n.size[e] = t; }, convertFrom: (n, e, t) => n.size ? n.size[e] : n[e] }, ze = { convertFrom: (n, e, t) => { var r, i; return (r = n.formatter) != null && r.data && e === "formatterEnumData" && !n.formatterEnumData ? (i = n.formatter) == null ? void 0 : i.data : n.formatterEnumData; } }, _e = { convertTo: (n, e, t, r) => { n.sort || (n.sort = {}), n.sort[e] = t; }, convertFrom: (n, e, t) => { var r, i; if (e === "mode") return ((r = n.sort) == null ? void 0 : r.mode) || "client"; if (e === "multiSort") return !!((i = n.sort) != null && i.multiSort); } }, We = { convertTo: (n, e, t, r) => { n.filter || (n.filter = {}), n.filter[e] = t; }, convertFrom: (n, e, t) => { var r; if (e === "mode") return ((r = n.filter) == null ? void 0 : r.mode) || "client"; } }, Ge = { convertTo: (n, e, t, r) => { n.rowOption ? n.rowOption[e] = t : n.rowOption = { [e]: t }; }, convertFrom: (n, e, t) => { if (n.rowOption) { if (e === "customRowStyle") return n.rowOption.customRowStyle; if (e === "customCellStyle") return n.rowOption.customCellStyle; } return ""; } }; function R(n, e, t) { const r = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", Pe], ["/converter/buttons.converter", Fe], ["/converter/property-editor.converter", Ce], ["/converter/items-count.converter", He], ["/converter/type.converter", Ve], ["/converter/change-editor.converter", Ne], ["/converter/change-formatter.converter", Oe], ["/converter/column-command.converter", ke], ["/converter/column-option.converter", xe], ["/converter/summary.converter", Be], ["/converter/group.converter", De], ["/converter/form-group-label.converter", qe], ["/converter/field-selector.converter", $e], ["/converter/pagination.converter", Ue], ["/converter/row-number.converter", je], ["/converter/grid-selection.converter", Ae], ["/converter/size.converter", Le], ["/converter/change-formatter-enum.converter", ze], ["/converter/grid-sort.converter", _e], ["/converter/grid-filter.converter", We], ["/converter/row-option.converter", Ge] ]), i = /* @__PURE__ */ new Map([ ["string", { type: "input-group", enableClear: !1 }], ["boolean", { type: "combo-list", textField: "name", valueField: "value", idField: "value", enableClear: !1, editable: !1, data: [ { value: !0, name: "是" }, { value: !1, name: "否" } ] }], ["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }], ["array", { type: "button-edit" }], ["number", { type: "number-spinner", placeholder: "" }], ["events-editor", { type: "events-editor", hide: !0 }] ]), a = we(); function o(l, f) { return () => a.parseValueSchema(l, f); } function g(l, f, v) { return l.includes("visible") && f.visible !== void 0 ? typeof f.visible == "boolean" ? () => !!f.visible : f.visible === void 0 ? !0 : o(f.visible, v) : () => !0; } function u(l, f, v) { return l.includes("readonly") && f.readonly !== void 0 ? typeof f.readonly == "boolean" ? () => !!f.readonly : o(f.readonly, v) : () => !1; } function c(l, f) { const v = l.$converter || f; return typeof v == "string" && v && r.has(v) ? r.get(v) || null : v || null; } function d(l, f, v, M, T, V = "", x = "") { return Object.keys(l).map((w) => { const B = H(1), D = w, h = l[w], N = Object.keys(h), j = h.title, m = h.type, y = i.get(m) || { type: "input-group", enableClear: !1 }, S = h.editor ? Object.assign({}, y, h.editor) : Object.assign({}, y), E = g(N, h, f), P = u(N, h, f); S.readonly = S.readonly === void 0 ? P() : S.readonly; const k = h.type === "cascade" ? d(h.properties, f, v, M, T, V, x) : [], A = !0; let C = c(h, x); const $ = Q({ get() { if (B.value) { if (["class", "style"].find((me) => me === D) && !C && (C = r.get("/converter/appearance.converter") || null), C && C.convertFrom) return C.convertFrom(v, w, T, V); const U = v[w]; return Object.prototype.hasOwnProperty.call(h, "defaultValue") && (U === void 0 || typeof U == "string" && U === "") ? h.type === "boolean" ? h.defaultValue : h.defaultValue || "" : U; } return null; }, set(U) { B.value += 1, C && C.convertTo ? (C.convertTo(M, w, U, T, V), C.convertTo(v, w, U, T, V)) : (M[w] = U, v[w] = U); } }), { refreshPanelAfterChanged: q, description: fe, isExpand: pe, parentPropertyID: de } = h, W = { propertyID: D, propertyName: j, propertyType: m, propertyValue: $, editor: S, visible: E, readonly: P, cascadeConfig: k, hideCascadeTitle: A, refreshPanelAfterChanged: q, description: fe, isExpand: pe, parentPropertyID: de }; return f[D] = W, W; }); } function s(l, f, v = {}) { const M = {}, T = n[l]; return T && T.categories ? Object.keys(T.categories).map((x) => { const O = T.categories[x], w = O == null ? void 0 : O.title, B = d(O.properties || {}, M, {}, v, f); return { categoryId: x, categoryName: w, properties: B }; }) : []; } function p(l, f, v, M, T = "") { const V = f.$ref.schema, x = f.$ref.converter, O = v[V], w = O.type, B = t(O), D = {}, h = n[w]; if (h && h.categories) { const N = h.categories[l], j = N == null ? void 0 : N.title; x && Object.keys(N.properties).forEach((S) => { N.properties[S].$converter = x; }); const m = (N == null ? void 0 : N.properties) || {}, y = d(m, D, B, O, M, T); return { categoryId: l, categoryName: j, properties: y }; } return { categoryId: l, categoryName: "", properties: [] }; } function b(l, f, v, M, T) { const V = l.type, x = t(l), O = {}; let w = T || n[V]; if (w && Object.keys(w).length === 0 && v && v.getPropConfig && (w = v.getPropConfig(M)), w && w.categories) { const B = []; return Object.keys(w.categories).map((D) => { const h = w.categories[D]; if (h.$ref) { B.push(p(D, h, l, f, M)); return; } const N = h == null ? void 0 : h.title, j = h == null ? void 0 : h.tabId, m = h == null ? void 0 : h.tabName, y = h == null ? void 0 : h.hide, S = h == null ? void 0 : h.hideTitle, E = d(h.properties || {}, O, x, l, f, M, h.$converter), { setPropertyRelates: P } = h, k = h == null ? void 0 : h.parentPropertyID; B.push({ categoryId: D, categoryName: N, tabId: j, tabName: m, hide: y, properties: E, hideTitle: S, setPropertyRelates: P, parentPropertyID: k }); }), B; } return []; } return { getPropertyConfigBySchema: b, getPropertyConfigByType: s, propertyConverterMap: r }; } const K = {}, ee = {}; R(K, ee, Me); const te = {}, ne = {}, { getSchemaByType: St, resolveSchemaWithDefaultValue: Je, resolveSchemaToProps: Mt, mappingSchemaToProps: Et, setDesignerContext: Tt } = Y(te, ne), re = {}, oe = {}; R(re, oe, Je); function ie(n, e, t = /* @__PURE__ */ new Map(), r = (o, g, u, c) => g, i = {}, a = (o) => o) { return Z[e.title] = e, I[e.title] = r, K[e.title] = i, ee[e.title] = a, te[e.title] = e, ne[e.title] = r, re[e.title] = i, oe[e.title] = a, (o = {}, g = !0) => { if (!g) return Te(o, t); const u = Ee(o, e, t), c = Object.keys(n).reduce((d, s) => (d[s] = n[s].default, d), {}); return Object.assign(c, u); }; } const Qe = "https://json-schema.org/draft/2020-12/schema", Xe = "https://farris-design.gitee.io/html-template.schema.json", Ye = "html-template", Ze = "A Farris Component", Ie = "object", Re = { id: { description: "The unique identifier for a html-template", type: "string" }, type: { description: "The type string of html-template", type: "string", default: "html-template" }, html: { description: "", type: "string", default: "" }, renderFunction: { description: "", type: "function", default: null } }, Ke = [ "id", "type" ], et = [], se = { $schema: Qe, $id: Xe, title: Ye, description: Ze, type: Ie, properties: Re, required: Ke, ignore: et }, ae = /* @__PURE__ */ new Map([]); function ce(n, e, t) { return e; } const le = { /** 渲染函数 */ renderFunction: { type: Function } }, tt = ie(le, se, ae, ce), ue = { /** html模板 */ html: { type: String, default: "" } }, nt = ie(ue, se, ae, ce), z = /* @__PURE__ */ X({ name: "FHtmlTemplate", props: le, emits: [], setup(n) { return () => { var e; return (e = n.renderFunction) == null ? void 0 : e.call(n); }; } }); function rt(n, e, t) { var j; const r = t && t.getStyles && t.getStyles() || "", i = t && t.getDesignerClass && t.getDesignerClass() || "", a = H(); let o; function g() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanMoveComponent ? t.checkCanMoveComponent() : !0; } function u() { return !1; } function c() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanDeleteComponent ? t.checkCanDeleteComponent() : !0; } function d() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !0 : t && t.hideNestedPaddingInDesginerView ? t.hideNestedPaddingInDesginerView() : !1; } function s(m) { if (!m || !m.value) return null; if (m.value.schema && m.value.schema.type === "component") return m.value; const y = H(m == null ? void 0 : m.value.parent), S = s(y); return S || null; } function p(m = e) { var P; if (t != null && t.getDraggableDesignItemElement) return t.getDraggableDesignItemElement(m); const { componentInstance: y, designerItemElementRef: S } = m; if (!y || !y.value) return null; const { getCustomButtons: E } = y.value; return y.value.canMove || E && ((P = E()) != null && P.length) ? S : p(m.parent); } function b(m) { return !!t && t.canAccepts(m); } function l() { return (e == null ? void 0 : e.schema.label) || (e == null ? void 0 : e.schema.title) || (e == null ? void 0 : e.schema.name); } function f() { } function v(m, y) { var S; !m || !y || (t != null && t.onAcceptMovedChildElement && t.onAcceptMovedChildElement(m, y), (S = e == null ? void 0 : e.setupContext) == null || S.emit("dragEnd")); } function M(m, y) { const { componentType: S } = m; let E = Se(S, m, y); t && t.onResolveNewComponentSchema && (E = t.onResolveNewComponentSchema(m, E)); const P = S.toLowerCase().replace(/-/g, "_"); return E && !E.id && E.type === S && (E.id = `${P}_${Math.random().toString().slice(2, 6)}`), E; } function T(m) { m && t != null && t.onChildElementMovedOut && t.onChildElementMovedOut(m); } function V(...m) { if (t && t.getPropsConfig) return t.getPropsConfig(...m); } function x(m) { if (!m) return; const y = e == null ? void 0 : e.schema, { formSchemaUtils: S } = m; if (y && S.getExpressions().length) { const E = S.getExpressions().findIndex((P) => P.target === y.id); E > -1 && S.getExpressions().splice(E, 1); } } function O(m) { if (!m || !(e != null && e.schema)) return; const y = e.schema, { formSchemaUtils: S } = m; S.removeCommunicationInComponent(y); } function w(m) { t && t.onRemoveComponent && t.onRemoveComponent(), x(m), O(m), e != null && e.schema.contents && e.schema.contents.map((y) => { let S = y.id; y.type === "component-ref" && (S = y.component); const E = n.value.querySelectorAll(`#${S}-design-item`); E != null && E.length && Array.from(E).map((P) => { var k; (k = P == null ? void 0 : P.componentInstance) != null && k.value.onRemoveComponent && P.componentInstance.value.onRemoveComponent(m); }); }); } function B() { if (t && t.getCustomButtons) return t.getCustomButtons(); } function D(m) { var S, E; if (!((S = e == null ? void 0 : e.schema) != null && S.id)) return; if (!o && m && (o = m.formSchemaUtils), t != null && t.setComponentBasicInfoMap) { t.setComponentBasicInfoMap(); return; } let y = ""; if (t != null && t.getComponentTitle) y = t.getComponentTitle(); else { const { text: P, title: k, label: A, mainTitle: C, name: $, type: q } = e.schema; y = P || k || A || C || $ || ((E = L[q]) == null ? void 0 : E.name); } y && o.getControlBasicInfoMap().set(e.schema.id, { componentTitle: y, parentPathName: y }); } function h(m) { var P; const { changeObject: y } = m, { propertyID: S, propertyValue: E } = y; if (["text", "title", "label", "name", "mainTitle"].includes((P = m == null ? void 0 : m.changeObject) == null ? void 0 : P.propertyID) && S && E && (D(), o)) { const k = o.getControlBasicInfoMap(), A = k.keys().toArray().filter((C) => { var $, q; return (($ = k.get(C)) == null ? void 0 : $.reliedComponentId) === ((q = e == null ? void 0 : e.schema) == null ? void 0 : q.id); }); A != null && A.length && A.forEach((C) => { const $ = k.get(C).parentPathName.split(" > "); $[0] = E, k.get(C).parentPathName = $.join(" > "); }); } } function N(m) { if (h(m), t && t.onPropertyChanged) return t.onPropertyChanged(m); } return a.value = { canMove: g(), canSelectParent: u(), canDelete: c(), canNested: !d(), contents: e == null ? void 0 : e.schema.contents, elementRef: n, parent: (j = e == null ? void 0 : e.parent) == null ? void 0 : j.componentInstance, schema: e == null ? void 0 : e.schema, styles: r, designerClass: i, canAccepts: b, getBelongedComponentInstance: s, getDraggableDesignItemElement: p, getDraggingDisplayText: l, getPropConfig: V, getDragScopeElement: f, onAcceptMovedChildElement: v, onChildElementMovedOut: T, addNewChildComponentSchema: M, triggerBelongedComponentToMoveWhenMoved: !!t && t.triggerBelongedComponentToMoveWhenMoved || H(!1), triggerBelongedComponentToDeleteWhenDeleted: !!t && t.triggerBelongedComponentToDeleteWhenDeleted || H(!1), onRemoveComponent: w, getCustomButtons: B, onPropertyChanged: N, setComponentBasicInfoMap: D, updateContextSchema: e == null ? void 0 : e.updateContextSchema }, a; } const ot = H(0); function it() { ot.value++; } const st = H(0); function at(n) { const { formSchemaUtils: e, formStateMachineUtils: t } = n; function r(u, c = "") { return { path: c + u.code, field: u.id, fullPath: u.code }; } function i(u, c = "") { return e.getViewModelById(u).states.map((s) => r(s, c)); } function a(u) { const c = e.getRootViewModelId(), d = i(u); if (u === c) return d; const s = i(c, "root-component."); return [...d, ...s]; } function o(u) { return u.binding && u.binding.path || u.id || ""; } function g() { return t && t.getRenderStates() || []; } return { getVariables: a, getControlName: o, getStateMachines: g }; } class ct { constructor(e) { F(this, "sessionVariables", [ { key: "CurrentSysOrgName", name: "当前组织Name", description: "当前组织Name" }, // { // key: "CurrentSysOrgCode", // name: "当前组织Code", // description: "当前组织Code" // }, { key: "CurrentSysOrgId", name: "当前组织Id", description: "当前组织Id" }, { key: "CurrentUserName", name: "当前用户Name", description: "当前用户Name" }, { key: "CurrentUserCode", name: "当前用户Code", description: "当前用户Code" }, { key: "CurrentUserId", name: "当前用户Id", description: "当前用户Id" }, { key: "CurrentLanguage", name: "当前语言编号", description: "当前登录的语言编号,例如简体中文返回'zh-CHS',英文返回'en',繁体中文'zh-CHT'" } ]); F(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); F(this, "getExpressionConverter", (e, t) => ({ convertFrom: (r, i, a, o) => { const g = a.getExpressionRuleValue(e, t || i); return g && g.value || ""; }, convertTo: (r, i, a, o, g) => { var u; if (i === "dataPicking" && (a != null && a.target)) { const c = `${a.target}_dataPicking`; ((u = a.rules) == null ? void 0 : u.some( (s) => s.id === c && s.value )) ? r.dictPickingExpressionId = c : delete r.dictPickingExpressionId; } o.updateExpression(a); } })); this.formSchemaService = e; } getExpressionRule(e, t) { const r = this.formSchemaService.getExpressions(); if (!r) return ""; const i = r.find((o) => o.target === e); if (!i) return ""; const a = i.rules.find((o) => o.type === t); return a || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: e } = this.formSchemaService.getFormSchema(); if (!e.viewmodels || e.viewmodels.length === 0) return []; const t = this.formSchemaService.getRootViewModelId(), r = this.formSchemaService.getViewModelById(t); if (!r || !r.states || r.states.length === 0) return []; const i = []; return r.states.forEach((a) => { i.push({ key: a.code, name: a.name, description: a.name, category: a.category }); }), i; } createTreeNode(e, t, r = "label") { return { id: e.id, name: e.name, bindingPath: e[r], parents: t, type: "field" }; } buildEntityFieldsTreeData(e = null, t) { const r = []; return e == null || e.forEach((i) => { var g; const a = this.createTreeNode(i, t); let o = []; (g = i.type) != null && g.fields && (o = this.buildEntityFieldsTreeData(i.type.fields, [...t, i.label])), r.push({ data: a, children: o, expanded: !0 }); }), r; } buildChildEntityTreeData(e = null, t) { const r = []; return e == null || e.forEach((i) => { var u, c; const a = this.createTreeNode(i, t); a.type = "entity"; const o = this.buildEntityFieldsTreeData((u = i.type) == null ? void 0 : u.fields, [...t, i.label]), g = this.buildChildEntityTreeData((c = i.type) == null ? void 0 : c.entities, [...t, i.label]); g != null && g.length && (o == null || o.push(...g)), r.push({ data: a, children: o || [], // 空值回退 expanded: !0 }); }), r; } getEntitiesTreeData() { const e = this.formSchemaService.getSchemaEntities(); if (!(e != null && e.length)) return []; const t = e[0]; if (!(t != null && t.type)) return []; const r = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), i = this.buildChildEntityTreeData(t.type.entities, [t.code]); return i != null && i.length && (r == null || r.push(...i)), { entityCode: t.code, fields: [{ data: this.createTreeNode(t, [], "code"), children: r || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(e, t, r) { const i = r === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, t), o = this.getEntitiesAndVariables(), g = { message: ["validate", "required", "dataPicking"].includes(t) && a ? a.message : "", ...o }; return a.messageType != null && (g.messageType = a.messageType), g; } buildRule(e, t, r, i) { const { expression: a, message: o, messageType: g } = t, u = { id: `${e}_${r}`, type: r, value: a }; return (r === "validate" || r === "dataPicking" || r === "required") && (u.message = o), r === "dataPicking" && (u.messageType = g), r === "validate" && i && (u.elementId = i), u; } getExpressionData() { const { expressions: e } = this.formSchemaService.getFormSchema().module; return e || []; } updateExpression(e, t, r, i) { const a = t === "Field" ? e.binding.field : e.id, o = this.buildRule(a, r, i, e.type === "form-group" ? e.id : ""); let u = this.getExpressionData().find((d) => d.targetType === t && d.target === a); const c = (d) => d.value.trim() === ""; if (u) { const d = u.rules.find((s) => s.id === o.id); if (d) c(o) ? u.rules = u.rules.filter((s) => s.id !== o.id) : (Object.assign(d, o), i === "validate" && e.type === "form-group" && (d.elementId = e.id)); else { if (c(o)) return null; u.rules = u.rules || [], u.rules.push(o); } } else { if (c(o)) return null; u = { target: `${a}`, rules: [o], targetType: t }; } return u; } getExpressionEditorOptions(e, t, r, i) { return r.reduce((a, o) => { var u, c; const g = t === "Field" ? (u = e == null ? void 0 : e.binding) == null ? void 0 : u.field : e.id; return a[o] = { hide: t === "Field" ? !!((c = e == null ? void 0 : e.binding) != null && c.field) : !1, description: "", title: this.expressionNames[o], type: "string", $converter: this.getExpressionConverter(g), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[o]}编辑器`, showMessage: o === "validate" || o === "dataPicking" || o === "required", showMessageType: o === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(e, o, t), onSubmitModal: (d) => { const s = this.updateExpression(e, t, d, o); if (i) { const p = this.buildRule(g, d, o); i(p); } return s; } } }, a; }, {}); } getExpressionInfo(e, t, r) { const i = t === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, r), o = { value: a && a.value, targetId: i, targetType: t, expressionType: r }; return a && a.message && (o.message = a.message), o; } getExpressionConfig(e, t, r = ["compute", "dependency", "validate"], i) { return { description: "表达式", title: "表达式", hide: !e.binding, properties: { ...this.getExpressionEditorOptions(e, t, r, i) } }; } getExpressionOptions(e, t, r) { const i = this.getExpressionInfo(e, t, r); return { dialogTitle: `${this.expressionNames[r]}编辑器`, singleExpand: !1, showMessage: r === "required", beforeOpen: () => this.onBeforeOpenExpression(e, r, t), expressionInfo: i }; } } class lt { constructor(e, t) { F(this, "componentId"); F(this, "viewModelId"); F(this, "eventsEditorUtils"); F(this, "formSchemaUtils"); F(this, "formMetadataConverter"); F(this, "designViewModelUtils"); F(this, "designViewModelField"); F(this, "controlCreatorUtils"); F(this, "designerHostService"); F(this, "designerContext"); F(this, "schemaService", null); F(this, "metadataService", null); F(this, "propertyConfig", { type: "object", categories: {} }); var r; this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((r = this.formSchemaUtils) == null ? void 0 : r.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = t.designViewModelUtils, this.controlCreatorUtils = t.controlCreatorUtils, this.metadataService = t.metadataService, this.schemaService = t.schemaService, this.designerContext = t.designerContext; } getFormDesignerInstance() { var e, t; return (t = (e = this.designerContext) == null ? void 0 : e.instances) == null ? void 0 : t.formDesigner.value; } getTableInfo() { var e; return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(e) { var r; const t = e.binding && e.binding.type === "Form" && e.binding.field; if (t) { if (!this.designViewModelField) { const i = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = i.fields.find((a) => a.id === t); } e.updateOn = (r = this.designViewModelField) == null ? void 0 : r.updateOn; } } getBasicPropConfig(e) { return { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "combo-list", textField: "name", valueField: "value", idField: "value", editable: !1, data: [{ value: e.type, name: L[e.type] && L[e.type].name }] } } } }; } getAppearanceConfig(e = null, t = {}, r) { const i = { title: "外观", description: "Appearance" }, a = { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" } }; for (const o in t) a[o] = Object.assign(a[o] || {}, t[o]); return { ...i, properties: { ...a }, setPropertyRelates(o, g) { if (o) { switch (o && o.propertyID) { case "class": case "style": { st.value++; break; } } r && r(o, e, g); } } }; } getPropertyEditorParams(e, t = [], r = "visible", i = {}, a = {}) { const { getVariables: o, getControlName: g, getStateMachines: u } = at(this.designerHostService), c = this.getRealTargetType(e), d = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], s = { type: "property-editor", propertyTypes: d }; return d.map((p) => { switch (p) { case "Const": Object.assign(s, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, i); break; case "Expression": s.expressionConfig = this.getExpressionOptions(e, c, r); break; case "StateMachine": s.stateMachines = u(); break; case "Variable": Object.assign(s, { controlName: g(e), newVariablePrefix: "is", newVariableType: "Boolean", variables: o(this.viewModelId), onBeforeOpenVariables: (b) => { b.value = o(this.viewModelId); } }, a); break; } }), s; } getVisibleProperty(e, t = "") { var a; let r = ["Const", "Variable", "StateMachine", "Expression"]; return t === "gridFieldEditor" ? r = ["Const", "Expression"] : t === "form-group" && !((a = e.binding) != null && a.field) && (r = ["Const", "Variable", "StateMachine"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(e, r, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(e, t = "", r = {}, i) { const a = { title: "行为", description: "" }, o = this.getVisibleProperty(e, t); for (const u in r) o[u] = Object.assign(o[u] || {}, r[u]); const g = this; return { ...a, properties: { ...o }, setPropertyRelates(u, c) { if (u) { switch (u.propertyID) { case "disabled": case "readonly": case "visible": g.afterMutilEditorChanged(e, u); break; } i && i(u, c); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(e, t) { this.addNewVariableToViewModel(t, this.viewModelId), this.updateExpressionValue(t), this.clearExpression(t, e); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(e, t) { const r = t && t.parent && t.parent.schema; if (!r) return; const i = r.contents.findIndex((o) => o.id === e), a = _(r.contents[i]); r.contents.splice(i, 1), r.contents.splice(i, 0, a), it(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(e, t) { const r = e.propertyValue; if (!(r && typeof r == "object") || !(r.type === "Variable" && r.isNewVariable)) return; const o = { id: r.field, category: "locale", code: r.fullPath, name: r.fullPath, type: r.newVariableType || "String" }; delete r.newVariableType, delete r.isNewVariable, this.formSchemaUtils.getVariableByCode(o.code) || this.formSchemaUtils.getViewModelById(t).states.push(o); } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(e) { const t = e.propertyValue; if (!((t && t.type) === "Expression" && t.expressionInfo)) return; const { expressionId: a, expressionInfo: o } = t, { targetId: g, targetType: u, expressionType: c, value: d, message: s } = o, p = this.formSchemaUtils.getModule(); p.expressions = p.expressions || []; const { expressions: b } = p; let l = b.find((v) => v.target === g); l || (l = { target: g, rules: [], targetType: u }, b.push(l)); const f = l.rules.find((v) => v.type === c); if (f) f.value = d, f.message = s; else { const v = { id: a, type: c, value: d, message: s }; l.rules.push(v); } delete t.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(e, t) { const r = e.propertyValue; if (r && r.type === "Expression") return; const a = e.propertyID, o = this.formSchemaUtils.getExpressions(), g = t.binding ? t.binding.field : t.id, u = o.find((c) => c.target === g); !u || !u.rules || (u.rules = u.rules.filter((c) => c.type !== a)); } getExpressionOptions(e, t, r) { return new ct(this.formSchemaUtils).getExpressionOptions(e, t, r); } getRealTargetType(e) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item"].indexOf(e.type) > -1 ? "Button" : e.binding && e.binding.field ? "Field" : "Container"; } createBaseEventProperty(e) { const t = {}; return t[this.viewModelId] = { type: "events-editor", editor: { initialData: e, viewSourceHandle: (r) => { var i; ((i = r.controller) == null ? void 0 : i.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(r); } } }, t; } } class ut extends lt { constructor(e, t) { super(e, t); } getPropertyConfig(e) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(e), this.propertyConfig.categories.template = this.getTemplateProperties(e), this.propertyConfig; } getTemplateProperties(e) { return { title: "模板", description: "", properties: { html: { title: "html", type: "string", description: "HTML模板", refreshPanelAfterChanged: !0, editor: { type: "code-editor", language: "html" } } } }; } } function ft(n, e) { function t() { return !1; } function r() { return !0; } function i() { return !0; } function a() { return !0; } function o(g) { return new ut(g, e).getPropertyConfig(n); } return { canAccepts: t, hideNestedPaddingInDesginerView: a, getPropsConfig: o, checkCanDeleteComponent: r, checkCanMoveComponent: i }; } const pt = /* @__PURE__ */ X({ name: "FHtmlTemplateDesign", props: ue, emits: [], setup(n, e) { const t = H(), r = G("designer-host-service"), i = G("design-item-context"), a = ft(i.schema, r), o = rt(t, i, a); he(() => { t.value.componentInstance = o; }), e.expose(o.value); const u = '<div class="fv-html-template-design-placeholder">请在属性面板中配置模板</div>', c = Q(() => n.html ? n.html : u); return () => be("div", { ref: t, class: "fv-html-template-design", innerHTML: c.value }, null); } }); z.register = (n, e, t, r) => { n["html-template"] = z, e["html-template"] = tt; }; z.registerDesigner = (n, e, t) => { n["html-template"] = pt, e["html-template"] = nt; }; const wt = ye(z); export { z as FHtmlTemplate, wt as default, nt as designPropsResolver, ue as htmlTemplateDesignProps, le as htmlTemplateProps, tt as propsResolver };