UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,365 lines 144 kB
var It = Object.defineProperty; var Ft = (n, t, e) => t in n ? It(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var S = (n, t, e) => Ft(n, typeof t != "symbol" ? t + "" : t, e); import { radioCheckboxCommonProps as kt, FormSchemaEntityField$Type as Se, FormSchemaEntityFieldType$Type as Le, EVENT_PROPERTY_TAB_IDS as Pe, isMobilePhone as re, getMaxZIndex as Ve, useGuid as xe, withInstall as Bt } from "../../components/common/index.esm.js"; import { resolveAppearance as Tt, createPropsResolver as Ne, getPropsResolverGenerator as Ae } from "../../components/dynamic-resolver/index.esm.js"; import St, { radioGroupProps as ze } from "../../components/radio-group/index.esm.js"; import { computed as T, createVNode as p, Fragment as Z, createTextVNode as Y, nextTick as ie, defineComponent as Q, ref as v, inject as fe, onMounted as J, Teleport as He, createApp as Ee, onUnmounted as he, watch as G, onBeforeMount as Pt, watchEffect as Vt, Transition as $e, shallowRef as Rt, render as be, h as Ot, cloneVNode as Lt, mergeProps as Me, withDirectives as Ce, vShow as Nt, onUpdated as At, onBeforeUnmount as zt, reactive as Ht, vModelText as Re } from "vue"; import { DgControl as C, canvasChanged as de, refreshCanvas as $t, useDesignerComponent as Ut } from "../../components/designer-canvas/index.esm.js"; import { cloneDeep as Ue, debounce as We } from "lodash-es"; import { LocaleService as oe } from "../../components/locale/index.esm.js"; import "../../components/property-panel/index.esm.js"; import "../../components/button/index.esm.js"; import "../../components/field-selector/index.esm.js"; import "../../components/collection-property-editor/index.esm.js/src/use-button-items.designer"; import Wt from "../../components/tags/index.esm.js"; import { useInputExpand as qt } from "../../components/common/index.esm.js/text-box/use-input-expand"; import jt from "../../components/popover/index.esm.js"; import Gt from "../../components/drawer/index.esm.js"; import Dt from "../../components/data-grid/index.esm.js"; import { FNotifyService as Kt } from "../../components/notify/index.esm.js"; import "bignumber.js"; const Xt = { ...kt, /** * 组件标识 */ id: String, /** * 可选,是否禁用组件 * @default false */ disabled: { type: Boolean, default: !1 }, /** * 功能同disabled */ readonly: { type: Boolean, default: !1 }, /** * 废弃 * @deprecated */ enumData: { type: Array }, /** * 单选组数据源 */ data: { type: Array }, /** * 组件值 */ modelValue: { type: String, default: "" }, /** * 组件名称 */ name: { type: String, default: "" }, /** * 输入框Tab键索引 */ tabIndex: { type: Number, default: -1 }, /** * 可选,默认为name,显示文本字段 * @default 'name' */ textField: { type: String, default: "name" }, /** * 可选,默认为value,值字段 * @default 'value' */ valueField: { type: String, default: "value" } }; function _t(n, t, e) { const o = T(() => !n.disabled), i = T(() => n.data || n.enumData || n.options || []); function l(s) { return s[n.valueField]; } function a(s) { return s[n.textField]; } function r(s, d) { if (o.value) { const c = l(s); e.value !== c && (e.value = c, t.emit("change", c), t.emit("changeValue", c), t.emit("update:modelValue", c)); } d.stopPropagation(); } return { enumData: i, getValue: l, getText: a, onClickRadio: r }; } function Yt(n) { const { formSchemaUtils: t, formStateMachineUtils: e } = n; function o(s, d = "") { return { path: d + s.code, field: s.id, fullPath: s.code }; } function i(s, d = "") { const c = t.getViewModelById(s); return c ? c.states.map((u) => o(u, d)) : []; } function l(s) { const d = t.getRootViewModelId(), c = i(s); if (s === d) return c; const u = i(d, "root-component."); return [...c, ...u]; } function a(s) { return s.binding && s.binding.path || s.id || ""; } function r() { return e && e.getRenderStates() || []; } return { getVariables: l, getControlName: a, getStateMachines: r }; } class Jt { constructor(t) { S(this, "sessionVariables", [ { key: "CurrentSysOrgName", name: "当前组织Name", description: "当前组织Name" }, // { // key: "CurrentSysOrgCode", // name: "当前组织Code", // description: "当前组织Code" // }, { key: "CurrentSysOrgId", name: "当前组织Id", description: "当前组织Id" }, { key: "CurrentUserName", name: "当前用户Name", description: "当前用户Name" }, { key: "CurrentUserCode", name: "当前用户Code", description: "当前用户Code" }, { key: "CurrentUserId", name: "当前用户Id", description: "当前用户Id" }, { key: "CurrentLanguage", name: "当前语言编号", description: "当前登录的语言编号,例如简体中文返回'zh-CHS',英文返回'en',繁体中文'zh-CHT'" } ]); S(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); S(this, "getExpressionConverter", (t, e) => ({ convertFrom: (o, i, l, a) => { const r = l.getExpressionRuleValue(t, e || i); return r && r.value || ""; }, convertTo: (o, i, l, a, r) => { var s; if (i === "dataPicking" && (l != null && l.target)) { const d = `${l.target}_dataPicking`; ((s = l.rules) == null ? void 0 : s.some( (u) => u.id === d && u.value )) ? o.dictPickingExpressionId = d : delete o.dictPickingExpressionId; } a.updateExpression(l); } })); this.formSchemaService = t; } getExpressionRule(t, e) { const o = this.getExpressionData(); if (!o) return ""; const i = o.find((a) => a.target === t); if (!i) return ""; const l = i.rules.find((a) => a.type === e); return l || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: t } = this.formSchemaService.getFormSchema(); if (!t.viewmodels || t.viewmodels.length === 0) return []; const e = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(e); if (!o || !o.states || o.states.length === 0) return []; const i = []; return o.states.filter((l) => l.category === "remote").forEach((l) => { i.push({ key: l.code, name: l.name, description: l.name, category: l.category }); }), i; } createTreeNode(t, e, o = "label") { return { id: t.id, name: t.name, bindingPath: t[o], parents: e, type: "field" }; } buildEntityFieldsTreeData(t = null, e) { const o = []; return t == null || t.forEach((i) => { var r; const l = this.createTreeNode(i, e); let a = []; (r = i.type) != null && r.fields && (a = this.buildEntityFieldsTreeData(i.type.fields, [...e, i.label])), o.push({ data: l, children: a, expanded: !0 }); }), o; } buildChildEntityTreeData(t = null, e) { const o = []; return t == null || t.forEach((i) => { var s, d; const l = this.createTreeNode(i, e); l.type = "entity"; const a = this.buildEntityFieldsTreeData((s = i.type) == null ? void 0 : s.fields, [...e, i.label]), r = this.buildChildEntityTreeData((d = i.type) == null ? void 0 : d.entities, [...e, i.label]); r != null && r.length && (a == null || a.push(...r)), o.push({ data: l, children: a || [], // 空值回退 expanded: !0 }); }), o; } getEntitiesTreeData() { const t = this.formSchemaService.getSchemaEntities(); if (!(t != null && t.length)) return []; const e = t[0]; if (!(e != null && e.type)) return []; const o = this.buildEntityFieldsTreeData(e.type.fields, [e.code]), i = this.buildChildEntityTreeData(e.type.entities, [e.code]); return i != null && i.length && (o == null || o.push(...i)), { entityCode: e.code, fields: [{ data: this.createTreeNode(e, [], "code"), children: o || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(t, e, o) { const i = o === "Field" ? t.binding.field : t.id, l = this.getExpressionRule(i, e), a = this.getEntitiesAndVariables(), r = { message: ["validate", "required", "dataPicking"].includes(e) && l ? l.message : "", ...a }; return l.messageType != null && (r.messageType = l.messageType), r; } buildRule(t, e, o, i) { const { expression: l, message: a, messageType: r } = e, s = { id: `${t}_${o}`, type: o, value: l }; return (o === "validate" || o === "dataPicking" || o === "required") && (s.message = a), o === "dataPicking" && (s.messageType = r), o === "validate" && i && (s.elementId = i), s; } getExpressionData() { const { expressions: t } = this.formSchemaService.getFormSchema().module; return t || []; } updateExpression(t, e, o, i) { const l = e === "Field" ? t.binding.field : t.id, a = this.buildRule(l, o, i, t.type === "form-group" ? t.id : ""); let s = this.getExpressionData().find((c) => c.targetType === e && c.target === l); const d = (c) => c.value.trim() === ""; if (s) { const c = s.rules.find((u) => u.id === a.id); if (c) d(a) ? s.rules = s.rules.filter((u) => u.id !== a.id) : (Object.assign(c, a), i === "validate" && t.type === "form-group" && (c.elementId = t.id)); else { if (d(a)) return null; s.rules = s.rules || [], s.rules.push(a); } } else { if (d(a)) return null; s = { target: `${l}`, rules: [a], targetType: e }; } return s; } getExpressionEditorOptions(t, e, o, i) { return o.reduce((l, a) => { var s, d; const r = e === "Field" ? (s = t == null ? void 0 : t.binding) == null ? void 0 : s.field : t.id; return l[a] = { hide: e === "Field" ? !!((d = t == null ? void 0 : t.binding) != null && d.field) : !1, description: "", title: this.expressionNames[a], type: "string", $converter: this.getExpressionConverter(r), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[a]}编辑器`, showMessage: a === "validate" || a === "dataPicking" || a === "required", showMessageType: a === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(t, a, e), onSubmitModal: (c) => { const u = this.updateExpression(t, e, c, a); if (i) { const y = this.buildRule(r, c, a); i(y); } return u; } } }, l; }, {}); } getExpressionInfo(t, e, o) { const i = e === "Field" ? t.binding.field : t.id, l = this.getExpressionRule(i, o), a = { value: l && l.value, targetId: i, targetType: e, expressionType: o }; return l && l.message && (a.message = l.message), a; } getExpressionConfig(t, e, o = ["compute", "dependency", "validate"], i) { var l; return { description: "表达式", title: "表达式", hide: !(t.binding && ((l = t.binding) == null ? void 0 : l.type) === "Form"), properties: { ...this.getExpressionEditorOptions(t, e, o, i) } }; } getExpressionOptions(t, e, o) { const i = this.getExpressionInfo(t, e, o); return { dialogTitle: `${this.expressionNames[o] || "表达式"}编辑器`, singleExpand: !1, showMessage: o === "required", beforeOpen: () => this.onBeforeOpenExpression(t, o, e), expressionInfo: i }; } } class Zt { constructor(t, e) { S(this, "componentId"); S(this, "viewModelId"); S(this, "eventsEditorUtils"); S(this, "formSchemaUtils"); S(this, "formMetadataConverter"); S(this, "designViewModelUtils"); S(this, "designViewModelField"); S(this, "controlCreatorUtils"); S(this, "designerHostService"); S(this, "designerContext"); S(this, "modalService", null); /** 表单规则 */ S(this, "formRule", null); S(this, "schemaService", null); S(this, "metadataService", null); S(this, "propertyConfig", { type: "object", categories: {} }); S(this, "expressionProperty"); var o; this.componentId = t, this.designerHostService = e, this.eventsEditorUtils = e.eventsEditorUtils, this.formSchemaUtils = e.formSchemaUtils, this.formMetadataConverter = e.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.getViewModelIdByComponentId(t)) || "", this.designViewModelUtils = e.designViewModelUtils, this.controlCreatorUtils = e.controlCreatorUtils, this.metadataService = e.metadataService, this.schemaService = e.schemaService, this.designerContext = e.designerContext, this.modalService = e.modalService, this.expressionProperty = new Jt(this.formSchemaUtils); } /** * 是否在响应式表单中 */ inResponsiveForm() { var t; return !!((t = this.designerContext) != null && t.responsiveForm); } getFormDesignerInstance() { var t, e; return (e = (t = this.designerContext) == null ? void 0 : t.instances) == null ? void 0 : e.formDesigner.value; } getTableInfo() { var t; return (t = this.schemaService) == null ? void 0 : t.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(t) { var o; const e = t.binding && t.binding.type === "Form" && t.binding.field; if (e) { if (!this.designViewModelField) { const i = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = i.fields.find((l) => l.id === e); } t.updateOn = (o = this.designViewModelField) == null ? void 0 : o.updateOn; } } getBasicPropConfig(t) { return { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "combo-list", textField: "name", valueField: "value", idField: "value", editable: !1, data: [{ value: t.type, name: C[t.type] && C[t.type].name }] } } } }; } getAppearanceConfig(t = null, e = {}, o) { const i = { title: "外观", description: "Appearance" }, l = { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" } }; for (const a in e) l[a] = Object.assign(l[a] || {}, e[a]); return { ...i, properties: { ...l }, setPropertyRelates(a, r) { if (a) { switch (a && a.propertyID) { case "class": case "style": { de.value++; break; } } o && o(a, t, r); } } }; } /** * * @param propertyData * @param propertyTypes * @param propertyName * @param constInfos * @param variableInfos * @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况 * @returns */ getPropertyEditorParams(t, e = [], o = "visible", i = {}, l = {}, a = "") { const { getVariables: r, getControlName: s, getStateMachines: d } = Yt(this.designerHostService), c = this.getRealTargetType(t), u = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], y = { type: "property-editor", propertyTypes: u }; return u.map((h) => { switch (h) { case "Const": Object.assign(y, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, i); break; case "Expression": y.expressionConfig = this.getExpressionOptions(t, c, a || o); break; case "StateMachine": y.stateMachines = d(); break; case "Variable": Object.assign(y, { controlName: s(t), newVariablePrefix: "is", newVariableType: "Boolean", variables: r(this.viewModelId), parentComponentId: this.componentId === "root-component" ? "" : "root-component", onBeforeOpenVariables: (m) => { m.value = r(this.viewModelId); } }, l), this.designerContext.designerMode === "PC_RTC" && (y.newVariablePrefix = "ext_" + y.newVariablePrefix); break; } }), y; } getVisibleProperty(t, e = "") { var l; let o = ["Const", "Variable", "StateMachine", "Expression"]; return e === "gridFieldEditor" ? o = ["Const", "Expression"] : e === "form-group" && !((l = t.binding) != null && l.field) ? o = ["Const", "Variable", "StateMachine", "Custom"] : e === "dataGrid" || e === "treeGrid" || e === "wizard" ? o = ["Const", "Variable", "Expression"] : (t.type.indexOf("toolbar-item") > -1 || e === "form-group") && (o = ["Const", "Variable", "StateMachine", "Custom", "Expression"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(t, o, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(t, e = "", o = {}, i) { const l = { title: "行为", description: "" }, a = this.getVisibleProperty(t, e); for (const s in o) a[s] = Object.assign(a[s] || {}, o[s]); const r = this; return { ...l, properties: { ...a }, setPropertyRelates(s, d) { if (s) { switch (s.propertyID) { case "disabled": case "readonly": case "visible": r.afterMutilEditorChanged(t, s); break; } i && i(s, d); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(t, e) { this.addNewVariableToViewModel(e, this.viewModelId), this.updateExpressionValue(e, t), this.clearExpression(e, t); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(t, e) { const o = e && e.parent && e.parent.schema; if (!o) return; const i = o.contents.findIndex((a) => a.id === t), l = Ue(o.contents[i]); o.contents.splice(i, 1), o.contents.splice(i, 0, l), $t(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(t, e) { const o = t.propertyValue; if (!(o && typeof o == "object") || !(o.type === "Variable" && o.isNewVariable)) return; const a = { id: o.field, category: "locale", code: o.fullPath, name: o.fullPath, type: o.newVariableType || "String", isRtcVariable: this.designerContext.designerMode === "PC_RTC" ? !0 : void 0 }; delete o.newVariableType, delete o.isNewVariable, this.formSchemaUtils.getVariableByCode(a.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(a); } getExpressions() { let t = []; return this.formRule ? (this.formRule.expressions = this.formRule.expressions || [], t = this.formRule.expressions || []) : t = this.formSchemaUtils.getExpressions(), t; } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(t, e) { const o = t.propertyValue; if (!((o && o.type) === "Expression" && o.expressionInfo)) return; const { expressionId: a, expressionInfo: r } = o, { targetId: s, targetType: d, expressionType: c, value: u, message: y } = r, h = this.getExpressions(); let m = h.find((M) => M.target === s); m || (m = { target: s, rules: [], targetType: d }, h.push(m)); const f = m.rules.find((M) => M.type === c); if (f) f.id = a, f.value = u, f.message = y, (c === "minDate" || c === "maxDate" || c === "defaultTime") && (f.elementId = e.id); else { const M = { id: a, type: c, value: u, message: y, elementId: e.id }; m.rules.push(M); } delete o.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(t, e) { const o = t.propertyValue; if (o && o.type === "Expression") return; const l = t.propertyID, a = this.getExpressions(), r = e.binding ? e.binding.field : e.id, s = a.find((d) => d.target === r); !s || !s.rules || (s.rules = s.rules.filter((d) => d.type !== l)); } getExpressionOptions(t, e, o) { return this.expressionProperty.getExpressionOptions(t, e, o); } getRealTargetType(t) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item", "drawer-toolbar-item"].indexOf(t.type) > -1 ? "Button" : t.binding && t.binding.field ? "Field" : "Container"; } createBaseEventProperty(t) { const e = {}; return e[this.viewModelId] = { type: "events-editor", editor: { initialData: t, viewSourceHandle: (o) => { var i; ((i = o.controller) == null ? void 0 : i.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(o); } } }, e; } } const le = class le { /** * 根据绑定字段类型获取可用的输入类控件 */ static getEditorTypesByMDataType(t, e = !1, o = "") { if (e) return [{ key: C["language-textbox"].type, value: C["language-textbox"].name }]; let i = le.fieldControlTypeMapping[t]; if (o === "data-grid-column" && (i != null && i.length)) { const l = [C["check-group"].type, C["radio-group"].type, C.image.type, C["rich-text-editor"].type, C.avatar.type]; i = i.filter((a) => !l.includes(a.key)); } if (o === "tree-grid-column" && (i != null && i.length)) { const l = [C["check-group"].type, C["radio-group"].type, C.image.type, C["rich-text-editor"].type, C.avatar.type, C.switch.type]; i = i.filter((a) => !l.includes(a.key)); } return i; } /** * 获取所有输入类控件 */ static getAllInputTypes() { const t = []; for (const e in le.fieldControlTypeMapping) le.fieldControlTypeMapping[e].forEach((o) => { t.find((i) => i.key === o.key && i.value === o.value) || t.push({ key: o.key, value: o.value }); }); return t; } /** * 提供schema字段基础属性和DOM控件属性的映射 * @param control 控件元数据 */ static mappingDomPropAndSchemaProp(t, e) { var l; const o = (l = t.editor) == null ? void 0 : l.type, i = []; return (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && e && e.categoryId && e.categoryId.indexOf("gridFieldEditor") < 0 && i.push({ domField: "title", schemaField: "name" }), i.push({ domField: "label", schemaField: "name" }), i.push({ domField: "editor.required", schemaField: "require" }), i.push({ domField: "editor.readonly", schemaField: "readonly" }), (o === C["input-group"].type || o === C.textarea.type || o === C["number-spinner"].type) && i.push({ domField: "editor.maxLength", schemaField: "type.length" }), o === C["number-spinner"].type && i.push({ domField: "editor.precision", schemaField: "type.precision" }), (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && i.push({ domField: "formatter.precision", schemaField: "type.precision" }), (o === C["combo-list"].type || o === C["radio-group"].type) && i.push({ domField: "editor.data", schemaField: "type.enumValues" }), (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && i.push({ domField: "formatter.data", schemaField: "type.enumValues" }), o === C["date-picker"].type && (i.push({ domField: "editor.displayFormat", schemaField: "editor.format" }), i.push({ domField: "editor.fieldType", schemaField: "type.name" })), o === C["number-spinner"].type && (i.push({ domField: "editor.max", schemaField: "editor.maxValue" }), i.push({ domField: "editor.min", schemaField: "editor.minValue" })), o === C.lookup.type && (i.push({ domField: "editor.dataSource", schemaField: "editor.dataSource" }), i.push({ domField: "editor.valueField", schemaField: "editor.valueField" }), i.push({ domField: "editor.textField", schemaField: "editor.textField" }), i.push({ domField: "editor.displayType", schemaField: "editor.displayType" }), i.push({ domField: "editor.mapFields", schemaField: "editor.mapFields" }), i.push({ domField: "editor.helpId", schemaField: "editor.helpId" })), i.push({ domField: "path", schemaField: "bindingPath" }), i.push({ domField: "binding.path", schemaField: "bindingField" }), i.push({ domField: "binding.fullPath", schemaField: "path" }), (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && i.push({ domField: "field", schemaField: "bindingPath" }), i; } }; /** * <字段类型,可配置的控件类型列表>的映射 */ S(le, "fieldControlTypeMapping", { String: [ { key: C["input-group"].type, value: C["input-group"].name }, { key: C.lookup.type, value: C.lookup.name }, { key: C.image.type, value: C.image.name }, { key: C["date-picker"].type, value: C["date-picker"].name }, { key: C.switch.type, value: C.switch.name }, { key: C["check-box"].type, value: C["check-box"].name }, { key: C["check-group"].type, value: C["check-group"].name }, { key: C["radio-group"].type, value: C["radio-group"].name }, { key: C["combo-list"].type, value: C["combo-list"].name }, { key: C.textarea.type, value: C.textarea.name }, { key: C["time-picker"].type, value: C["time-picker"].name }, { key: C["rich-text-editor"].type, value: C["rich-text-editor"].name } ], Text: [ { key: C.textarea.type, value: C.textarea.name }, { key: C.lookup.type, value: C.lookup.name }, { key: C.image.type, value: C.image.name }, { key: C.avatar.type, value: C.avatar.name }, { key: C["rich-text-editor"].type, value: C["rich-text-editor"].name } ], Decimal: [ { key: C["number-spinner"].type, value: C["number-spinner"].name } ], Integer: [ { key: C["number-spinner"].type, value: C["number-spinner"].name } ], Number: [ { key: C["number-spinner"].type, value: C["number-spinner"].name }, { key: C.switch.type, value: C.switch.name }, { key: C["check-box"].type, value: C["check-box"].name } ], BigNumber: [ { key: C["number-spinner"].type, value: C["number-spinner"].name } ], Date: [ { key: C["date-picker"].type, value: C["date-picker"].name } ], DateTime: [ { key: C["date-picker"].type, value: C["date-picker"].name } ], Boolean: [ { key: C.switch.type, value: C.switch.name }, { key: C["check-box"].type, value: C["check-box"].name } ], Enum: [ { key: C["combo-list"].type, value: C["combo-list"].name }, { key: C["radio-group"].type, value: C["radio-group"].name } ], Object: [ { key: C.lookup.type, value: C.lookup.name }, { key: C["combo-list"].type, value: C["combo-list"].name } // { key: DgControl['radio-group'].type, value: DgControl['radio-group'].name }, ] }); let me = le; var ae = /* @__PURE__ */ ((n) => (n.Form = "Form", n.Variable = "Variable", n))(ae || {}); class Oe { constructor() { /** 控件标题 */ S(this, "label", ""); /** 控件id */ S(this, "id", ""); /** 每个控件占用的栅格数 */ S(this, "columnInSM", 12); S(this, "columnInMD", 6); S(this, "columnInLG", 3); S(this, "columnInEL", 2); /** 每个控件占用的列数 */ S(this, "displayWidthInSM", 1); S(this, "displayWidthInMD", 1); S(this, "displayWidthInLG", 1); S(this, "displayWidthInEL", 1); /** 编辑器内部默认显示的屏幕大小-----可以去掉 */ S(this, "displayColumnCountAtBreakPoint", "md"); /** 控件所在行,传0即可-----编辑器内部使用 */ S(this, "tagRow", 0); /** 控件是否显示上方空白:传0即可-----编辑器内部使用 */ S(this, "showTopBorder", 0); /** 区域,从1开始。卡片内的控件从上往下,从左往右划分区域,遇到分组fieldSet时group+1,分组结束后group+1 */ S(this, "group", 1); /** 控件是否符合标准的class配置(设计器用的) */ S(this, "isSupportedClass", !0); /** 控件所在分组id(设计器用的) */ S(this, "fieldSetId", ""); } } function Qt(n) { let t, e; const o = /* @__PURE__ */ new Map(); let i = []; function l(c, u) { const h = (c || "").split(" ").filter((E) => E.startsWith("col-")); if (h.length === 0) { u.isSupportedClass = !1; return; } let m = h.find((E) => /^col-([1-9]|10|11|12)$/.test(E)), f = h.find((E) => /^col-md-([1-9]|10|11|12)$/.test(E)), M = h.find((E) => /^col-xl-([1-9]|10|11|12)$/.test(E)), F = h.find((E) => /^col-el-([1-9]|10|11|12)$/.test(E)); m = m || "col-12", u.columnInSM = parseInt(m.replace("col-", ""), 10), u.displayWidthInSM = u.columnInSM / 12, u.displayWidthInSM !== 1 && (u.isSupportedClass = !1), f = f || "col-md-" + u.columnInSM, u.columnInMD = parseInt(f.replace("col-md-", ""), 10), u.displayWidthInMD = u.columnInMD / 6, [1, 2].includes(u.displayWidthInMD) || (u.isSupportedClass = !1), M = M || "col-xl-" + u.columnInMD, u.columnInLG = parseInt(M.replace("col-xl-", ""), 10), u.displayWidthInLG = u.columnInLG / 3, [1, 2, 3, 4].includes(u.displayWidthInLG) || (u.isSupportedClass = !1), F = F || "col-el-" + u.columnInLG, u.columnInEL = parseInt(F.replace("col-el-", ""), 10), u.displayWidthInEL = u.columnInEL / 2, [1, 2, 3, 4, 5, 6].includes(u.displayWidthInEL) || (u.isSupportedClass = !1); } function a(c, u, y, h = !1) { let m = !1; if (!c.contents || c.contents.length === 0) { const f = new Oe(); l(c.layout, f), u.push(f); return; } c.contents.forEach((f) => { if (f.type === "fieldset") { y += 1, a(f, u, y, !0), m = !0; return; } if (f.type === "dynamic-form") return; m && (y += 1, m = !1); const M = f.appearance && f.appearance.class, F = new Oe(); M ? l(M, F) : F.isSupportedClass = !1, F.label = f.label || f.id, F.id = f.id, F.group = y, h && (F.fieldSetId = c.id), e === f.id && (t = y), o.set(f.id, f), u.push(F); }); } function r(c) { const u = n.getComponentById(c); if (!u || !u.componentType || !u.componentType.startsWith("form")) return { result: !1, message: "只可以在响应式表单组件中调整响应式布局配置" }; const y = n.selectNode(u, (h) => h.type === C["response-form"].type); return !y || !y.contents || y.contents.length === 0 ? { result: !1, message: "Form区域内没有控件,请先添加控件" } : { result: !0, message: "", formNode: y }; } function s(c, u) { u = u || c.id; const { result: y, message: h, formNode: m } = r(u); if (!y) return { result: y, message: h }; e = c.id, i = [], o.clear(); const f = m.contents[0].type === C.fieldset.type ? 0 : 1; a(m, i, f); const M = i.find((E) => !E.isSupportedClass); return { defaultState: { defaultGroupNumber: t || 1, model: M ? "customize" : "standard" }, importData: i }; } function d(c, u) { u = u; const { result: y, formNode: h } = r(u); if (!y) return ""; const m = []; return c.forEach((f) => { var E; const M = o.get(f.id), F = M.appearance && M.appearance.class; if (F) { const N = F.split(" ").filter((L) => !L.startsWith("col-")), H = "col-" + f.columnInSM, $ = "col-md-" + f.columnInMD, b = "col-xl-" + f.columnInLG, w = "col-el-" + f.columnInEL, B = [H, $, b, w].concat(N); M.appearance.class = B.join(" "); } if (f.fieldSetId) { const V = h.contents.find((H) => H.id === f.fieldSetId), N = m.find((H) => H.id === f.fieldSetId); N ? (E = N.contents) == null || E.push(M) : (m.push(V), V.contents = [M]); } else m.push(M); }), h.contents = m, h.id; } return { checkCanFindFormNode: r, checkCanOpenLayoutEditor: s, changeFormControlsByResponseLayoutConfig: d, getResonseFormLayoutConfig: a }; } const en = (n) => p(Z, null, [p("h5", null, [Y("代码示例")]), p("pre", { style: "background-color: #f5f5f5; padding: 10px; border-radius: 5px;" }, [p("code", null, [` <h3>Tips:</h3> <span style="color: blue;"> 自定义提示内容 </span> `])])]); class tn extends Zt { constructor(e, o) { super(e, o); S(this, "responseLayoutEditorFunction"); /** 控件绑定的变量 */ S(this, "bindingVarible"); S(this, "formGroupEvents", [ { label: "fieldValueChanging", name: "绑定字段值变化前事件" }, { label: "fieldValueChanged", name: "绑定字段值变化后事件" }, { label: "onClickLabel", name: "标签点击事件" } ]); S(this, "numberEditorOptions", { type: "number-spinner", useThousands: !1, keyboard: !1, showButton: !1 }); S(this, "showCustomValue", (e) => { var i; const o = this.designViewModelField != null && ((i = this.designViewModelField) == null ? void 0 : i.type.name) !== "Boolean"; return this.formRule ? e.dataType !== "boolean" : o; }); this.responseLayoutEditorFunction = Qt(this.formSchemaUtils); } getCommonPropertyConfig(e, o, i = "Card") { if (this.propertyConfig.categories.basic = this.getBasicProperties(e, o, i), this.propertyConfig.categories.appearance = this.getAppearanceProperties(e, o), this.propertyConfig.categories.behavior = this.getBehaviorConfig(e, "form-group"), i === "Card") { const l = this.getTipsConfig(e); this.propertyConfig.categories.behavior.properties = { ...this.propertyConfig.categories.behavior.properties, ...l }, ["time-picker", "date-picker", "lookup", "combo-list", "number-spinner", "input-group", "language-textbox"].includes(e.editor.type) && (this.propertyConfig.categories.expansion = this.getExpandProperties(e, i)); } } getPropertyConfig(e, o) { return this.getCommonPropertyConfig(e, o, "Card"), this.propertyConfig.categories.editor = this.getEditorProperties(e), this.propertyConfig.categories.expressions = this.getExpressionConfig(e, "Field"), this.propertyConfig.categories.eventsEditor = this.getEventPropertyConfig(e), this.propertyConfig; } getGridFieldEdtiorPropConfig(e, o) { return this.propertyConfig.categories = {}, this.getCommonPropertyConfig(e, o, "Grid"), this.getGridFieldEdtiorProperties ? this.propertyConfig.categories.editor = this.getGridFieldEdtiorProperties(e) : this.propertyConfig.categories.editor = this.getEditorProperties(e), this.propertyConfig.categories.expressons = this.getExpressionConfig(e, "Field"), this.propertyConfig.categories; } getBasicProperties(e, o, i = "Card") { var u; const l = this; this.setDesignViewModelField(e); const { canChangeControlType: a, editorTypeList: r } = this.getAvailableEditorType(e), s = this.getPropertyEditorParams(e, ["Variable"], "label", {}, { newVariablePrefix: "", newVariableType: "String" }); let d = r; this.formRule && (d = r.filter((y) => y.key !== "image" && y.key !== "rich-text-editor" && y.key !== "avatar")); const c = { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "编辑器类型", title: "编辑器类型", type: "string", $converter: "/converter/change-editor.converter", parentPropertyID: "editor", editor: { type: "combo-list", textField: "value", valueField: "key", idField: "key", editable: !1, data: d, readonly: !a } }, titleSourceType: { description: "标签来源类型", title: "标签类型", type: "string", refreshPanelAfterChanged: !0, editor: { type: "combo-list", textField: "name", valueField: "id", idField: "id", editable: !1, data: [{ id: "static", name: "静态" }, { id: "dynamic", name: "动态" }] }, defaultValue: "static" }, label: { title: "标签", type: "string", $converter: "/converter/form-group-label.converter", visible: !e.titleSourceType || e.titleSourceType === "static" }, titleDataSource: { description: "标签", title: "标签", type: "string", editor: s, visible: e.titleSourceType === "dynamic" }, showLabelType: { description: "标签显示方式:1、显示:显示标签 2、占位:保留标签空间,但不显示文本 3、不显示:不显示标签", title: "标签显示", type: "enum", editor: { data: [{ id: "visible", name: "显示" }, { id: "reserve-space", name: "占位" }, { id: "none", name: "不显示" }] }, defaultValue: ((u = e.editor) == null ? void 0 : u.type) === "image" ? "none" : "visible" }, binding: { description: "绑定的表单字段", title: "绑定", editor: { type: "binding-selector", bindingType: { enable: !0 }, title: "绑定编辑器", editorParams: { componentSchema: e, needSyncToViewModel: !0, viewModelId: this.viewModelId, designerHostService: this.designerHostService, disableOccupiedFields: !0 }, textField: "bindingField" }, refreshPanelAfterChanged: !0, readonly: this.formSchemaUtils.designerMode === "PC_RTC" && !e.isRtcControl } }, setPropertyRelates(y, h, m) { if (y) switch (y && y.propertyID) { case "type": { l.changeControlType(e, y, o); break; } case "label": { y.needRefreshControlTree = !0; break; } case "binding": { l.changeBindingField(e, y, m); break; } case "titleDataSource": { l.afterMutilEditorChanged(e, y); break; } } } }; return i.toLocaleLowerCase() !== "card" && (c.hide = !0, delete c.properties.showLabelType), c; } getExpandProperties(e, o = "Card") { const i = this, l = ["Const", "Variable"], a = this.getPropertyEditorParams(e, l, "expandable"), r = this.getPropertyEditorParams(e, l, "expandDisabled"); return o === "Card" ? { description: "Expand Information", hide: !!this.formRule, title: "扩展区域", properties: { expandable: { description: "扩展区域是指输入框右侧的区域,常用于展示自定义按钮或者文本,以便于丰富输入控件的展示内容。", title: "启用扩展区域", refreshPanelAfterChanged: !0, $converter: "/converter/property-editor.converter", editor: a }, expandMode: { description: "静态文本:扩展内容不可点击;交互式按钮:扩展内容可以点击并配置交互事件。", title: "扩展模式", type: "enum", refreshPanelAfterChanged: !0, $converter: "/converter/property-editor.converter", editor: { data: [{ id: "text", name: "静态文本" }, { id: "button", name: "交互按钮" }] }, defaultValue: "text", visible: !!e.editor.expandable }, expandContent: { $converter: "/converter/property-editor.converter", description: "扩展区域内展示的文本内容", title: "扩展内容", type: "string", visible: !!e.editor.expandable, editor: { type: "code-editor", language: "html" } }, expandDisabled: { $converter: "/converter/property-editor.converter", description: "是否动态隐藏扩展区域,常用于根据变量或自定义条件配置扩展区域的隐藏状态。", title: "隐藏扩展区域", editor: r, visible: !!e.editor.expandable } }, setPropertyRelates(d, c) { if (d) switch (d.propertyID) { case "expandable": case "expandDisabled": i.afterMutilEditorChanged(e, d); break; } } } : { properties: {} }; } /** * 校验控件是否支持切换类型 * @param control 控件 */ checkCanChangeControlType(e, o) { if (!e.binding) return !1; if (e.binding.type === "Variable") { if (this.bindingVarible = this.formSchemaUtils.getVariableById(e.binding.field), !this.bindingVarible) return !1; } else if (!this.designViewModelField || this.designViewModelField.$type !== Se.SimpleField) return !1; return !0; } /** * 获取可选的编辑器类型 */ getAvailableEditorType(e) { var l, a; const o = this.checkCanChangeControlType(e, this.viewModelId); if (!o) return { canChangeControlType: !1, editorTypeList: [{ key: e.editor.type, value: ((l = C[e.editor.type]) == null ? void 0 : l.name) || e.editor.type }] }; let i = []; return this.designViewModelField && this.designViewModelField.$type === Se.SimpleField ? i = me.getEditorTypesByMDataType(this.designViewModelField.type.name, this.designViewModelField.multiLanguage) : this.bindingVarible && (i = me.getEditorTypesByMDataType(this.bindingVarible.type, !!((a = this.designViewModelField) != null && a.multiLanguage))), { canChangeControlType: o, editorTypeList: i }; } changeBindingField(e, o, i) { o.needRefreshEntityTree = !0; } getAppearanceProperties(e, o) { const i = this; return { title: "外观", description: "Appearance", properties: { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" }, style: { title: "style样式", type: "string", description: "组件的内联样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" }, fill: { title: "填充宽度", description: "启用后,控件占满父容器宽度", type: "boolean", parentPropertyID: "appearance", defaultValue: !1 }, responseLayout: { description: "响应式列宽", title: "响应式列宽", type: "boolean", visible: !i.formRule, // 这个属性,标记当属性变更得时候触发重新更新属性 refreshPanelAfterChanged: !0, editor: { type: "response-layout-editor-setting", beforeOpen: () => i.responseLayoutEditorFunction.checkCanOpenLayoutEditor(e, i.componentId) } } }, setPropertyRelates(l, a) { if (l) switch (l && l.propertyID) { case "responseLayout": i.responseLayoutEditorFunction.changeFormControlsByResponseLayoutConfig(l.propertyValue, i.componentId || e.id), i.updateUnifiedLayoutAfterResponseLayoutChanged(i.componentId), i.updateElementByParentContainer(e.id, o), delete e.responseLayout; break; case "class": i.updateUnifiedLayoutAfterControlChanged(l.propertyValue, e.id, this.componentId), de.value++; break; case "style": { de.value++; break; } } } }; } getEditorProperties(e) { return this.getComponentConfig(e); } /** * 卡片控件:切换控件类型后事件 * @param propertyData 控件DOM属性 * @param newControlType 新控件类型 */ changeControlType(e, o, i) { var m; const l = o.propertyValue, a = i && i.parent && i.parent.schema; if (!a) return; const r = a.contents.findIndex((f) => f.id === e.id); if (r === -1) return; const s = a.contents[r]; let d; if (this.designViewModelField) { const F = this.formSchemaUtils.getViewModelById(this.viewModelId).fields.find((V) => V.id === this.designViewModelField.id).fieldSchema || {}; F.editor || (F.editor = {}), F.editor.$type = l, this.designViewModelUtils.getDgViewModel(this.viewModelId).changeField(this.designViewModelField.id, F, !1), d = this.controlCreatorUtils.setFormFieldProperty(this.designViewModelField, l); } d || (d = this.controlCreatorUtils.createFormGroupWithoutField(l)), Object.assign(d, { id: s.id, appearance: s.appearance, size: s.size, label: s.label, binding: s.binding }), Object.prototype.hasOwnProperty.call(s, "visible") && Object.assign(d, { visible: s.visible }), s.editor && ["readonly", "required", "placeholder"].map((f) => { Object.prototype.hasOwnProperty.call(s.editor, f) && (d.editor[f] = s.editor[f]); }); const c = ["image", "avatar"], u = s.editor.type && c.indexOf(s.editor.type) > -1, y = ((m = d.editor) == null ? void 0 : m.type) && c.indexOf(d.editor.type) > -1; u && s.showLabelType === "none" && !y && (d.showLabelType = "visible"), i != null && i.updateContextSchema ? i.updateContextSchema(d) : (i.schema = Object.assign(s, d), Object.assign(e, d)), Array.from(document.getElementsByClassName("dgComponentSelected")).forEach( (f) => f.classList.remove("dgComponentSelected") ), Array.from(document.getElementsByClassName("dgComponentFocused")).forEach( (f) => f.classList.remove("dgComponentFocused") ), ["time-picker", "date-picker", "lookup", "combo-list", "number-spinner", "input-group", "textarea", "rich-text-editor", "language-textbox"].includes(e.editor.type) || (e.enableTips = !1), de.value++, ie(() => { this.getFormDesignerInstance().reloadPropertyPanel(); }); } getTipsConfig(e) { return ["time-picker", "date-picker", "lookup", "combo-list", "number-spinner", "input-group", "textarea", "rich-text-editor", "language-textbox"].includes(e.editor.type) ? { enableTips: { refreshPanelAfterChanged: !0, description: "", title: "启用提示", type: "boolean", default: !1, visible: !this.formRule }, tipsContent: { description: "提示内容", title: "提示内容", type: "string", editor: { type: "code-editor", language: "html", leftTemplate: en }, visible: !!e.enableTips && !this.formRule } } : {}; } getComponentConfig(e, o = {}, i = {}, l) { var y, h, m; const a = Object.assign({ description: "编辑器", title: "编辑器", type: "input-group", $converter: "/converter/property-editor.converter", parentPropertyID: "editor" }, o), r = (y = e.binding) != null && y.field ? ["Const", "Variable", "StateMachine", "Custom", "Expression"] : ["Const", "Variable", "StateMachine", "Custom"], s = this.getPropertyEditorParams(e, r, "readonly"), d = this.getPropertyEditorParams(e, r, "required"), c = { readonly: { description: "", title: "只读", editor: s }, required: { description: "", title: "必填", type: "boolean", editor: d, visible: !!((h = e.binding) != null && h.field) && ((m = e.binding) == null ? void 0 : m.type) === "Form" }, placeholder: { description: "当控件没有值时在输入框中显示的文本", title: "提示文本", type: "string" } }; for (const f in i) c[f] = Object.assign(c[f] || {}, i[f]); const u = this; return { ...a, properties: { ...c }, setPropertyRelates(f, M) { if (f) { switch (f.propertyID) { case "readonly": case "required": case "label": u.afterMutilEditorChanged(e, f); break; } l && l.bind(u)(f, e, M); } } }; } /** * 修改某一输入控件的样式后更新Form的统一布局配置 * @param controlClass 控件样式 * @param controlId 控件Id * @param componentId 控件所在组件id */ updateUnifiedLayoutAfterControlChanged(e, o, i) { const l = e.split(" "); let a = l.find((u) => /^col-([1-9]|10|11|12)$/.test(u)), r = l.find((u) => /^col-md-([1-9]|10|11|12)$/.test(u)), s = l.find((u) => /^col-xl-([1-9]|10|11|12)$/.test(u)), d = l.find((u) => /^col-el-([1-9]|10|11|12)$/.test(u)); a = a || "col-12", r = r || "col-md-" + a.replace("col-", ""), s = s || "col-xl-" + r.replace("col-md-", ""), d = d || "col-el-" + s.replace("col-xl-", ""); const c = { id: o, columnInSM: parseInt(a.replace("col-", ""), 10), columnInMD: parseInt(r.replace("col-md-", ""), 10), columnInLG: parseInt(s.replace("col-xl-", ""), 10), columnInEL: parseInt(d.replace("col-el-", ""), 10) }; this.updateUnifiedLayoutAfterResponseLayoutChanged(i, c); } /** * 修改控件布局配置后更新Form统一布局配置 * @param componentId 组件Id * @param controlLayoutConfig 某单独变动的控件配置项,FormResponseLayoutContext类型 */ updateUnifiedLayoutAfterResponseLayoutChanged(e, o) { const { formNode: i } = this.responseLayoutEditorFunction.checkCanFindFormNode(e); if (!i || !i.unifiedLayout) return; const l = []; if (this.responseLayoutEditorFunction.getResonseFormLayoutConfig(i, l, 1), o) { const m = l.find((f) => f.