UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,461 lines 56.9 kB
var de = Object.defineProperty; var me = (n, e, t) => e in n ? de(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var F = (n, e, t) => me(n, typeof e != "symbol" ? e + "" : e, t); import { ref as D, computed as W, defineComponent as Y, createVNode as w, inject as J, onMounted as ve } from "vue"; import { getCustomClass as ge } from "../common/index.esm.js"; import { cloneDeep as H, isPlainObject as Q } from "lodash-es"; import { getSchemaByTypeForDesigner as he } from "../dynamic-resolver/index.esm.js"; import { DgControl as ye } from "../designer-canvas/index.esm.js"; function Z(n, e) { let t; function r(l) { const { properties: d, title: h, ignore: u } = l, p = u && Array.isArray(u), v = Object.keys(d).reduce((b, M) => ((!p || !u.find((k) => k === M)) && (b[M] = d[M].type === "object" && d[M].properties ? r(d[M]) : H(d[M].default)), b), {}); if (h && (!p || !u.find((b) => b === "id"))) { const b = h.toLowerCase().replace(/-/g, "_"); v.id = `${b}_${Math.random().toString().slice(2, 6)}`; } return v; } function o(l) { const { properties: d, title: h, required: u } = l; if (u && Array.isArray(u)) { const p = u.reduce((v, b) => (v[b] = d[b].type === "object" && d[b].properties ? r(d[b]) : H(d[b].default), v), {}); if (h && u.find((v) => v === "id")) { const v = h.toLowerCase().replace(/-/g, "_"); p.id = `${v}_${Math.random().toString().slice(2, 6)}`; } return p; } return { type: h }; } function i(l, d = {}, h) { const u = n[l]; if (u) { let p = o(u); const v = e[l]; return p = v ? v({ getSchemaByType: i }, p, d, h) : p, t != null && t.appendIdentifyForNewControl && t.appendIdentifyForNewControl(p), p; } return null; } function s(l, d) { const h = r(d); return Object.keys(h).reduce((u, p) => (Object.prototype.hasOwnProperty.call(l, p) && (u[p] && Q(u[p]) && Q(l[p] || !l[p]) ? Object.assign(u[p], l[p] || {}) : u[p] = l[p]), u), h), h; } function m(l, d) { return Object.keys(l).filter((u) => l[u] != null).reduce((u, p) => { if (d.has(p)) { const v = d.get(p); if (typeof v == "string") u[v] = l[p]; else { const b = v(p, l[p], l); Object.assign(u, b); } } else u[p] = l[p]; return u; }, {}); } function f(l, d, h = /* @__PURE__ */ new Map()) { const u = s(l, d); return m(u, h); } function a(l) { var h; const d = l.type; if (d) { const u = n[d]; if (!u) return l; const p = s(l, u), v = ((h = l.editor) == null ? void 0 : h.type) || ""; if (v) { const b = n[v], M = s(l.editor, b); p.editor = M; } return p; } return l; } function c(l) { t = l; } return { getSchemaByType: i, resolveSchemaWithDefaultValue: a, resolveSchemaToProps: f, mappingSchemaToProps: m, setDesignerContext: c }; } const K = {}, ee = {}, { getSchemaByType: St, resolveSchemaWithDefaultValue: be, resolveSchemaToProps: Ce, mappingSchemaToProps: Se, setDesignerContext: Mt } = Z(K, ee); function Me(n = {}) { function e(a, c, l, d) { if (typeof l == "number") return d[a].length === l; if (typeof l == "object") { const h = Object.keys(l)[0], u = l[h]; if (h === "not") return Number(d[a].length) !== Number(u); if (h === "moreThan") return Number(d[a].length) >= Number(u); if (h === "lessThan") return Number(d[a].length) <= Number(u); } return !1; } function t(a, c, l, d) { return d[a] && d[a].propertyValue && String(d[a].propertyValue.value) === String(l); } const r = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(n).reduce((a, c) => (a.set(c, n[c]), a), r); function o(a, c) { const l = a; return typeof c == "number" ? [{ target: l, operator: "length", param: null, value: Number(c) }] : typeof c == "boolean" ? [{ target: l, operator: "getProperty", param: a, value: !!c }] : typeof c == "object" ? Object.keys(c).map((d) => { if (d === "length") return { target: l, operator: "length", param: null, value: c[d] }; const h = d, u = c[d]; return { target: l, operator: "getProperty", param: h, value: u }; }) : []; } function i(a) { return Object.keys(a).reduce((l, d) => { const h = o(d, a[d]); return l.push(...h), l; }, []); } function s(a, c) { if (r.has(a.operator)) { const l = r.get(a.operator); return l && l(a.target, a.param, a.value, c) || !1; } return !1; } function m(a, c) { return i(a).reduce((h, u) => h && s(u, c), !0); } function f(a, c) { const l = Object.keys(a), d = l.includes("allOf"), h = l.includes("anyOf"), u = d || h, b = (u ? a[u ? d ? "allOf" : "anyOf" : "allOf"] : [a]).map((k) => m(k, c)); return d ? !b.includes(!1) : b.includes(!0); } return { parseValueSchema: f }; } const Ee = { convertTo: (n, e, t, r) => { n.appearance || (n.appearance = {}), n.appearance[e] = t; }, convertFrom: (n, e, t) => n.appearance ? n.appearance[e] : n[e] }, Te = { convertFrom: (n, e, t) => n.buttons && n.buttons.length ? `共 ${n.buttons.length} 项` : "无" }, we = { 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] }, N = { 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: "多语输入框" } }, Pe = { convertFrom: (n, e, t) => { var o; const r = n.editor && n.editor[e] ? n.editor[e] : n[e]; return ((o = N[r]) == null ? void 0 : o.name) || r; } }, Fe = { convertTo: (n, e, t, r) => { n[e] = n[e]; }, convertFrom: (n, e, t) => n.editor ? t.getRealEditorType(n.editor.type) : "" }, Ve = { 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"; } }, Ne = { 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 : "" }, De = { 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 ""; } }, ke = { 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 : "" }, Oe = { 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; } } }, Be = { 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; } } }, $e = { convertTo: (n, e, t, r) => { n.pagination || (n.pagination = {}), n.pagination[e] = t; }, convertFrom: (n, e, t) => n.pagination ? n.pagination[e] : n[e] }, Le = { 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] }, Ue = { convertFrom: (n, e, t) => n[e] && n[e].length ? `共 ${n[e].length} 项` : "" }, je = { convertFrom: (n, e) => n[e] || "", convertTo: (n, e, t) => { n[e] = t; } }, xe = { 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, o; return (r = n.formatter) != null && r.data && e === "formatterEnumData" && !n.formatterEnumData ? (o = n.formatter) == null ? void 0 : o.data : n.formatterEnumData; } }, qe = { convertTo: (n, e, t, r) => { n.sort || (n.sort = {}), n.sort[e] = t; }, convertFrom: (n, e, t) => { var r, o; if (e === "mode") return ((r = n.sort) == null ? void 0 : r.mode) || "client"; if (e === "multiSort") return !!((o = n.sort) != null && o.multiSort); } }, _e = { 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"; } }, We = { 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 te(n, e, t) { const r = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", Ee], ["/converter/buttons.converter", Te], ["/converter/property-editor.converter", we], ["/converter/items-count.converter", Ue], ["/converter/type.converter", Pe], ["/converter/change-editor.converter", Fe], ["/converter/change-formatter.converter", Ve], ["/converter/column-command.converter", Ne], ["/converter/column-option.converter", De], ["/converter/summary.converter", ke], ["/converter/group.converter", Oe], ["/converter/form-group-label.converter", je], ["/converter/field-selector.converter", Be], ["/converter/pagination.converter", $e], ["/converter/row-number.converter", Le], ["/converter/grid-selection.converter", Ae], ["/converter/size.converter", xe], ["/converter/change-formatter-enum.converter", ze], ["/converter/grid-sort.converter", qe], ["/converter/grid-filter.converter", _e], ["/converter/row-option.converter", We] ]), o = /* @__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 }] ]), i = Me(); function s(u, p) { return () => i.parseValueSchema(u, p); } function m(u, p, v) { return u.includes("visible") && p.visible !== void 0 ? typeof p.visible == "boolean" ? () => !!p.visible : p.visible === void 0 ? !0 : s(p.visible, v) : () => !0; } function f(u, p, v) { return u.includes("readonly") && p.readonly !== void 0 ? typeof p.readonly == "boolean" ? () => !!p.readonly : s(p.readonly, v) : () => !1; } function a(u, p) { const v = u.$converter || p; return typeof v == "string" && v && r.has(v) ? r.get(v) || null : v || null; } function c(u, p, v, b, M, k = "", L = "") { return Object.keys(u).map((T) => { const A = D(1), U = T, y = u[T], O = Object.keys(y), z = y.title, g = y.type, C = o.get(g) || { type: "input-group", enableClear: !1 }, S = y.editor ? Object.assign({}, C, y.editor) : Object.assign({}, C), E = m(O, y, p), P = f(O, y, p); S.readonly = S.readonly === void 0 ? P() : S.readonly; const $ = y.type === "cascade" ? c(y.properties, p, v, b, M, k, L) : [], q = !0; let V = a(y, L); const j = W({ get() { if (A.value) { if (["class", "style"].find((pe) => pe === U) && !V && (V = r.get("/converter/appearance.converter") || null), V && V.convertFrom) return V.convertFrom(v, T, M, k); const x = v[T]; return Object.prototype.hasOwnProperty.call(y, "defaultValue") && (x === void 0 || typeof x == "string" && x === "") ? y.type === "boolean" ? y.defaultValue : y.defaultValue || "" : x; } return null; }, set(x) { A.value += 1, V && V.convertTo ? (V.convertTo(b, T, x, M, k), V.convertTo(v, T, x, M, k)) : (b[T] = x, v[T] = x); } }), { refreshPanelAfterChanged: _, description: ce, isExpand: ue, parentPropertyID: fe } = y, I = { propertyID: U, propertyName: z, propertyType: g, propertyValue: j, editor: S, visible: E, readonly: P, cascadeConfig: $, hideCascadeTitle: q, refreshPanelAfterChanged: _, description: ce, isExpand: ue, parentPropertyID: fe }; return p[U] = I, I; }); } function l(u, p, v = {}) { const b = {}, M = n[u]; return M && M.categories ? Object.keys(M.categories).map((L) => { const B = M.categories[L], T = B == null ? void 0 : B.title, A = c(B.properties || {}, b, {}, v, p); return { categoryId: L, categoryName: T, properties: A }; }) : []; } function d(u, p, v, b, M = "") { const k = p.$ref.schema, L = p.$ref.converter, B = v[k], T = B.type, A = t(B), U = {}, y = n[T]; if (y && y.categories) { const O = y.categories[u], z = O == null ? void 0 : O.title; L && Object.keys(O.properties).forEach((S) => { O.properties[S].$converter = L; }); const g = (O == null ? void 0 : O.properties) || {}, C = c(g, U, A, B, b, M); return { categoryId: u, categoryName: z, properties: C }; } return { categoryId: u, categoryName: "", properties: [] }; } function h(u, p, v, b, M) { const k = u.type, L = t(u), B = {}; let T = M || n[k]; if (T && Object.keys(T).length === 0 && v && v.getPropConfig && (T = v.getPropConfig(b)), T && T.categories) { const A = []; return Object.keys(T.categories).map((U) => { const y = T.categories[U]; if (y.$ref) { A.push(d(U, y, u, p, b)); return; } const O = y == null ? void 0 : y.title, z = y == null ? void 0 : y.tabId, g = y == null ? void 0 : y.tabName, C = y == null ? void 0 : y.hide, S = y == null ? void 0 : y.hideTitle, E = c(y.properties || {}, B, L, u, p, b, y.$converter), { setPropertyRelates: P } = y, $ = y == null ? void 0 : y.parentPropertyID; A.push({ categoryId: U, categoryName: O, tabId: z, tabName: g, hide: C, properties: E, hideTitle: S, setPropertyRelates: P, parentPropertyID: $ }); }), A; } return []; } return { getPropertyConfigBySchema: h, getPropertyConfigByType: l, propertyConverterMap: r }; } const ne = {}, re = {}; te(ne, re, be); const oe = {}, ie = {}, { getSchemaByType: Et, resolveSchemaWithDefaultValue: Ge, resolveSchemaToProps: Tt, mappingSchemaToProps: wt, setDesignerContext: Pt } = Z(oe, ie), se = {}, ae = {}; te(se, ae, Ge); function He(n, e, t = /* @__PURE__ */ new Map(), r = (s, m, f, a) => m, o = {}, i = (s) => s) { return K[e.title] = e, ee[e.title] = r, ne[e.title] = o, re[e.title] = i, oe[e.title] = e, ie[e.title] = r, se[e.title] = o, ae[e.title] = i, (s = {}, m = !0) => { if (!m) return Se(s, t); const f = Ce(s, e, t), a = Object.keys(n).reduce((c, l) => (c[l] = n[l].default, c), {}); return Object.assign(a, f); }; } function Re(n, e) { return { customClass: e.class, customStyle: e.style }; } function Ie(n, e) { return { size: e.width || e.height || "" }; } const Je = /* @__PURE__ */ new Map([ ["appearance", Re], ["size", Ie] ]); function Qe(n, e, t) { return e; } const Xe = "https://json-schema.org/draft/2020-12/schema", Ye = "https://farris-design.gitee.io/list-nav.schema.json", Ze = "list-nav", Ke = "A Farris Container Component", et = "object", tt = { id: { description: "The unique identifier for a list-nav", type: "string" }, type: { description: "The type string of list-nav component", type: "string", default: "list-nav" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, size: { description: "", type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, default: null }, visible: { description: "", type: "boolean", default: !0 }, position: { description: "", type: "string", default: "left" } }, nt = [ "id", "type", "contents" ], rt = { $schema: Xe, $id: Ye, title: Ze, description: Ke, type: et, properties: tt, required: nt }, R = { /** 自定义样式 */ customClass: { type: String, default: "" }, customStyle: { type: String, default: "" }, /** 位置 */ position: { Type: String, default: "left" }, /** listNav名称 */ title: { Type: String, default: "" }, /** 宽度或者高度 */ size: { Type: Number || String, default: 218 }, /** 是否启用收折 */ collapsible: { Type: Boolean, default: !0 }, /** 初始收折状态 */ folded: { Type: Boolean, default: !1 }, /** 控件禁用状态 */ disabled: { Type: Boolean, default: !1 }, /** 是否启用拖拽 TODO */ draggable: { Type: Boolean, default: !1 } }, X = He(R, rt, Je, Qe), G = /* @__PURE__ */ Y({ name: "FListNav", props: R, emits: ["collapse"], setup(n, e) { const t = D(n.position), r = D(n.title), o = D(n.folded), i = D(!1); function s(a) { a && a.stopPropagation(), !n.disabled && (i.value = !0, o.value = !o.value, e.emit("collapse", o.value)); } const m = W(() => { const a = {}, c = ["top", "bottom"].indexOf(t.value) > -1 ? "height" : "width"; return a[c] = o.value ? "0px" : n.size + "px", a; }), f = W(() => { const a = { "f-list-nav": !0, "f-list-nav-top": t.value === "top", "f-list-nav-left": t.value === "left", "f-list-nav-right": t.value === "right", "f-list-nav-bottom": t.value === "bottom" }; return ge(a, n.customClass); }); return () => w("div", { class: f.value, style: n.customStyle }, [w("div", { class: "f-list-nav-in", style: m.value }, [w("div", { class: "f-list-nav-main" }, [e.slots.navHeader && w("div", { class: "f-list-nav-header" }, [e.slots.navHeader()]), !e.slots.navHeader && r.value && w("div", { class: "f-list-nav-header" }, [w("div", { class: "f-list-nav-title" }, [r.value])]), e.slots.default && w("div", { class: "f-list-nav-content" }, [e.slots.default()]), e.slots.navContent && w("div", { class: "f-list-nav-content" }, [e.slots.navContent()]), e.slots.navFooter && w("div", { class: "f-list-nav-footer" }, [e.slots.navFooter()])]), n.collapsible && w("div", { class: ["f-list-nav-toggle-sidebar", { disabled: n.disabled, active: o.value, "splitter-pane-collapse-animate": i.value }], onClick: (a) => s(a) }, [w("span", { class: "triangle" }, null)])])]); } }); function ot(n, e, t) { var z; const r = t && t.getStyles && t.getStyles() || "", o = t && t.getDesignerClass && t.getDesignerClass() || "", i = D(); let s; function m() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanMoveComponent ? t.checkCanMoveComponent() : !0; } function f() { return !1; } function a() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanDeleteComponent ? t.checkCanDeleteComponent() : !0; } function c() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !0 : t && t.hideNestedPaddingInDesginerView ? t.hideNestedPaddingInDesginerView() : !1; } function l(g) { if (!g || !g.value) return null; if (g.value.schema && g.value.schema.type === "component") return g.value; const C = D(g == null ? void 0 : g.value.parent), S = l(C); return S || null; } function d(g = e) { var P; if (t != null && t.getDraggableDesignItemElement) return t.getDraggableDesignItemElement(g); const { componentInstance: C, designerItemElementRef: S } = g; if (!C || !C.value) return null; const { getCustomButtons: E } = C.value; return C.value.canMove || E && ((P = E()) != null && P.length) ? S : d(g.parent); } function h(g) { return !!t && t.canAccepts(g); } function u() { return (e == null ? void 0 : e.schema.label) || (e == null ? void 0 : e.schema.title) || (e == null ? void 0 : e.schema.name); } function p() { } function v(g, C) { var S; !g || !C || (t != null && t.onAcceptMovedChildElement && t.onAcceptMovedChildElement(g, C), (S = e == null ? void 0 : e.setupContext) == null || S.emit("dragEnd")); } function b(g, C) { const { componentType: S } = g; let E = he(S, g, C); t && t.onResolveNewComponentSchema && (E = t.onResolveNewComponentSchema(g, 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 M(g) { g && t != null && t.onChildElementMovedOut && t.onChildElementMovedOut(g); } function k(...g) { if (t && t.getPropsConfig) return t.getPropsConfig(...g); } function L(g) { if (!g) return; const C = e == null ? void 0 : e.schema, { formSchemaUtils: S } = g; if (C && S.getExpressions().length) { const E = S.getExpressions().findIndex((P) => P.target === C.id); E > -1 && S.getExpressions().splice(E, 1); } } function B(g) { if (!g || !(e != null && e.schema)) return; const C = e.schema, { formSchemaUtils: S } = g; S.removeCommunicationInComponent(C); } function T(g) { t && t.onRemoveComponent && t.onRemoveComponent(), L(g), B(g), e != null && e.schema.contents && e.schema.contents.map((C) => { let S = C.id; C.type === "component-ref" && (S = C.component); const E = n.value.querySelectorAll(`#${S}-design-item`); E != null && E.length && Array.from(E).map((P) => { var $; ($ = P == null ? void 0 : P.componentInstance) != null && $.value.onRemoveComponent && P.componentInstance.value.onRemoveComponent(g); }); }); } function A() { if (t && t.getCustomButtons) return t.getCustomButtons(); } function U(g) { var S, E; if (!((S = e == null ? void 0 : e.schema) != null && S.id)) return; if (!s && g && (s = g.formSchemaUtils), t != null && t.setComponentBasicInfoMap) { t.setComponentBasicInfoMap(); return; } let C = ""; if (t != null && t.getComponentTitle) C = t.getComponentTitle(); else { const { text: P, title: $, label: q, mainTitle: V, name: j, type: _ } = e.schema; C = P || $ || q || V || j || ((E = N[_]) == null ? void 0 : E.name); } C && s.getControlBasicInfoMap().set(e.schema.id, { componentTitle: C, parentPathName: C }); } function y(g) { var P; const { changeObject: C } = g, { propertyID: S, propertyValue: E } = C; if (["text", "title", "label", "name", "mainTitle"].includes((P = g == null ? void 0 : g.changeObject) == null ? void 0 : P.propertyID) && S && E && (U(), s)) { const $ = s.getControlBasicInfoMap(), q = $.keys().toArray().filter((V) => { var j, _; return ((j = $.get(V)) == null ? void 0 : j.reliedComponentId) === ((_ = e == null ? void 0 : e.schema) == null ? void 0 : _.id); }); q != null && q.length && q.forEach((V) => { const j = $.get(V).parentPathName.split(" > "); j[0] = E, $.get(V).parentPathName = j.join(" > "); }); } } function O(g) { if (y(g), t && t.onPropertyChanged) return t.onPropertyChanged(g); } return i.value = { canMove: m(), canSelectParent: f(), canDelete: a(), canNested: !c(), contents: e == null ? void 0 : e.schema.contents, elementRef: n, parent: (z = e == null ? void 0 : e.parent) == null ? void 0 : z.componentInstance, schema: e == null ? void 0 : e.schema, styles: r, designerClass: o, canAccepts: h, getBelongedComponentInstance: l, getDraggableDesignItemElement: d, getDraggingDisplayText: u, getPropConfig: k, getDragScopeElement: p, onAcceptMovedChildElement: v, onChildElementMovedOut: M, addNewChildComponentSchema: b, triggerBelongedComponentToMoveWhenMoved: !!t && t.triggerBelongedComponentToMoveWhenMoved || D(!1), triggerBelongedComponentToDeleteWhenDeleted: !!t && t.triggerBelongedComponentToDeleteWhenDeleted || D(!1), onRemoveComponent: T, getCustomButtons: A, onPropertyChanged: O, setComponentBasicInfoMap: U, updateContextSchema: e == null ? void 0 : e.updateContextSchema }, i; } function it() { function n(e, t) { var s; if (!e) return !1; const r = ((s = e.targetContainer) == null ? void 0 : s.componentInstance) && e.targetContainer.componentInstance.value; if (!r) return !1; const o = r.schema.type, i = t == null ? void 0 : t.formSchemaUtils.getComponentById(r.belongedComponentId); return !((e.componentCategory === "input" || e.componentType === "form-group") && ![N["response-layout-item"].type, N["response-form"].type, N.fieldset.type].includes(o) || (e.componentType === N.tabs.type || e.componentType === N.section.type) && ((i == null ? void 0 : i.componentType) !== "frame" || ![N["content-container"].type, N["splitter-pane"].type, N["response-layout-item"].type].includes(o)) || [N["query-solution"].type, N["filter-bar"].type].includes(e.componentType) || e.componentType === N.fieldset.type && o !== N["response-form"].type); } return { basalDragulaRuleForContainer: n }; } class st { getTemplateRule(e, t) { const r = t == null ? void 0 : t.formSchemaUtils, o = r == null ? void 0 : r.getFormTemplateRule(), i = { canAccept: !0, canDelete: !0, canMove: !0 }; if (!o) return i; const s = this.getComponentContext(e), { componentClassList: m } = s; return m.forEach((f) => { if (!f || !o[f]) return; const { canMove: a, canDelete: c, canAccept: l } = o[f]; i.canMove = i.canMove && this.resolveRuleValue(a, s), i.canDelete = i.canDelete && this.resolveRuleValue(c, s), i.canAccept = i.canAccept && this.resolveRuleValue(l, s); }), i; } resolveRuleValue(e, t) { return typeof e == "boolean" ? e : this.parseRuleValueSchema(e, t); } parseRuleValueSchema(e, t) { const r = e.invalidContext || []; let o = !0; for (const i of r) { const { firstLevelChild: s, secondLevelChild: m, parent: f, ...a } = i; if (a && t.component) { let c = !0; for (const l of Object.keys(a)) if (a[l] !== t.component[l]) { c = !1; break; } if (!c) { o = !1; continue; } } if (i.firstLevelChild) { if (i.firstLevelChild.class) { const { firstLevelChildClassList: c } = t; if (c && !c.includes(i.firstLevelChild.class)) { o = !1; continue; } } if (i.firstLevelChild.type) { const { firstLevelChildSchema: c } = t; if (!c || c.type !== i.firstLevelChild.type) { o = !1; continue; } } } if (i.secondLevelChild) { if (i.secondLevelChild.class) { const { secondLevelChildClassList: c } = t; if (c && !c.includes(i.secondLevelChild.class)) { o = !1; continue; } } if (i.secondLevelChild.type) { const { secondLevelChildSchema: c } = t; if (!c || c.type !== i.secondLevelChild.type) { o = !1; continue; } } } if (i.parent) { if (i.parent.class) { const { parentClassList: c } = t; if (c && !c.includes(i.parent.class)) { o = !1; continue; } } if (i.parent.type) { const { parentSchema: c } = t; if (c && c.type !== i.parent.type) { o = !1; continue; } } } o = !0; break; } return !o; } getComponentContext(e) { var p, v, b, M; const t = e.schema, r = t.appearance && t.appearance.class || "", o = r.split(" ") || [], i = t.contents || [], s = i.length ? i[0] : null, m = s && s.appearance ? s.appearance.class : "", f = m ? m.split(" ") : [], a = (p = s == null ? void 0 : s.contents) != null && p.length ? s == null ? void 0 : s.contents[0] : null, c = a && a.appearance ? a.appearance.class : "", l = c ? c.split(" ") : [], d = t.type === "component" ? (b = (v = e.parent) == null ? void 0 : v.parent) == null ? void 0 : b.schema : (M = e.parent) == null ? void 0 : M.schema, h = d && d.appearance && d.appearance.class || "", u = h ? h.split(" ") : []; return { componentClass: r, componentClassList: o, childContents: i, firstLevelChildSchema: s, firstLevelChildClass: m, firstLevelChildClassList: f, secondLevelChildSchema: a, secondLevelChildClass: c, secondLevelChildClassList: l, parentSchema: d, parentClass: h, parentClassList: u, component: t }; } } const le = D(0), at = D(0); function lt() { at.value++; } function ct(n) { const { formSchemaUtils: e, formStateMachineUtils: t } = n; function r(f, a = "") { return { path: a + f.code, field: f.id, fullPath: f.code }; } function o(f, a = "") { return e.getViewModelById(f).states.map((l) => r(l, a)); } function i(f) { const a = e.getRootViewModelId(), c = o(f); if (f === a) return c; const l = o(a, "root-component."); return [...c, ...l]; } function s(f) { return f.binding && f.binding.path || f.id || ""; } function m() { return t && t.getRenderStates() || []; } return { getVariables: i, getControlName: s, getStateMachines: m }; } class ut { 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, o, i, s) => { const m = i.getExpressionRuleValue(e, t || o); return m && m.value || ""; }, convertTo: (r, o, i, s, m) => { var f; if (o === "dataPicking" && (i != null && i.target)) { const a = `${i.target}_dataPicking`; ((f = i.rules) == null ? void 0 : f.some( (l) => l.id === a && l.value )) ? r.dictPickingExpressionId = a : delete r.dictPickingExpressionId; } s.updateExpression(i); } })); this.formSchemaService = e; } getExpressionRule(e, t) { const r = this.formSchemaService.getExpressions(); if (!r) return ""; const o = r.find((s) => s.target === e); if (!o) return ""; const i = o.rules.find((s) => s.type === t); return i || ""; } // 获取上下文表单变量 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 o = []; return r.states.forEach((i) => { o.push({ key: i.code, name: i.name, description: i.name, category: i.category }); }), o; } 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((o) => { var m; const i = this.createTreeNode(o, t); let s = []; (m = o.type) != null && m.fields && (s = this.buildEntityFieldsTreeData(o.type.fields, [...t, o.label])), r.push({ data: i, children: s, expanded: !0 }); }), r; } buildChildEntityTreeData(e = null, t) { const r = []; return e == null || e.forEach((o) => { var f, a; const i = this.createTreeNode(o, t); i.type = "entity"; const s = this.buildEntityFieldsTreeData((f = o.type) == null ? void 0 : f.fields, [...t, o.label]), m = this.buildChildEntityTreeData((a = o.type) == null ? void 0 : a.entities, [...t, o.label]); m != null && m.length && (s == null || s.push(...m)), r.push({ data: i, children: s || [], // 空值回退 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]), o = this.buildChildEntityTreeData(t.type.entities, [t.code]); return o != null && o.length && (r == null || r.push(...o)), { 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 o = r === "Field" ? e.binding.field : e.id, i = this.getExpressionRule(o, t), s = this.getEntitiesAndVariables(), m = { message: ["validate", "required", "dataPicking"].includes(t) && i ? i.message : "", ...s }; return i.messageType != null && (m.messageType = i.messageType), m; } buildRule(e, t, r, o) { const { expression: i, message: s, messageType: m } = t, f = { id: `${e}_${r}`, type: r, value: i }; return (r === "validate" || r === "dataPicking" || r === "required") && (f.message = s), r === "dataPicking" && (f.messageType = m), r === "validate" && o && (f.elementId = o), f; } getExpressionData() { const { expressions: e } = this.formSchemaService.getFormSchema().module; return e || []; } updateExpression(e, t, r, o) { const i = t === "Field" ? e.binding.field : e.id, s = this.buildRule(i, r, o, e.type === "form-group" ? e.id : ""); let f = this.getExpressionData().find((c) => c.targetType === t && c.target === i); const a = (c) => c.value.trim() === ""; if (f) { const c = f.rules.find((l) => l.id === s.id); if (c) a(s) ? f.rules = f.rules.filter((l) => l.id !== s.id) : (Object.assign(c, s), o === "validate" && e.type === "form-group" && (c.elementId = e.id)); else { if (a(s)) return null; f.rules = f.rules || [], f.rules.push(s); } } else { if (a(s)) return null; f = { target: `${i}`, rules: [s], targetType: t }; } return f; } getExpressionEditorOptions(e, t, r, o) { return r.reduce((i, s) => { var f, a; const m = t === "Field" ? (f = e == null ? void 0 : e.binding) == null ? void 0 : f.field : e.id; return i[s] = { hide: t === "Field" ? !!((a = e == null ? void 0 : e.binding) != null && a.field) : !1, description: "", title: this.expressionNames[s], type: "string", $converter: this.getExpressionConverter(m), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[s]}编辑器`, showMessage: s === "validate" || s === "dataPicking" || s === "required", showMessageType: s === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(e, s, t), onSubmitModal: (c) => { const l = this.updateExpression(e, t, c, s); if (o) { const d = this.buildRule(m, c, s); o(d); } return l; } } }, i; }, {}); } getExpressionInfo(e, t, r) { const o = t === "Field" ? e.binding.field : e.id, i = this.getExpressionRule(o, r), s = { value: i && i.value, targetId: o, targetType: t, expressionType: r }; return i && i.message && (s.message = i.message), s; } getExpressionConfig(e, t, r = ["compute", "dependency", "validate"], o) { return { description: "表达式", title: "表达式", hide: !e.binding, properties: { ...this.getExpressionEditorOptions(e, t, r, o) } }; } getExpressionOptions(e, t, r) { const o = this.getExpressionInfo(e, t, r); return { dialogTitle: `${this.expressionNames[r]}编辑器`, singleExpand: !1, showMessage: r === "required", beforeOpen: () => this.onBeforeOpenExpression(e, r, t), expressionInfo: o }; } } class ft { 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 o = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = o.fields.find((i) => i.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: N[e.type] && N[e.type].name }] } } } }; } getAppearanceConfig(e = null, t = {}, r) { const o = { title: "外观", description: "Appearance" }, i = { 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 s in t) i[s] = Object.assign(i[s] || {}, t[s]); return { ...o, properties: { ...i }, setPropertyRelates(s, m) { if (s) { switch (s && s.propertyID) { case "class": case "style": { le.value++; break; } } r && r(s, e, m); } } }; } getPropertyEditorParams(e, t = [], r = "visible", o = {}, i = {}) { const { getVariables: s, getControlName: m, getStateMachines: f } = ct(this.designerHostService), a = this.getRealTargetType(e), c = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], l = { type: "property-editor", propertyTypes: c }; return c.map((d) => { switch (d) { case "Const": Object.assign(l, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, o); break; case "Expression": l.expressionConfig = this.getExpressionOptions(e, a, r); break; case "StateMachine": l.stateMachines = f(); break; case "Variable": Object.assign(l, { controlName: m(e), newVariablePrefix: "is", newVariableType: "Boolean", variables: s(this.viewModelId), onBeforeOpenVariables: (h) => { h.value = s(this.viewModelId); } }, i); break; } }), l; } getVisibleProperty(e, t = "") { var i; let r = ["Const", "Variable", "StateMachine", "Expression"]; return t === "gridFieldEditor" ? r = ["Const", "Expression"] : t === "form-group" && !((i = e.binding) != null && i.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 = {}, o) { const i = { title: "行为", description: "" }, s = this.getVisibleProperty(e, t); for (const f in r) s[f] = Object.assign(s[f] || {}, r[f]); const m = this; return { ...i, properties: { ...s }, setPropertyRelates(f, a) { if (f) { switch (f.propertyID) { case "disabled": case "readonly": case "visible": m.afterMutilEditorChanged(e, f); break; } o && o(f, a); } } }; } /** * 当多值编辑器变更时 * @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 o = r.contents.findIndex((s) => s.id === e), i = H(r.contents[o]); r.contents.splice(o, 1), r.contents.splice(o, 0, i), lt(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到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 s = { id: r.field, category: "locale", code: r.fullPath, name: r.fullPath, type: r.newVariableType || "String" }; delete r.newVariableType, delete r.isNewVariable, this.formSchemaUtils