UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,415 lines 110 kB
var et = Object.defineProperty; var tt = (e, t, n) => t in e ? et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var ve = (e, t, n) => tt(e, typeof t != "symbol" ? t + "" : t, n); import { dynamicFormGroupProps as Ne, FDynamicFormLabel as nt, dynamicFormInputProps as ot, FDynamicFormGroup as rt, FResponseForm as it, FDynamicFormInput as at } from "../../components/dynamic-form/index.esm.js"; import { schemaMap as lt, resolveAppearance as st, createPropsResolver as he, propertyConfigSchemaMapForDesigner as ct, createFormGroupEditorResolver as ut } from "../../components/dynamic-resolver/index.esm.js"; import { defineComponent as pe, ref as U, inject as re, onMounted as fe, computed as ee, withDirectives as Ie, createVNode as I, resolveDirective as Pe, createTextVNode as ne, watch as Fe, reactive as Re, Fragment as dt, mergeProps as Ue } from "vue"; import { DgControl as p, refreshCanvas as pt, UseTemplateDragAndDropRules as mt, useDragulaCommonRule as ft, useDesignerComponent as we } from "../../components/designer-canvas/index.esm.js"; import { useGuid as De, FormSchemaEntityField$Type as Oe, FormSchemaEntityFieldTypeName as $e, areaResponseDirective as yt, getCustomClass as Me, EVENT_PROPERTY_TAB_IDS as Se, useThirdComponent as qe, useTextBoxDesign as gt } from "../../components/common/index.esm.js"; import { BaseControlProperty as vt, FormBindingType as de, InputBaseProperty as bt } from "../../components/property-panel/index.esm.js"; import { useResponseLayoutEditorSetting as ht } from "../response-layout-editor/index.esm.js"; import { createPropsResolver as Ge } from "../../components/designer/index.esm.js"; import { cloneDeep as xe, mergeWith as Ct, merge as Ft, isPlainObject as Ae } from "lodash-es"; import { loadRegister as Tt, useComponentManager as wt, useEntityState as kt, useDynamicViewUtils as It, componentMap as ke, resolverMap as Pt, componentPropsConverter as xt } from "../../components/dynamic-view/index.esm.js"; import { LocaleService as Vt } from "../../components/locale/index.esm.js"; import Bt from "../../components/section/index.esm.js"; import "../../components/accordion/index.esm.js"; import "../avatar/index.esm.js"; import "../approval-logs/index.esm.js"; import "../button-edit/index.esm.js"; import "../../components/button-group/index.esm.js"; import "../../components/button/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 "../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 "../wizard/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 "../../components/tooltip/index.esm.js"; import { FMessageBoxService as Mt } from "../../components/message-box/index.esm.js"; function Et(e, t) { function n(g, l = null) { if (l) return l; const v = e.getComponentById(t); return e.selectNode(v, (i) => i.id === g); } function o(g) { const l = e.getComponentById(g); return !(!l || !l.componentType || !l.componentType.startsWith("form")); } function r(g) { const l = new Set(g); return Array.from(l).length === 1; } function m(g) { const l = n(g.id), v = ht(e), i = []; v.getResonseFormLayoutConfig(l, i, 1); const d = i.map((j) => j.columnInSM), h = i.map((j) => j.columnInMD), s = i.map((j) => j.columnInLG), f = i.map((j) => j.columnInEL), F = r(d) ? d[0] : 0, T = r(h) ? h[0] : 0, w = r(s) ? s[0] : 0, L = r(f) ? f[0] : 0; return { uniqueColClassInSM: F, uniqueColClassInMD: T, uniqueColClassInLG: w, uniqueColClassInEL: L }; } function u(g, l) { let v, i, d, h, s = []; if (g) { const j = g.split(" "), q = j.filter((R) => R.startsWith("col-")); v = q.find((R) => /^col-([1-9]|10|11|12)$/.test(R)), i = q.find((R) => /^col-md-([1-9]|10|11|12)$/.test(R)), d = q.find((R) => /^col-xl-([1-9]|10|11|12)$/.test(R)), h = q.find((R) => /^col-el-([1-9]|10|11|12)$/.test(R)), s = j.filter((R) => !R.startsWith("col-")); } const f = l.uniqueColClassInSM ? "col-" + l.uniqueColClassInSM : v, F = l.uniqueColClassInMD ? "col-md-" + l.uniqueColClassInMD : i, T = l.uniqueColClassInLG ? "col-xl-" + l.uniqueColClassInLG : d, w = l.uniqueColClassInEL ? "col-el-" + l.uniqueColClassInEL : h; return [f, F, T, w].concat(s).join(" "); } function b(g, l, v) { g = n(v, g), g.contents.forEach((i) => { if (i.type === p["dynamic-form"].type) return; if (i.type === p.fieldset.type) { b(i, l, i.id); return; } i.appearance || (i.appearance = {}); const d = i.appearance.class; i.appearance.class = u(d, l); }); } return { checkIsInFormComponent: o, assembleUnifiedLayoutContext: m, changeFormControlsByUnifiedLayoutConfig: b, changeControlClassInByColumn: u }; } class ze extends vt { constructor(t, n) { super(t, n); } getBaseFormAppearanceConfig(t, n, o) { const r = this, { assembleUnifiedLayoutContext: m, changeFormControlsByUnifiedLayoutConfig: u, changeControlClassInByColumn: b } = Et(this.formSchemaUtils, this.componentId), g = this.getAppearanceConfig(n); return g.properties.adaptForLanguage = { title: "控件布局响应国际化", description: "启用国际化后:简体中文、繁体中文环境下控件标签与输入框在一行展示,其他语言环境下控件标签与输入框上下排列。", type: "boolean" }, g.properties.labelAutoOverflow = { title: "控件标签换行", description: "控件标签字数超长时,换行显示。控件标签与输入框在一行展示时,此属性有效。", type: "boolean" }, g.properties.unifiedLayout = { title: "统一布局配置", description: "统一配置卡片区域内所有控件的宽度,只支持标准模式", refreshPanelAfterChanged: !0, editor: { type: "response-form-layout-setting", initialState: m(n) } }, g.setPropertyRelates = function(l, v) { if (l) switch (l && l.propertyID) { case "unifiedLayout": { n.layout = b("", l.propertyValue), t === "dynamic" ? n.layout = b("", l.propertyValue) : (u(null, l.propertyValue, n.id), r.updateElementByParentContainer(n.id, o)); break; } case "labelAutoOverflow": { r.setLabelAutoOverflow(n, l.propertyValue), pt(); break; } } }, g; } getBaseFormBehaviorConfig(t, n) { const o = this, r = this.getPropertyEditorParams(n, ["Variable", "Custom"], "fields", {}, { newVariablePrefix: "", newVariableType: "Array" }), m = this.getPropertyEditorParams(n, ["Variable", "Custom"], "formData", {}, { newVariablePrefix: "", newVariableType: "Object" }); let u = {}; return t === "dynamic" && (u = { fields: { title: "动态控件列表", type: "string", description: "动态控件列表", editor: r }, formData: { title: "动态控件列表初始值", type: "string", description: "动态控件列表初始值", editor: m }, mode: { description: "两种方式,快速模式下,控件属性写法支持组件的属性,可以直接写回调和事件,比如onClick: () => {}。完整模式下,控件属性写法与设计时schema一致。", title: "渲染模式", type: "enum", editor: { default: "quick", readonly: !0, data: [ { id: "quick", name: "快速模式" }, { id: "full", name: "完整模式" } ] } } }), this.getBehaviorConfig(n, "", u, (b, g) => { switch (b.propertyID) { case "fields": case "formData": o.afterMutilEditorChanged(n, b); break; } }); } setLabelAutoOverflow(t, n, o) { if (!o) { const r = this.formSchemaUtils.getComponentById(this.componentId); o = this.formSchemaUtils.selectNode(r, (m) => m.id === t.id); } o && o.contents && o.contents.length && o.contents.forEach((r) => { if (r.type === p.fieldset.type) { this.setLabelAutoOverflow(null, n, r); return; } r.appearance || (r.appearance = { class: "" }), r.appearance.class || (r.appearance.class = ""), n ? r.appearance.class.includes("farris-group-multi-label") || (r.appearance.class = r.appearance.class + " farris-group-multi-label") : r.appearance.class = r.appearance.class.replace("farris-group-multi-label", "").trim(); }); } } class Rt extends ze { constructor(t, n) { super(t, n); } getPropertyConfig(t, n) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(t), this.propertyConfig.categories.appearance = this.getBaseFormAppearanceConfig("default", t, n), this.propertyConfig.categories.behavior = this.getBaseFormBehaviorConfig("default", t), this.propertyConfig; } } function Dt(e, t) { const n = e.schema, o = new mt(), { canMove: r, canAccept: m, canDelete: u } = o.getTemplateRule(e, t); function b(c, y) { const { sourceElement: C } = c, { componentInstance: P } = C, x = t == null ? void 0 : t.formSchemaUtils; if (!x) return !0; const O = x.getComponentById(P.value.belongedComponentId), A = x.getViewModelById(O.viewModel), V = x.getComponentById(e.componentInstance.value.belongedComponentId), k = x.getViewModelById(V.viewModel); return y ? A != null && A.id && (k != null && k.id) && A.id !== k.id ? A.bindTo === k.bindTo : !0 : (A == null ? void 0 : A.id) === (k == null ? void 0 : k.id); } function g(c) { const { bindingTargetId: y } = c; if (!t) return; const { formSchemaUtils: C, schemaService: P } = t, x = C.getComponentById(e.componentInstance.value.belongedComponentId), O = P.getFieldByIDAndVMID(y, x.viewModel); return !!(O != null && O.schemaField); } function l(c) { const y = o.getComponentContext(e); if (y && y.componentClassList && y.componentClassList.includes("f-form-layout") && y.componentClassList.includes("farris-form")) { if (c.sourceType === "control" && (c.componentCategory === "input" || c.componentType && ["fieldset", "dynamic-form"].indexOf(c.componentType) > -1)) return !0; if (c.sourceType === "move") { if (c.componentType === "form-group") return b(c, !0); if (c.componentType === "fieldset") return b(c, !1); if (c.componentType === "dynamic-form") return !0; } return c.sourceType === "field" && c.componentCategory === "input" ? g(c) : !1; } return !0; } function v(c) { return !(!ft().basalDragulaRuleForContainer(c, t) || !m || !l(c)); } function i(c) { var k; const y = c.componentInstance, C = y.value.schema, P = t == null ? void 0 : t.formSchemaUtils, x = t == null ? void 0 : t.designViewModelUtils, O = P.getViewModelIdByComponentId(y.value.belongedComponentId), A = x.getDgViewModel(O), V = y.value.parent; if (V && p.fieldset && ((k = V.schema) == null ? void 0 : k.type) === p.fieldset.type && A) { const N = { groupId: null, groupName: null }; switch (C.binding.type) { case de.Form: { A.changeField(C.binding.field, N); break; } case de.Variable: { P.modifyViewModelFieldById(O, C.binding.field, N, !0); break; } } } } function d(c, y, C) { const P = y.fields.find((k) => k.id === c), x = t == null ? void 0 : t.designViewModelUtils, O = x.getDgViewModel(y.id), A = O.fields.find((k) => k.id === c); O.removeField([c]); const V = x.getDgViewModel(C); V.addField(A), P.fieldSchema && V.changeField(A.id, P.fieldSchema); } function h(c, y, C, P = []) { const x = y.id, O = c.binding.field, A = y.fields.findIndex((k) => k.id === O); if (A > -1 && (C.fields.push(y.fields[A]), y.fields.splice(A, 1)), x === "root-viewmodel" && C.id !== "root-viewmodel") { c.binding.path && !c.binding.path.includes("root-component.") && (c.binding.path = "root-component." + c.binding.path); return; } if (C.id === "root-viewmodel" && x !== "root-viewmodel" && c.binding.path && c.binding.path.includes("root-component.")) { c.binding.path = c.binding.path.replace("root-component.", ""); return; } const V = y.states.find((k) => k.id === O); V && (C.states = C.states ? C.states : [], C.states.findIndex((k) => k.id === V.id) < 0 && (C.states.push(V), P.push(V.id))); } function s(c, y, C, P = []) { var A; if (!c) return; const x = y.id === "root-viewmodel" && C.id !== "root-viewmodel", O = C.id === "root-viewmodel" && y.id !== "root-viewmodel"; Object.keys(c).forEach((V) => { if (V === "binding") return; const k = c[V]; if (k && typeof k == "object" && k.type === de.Variable && k.field) { if (x) { k.path && !k.path.includes("root-component.") && (k.path = "root-component." + k.path); return; } if (O && k.path && k.path.includes("root-component.")) { k.path = k.path.replace("root-component.", ""); return; } const N = y.states.find((G) => G.id === k.field); if (N) { P.push(N.id), C.states = C.states ? C.states : []; const G = C.states.find((S) => S.code === N.code); if (G) k.field = G.id; else { const S = Object.assign({}, { newId: De().guid() }, N); C.states.push(S), k.field = S.newId; } } } }), (A = C.states) != null && A.length && C.states.map((V) => { V.newId && (V.id = V.newId, delete V.newId); }); } function f(c, y, C) { if (c && (y(c, C), c.contents)) for (const P of c.contents) f(P, y, C); } function F(c = [], y) { if (!c.length) return; const C = t == null ? void 0 : t.formSchemaUtils, P = C.getComponentByViewModelId(y), x = [], O = (V, k) => { V && (Object.keys(V).forEach((N) => { const G = V[N]; G && typeof G == "object" && G.type === de.Variable && c.includes(G.field) && !k.includes(G.field) && k.push(G.field); }), V.editor && O(V.editor, k)); }; f(P, O, x); const A = C.getViewModelById(y); c.forEach((V) => { x.includes(V) || (A.states = A.states.filter((k) => k.id !== V)); }); } function T(c) { const y = De().guid(), C = Object.assign({}, c, { id: y, code: c.code + y.slice(0, 4), name: c.name + y.slice(0, 4) }), O = (t == null ? void 0 : t.formSchemaUtils).getCommands().find((A) => A.id === c.cmpId); return O && O.refedHandlers.push({ host: y, handler: c.handlerName }), C; } function w(c, y, C) { var N, G; const P = {}, O = (t == null ? void 0 : t.formSchemaUtils).resolveComponentEvents(lt, c); if (!O) return; Object.keys(c).forEach((S) => { const Z = Object.keys(O).find((K) => K === S); if (Z && c[Z]) { const K = y.commands.find((Y) => Y.code === c[Z]); if (K) { let Y = P[K.code]; Y || (Y = T(K), P[K.code] = Y, C.commands.push(Y)), c[Z] = Y.code; } } }); const V = (t == null ? void 0 : t.designViewModelUtils).getDgViewModel(C.id), k = ["valueChanging", "valueChanged"]; if (((N = c.binding) == null ? void 0 : N.type) === de.Form) { const S = (G = C.fields) == null ? void 0 : G.find((Z) => Z.id === c.binding.field); S && k.forEach((Z) => { if (S[Z]) { const K = y.commands.find((Y) => Y.code === S[Z]); if (!K) return; if (P[K.code]) V.changeField(S.id, { [Z]: P[K.code].code }); else { const Y = T(K); P[K.code] = Y, C.commands.push(Y), V.changeField(S.id, { [Z]: Y.code }); } } }); } } function L(c) { var k, N; const y = t == null ? void 0 : t.formSchemaUtils, C = c.componentInstance, P = C.value.schema, x = y.getViewModelIdByComponentId(C.value.belongedComponentId), O = y.getViewModelById(x), A = y.getComponentById(e.componentInstance.value.belongedComponentId), V = y.getViewModelById(A.viewModel); if (x !== V.id) { const G = (k = P.binding) == null ? void 0 : k.type, S = (N = P.binding) == null ? void 0 : N.field, Z = []; switch (G) { case de.Form: { d(S, O, V.id); break; } case de.Variable: { h(P, O, V, Z); break; } } s(P, O, V, Z), s(P.editor, O, V, Z), w(P, O, V), x !== "root-viewmodel" && F(Z, x); } } function j(c) { var P; if (!c || !c.componentInstance) return; const C = c.componentInstance.value.schema; if (C.type === "dynamic-form") { const x = ((P = C == null ? void 0 : C.appearance) == null ? void 0 : P.class) || ""; x.indexOf("col-12") < 0 && (C.appearance = { ...C.appearance, class: x + " col-12 px-0" }), L(c); return; } !C.binding || !C.binding.field || (i(c), L(c)); } function q() { return n.componentType ? "display:inherit;flex-direction:inherit;margin-bottom:10px" : ""; } function R(c) { let y = ""; switch (c) { case 1: { y = "col-12 col-md-12 col-xl-12 col-el-12"; break; } case 2: { y = "col-12 col-md-6 col-xl-6 col-el-6"; break; } case 3: { y = "col-12 col-md-6 col-xl-4 col-el-4"; break; } case 4: { y = "col-12 col-md-6 col-xl-3 col-el-2"; break; } } return y; } function H(c, y) { let C = !1; if (e.schema && Object.prototype.hasOwnProperty.call(e.schema, "labelAutoOverflow")) C = e.schema.labelAutoOverflow; else { const P = t == null ? void 0 : t.formSchemaUtils, x = P == null ? void 0 : P.selectNode(y, (O) => O.type === p["response-form"].type); x && (C = x.labelAutoOverflow); } return C && (c += " farris-group-multi-label"), c; } function _(c) { const y = e.componentInstance.value.getBelongedComponentInstance(e.componentInstance); if (y && y.schema && y.schema.componentType) { const { formColumns: C } = y.schema; let P = R(C); P = t == null ? void 0 : t.formSchemaUtils.getControlClassByFormUnifiedLayout(P, y.schema.id, e.schema), P = H(P, y.schema), c.appearance || (c.appearance = {}), c.appearance.class = P; } } function D(c, y, C, P) { const { bindingSourceContext: x, parentComponentInstance: O } = c; if (x != null && x.entityFieldNode && O) { const A = t == null ? void 0 : t.designViewModelUtils, k = (t == null ? void 0 : t.formSchemaUtils).getViewModelIdByComponentId(O.belongedComponentId), N = A.getDgViewModel(k); N.removeField([x.entityFieldNode.id]), N.addField(x.designViewModelField), y && N.changeField(x.entityFieldNode.id, { editor: { $type: y }, groupId: C, groupName: P }); } } function E(c, y) { var O, A, V; const C = n; if ((C.appearance && C.appearance.class || "").split(" ").includes("f-form-layout") && c.componentCategory === "input") { const { label: k } = c; let N; const G = t == null ? void 0 : t.controlCreatorUtils; return (O = c.bindingSourceContext) != null && O.entityFieldNode ? N = G.setFormFieldProperty((A = c.bindingSourceContext) == null ? void 0 : A.entityFieldNode, y == null ? void 0 : y.type) : (N = G.createFormGroupWithoutField(y == null ? void 0 : y.type), N.label = k), _(N), D(c, (V = N.editor) == null ? void 0 : V.type), N; } return c.componentType === "dynamic-form" && (y.appearance = { class: "col-12", ...y.appearance }), y; } function J() { return r; } function Q() { return u; } function te() { return !1; } function X(c) { return new Rt(c, t).getPropertyConfig(n, e.componentInstance.value); } return { canAccepts: v, checkCanDeleteComponent: Q, checkCanMoveComponent: J, getStyles: q, getPropsConfig: X, hideNestedPaddingInDesginerView: te, onAcceptMovedChildElement: j, onResolveNewComponentSchema: E, moveInputBetweenComponent: L, resolveFormGroupAppearance: _, syncFieldToViewModel: D }; } const Ot = "root-viewmodel"; class $t { constructor(t, n) { ve(this, "formSchemaUtils"); ve(this, "controlCreatorUtils"); ve(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), r = this.createViewModeNode(t), m = this.formSchemaUtils.getFormSchema(); return m.module.viewmodels.push(r), m.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, r; const { templateId: n } = this.formSchemaUtils.getFormSchema().module; if (n === "double-list-in-tab-template" && ((r = (o = t.parentComponentInstance) == null ? void 0 : o.schema) == null ? void 0 : r.type) === "tab-page") { const m = t.parentComponentInstance.parent && t.parentComponentInstance.parent.schema; if ((m == null ? void 0 : m.type) === "tabs" && (m == null ? void 0 : m.fill) === !0) return "f-struct-wrapper f-utils-fill-flex-column"; } return "f-struct-wrapper"; } createFormComponentContents(t) { var b, g; 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"), r = []; Object.assign(o, { id: t.componentId + "-form", appearance: { class: "f-form-layout farris-form farris-form-controls-inline" }, contents: r, controlsInline: !0 }), n.contents = [o]; const { selectedFields: m } = t; m == null || m.forEach((l) => { if (l.$type === Oe.SimpleField) { const v = xe(l), i = this.resolveControlClassByFormColumns(t), d = this.controlCreatorUtils.setFormFieldProperty(v, "", i); d && r.push(d); } }); const { templateId: u } = this.formSchemaUtils.getFormSchema().module; if (u === "double-list-in-tab-template" && ((g = (b = t.parentComponentInstance) == null ? void 0 : b.schema) == null ? void 0 : g.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: Ot, fields: this.assembleViewModelFields(t), commands: [], states: [], enableValidation: !0 }; } /** * 组装viewModel fields 节点 */ assembleViewModelFields(t) { const n = [], { selectedFields: o } = t; return o == null || o.forEach((r) => { if (r.$type === Oe.SimpleField) { let m = "blur"; const u = r.type.name; (u === $e.Enum || u === $e.Boolean) && (m = "change"), n.push({ type: "Form", id: r.id, fieldName: r.bindingField, groupId: null, groupName: null, updateOn: m, fieldSchema: {} }); } }), n; } } function Ee(e, t, n, o) { var m, u, b, g, l, v; const r = n.parentComponentInstance; if (r && o) { const i = (m = r.schema) == null ? void 0 : m.type, h = { componentId: `form-${Math.random().toString(36).slice(2, 6)}`, componentName: ((u = n.bindingSourceContext) == null ? void 0 : u.entityTitle) || ((g = (b = n.bindingSourceContext) == null ? void 0 : b.bindingEntity) == null ? void 0 : g.name) || "标题", componentType: "form", formColumns: i === "splitter-pane" ? 1 : 4, parentContainerId: r.schema.id, parentComponentInstance: r, bindTo: ((l = n.bindingSourceContext) == null ? void 0 : l.bindTo) || "/", selectedFields: (v = n.bindingSourceContext) == null ? void 0 : v.bindingEntityFields }; return new $t(e, o).createComponent(h); } else return t; } function At(e, t, n) { return t; } function Lt(e, t, n, o) { return t.layout = "col-12 col-md-6 col-xl-3 col-el-2", t; } const ye = /* @__PURE__ */ new Map([ ["appearance", st] ]), jt = /* @__PURE__ */ new Map([]), Nt = "https://json-schema.org/draft/2020-12/schema", Ut = "https://farris-design.gitee.io/response-form.schema.json", St = "response-form", qt = "A Farris Data Collection Component", Gt = "object", zt = { 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" } }, Zt = [ "id", "type", "contents" ], Ze = { $schema: Nt, $id: Ut, title: St, description: qt, type: Gt, properties: zt, required: Zt }, Wt = "https://json-schema.org/draft/2020-12/schema", _t = "https://farris-design.gitee.io/dynamic-form.schema.json", Jt = "dynamic-form", Xt = "A Farris Data Collection Component", Qt = "object", Yt = { 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 }, 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: "" }, onChange: { description: "", type: "string" }, callback: { description: "", type: "string" } }, Ht = [ "id", "type", "contents" ], Kt = { onClick: "点击事件", onChange: "ֵ值变化事件", event: "内部控件事件", callback: "内部控件属性回调事件" }, We = { $schema: Wt, $id: _t, title: Jt, description: Xt, type: Qt, properties: Yt, required: Ht, events: Kt }; var be = /* @__PURE__ */ ((e) => (e.Header = "header", e.Footer = "footer", e))(be || {}), 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" } }, _e = 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: "" }, fields: { type: [Object, String] } }); Object.assign({}, _e, { componentId: { type: String, default: "" } }); const nn = Ge(ge, Ze, ye, Ee), on = Ge(ge, We, ye, Lt), Ve = /* @__PURE__ */ pe({ name: "FResponseFormDesign", directives: { "area-response": yt }, props: Je, emits: [], setup(e, t) { const n = U(), o = re("design-item-context"), r = re("designer-host-service"), m = Dt(o, r), u = we(n, o, m); fe(() => { n.value.componentInstance = u; }), t.expose(u.value); const b = ee(() => Me({ "drag-container": !0 }, e.customClass)); function g() { return typeof e.fields == "string" && e.fields || e.fields && e.fields.path ? I("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;" }, [ne("动态表单")]) : null; } return () => Ie(I("div", { ref: n, class: b.value, style: e.customClass, "data-dragref": `${o.schema.id}-container`, "data-associate": `${o.schema.id}-component` }, [t.slots.default && t.slots.default(), g()]), [[Pe("area-response")]]); } }); class rn extends ze { constructor(t, n) { super(t, n); } getPropertyConfig(t, n) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(t), this.propertyConfig.categories.appearance = this.getBaseFormAppearanceConfig("dynamic", t, n), this.propertyConfig.categories.behavior = this.getBaseFormBehaviorConfig("dynamic", t), this.propertyConfig.categories.eventsEditor = this.getEventPropConfig(t), this.propertyConfig; } getEventPropConfig(t) { const n = [ { label: "onChange", name: "ֵ值变化事件" }, { label: "event", name: "内部控件事件" } // { // "label": "callback", // "name": "内部控件回调事件" // } ], o = this, r = o.eventsEditorUtils.formProperties(t, o.viewModelId, n); return { title: "事件", hideTitle: !0, properties: o.createBaseEventProperty(r), // 这个属性,标记当属性变更得时候触发重新更新属性 refreshPanelAfterChanged: !0, tabId: Se, tabName: "交互", setPropertyRelates(u, b) { const g = u.propertyValue; delete t[o.viewModelId], g && (g.setPropertyRelates = this.setPropertyRelates, o.eventsEditorUtils.saveRelatedParameters(t, o.viewModelId, g.events, g)), t.remoteSort = !!t.columnSorted; } }; } } function an(e, t) { function n(u) { const b = e.schema; return new rn(u, t).getPropertyConfig(b, e.componentInstance.value); } function o() { return !1; } function r() { return !0; } function m() { return !0; } return { getPropsConfig: n, canAccepts: o, checkCanDeleteComponent: r, checkCanMoveComponent: m }; } const ln = /* @__PURE__ */ pe({ name: "FDynamicFormDesign", props: Je, emits: [], setup(e, t) { const n = U(), o = re("design-item-context"), r = re("designer-host-service"), m = an(o, r), u = we(n, o, m); fe(() => { n.value.componentInstance = u; }), t.expose(u.value); const b = ee(() => Me({ "drag-container": !0 }, e.customClass)); return () => I("div", { ref: n, class: b.value, style: e.customStyle }, [I("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;" }, [ne("动态表单")])]); } }); function sn(e, t) { function n(u) { return e.value && e.value[u]; } const o = []; function r(u) { o.push(u); } function m(u, b, g) { const l = e.value ? e.value[u] : void 0; e.value && (e.value[u] = g), b && (t && (t.emit("update:modelValue", { elementId: u, field: b, value: g, modelValue: e.value }), t.emit("change", { elementId: u, field: b, value: g, modelValue: e.value })), o.forEach((v) => { v({ elementId: u, field: b, value: g, oldValue: l, modelValue: e.value }); })); } return { getValue: n, setValue: m, onValueChange: r }; } const cn = /* @__PURE__ */ pe({ name: "FDynamicForm", props: _e, emits: ["update:modelValue", "change", "event", "click"], setup(e, t) { const n = U(e.fields), o = /* @__PURE__ */ new Map(), r = U(e.callback); Tt(); const m = wt(), u = U(e.formData || {}), b = sn(u, t); kt(n.value).setup(); const l = /* @__PURE__ */ new Map(), v = U(e.canRenderForm); let i = [], d = [], h = []; const s = e.mode === Te.FULL ? "contents" : "fields", { mergeArray: f, resolveCallbacks: F, resolveEvents: T } = It(), w = ee(() => { const a = Vt.getLocale(), B = e.fields && e.fields.length > 0; let M = { "f-form-layout": B, "farris-form": B, "f-dynamic-form": !(e.showHeader || e.showFooter) }; return M = Me(M, e.customClass), e.adaptForLanguage && a && (M["farris-form-controls-inline"] = a !== "en"), M; }); function L() { function a(B, M) { const { id: $ } = B || {}, { field: z } = B.binding || {}; return { modelValue: M.getValue($), "onUpdate:modelValue": (ie) => { M.setValue($, z || $, ie); } }; } return { resolve: a }; } function j(a) { const B = L(); return b.getValue(a.id) === void 0 && Object.hasOwnProperty.call(a, "modelValue") && b.setValue(a.id, void 0, a.modelValue), B.resolve(a, b); } function q(a) { const B = {}; return a && Object.entries(a).forEach(([M, $]) => { B[M] = () => Array.isArray($) ? $.map((z) => E(z)) : E($); }), B; } function R(a) { return a.type ? a.type : a[s] ? "fieldset" : "form-group"; } function H(a) { const B = R(a), M = a.customClass || ""; return M || (B === "fieldset" ? "col-12 px-0" : i.length === 0 && d.length === 0 || a.id && h.find(($) => $[s] ? $[s].find((z) => z.id === a.id) : $.id === a.id) ? e.layout : "unset-item"); } function _(a) { const B = R(a); let M = {}, $ = "", z = {}, ie = {}; if (e.mode === Te.FULL) { z = { ...T(a, t, B) }, ie = { ...F(a, r, B) }; const W = xt[B]; M = W ? W(a) : {}, $ = H(M); } else { $ = H(a); const { fields: W, customClass: oe, ...le } = a; M = le; } return { props: { ...{ ...M, customClass: $, ...j(a) }, key: a.id, ref: (W) => { if (W && a.id && !m.has(a.id)) { m.register(a.id, W); const oe = { token: a.id, name: "component:ready", type: R(a), payloads: [U(W)], schema: a }; t.emit("event", oe); } }, onVnodeUnmounted: (W) => { if (a.id && m.has(a.id)) { m.remove(a.id); const oe = { token: a.id, name: "component:unmounted", type: R(a), payloads: [W], schema: a }; t.emit("event", oe); } } }, eventProps: z, callbackProps: ie }; } function D(a, B) { return Array.isArray(a) ? a.map((M) => B(M)) : B(a); } function E(a, B) { var se; const M = R(a), $ = ke[M]; if (a.id && o.set(a.id, a), !$) return null; const z = () => a[s] ? a[s].map((W) => E(W)) : null, ie = (W, oe, le) => { let ue; return le && le.length > 0 ? ue = I(W, { ...oe }, le) : ue = I(W, { ...oe }, null), ue; }, ce = ((se = l.get(a.id)) == null ? void 0 : se.props) || {}; return a[s] && a[s].length > 0 ? ie($, ce, [z()]) : a.slots ? ie($, ce, [...Object.values(q(a.slots))]) : ie($, ce); } function J(a) { const B = R(a); if (!ke[B]) return; const { props: $, eventProps: z, callbackProps: ie } = _(a), ce = Pt[B], se = ce ? ce.editorResolver : null, { componentEventProps: W, editorEventProps: oe } = z, { componentCallbackProps: le, editorCallbackProps: ue } = ie; if (W && Object.keys(W).length > 0 && Object.assign($, W), le && Object.keys(le).length > 0 && Object.assign($, 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 ($ && Object.keys($).length > 0) { const ae = l.get(a.id); ae ? Ft(ae == null ? void 0 : ae.props, $) : l.set(a.id, Re({ props: $ })); } !a[s] || !Array.isArray(a[s]) || a[s].forEach((ae) => J(ae)); } function Q(a) { const B = R(a); ke[B] && (te(a), !(!a[s] || !Array.isArray(a[s])) && a[s].forEach(($) => Q($))); } function te(a) { const B = j(a); if (B && Object.keys(B).length > 0) { const M = l.get(a.id); if (!M) l.set(a.id, Re({ props: B })); else { const $ = { ...M == null ? void 0 : M.props }; Object.keys(B).forEach((z) => { $[z] = B[z]; }), Object.assign(M == null ? void 0 : M.props, $); } } } fe(() => { }), Fe(() => e.formData, (a) => { u.value = a; }), Fe(() => u.value, (a) => { D(n.value, Q); }, { deep: !0 }); function X(a, B = "") { return B ? a.filter((M) => M.position === B) : a.filter((M) => !M.position || [be.Header, be.Footer].indexOf(M.position) < 0); } function c(a) { a && (i = X(a, be.Header), i.length && D(i, J), d = X(a, be.Footer), d.length && D(d, J), h = X(a), h.length && D(h, J)); } Fe(() => e.fields, (a) => { o.clear(), m.clear(), u.value = e.formData || {}, l.clear(), n.value = a, c(a); }), c(e.fields); function y(a) { a.$forceUpdate && a.$forceUpdate(); } function C(a) { return b.getValue(a); } function P() { return u.value; } function x(a, B) { b.setValue(a, void 0, B); const M = o.get(a); M && te(M); } function O(a) { var B; return (B = l.get(a)) == null ? void 0 : B.props; } function A(a, B) { const M = l.get(a); Ct(M == null ? void 0 : M.props, B, f); } t.expose({ componentManager: m, rerender: y, getProps: O, setProps: A, getControlValue: C, setControlValue: x, getValues: P }); function V(a = []) { return a.length > 0 && D(a, E); } function k(a) { return Ie(I("div", { class: w.value, style: e.customStyle }, [t.slots.default && t.slots.default(), a.length > 0 && D(a, E)]), [[Pe("area-response")]]); } function N() { const a = {}; let B = "f-dynamic-form-section--header-content", M = "f-dynamic-form-section--footer"; return e.showHeader && (t.slots.headerTitle && (a.headerTitle = () => { var $, z; return (z = ($ = t.slots).headerTitle) == null ? void 0 : z.call($); }), B += e.headerContentRenderFunction || t.slots.headerContent ? " f-dynamic-form-section--header-cotnent-tmpl" : "", t.slots.headerContent ? a.headerContent = () => { var $, z; return (z = ($ = t.slots).headerContent) == null ? void 0 : z.call($); } : !e.headerContentRenderFunction && i.length > 0 && (a.headerContent = () => Ie(I("div", { class: "f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" }, [V(i)]), [[Pe("area-response")]]))), e.showFooter && (M += e.footerRenderFunction || t.slots.footer ? " f-dynamic-form-section--footer-tmpl" : 0, t.slots.footer ? a.footer = () => { var $, z; return (z = ($ = t.slots).footer) == null ? void 0 : z.call($); } : !e.footerRenderFunction && d.length > 0 && (M += d.length > 0 ? " f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" : "", a.footer = () => V(d))), { slots: a, footerClass: M, headerContentClass: B }; } const G = ee(() => typeof e.toolbar == "function" ? e.toolbar() : e.toolbar), S = ee(() => e.headerStyle ? typeof e.headerStyle == "function" ? e.headerStyle() : e.headerStyle : ""), Z = ee(() => e.footerStyle ? typeof e.footerStyle == "function" ? e.footerStyle() : e.footerStyle : ""); function K(a, B) { t.emit("click", a, B); } function Y() { const { slots: a, footerClass: B, headerContentClass: M } = N(); return I(Bt, { customClass: "f-dynamic-form-section", showHeader: e.showHeader, mainTitle: e.mainTitle, enableAccordion: e.enableAccordion ? "default" : "", headerContentClass: M, footerClass: B, buttons: G.value, headerStyle: S.value, footerStyle: Z.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: K, moreButtonClass: e.moreButtonClass }, { default: () => k(h), ...a }); } return () => e.visible ? e.showHeader || e.showFooter ? Y() : v.value && k(n.value) || !v.value && V(n.value) : null; } }), un = { 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 }, enableTips: { type: Boolean, default: !1 }, tipsContent: { type: [Object, String], default: "" }, linkLabel: { type: String, default: !1 } }, dn = {}, pn = {}, { globalStorageKey: mi } = qe(), mn = { id: { Type: String, default: "" }, /** 是否自动完成 */ autocomplete: { Type: String, default: "off" }, /** 自定义CLASS */ customClass: { Ty