UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,380 lines (1,379 loc) 232 kB
var Xn = Object.defineProperty; var Jn = (n, e, t) => e in n ? Xn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var oe = (n, e, t) => Jn(n, typeof e != "symbol" ? e + "" : e, t); import { ref as T, computed as _, defineComponent as Fe, onBeforeMount as Tt, onMounted as _e, createVNode as v, watch as Se, Fragment as Re, reactive as Ge, createApp as vn, onUnmounted as Ft, Transition as hn, mergeProps as xt, nextTick as Mt, createTextVNode as ce, inject as Ht, Teleport as Qn, shallowRef as Zn, render as Ut, h as Kn, cloneVNode as eo, withDirectives as to, vModelText as no } from "vue"; import { cloneDeep as De, isPlainObject as rn, isUndefined as qe } from "lodash-es"; import { getSchemaByTypeForDesigner as oo, resolveAppearance as io, createPropsResolver as gn } from "../dynamic-resolver/index.esm.js"; import { useI18n as Yt } from "vue-i18n"; import { LocaleService as Et } from "../locale/index.esm.js"; import { getCustomClass as Ct, withInstall as ro, FormSchemaEntityField$Type as an, FormSchemaEntityFieldTypeName as sn } from "../common/index.esm.js"; import { useResizeObserver as ao } from "@vueuse/core"; import { getHierarchyRow as so, useIdentify as lo, useGroupData as co, useFilter as uo, useHierarchy as fo, useLoading as po, useDataView as mo, useSelection as vo, useSelectHierarchyItem as ho, usePagination as go, useDataViewContainerStyle as yo, useCommandColumn as bo, useSettingColumn as wo, useColumn as Co, useSort as So, useGroupColumn as To, useRow as Fo, useEdit as xo, useVisualDataBound as Mo, useVisualDataCell as Eo, useVisualDataRow as Bo, useVisualData as ko, useCellPosition as Io, useSidebar as Vo, useVirtualScroll as Oo, useFitColumn as Po, useFilterHistory as No, useColumnFilter as Do, useDragColumn as Ro, getColumnHeader as jo, getSidebar as $o, getDisableMask as Lo, getHorizontalScrollbar as Ao, getVerticalScrollbar as Uo, getEmpty as zo, getPagination as qo, getSummary as Ho } from "../data-view/index.esm.js"; import { DgControl as rt } from "../designer-canvas/index.esm.js"; import { FormBindingType as Go } from "../property-panel/index.esm.js"; import _o from "../accordion/index.esm.js"; import Wo from "../avatar/index.esm.js"; import Yo from "../../designer/button-edit/index.esm.js"; import Xo from "../button-group/index.esm.js"; import Jo from "../calendar/index.esm.js"; import Qo from "../capsule/index.esm.js"; import ln from "../../designer/checkbox/index.esm.js"; import cn from "../../designer/checkbox-group/index.esm.js"; import Zo from "../combo-list/index.esm.js"; import Ko from "../combo-tree/index.esm.js"; import ei from "../component/index.esm.js"; import ti from "../color-picker/index.esm.js"; import ni from "../content-container/index.esm.js"; import oi from "../date-picker/index.esm.js"; import ii from "../../designer/data-grid/index.esm.js"; import ri from "../dropdown/index.esm.js"; import ai from "../dynamic-form/index.esm.js"; import si from "../events-editor/index.esm.js"; import li from "../filter-bar/index.esm.js"; import ci from "../field-selector/index.esm.js"; import ui from "../binding-selector/index.esm.js"; import di from "../image-cropper/index.esm.js"; import fi from "../../designer/input-group/index.esm.js"; import pi from "../layout/index.esm.js"; import mi from "../list-nav/index.esm.js"; import vi from "../../designer/list-view/index.esm.js"; import hi from "../lookup/index.esm.js"; import gi from "../mapping-editor/index.esm.js"; import yi from "../nav/index.esm.js"; import bi from "../number-range/index.esm.js"; import wi from "../number-spinner/index.esm.js"; import Ci from "../order/index.esm.js"; import Si from "../page-header/index.esm.js"; import Ti from "../page-footer/index.esm.js"; import Fi from "../pagination/index.esm.js"; import xi from "../progress/index.esm.js"; import Mi from "../query-solution/index.esm.js"; import Ei from "../../designer/radio-group/index.esm.js"; import Bi from "../rate/index.esm.js"; import ki from "../response-toolbar/index.esm.js"; import Ii from "../response-layout/index.esm.js"; import Vi from "../response-layout-editor/index.esm.js"; import Oi from "../search-box/index.esm.js"; import Pi from "../section/index.esm.js"; import Ni from "../smoke-detector/index.esm.js"; import Di from "../splitter/index.esm.js"; import Ri from "../step/index.esm.js"; import ji from "../switch/index.esm.js"; import $i from "../tabs/index.esm.js"; import Li from "../tags/index.esm.js"; import Ai from "../text/index.esm.js"; import Ui from "../time-picker/index.esm.js"; import zi from "../transfer/index.esm.js"; import qi from "../tree-view/index.esm.js"; import Hi from "../uploader/index.esm.js"; import Gi from "../verify-detail/index.esm.js"; import _i from "../video/index.esm.js"; import Wi from "../textarea/index.esm.js"; import Yi from "../schema-selector/index.esm.js"; import Xi from "../../designer/tree-grid/index.esm.js"; import Ji from "../event-parameter/index.esm.js"; import Qi from "../filter-condition-editor/index.esm.js"; import Zi from "../fieldset/index.esm.js"; import Ki from "../sort-condition-editor/index.esm.js"; import er from "../menu-lookup/index.esm.js"; import tr from "../../designer/drawer/index.esm.js"; import nr from "../json-editor/index.esm.js"; import or from "../property-editor/index.esm.js"; import ir from "../expression-editor/index.esm.js"; import rr from "../code-editor/index.esm.js"; import ar from "../html-template/index.esm.js"; import sr from "../collection-property-editor/index.esm.js"; import lr from "../modal/index.esm.js"; import cr from "../external-container/index.esm.js"; import ur from "../language-textbox/index.esm.js"; import { FNotifyService as dr } from "../notify/index.esm.js"; import fr from "../tree-grid/index.esm.js"; import "bignumber.js"; function yn(n, e) { let t; function o(d) { const { properties: g, title: h, ignore: f } = d, p = f && Array.isArray(f), x = Object.keys(g).reduce((B, V) => ((!p || !f.find((N) => N === V)) && (B[V] = g[V].type === "object" && g[V].properties ? o(g[V]) : De(g[V].default)), B), {}); if (h && (!p || !f.find((B) => B === "id"))) { const B = h.toLowerCase().replace(/-/g, "_"); x.id = `${B}_${Math.random().toString().slice(2, 6)}`; } return x; } function i(d) { const { properties: g, title: h, required: f } = d; if (f && Array.isArray(f)) { const p = f.reduce((x, B) => (x[B] = g[B].type === "object" && g[B].properties ? o(g[B]) : De(g[B].default), x), {}); if (h && f.find((x) => x === "id")) { const x = h.toLowerCase().replace(/-/g, "_"); p.id = `${x}_${Math.random().toString().slice(2, 6)}`; } return p; } return { type: h }; } function a(d, g = {}, h) { const f = n[d]; if (f) { let p = i(f); const x = e[d]; return p = x ? x({ getSchemaByType: a }, p, g, h) : p, t != null && t.appendIdentifyForNewControl && t.appendIdentifyForNewControl(p), p; } return null; } function r(d, g) { const h = o(g); return Object.keys(h).reduce((f, p) => (Object.prototype.hasOwnProperty.call(d, p) && (f[p] && rn(f[p]) && rn(d[p] || !d[p]) ? Object.assign(f[p], d[p] || {}) : f[p] = d[p]), f), h), h; } function c(d, g) { return Object.keys(d).filter((f) => d[f] != null).reduce((f, p) => { if (g.has(p)) { const x = g.get(p); if (typeof x == "string") f[x] = d[p]; else { const B = x(p, d[p], d); Object.assign(f, B); } } else f[p] = d[p]; return f; }, {}); } function s(d, g, h = /* @__PURE__ */ new Map()) { const f = r(d, g); return c(f, h); } function l(d) { var h; const g = d.type; if (g) { const f = n[g]; if (!f) return d; const p = r(d, f), x = ((h = d.editor) == null ? void 0 : h.type) || ""; if (x) { const B = n[x], V = r(d.editor, B); p.editor = V; } return p; } return d; } function u(d) { t = d; } return { getSchemaByType: a, resolveSchemaWithDefaultValue: l, resolveSchemaToProps: s, mappingSchemaToProps: c, setDesignerContext: u }; } const Xt = {}, bn = {}, { getSchemaByType: zt, resolveSchemaWithDefaultValue: pr, resolveSchemaToProps: mr, mappingSchemaToProps: vr, setDesignerContext: Hc } = yn(Xt, bn); function hr(n = {}) { function e(l, u, d, g) { if (typeof d == "number") return g[l].length === d; if (typeof d == "object") { const h = Object.keys(d)[0], f = d[h]; if (h === "not") return Number(g[l].length) !== Number(f); if (h === "moreThan") return Number(g[l].length) >= Number(f); if (h === "lessThan") return Number(g[l].length) <= Number(f); } return !1; } function t(l, u, d, g) { return g[l] && g[l].propertyValue && String(g[l].propertyValue.value) === String(d); } const o = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(n).reduce((l, u) => (l.set(u, n[u]), l), o); function i(l, u) { const d = l; return typeof u == "number" ? [{ target: d, operator: "length", param: null, value: Number(u) }] : typeof u == "boolean" ? [{ target: d, operator: "getProperty", param: l, value: !!u }] : typeof u == "object" ? Object.keys(u).map((g) => { if (g === "length") return { target: d, operator: "length", param: null, value: u[g] }; const h = g, f = u[g]; return { target: d, operator: "getProperty", param: h, value: f }; }) : []; } function a(l) { return Object.keys(l).reduce((d, g) => { const h = i(g, l[g]); return d.push(...h), d; }, []); } function r(l, u) { if (o.has(l.operator)) { const d = o.get(l.operator); return d && d(l.target, l.param, l.value, u) || !1; } return !1; } function c(l, u) { return a(l).reduce((h, f) => h && r(f, u), !0); } function s(l, u) { const d = Object.keys(l), g = d.includes("allOf"), h = d.includes("anyOf"), f = g || h, B = (f ? l[f ? g ? "allOf" : "anyOf" : "allOf"] : [l]).map((N) => c(N, u)); return g ? !B.includes(!1) : B.includes(!0); } return { parseValueSchema: s }; } const gr = { convertTo: (n, e, t, o) => { n.appearance || (n.appearance = {}), n.appearance[e] = t; }, convertFrom: (n, e, t) => n.appearance ? n.appearance[e] : n[e] }, yr = { convertFrom: (n, e, t) => n.buttons && n.buttons.length ? `共 ${n.buttons.length} 项` : "无" }, br = { convertTo: (n, e, t, o) => { n.editor && (n.editor[e] = t); }, convertFrom: (n, e, t) => n.editor && Object.prototype.hasOwnProperty.call(n.editor, e) ? n.editor[e] : n[e] }, $ = { 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: "多语输入框" } }, wr = { convertFrom: (n, e, t) => { var i; const o = n.editor && n.editor[e] ? n.editor[e] : n[e]; return ((i = $[o]) == null ? void 0 : i.name) || o; } }, Cr = { convertTo: (n, e, t, o) => { n[e] = n[e]; }, convertFrom: (n, e, t) => n.editor ? t.getRealEditorType(n.editor.type) : "" }, Sr = { convertTo: (n, e, t, o) => { (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"; } }, Tr = { convertTo: (n, e, t, o) => { 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 : "" }, Fr = { convertTo: (n, e, t, o) => { 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 ""; } }, xr = { convertTo: (n, e, t, o) => { 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 : "" }, Mr = { convertTo: (n, e, t, o) => { 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; } } }, Er = { convertFrom: (n, e) => n.binding ? n.binding.path : "", convertTo: (n, e, t) => { if (t && t.length > 0) { const o = t[0]; n.binding || (n.binding = {}), n.binding.type = "Form", n.binding.path = o.bindingField, n.binding.field = o.id, n.binding.fullPath = o.path, n.path = o.bindingPath; } } }, Br = { convertTo: (n, e, t, o) => { n.pagination || (n.pagination = {}), n.pagination[e] = t; }, convertFrom: (n, e, t) => n.pagination ? n.pagination[e] : n[e] }, kr = { convertTo: (n, e, t, o) => { n.rowNumber || (n.rowNumber = {}), n.rowNumber[e] = t; }, convertFrom: (n, e, t) => n.rowNumber ? n.rowNumber[e] : n[e] }, Ir = { convertTo: (n, e, t, o) => { n.selection || (n.selection = {}), n.selection[e] = t; }, convertFrom: (n, e, t) => n.selection ? n.selection[e] : n[e] }, Vr = { convertFrom: (n, e, t) => n[e] && n[e].length ? `共 ${n[e].length} 项` : "" }, Or = { convertFrom: (n, e) => n[e] || "", convertTo: (n, e, t) => { n[e] = t; } }, Pr = { convertTo: (n, e, t, o) => { n.size || (n.size = {}), n.size[e] = t; }, convertFrom: (n, e, t) => n.size ? n.size[e] : n[e] }, Nr = { convertFrom: (n, e, t) => { var o, i; return (o = n.formatter) != null && o.data && e === "formatterEnumData" && !n.formatterEnumData ? (i = n.formatter) == null ? void 0 : i.data : n.formatterEnumData; } }, Dr = { convertTo: (n, e, t, o) => { n.sort || (n.sort = {}), n.sort[e] = t; }, convertFrom: (n, e, t) => { var o, i; if (e === "mode") return ((o = n.sort) == null ? void 0 : o.mode) || "client"; if (e === "multiSort") return !!((i = n.sort) != null && i.multiSort); } }, Rr = { convertTo: (n, e, t, o) => { n.filter || (n.filter = {}), n.filter[e] = t; }, convertFrom: (n, e, t) => { var o; if (e === "mode") return ((o = n.filter) == null ? void 0 : o.mode) || "client"; } }, jr = { convertTo: (n, e, t, o) => { 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 wn(n, e, t) { const o = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", gr], ["/converter/buttons.converter", yr], ["/converter/property-editor.converter", br], ["/converter/items-count.converter", Vr], ["/converter/type.converter", wr], ["/converter/change-editor.converter", Cr], ["/converter/change-formatter.converter", Sr], ["/converter/column-command.converter", Tr], ["/converter/column-option.converter", Fr], ["/converter/summary.converter", xr], ["/converter/group.converter", Mr], ["/converter/form-group-label.converter", Or], ["/converter/field-selector.converter", Er], ["/converter/pagination.converter", Br], ["/converter/row-number.converter", kr], ["/converter/grid-selection.converter", Ir], ["/converter/size.converter", Pr], ["/converter/change-formatter-enum.converter", Nr], ["/converter/grid-sort.converter", Dr], ["/converter/grid-filter.converter", Rr], ["/converter/row-option.converter", jr] ]), 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 = hr(); function r(f, p) { return () => a.parseValueSchema(f, p); } function c(f, p, x) { return f.includes("visible") && p.visible !== void 0 ? typeof p.visible == "boolean" ? () => !!p.visible : p.visible === void 0 ? !0 : r(p.visible, x) : () => !0; } function s(f, p, x) { return f.includes("readonly") && p.readonly !== void 0 ? typeof p.readonly == "boolean" ? () => !!p.readonly : r(p.readonly, x) : () => !1; } function l(f, p) { const x = f.$converter || p; return typeof x == "string" && x && o.has(x) ? o.get(x) || null : x || null; } function u(f, p, x, B, V, N = "", M = "") { return Object.keys(f).map((S) => { const O = T(1), m = S, y = f[S], C = Object.keys(y), b = y.title, F = y.type, I = i.get(F) || { type: "input-group", enableClear: !1 }, E = y.editor ? Object.assign({}, I, y.editor) : Object.assign({}, I), P = c(C, y, p), G = s(C, y, p); E.readonly = E.readonly === void 0 ? G() : E.readonly; const Q = y.type === "cascade" ? u(y.properties, p, x, B, V, N, M) : [], j = !0; let D = l(y, M); const X = _({ get() { if (O.value) { if (["class", "style"].find((ve) => ve === m) && !D && (D = o.get("/converter/appearance.converter") || null), D && D.convertFrom) return D.convertFrom(x, S, V, N); const ue = x[S]; return Object.prototype.hasOwnProperty.call(y, "defaultValue") && (ue === void 0 || typeof ue == "string" && ue === "") ? y.type === "boolean" ? y.defaultValue : y.defaultValue || "" : ue; } return null; }, set(ue) { O.value += 1, D && D.convertTo ? (D.convertTo(B, S, ue, V, N), D.convertTo(x, S, ue, V, N)) : (B[S] = ue, x[S] = ue); } }), { refreshPanelAfterChanged: q, description: K, isExpand: le, parentPropertyID: de } = y, ee = { propertyID: m, propertyName: b, propertyType: F, propertyValue: X, editor: E, visible: P, readonly: G, cascadeConfig: Q, hideCascadeTitle: j, refreshPanelAfterChanged: q, description: K, isExpand: le, parentPropertyID: de }; return p[m] = ee, ee; }); } function d(f, p, x = {}) { const B = {}, V = n[f]; return V && V.categories ? Object.keys(V.categories).map((M) => { const w = V.categories[M], S = w == null ? void 0 : w.title, O = u(w.properties || {}, B, {}, x, p); return { categoryId: M, categoryName: S, properties: O }; }) : []; } function g(f, p, x, B, V = "") { const N = p.$ref.schema, M = p.$ref.converter, w = x[N], S = w.type, O = t(w), m = {}, y = n[S]; if (y && y.categories) { const C = y.categories[f], b = C == null ? void 0 : C.title; M && Object.keys(C.properties).forEach((E) => { C.properties[E].$converter = M; }); const F = (C == null ? void 0 : C.properties) || {}, I = u(F, m, O, w, B, V); return { categoryId: f, categoryName: b, properties: I }; } return { categoryId: f, categoryName: "", properties: [] }; } function h(f, p, x, B, V) { const N = f.type, M = t(f), w = {}; let S = V || n[N]; if (S && Object.keys(S).length === 0 && x && x.getPropConfig && (S = x.getPropConfig(B)), S && S.categories) { const O = []; return Object.keys(S.categories).map((m) => { const y = S.categories[m]; if (y.$ref) { O.push(g(m, y, f, p, B)); return; } const C = y == null ? void 0 : y.title, b = y == null ? void 0 : y.tabId, F = y == null ? void 0 : y.tabName, I = y == null ? void 0 : y.hide, E = y == null ? void 0 : y.hideTitle, P = u(y.properties || {}, w, M, f, p, B, y.$converter), { setPropertyRelates: G } = y, Q = y == null ? void 0 : y.parentPropertyID; O.push({ categoryId: m, categoryName: C, tabId: b, tabName: F, hide: I, properties: P, hideTitle: E, setPropertyRelates: G, parentPropertyID: Q }); }), O; } return []; } return { getPropertyConfigBySchema: h, getPropertyConfigByType: d, propertyConverterMap: o }; } const Cn = {}, Sn = {}; wn(Cn, Sn, pr); const Tn = {}, Fn = {}, { getSchemaByType: Gc, resolveSchemaWithDefaultValue: $r, resolveSchemaToProps: _c, mappingSchemaToProps: Wc, setDesignerContext: Yc } = yn(Tn, Fn), xn = {}, Mn = {}; wn(xn, Mn, $r); function st(n, e, t = /* @__PURE__ */ new Map(), o = (r, c, s, l) => c, i = {}, a = (r) => r) { return Xt[e.title] = e, bn[e.title] = o, Cn[e.title] = i, Sn[e.title] = a, Tn[e.title] = e, Fn[e.title] = o, xn[e.title] = i, Mn[e.title] = a, (r = {}, c = !0) => { if (!c) return vr(r, t); const s = mr(r, e, t), l = Object.keys(n).reduce((u, d) => (u[d] = n[d].default, u), {}); return Object.assign(l, s); }; } function Jt(n, e) { return { customClass: e.class, customStyle: e.style }; } const En = /* @__PURE__ */ new Map([ ["appearance", Jt] ]), Lr = "https://json-schema.org/draft/2020-12/schema", Ar = "https://farris-design.gitee.io/component.schema.json", Ur = "component", zr = "A Farris Visual Component", qr = "object", Hr = { id: { description: "The unique identifier for a component", type: "string" }, type: { description: "The type string of component", type: "string", default: "component" }, componentType: { description: "The type string of component", type: "string" }, viewModel: { description: "The viewModel string of component", type: "string" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, visible: { description: "", type: "boolean", default: !0 }, onInit: { description: "初始化事件", type: "string", default: "" }, onAfterViewInit: { description: "视图初始化后事件", type: "string", default: "" } }, Gr = [ "id", "type", "contents" ], _r = { onInit: "初始化事件", onAfterViewInit: "视图初始化后事件" }, Wr = { $schema: Lr, $id: Ar, title: Ur, description: zr, type: qr, properties: Hr, required: Gr, events: _r }; function Bn(n, e, t) { return e; } const Bt = { id: { type: String }, customClass: { type: String, default: "" }, customStyle: { type: String, default: "" }, componentType: { type: String, default: "" }, formColumns: { type: Number, default: 4 }, code: { type: String, default: "" } }, un = st(Bt, Wr, En, Bn), Xc = Object.assign({}, Bt, { componentId: { type: String, default: "" } }), qt = /* @__PURE__ */ Fe({ name: "FComponent", props: Bt, emits: ["init", "afterViewInit"], setup(n, e) { const t = T(); return Tt(() => { e.emit("init", n.id); }), _e(() => { t.value && n.code && t.value.setAttribute("scope-" + n.code.toLowerCase(), ""), e.emit("afterViewInit", n.id); }), () => v("div", { ref: t, class: n.id + " " + n.customClass, style: n.customStyle }, [e.slots.default && e.slots.default()]); } }); function kn(n, e, t) { var b; const o = t && t.getStyles && t.getStyles() || "", i = t && t.getDesignerClass && t.getDesignerClass() || "", a = T(); let r; function c() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanMoveComponent ? t.checkCanMoveComponent() : !0; } function s() { return !1; } function l() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanDeleteComponent ? t.checkCanDeleteComponent() : !0; } function u() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !0 : t && t.hideNestedPaddingInDesginerView ? t.hideNestedPaddingInDesginerView() : !1; } function d(F) { if (!F || !F.value) return null; if (F.value.schema && F.value.schema.type === "component") return F.value; const I = T(F == null ? void 0 : F.value.parent), E = d(I); return E || null; } function g(F = e) { var G; if (t != null && t.getDraggableDesignItemElement) return t.getDraggableDesignItemElement(F); const { componentInstance: I, designerItemElementRef: E } = F; if (!I || !I.value) return null; const { getCustomButtons: P } = I.value; return I.value.canMove || P && ((G = P()) != null && G.length) ? E : g(F.parent); } function h(F) { return !!t && t.canAccepts(F); } function f() { 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 x(F, I) { var E; !F || !I || (t != null && t.onAcceptMovedChildElement && t.onAcceptMovedChildElement(F, I), (E = e == null ? void 0 : e.setupContext) == null || E.emit("dragEnd")); } function B(F, I) { const { componentType: E } = F; let P = oo(E, F, I); t && t.onResolveNewComponentSchema && (P = t.onResolveNewComponentSchema(F, P)); const G = E.toLowerCase().replace(/-/g, "_"); return P && !P.id && P.type === E && (P.id = `${G}_${Math.random().toString().slice(2, 6)}`), P; } function V(F) { F && t != null && t.onChildElementMovedOut && t.onChildElementMovedOut(F); } function N(...F) { if (t && t.getPropsConfig) return t.getPropsConfig(...F); } function M(F) { if (!F) return; const I = e == null ? void 0 : e.schema, { formSchemaUtils: E } = F; if (I && E.getExpressions().length) { const P = E.getExpressions().findIndex((G) => G.target === I.id); P > -1 && E.getExpressions().splice(P, 1); } } function w(F) { if (!F || !(e != null && e.schema)) return; const I = e.schema, { formSchemaUtils: E } = F; E.removeCommunicationInComponent(I); } function S(F) { t && t.onRemoveComponent && t.onRemoveComponent(), M(F), w(F), e != null && e.schema.contents && e.schema.contents.map((I) => { let E = I.id; I.type === "component-ref" && (E = I.component); const P = n.value.querySelectorAll(`#${E}-design-item`); P != null && P.length && Array.from(P).map((G) => { var Q; (Q = G == null ? void 0 : G.componentInstance) != null && Q.value.onRemoveComponent && G.componentInstance.value.onRemoveComponent(F); }); }); } function O() { if (t && t.getCustomButtons) return t.getCustomButtons(); } function m(F) { var E, P; if (!((E = e == null ? void 0 : e.schema) != null && E.id)) return; if (!r && F && (r = F.formSchemaUtils), t != null && t.setComponentBasicInfoMap) { t.setComponentBasicInfoMap(); return; } let I = ""; if (t != null && t.getComponentTitle) I = t.getComponentTitle(); else { const { text: G, title: Q, label: j, mainTitle: D, name: X, type: q } = e.schema; I = G || Q || j || D || X || ((P = $[q]) == null ? void 0 : P.name); } I && r.getControlBasicInfoMap().set(e.schema.id, { componentTitle: I, parentPathName: I }); } function y(F) { var G; const { changeObject: I } = F, { propertyID: E, propertyValue: P } = I; if (["text", "title", "label", "name", "mainTitle"].includes((G = F == null ? void 0 : F.changeObject) == null ? void 0 : G.propertyID) && E && P && (m(), r)) { const Q = r.getControlBasicInfoMap(), j = Q.keys().toArray().filter((D) => { var X, q; return ((X = Q.get(D)) == null ? void 0 : X.reliedComponentId) === ((q = e == null ? void 0 : e.schema) == null ? void 0 : q.id); }); j != null && j.length && j.forEach((D) => { const X = Q.get(D).parentPathName.split(" > "); X[0] = P, Q.get(D).parentPathName = X.join(" > "); }); } } function C(F) { if (y(F), t && t.onPropertyChanged) return t.onPropertyChanged(F); } return a.value = { canMove: c(), canSelectParent: s(), canDelete: l(), canNested: !u(), contents: e == null ? void 0 : e.schema.contents, elementRef: n, parent: (b = e == null ? void 0 : e.parent) == null ? void 0 : b.componentInstance, schema: e == null ? void 0 : e.schema, styles: o, designerClass: i, canAccepts: h, getBelongedComponentInstance: d, getDraggableDesignItemElement: g, getDraggingDisplayText: f, getPropConfig: N, getDragScopeElement: p, onAcceptMovedChildElement: x, onChildElementMovedOut: V, addNewChildComponentSchema: B, triggerBelongedComponentToMoveWhenMoved: !!t && t.triggerBelongedComponentToMoveWhenMoved || T(!1), triggerBelongedComponentToDeleteWhenDeleted: !!t && t.triggerBelongedComponentToDeleteWhenDeleted || T(!1), onRemoveComponent: S, getCustomButtons: O, onPropertyChanged: C, setComponentBasicInfoMap: m, updateContextSchema: e == null ? void 0 : e.updateContextSchema }, a; } class Yr { getTemplateRule(e, t) { const o = t == null ? void 0 : t.formSchemaUtils, i = o == null ? void 0 : o.getFormTemplateRule(), a = { canAccept: !0, canDelete: !0, canMove: !0 }; if (!i) return a; const r = this.getComponentContext(e), { componentClassList: c } = r; return c.forEach((s) => { if (!s || !i[s]) return; const { canMove: l, canDelete: u, canAccept: d } = i[s]; a.canMove = a.canMove && this.resolveRuleValue(l, r), a.canDelete = a.canDelete && this.resolveRuleValue(u, r), a.canAccept = a.canAccept && this.resolveRuleValue(d, r); }), a; } resolveRuleValue(e, t) { return typeof e == "boolean" ? e : this.parseRuleValueSchema(e, t); } parseRuleValueSchema(e, t) { const o = e.invalidContext || []; let i = !0; for (const a of o) { const { firstLevelChild: r, secondLevelChild: c, parent: s, ...l } = a; if (l && t.component) { let u = !0; for (const d of Object.keys(l)) if (l[d] !== t.component[d]) { u = !1; break; } if (!u) { i = !1; continue; } } if (a.firstLevelChild) { if (a.firstLevelChild.class) { const { firstLevelChildClassList: u } = t; if (u && !u.includes(a.firstLevelChild.class)) { i = !1; continue; } } if (a.firstLevelChild.type) { const { firstLevelChildSchema: u } = t; if (!u || u.type !== a.firstLevelChild.type) { i = !1; continue; } } } if (a.secondLevelChild) { if (a.secondLevelChild.class) { const { secondLevelChildClassList: u } = t; if (u && !u.includes(a.secondLevelChild.class)) { i = !1; continue; } } if (a.secondLevelChild.type) { const { secondLevelChildSchema: u } = t; if (!u || u.type !== a.secondLevelChild.type) { i = !1; continue; } } } if (a.parent) { if (a.parent.class) { const { parentClassList: u } = t; if (u && !u.includes(a.parent.class)) { i = !1; continue; } } if (a.parent.type) { const { parentSchema: u } = t; if (u && u.type !== a.parent.type) { i = !1; continue; } } } i = !0; break; } return !i; } getComponentContext(e) { var p, x, B, V; const t = e.schema, o = t.appearance && t.appearance.class || "", i = o.split(" ") || [], a = t.contents || [], r = a.length ? a[0] : null, c = r && r.appearance ? r.appearance.class : "", s = c ? c.split(" ") : [], l = (p = r == null ? void 0 : r.contents) != null && p.length ? r == null ? void 0 : r.contents[0] : null, u = l && l.appearance ? l.appearance.class : "", d = u ? u.split(" ") : [], g = t.type === "component" ? (B = (x = e.parent) == null ? void 0 : x.parent) == null ? void 0 : B.schema : (V = e.parent) == null ? void 0 : V.schema, h = g && g.appearance && g.appearance.class || "", f = h ? h.split(" ") : []; return { componentClass: o, componentClassList: i, childContents: a, firstLevelChildSchema: r, firstLevelChildClass: c, firstLevelChildClassList: s, secondLevelChildSchema: l, secondLevelChildClass: u, secondLevelChildClassList: d, parentSchema: g, parentClass: h, parentClassList: f, component: t }; } } const Xr = T(0); function In() { Xr.value++; } const Vn = T(0); function Jr(n) { const { formSchemaUtils: e, formStateMachineUtils: t } = n; function o(s, l = "") { return { path: l + s.code, field: s.id, fullPath: s.code }; } function i(s, l = "") { return e.getViewModelById(s).states.map((d) => o(d, l)); } function a(s) { const l = e.getRootViewModelId(), u = i(s); if (s === l) return u; const d = i(l, "root-component."); return [...u, ...d]; } function r(s) { return s.binding && s.binding.path || s.id || ""; } function c() { return t && t.getRenderStates() || []; } return { getVariables: a, getControlName: r, getStateMachines: c }; } class Qr { constructor(e) { oe(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'" } ]); oe(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); oe(this, "getExpressionConverter", (e, t) => ({ convertFrom: (o, i, a, r) => { const c = a.getExpressionRuleValue(e, t || i); return c && c.value || ""; }, convertTo: (o, i, a, r, c) => { var s; if (i === "dataPicking" && (a != null && a.target)) { const l = `${a.target}_dataPicking`; ((s = a.rules) == null ? void 0 : s.some( (d) => d.id === l && d.value )) ? o.dictPickingExpressionId = l : delete o.dictPickingExpressionId; } r.updateExpression(a); } })); this.formSchemaService = e; } getExpressionRule(e, t) { const o = this.formSchemaService.getExpressions(); if (!o) return ""; const i = o.find((r) => r.target === e); if (!i) return ""; const a = i.rules.find((r) => r.type === t); return a || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: e } = this.formSchemaService.getFormSchema(); if (!e.viewmodels || e.viewmodels.length === 0) return []; const t = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(t); if (!o || !o.states || o.states.length === 0) return []; const i = []; return o.states.forEach((a) => { i.push({ key: a.code, name: a.name, description: a.name, category: a.category }); }), i; } createTreeNode(e, t, o = "label") { return { id: e.id, name: e.name, bindingPath: e[o], parents: t, type: "field" }; } buildEntityFieldsTreeData(e = null, t) { const o = []; return e == null || e.forEach((i) => { var c; const a = this.createTreeNode(i, t); let r = []; (c = i.type) != null && c.fields && (r = this.buildEntityFieldsTreeData(i.type.fields, [...t, i.label])), o.push({ data: a, children: r, expanded: !0 }); }), o; } buildChildEntityTreeData(e = null, t) { const o = []; return e == null || e.forEach((i) => { var s, l; const a = this.createTreeNode(i, t); a.type = "entity"; const r = this.buildEntityFieldsTreeData((s = i.type) == null ? void 0 : s.fields, [...t, i.label]), c = this.buildChildEntityTreeData((l = i.type) == null ? void 0 : l.entities, [...t, i.label]); c != null && c.length && (r == null || r.push(...c)), o.push({ data: a, children: r || [], // 空值回退 expanded: !0 }); }), o; } getEntitiesTreeData() { const e = this.formSchemaService.getSchemaEntities(); if (!(e != null && e.length)) return []; const t = e[0]; if (!(t != null && t.type)) return []; const o = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), i = this.buildChildEntityTreeData(t.type.entities, [t.code]); return i != null && i.length && (o == null || o.push(...i)), { entityCode: t.code, fields: [{ data: this.createTreeNode(t, [], "code"), children: o || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(e, t, o) { const i = o === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, t), r = this.getEntitiesAndVariables(), c = { message: ["validate", "required", "dataPicking"].includes(t) && a ? a.message : "", ...r }; return a.messageType != null && (c.messageType = a.messageType), c; } buildRule(e, t, o, i) { const { expression: a, message: r, messageType: c } = t, s = { id: `${e}_${o}`, type: o, value: a }; return (o === "validate" || o === "dataPicking" || o === "required") && (s.message = r), o === "dataPicking" && (s.messageType = c), o === "validate" && i && (s.elementId = i), s; } getExpressionData() { const { expressions: e } = this.formSchemaService.getFormSchema().module; return e || []; } updateExpression(e, t, o, i) { const a = t === "Field" ? e.binding.field : e.id, r = this.buildRule(a, o, i, e.type === "form-group" ? e.id : ""); let s = this.getExpressionData().find((u) => u.targetType === t && u.target === a); const l = (u) => u.value.trim() === ""; if (s) { const u = s.rules.find((d) => d.id === r.id); if (u) l(r) ? s.rules = s.rules.filter((d) => d.id !== r.id) : (Object.assign(u, r), i === "validate" && e.type === "form-group" && (u.elementId = e.id)); else { if (l(r)) return null; s.rules = s.rules || [], s.rules.push(r); } } else { if (l(r)) return null; s = { target: `${a}`, rules: [r], targetType: t }; } return s; } getExpressionEditorOptions(e, t, o, i) { return o.reduce((a, r) => { var s, l; const c = t === "Field" ? (s = e == null ? void 0 : e.binding) == null ? void 0 : s.field : e.id; return a[r] = { hide: t === "Field" ? !!((l = e == null ? void 0 : e.binding) != null && l.field) : !1, description: "", title: this.expressionNames[r], type: "string", $converter: this.getExpressionConverter(c), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[r]}编辑器`, showMessage: r === "validate" || r === "dataPicking" || r === "required", showMessageType: r === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(e, r, t), onSubmitModal: (u) => { const d = this.updateExpression(e, t, u, r); if (i) { const g = this.buildRule(c, u, r); i(g); } return d; } } }, a; }, {}); } getExpressionInfo(e, t, o) { const i = t === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, o), r = { value: a && a.value, targetId: i, targetType: t, expressionType: o }; return a && a.message && (r.message = a.message), r; } getExpressionConfig(e, t, o = ["compute", "dependency", "validate"], i) { return { description: "表达式", title: "表达式", hide: !e.binding, properties: { ...this.getExpressionEditorOptions(e, t, o, i) } }; } getExpressionOptions(e, t, o) { const i = this.getExpressionInfo(e, t, o); return { dialogTitle: `${this.expressionNames[o]}编辑器`, singleExpand: !1, showMessage: o === "required", beforeOpen: () => this.onBeforeOpenExpression(e, o, t), expressionInfo: i }; } } class Zr { constructor(e, t) { oe(this, "componentId"); oe(this, "viewModelId"); oe(this, "eventsEditorUtils"); oe(this, "formSchemaUtils"); oe(this, "formMetadataConverter"); oe(this, "designViewModelUtils"); oe(this, "designViewModelField"); oe(this, "controlCreatorUtils"); oe(this, "designerHostService"); oe(this, "designerContext"); oe(this, "schemaService", null); oe(this, "metadataService", null); oe(this, "propertyConfig", { type: "object", categories: {} }); var o; this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.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 o; 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 = (o = this.designViewModelField) == null ? void 0 : o.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: $[e.type] && $[e.type].name }] } } } }; } getAppearanceConfig(e = null, t = {}, o) { 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 r in t) a[r] = Object.assign(a[r] || {}, t[r]); return { ...i, properties: { ...a }, setPropertyRelates(r, c) { if (r) { switch (r && r.propertyID) { case "class": case "style": { Vn.value++; break; } } o && o(r, e, c); } } }; } getPropertyEditorParams(e, t = [], o = "visible", i = {}, a = {}) { const { getVariables: r, getControlName: c, getStateMachines: s } = Jr(this.designerHostService), l = this.getRealTargetType(e), u = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], d = { type: "property-editor", propertyTypes: u }; return u.map((g) => { switch (g) { case "Const": Object.assign(d, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, i);