UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,522 lines 133 kB
var gt = Object.defineProperty; var vt = (e, t, n) => t in e ? gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var I = (e, t, n) => vt(e, typeof t != "symbol" ? t + "" : t, n); import { ref as N, computed as _, watch as K, defineComponent as ee, onBeforeUnmount as Je, withDirectives as he, createVNode as L, resolveDirective as be, onMounted as Le, reactive as je, createTextVNode as Qe, mergeProps as Te, Fragment as yt, inject as pe } from "vue"; import { FDynamicFormGroup as ht, dynamicFormGroupProps as bt, FDynamicFormLabel as Ft } from "../dynamic-form/index.esm.js"; import { cloneDeep as fe, mergeWith as Ct, merge as Tt, isPlainObject as Re } from "lodash-es"; import { useDateFormat as Xe, resolveField as kt, useNumberFormat as Vt, FormSchemaEntityField$Type as $e, FormSchemaEntityFieldTypeName as Ae, getCustomClass as Ye, useThirdComponent as De, isMobilePhone as wt, useTextBoxDesign as xt, areaResponseDirective as St } from "../common/index.esm.js"; import { LocaleService as ve } from "../locale/index.esm.js"; import { resolveAppearance as Et, createPropsResolver as Oe, schemaResolverMap as Pt, propertyEffectMap as It, propertyConfigSchemaMap as Lt, schemaMap as Ot, propertyConfigSchemaMapForDesigner as Mt } from "../dynamic-resolver/index.esm.js"; import { loadRegister as Bt, useComponentManager as Nt, useBindingData as jt, useEntityState as Rt, useDynamicViewUtils as $t, componentMap as xe, resolverMap as At, componentPropsConverter as qt } from "../dynamic-view/index.esm.js"; import Ut from "../section/index.esm.js"; import Gt from "../accordion/index.esm.js"; import zt from "../avatar/index.esm.js"; import Wt from "../../designer/button-edit/index.esm.js"; import Zt from "../button-group/index.esm.js"; import Ht from "../calendar/index.esm.js"; import _t from "../../designer/capsule/index.esm.js"; import qe from "../../designer/checkbox/index.esm.js"; import Ue from "../../designer/checkbox-group/index.esm.js"; import Ee from "../combo-list/index.esm.js"; import Jt from "../combo-tree/index.esm.js"; import Qt from "../component/index.esm.js"; import Xt from "../color-picker/index.esm.js"; import Yt from "../content-container/index.esm.js"; import Dt from "../../designer/date-picker/index.esm.js"; import Kt from "../../designer/data-grid/index.esm.js"; import en from "../dropdown/index.esm.js"; import tn from "../../designer/dynamic-form/index.esm.js"; import nn from "../events-editor/index.esm.js"; import on from "../filter-bar/index.esm.js"; import rn from "../field-selector/index.esm.js"; import sn from "../binding-selector/index.esm.js"; import ln from "../image-cropper/index.esm.js"; import an from "../../designer/input-group/index.esm.js"; import un from "../layout/index.esm.js"; import cn from "../list-nav/index.esm.js"; import dn from "../../designer/list-view/index.esm.js"; import mn from "../lookup/index.esm.js"; import pn from "../mapping-editor/index.esm.js"; import fn from "../nav/index.esm.js"; import gn from "../number-range/index.esm.js"; import vn from "../../designer/number-spinner/index.esm.js"; import yn from "../order/index.esm.js"; import hn from "../page-header/index.esm.js"; import bn from "../page-footer/index.esm.js"; import Fn from "../pagination/index.esm.js"; import Cn from "../progress/index.esm.js"; import Tn from "../query-solution/index.esm.js"; import kn from "../../designer/radio-group/index.esm.js"; import Vn from "../../designer/rate/index.esm.js"; import wn from "../../designer/response-toolbar/index.esm.js"; import xn from "../response-layout/index.esm.js"; import Sn from "../../designer/response-layout-editor/index.esm.js"; import En from "../search-box/index.esm.js"; import Pn from "../../designer/section/index.esm.js"; import In from "../smoke-detector/index.esm.js"; import Ln from "../splitter/index.esm.js"; import On from "../step/index.esm.js"; import Mn from "../../designer/switch/index.esm.js"; import Bn from "../../designer/tabs/index.esm.js"; import Nn from "../../designer/tags/index.esm.js"; import jn from "../text/index.esm.js"; import Rn from "../../designer/time-picker/index.esm.js"; import $n from "../transfer/index.esm.js"; import An from "../tree-view/index.esm.js"; import qn from "../uploader/index.esm.js"; import Un from "../verify-detail/index.esm.js"; import Gn from "../video/index.esm.js"; import zn from "../../designer/textarea/index.esm.js"; import Wn from "../schema-selector/index.esm.js"; import Zn from "../../designer/tree-grid/index.esm.js"; import Hn from "../event-parameter/index.esm.js"; import _n from "../filter-condition-editor/index.esm.js"; import Jn from "../fieldset/index.esm.js"; import Qn from "../sort-condition-editor/index.esm.js"; import Xn from "../menu-lookup/index.esm.js"; import Yn from "../../designer/drawer/index.esm.js"; import Dn from "../json-editor/index.esm.js"; import Kn from "../property-editor/index.esm.js"; import eo from "../expression-editor/index.esm.js"; import to from "../code-editor/index.esm.js"; import no from "../html-template/index.esm.js"; import oo from "../collection-property-editor/index.esm.js"; import ro from "../../designer/modal/index.esm.js"; import io from "../external-container/index.esm.js"; import so from "../language-textbox/index.esm.js"; import lo from "../image/index.esm.js"; import ao from "../comment/index.esm.js"; import { useDesignerComponent as Ke, DgControl as T } from "../designer-canvas/index.esm.js"; import { InputBaseProperty as uo } from "../property-panel/index.esm.js"; const Me = { conditions: { type: Array, default: [] }, fields: { type: Array, default: [] }, key: { type: String, default: "" }, /** * 控件标签同行展示 */ isControlInline: { type: [Boolean, String], default: "auto", validator: (e) => [!0, !1, "auto"].includes(e) }, /** * 条件项统一的样式 */ itemClass: { type: Boolean, default: "col-12 col-md-6 col-xl-3 col-el-2" } }; class co { constructor(t = { value: [] }, n) { I(this, "editorType", "check-box"); I(this, "value"); I(this, "valueType", "boolean"); // 编辑器配置 I(this, "editiorConfig"); const r = (Array.isArray(t.value) ? t.value : typeof t.value == "string" ? t.value.split(",") : []).map((c) => JSON.parse(c)); this.value = r, this.editiorConfig = Object.assign({}, n); } clear() { this.value = []; } setValue(t) { this.value = t; } getValue() { return this.value; } getDisplayText() { return this.value.map((t) => t ? "是" : "否").join(","); } isEmpty() { return this.value.length === 0; } } class mo { constructor(t = { textValue: "", value: "", valueField: "" }, n) { I(this, "editorType", "combo-lookup"); I(this, "textValue"); I(this, "value"); I(this, "valueField"); I(this, "valueType", "text"); // 编辑器配置 I(this, "editiorConfig"); this.textValue = t == null ? void 0 : t.textValue, this.value = t == null ? void 0 : t.value, this.editiorConfig = Object.assign({}, n), this.valueField = t == null ? void 0 : t.valueField; } clear() { this.value = "", this.valueField = "", this.textValue = ""; } getPropValue(t, n) { if (n.length > 1) { const o = n.shift(); return t[o] ? this.getPropValue(t[o], n) : null; } return t[n[0]]; } getTextValue(t) { const n = t.split("."), o = this.value.split(",").map((r) => this.getPropValue(r, fe(n))); return o && o.length ? o.join(",") : ""; } getValue() { const t = this.valueField.split("."), n = this.value.split(",").map((o) => this.getPropValue(o, fe(t))); return n && n.length ? n.join(",") : ""; } getDisplayText() { return this.getValue(); } setValue(t) { throw new Error("Method not implemented."); } isEmpty() { return !this.valueField; } } class ke { constructor(t = { value: "", displayFormat: "", valueFormat: "" }, n) { I(this, "editorType", "date-picker"); I(this, "value"); I(this, "valueType", "datetime"); I(this, "displayFormat", ""); I(this, "valueFormat", ""); // 编辑器配置 I(this, "editiorConfig"); this.value = t == null ? void 0 : t.value, this.editiorConfig = Object.assign({}, n), this.displayFormat = (t == null ? void 0 : t.displayFormat) || (n == null ? void 0 : n.displayFormat) || "", this.valueFormat = (t == null ? void 0 : t.valueFormat) || (n == null ? void 0 : n.valueFormat) || ""; } formatValue() { const { formatTo: t, parseToDate: n } = Xe(); if (!this.value) return ""; const o = n(this.value, this.valueFormat); return t(o, this.displayFormat); } setValue(t) { this.value = t; } getValue() { return this.value; } getDisplayText() { return this.formatValue(); } isEmpty() { return !this.value; } clear() { this.value = void 0; } } class Be { constructor(t = { begin: "", end: "", displayFormat: "", valueFormat: "" }, n = {}) { I(this, "editorType", "date-range"); I(this, "begin", ""); I(this, "end", ""); I(this, "valueType", "datetime"); I(this, "value", ""); // 编辑器配置 I(this, "editiorConfig"); I(this, "displayFormat", ""); I(this, "valueFormat", ""); this.begin = (t == null ? void 0 : t.begin) || "", this.end = (t == null ? void 0 : t.end) || "", this.editiorConfig = Object.assign({}, n, { delimiter: "~" }), this.displayFormat = (t == null ? void 0 : t.displayFormat) || (n == null ? void 0 : n.displayFormat) || "", this.valueFormat = (t == null ? void 0 : t.valueFormat) || (n == null ? void 0 : n.valueFormat) || "", this.value = (this.begin === null ? "" : this.begin) + "~" + (this.end === null ? "" : this.end); } clear() { this.begin = "", this.end = "", this.value = ""; } formatValue(t) { const { formatTo: n, parseToDate: o } = Xe(); if (!t) return ""; const r = o(t, this.valueFormat); return n(r, this.displayFormat); } getValue() { return { begin: this.begin, end: this.end }; } // TODO getDisplayText() { return !this.begin && !this.end ? "" : (this.begin === null ? "" : this.formatValue(this.begin)) + "~" + (this.end === null ? "" : this.formatValue(this.end)); } setValue(t) { if (t) { const n = t.split(this.editiorConfig.delimiter); this.begin = n[0] || "", this.end = n[1] || "", this.value = t; } else this.clear(); } isEmpty() { return !this.begin && !this.end; } } class et { constructor(t = { value: "", valueList: [] }, n) { I(this, "editorType", "combo-list"); I(this, "value"); I(this, "valueType", "enum"); I(this, "valueList", []); // 编辑器配置 I(this, "editiorConfig"); this.value = t == null ? void 0 : t.value, this.editiorConfig = Object.assign({}, n), this.editiorConfig.data && this.editiorConfig.data.length ? this.valueList = this.editiorConfig.data : this.valueList = (t == null ? void 0 : t.valueList) || []; } clear() { const t = typeof this.value; this.value = t === "string" ? "" : void 0; } /** * 更新数据源 */ updateData(t) { this.valueList = [...t]; } getValue() { return this.value; } getDisplayText() { var r, c; const t = typeof this.value; let n = "", o = []; switch (t) { case "string": o = this.value.split(",") || [], n = this.valueList.filter((i) => o.indexOf(i.value + "") > -1).map((i) => i.name).join(","); break; case "boolean": n = ((r = this.valueList.find((i) => i.value === this.value)) == null ? void 0 : r.name) || ""; break; case "number": n = ((c = this.valueList.find((i) => i.value === this.value)) == null ? void 0 : c.name) || ""; break; } return n; } // setValue(data: { value: string; displayText: string }) { // // this.displayText = data.dispalyText; // const enumValues = getEnumValues(data); // this.value = enumValues; // return this.displayText; // } setValue(t) { this.value = t.value; } isEmpty() { return !this.value && this.value !== !1 && this.value !== 0; } } class po { constructor(t = { value: "", displayText: "", displayField: "", isInputText: !1 }, n) { I(this, "editorType", "input-group"); // 通过弹窗返回的若干个值对象构成的数组 I(this, "value"); I(this, "valueType", "text"); // 控件内显示的值 I(this, "displayText"); // 弹窗模式下,取列表中哪个字段的值映射到当前字段 I(this, "valueField"); // 是否是手动输入的值 I(this, "isInputText"); // 编辑器配置 I(this, "editiorConfig"); this.value = t == null ? void 0 : t.value, this.displayText = t == null ? void 0 : t.displayText, this.valueField = t == null ? void 0 : t.displayField, this.isInputText = t == null ? void 0 : t.isInputText, this.editiorConfig = Object.assign({}, n); } clear() { this.value = "", this.displayText = "", this.valueField = ""; } getPropValue(t, n) { if (n.length > 1) { const o = n.shift(); return t[o] ? this.getPropValue(t[o], n) : ""; } return t[n[0]]; } getTextValue(t) { const n = t.split("."), o = this.value.map((r) => this.getPropValue(r, fe(n))); return o && o.length ? o.join(",") : ""; } getValue() { return this.value; } getDisplayText() { return this.getValue(); } setValue(t) { throw new Error("Method not implemented."); } isEmpty() { var t; return !this.displayText && (this.value == null || !((t = this.value) != null && t.length)); } } class fo { constructor(t = { mapFields: [], value: "", valueField: "", isInputText: !1, helpId: "" }, n) { I(this, "editorType", "lookup"); I(this, "helpId"); I(this, "mapFields"); I(this, "value"); I(this, "valueField"); I(this, "valueType", "text"); // 帮助的值是否为手动输入的任意值,对应帮助的任意输入属性nosearch I(this, "isInputText"); // 编辑器配置 I(this, "editiorConfig"); this.editiorConfig = Object.assign({}, n), this.value = (t == null ? void 0 : t.value) || "", this.valueField = (t == null ? void 0 : t.valueField) || (n == null ? void 0 : n.valueField), this.mapFields = t.mapFields, this.isInputText = (t == null ? void 0 : t.isInputText) || (n == null ? void 0 : n.isInputText), this.helpId = (t == null ? void 0 : t.helpId) || (n == null ? void 0 : n.helpId); } clear() { this.value = "", this.mapFields = []; } getValue() { return this.mapFields.map((t) => kt(t, this.valueField || "id")).join(","); } getDisplayText() { return this.value; } setValue(t) { throw new Error("Method not implemented."); } isEmpty() { return !this.mapFields.length; } } class go extends ke { constructor(n = { value: "", displayFormat: "", valueFormat: "" }, o) { super(n, o); I(this, "editorType", "month-picker"); } } class vo extends Be { constructor(n = { begin: "", end: "", displayFormat: "", valueFormat: "" }, o) { super(n, o); I(this, "editorType", "month-range"); } } class yo { constructor(t = { begin: null, end: null }, n) { I(this, "editorType", "number-range"); I(this, "begin"); I(this, "end"); I(this, "valueType", "number"); // 编辑器配置 I(this, "editiorConfig"); this.editiorConfig = Object.assign({}, n), this.begin = (t == null ? void 0 : t.begin) == null ? null : parseFloat(t.begin), this.end = (t == null ? void 0 : t.end) == null ? null : parseFloat(t.end); } clear() { this.begin = null, this.end = null; } getValue() { return { begin: this.begin, end: this.end }; } getDisplayText() { return this.begin === null && this.end === null ? "" : (this.begin === null ? "" : this.begin) + "~" + (this.end === null ? "" : this.end); } setValue(t) { this.begin = t.begin == null ? null : parseFloat(t.begin), this.end = t.end == null ? null : parseFloat(t.end); } isEmpty() { return this.begin == null && this.end == null; } } class ho { constructor(t = { value: "" }, n) { I(this, "editorType", "number-spinner"); I(this, "value"); I(this, "valueType", "number"); // 编辑器配置 I(this, "editiorConfig"); this.editiorConfig = Object.assign({}, n); const o = parseFloat(t.value); this.value = isNaN(o) ? null : o; } clear() { this.value = null; } getValue() { return this.value; } getDisplayText() { if (this.isEmpty()) return ""; const { formatTo: t } = Vt(); return t(this.value, this.editiorConfig); } setValue(t) { this.value = isNaN(parseFloat(t)) ? null : t; } isEmpty() { return this.value == null || isNaN(this.value); } } class bo { constructor(t = { value: null, valueList: [] }, n) { I(this, "editorType", "radio-group"); I(this, "value"); I(this, "valueType", "enum"); I(this, "valueList", []); // 编辑器配置 I(this, "editiorConfig"); this.editiorConfig = Object.assign({}, n), this.value = t == null ? void 0 : t.value, this.editiorConfig.data && this.editiorConfig.data.length ? this.valueList = this.editiorConfig.data : this.valueList = (t == null ? void 0 : t.valueList) || []; } clear() { this.value = void 0, this.valueList = []; } getValue() { return this.value; } getDisplayText() { var t; return ((t = this.valueList.find((n) => n.value === this.value)) == null ? void 0 : t.name) || ""; } setValue(t) { this.value = t; } isEmpty() { return !this.value && this.value !== 0 && this.value !== !1; } } class Fo extends ke { constructor(n = { value: "", displayFormat: "", valueFormat: "" }, o) { super(n, o); I(this, "editorType", "year-picker"); } } class tt { constructor(t = { value: "" }, n) { I(this, "editorType", "text"); I(this, "value"); I(this, "valueType", "text"); // 编辑器配置 I(this, "editiorConfig"); this.value = t.value; } clear() { this.value = void 0; } getValue() { return this.value; } getDisplayText() { return this.getValue(); } setValue(t) { this.value = t; } isEmpty() { return !this.value; } } class Co extends ke { constructor(n = { value: "", displayFormat: "", valueFormat: "" }, o) { super(n, o); I(this, "editorType", "datetime-picker"); } } class To extends Be { constructor(n = { begin: "", end: "", displayFormat: "", valueFormat: "" }, o = {}) { super(n, o); // 这个属性会在后面进行比对 I(this, "editorType", "datetime-range"); I(this, "valueType", "datetime"); } } class ko extends et { constructor(n = { value: "", valueList: [] }, o) { super(n, o); I(this, "editorType", "check-group"); } } function nt() { function e(t, n, o) { switch (t) { case "check-box": return new co(n, o); case "combo-list": return new et(n, o); case "combo-lookup": return new mo(n, o); case "input-group": return new po(n, o); case "year-picker": return new Fo(n, o); case "date-picker": return new ke(n, o); case "datetime-range": return new To(n, o); case "date-range": return new Be(n, o); case "datetime-picker": return new Co(n, o); case "lookup": return new fo(n, o); case "month-picker": return new go(n, o); case "month-range": return new vo(n, o); case "number-range": return new yo(n, o); case "number-spinner": return new ho(n, o); case "radio-group": return new bo(n, o); case "check-group": return new ko(n, o); default: return new tt(n, o); } } return { createConditionValue: e }; } function ot(e = "query-solution") { function t(i) { let a = "input-group"; switch (i) { case "year-picker": case "month-picker": case "month-range": case "date-range": case "datetime-range": case "datetime-picker": a = "date-picker"; break; default: a = i; } return a; } function n(i) { const a = i.editor ? i.editor.type : "input-group"; return i.editor.type = t(a), i.editor.type === "date-picker" ? (a.indexOf("range") > -1 && (i.editor.enablePeriod = !0), a.indexOf("datetime") > -1 && (i.editor.showTime = !0), a.indexOf("year") > -1 && (i.editor.selectMode = "year"), a.indexOf("month") > -1 && (i.editor.selectMode = "month"), i.editor.weekSelect && (i.editor.selectMode = "week")) : i.editor.type === "number-spinner" || i.editor.type === "number-range" ? (i.editor.showZero = !0, i.editor.nullable = !0, i.editor.needValid = !0) : i.editor.type === "check-group" && e === "filter-bar" ? i.editor.direction = "vertical" : (i.editor.type === "lookup" || i.editor.type === "combo-list") && (i.editor.enableClear = Object.prototype.hasOwnProperty.call(i.editor, "enableClear") ? i.editor.enableClear : !0), a === "input-group" && !i.editor.placeholder && (i.editor.placeholder = ve.getLocaleValue("input-group.placeholder")), i.editor; } function o(i) { return i.map((C) => Object.assign({}, C)).map((C) => (C.visible = Object.prototype.hasOwnProperty.call(C, "visible") ? C.visible : !0, C.editor = n(C), C)); } function r(i, a, C, m) { switch (i.value.editorType) { case "combo-list": m.newValue && (i.value.valueList = m.newValue.map((h) => ({ name: h.name, value: h.value }))); break; case "radio-group": i.value.valueList = [C.data.find((h) => h.value === a)]; break; case "year-range": case "month-range": case "date-range": case "datetime-range": i.value.setValue(a); break; } } function c(i, a, C) { var v, p, b, P, g, y, F; const m = fe((v = i.get(a.fieldCode)) == null ? void 0 : v.editor), h = (p = i.get(a.fieldCode)) == null ? void 0 : p.id, l = Object.prototype.hasOwnProperty.call(a, "visible") ? a.visible : (b = i.get(a.fieldCode)) == null ? void 0 : b.visible; let s = !0; if (((P = a.value) == null ? void 0 : P.editorType) === "lookup" && m) { m.idValue = (g = a.value.mapFields) == null ? void 0 : g.map((A) => A.id).join(","); const { onClear: j } = m; m.onClear = (A) => { a.value.mapFields = [], C(a, ""), j && j(A); }, m["onUpdate:dataMapping"] = (A) => { a.value.mapFields = A.items || [], C(a, a.value.getValue()); }, s = !1; } else ((y = a.value) == null ? void 0 : y.editorType) === "number-range" && m ? (m.beginValue = a.value.begin, m.onBeginValueChange = (j) => { a.value.begin = j, C(a, j); }, m.endValue = a.value.end, m.onEndValueChange = (j) => { a.value.end = j, C(a, j); }, s = !1) : m && ["year-range", "month-range", "date-range", "datetime-range"].find((j) => { var A; return j === ((A = a.value) == null ? void 0 : A.editorType); }) ? (m.beginValue = a.value.begin, m.endValue = a.value.end) : ((F = a.value) == null ? void 0 : F.editorType) === "combo-list" && m && (m.onDataChanged = (j) => { var U; const A = (U = i.get(a.fieldCode)) == null ? void 0 : U.editor; A && (A.data = j), a.value.updateData(j); }); return Object.prototype.hasOwnProperty.call(a, "disabled") && (m.disabled = a.disabled), { id: h, editor: m, visible: l, needEmitChange: s }; } return { getSingleControlType: n, convertToControls: o, conditionChangeHandler: r, renderFieldConditionEditor: c }; } function Ne(e, t, n = "query-solution") { const { convertToControls: o } = ot(n), r = N(e.fields), c = N([]), i = /* @__PURE__ */ new Map(), { createConditionValue: a } = nt(); function C(h = !0) { h && (r.value = o(r.value)), r.value.reduce((l, s) => (l.set(s.labelCode, s), l), i); } function m(h) { return h.forEach((l) => { if (l) { const s = i.get(l.fieldCode); s.controlType && (l.value = a(s.controlType, l.value, s.editor)); } }), h; } return { convertToControls: o, fields: r, fieldMap: i, fieldConditions: c, loadFieldConfigs: C, initialConditionValue: m }; } function rt(e, t, n) { const o = N(null), r = N(n), c = N(0); function i(h, l) { let s = null; return function() { const v = arguments; s ? (clearTimeout(s), s = setTimeout(() => { s = null, h(...v); }, 200)) : (h(...v), s = setTimeout(() => { s = null; }, 200)); }; } function a() { r.value && (o.value = new ResizeObserver(i((h) => { const l = h[0]; c.value = l.contentRect.width; })), o.value.observe(r.value)); } function C(h) { let s = "col-12"; return h > 250 * 6 ? s = "col-2" : h > 250 * 4 ? s = "col-3" : h > 250 * 3 ? s = "col-4" : h > 250 * 2 && (s = "col-6"), s; } const m = _(() => C(c.value)); return K([n], ([h]) => { r.value = h, a(); }), { conditionClass: m, resizeObserver: o }; } const Ge = /* @__PURE__ */ ee({ name: "FConditionFields", props: Me, emits: ["valueChange", "blur", "focus", "click", "input"], setup(e, t) { const n = N(), o = ve.getLocale(), r = N(e.key), c = N(e.conditions), { renderFieldConditionEditor: i, conditionChangeHandler: a } = ot(), C = Ne(e), { initialConditionValue: m, fieldMap: h, loadFieldConfigs: l } = C, s = rt(e, t, n), { resizeObserver: v } = s; l(!0), m(c.value), Je(() => { var g; (g = v.value) == null || g.unobserve(n.value); }), K(() => e.fields, () => { l(!0); }), K(() => e.conditions, () => { c.value = e.conditions, m(c.value); }); const p = _(() => ({ // row: true, "f-utils-flex-row-wrap": !0, "farris-form": !0, "condition-div": !0, "farris-form-controls-inline": !o || e.isControlInline === !0 || e.isControlInline === "auto" && o !== "en" })); function b(g, y, F, j) { a(g, y, F, j), t.emit("valueChange", y, g); } function P() { return c.value.map((g) => { var J; const { id: y, editor: F, needEmitChange: j, visible: A } = i(h, g, b); let U = ((J = F == null ? void 0 : F.appearance) == null ? void 0 : J.class) || e.itemClass; return F != null && F.multiLineLabel && (U = U + " farris-group-multi-label"), L(ht, { id: y, key: y, visible: A, customClass: U, label: (F == null ? void 0 : F.showLabel) === !1 ? " " : g.fieldName, editor: F, required: F == null ? void 0 : F.required, modelValue: g.value.value, "onUpdate:modelValue": (H) => g.value.value = H, onChange: (H, u) => { j && b(g, H, F, u); } }, null); }); } return () => he(L("div", { class: p.value, key: r.value, ref: n }, [P()]), [[be("area-response")]]); } }), Vo = "root-viewmodel"; class wo { constructor(t, n) { I(this, "formSchemaUtils"); I(this, "controlCreatorUtils"); I(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), c = this.formSchemaUtils.getFormSchema(); return c.module.viewmodels.push(r), c.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 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 a, C; 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: c } = t; c == null || c.forEach((m) => { if (m.$type === $e.SimpleField) { const h = fe(m), l = this.resolveControlClassByFormColumns(t), s = this.controlCreatorUtils.setFormFieldProperty(h, "", l); s && r.push(s); } }); const { templateId: i } = this.formSchemaUtils.getFormSchema().module; if (i === "double-list-in-tab-template" && ((C = (a = t.parentComponentInstance) == null ? void 0 : a.schema) == null ? void 0 : C.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 && (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: Vo, 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 === $e.SimpleField) { let c = "blur"; const i = r.type.name; (i === Ae.Enum || i === Ae.Boolean) && (c = "change"), n.push({ type: "Form", id: r.id, fieldName: r.bindingField, groupId: null, groupName: null, updateOn: c, fieldSchema: {} }); } }), n; } } function it(e, t, n, o) { var c, i, a, C, m, h; const r = n.parentComponentInstance; if (r && o) { const l = (c = r.schema) == null ? void 0 : c.type, v = { componentId: `form-${Math.random().toString(36).slice(2, 6)}`, componentName: ((i = n.bindingSourceContext) == null ? void 0 : i.entityTitle) || ((C = (a = n.bindingSourceContext) == null ? void 0 : a.bindingEntity) == null ? void 0 : C.name) || "标题", componentType: "form", formColumns: l === "splitter-pane" ? 1 : 4, parentContainerId: r.schema.id, parentComponentInstance: r, bindTo: ((m = n.bindingSourceContext) == null ? void 0 : m.bindTo) || "/", selectedFields: (h = n.bindingSourceContext) == null ? void 0 : h.bindingEntityFields }; return new wo(e, o).createComponent(v); } else return t; } const xo = "https://json-schema.org/draft/2020-12/schema", So = "https://farris-design.gitee.io/response-form.schema.json", Eo = "response-form", Po = "A Farris Data Collection Component", Io = "object", Lo = { 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" } }, Oo = [ "id", "type", "contents" ], Mo = { $schema: xo, $id: So, title: Eo, description: Po, type: Io, properties: Lo, required: Oo }, st = /* @__PURE__ */ new Map([ ["appearance", Et] ]), Bo = "https://json-schema.org/draft/2020-12/schema", No = "https://farris-design.gitee.io/dynamic-form.schema.json", jo = "dynamic-form", Ro = "A Farris Data Collection Component", $o = "object", Ao = { 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: "" } }, qo = [ "id", "type", "contents" ], Uo = { onClick: "点击事件", "onUpdate:modelValue": "值变更事件", event: "事件" }, Go = { $schema: Bo, $id: No, title: jo, description: Ro, type: $o, properties: Ao, required: qo, events: Uo }; var ye = /* @__PURE__ */ ((e) => (e.Header = "header", e.Footer = "footer", e))(ye || {}), Ce = /* @__PURE__ */ ((e) => (e.QUICK = "quick", e.FULL = "full", e))(Ce || {}); const Ve = { 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" } }, zo = Object.assign({}, Ve, { // 是否渲染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: Ce.QUICK }, /** 工具栏 */ toolbar: { type: [Array, Function], default: [] }, /** 设置头部的样式 */ headerStyle: { type: [String, Function], default: "" }, /** 设置底部样式 */ footerStyle: { type: [String, Function], default: "" }, /** 更多按钮样式 */ moreButtonClass: { type: String, default: "btn-link" } }); Oe(Ve, Mo, st, it); Oe(Ve, Go, st, it); const Fe = /* @__PURE__ */ ee({ name: "FDynamicForm", props: zo, emits: ["update:modelValue", "event", "click"], setup(e, t) { const n = N(e.fields), o = /* @__PURE__ */ new Map(), r = N(e.callback); Bt(); const c = Nt(), i = N(e.formData || {}), a = jt(i, t); Rt(n.value).setup(); const m = /* @__PURE__ */ new Map(), h = N(e.canRenderForm); let l = [], s = [], v = []; const p = e.mode === Ce.FULL ? "contents" : "fields", { mergeArray: b, resolveCallbacks: P, resolveEvents: g } = $t(), y = _(() => { const d = ve.getLocale(), R = e.fields && e.fields.length > 0; let $ = { "f-form-layout": R, "farris-form": R, "f-dynamic-form": !(e.showHeader || e.showFooter) }; return $ = Ye($, e.customClass), e.adaptForLanguage && d && ($["farris-form-controls-inline"] = d !== "en"), $; }); function F() { function d(R, $) { const { id: z } = R || {}, { field: Q } = R.binding || {}; return { modelValue: $.getValue(z), "onUpdate:modelValue": (ie) => { $.setValue(z, Q || z, ie); } }; } return { resolve: d }; } function j(d) { const R = F(); return a.getValue(d.id) === void 0 && Object.hasOwnProperty.call(d, "modelValue") && a.setValue(d.id, void 0, d.modelValue), R.resolve(d, a); } function A(d) { const R = {}; return d && Object.entries(d).forEach(([$, z]) => { R[$] = () => Array.isArray(z) ? z.map((Q) => f(Q)) : f(z); }), R; } function U(d) { return d.type ? d.type : d[p] ? "fieldset" : "form-group"; } function J(d) { const R = U(d), $ = d.customClass || ""; return $ || (R === "fieldset" ? "col-12 px-0" : l.length === 0 && s.length === 0 || d.id && v.find((z) => z[p] ? z[p].find((Q) => Q.id === d.id) : z.id === d.id) ? e.layout : "unset-item"); } function H(d) { const R = U(d); let $ = {}, z = "", Q = {}, ie = {}; if (e.mode === Ce.FULL) { Q = { ...g(d, t, R) }, ie = { ...P(d, r, R) }; const D = qt[R]; $ = D ? D(d) : {}, z = J($); } else { z = J(d); const { fields: D, customClass: oe, ...ae } = d; $ = ae; } return { props: { ...{ ...$, customClass: z, ...j(d) }, key: d.id, ref: (D) => { if (D && d.id && !c.has(d.id)) { c.register(d.id, D); const oe = { token: d.id, name: "component:ready", type: U(d), payloads: [N(D)], schema: d }; t.emit("event", oe); } }, onVnodeUnmounted: (D) => { if (d.id && c.has(d.id)) { c.remove(d.id); const oe = { token: d.id, name: "component:unmounted", type: U(d), payloads: [D], schema: d }; t.emit("event", oe); } } }, eventProps: Q, callbackProps: ie }; } function u(d, R) { return Array.isArray(d) ? d.map(($) => R($)) : R(d); } function f(d, R) { var ce; const $ = U(d), z = xe[$]; if (d.id && o.set(d.id, d), !z) return null; const Q = () => d[p] ? d[p].map((D) => f(D)) : null, ie = (D, oe, ae) => { let me; return ae && ae.length > 0 ? me = L(D, { ...oe }, ae) : me = L(D, { ...oe }, null), me; }, de = ((ce = m.get(d.id)) == null ? void 0 : ce.props) || {}; return d[p] && d[p].length > 0 ? ie(z, de, [Q()]) : d.slots ? ie(z, de, [...Object.values(A(d.slots))]) : ie(z, de); } function x(d) { const R = U(d); if (!xe[R]) return; const { props: z, eventProps: Q, callbackProps: ie } = H(d), de = At[R], ce = de ? de.editorResolver : null, { componentEventProps: D, editorEventProps: oe } = Q, { componentCallbackProps: ae, editorCallbackProps: me } = ie; if (D && Object.keys(D).length > 0 && Object.assign(z, D), ae && Object.keys(ae).length > 0 && Object.assign(z, ae), ce && oe && Object.keys(oe).length > 0) { const se = ce.resolve(d); Object.assign(se, oe); } if (ce && me && Object.keys(me).length > 0) { const se = ce.resolve(d); Object.assign(se, me); } if (z && Object.keys(z).length > 0) { const se = m.get(d.id); se ? Tt(se == null ? void 0 : se.props, z) : m.set(d.id, je({ props: z })); } !d[p] || !Array.isArray(d[p]) || d[p].forEach((se) => x(se)); } function M(d) { const R = U(d); xe[R] && (B(d), !(!d[p] || !Array.isArray(d[p])) && d[p].forEach((z) => M(z))); } function B(d) { const R = j(d); if (R && Object.keys(R).length > 0) { const $ = m.get(d.id); if (!$) m.set(d.id, je({ props: R })); else { const z = { ...$ == null ? void 0 : $.props }; Object.keys(R).forEach((Q) => { z[Q] = R[Q]; }), Object.assign($ == null ? void 0 : $.props, z); } } } Le(() => { }), K(() => e.formData, (d) => { i.value = d; }), K(() => i.value, () => { u(n.value, M); }, { deep: !0 }); function k(d, R = "") { return R ? d.filter(($) => $.position === R) : d.filter(($) => !$.position || [ye.Header, ye.Footer].indexOf($.position) < 0); } function O(d) { d && (l = k(d, ye.Header), l.length && u(l, x), s = k(d, ye.Footer), s.length && u(s, x), v = k(d), v.length && u(v, x)); } K(() => e.fields, (d) => { o.clear(), c.clear(), i.value = e.formData || {}, m.clear(), n.value = d, O(d); }), O(e.fields); function q(d) { d.$forceUpdate && d.$forceUpdate(); } function W(d) { return a.getValue(d); } function X() { return i.value; } function Y(d, R) { a.setValue(d, void 0, R); const $ = o.get(d); $ && B($); } function le(d) { var R; return (R = m.get(d)) == null ? void 0 : R.props; } function ue(d, R) { const $ = m.get(d); Ct($ == null ? void 0 : $.props, R, b); } t.expose({ componentManager: c, rerender: q, getProps: le, setProps: ue, getControlValue: W, setControlValue: Y, getValues: X }); function re(d = []) { return d.length > 0 && u(d, f); } function G(d) { return he(L("div", { class: y.value, style: e.customStyle }, [t.slots.default && t.slots.default(), d.length > 0 && u(d, f)]), [[be("area-response")]]); } function Z() { const d = {}; let R = "f-dynamic-form-section--header-content", $ = "f-dynamic-form-section--footer"; return e.showHeader && (t.slots.headerTitle && (d.headerTitle = () => { var z, Q; return (Q = (z = t.slots).headerTitle) == null ? void 0 : Q.call(z); }), R += e.headerContentRenderFunction || t.slots.headerContent ? " f-dynamic-form-section--header-cotnent-tmpl" : "", t.slots.headerContent ? d.headerContent = () => { var z, Q; return (Q = (z = t.slots).headerContent) == null ? void 0 : Q.call(z); } : !e.headerContentRenderFunction && l.length > 0 && (d.headerContent = () => he(L("div", { class: "f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" }, [re(l)]), [[be("area-response")]]))), e.showFooter && ($ += e.footerRenderFunction || t.slots.footer ? " f-dynamic-form-section--footer-tmpl" : 0, t.slots.footer ? d.footer = () => { var z, Q; return (Q = (z = t.slots).footer) == null ? void 0 : Q.call(z); } : !e.footerRenderFunction && s.length > 0 && ($ += s.length > 0 ? " f-form-layout farris-form farris-form-controls-inline f-dynamic-form-section--fields" : "", d.footer = () => re(s))), { slots: d, footerClass: $, headerContentClass: R }; } const te = _(() => typeof e.toolbar == "function" ? e.toolbar() : e.toolbar), ne = _(() => e.headerStyle ? typeof e.headerStyle == "function" ? e.headerStyle() : e.headerStyle : ""), we = _(() => e.footerStyle ? typeof e.footerStyle == "function" ? e.footerStyle() : e.footerStyle : ""); function pt(d, R) { t.emit("click", d, R); } function ft() { const { slots: d, footerClass: R, headerContentClass: $ } = Z(); return L(Ut, { customClass: "f-dynamic-form-section", showHeader: e.showHeader, mainTitle: e.mainTitle, enableAccordion: e.enableAccordion ? "default" : "", headerContentClass: $, footerClass: R, buttons: te.value, headerStyle: ne.value, footerStyle: we.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: pt, moreButtonClass: e.moreButtonClass }, { default: () => G(v), ...d }); } return () => e.visible ? e.showHeader || e.showFooter ? ft() : h.value && G(n.value) || !h.value && re(n.value) : null; } }), ze = /* @__PURE__ */ ee({ name: "FResponseForm", props: Ve, emits: [], setup(e, t) { var l; const n = N(), o = N(), r = _(() => { const s = ve.getLocale(), v = e.fields && e.fields.length > 0; let p = { "drag-container": !0, "f-form-layout": v, "farris-form": v }; return p = Ye(p, e.customClass), e.adaptForLanguage && s && (p["farris-form-controls-inline"] = s !== "en"), p; }), c = (l = o.value) == null ? void 0 : l.componentManager; function i(s) { o.value.render(s); } function a(s) { return o.value.getControlValue(s); } function C(s, v) { o.value.setControlValue(s, v); } function m(s) { return o.value.getProps(s); } function h(s, v) { o.value.setProps(s, v); } return t.expose({ componentManager: c, rerender: i, getProps: m, setProps: h, getControlValue: a, setControlValue: C }), () => e.visible && he(L("div", { ref: n, class: r.value, style: e.customStyle }, [t.slots.default && t.slots.default(), e.fields && e.fields.length > 0 && L(Fe, { ref: o, fields: e.fields, canRenderForm: !1, formData: e.formData, layout: e.layout }, null)]), [[be("area-response")]]); } }), lt = { 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