UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,421 lines 61.9 kB
var xe = Object.defineProperty; var Ge = (e, t, i) => t in e ? xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i; var Ce = (e, t, i) => Ge(e, typeof t != "symbol" ? t + "" : t, i); import { defineComponent as ye, ref as O, computed as W, onMounted as Ke, watch as re, withDirectives as Ve, createVNode as x, resolveDirective as Te, reactive as Me, createTextVNode as We, mergeProps as Oe } from "vue"; import { resolveAppearance as _e, createPropsResolver as Ie, schemaResolverMap as Qe, propertyEffectMap as Xe, propertyConfigSchemaMap as Je, schemaMap as Ne } from "../dynamic-resolver/index.esm.js"; import { FormSchemaEntityField$Type as ke, FormSchemaEntityFieldTypeName as we, getCustomClass as Ae, useThirdComponent as ze, isMobilePhone as Ye, useGuid as Pe } from "../common/index.esm.js"; import { cloneDeep as Ze, mergeWith as Se, merge as He } from "lodash-es"; import { LocaleService as De } from "../locale/index.esm.js"; import { loadRegister as et, useComponentManager as tt, useBindingData as ot, useEntityState as nt, useDynamicViewUtils as rt, componentMap as ve, resolverMap as it, componentPropsConverter as at } from "../dynamic-view/index.esm.js"; import st from "../section/index.esm.js"; import lt from "../accordion/index.esm.js"; import ct from "../avatar/index.esm.js"; import ut from "../../designer/button-edit/index.esm.js"; import dt from "../button-group/index.esm.js"; import mt from "../calendar/index.esm.js"; import ft from "../../designer/capsule/index.esm.js"; import Be from "../../designer/checkbox/index.esm.js"; import Le from "../../designer/checkbox-group/index.esm.js"; import pt from "../combo-list/index.esm.js"; import yt from "../combo-tree/index.esm.js"; import gt from "../component/index.esm.js"; import Ct from "../color-picker/index.esm.js"; import ht from "../content-container/index.esm.js"; import Ft from "../../designer/date-picker/index.esm.js"; import bt from "../../designer/data-grid/index.esm.js"; import vt from "../dropdown/index.esm.js"; import Vt from "../../designer/dynamic-form/index.esm.js"; import Tt from "../events-editor/index.esm.js"; import It from "../filter-bar/index.esm.js"; import Mt from "../field-selector/index.esm.js"; import kt from "../binding-selector/index.esm.js"; import wt from "../image-cropper/index.esm.js"; import Pt from "../../designer/input-group/index.esm.js"; import Bt from "../layout/index.esm.js"; import Lt from "../list-nav/index.esm.js"; import Et from "../../designer/list-view/index.esm.js"; import Rt from "../lookup/index.esm.js"; import Ut from "../mapping-editor/index.esm.js"; import Ot from "../nav/index.esm.js"; import Nt from "../number-range/index.esm.js"; import At from "../../designer/number-spinner/index.esm.js"; import Dt from "../order/index.esm.js"; import jt from "../page-header/index.esm.js"; import $t from "../page-footer/index.esm.js"; import qt from "../pagination/index.esm.js"; import xt from "../progress/index.esm.js"; import Gt from "../query-solution/index.esm.js"; import Kt from "../../designer/radio-group/index.esm.js"; import Wt from "../../designer/rate/index.esm.js"; import _t from "../../designer/response-toolbar/index.esm.js"; import Qt from "../response-layout/index.esm.js"; import Xt, { useResponseLayoutEditorSetting as Jt } from "../../designer/response-layout-editor/index.esm.js"; import zt from "../search-box/index.esm.js"; import Yt from "../../designer/section/index.esm.js"; import Zt from "../smoke-detector/index.esm.js"; import St from "../splitter/index.esm.js"; import Ht from "../step/index.esm.js"; import eo from "../../designer/switch/index.esm.js"; import to from "../../designer/tabs/index.esm.js"; import oo from "../../designer/tags/index.esm.js"; import no from "../text/index.esm.js"; import ro from "../../designer/time-picker/index.esm.js"; import io from "../transfer/index.esm.js"; import ao from "../tree-view/index.esm.js"; import so from "../uploader/index.esm.js"; import lo from "../verify-detail/index.esm.js"; import co from "../video/index.esm.js"; import uo from "../../designer/textarea/index.esm.js"; import mo from "../schema-selector/index.esm.js"; import fo from "../../designer/tree-grid/index.esm.js"; import po from "../event-parameter/index.esm.js"; import yo from "../filter-condition-editor/index.esm.js"; import go from "../fieldset/index.esm.js"; import Co from "../sort-condition-editor/index.esm.js"; import ho from "../menu-lookup/index.esm.js"; import Fo from "../../designer/drawer/index.esm.js"; import bo from "../json-editor/index.esm.js"; import vo from "../property-editor/index.esm.js"; import Vo from "../expression-editor/index.esm.js"; import To from "../code-editor/index.esm.js"; import Io from "../html-template/index.esm.js"; import Mo from "../collection-property-editor/index.esm.js"; import ko from "../../designer/modal/index.esm.js"; import wo from "../external-container/index.esm.js"; import Po from "../language-textbox/index.esm.js"; import Bo from "../image/index.esm.js"; import Lo from "../comment/index.esm.js"; import { DgControl as pe, refreshCanvas as Eo, UseTemplateDragAndDropRules as Ro, useDragulaCommonRule as Uo } from "../designer-canvas/index.esm.js"; import { BaseControlProperty as Oo, FormBindingType as me } from "../property-panel/index.esm.js"; const No = "root-viewmodel"; class Ao { constructor(t, i) { Ce(this, "formSchemaUtils"); Ce(this, "controlCreatorUtils"); Ce(this, "designViewModelUtils"); this.resolver = t, this.designerHostService = i, this.formSchemaUtils = this.designerHostService.formSchemaUtils, this.controlCreatorUtils = this.designerHostService.controlCreatorUtils, this.designViewModelUtils = this.designerHostService.designViewModelUtils; } createComponent(t) { const i = this.createComponentRefNode(t), m = this.createComponentNode(t), a = this.createViewModeNode(t), C = this.formSchemaUtils.getFormSchema(); return C.module.viewmodels.push(a), C.module.components.push(m), this.designViewModelUtils.assembleDesignViewModel(), i; } createComponentRefNode(t) { const i = this.resolver.getSchemaByType("component-ref"); return Object.assign(i, { id: `${t.componentId}-component-ref`, component: `${t.componentId}-component` }), i; } createComponentNode(t) { const i = this.resolver.getSchemaByType("component"), m = this.createFormComponentContents(t); return Object.assign(i, { id: `${t.componentId}-component`, viewModel: `${t.componentId}-component-viewmodel`, componentType: t.componentType, appearance: { class: this.getFormComponentClass(t) }, formColumns: t.formColumns, contents: m }), i; } /** * 获取卡片组件层级的class样式 */ getFormComponentClass(t) { var m, a; const { templateId: i } = this.formSchemaUtils.getFormSchema().module; if (i === "double-list-in-tab-template" && ((a = (m = t.parentComponentInstance) == null ? void 0 : m.schema) == null ? void 0 : a.type) === "tab-page") { const C = t.parentComponentInstance.parent && t.parentComponentInstance.parent.schema; if ((C == null ? void 0 : C.type) === "tabs" && (C == null ? void 0 : C.fill) === !0) return "f-struct-wrapper f-utils-fill-flex-column"; } return "f-struct-wrapper"; } createFormComponentContents(t) { var P, M; const i = this.resolver.getSchemaByType("section"); Object.assign(i, { id: t.componentId + "-form-section", appearance: { class: "f-section-form f-section-in-mainsubcard" }, mainTitle: t.componentName }); const m = this.resolver.getSchemaByType("response-form"), a = []; Object.assign(m, { id: t.componentId + "-form", appearance: { class: "f-form-layout farris-form farris-form-controls-inline" }, contents: a, controlsInline: !0 }), i.contents = [m]; const { selectedFields: C } = t; C == null || C.forEach((f) => { if (f.$type === ke.SimpleField) { const E = Ze(f), g = this.resolveControlClassByFormColumns(t), V = this.controlCreatorUtils.setFormFieldProperty(E, "", g); V && a.push(V); } }); const { templateId: v } = this.formSchemaUtils.getFormSchema().module; if (v === "double-list-in-tab-template" && ((M = (P = t.parentComponentInstance) == null ? void 0 : P.schema) == null ? void 0 : M.type) === "tab-page") { const f = t.parentComponentInstance.parent && t.parentComponentInstance.parent.schema; (f == null ? void 0 : f.type) === "tabs" && (f == null ? void 0 : f.fill) === !0 && (i.appearance.class = "f-section-grid f-section-in-main px-0 pt-0", i.fill = !0); } return [i]; } resolveControlClassByFormColumns(t) { let i = ""; switch (t.formColumns) { case 1: { i = "col-12 col-md-12 col-xl-12 col-el-12"; break; } case 2: { i = "col-12 col-md-6 col-xl-6 col-el-6"; break; } case 3: { i = "col-12 col-md-6 col-xl-4 col-el-4"; break; } case 4: { i = "col-12 col-md-6 col-xl-3 col-el-2"; break; } } return i; } /** * 添加viewModel节点 */ createViewModeNode(t) { return { id: `${t.componentId}-component-viewmodel`, code: `${t.componentId}-component-viewmodel`, name: t.componentName, bindTo: t.bindTo, parent: No, fields: this.assembleViewModelFields(t), commands: [], states: [], enableValidation: !0 }; } /** * 组装viewModel fields 节点 */ assembleViewModelFields(t) { const i = [], { selectedFields: m } = t; return m == null || m.forEach((a) => { if (a.$type === ke.SimpleField) { let C = "blur"; const v = a.type.name; (v === we.Enum || v === we.Boolean) && (C = "change"), i.push({ type: "Form", id: a.id, fieldName: a.bindingField, groupId: null, groupName: null, updateOn: C, fieldSchema: {} }); } }), i; } } function je(e, t, i, m) { var C, v, P, M, f, E; const a = i.parentComponentInstance; if (a && m) { const g = (C = a.schema) == null ? void 0 : C.type, U = { componentId: `form-${Math.random().toString(36).slice(2, 6)}`, componentName: ((v = i.bindingSourceContext) == null ? void 0 : v.entityTitle) || ((M = (P = i.bindingSourceContext) == null ? void 0 : P.bindingEntity) == null ? void 0 : M.name) || "标题", componentType: "form", formColumns: g === "splitter-pane" ? 1 : 4, parentContainerId: a.schema.id, parentComponentInstance: a, bindTo: ((f = i.bindingSourceContext) == null ? void 0 : f.bindTo) || "/", selectedFields: (E = i.bindingSourceContext) == null ? void 0 : E.bindingEntityFields }; return new Ao(e, m).createComponent(U); } else return t; } const Do = "https://json-schema.org/draft/2020-12/schema", jo = "https://farris-design.gitee.io/response-form.schema.json", $o = "response-form", qo = "A Farris Data Collection Component", xo = "object", Go = { 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" } }, Ko = [ "id", "type", "contents" ], Wo = { $schema: Do, $id: jo, title: $o, description: qo, type: xo, properties: Go, required: Ko }, $e = /* @__PURE__ */ new Map([ ["appearance", _e] ]), _o = "https://json-schema.org/draft/2020-12/schema", Qo = "https://farris-design.gitee.io/dynamic-form.schema.json", Xo = "dynamic-form", Jo = "A Farris Data Collection Component", zo = "object", Yo = { 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: "" } }, Zo = [ "id", "type", "contents" ], So = { onClick: "点击事件", "onUpdate:modelValue": "值变更事件", event: "事件" }, Ho = { $schema: _o, $id: Qo, title: Xo, description: Jo, type: zo, properties: Yo, required: Zo, events: So }; var ge = /* @__PURE__ */ ((e) => (e.Header = "header", e.Footer = "footer", e))(ge || {}), Fe = /* @__PURE__ */ ((e) => (e.QUICK = "quick", e.FULL = "full", e))(Fe || {}); const be = { 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" } }, en = Object.assign({}, be, { // 是否渲染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: Fe.QUICK }, /** 工具栏 */ toolbar: { type: [Array, Function], default: [] }, /** 设置头部的样式 */ headerStyle: { type: [String, Function], default: "" }, /** 设置底部样式 */ footerStyle: { type: [String, Function], default: "" }, /** 更多按钮样式 */ moreButtonClass: { type: String, default: "btn-link" } }), _r = Ie(be, Wo, $e, je), Qr = Ie(be, Ho, $e, je), he = /* @__PURE__ */ ye({ name: "FDynamicForm", props: en, emits: ["update:modelValue", "event", "click"], setup(e, t) { const i = O(e.fields), m = /* @__PURE__ */ new Map(), a = O(e.callback); et(); const C = tt(), v = O(e.formData || {}), P = ot(v, t); nt(i.value).setup(); const f = /* @__PURE__ */ new Map(), E = O(e.canRenderForm); let g = [], V = [], U = []; const B = e.mode === Fe.FULL ? "contents" : "fields", { mergeArray: _, resolveCallbacks: Y, resolveEvents: z } = rt(), D = W(() => { const o = De.getLocale(), F = e.fields && e.fields.length > 0; let b = { "f-form-layout": F, "farris-form": F, "f-dynamic-form": !(e.showHeader || e.showFooter) }; return b = Ae(b, e.customClass), e.adaptForLanguage && o && (b["farris-form-controls-inline"] = o !== "en"), b; }); function L() { function o(F, b) { const { id: k } = F || {}, { field: $ } = F.binding || {}; return { modelValue: b.getValue(k), "onUpdate:modelValue": (ee) => { b.setValue(k, $ || k, ee); } }; } return { resolve: o }; } function A(o) { const F = L(); return P.getValue(o.id) === void 0 && Object.hasOwnProperty.call(o, "modelValue") && P.setValue(o.id, void 0, o.modelValue), F.resolve(o, P); } function K(o) { const F = {}; return o && Object.entries(o).forEach(([b, k]) => { F[b] = () => Array.isArray(k) ? k.map(($) => oe($)) : oe(k); }), F; } function j(o) { return o.type ? o.type : o[B] ? "fieldset" : "form-group"; } function ie(o) { const F = j(o), b = o.customClass || ""; return b || (F === "fieldset" ? "col-12 px-0" : g.length === 0 && V.length === 0 || o.id && U.find((k) => k[B] ? k[B].find(($) => $.id === o.id) : k.id === o.id) ? e.layout : "unset-item"); } function ae(o) { const F = j(o); let b = {}, k = "", $ = {}, ee = {}; if (e.mode === Fe.FULL) { $ = { ...z(o, t, F) }, ee = { ...Y(o, a, F) }; const G = at[F]; b = G ? G(o) : {}, k = ie(b); } else { k = ie(o); const { fields: G, customClass: H, ...ne } = o; b = ne; } return { props: { ...{ ...b, customClass: k, ...A(o) }, key: o.id, ref: (G) => { if (G && o.id && !C.has(o.id)) { C.register(o.id, G); const H = { token: o.id, name: "component:ready", type: j(o), payloads: [O(G)], schema: o }; t.emit("event", H); } }, onVnodeUnmounted: (G) => { if (o.id && C.has(o.id)) { C.remove(o.id); const H = { token: o.id, name: "component:unmounted", type: j(o), payloads: [G], schema: o }; t.emit("event", H); } } }, eventProps: $, callbackProps: ee }; } function Z(o, F) { return Array.isArray(o) ? o.map((b) => F(b)) : F(o); } function oe(o, F) { var le; const b = j(o), k = ve[b]; if (o.id && m.set(o.id, o), !k) return null; const $ = () => o[B] ? o[B].map((G) => oe(G)) : null, ee = (G, H, ne) => { let de; return ne && ne.length > 0 ? de = x(G, { ...H }, ne) : de = x(G, { ...H }, null), de; }, ue = ((le = f.get(o.id)) == null ? void 0 : le.props) || {}; return o[B] && o[B].length > 0 ? ee(k, ue, [$()]) : o.slots ? ee(k, ue, [...Object.values(K(o.slots))]) : ee(k, ue); } function se(o) { const F = j(o); if (!ve[F]) return; const { props: k, eventProps: $, callbackProps: ee } = ae(o), ue = it[F], le = ue ? ue.editorResolver : null, { componentEventProps: G, editorEventProps: H } = $, { componentCallbackProps: ne, editorCallbackProps: de } = ee; if (G && Object.keys(G).length > 0 && Object.assign(k, G), ne && Object.keys(ne).length > 0 && Object.assign(k, ne), le && H && Object.keys(H).length > 0) { const te = le.resolve(o); Object.assign(te, H); } if (le && de && Object.keys(de).length > 0) { const te = le.resolve(o); Object.assign(te, de); } if (k && Object.keys(k).length > 0) { const te = f.get(o.id); te ? He(te == null ? void 0 : te.props, k) : f.set(o.id, Me({ props: k })); } !o[B] || !Array.isArray(o[B]) || o[B].forEach((te) => se(te)); } function fe(o) { const F = j(o); ve[F] && (ce(o), !(!o[B] || !Array.isArray(o[B])) && o[B].forEach((k) => fe(k))); } function ce(o) { const F = A(o); if (F && Object.keys(F).length > 0) { const b = f.get(o.id); if (!b) f.set(o.id, Me({ props: F })); else { const k = { ...b == null ? void 0 : b.props }; Object.keys(F).forEach(($) => { k[$] = F[$]; }), Object.assign(b == null ? void 0 : b.props, k); } } } Ke(() => { }), re(() => e.formData, (o) => { v.value = o; }), re(() => v.value, () => { Z(i.value, fe); }, { deep: !0 }); function N(o, F = "") { return F ? o.filter((b) => b.position === F) : o.filter((b) => !b.position || [ge.Header, ge.Footer].indexOf(b.position) < 0); } function n(o) { o && (g = N(o, ge.Header), g.length && Z(g, se), V = N(o, ge.Footer), V.length && Z(V, se), U = N(o), U.length && Z(U, se)); } re(() => e.fields, (o) => { m.clear(), C.clear(), v.value = e.formData || {}, f.clear(), i.value = o, n(o); }), n(e.fields); function r(o) { o.$forceUpdate && o.$forceUpdate(); } function d(o) { return P.getValue(o); } function y() { return v.value; } function T(o, F) { P.setValue(o, void 0, F); const b = m.get(o); b && ce(b); } function I(o) { var F; return (F = f.get(o)) == null ? void 0 : F.props; } function w(o, F) { const b = f.get(o); Se(b == null ? void 0 : b.props, F, _); } t.expose({ componentManager: C, rerender: r, getProps: I, setProps: w, getControlValue: d, setControlValue: T, getValues: y }); function h(o = []) { return o.length > 0 && Z(o, oe); } function p(o) { return Ve(x("div", { class: D.value, style: e.customStyle }, [t.slots.default && t.slots.default(), o.length > 0 && Z(o, oe)]), [[Te("area-response")]]); } function R() { const o = {}; let F = "f-dynamic-form-section--header-content", b = "f-dynamic-form-section--footer"; return e.showHeader && (t.slots.headerTitle && (o.headerTitle = () => { var k, $; return ($ = (k = t.slots).headerTitle) == null ? void 0 : $.call(k); }), F += e.headerContentRenderFunction || t.slots.headerContent ? " f-dynamic-form-section--header-cotnent-tmpl" : "", t.slots.headerContent ? o.headerContent = () => { var k, $; return ($ = (k = t.slots).headerContent) == null ? void 0 : $.call(k); } : !e.headerContentRenderFunction && g.length > 0 && (o.headerContent = () => Ve(x("div", { class: "f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" }, [h(g)]), [[Te("area-response")]]))), e.showFooter && (b += e.footerRenderFunction || t.slots.footer ? " f-dynamic-form-section--footer-tmpl" : 0, t.slots.footer ? o.footer = () => { var k, $; return ($ = (k = t.slots).footer) == null ? void 0 : $.call(k); } : !e.footerRenderFunction && V.length > 0 && (b += V.length > 0 ? " f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" : "", o.footer = () => h(V))), { slots: o, footerClass: b, headerContentClass: F }; } const q = W(() => typeof e.toolbar == "function" ? e.toolbar() : e.toolbar), S = W(() => e.headerStyle ? typeof e.headerStyle == "function" ? e.headerStyle() : e.headerStyle : ""), Q = W(() => e.footerStyle ? typeof e.footerStyle == "function" ? e.footerStyle() : e.footerStyle : ""); function J(o, F) { t.emit("click", o, F); } function X() { const { slots: o, footerClass: F, headerContentClass: b } = R(); return x(st, { customClass: "f-dynamic-form-section", showHeader: e.showHeader, mainTitle: e.mainTitle, enableAccordion: e.enableAccordion ? "default" : "", headerContentClass: b, footerClass: F, buttons: q.value, headerStyle: S.value, footerStyle: Q.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: J, moreButtonClass: e.moreButtonClass }, { default: () => p(U), ...o }); } return () => e.visible ? e.showHeader || e.showFooter ? X() : E.value && p(i.value) || !E.value && h(i.value) : null; } }), Ee = /* @__PURE__ */ ye({ name: "FResponseForm", props: be, emits: [], setup(e, t) { var g; const i = O(), m = O(), a = W(() => { const V = De.getLocale(), U = e.fields && e.fields.length > 0; let B = { "drag-container": !0, "f-form-layout": U, "farris-form": U }; return B = Ae(B, e.customClass), e.adaptForLanguage && V && (B["farris-form-controls-inline"] = V !== "en"), B; }), C = (g = m.value) == null ? void 0 : g.componentManager; function v(V) { m.value.render(V); } function P(V) { return m.value.getControlValue(V); } function M(V, U) { m.value.setControlValue(V, U); } function f(V) { return m.value.getProps(V); } function E(V, U) { m.value.setProps(V, U); } return t.expose({ componentManager: C, rerender: v, getProps: f, setProps: E, getControlValue: P, setControlValue: M }), () => e.visible && Ve(x("div", { ref: i, class: a.value, style: e.customStyle }, [t.slots.default && t.slots.default(), e.fields && e.fields.length > 0 && x(he, { ref: m, fields: e.fields, canRenderForm: !1, formData: e.formData, layout: e.layout }, null)]), [[Te("area-response")]]); } }), tn = { 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 } }, on = { id: { type: String }, required: { type: Boolean, default: !1 }, text: { type: String, default: "" }, title: { type: String }, valid: { type: Boolean, default: !0 }, inValidTip: { type: String, default: "" }, /** * 实际支持 'visible'可见 | 'reserve-space' 占位不显示 */ showType: { type: String, default: "visible" }, isLink: { type: Boolean, default: !1 } }, nn = /* @__PURE__ */ ye({ name: "FDynamicFormLabel", props: on, emits: ["clickLabel"], setup(e, t) { O(e.title || e.text); const i = O(e.required), m = O(e.text), a = O(e.valid), C = O(e.inValidTip); re(() => e.text, () => { m.value = e.text; }), re(() => e.required, (V, U) => { V !== U && (i.value = V); }), re([() => e.valid, () => e.inValidTip], ([V, U]) => { a.value = V, C.value = U; }); const v = W(() => a.value ? m.value : C.value), P = W(() => a.value ? "" : "color:red"), M = W(() => ({ "col-form-label": !0, // 指定必填,当显示模式是隐藏或者没有指定标签名时,宽度不限定 "f-width-auto": i.value && (e.showType === "none" || !m.value) })), f = W(() => e.showType === "force-none" ? !1 : e.showType === "reserve-space" || i.value || !!m.value && e.showType !== "none"), E = () => { e.showType !== "reserve-space" && t.emit("clickLabel"); }, g = W(() => ({ "farris-label-text": !0, "f-pretend-link": !!e.isLink && e.showType !== "reserve-space" })); return () => f.value && x("label", { class: M.value, title: v.value, style: P.value }, [!a.value && x("span", { class: "f-icon f-icon-warning mr-1", style: "color: red; min-width: 16px;", title: C.value }, null), x("span", { class: g.value, onClick: E }, [i.value && x("span", { class: "farris-label-info text-danger" }, [We("*")]), e.showType === "visible" && m.value])]); } }), { globalStorageKey: rn } = ze(), s = {}, l = {}, c = {}, u = {}; async function an() { { const e = { schemaMap: Ne, propertyConfigSchemaMap: Je, propertyEffectMap: Xe, schemaResolverMap: Qe }; ct.register(s, l, c, u), lt.register(s, l, c, u), ut.register(s, l, c, u), dt.register(s, l, c, u), mt.register(s, l, c, u, e), ft.register(s, l, c, u), Be.register(s, l, c, u, e), Le.register(s, l, c, u, e), Be.register(s, l, c, u, e), Le.register(s, l, c, u, e), pt.register(s, l, c, u, e), yt.register(s, l, c, u), gt.register(s, l, c, u), ht.register(s, l, c, u, e), Ct.register(s, l, c, u), Ft.register(s, l, c, u, e), bt.register(s, l, c, u, e), vt.register(s, l, c, u), Vt.register(s, l, c, u, e), Tt.register(s, l, c, u), Vo.register(s, l, c, u), It.register(s, l, c, u), Mt.register(s, l, c, u), yo.register(s, l, c, u), wt.register(s, l, c, u), Pt.register(s, l, c, u, e), Bt.register(s, l, c, u, e), Et.register(s, l, c, u, e), Lt.register(s, l, c, u), Rt.register(s, l, c, u, e), Ut.register(s, l, c, u), Ot.register(s, l, c, u), Nt.register(s, l, c, u), At.register(s, l, c, u, e), Dt.register(s, l, c, u), jt.register(s, l, c, u, e), $t.register(s, l, c, u), qt.register(s, l, c, u), xt.register(s, l, c, u), Gt.register(s, l, c, u, e), Kt.register(s, l, c, u, e), Wt.register(s, l, c, u), Qt.register(s, l, c, u, e), Xt.register(s, l, c, u), _t.register(s, l, c, u), mo.register(s, l, c), zt.register(s, l, c, u), Yt.register(s, l, c, u, e), Zt.register(s, l, c, u), St.register(s, l, c, u), Ht.register(s, l, c, u), eo.register(s, l, c, u, e), Co.register(s, l, c, u), to.register(s, l, c, u, e), oo.register(s, l, c, u), no.register(s, l, c, u), ro.register(s, l, c, u, e), io.register(s, l, c, u), ao.register(s, l, c, u), lo.register(s, l, c, u), so.register(s, l, c, u), co.register(s, l, c, u), uo.register(s, l, c, u, e), fo.register(s, l, c, u), kt.register(s, l, c, u), po.register(s, l, c, u), go.register(s, l, c, u, e), ho.register(s, l, c, u), Fo.register(s, l, c, u), bo.register(s, l, c, u), vo.register(s, l, c, u), To.register(s, l, c, u), Io.register(s, l, c, u, e), Mo.register(s, l, c, u), ko.register(s, l, c, u), wo.register(s, l, c, u), Po.register(s, l, c, u, e), Bo.register(s, l, c, u, e), Lo.register(s, l, c, u); const t = window[rn]; if (t) for (const i in t) t[i].createPropsResolver = Ie, t[i].register(s, l, c); } } function qe() { an(); function e(v) { const P = s[v]; if (!P) throw new Error(`Could not find the editor of type '${v}'`); return P; } function t(v, P) { const M = l[v]; return M ? M(P) : {}; } function i(v) { switch (v) { case "check-box": return "onChangeValue"; case "switch": return "onModelValueChanged"; case "check-group": return "onChangeValue"; case "combo-list": case "combo-tree": return "onChange"; case "combo-lookup": return ""; case "year-range": case "year-picker": case "month-range": case "month-picker": case "date-range": case "datetime-range": case "datetime-picker": return "onDatePicked"; case "date-picker": return "onUpdate:modelValue"; case "time-picker": return "onValueChange"; case "input-group": return "onChange"; case "lookup": case "sort-condition-editor": case "filter-condition-editor": case "code-editor": case "language-textbox": case "rich-text-editor": return "onUpdate:modelValue"; case "number-range": return "onValueChange"; case "number-spinner": return "onValueChange"; case "radio-group": return "onChangeValue"; case "text": return ""; case "events-editor": return "onSavedCommandListChanged"; case "grid-field-editor": case "item-collection-editor": case "response-form-layout-setting": case "response-layout-editor-setting": case "response-layout-splitter": case "menu-lookup": case "json-editor": return "onChange"; case "field-selector": case "binding-selector": return "onFieldSelected"; case "schema-selector": return "onSchemaSelected"; case "mapping-editor": return "onMappingFieldsChanged"; case "textarea": return "onChange"; case "query-solution-config": case "solution-preset": case "filter-bar-config": return "onFieldsChanged"; case "property-editor": return "onValueChange"; case "expression-editor": return "onExpressionChanged"; case "collection-property-editor": return "onValueChange"; default: return "onUpdate:modelValue"; } } function m(v) { switch (v) { case "combo-list": case "input-group": case "textarea": return "onClear"; } } function a(v) { switch (v) { case "input-group": case "textarea": return "onMousedownEvent"; } } function C(v) { switch (v) { case "input-group": case "textarea": return "onMouseupEvent"; } } return { resolveEditorProps: t, resolveEditorType: e, getChangeFunctionName: i, getClearFunctionName: m, getMousedownFunctionName: a, getMouseupFunctionName: C }; } const sn = { /** * 显示的错误信息 */ errors: { type: Object, default: null } }, ln = /* @__PURE__ */ ye({ name: "FValidationMessage", props: sn, emits: [], setup(e, t) { const i = O(e.errors); re(() => e.errors, (C) => { i.value = C; }); const m = O(!0), a = W(() => { if (i.value) { const C = Object.keys(i.value).map((v) => { var P; return (P = i.value[v]) == null ? void 0 : P.name; }); return C.length ? C.join(" ") : ""; } return ""; }); return () => a.value && x("div", { class: "farris-feedback f-state-invalid", onClick: () => m.value = !m.value }, [!m.value && x("span", { class: "f-icon f-icon-message_warning f-feedback-icon" }, null), m.value && x("span", { class: "f-feedback-message" }, [a.value])]); } }), Re = /* @__PURE__ */ ye({ name: "FDynamicFormGroup", props: tn, emits: ["change", "update:modelValue", "clickLabel"], setup(e, t) { var ce; const i = O(e.id), m = O(e.customClass), a = O(e.editor), C = O(e.label), v = O(e.modelValue), P = O(e.readonly), M = O(((ce = e.editor) == null ? void 0 : ce.required) || e.required), f = O(e.showLabel), E = O(e.visible); O(e.type); const g = O(), V = O(e.errors), U = Ye(), B = O(e.editor.type || "input-group"), _ = W(() => f.value ? e.showLabelType : "none"), { resolveEditorProps: Y, resolveEditorType: z, getChangeFunctionName: D, getClearFunctionName: L } = qe(), A = W(() => { const N = { "form-group": !0, "farris-form-group": !0, "common-group": !0, "q-state-readonly": P.value, "form-group--in-mobile": U }; return N["form-group--has-" + B.value] = !0, N; }), K = W(() => { if (e.fill) return { maxWidth: "none" }; }); function j(N, n, r) { v.value = n !== void 0 ? n : N, t.emit("update:modelValue", v.value), t.emit("change", v.value, { newValue: N, newModelValue: n, parameters: r }); } function ie() { t.emit("update:modelValue", ""); } function ae(N) { return (...n) => { ie(), typeof N == "function" && N(...n); }; } function Z(N) { return (n, r, d) => { j(n, r, d), typeof N == "function" && N(n, r, d); }; } const oe = W(() => { const N = a.value.type || "input-group", n = z(N), r = Y(N, a.value), d = D(N), y = L(a.value.type); return y && (r[y] = ae(r[y])), d && (r[d] = Z(r[d])), (r.id == null || r.id === "") && (r.id = i.value), N === "number-range" && a.value.onBeginValueChange && typeof a.value.onBeginValueChange == "function" ? (a.value.onBeginValueChange && typeof a.value.onBeginValueChange == "function" && (r.onBeginValueChange = a.value.onBeginValueChange), a.value.onEndValueChange && typeof a.value.onEndValueChange == "function" && (r.onEndValueChange = a.value.onEndValueChange)) : N === "lookup" && a.value["onUpdate:idValue"] && typeof a.value["onUpdate:idValue"] == "function" ? (r["onUpdate:idValue"] = a.value["onUpdate:idValue"], r.id = i.value) : N === "collection-property-editor" && a.value.onSelectionChange && typeof a.value.onSelectionChange == "function" ? r.onSelectionChange = a.value.onSelectionChange : N === "property-editor" && (r.onBeforeOpenVariables = a.value.onBeforeOpenVariables), () => x(n, Oe({ ref: g }, r, { modelValue: v.value, "onUpdate:modelValue": (T) => v.value = T }), t.slots); }); function se() { return x(ln, { id: `${i.value}-validation-message`, errors: V.value }, null); } re([() => e.id, () => e.customClass, () => e.editor, () => e.label, () => e.modelValue, () => e.readonly, () => e.required, () => e.showLabel, () => e.visible, () => e.errors], ([N, n, r, d, y, T, I, w, h, p]) => { var R; i.value = N, m.value = n, a.value = r, C.value = d, v.value = y, P.value = T, M.value = ((R = a.value) == null ? void 0 : R.required) || I, f.value = w, E.value = h, V.value = p; }); function fe(N) { t.emit("clickLabel", N); } return t.expose({ editorRef: g }), () => E.value && x("div", { id: `${i.value}-form-group`, class: m.value, style: e.customStyle }, [x("div", { class: "farris-group-wrap", style: K.value }, [x("div", { class: A.value }, [x(nn, { id: `${i.value}-lable`, showType: _.value, required: M.value, text: C.value, title: C.value, isLink: !!e.linkLabel, onClickLabel: fe }, null), x("div", { class: "farris-input-wrap" }, [oe.value(), se()])])])]); } }), cn = { id: { type: String, default: "" }, /** 筛选组件配置器,具体配置项可查看各组件文档 */ editor: { type: Object, default: {} }, /** value is uncertain because type is uncertain, default value should not be set */ modelValue: { type: [String, Boolean, Array, Number] }, /** * 作为内嵌编辑器被创建后默认获得焦点 */ focusOnCreated: { type: Boolean, default: !1 }, /** * 作为内嵌编辑器被创建后默认选中文本 */ selectOnCreated: { type: Boolean, default: !1 } }, Ue = /* @__PURE__ */ ye({ name: "FDynamicFormInput", props: cn, emits: ["change", "update:modelValue", "mousedown", "mouseup"], setup(e, t) { const i = O(e.id), m = O(e.editor), a = O(e.modelValue), { resolveEditorProps: C, resolveEditorType: v, getChangeFunctionName: P, getMousedownFunctionName: M, getMouseupFunctionName: f, getClearFunctionName: E } = qe(); function g(D, L, A) { a.value = L !== void 0 ? L : D, t.emit("update:modelValue", a.value), t.emit("change", a.value, { newValue: D, newModelValue: L, parameters: A }); } function V(D) { t.emit("mousedown", D); } function U(D) { t.emit("mouseup", D); } function B() { t.emit("update:modelValue", ""); } function _(D) { return (...L) => { B(), typeof D == "function" && D(...L); }; } function Y(D) { return (L, A, K) => { g(L, A, K), typeof D == "function" && D(L, A, K); }; } const z = W(() => { const D = v(m.value.type), L = C(m.value.type, m.value); L.focusOnCreated = e.focusOnCreated, L.selectOnCreated = e.selectOnCreated; const A = P(m.value.type), K = E(m.value.type); K && (L[K] = _(L[K])), A && (L[A] = Y(L[A])); const j = M(m.value.type); L[j] = V; const ie = f(m.value.type); return L[ie] = U, L.id = i.value, () => x(D, Oe(L, { modelValue: a.value, "onUpdate:modelValue": (ae) => a.value = ae }), null); }); return re([() => e.id, () => e.editor, () => e.modelValue], ([D, L, A]) => { i.value = D, m.value = L, a.value = A; }), () => z.value(); } }); function un(e, t) { function i(M, f = null) { if (f) return f; const E = e.getComponentById(t); return e.selectNode(E, (g) => g.id === M); } function m(M) { const f = e.getComponentById(M); return !(!f || !f.componentType || !f.componentType.startsWith("form")); } function a(M) { const f = new Set(M); return Array.from(f).length === 1; } function C(M) { const f = i(M.id), E = Jt(e), g = []; E.getResonseFormLayoutConfig(f, g, 1); const V = g.map((A) => A.columnInSM), U = g.map((A) => A.columnInMD), B = g.map((A) => A.columnInLG), _ = g.map((A) => A.columnInEL), Y = a(V) ? V[0] : 0, z = a(U) ? U[0] : 0, D = a(B) ? B[0] : 0, L = a(_) ? _[0] : 0; return { uniqueColClassInSM: Y, uniqueColClassInMD: z, uniqueColClassInLG: D, uniqueColClassInEL: L }; } function v(M, f) { let E, g, V, U, B = []; if (M) { const A = M.split(" "), K = A.filter((j) => j.startsWith("col-")); E = K.find((j) => /^col-([1-9]|10|11|12)$/.test(j)), g = K.find((j) => /^col-md-([1-9]|10|11|12)$/.test(j)), V = K.find((j) => /^col-xl-([1-9]|10|11|12)$/.test(j)), U = K.find((j) => /^col-el-([1-9]|10|11|12)$/.test(j)), B = A.filter((j) => !j.startsWith("col-")); } const _ = f.uniqueColClassInSM ? "col-" + f.uniqueColClassInSM : E, Y = f.uniqueColClassInMD ? "col-md-" + f.uniqueColClassInMD : g, z = f.uniqueColClassInLG ? "col-xl-" + f.uniqueColClassInLG : V, D = f.uniqueColClassInEL ? "col-el-" + f.uniqueColClassInEL : U; return [_, Y, z, D].concat(B).join(" "); } function P(M, f, E) { M = i(E, M), M.contents.forEach((g) => { if (g.type === pe["dynamic-form"].type) return; if (g.type === pe.fieldset.type) { P(g, f, g.id); return; } g.appearance || (g.appearance = {}); const V = g.appearance.class; g.appearance.class = v(V, f); }); } return { checkIsInFormComponent: m, assembleUnifiedLayoutContext: C, changeFormControlsByUnifiedLayoutConfig: P, changeControlClassInByColumn: v }; } class dn extends Oo { constructor(t, i) { super(t, i); } getPropertyConfig(t, i) { const m = this; this.propertyConfig.categories.basic = this.getBasicPropConfig(t); const { checkIsInFormComponent: a, assembleUnifiedLayoutContext: C, changeFormControlsByUnifiedLayoutConfig: v, changeControlClassInByColumn: P } = un(this.formSchemaUtils, this.componentId), M = this.getAppearanceConfig(t), f = a(this.componentId); M.properties.adaptForLanguage = { title: "控件布局响应国际化", description: "启用国际化后:简体中文、繁体中文环境下控件标签与输入框在一行展示,其他语言环境下控件标签与输入框上下排列。", visible: t.formType === "dynamic" || f, type: "boolean" }, M.properties.labelAutoOverflow = { title: "控件标签换行", description: "控件标签字数超长时,换行显示。控件标签与输入框在一行展示时,此属性有效。", visible: t.formType === "dynamic" || f, type: "boolean" }, M.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 }, M.properties.unifiedLayout = { title: "统一布局配置", description: "统一配置卡片区域内所有控件的宽度,只支持标准模式", visible: t.formType === "dynamic" || f, refreshPanelAfterChanged: !0, editor: { type: "response-form-layout-setting", initialState: C(t) } }, M.setPropertyRelates = function(g, V) { if (g) switch (g && g.propertyID) { case "unifiedLayout": { t.formType === "dynamic" ? t.layout = P("", g.propertyValue) : (v(null, g.propertyValue, t.id), m.updateElementByParentContainer(t.id, i)); break; } case "labelAutoOverflow": { m.setLabelAutoOverflow(t, g.propertyValue), Eo(); break; } } }, this.propertyConfig.categories.appearance = M; let E = {}; if (t.formType && ["dynamic", "mixed"].indexOf(t.formType) > -1) { const g = this.getPropertyEditorParams(t, ["Variable", "Custom"], "fields", {}, { newVariablePrefix: "", newVariableType: "Array" }), V = this.getPropertyEditorParams(t, ["Variable", "Custom"], "formData", {}, { newVariablePrefix: "", newVariableType: "Object" }); E = { fields: { title: "动态控件列表", type: "string", description: "动态控件列表", editor: g }, formData: { title: "动态控件列表初始值", type: "string", description: "动态控件列表初始值", editor: V } }; } return this.propertyConfig.categories.behavior = this.getBehaviorConfig(t, "", E, (g, V) => { switch (g.propertyID) { case "fields": case "formData": m.afterMutilEditorChanged(t, g); break; } }), this.propertyConfig; } setLabelAutoOverflow(t, i, m) { if (!m) { const a = this.formSchemaUtils.getComponentById(this.componentId); m = this.formSchemaUtils.selectNode(a, (C) => C.id === t.id); } m && m.contents && m.contents.length && m.contents.forEach((a) => { if (a.type === pe.fieldset.type) { this.setLabelAutoOverflow(null, i, a); return; } a.appearance || (a.appearance = { class: "" }), a.appearance.class || (a.appearance.class = ""), i ? a.appearance.class.includes("farris-group-multi-label") || (a.appearance.class = a.appearance.class + " farris-group-multi-label") : a.appearance.class = a.appearance.class.replace("farris-group-multi-label", "").trim(); }); } } function Xr(e, t) { const i = e.schema, m = new Ro(), { canMove: a, canAccept: C, canDelete: v } = m.getTemplateRule(e, t); function P(n, r) { const { sourceElement: d } = n, { componentInstance: y } = d, T = t == null ? void 0 : t.formSchemaUtils; if (!T) return !0; const I = T.getComponentById(y.value.belongedComponentId), w = T.getViewModelById(I.viewModel), h = T.getComponentById(e.componentInstance.value.belongedComponentId), p = T.getViewModelById(h.viewModel); return r ? w != null && w.id && (p != null && p.id) && w.id !== p.id ? w.bindTo === p.bindTo : !0 : (w == null ? void 0 : w.id) === (p == null ? void 0 : p.id); } function M(n) { const { bindingTargetId: r } = n; if (!t) return; const { formSchemaUtils: d, schemaService: y } = t, T = d.getComponentById(e.componentInstance.value.belongedComponentId), I = y.getFieldByIDAndVMID(r, T.viewModel); return !!(I != null && I.schemaField); } function f(n) { const r = m.getComponentContext(e); if (r && r.componentClassList && r.componentClassList.includes("f-form-layout") && r.componentClassList.include