UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

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