UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,421 lines 106 kB
var Ke = Object.defineProperty; var et = (e, t, n) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var be = (e, t, n) => et(e, typeof t != "symbol" ? t + "" : t, n); import { dynamicFormGroupProps as Ue, FDynamicFormLabel as tt, dynamicFormInputProps as nt, FDynamicFormGroup as ot, FResponseForm as rt, FDynamicFormInput as it } from "../../components/dynamic-form/index.esm.js"; import { schemaMap as at, resolveAppearance as lt, createPropsResolver as he, propertyConfigSchemaMapForDesigner as st, createFormGroupEditorResolver as ct } from "../../components/dynamic-resolver/index.esm.js"; import { defineComponent as pe, ref as U, inject as re, onMounted as fe, computed as ne, withDirectives as Ie, createVNode as V, createTextVNode as te, resolveDirective as Pe, watch as Fe, reactive as De, Fragment as ut, mergeProps as Se } from "vue"; import { DgControl as d, refreshCanvas as dt, UseTemplateDragAndDropRules as pt, useDragulaCommonRule as mt, useDesignerComponent as we } from "../../components/designer-canvas/index.esm.js"; import { useGuid as Re, FormSchemaEntityField$Type as $e, FormSchemaEntityFieldTypeName as Le, areaResponseDirective as ft, getCustomClass as Be, useThirdComponent as qe, useTextBoxDesign as yt } from "../../components/common/index.esm.js"; import { BaseControlProperty as gt, FormBindingType as de, InputBaseProperty as bt } from "../../components/property-panel/index.esm.js"; import { useResponseLayoutEditorSetting as vt } from "../response-layout-editor/index.esm.js"; import { createPropsResolver as Ge } from "../../components/designer/index.esm.js"; import { cloneDeep as Ve, mergeWith as ht, merge as Ct, isPlainObject as Oe } from "lodash-es"; import { loadRegister as Ft, useComponentManager as Tt, useBindingData as wt, useEntityState as kt, useDynamicViewUtils as It, componentMap as ke, resolverMap as Pt, componentPropsConverter as Vt } from "../../components/dynamic-view/index.esm.js"; import { LocaleService as xt } from "../../components/locale/index.esm.js"; import Mt from "../../components/section/index.esm.js"; import "../../components/accordion/index.esm.js"; import "../../components/avatar/index.esm.js"; import "../button-edit/index.esm.js"; import "../../components/button-group/index.esm.js"; import "../../components/calendar/index.esm.js"; import "../capsule/index.esm.js"; import "../checkbox/index.esm.js"; import "../checkbox-group/index.esm.js"; import "../../components/color-picker/index.esm.js"; import Ce from "../../components/combo-list/index.esm.js"; import "../../components/content-container/index.esm.js"; import "../data-grid/index.esm.js"; import "../date-picker/index.esm.js"; import "../../components/dropdown/index.esm.js"; import "../dynamic-form/index.esm.js"; import "../../components/external-container/index.esm.js"; import "../../components/filter-bar/index.esm.js"; import "../../components/image-cropper/index.esm.js"; import "../input-group/index.esm.js"; import "../../components/layout/index.esm.js"; import "../../components/list-nav/index.esm.js"; import "../list-view/index.esm.js"; import "../../components/lookup/index.esm.js"; import "../../components/language-textbox/index.esm.js"; import "../../components/nav/index.esm.js"; import "../number-spinner/index.esm.js"; import "../../components/number-range/index.esm.js"; import "../../components/order/index.esm.js"; import "../../components/page-header/index.esm.js"; import "../../components/page-footer/index.esm.js"; import "../../components/pagination/index.esm.js"; import "../../components/progress/index.esm.js"; import "../../components/query-solution/index.esm.js"; import "../radio-group/index.esm.js"; import "../rate/index.esm.js"; import "../response-toolbar/index.esm.js"; import "../../components/response-layout/index.esm.js"; import "../../components/search-box/index.esm.js"; import "../section/index.esm.js"; import "../../components/smoke-detector/index.esm.js"; import "../../components/splitter/index.esm.js"; import "../../components/step/index.esm.js"; import "../switch/index.esm.js"; import "../tabs/index.esm.js"; import "../tags/index.esm.js"; import "../../components/text/index.esm.js"; import "../time-picker/index.esm.js"; import "../../components/transfer/index.esm.js"; import "../../components/tree-view/index.esm.js"; import "../../components/uploader/index.esm.js"; import "../../components/verify-detail/index.esm.js"; import "../../components/component/index.esm.js"; import "../../components/video/index.esm.js"; import "../textarea/index.esm.js"; import "../tree-grid/index.esm.js"; import "../../components/fieldset/index.esm.js"; import "../drawer/index.esm.js"; import "../../components/html-template/index.esm.js"; import "../../components/image/index.esm.js"; import "../../components/comment/index.esm.js"; import "../../components/combo-tree/index.esm.js"; import "../../components/events-editor/index.esm.js"; import "../../components/field-selector/index.esm.js"; import "../../components/binding-selector/index.esm.js"; import "../../components/mapping-editor/index.esm.js"; import "../../components/schema-selector/index.esm.js"; import "../../components/event-parameter/index.esm.js"; import "../../components/filter-condition-editor/index.esm.js"; import "../../components/sort-condition-editor/index.esm.js"; import "../../components/menu-lookup/index.esm.js"; import "../../components/json-editor/index.esm.js"; import "../../components/property-editor/index.esm.js"; import "../../components/expression-editor/index.esm.js"; import "../../components/code-editor/index.esm.js"; import "../../components/collection-property-editor/index.esm.js"; import "../modal/index.esm.js"; import { FMessageBoxService as Bt } from "../../components/message-box/index.esm.js"; function Et(e, t) { function n(b, l = null) { if (l) return l; const g = e.getComponentById(t); return e.selectNode(g, (r) => r.id === b); } function o(b) { const l = e.getComponentById(b); return !(!l || !l.componentType || !l.componentType.startsWith("form")); } function i(b) { const l = new Set(b); return Array.from(l).length === 1; } function p(b) { const l = n(b.id), g = vt(e), r = []; g.getResonseFormLayoutConfig(l, r, 1); const c = r.map((j) => j.columnInSM), v = r.map((j) => j.columnInMD), u = r.map((j) => j.columnInLG), m = r.map((j) => j.columnInEL), C = i(c) ? c[0] : 0, T = i(v) ? v[0] : 0, w = i(u) ? u[0] : 0, A = i(m) ? m[0] : 0; return { uniqueColClassInSM: C, uniqueColClassInMD: T, uniqueColClassInLG: w, uniqueColClassInEL: A }; } function y(b, l) { let g, r, c, v, u = []; if (b) { const j = b.split(" "), S = j.filter((D) => D.startsWith("col-")); g = S.find((D) => /^col-([1-9]|10|11|12)$/.test(D)), r = S.find((D) => /^col-md-([1-9]|10|11|12)$/.test(D)), c = S.find((D) => /^col-xl-([1-9]|10|11|12)$/.test(D)), v = S.find((D) => /^col-el-([1-9]|10|11|12)$/.test(D)), u = j.filter((D) => !D.startsWith("col-")); } const m = l.uniqueColClassInSM ? "col-" + l.uniqueColClassInSM : g, C = l.uniqueColClassInMD ? "col-md-" + l.uniqueColClassInMD : r, T = l.uniqueColClassInLG ? "col-xl-" + l.uniqueColClassInLG : c, w = l.uniqueColClassInEL ? "col-el-" + l.uniqueColClassInEL : v; return [m, C, T, w].concat(u).join(" "); } function F(b, l, g) { b = n(g, b), b.contents.forEach((r) => { if (r.type === d["dynamic-form"].type) return; if (r.type === d.fieldset.type) { F(r, l, r.id); return; } r.appearance || (r.appearance = {}); const c = r.appearance.class; r.appearance.class = y(c, l); }); } return { checkIsInFormComponent: o, assembleUnifiedLayoutContext: p, changeFormControlsByUnifiedLayoutConfig: F, changeControlClassInByColumn: y }; } class ze extends gt { constructor(t, n) { super(t, n); } getPropertyConfig(t, n) { const o = this; this.propertyConfig.categories.basic = this.getBasicPropConfig(t); const { checkIsInFormComponent: i, assembleUnifiedLayoutContext: p, changeFormControlsByUnifiedLayoutConfig: y, changeControlClassInByColumn: F } = Et(this.formSchemaUtils, this.componentId), b = this.getAppearanceConfig(t), l = i(this.componentId); b.properties.adaptForLanguage = { title: "控件布局响应国际化", description: "启用国际化后:简体中文、繁体中文环境下控件标签与输入框在一行展示,其他语言环境下控件标签与输入框上下排列。", visible: t.formType === "dynamic" || l, type: "boolean" }, b.properties.labelAutoOverflow = { title: "控件标签换行", description: "控件标签字数超长时,换行显示。控件标签与输入框在一行展示时,此属性有效。", visible: t.formType === "dynamic" || l, type: "boolean" }, b.properties.formType = { title: "控件来源", description: "", type: "enum", editor: { readonly: t.type === "dynamic-form", type: "combo-list", textField: "name", valueField: "value", data: [ { value: "static", name: "静态" }, { value: "dynamic", name: "动态" }, { value: "mixed", name: "混合" } ] }, refreshPanelAfterChanged: !0 }, b.properties.unifiedLayout = { title: "统一布局配置", description: "统一配置卡片区域内所有控件的宽度,只支持标准模式", visible: t.formType === "dynamic" || l, refreshPanelAfterChanged: !0, editor: { type: "response-form-layout-setting", initialState: p(t) } }, b.setPropertyRelates = function(r, c) { if (r) switch (r && r.propertyID) { case "unifiedLayout": { t.formType === "dynamic" ? t.layout = F("", r.propertyValue) : (y(null, r.propertyValue, t.id), o.updateElementByParentContainer(t.id, n)); break; } case "labelAutoOverflow": { o.setLabelAutoOverflow(t, r.propertyValue), dt(); break; } } }, this.propertyConfig.categories.appearance = b; let g = {}; if (t.formType && ["dynamic", "mixed"].indexOf(t.formType) > -1) { const r = this.getPropertyEditorParams(t, ["Variable", "Custom"], "fields", {}, { newVariablePrefix: "", newVariableType: "Array" }), c = this.getPropertyEditorParams(t, ["Variable", "Custom"], "formData", {}, { newVariablePrefix: "", newVariableType: "Object" }); g = { fields: { title: "动态控件列表", type: "string", description: "动态控件列表", editor: r }, formData: { title: "动态控件列表初始值", type: "string", description: "动态控件列表初始值", editor: c } }; } return this.propertyConfig.categories.behavior = this.getBehaviorConfig(t, "", g, (r, c) => { switch (r.propertyID) { case "fields": case "formData": o.afterMutilEditorChanged(t, r); break; } }), this.propertyConfig; } setLabelAutoOverflow(t, n, o) { if (!o) { const i = this.formSchemaUtils.getComponentById(this.componentId); o = this.formSchemaUtils.selectNode(i, (p) => p.id === t.id); } o && o.contents && o.contents.length && o.contents.forEach((i) => { if (i.type === d.fieldset.type) { this.setLabelAutoOverflow(null, n, i); return; } i.appearance || (i.appearance = { class: "" }), i.appearance.class || (i.appearance.class = ""), n ? i.appearance.class.includes("farris-group-multi-label") || (i.appearance.class = i.appearance.class + " farris-group-multi-label") : i.appearance.class = i.appearance.class.replace("farris-group-multi-label", "").trim(); }); } } function Dt(e, t) { const n = e.schema, o = new pt(), { canMove: i, canAccept: p, canDelete: y } = o.getTemplateRule(e, t); function F(s, f) { const { sourceElement: h } = s, { componentInstance: P } = h, I = t == null ? void 0 : t.formSchemaUtils; if (!I) return !0; const $ = I.getComponentById(P.value.belongedComponentId), O = I.getViewModelById($.viewModel), x = I.getComponentById(e.componentInstance.value.belongedComponentId), k = I.getViewModelById(x.viewModel); return f ? O != null && O.id && (k != null && k.id) && O.id !== k.id ? O.bindTo === k.bindTo : !0 : (O == null ? void 0 : O.id) === (k == null ? void 0 : k.id); } function b(s) { const { bindingTargetId: f } = s; if (!t) return; const { formSchemaUtils: h, schemaService: P } = t, I = h.getComponentById(e.componentInstance.value.belongedComponentId), $ = P.getFieldByIDAndVMID(f, I.viewModel); return !!($ != null && $.schemaField); } function l(s) { const f = o.getComponentContext(e); if (f && f.componentClassList && f.componentClassList.includes("f-form-layout") && f.componentClassList.includes("farris-form")) { if (s.sourceType === "control" && (s.componentCategory === "input" || s.componentType && ["fieldset", "dynamic-form"].indexOf(s.componentType) > -1)) return !0; if (s.sourceType === "move") { if (s.componentType === "form-group") return F(s, !0); if (s.componentType === "fieldset") return F(s, !1); if (s.componentType === "dynamic-form") return !0; } return s.sourceType === "field" && s.componentCategory === "input" ? b(s) : !1; } return !0; } function g(s) { return !(!mt().basalDragulaRuleForContainer(s, t) || !p || !l(s)); } function r(s) { var k; const f = s.componentInstance, h = f.value.schema, P = t == null ? void 0 : t.formSchemaUtils, I = t == null ? void 0 : t.designViewModelUtils, $ = P.getViewModelIdByComponentId(f.value.belongedComponentId), O = I.getDgViewModel($), x = f.value.parent; if (x && d.fieldset && ((k = x.schema) == null ? void 0 : k.type) === d.fieldset.type && O) { const N = { groupId: null, groupName: null }; switch (h.binding.type) { case de.Form: { O.changeField(h.binding.field, N); break; } case de.Variable: { P.modifyViewModelFieldById($, h.binding.field, N, !0); break; } } } } function c(s, f, h) { const P = f.fields.find((k) => k.id === s), I = t == null ? void 0 : t.designViewModelUtils, $ = I.getDgViewModel(f.id), O = $.fields.find((k) => k.id === s); $.removeField([s]); const x = I.getDgViewModel(h); x.addField(O), P.fieldSchema && x.changeField(O.id, P.fieldSchema); } function v(s, f, h, P = []) { const I = f.id, $ = s.binding.field, O = f.fields.findIndex((k) => k.id === $); if (O > -1 && (h.fields.push(f.fields[O]), f.fields.splice(O, 1)), I === "root-viewmodel" && h.id !== "root-viewmodel") { s.binding.path && !s.binding.path.includes("root-component.") && (s.binding.path = "root-component." + s.binding.path); return; } if (h.id === "root-viewmodel" && I !== "root-viewmodel" && s.binding.path && s.binding.path.includes("root-component.")) { s.binding.path = s.binding.path.replace("root-component.", ""); return; } const x = f.states.find((k) => k.id === $); x && (h.states = h.states ? h.states : [], h.states.findIndex((k) => k.id === x.id) < 0 && (h.states.push(x), P.push(x.id))); } function u(s, f, h, P = []) { var O; if (!s) return; const I = f.id === "root-viewmodel" && h.id !== "root-viewmodel", $ = h.id === "root-viewmodel" && f.id !== "root-viewmodel"; Object.keys(s).forEach((x) => { if (x === "binding") return; const k = s[x]; if (k && typeof k == "object" && k.type === de.Variable && k.field) { if (I) { k.path && !k.path.includes("root-component.") && (k.path = "root-component." + k.path); return; } if ($ && k.path && k.path.includes("root-component.")) { k.path = k.path.replace("root-component.", ""); return; } const N = f.states.find((q) => q.id === k.field); if (N) { P.push(N.id), h.states = h.states ? h.states : []; const q = h.states.find((z) => z.code === N.code); if (q) k.field = q.id; else { const z = Object.assign({}, { newId: Re().guid() }, N); h.states.push(z), k.field = z.newId; } } } }), (O = h.states) != null && O.length && h.states.map((x) => { x.newId && (x.id = x.newId, delete x.newId); }); } function m(s, f, h) { if (s && (f(s, h), s.contents)) for (const P of s.contents) m(P, f, h); } function C(s = [], f) { if (!s.length) return; const h = t == null ? void 0 : t.formSchemaUtils, P = h.getComponentByViewModelId(f), I = [], $ = (x, k) => { x && (Object.keys(x).forEach((N) => { const q = x[N]; q && typeof q == "object" && q.type === de.Variable && s.includes(q.field) && !k.includes(q.field) && k.push(q.field); }), x.editor && $(x.editor, k)); }; m(P, $, I); const O = h.getViewModelById(f); s.forEach((x) => { I.includes(x) || (O.states = O.states.filter((k) => k.id !== x)); }); } function T(s) { const f = Re().guid(), h = Object.assign({}, s, { id: f, code: s.code + f.slice(0, 4), name: s.name + f.slice(0, 4) }), $ = (t == null ? void 0 : t.formSchemaUtils).getCommands().find((O) => O.id === s.cmpId); return $ && $.refedHandlers.push({ host: f, handler: s.handlerName }), h; } function w(s, f, h) { var N, q, z; const P = {}, I = s.type === "form-group" && s.editor ? s.editor.type : s.type, $ = (N = at[I]) == null ? void 0 : N.events; if (!$) return; Object.keys(s).forEach((X) => { const ee = Object.keys($).find((H) => H === X); if (ee && s[ee]) { const H = f.commands.find((a) => a.code === s[ee]); if (H) { let a = P[H.code]; a || (a = T(H), P[H.code] = a, h.commands.push(a)), s[ee] = a.code; } } }); const x = (t == null ? void 0 : t.designViewModelUtils).getDgViewModel(h.id), k = ["valueChanging", "valueChanged"]; if (((q = s.binding) == null ? void 0 : q.type) === de.Form) { const X = (z = h.fields) == null ? void 0 : z.find((ee) => ee.id === s.binding.field); X && k.forEach((ee) => { if (X[ee]) { const H = f.commands.find((a) => a.code === X[ee]); if (!H) return; if (P[H.code]) x.changeField(X.id, { [ee]: P[H.code].code }); else { const a = T(H); P[H.code] = a, h.commands.push(a), x.changeField(X.id, { [ee]: a.code }); } } }); } } function A(s) { var k, N; const f = t == null ? void 0 : t.formSchemaUtils, h = s.componentInstance, P = h.value.schema, I = f.getViewModelIdByComponentId(h.value.belongedComponentId), $ = f.getViewModelById(I), O = f.getComponentById(e.componentInstance.value.belongedComponentId), x = f.getViewModelById(O.viewModel); if (I !== x.id) { const q = (k = P.binding) == null ? void 0 : k.type, z = (N = P.binding) == null ? void 0 : N.field, X = []; switch (q) { case de.Form: { c(z, $, x.id); break; } case de.Variable: { v(P, $, x, X); break; } } u(P, $, x, X), u(P.editor, $, x, X), w(P, $, x), I !== "root-viewmodel" && C(X, I); } } function j(s) { var P; if (!s || !s.componentInstance) return; const h = s.componentInstance.value.schema; if (h.type === "dynamic-form") { const I = ((P = h == null ? void 0 : h.appearance) == null ? void 0 : P.class) || ""; I.indexOf("col-12") < 0 && (h.appearance = { ...h.appearance, class: I + " col-12 px-0" }), A(s); return; } !h.binding || !h.binding.field || (r(s), A(s)); } function S() { return n.componentType ? "display:inherit;flex-direction:inherit;margin-bottom:10px" : ""; } function D(s) { let f = ""; switch (s) { case 1: { f = "col-12 col-md-12 col-xl-12 col-el-12"; break; } case 2: { f = "col-12 col-md-6 col-xl-6 col-el-6"; break; } case 3: { f = "col-12 col-md-6 col-xl-4 col-el-4"; break; } case 4: { f = "col-12 col-md-6 col-xl-3 col-el-2"; break; } } return f; } function Y(s, f) { let h = !1; if (e.schema && Object.prototype.hasOwnProperty.call(e.schema, "labelAutoOverflow")) h = e.schema.labelAutoOverflow; else { const P = t == null ? void 0 : t.formSchemaUtils, I = P == null ? void 0 : P.selectNode(f, ($) => $.type === d["response-form"].type); I && (h = I.labelAutoOverflow); } return h && (s += " farris-group-multi-label"), s; } function W(s) { const f = e.componentInstance.value.getBelongedComponentInstance(e.componentInstance); if (f && f.schema && f.schema.componentType) { const { formColumns: h } = f.schema; let P = D(h); P = t == null ? void 0 : t.formSchemaUtils.getControlClassByFormUnifiedLayout(P, f.schema.id, e.schema), P = Y(P, f.schema), s.appearance || (s.appearance = {}), s.appearance.class = P; } } function R(s, f, h, P) { const { bindingSourceContext: I, parentComponentInstance: $ } = s; if (I != null && I.entityFieldNode && $) { const O = t == null ? void 0 : t.designViewModelUtils, k = (t == null ? void 0 : t.formSchemaUtils).getViewModelIdByComponentId($.belongedComponentId), N = O.getDgViewModel(k); N.removeField([I.entityFieldNode.id]), N.addField(I.designViewModelField), f && N.changeField(I.entityFieldNode.id, { editor: { $type: f }, groupId: h, groupName: P }); } } function E(s, f) { var $, O, x; const h = n; if ((h.appearance && h.appearance.class || "").split(" ").includes("f-form-layout") && s.componentCategory === "input") { const { label: k } = s; let N; const q = t == null ? void 0 : t.controlCreatorUtils; return ($ = s.bindingSourceContext) != null && $.entityFieldNode ? N = q.setFormFieldProperty((O = s.bindingSourceContext) == null ? void 0 : O.entityFieldNode, f == null ? void 0 : f.type) : (N = q.createFormGroupWithoutField(f == null ? void 0 : f.type), N.label = k), W(N), R(s, (x = N.editor) == null ? void 0 : x.type), N; } return s.componentType === "dynamic-form" && (f.appearance = { class: "col-12", ...f.appearance }), f; } function J() { return i; } function Q() { return y; } function K() { return !1; } function _(s) { return new ze(s, t).getPropertyConfig(n, e.componentInstance.value); } return { canAccepts: g, checkCanDeleteComponent: Q, checkCanMoveComponent: J, getStyles: S, getPropsConfig: _, hideNestedPaddingInDesginerView: K, onAcceptMovedChildElement: j, onResolveNewComponentSchema: E, moveInputBetweenComponent: A, resolveFormGroupAppearance: W, syncFieldToViewModel: R }; } const Rt = "root-viewmodel"; class $t { constructor(t, n) { be(this, "formSchemaUtils"); be(this, "controlCreatorUtils"); be(this, "designViewModelUtils"); this.resolver = t, this.designerHostService = n, this.formSchemaUtils = this.designerHostService.formSchemaUtils, this.controlCreatorUtils = this.designerHostService.controlCreatorUtils, this.designViewModelUtils = this.designerHostService.designViewModelUtils; } createComponent(t) { const n = this.createComponentRefNode(t), o = this.createComponentNode(t), i = this.createViewModeNode(t), p = this.formSchemaUtils.getFormSchema(); return p.module.viewmodels.push(i), p.module.components.push(o), this.designViewModelUtils.assembleDesignViewModel(), n; } createComponentRefNode(t) { const n = this.resolver.getSchemaByType("component-ref"); return Object.assign(n, { id: `${t.componentId}-component-ref`, component: `${t.componentId}-component` }), n; } createComponentNode(t) { const n = this.resolver.getSchemaByType("component"), o = this.createFormComponentContents(t); return Object.assign(n, { id: `${t.componentId}-component`, viewModel: `${t.componentId}-component-viewmodel`, componentType: t.componentType, appearance: { class: this.getFormComponentClass(t) }, formColumns: t.formColumns, contents: o }), n; } /** * 获取卡片组件层级的class样式 */ getFormComponentClass(t) { var o, i; const { templateId: n } = this.formSchemaUtils.getFormSchema().module; if (n === "double-list-in-tab-template" && ((i = (o = t.parentComponentInstance) == null ? void 0 : o.schema) == null ? void 0 : i.type) === "tab-page") { const p = t.parentComponentInstance.parent && t.parentComponentInstance.parent.schema; if ((p == null ? void 0 : p.type) === "tabs" && (p == null ? void 0 : p.fill) === !0) return "f-struct-wrapper f-utils-fill-flex-column"; } return "f-struct-wrapper"; } createFormComponentContents(t) { var F, b; const n = this.resolver.getSchemaByType("section"); Object.assign(n, { id: t.componentId + "-form-section", appearance: { class: "f-section-form f-section-in-mainsubcard" }, mainTitle: t.componentName }); const o = this.resolver.getSchemaByType("response-form"), i = []; Object.assign(o, { id: t.componentId + "-form", appearance: { class: "f-form-layout farris-form farris-form-controls-inline" }, contents: i, controlsInline: !0 }), n.contents = [o]; const { selectedFields: p } = t; p == null || p.forEach((l) => { if (l.$type === $e.SimpleField) { const g = Ve(l), r = this.resolveControlClassByFormColumns(t), c = this.controlCreatorUtils.setFormFieldProperty(g, "", r); c && i.push(c); } }); const { templateId: y } = this.formSchemaUtils.getFormSchema().module; if (y === "double-list-in-tab-template" && ((b = (F = t.parentComponentInstance) == null ? void 0 : F.schema) == null ? void 0 : b.type) === "tab-page") { const l = t.parentComponentInstance.parent && t.parentComponentInstance.parent.schema; (l == null ? void 0 : l.type) === "tabs" && (l == null ? void 0 : l.fill) === !0 && (n.appearance.class = "f-section-grid f-section-in-main px-0 pt-0", n.fill = !0); } return [n]; } resolveControlClassByFormColumns(t) { let n = ""; switch (t.formColumns) { case 1: { n = "col-12 col-md-12 col-xl-12 col-el-12"; break; } case 2: { n = "col-12 col-md-6 col-xl-6 col-el-6"; break; } case 3: { n = "col-12 col-md-6 col-xl-4 col-el-4"; break; } case 4: { n = "col-12 col-md-6 col-xl-3 col-el-2"; break; } } return n; } /** * 添加viewModel节点 */ createViewModeNode(t) { return { id: `${t.componentId}-component-viewmodel`, code: `${t.componentId}-component-viewmodel`, name: t.componentName, bindTo: t.bindTo, parent: Rt, fields: this.assembleViewModelFields(t), commands: [], states: [], enableValidation: !0 }; } /** * 组装viewModel fields 节点 */ assembleViewModelFields(t) { const n = [], { selectedFields: o } = t; return o == null || o.forEach((i) => { if (i.$type === $e.SimpleField) { let p = "blur"; const y = i.type.name; (y === Le.Enum || y === Le.Boolean) && (p = "change"), n.push({ type: "Form", id: i.id, fieldName: i.bindingField, groupId: null, groupName: null, updateOn: p, fieldSchema: {} }); } }), n; } } function Ee(e, t, n, o) { var p, y, F, b, l, g; const i = n.parentComponentInstance; if (i && o) { const r = (p = i.schema) == null ? void 0 : p.type, v = { componentId: `form-${Math.random().toString(36).slice(2, 6)}`, componentName: ((y = n.bindingSourceContext) == null ? void 0 : y.entityTitle) || ((b = (F = n.bindingSourceContext) == null ? void 0 : F.bindingEntity) == null ? void 0 : b.name) || "标题", componentType: "form", formColumns: r === "splitter-pane" ? 1 : 4, parentContainerId: i.schema.id, parentComponentInstance: i, bindTo: ((l = n.bindingSourceContext) == null ? void 0 : l.bindTo) || "/", selectedFields: (g = n.bindingSourceContext) == null ? void 0 : g.bindingEntityFields }; return new $t(e, o).createComponent(v); } else return t; } function Lt(e, t, n) { return t; } function Ot(e, t, n, o) { return t.formType = "dynamic", t.layout = "col-12 col-md-6 col-xl-3 col-el-2", t; } const ye = /* @__PURE__ */ new Map([ ["appearance", lt] ]), At = /* @__PURE__ */ new Map([]), jt = "https://json-schema.org/draft/2020-12/schema", Nt = "https://farris-design.gitee.io/response-form.schema.json", Ut = "response-form", St = "A Farris Data Collection Component", qt = "object", Gt = { id: { description: "The unique identifier for a form group", type: "string" }, type: { description: "The type string of form group component", type: "string", default: "response-form" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, visible: { description: "", type: "boolean", default: !0 }, labelAutoOverflow: { description: "", type: "boolean", default: !1 }, adaptForLanguage: { description: "", type: "boolean", default: !0 }, layout: { description: "", type: "string", default: "col-12 col-md-6 col-xl-3 col-el-2" }, fields: { description: "", type: "array" }, formData: { description: "", type: "object" }, formType: { description: "", type: "string", default: "static" } }, zt = [ "id", "type", "contents" ], Ze = { $schema: jt, $id: Nt, title: Ut, description: St, type: qt, properties: Gt, required: zt }, Zt = "https://json-schema.org/draft/2020-12/schema", Wt = "https://farris-design.gitee.io/dynamic-form.schema.json", Jt = "dynamic-form", _t = "A Farris Data Collection Component", Xt = "object", Qt = { id: { description: "The unique identifier for a form group", type: "string" }, type: { description: "The type string of form group component", type: "string", default: "dynamic-form" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, visible: { description: "", type: "boolean", default: !0 }, labelAutoOverflow: { description: "", type: "boolean", default: !1 }, adaptForLanguage: { description: "", type: "boolean", default: !0 }, formType: { description: "", type: "string", default: "dynamic" }, layout: { description: "", type: "string", default: "col-12 col-md-6 col-xl-3 col-el-2" }, fields: { description: "", type: "array" }, formData: { description: "", type: "object" }, headerTitleRenderFunction: { description: "", type: "function", default: null }, headerContentRenderFunction: { description: "", type: "function", default: null }, footerRenderFunction: { description: "", type: "function", default: null }, mode: { description: "", type: "string", default: "quick" }, footerStyle: { description: "", type: "string", default: "" }, headerStyle: { description: "", type: "string", default: "" }, toolbar: { description: "", type: "array", default: [] }, moreButtonClass: { description: "", type: "string", default: "btn-link" }, onClick: { description: "", type: "string", default: "" } }, Yt = [ "id", "type", "contents" ], Ht = { onClick: "点击事件", "onUpdate:modelValue": "值变更事件", event: "事件" }, We = { $schema: Zt, $id: Wt, title: Jt, description: _t, type: Xt, properties: Qt, required: Yt, events: Ht }; var ve = /* @__PURE__ */ ((e) => (e.Header = "header", e.Footer = "footer", e))(ve || {}), Te = /* @__PURE__ */ ((e) => (e.QUICK = "quick", e.FULL = "full", e))(Te || {}); const ge = { customClass: { type: String, default: "" }, customStyle: { type: String, defaut: "" }, /** 控制是否可见 */ visible: { type: Boolean, default: !0 }, /** 内部控件布局是否响应国际化 */ adaptForLanguage: { type: Boolean, default: !0 }, /** 绑定动态字段 */ fields: { type: Array, default: [] }, /** 绑定动态字段的值*/ formData: { type: Object, default: null }, /** 为动态字段指定样式*/ layout: { type: String, default: "col-12 col-md-6 col-xl-3 col-el-2" } }, Kt = Object.assign({}, ge, { // 是否渲染form层级 canRenderForm: { type: Boolean, default: !0 }, /** * 回调方法 * @param methodName 是回调方法名称 * @param viewSchema 是当前组件的视图配置 * @param eventParams 是回调方法接收的参数 * @param editorSchema 是当前组件的编辑器配置 */ callback: { type: Function }, /** 设置Section的主标题 */ mainTitle: { type: String, default: "" }, /** 设置是否显示头部区域 */ showHeader: { type: Boolean, default: !1 }, /** 设置头部标题渲染函数 */ headerTitleRenderFunction: { type: Function }, /** 设置头部内容渲染函数 */ headerContentRenderFunction: { type: Function }, /** 设置底部内容渲染函数 */ footerRenderFunction: { type: Function }, /** 显示底部区域 */ showFooter: { type: Boolean, default: !1 }, /** 展开文本 */ expandLabel: { type: String, default: "展开" }, /** 收起文本 */ collapseLabel: { type: String, default: "收起" }, enableAccordion: { type: Boolean, default: !0 }, /** 模式 **/ mode: { type: String, default: Te.QUICK }, /** 工具栏 */ toolbar: { type: [Array, Function], default: [] }, /** 设置头部的样式 */ headerStyle: { type: [String, Function], default: "" }, /** 设置底部样式 */ footerStyle: { type: [String, Function], default: "" }, /** 更多按钮样式 */ moreButtonClass: { type: String, default: "btn-link" } }), en = he(ge, Ze, ye, Ee), tn = he(ge, We, ye, Ee), Je = Object.assign({}, ge, { componentId: { type: String, default: "" }, formType: { type: String, default: "static" } }), nn = Ge(ge, Ze, ye, Ee), on = Ge(ge, We, ye, Ot), xe = /* @__PURE__ */ pe({ name: "FResponseFormDesign", directives: { "area-response": ft }, props: Je, emits: [], setup(e, t) { const n = U(), o = re("design-item-context"), i = re("designer-host-service"), p = Dt(o, i), y = we(n, o, p); fe(() => { n.value.componentInstance = y; }), t.expose(y.value); const F = ne(() => Be({ "drag-container": !0 }, e.customClass)); return () => Ie(V("div", { ref: n, class: F.value, style: e.customClass, "data-dragref": `${o.schema.id}-container`, "data-associate": `${o.schema.id}-component` }, [t.slots.default && t.slots.default(), ["dynamic", "mixed"].indexOf(e.formType) > -1 && V("div", { class: "no-drag w-100 col-12", style: "height: 50px;display: flex;justify-content: center;align-items: center;overflow: hidden;margin-bottom: 0;color: #315585; background-color: #dfedff; border-color: #d2e6ff;" }, [te("��̬����")])]), [[Pe("area-response")]]); } }); function rn(e, t) { function n(y) { const F = e.schema; return new ze(y, t).getPropertyConfig(F, e.componentInstance.value); } function o() { return !1; } function i() { return !0; } function p() { return !0; } return { getPropsConfig: n, canAccepts: o, checkCanDeleteComponent: i, checkCanMoveComponent: p }; } const an = /* @__PURE__ */ pe({ name: "FDynamicFormDesign", props: Je, emits: [], setup(e, t) { const n = U(), o = re("design-item-context"), i = re("designer-host-service"), p = rn(o, i), y = we(n, o, p); fe(() => { n.value.componentInstance = y; }), t.expose(y.value); const F = ne(() => Be({ "drag-container": !0 }, e.customClass)); return () => V("div", { ref: n, class: F.value, style: e.customStyle }, [V("div", { class: "no-drag w-100", style: "height: 50px;display: flex;justify-content: center;align-items: center;overflow: hidden;margin-bottom: 0;color: #315585; background-color: #dfedff; border-color: #d2e6ff;" }, [te("动态表单")])]); } }), ln = /* @__PURE__ */ pe({ name: "FDynamicForm", props: Kt, emits: ["update:modelValue", "event", "click"], setup(e, t) { const n = U(e.fields), o = /* @__PURE__ */ new Map(), i = U(e.callback); Ft(); const p = Tt(), y = U(e.formData || {}), F = wt(y, t); kt(n.value).setup(); const l = /* @__PURE__ */ new Map(), g = U(e.canRenderForm); let r = [], c = [], v = []; const u = e.mode === Te.FULL ? "contents" : "fields", { mergeArray: m, resolveCallbacks: C, resolveEvents: T } = It(), w = ne(() => { const a = xt.getLocale(), M = e.fields && e.fields.length > 0; let B = { "f-form-layout": M, "farris-form": M, "f-dynamic-form": !(e.showHeader || e.showFooter) }; return B = Be(B, e.customClass), e.adaptForLanguage && a && (B["farris-form-controls-inline"] = a !== "en"), B; }); function A() { function a(M, B) { const { id: L } = M || {}, { field: G } = M.binding || {}; return { modelValue: B.getValue(L), "onUpdate:modelValue": (ie) => { B.setValue(L, G || L, ie); } }; } return { resolve: a }; } function j(a) { const M = A(); return F.getValue(a.id) === void 0 && Object.hasOwnProperty.call(a, "modelValue") && F.setValue(a.id, void 0, a.modelValue), M.resolve(a, F); } function S(a) { const M = {}; return a && Object.entries(a).forEach(([B, L]) => { M[B] = () => Array.isArray(L) ? L.map((G) => E(G)) : E(L); }), M; } function D(a) { return a.type ? a.type : a[u] ? "fieldset" : "form-group"; } function Y(a) { const M = D(a), B = a.customClass || ""; return B || (M === "fieldset" ? "col-12 px-0" : r.length === 0 && c.length === 0 || a.id && v.find((L) => L[u] ? L[u].find((G) => G.id === a.id) : L.id === a.id) ? e.layout : "unset-item"); } function W(a) { const M = D(a); let B = {}, L = "", G = {}, ie = {}; if (e.mode === Te.FULL) { G = { ...T(a, t, M) }, ie = { ...C(a, i, M) }; const Z = Vt[M]; B = Z ? Z(a) : {}, L = Y(B); } else { L = Y(a); const { fields: Z, customClass: oe, ...le } = a; B = le; } return { props: { ...{ ...B, customClass: L, ...j(a) }, key: a.id, ref: (Z) => { if (Z && a.id && !p.has(a.id)) { p.register(a.id, Z); const oe = { token: a.id, name: "component:ready", type: D(a), payloads: [U(Z)], schema: a }; t.emit("event", oe); } }, onVnodeUnmounted: (Z) => { if (a.id && p.has(a.id)) { p.remove(a.id); const oe = { token: a.id, name: "component:unmounted", type: D(a), payloads: [Z], schema: a }; t.emit("event", oe); } } }, eventProps: G, callbackProps: ie }; } function R(a, M) { return Array.isArray(a) ? a.map((B) => M(B)) : M(a); } function E(a, M) { var se; const B = D(a), L = ke[B]; if (a.id && o.set(a.id, a), !L) return null; const G = () => a[u] ? a[u].map((Z) => E(Z)) : null, ie = (Z, oe, le) => { let ue; return le && le.length > 0 ? ue = V(Z, { ...oe }, le) : ue = V(Z, { ...oe }, null), ue; }, ce = ((se = l.get(a.id)) == null ? void 0 : se.props) || {}; return a[u] && a[u].length > 0 ? ie(L, ce, [G()]) : a.slots ? ie(L, ce, [...Object.values(S(a.slots))]) : ie(L, ce); } function J(a) { const M = D(a); if (!ke[M]) return; const { props: L, eventProps: G, callbackProps: ie } = W(a), ce = Pt[M], se = ce ? ce.editorResolver : null, { componentEventProps: Z, editorEventProps: oe } = G, { componentCallbackProps: le, editorCallbackProps: ue } = ie; if (Z && Object.keys(Z).length > 0 && Object.assign(L, Z), le && Object.keys(le).length > 0 && Object.assign(L, le), se && oe && Object.keys(oe).length > 0) { const ae = se.resolve(a); Object.assign(ae, oe); } if (se && ue && Object.keys(ue).length > 0) { const ae = se.resolve(a); Object.assign(ae, ue); } if (L && Object.keys(L).length > 0) { const ae = l.get(a.id); ae ? Ct(ae == null ? void 0 : ae.props, L) : l.set(a.id, De({ props: L })); } !a[u] || !Array.isArray(a[u]) || a[u].forEach((ae) => J(ae)); } function Q(a) { const M = D(a); ke[M] && (K(a), !(!a[u] || !Array.isArray(a[u])) && a[u].forEach((L) => Q(L))); } function K(a) { const M = j(a); if (M && Object.keys(M).length > 0) { const B = l.get(a.id); if (!B) l.set(a.id, De({ props: M })); else { const L = { ...B == null ? void 0 : B.props }; Object.keys(M).forEach((G) => { L[G] = M[G]; }), Object.assign(B == null ? void 0 : B.props, L); } } } fe(() => { }), Fe(() => e.formData, (a) => { y.value = a; }), Fe(() => y.value, () => { R(n.value, Q); }, { deep: !0 }); function _(a, M = "") { return M ? a.filter((B) => B.position === M) : a.filter((B) => !B.position || [ve.Header, ve.Footer].indexOf(B.position) < 0); } function s(a) { a && (r = _(a, ve.Header), r.length && R(r, J), c = _(a, ve.Footer), c.length && R(c, J), v = _(a), v.length && R(v, J)); } Fe(() => e.fields, (a) => { o.clear(), p.clear(), y.value = e.formData || {}, l.clear(), n.value = a, s(a); }), s(e.fields); function f(a) { a.$forceUpdate && a.$forceUpdate(); } function h(a) { return F.getValue(a); } function P() { return y.value; } function I(a, M) { F.setValue(a, void 0, M); const B = o.get(a); B && K(B); } function $(a) { var M; return (M = l.get(a)) == null ? void 0 : M.props; } function O(a, M) { const B = l.get(a); ht(B == null ? void 0 : B.props, M, m); } t.expose({ componentManager: p, rerender: f, getProps: $, setProps: O, getControlValue: h, setControlValue: I, getValues: P }); function x(a = []) { return a.length > 0 && R(a, E); } function k(a) { return Ie(V("div", { class: w.value, style: e.customStyle }, [t.slots.default && t.slots.default(), a.length > 0 && R(a, E)]), [[Pe("area-response")]]); } function N() { const a = {}; let M = "f-dynamic-form-section--header-content", B = "f-dynamic-form-section--footer"; return e.showHeader && (t.slots.headerTitle && (a.headerTitle = () => { var L, G; return (G = (L = t.slots).headerTitle) == null ? void 0 : G.call(L); }), M += e.headerContentRenderFunction || t.slots.headerContent ? " f-dynamic-form-section--header-cotnent-tmpl" : "", t.slots.headerContent ? a.headerContent = () => { var L, G; return (G = (L = t.slots).headerContent) == null ? void 0 : G.call(L); } : !e.headerContentRenderFunction && r.length > 0 && (a.headerContent = () => Ie(V("div", { class: "f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" }, [x(r)]), [[Pe("area-response")]]))), e.showFooter && (B += e.footerRenderFunction || t.slots.footer ? " f-dynamic-form-section--footer-tmpl" : 0, t.slots.footer ? a.footer = () => { var L, G; return (G = (L = t.slots).footer) == null ? void 0 : G.call(L); } : !e.footerRenderFunction && c.length > 0 && (B += c.length > 0 ? " f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" : "", a.footer = () => x(c))), { slots: a, footerClass: B, headerContentClass: M }; } const q = ne(() => typeof e.toolbar == "function" ? e.toolbar() : e.toolbar), z = ne(() => e.headerStyle ? typeof e.headerStyle == "function" ? e.headerStyle() : e.headerStyle : ""), X = ne(() => e.footerStyle ? typeof e.footerStyle == "function" ? e.footerStyle() : e.footerStyle : ""); function ee(a, M) { t.emit("click", a, M); } function H() { const { slots: a, footerClass: M, headerContentClass: B } = N(); return V(Mt, { customClass: "f-dynamic-form-section", showHeader: e.showHeader, mainTitle: e.mainTitle, enableAccordion: e.enableAccordion ? "default" : "", headerContentClass: B, footerClass: M, buttons: q.value, headerStyle: z.value, footerStyle: X.value, headerTitleRenderFunction: e.showHeader && e.headerTitleRenderFunction ? () => e.headerTitleRenderFunction() : null, headerContentRenderFunction: e.showHeader && e.headerContentRenderFunction ? () => e.headerContentRenderFunction() : null, footerRenderFunction: e.showFooter && e.footerRenderFunction ? () => e.footerRenderFunction() : null, buttonsClass: "col-auto", onClick: ee, moreButtonClass: e.moreButtonClass }, { default: () => k(v), ...a }); } return () => e.visible ? e.showHeader || e.showFooter ? H() : g.value && k(n.value) || !g.value && x(n.value) : null; } }), sn = { id: { type: String, default: "" }, customClass: { type: String, default: "" }, customStyle: { type: String, default: "" }, /** 筛选组件配置器,具体配置项可查看各组件文档 */ editor: { type: Object, default: {} }, label: { type: String, default: "" }, /** value is uncertain because type is uncertain, default value should not be set */ modelValue: { type: [String, Boolean, Array, Number], default: null }, // readonly: { type: Boolean, default: false }, visible: { type: Boolean, default: !0 }, required: { type: Boolean, default: !1 }, showLabel: { type: Boolean, default: !0 }, /** * visible相当于showLabel为true,none相当于showLabel为false */ showLabelType: { type: String, default: "visible" }, type: { type: String, default: "input-group" }, componentId: { type: String, default: "" }, errors: { type: Object, default: null }, fill: { type: Boolean, default: !1 }, linkLabel: { type: String, default: !1 } }, cn = {}, un = {}, { globalStorageKey: ri } = qe(), dn = { id: { Type: String, default: "" }, /** 是否自动完成 */ autocomplete: { Type: String, default: "off" }, /** 自定义CLASS */ customClass: { Type: String, default: "" }, /** 禁用 */ disabled: { Type: Boolean, default: !1 }, /** 允许编辑 */ editable: { Type: Boolean, default: !0 }, /** 启用清除按钮 */ enableClear: { Type: Boolean, default: !0 }, /** 启用提示文本 */ enableTitle: { Type: Boolean, default: !0 }, /** 能否查看密码 */ enableViewPassword: { Type: Boolean, default: !0 }, /** 始终显示占位符文本 */ forcePlaceholder: { Type: Boolean, default: !1 }, /** 扩展按钮 */ groupText: { Type: String, default: "" }, /** 密码模式 */ showType: { Type: String, default: "text" }, /** 密码模式 --废弃*/ type: { Type: String, default: "text" }, /** 最大值 */ max: { type: [Number, String] }, /** 最小值 */ min: { type: [Number, String] }, /** 最大长度 */ maxLength: { Type: Number || void 0, default: void 0 }, /** 最小长度 */ minLength: { Type: Number || void 0, default: void 0 }, /** 组件值 */ modelValue: { Type: String || Boolean, default: "" }, /** 隐藏边线 */ showBorder: { Type: Boolean, default: !0 }, /** 步长 */ step: { Type: Number, default: 1 }, /** 启用提示信息 */ placeholder: { Type: String, default: "" }, precision: { Type: Number, default: 0 }, /** 只读 */ readonly: { Type: Boolean, default: !1 }, /** 当组件禁用或只读时显示后边的按钮 */ showButtonWhenDisabled: { Type: Boolean, default: !1 }, /** tab索引 */ tabIndex: { Type: Number, default: 0 }, /** 文本在输入框中的对齐方式 */ textAlign: { Type: String, default: "left" }, /** 是否启用前置扩展信息;在输入框前面 显示 ① 图标鼠标滑过后显示 */ useExtendInfo: { Type: Boolean, default: !1 }, /** 前置扩展信息 */ extendInfo: { Type: String, default: "" }, /** 输入值 */ value: { Type: String, default: "" }, /** 是否撑开高度 */ autoHeight: { type: Boolean, default: !1 }, /** 自动聚焦 */ autofocus: { type: Boolean, default: !1 }, /** 文本区域可见的行数 */ rows: { type: Number, default: 2 }, /** 展示输入文本数量 */ showCount: { type: Boolean, default: !1 }, showZero: { type: Boolean, default: !1 }, /** * 作为内嵌编辑器被创建后默认获得焦点 */ focusOnCreated: { type: Boolean, default: !1 }, /** * 作为内嵌编辑器被创建后默认选中文本 */ selectOnCreated: { type: Boolean