UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,010 lines (1,009 loc) 33.2 kB
var W = Object.defineProperty; var X = (c, e, t) => e in c ? W(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t; var C = (c, e, t) => X(c, typeof e != "symbol" ? e + "" : e, t); import { defineComponent as L, ref as P, computed as k, createVNode as w, inject as $, onMounted as Y } from "vue"; import { isPlainObject as j, cloneDeep as _ } from "lodash-es"; import { UseTemplateDragAndDropRules as Z, useDragulaCommonRule as H, DgControl as S, useDesignerComponent as K } from "../designer-canvas/index.esm.js"; import { FormBindingType as D } from "../property-panel/index.esm.js"; import { useDesignerRules as q } from "../dynamic-form/index.esm.js"; import { getSchemaByType as ee } from "../dynamic-resolver/index.esm.js"; const te = {}, ne = {}; function z(c) { const { properties: e, title: t, ignore: n } = c, s = n && Array.isArray(n), o = Object.keys(e).reduce((i, l) => ((!s || !n.find((r) => r === l)) && (i[l] = e[l].type === "object" && e[l].properties ? z(e[l]) : _(e[l].default)), i), {}); if (t && (!s || !n.find((i) => i === "id"))) { const i = t.toLowerCase().replace(/-/g, "_"); o.id = `${i}_${Math.random().toString().slice(2, 6)}`; } return o; } function se(c, e) { const t = z(e); return Object.keys(t).reduce((n, s) => (Object.prototype.hasOwnProperty.call(c, s) && (n[s] && j(n[s]) && j(c[s] || !c[s]) ? Object.assign(n[s], c[s] || {}) : n[s] = c[s]), n), t), t; } function J(c, e) { return Object.keys(c).filter((n) => c[n] != null).reduce((n, s) => { if (e.has(s)) { const o = e.get(s); if (typeof o == "string") n[o] = c[s]; else { const i = o(s, c[s], c); Object.assign(n, i); } } else n[s] = c[s]; return n; }, {}); } function ie(c, e, t = /* @__PURE__ */ new Map()) { const n = se(c, e); return J(n, t); } function oe(c = {}) { function e(a, d, u, f) { if (typeof u == "number") return f[a].length === u; if (typeof u == "object") { const g = Object.keys(u)[0], m = u[g]; if (g === "not") return Number(f[a].length) !== Number(m); if (g === "moreThan") return Number(f[a].length) >= Number(m); if (g === "lessThan") return Number(f[a].length) <= Number(m); } return !1; } function t(a, d, u, f) { return f[a] && f[a].propertyValue && String(f[a].propertyValue.value) === String(u); } const n = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(c).reduce((a, d) => (a.set(d, c[d]), a), n); function s(a, d) { const u = a; return typeof d == "number" ? [{ target: u, operator: "length", param: null, value: Number(d) }] : typeof d == "boolean" ? [{ target: u, operator: "getProperty", param: a, value: !!d }] : typeof d == "object" ? Object.keys(d).map((f) => { if (f === "length") return { target: u, operator: "length", param: null, value: d[f] }; const g = f, m = d[f]; return { target: u, operator: "getProperty", param: g, value: m }; }) : []; } function o(a) { return Object.keys(a).reduce((u, f) => { const g = s(f, a[f]); return u.push(...g), u; }, []); } function i(a, d) { if (n.has(a.operator)) { const u = n.get(a.operator); return u && u(a.target, a.param, a.value, d) || !1; } return !1; } function l(a, d) { return o(a).reduce((g, m) => g && i(m, d), !0); } function r(a, d) { const u = Object.keys(a), f = u.includes("allOf"), g = u.includes("anyOf"), m = f || g, p = (m ? a[m ? f ? "allOf" : "anyOf" : "allOf"] : [a]).map((v) => l(v, d)); return f ? !p.includes(!1) : p.includes(!0); } return { parseValueSchema: r }; } const re = { button: { type: "button", name: "按钮" }, "response-toolbar": { type: "response-toolbar", name: "工具栏" }, "response-toolbar-item": { type: "response-toolbar-item", name: "按钮" }, "content-container": { type: "content-container", name: "容器" }, "input-group": { type: "input-group", name: "文本" }, textarea: { type: "textarea", name: "多行文本" }, lookup: { type: "lookup", name: "帮助" }, "number-spinner": { type: "number-spinner", name: "数值" }, "date-picker": { type: "date-picker", name: "日期" }, switch: { type: "switch", name: "开关" }, "radio-group": { type: "radio-group", name: "单选组" }, "check-box": { type: "check-box", name: "复选框" }, "check-group": { type: "check-group", name: "复选框组" }, "combo-list": { type: "combo-list", name: "下拉列表" }, "response-form": { type: "response-form", name: "卡片面板" }, "response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" }, "response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" }, "tree-grid": { type: "tree-grid", name: "树表格" }, "tree-grid-column": { type: "tree-grid-column", name: "树表格列" }, "data-grid": { type: "data-grid", name: "表格" }, "data-grid-column": { type: "data-grid-column", name: "表格列" }, module: { type: "Module", name: "模块" }, component: { type: "component", name: "组件" }, tabs: { type: "tabs", name: "标签页" }, "tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" }, "tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" }, "html-template": { type: "html-template", name: "模板容器" }, "time-picker": { type: "time-picker", name: "时间选择" }, section: { type: "section", name: "分组面板" }, "section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" }, "section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" }, splitter: { type: "splitter", name: "分栏面板" }, "splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" }, "component-ref": { type: "component-ref", name: "组件引用节点" }, uploader: { type: "uploader", name: "附件上传" }, "page-header": { type: "page-header", name: "页头" }, "page-footer": { type: "page-footer", name: "页脚" }, "tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" }, fieldset: { type: "fieldset", name: "分组" }, "query-solution": { type: "query-solution", name: "筛选方案" }, drawer: { type: "drawer", name: "抽屉" }, "external-container": { type: "external-container", name: "外部容器", icon: "content-container" }, "list-nav": { type: "list-nav", name: "列表导航" }, "filter-bar": { type: "filter-bar", name: "筛选条" } }, ae = {}, le = {}; oe(); function ce(c, e, t = /* @__PURE__ */ new Map(), n = (i, l, r, a) => l, s = {}, o = (i) => i) { return te[e.title] = e, ne[e.title] = n, ae[e.title] = s, le[e.title] = o, (i = {}, l = !0) => { if (!l) return J(i, t); const r = ie(i, e, t), a = Object.keys(c).reduce((d, u) => (d[u] = c[u].default, d), {}); return Object.assign(a, r); }; } function de(c, e) { return { customClass: e.class, customStyle: e.style }; } const ue = /* @__PURE__ */ new Map([ ["appearance", de] ]), pe = "https://json-schema.org/draft/2020-12/schema", fe = "https://farris-design.gitee.io/fieldset.schema.json", me = "fieldset", ge = "A Farris Container Component", he = "object", ye = { id: { description: "The unique identifier for a fieldset", type: "string" }, type: { description: "The type string of fieldset component", type: "string", default: "fieldset" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, title: { description: "The title for a fieldset", type: "string" }, contents: { description: "", type: "array", default: [] } }, be = [ "id", "type", "contents" ], Ce = { $schema: pe, $id: fe, title: me, description: ge, type: he, properties: ye, required: be }; function we(c, e, t) { return Object.assign(e, { appearance: { class: "col-12" }, title: "分组标题" }), e; } const B = { /** 组件自定义样式 */ customClass: { type: String, default: "" }, customStyle: { type: String, default: "" }, /** 标题 */ title: { type: String, default: "" } }, ve = Object.assign({}, B, { componentId: { type: String, default: "" } }), G = ce(B, Ce, ue, we), T = /* @__PURE__ */ L({ name: "FFieldset", props: B, emits: [], setup(c, e) { const t = P(!0); function n(l, r) { l && r && r.split(" ").reduce((d, u) => (d[u] = !0, d), l); } const s = k(() => { const l = { "f-section-formgroup": !0, "f-state-collapse": !t.value }; return n(l, c.customClass), l; }), o = k(() => ({ btn: !0, "f-btn-mx": !0, "f-btn-collapse-expand": !0, "f-state-expand": t.value })); function i() { t.value = !t.value; } return () => w("fieldset", { class: s.value, style: c.customStyle }, [w("legend", { class: "f-section-formgroup-legend" }, [w("div", { class: "f-header" }, [w("div", { class: "f-title", onClick: i }, [c.title]), w("div", { class: "f-toolbar", onClick: i }, [w("button", { class: o.value }, null)])])]), w("div", { class: "f-section-formgroup-inputs" }, [e.slots.default && e.slots.default()])]); } }), Ie = P(0); function Me() { Ie.value++; } const xe = P(0); function Ve(c) { const { formSchemaUtils: e, formStateMachineUtils: t } = c; function n(r, a = "") { return { path: a + r.code, field: r.id, fullPath: r.code }; } function s(r, a = "") { return e.getViewModelById(r).states.map((u) => n(u, a)); } function o(r) { const a = e.getRootViewModelId(), d = s(r); if (r === a) return d; const u = s(a, "root-component."); return [...d, ...u]; } function i(r) { return r.binding && r.binding.path || r.id || ""; } function l() { return t && t.getRenderStates() || []; } return { getVariables: o, getControlName: i, getStateMachines: l }; } class Ee { constructor(e) { C(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'" } ]); C(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); C(this, "getExpressionConverter", (e, t) => ({ convertFrom: (n, s, o, i) => { const l = o.getExpressionRuleValue(e, t || s); return l && l.value || ""; }, convertTo: (n, s, o, i, l) => { var r; if (s === "dataPicking" && (o != null && o.target)) { const a = `${o.target}_dataPicking`; ((r = o.rules) == null ? void 0 : r.some( (u) => u.id === a && u.value )) ? n.dictPickingExpressionId = a : delete n.dictPickingExpressionId; } i.updateExpression(o); } })); this.formSchemaService = e; } getExpressionRule(e, t) { const n = this.formSchemaService.getExpressions(); if (!n) return ""; const s = n.find((i) => i.target === e); if (!s) return ""; const o = s.rules.find((i) => i.type === t); return o || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: e } = this.formSchemaService.getFormSchema(); if (!e.viewmodels || e.viewmodels.length === 0) return []; const t = this.formSchemaService.getRootViewModelId(), n = this.formSchemaService.getViewModelById(t); if (!n || !n.states || n.states.length === 0) return []; const s = []; return n.states.forEach((o) => { s.push({ key: o.code, name: o.name, description: o.name, category: o.category }); }), s; } createTreeNode(e, t, n = "label") { return { id: e.id, name: e.name, bindingPath: e[n], parents: t }; } buildEntityFieldsTreeData(e = null, t) { const n = []; return e == null || e.forEach((s) => { var l; const o = this.createTreeNode(s, t); let i = []; (l = s.type) != null && l.fields && (i = this.buildEntityFieldsTreeData(s.type.fields, [...t, s.label])), n.push({ data: o, children: i, expanded: !0 }); }), n; } buildChildEntityTreeData(e = null, t) { const n = []; return e == null || e.forEach((s) => { var r, a; const o = this.createTreeNode(s, t), i = this.buildEntityFieldsTreeData((r = s.type) == null ? void 0 : r.fields, [...t, s.label]), l = this.buildChildEntityTreeData((a = s.type) == null ? void 0 : a.entities, [...t, s.label]); l != null && l.length && (i == null || i.push(...l)), n.push({ data: o, children: i || [], // 空值回退 expanded: !0 }); }), n; } getEntitiesTreeData() { const e = this.formSchemaService.getSchemaEntities(); if (!(e != null && e.length)) return []; const t = e[0]; if (!(t != null && t.type)) return []; const n = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), s = this.buildChildEntityTreeData(t.type.entities, [t.code]); return s != null && s.length && (n == null || n.push(...s)), { entityCode: t.code, fields: [{ data: this.createTreeNode(t, [], "code"), children: n || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(e, t, n) { const s = n === "Field" ? e.binding.field : e.id, o = this.getExpressionRule(s, t), i = this.getEntitiesAndVariables(), l = { message: ["validate", "required", "dataPicking"].includes(t) && o ? o.message : "", ...i }; return o.messageType != null && (l.messageType = o.messageType), l; } buildRule(e, t, n, s) { const { expression: o, message: i, messageType: l } = t, r = { id: `${e}_${n}`, type: n, value: o }; return (n === "validate" || n === "dataPicking" || n === "required") && (r.message = i), n === "dataPicking" && (r.messageType = l), n === "validate" && s && (r.elementId = s), r; } getExpressionData() { const { expressions: e } = this.formSchemaService.getFormSchema().module; return e || []; } updateExpression(e, t, n, s) { const o = t === "Field" ? e.binding.field : e.id, i = this.buildRule(o, n, s, e.type === "form-group" ? e.id : ""); let r = this.getExpressionData().find((d) => d.targetType === t && d.target === o); const a = (d) => d.value.trim() === ""; if (r) { const d = r.rules.find((u) => u.id === i.id); if (d) a(i) ? r.rules = r.rules.filter((u) => u.id !== i.id) : (Object.assign(d, i), s === "validate" && e.type === "form-group" && (d.elementId = e.id)); else { if (a(i)) return null; r.rules = r.rules || [], r.rules.push(i); } } else { if (a(i)) return null; r = { target: `${o}`, rules: [i], targetType: t }; } return r; } getExpressionEditorOptions(e, t, n, s) { return n.reduce((o, i) => { var r, a; const l = t === "Field" ? (r = e == null ? void 0 : e.binding) == null ? void 0 : r.field : e.id; return o[i] = { hide: t === "Field" ? !!((a = e == null ? void 0 : e.binding) != null && a.field) : !1, description: "", title: this.expressionNames[i], type: "string", $converter: this.getExpressionConverter(l), editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[i]}编辑器`, showMessage: i === "validate" || i === "dataPicking" || i === "required", showMessageType: i === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(e, i, t), onSubmitModal: (d) => { const u = this.updateExpression(e, t, d, i); if (s) { const f = this.buildRule(l, d, i); s(f); } return u; } } }, o; }, {}); } getExpressionInfo(e, t, n) { const s = t === "Field" ? e.binding.field : e.id, o = this.getExpressionRule(s, n), i = { value: o && o.value, targetId: s, targetType: t, expressionType: n }; return o && o.message && (i.message = o.message), i; } getExpressionConfig(e, t, n = ["compute", "dependency", "validate"], s) { return { description: "表达式", title: "表达式", properties: { ...this.getExpressionEditorOptions(e, t, n, s) } }; } getExpressionOptions(e, t, n) { const s = this.getExpressionInfo(e, t, n); return { dialogTitle: `${this.expressionNames[n]}编辑器`, singleExpand: !1, showMessage: n === "required", beforeOpen: () => this.onBeforeOpenExpression(e, n, t), expressionInfo: s }; } } class Pe { constructor(e, t) { C(this, "componentId"); C(this, "viewModelId"); C(this, "eventsEditorUtils"); C(this, "formSchemaUtils"); C(this, "formMetadataConverter"); C(this, "designViewModelUtils"); C(this, "designViewModelField"); C(this, "controlCreatorUtils"); C(this, "designerHostService"); C(this, "schemaService", null); C(this, "metadataService", null); C(this, "propertyConfig", { type: "object", categories: {} }); var n; this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((n = this.formSchemaUtils) == null ? void 0 : n.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = t.designViewModelUtils, this.controlCreatorUtils = t.controlCreatorUtils, this.metadataService = t.metadataService, this.schemaService = t.schemaService; } getTableInfo() { var e; return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(e) { var n; const t = e.binding && e.binding.type === "Form" && e.binding.field; if (t) { if (!this.designViewModelField) { const s = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = s.fields.find((o) => o.id === t); } e.updateOn = (n = this.designViewModelField) == null ? void 0 : n.updateOn; } } getBasicPropConfig(e) { 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: e.type, name: re[e.type].name }] } } } }; } getAppearanceConfig(e = null, t = {}, n) { const s = { title: "外观", description: "Appearance" }, o = { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter" } }; for (const i in t) o[i] = Object.assign(o[i] || {}, t[i]); return { ...s, properties: { ...o }, setPropertyRelates(i, l) { if (i) { switch (i && i.propertyID) { case "class": case "style": { xe.value++; break; } } n && n(i, e, l); } } }; } getPropertyEditorParams(e, t = [], n = "visible", s = {}, o = {}) { const { getVariables: i, getControlName: l, getStateMachines: r } = Ve(this.designerHostService), a = this.getRealTargetType(e), d = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], u = { type: "property-editor", propertyTypes: d }; return d.map((f) => { switch (f) { case "Const": Object.assign(u, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, s); break; case "Expression": u.expressionConfig = this.getExpressionOptions(e, a, n); break; case "StateMachine": u.stateMachines = r(); break; case "Variable": Object.assign(u, { controlName: l(e), newVariablePrefix: "is", newVariableType: "Boolean", variables: i(this.viewModelId), onBeforeOpenVariables: (g) => { g.value = i(this.viewModelId); } }, o); break; } }), u; } getVisibleProperty(e, t = "") { return { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(e, t === "gridFieldEditor" ? ["Const", "Expression"] : ["Const", "Variable", "StateMachine", "Expression"], "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(e, t = "", n = {}, s) { const o = { title: "行为", description: "" }, i = this.getVisibleProperty(e, t); for (const r in n) i[r] = Object.assign(i[r] || {}, n[r]); const l = this; return { ...o, properties: { ...i }, setPropertyRelates(r, a) { if (r) { switch (r.propertyID) { case "disabled": case "readonly": case "visible": l.afterMutilEditorChanged(e, r); break; } s && s(r, a); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(e, t) { this.addNewVariableToViewModel(t, this.viewModelId), this.updateExpressionValue(t), this.clearExpression(t, e); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(e, t) { const n = t && t.parent && t.parent.schema; if (!n) return; const s = n.contents.findIndex((i) => i.id === e), o = _(n.contents[s]); n.contents.splice(s, 1), n.contents.splice(s, 0, o), Me(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(e, t) { const n = e.propertyValue; if (!(n && typeof n == "object") || !(n.type === "Variable" && n.isNewVariable)) return; const i = { id: n.field, category: "locale", code: n.fullPath, name: n.fullPath, type: n.newVariableType || "String" }; delete n.newVariableType, delete n.isNewVariable, this.formSchemaUtils.getVariableByCode(i.code) || this.formSchemaUtils.getViewModelById(t).states.push(i); } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(e) { const t = e.propertyValue; if (!((t && t.type) === "Expression" && t.expressionInfo)) return; const { expressionId: o, expressionInfo: i } = t, { targetId: l, targetType: r, expressionType: a, value: d, message: u } = i, f = this.formSchemaUtils.getModule(); f.expressions ?? (f.expressions = []); const { expressions: g } = f; let m = g.find((E) => E.target === l); m || (m = { target: l, rules: [], targetType: r }, g.push(m)); const V = m.rules.find((E) => E.type === a); if (V) V.value = d, V.message = u; else { const E = { id: o, type: a, value: d, message: u }; m.rules.push(E); } delete t.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(e, t) { const n = e.propertyValue; if (n && n.type === "Expression") return; const o = e.propertyID, i = this.formSchemaUtils.getExpressions(), l = t.binding ? t.binding.field : t.id, r = i.find((a) => a.target === l); !r || !r.rules || (r.rules = r.rules.filter((a) => a.type !== o)); } getExpressionOptions(e, t, n) { return new Ee(this.formSchemaUtils).getExpressionOptions(e, t, n); } getRealTargetType(e) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item"].indexOf(e.type) > -1 ? "Button" : e.binding && e.binding.field ? "Field" : "Container"; } } class ke extends Pe { constructor(e, t) { super(e, t); } getPropertyConfig(e) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(e), this.propertyConfig.categories.appearance = this.getAppearanceProperties(e), this.propertyConfig; } getAppearanceProperties(e) { const t = this; return this.getAppearanceConfig(e, { title: { title: "标题", type: "string", description: "标题" } }, (s, o, i) => { switch (s && s.propertyID) { case "title": { s.needRefreshControlTree = !0, t.changeGroupNameInViewModel(o.id, s.propertyValue); break; } } }); } /** * 修改分组标题后,需要同步viewmodel中字段的分组信息 */ changeGroupNameInViewModel(e, t) { var o; const n = this.designViewModelUtils.getDgViewModel(this.viewModelId); n && n.changeGroupName(e, t); const s = this.formSchemaUtils.getViewModelById(this.viewModelId); (o = s == null ? void 0 : s.fields) != null && o.length && s.fields.forEach((i) => { i.groupId === e && (i.groupName = t); }); } } function Fe(c, e) { const t = new Z(), { canAccept: n } = t.getTemplateRule(c, e), s = c.schema; function o() { return "f-section-formgroup"; } function i() { return !0; } function l() { return !0; } function r() { return !1; } function a(p) { const { sourceElement: h } = p, { componentInstance: v } = h, y = e == null ? void 0 : e.formSchemaUtils; if (!y) return !0; const M = y.getComponentById(v.value.belongedComponentId), b = y.getViewModelById(M.viewModel), I = y.getComponentById(c.componentInstance.value.belongedComponentId), x = y.getViewModelById(I.viewModel); return b != null && b.id && (x != null && x.id) && b.id !== x.id ? b.bindTo === x.bindTo : !0; } function d(p) { const { bindingTargetId: h } = p; if (!e) return; const { formSchemaUtils: v, schemaService: y } = e, M = v.getComponentById(c.componentInstance.value.belongedComponentId), b = y.getFieldByIDAndVMID(h, M.viewModel); return !!(b != null && b.schemaField); } function u(p) { return p.sourceType === "control" && p.componentCategory === "input" ? !0 : p.sourceType === "move" && p.componentType === "form-group" ? a(p) : p.sourceType === "field" && p.componentCategory === "input" ? d(p) : !1; } function f(p) { return !(!H().basalDragulaRuleForContainer(p, e) || !n || !u(p)); } function g(p) { return new ke(p, e).getPropertyConfig(s); } function m(p) { var x, F, N, R, U; if (!e) return; const { formSchemaUtils: h, designViewModelUtils: v } = e, y = p.componentInstance, M = y.value.parent, b = h.getComponentById(y.value.belongedComponentId), I = v.getDgViewModel(b.viewModel); switch (M && ((x = M.schema) == null ? void 0 : x.type)) { case S.fieldset.type: case S["response-form"].type: case S["response-layout-item"].type: { const O = { groupId: s.id, groupName: s.title }, Q = (N = (F = y.value.schema) == null ? void 0 : F.binding) == null ? void 0 : N.type, A = (U = (R = y.value.schema) == null ? void 0 : R.binding) == null ? void 0 : U.field; switch (Q) { case D.Form: { I.changeField(A, O); break; } case D.Variable: { h.modifyViewModelFieldById(b.viewModel, A, O, !0); break; } } break; } } } function V(p) { if (!p || !p.componentInstance || !e) return; const h = p.componentInstance, v = h.value.schema; if (!v.binding || !v.binding.field) return; m(p); const { formSchemaUtils: y } = e, M = y.getViewModelIdByComponentId(h.value.belongedComponentId), b = y.getViewModelIdByComponentId(c.componentInstance.value.belongedComponentId); M !== b && q(c, e).moveInputBetweenComponent(p); } function E(p, h) { var v, y, M; if (p.componentCategory === "input") { const { label: b } = p; let I; (v = p.bindingSourceContext) != null && v.entityFieldNode ? I = (e == null ? void 0 : e.controlCreatorUtils).setFormFieldProperty((y = p.bindingSourceContext) == null ? void 0 : y.entityFieldNode, h == null ? void 0 : h.type) : (I = ee("form-group"), I.editor = h, I.label = b); const x = q(c, e); return x.resolveFormGroupAppearance(I), x.syncFieldToViewModel(p, (M = I.editor) == null ? void 0 : M.type, s.id, s.title), I; } return h; } return { canAccepts: f, hideNestedPaddingInDesginerView: r, getPropsConfig: g, checkCanDeleteComponent: i, checkCanMoveComponent: l, onAcceptMovedChildElement: V, onResolveNewComponentSchema: E, getDesignerClass: o }; } const Se = /* @__PURE__ */ L({ name: "FFieldsetDesign", props: ve, emits: [], setup(c, e) { const t = P(), n = P(), s = $("design-item-context"), o = $("designer-host-service"), i = Fe(s, o), l = K(n, s, i); e.expose(l.value), Y(() => { n.value.componentInstance = l; }); const r = P(!0); function a(m, V) { m && V && V.split(" ").reduce((p, h) => (p[h] = !0, p), m); } const d = k(() => { const m = { "f-section-formgroup": !0, "f-state-collapse": !r.value }; return a(m, c.customClass), m; }), u = k(() => ({ display: r.value ? "flex" : "none", "flex-wrap": "wrap" })), f = k(() => ({ btn: !0, "f-btn-mx": !0, "f-btn-collapse-expand": !0, "f-state-expand": r.value })); function g() { r.value = !r.value; } return () => w("fieldset", { class: d.value, ref: t }, [w("legend", { class: "f-section-formgroup-legend" }, [w("div", { class: "f-header" }, [w("div", { class: "f-title", onClick: g }, [c.title]), w("div", { class: "f-toolbar", onClick: g }, [w("button", { class: f.value }, null)])])]), w("div", { "data-dragref": `${s.schema.id}-container`, ref: n, class: "f-section-formgroup-inputs drag-container", style: u.value }, [e.slots.default && e.slots.default()])]); } }), $e = { install(c) { c.component(T.name, T); }, register(c, e, t, n) { c.fieldset = T, e.fieldset = G; }, registerDesigner(c, e, t) { c.fieldset = Se, e.fieldset = G; } }; export { T as Fieldset, $e as default, ve as fieldsetDesignerProps, B as fieldsetProps, G as propsResolver };