UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,472 lines 423 kB
var ar = Object.defineProperty; var ir = (n, t, e) => t in n ? ar(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var L = (n, t, e) => ir(n, typeof t != "symbol" ? t + "" : t, e); import { defineComponent as qe, ref as x, computed as G, withDirectives as Tn, createVNode as I, resolveDirective as Fn, inject as rt, onMounted as yt, watch as Fe, createTextVNode as Ke, mergeProps as gt, Fragment as Zt, reactive as _t, createApp as Kn, onUnmounted as cn, Transition as Jn, onBeforeUnmount as eo, nextTick as dn, provide as sr, triggerRef as lr, isVNode as ur, onBeforeMount as cr, Teleport as dr, shallowRef as fr, render as fn, h as pr, cloneVNode as mr } from "vue"; import { isPlainObject as Nn, cloneDeep as Et, isUndefined as dt, throttle as hr } from "lodash-es"; import { FormSchemaEntityFieldTypeName as Rn, useGuid as gn, areaResponseDirective as vr, useTextBoxDesign as gr, useClear as yr, resolveField as it, useCommonUtils as br, useDateFormat as wr, useNumberFormat as Cr, setFieldValue as yn, getCustomClass as pn, withInstall as _r } from "../common/index.esm.js"; import { getSchemaByType as xr, schemaMap as Tr, createPropsResolver as Fr } from "../dynamic-resolver/index.esm.js"; import { DgControl as At, useDesignerComponent as Sr } from "../designer-canvas/index.esm.js"; import { FormBindingType as Nt, InputBaseProperty as kr } from "../property-panel/index.esm.js"; import Mr from "../accordion/index.esm.js"; import Er from "../avatar/index.esm.js"; import Ir from "../../designer/button-edit/index.esm.js"; import Or from "../button-group/index.esm.js"; import Dr from "../calendar/index.esm.js"; import Vr from "../capsule/index.esm.js"; import Ln from "../../designer/checkbox/index.esm.js"; import Wn from "../../designer/checkbox-group/index.esm.js"; import Lt from "../combo-list/index.esm.js"; import Pr from "../combo-tree/index.esm.js"; import Br from "../component/index.esm.js"; import Nr from "../color-picker/index.esm.js"; import Rr from "../content-container/index.esm.js"; import Lr from "../date-picker/index.esm.js"; import Wr from "../../designer/data-grid/index.esm.js"; import $r from "../dropdown/index.esm.js"; import jr, { FDynamicFormGroup as Ar, FDynamicFormInput as Hr } from "../dynamic-form/index.esm.js"; import Gr from "../events-editor/index.esm.js"; import qr from "../filter-bar/index.esm.js"; import zr from "../field-selector/index.esm.js"; import Yr from "../binding-selector/index.esm.js"; import Ur from "../image-cropper/index.esm.js"; import Xr from "../../designer/input-group/index.esm.js"; import Qr from "../layout/index.esm.js"; import Zr from "../list-nav/index.esm.js"; import Kr from "../list-view/index.esm.js"; import Jr from "../lookup/index.esm.js"; import ea from "../mapping-editor/index.esm.js"; import ta from "../nav/index.esm.js"; import na from "../number-range/index.esm.js"; import oa from "../number-spinner/index.esm.js"; import ra from "../order/index.esm.js"; import aa from "../page-header/index.esm.js"; import ia from "../page-footer/index.esm.js"; import sa from "../pagination/index.esm.js"; import la from "../progress/index.esm.js"; import ua from "../query-solution/index.esm.js"; import ca from "../../designer/radio-group/index.esm.js"; import da from "../rate/index.esm.js"; import fa from "../response-toolbar/index.esm.js"; import pa from "../response-layout/index.esm.js"; import ma from "../response-layout-editor/index.esm.js"; import ha from "../search-box/index.esm.js"; import va from "../section/index.esm.js"; import ga from "../smoke-detector/index.esm.js"; import ya from "../splitter/index.esm.js"; import ba from "../step/index.esm.js"; import wa from "../switch/index.esm.js"; import Ca from "../tabs/index.esm.js"; import _a from "../tags/index.esm.js"; import xa from "../text/index.esm.js"; import Ta from "../time-picker/index.esm.js"; import Fa from "../transfer/index.esm.js"; import Sa from "../tree-view/index.esm.js"; import ka from "../uploader/index.esm.js"; import Ma from "../verify-detail/index.esm.js"; import Ea from "../video/index.esm.js"; import Ia from "../textarea/index.esm.js"; import Oa from "../schema-selector/index.esm.js"; import Da from "../tree-grid/index.esm.js"; import Va from "../event-parameter/index.esm.js"; import Pa from "../filter-condition-editor/index.esm.js"; import Ba from "../fieldset/index.esm.js"; import Na from "../sort-condition-editor/index.esm.js"; import Ra from "../menu-lookup/index.esm.js"; import La from "../drawer/index.esm.js"; import Wa from "../json-editor/index.esm.js"; import $a from "../property-editor/index.esm.js"; import ja from "../expression-editor/index.esm.js"; import Aa from "../code-editor/index.esm.js"; import Ha from "../html-template/index.esm.js"; import "../external-container/index.esm.js"; import { useResizeObserver as to } from "@vueuse/core"; import { useIdentify as Ga, useGroupData as qa, useFilter as za, useHierarchy as Ya, useLoading as Ua, useDataView as Xa, useSelection as Qa, useSelectHierarchyItem as Za, useDataViewContainerStyle as Ka, useCommandColumn as Ja, useColumn as ei, useSort as ti, useGroupColumn as ni, useRow as oi, useEdit as ri, useVisualDataBound as ai, useVisualDataCell as ii, useVisualDataRow as si, useVisualData as li, useCellPosition as ui, useSidebar as ci, useVirtualScroll as di, useFitColumn as fi, useFilterHistory as pi, useColumnFilter as mi, useDragColumn as hi, getColumnHeader as vi, getSidebar as gi, getDisableMask as yi, getHorizontalScrollbar as bi, getVerticalScrollbar as wi, getEmpty as Ci } from "../data-view/index.esm.js"; import "../modal/index.esm.js"; import "../condition/index.esm.js"; import { FCheckbox as _i } from "../checkbox/index.esm.js"; import $n from "../tooltip/index.esm.js"; import xi from "../button/index.esm.js"; import "../notify/index.esm.js"; const no = {}, oo = {}; function Sn(n) { const { properties: t, title: e, ignore: o } = n, r = o && Array.isArray(o), a = Object.keys(t).reduce((i, s) => ((!r || !o.find((l) => l === s)) && (i[s] = t[s].type === "object" && t[s].properties ? Sn(t[s]) : Et(t[s].default)), i), {}); if (e && (!r || !o.find((i) => i === "id"))) { const i = e.toLowerCase().replace(/-/g, "_"); a.id = `${i}_${Math.random().toString().slice(2, 6)}`; } return a; } function Ti(n) { const { properties: t, title: e, required: o } = n; if (o && Array.isArray(o)) { const r = o.reduce((a, i) => (a[i] = t[i].type === "object" && t[i].properties ? Sn(t[i]) : Et(t[i].default), a), {}); if (e && o.find((a) => a === "id")) { const a = e.toLowerCase().replace(/-/g, "_"); r.id = `${a}_${Math.random().toString().slice(2, 6)}`; } return r; } return { type: e }; } function ro(n, t = {}, e) { const o = no[n]; if (o) { let r = Ti(o); const a = oo[n]; return r = a ? a({ getSchemaByType: ro }, r, t, e) : r, r; } return null; } function Fi(n, t) { const e = Sn(t); return Object.keys(e).reduce((o, r) => (Object.prototype.hasOwnProperty.call(n, r) && (o[r] && Nn(o[r]) && Nn(n[r] || !n[r]) ? Object.assign(o[r], n[r] || {}) : o[r] = n[r]), o), e), e; } function ao(n, t) { return Object.keys(n).filter((o) => n[o] != null).reduce((o, r) => { if (t.has(r)) { const a = t.get(r); if (typeof a == "string") o[a] = n[r]; else { const i = a(r, n[r], n); Object.assign(o, i); } } else o[r] = n[r]; return o; }, {}); } function Si(n, t, e = /* @__PURE__ */ new Map()) { const o = Fi(n, t); return ao(o, e); } function ki(n = {}) { function t(d, c, u, f) { if (typeof u == "number") return f[d].length === u; if (typeof u == "object") { const m = Object.keys(u)[0], p = u[m]; if (m === "not") return Number(f[d].length) !== Number(p); if (m === "moreThan") return Number(f[d].length) >= Number(p); if (m === "lessThan") return Number(f[d].length) <= Number(p); } return !1; } function e(d, c, u, f) { return f[d] && f[d].propertyValue && String(f[d].propertyValue.value) === String(u); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", e] ]); Object.keys(n).reduce((d, c) => (d.set(c, n[c]), d), o); function r(d, c) { const u = d; return typeof c == "number" ? [{ target: u, operator: "length", param: null, value: Number(c) }] : typeof c == "boolean" ? [{ target: u, operator: "getProperty", param: d, value: !!c }] : typeof c == "object" ? Object.keys(c).map((f) => { if (f === "length") return { target: u, operator: "length", param: null, value: c[f] }; const m = f, p = c[f]; return { target: u, operator: "getProperty", param: m, value: p }; }) : []; } function a(d) { return Object.keys(d).reduce((u, f) => { const m = r(f, d[f]); return u.push(...m), u; }, []); } function i(d, c) { if (o.has(d.operator)) { const u = o.get(d.operator); return u && u(d.target, d.param, d.value, c) || !1; } return !1; } function s(d, c) { return a(d).reduce((m, p) => m && i(p, c), !0); } function l(d, c) { const u = Object.keys(d), f = u.includes("allOf"), m = u.includes("anyOf"), p = f || m, v = (p ? d[p ? f ? "allOf" : "anyOf" : "allOf"] : [d]).map((y) => s(y, c)); return f ? !v.includes(!1) : v.includes(!0); } return { parseValueSchema: l }; } const ie = { 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: "筛选条" } }, io = {}, Mi = {}; ki(); function Gt(n, t, e = /* @__PURE__ */ new Map(), o = (i, s, l, d) => s, r = {}, a = (i) => i) { return no[t.title] = t, oo[t.title] = o, io[t.title] = r, Mi[t.title] = a, (i = {}, s = !0) => { if (!s) return ao(i, e); const l = Si(i, t, e), d = Object.keys(n).reduce((c, u) => (c[u] = n[u].default, c), {}); return Object.assign(d, l); }; } function kn(n, t) { return { customClass: t.class, customStyle: t.style }; } function Ei() { function n(t, e) { const { dataSource: o } = t || {}; return o === void 0 ? {} : {}; } return { resolve: n }; } function Ii() { function n(t, e) { return t.selectItemById(e); } return { selectItemById: n }; } function Oi() { function n(t) { return t.editor; } return { resolve: n }; } function Di() { function n(t, e) { const { columns: o } = e; return t.updateColumns(o); } return { updateColumns: n }; } const Mn = /* @__PURE__ */ new Map([ ["appearance", kn] ]), Vi = /* @__PURE__ */ new Map([]), Pi = "root-viewmodel"; class Bi { constructor(t, e) { L(this, "formSchemaUtils"); L(this, "controlCreatorUtils"); L(this, "designViewModelUtils"); this.resolver = t, this.designerHostService = e, this.formSchemaUtils = this.designerHostService.formSchemaUtils, this.controlCreatorUtils = this.designerHostService.controlCreatorUtils, this.designViewModelUtils = this.designerHostService.designViewModelUtils; } createComponent(t) { const e = this.createComponentRefNode(t), o = this.createComponentNode(t), r = this.createViewModeNode(t), a = this.formSchemaUtils.getFormSchema(); return a.module.viewmodels.push(r), a.module.components.push(o), this.designViewModelUtils.assembleDesignViewModel(), e; } createComponentRefNode(t) { const e = this.resolver.getSchemaByType("component-ref"); return Object.assign(e, { id: `${t.componentId}-component-ref`, component: `${t.componentId}-component` }), e; } createComponentNode(t) { const e = this.resolver.getSchemaByType("component"), o = this.createFormComponentContents(t); return Object.assign(e, { id: `${t.componentId}-component`, viewModel: `${t.componentId}-component-viewmodel`, componentType: t.componentType, appearance: { class: this.getFormComponentClass() }, formColumns: t.formColumns, contents: o }), e; } /** * 获取卡片组件层级的class样式 */ getFormComponentClass() { const { templateId: t } = this.formSchemaUtils.getFormSchema().module; return t === "double-list-in-tab-template" ? "f-struct-wrapper f-utils-fill-flex-column" : "f-struct-wrapper"; } createFormComponentContents(t) { const e = this.resolver.getSchemaByType("section"); Object.assign(e, { 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 }), e.contents = [o]; const { selectedFields: a } = t; a == null || a.forEach((s) => { const l = Et(s), d = this.resolveControlClassByFormColumns(t), c = this.controlCreatorUtils.setFormFieldProperty(l, "", d); c && r.push(c); }); const { templateId: i } = this.formSchemaUtils.getFormSchema().module; return i === "double-list-in-tab-template" && (e.appearance.class = "f-section-grid f-section-in-main px-0 pt-0", e.fill = !0), [e]; } resolveControlClassByFormColumns(t) { let e = ""; switch (t.formColumns) { case 1: { e = "col-12"; break; } case 2: { e = "col-12 col-md-6 col-xl-6 col-el-6"; break; } case 3: { e = "col-12 col-md-6 col-xl-4 col-el-4"; break; } case 4: { e = "col-12 col-md-6 col-xl-3 col-el-2"; break; } } return e; } /** * 添加viewModel节点 */ createViewModeNode(t) { return { id: `${t.componentId}-component-viewmodel`, code: `${t.componentId}-component-viewmodel`, name: t.componentName, bindTo: t.bindTo, parent: Pi, fields: this.assembleViewModelFields(t), commands: [], states: [], enableValidation: !0 }; } /** * 组装viewModel fields 节点 */ assembleViewModelFields(t) { const e = [], { selectedFields: o } = t; return o == null || o.forEach((r) => { let a = "blur"; const i = r.type.name; (i === Rn.Enum || i === Rn.Boolean) && (a = "change"), e.push({ type: "Form", id: r.id, fieldName: r.bindingField, groupId: null, groupName: null, updateOn: a, fieldSchema: {} }); }), e; } } function Ni(n, t, e, o) { var a, i, s, l, d, c; const r = e.parentComponentInstance; if (r && o) { const u = (a = r.schema) == null ? void 0 : a.type, m = { componentId: `form-${Math.random().toString(36).slice(2, 6)}`, componentName: ((i = e.bindingSourceContext) == null ? void 0 : i.entityTitle) || ((l = (s = e.bindingSourceContext) == null ? void 0 : s.bindingEntity) == null ? void 0 : l.name) || "标题", componentType: "form", formColumns: u === "splitter-pane" ? 1 : 4, parentContainerId: r.schema.id, bindTo: ((d = e.bindingSourceContext) == null ? void 0 : d.bindTo) || "/", selectedFields: (c = e.bindingSourceContext) == null ? void 0 : c.bindingEntityFields }; return new Bi(n, o).createComponent(m); } else return t; } function Ri(n, t, e) { return t; } const Li = "https://json-schema.org/draft/2020-12/schema", Wi = "https://farris-design.gitee.io/response-form.schema.json", $i = "response-form", ji = "A Farris Data Collection Component", Ai = "object", Hi = { 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 } }, Gi = [ "id", "type", "contents" ], qi = { $schema: Li, $id: Wi, title: $i, description: ji, type: Ai, properties: Hi, required: Gi }, so = { customClass: { type: String, default: "" }, customStyle: { type: String, defaut: "" }, /** 控制是否可见 */ visible: { type: Boolean, default: !0 } }, jn = Gt(so, qi, Mn, Ni), mn = /* @__PURE__ */ qe({ name: "FResponseForm", props: so, emits: [], setup(n, t) { const e = x(), o = G(() => { const r = n.customClass.split(" "), a = { "drag-container": !0 }; return r.reduce((i, s) => (i[s] = !0, i), a), a; }); return () => n.visible && Tn(I("div", { ref: e, class: o.value, style: n.customStyle }, [t.slots.default && t.slots.default()]), [[Fn("area-response")]]); } }), zi = "https://json-schema.org/draft/2020-12/schema", Yi = "https://farris-design.gitee.io/form-group.schema.json", Ui = "form-group", Xi = "A Farris Input Component", Qi = "object", Zi = { id: { description: "The unique identifier for a form group", type: "string" }, type: { description: "The type string of form group component", type: "string", default: "form-group" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, enableLinkLabel: { description: "", type: "boolean", default: !1 }, editor: { description: "", type: "obejct", default: null }, label: { description: "", type: "string", default: "" }, lableWidth: { description: "", type: "number" }, binding: { description: "", type: "object", default: {} }, visible: { description: "", type: "boolean", default: !0 }, required: { description: "", type: "boolean", default: !1 }, errors: { description: "", type: "object", default: null } }, Ki = [ "id", "type", "editor" ], lo = { $schema: zi, $id: Yi, title: Ui, description: Xi, type: Qi, properties: Zi, required: Ki }, Kt = { 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] }, // readonly: { type: Boolean, default: false }, visible: { type: Boolean, default: !0 }, required: { type: Boolean, default: !1 }, showLabel: { type: Boolean, default: !0 }, type: { type: String, default: "input-group" }, componentId: { type: String, default: "" }, errors: { type: Object, default: null } }, An = Gt( Kt, lo, Mn, void 0 ), Ji = Oi(); function En(n, t, e) { var h; const o = e && e.getStyles && e.getStyles() || "", r = e && e.getDesignerClass && e.getDesignerClass() || "", a = x(); function i() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanMoveComponent ? e.checkCanMoveComponent() : !0; } function s() { return !1; } function l() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanDeleteComponent ? e.checkCanDeleteComponent() : !0; } function d() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !0 : e && e.hideNestedPaddingInDesginerView ? e.hideNestedPaddingInDesginerView() : !1; } function c(M) { if (!M || !M.value) return null; if (M.value.schema && M.value.schema.type === "component") return M.value; const F = x(M == null ? void 0 : M.value.parent), O = c(F); return O || null; } function u(M = t) { var W; if (e != null && e.getDraggableDesignItemElement) return e.getDraggableDesignItemElement(M); const { componentInstance: F, designerItemElementRef: O } = M; if (!F || !F.value) return null; const { getCustomButtons: b } = F.value; return F.value.canMove || b && ((W = b()) != null && W.length) ? O : u(M.parent); } function f(M) { return !!e && e.canAccepts(M); } function m() { return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name); } function p() { } function E(M, F) { var O; !M || !F || (e != null && e.onAcceptMovedChildElement && e.onAcceptMovedChildElement(M, F), (O = t == null ? void 0 : t.setupContext) == null || O.emit("dragEnd")); } function C(M, F) { const { componentType: O } = M; let b = ro(O, M, F); e && e.onResolveNewComponentSchema && (b = e.onResolveNewComponentSchema(M, b)); const W = O.toLowerCase().replace(/-/g, "_"); return b && !b.id && b.type === O && (b.id = `${W}_${Math.random().toString().slice(2, 6)}`), b; } function v(M) { M && e != null && e.onChildElementMovedOut && e.onChildElementMovedOut(M); } function g(...M) { if (e && e.getPropsConfig) return e.getPropsConfig(...M); } function y(M) { if (!M) return; const F = t == null ? void 0 : t.schema, { formSchemaUtils: O } = M; if (F && O.getExpressions().length) { const b = O.getExpressions().findIndex((W) => W.target === F.id); b > -1 && O.getExpressions().splice(b, 1); } } function _(M) { e && e.onRemoveComponent && e.onRemoveComponent(), y(M), t != null && t.schema.contents && t.schema.contents.map((F) => { let O = F.id; F.type === "component-ref" && (O = F.component); const b = n.value.querySelectorAll(`#${O}-design-item`); b != null && b.length && Array.from(b).map((W) => { var $; ($ = W == null ? void 0 : W.componentInstance) != null && $.value.onRemoveComponent && W.componentInstance.value.onRemoveComponent(M); }); }); } function S() { if (e && e.getCustomButtons) return e.getCustomButtons(); } function T(M) { if (e && e.onPropertyChanged) return e.onPropertyChanged(M); } return a.value = { canMove: i(), canSelectParent: s(), canDelete: l(), canNested: !d(), contents: t == null ? void 0 : t.schema.contents, elementRef: n, parent: (h = t == null ? void 0 : t.parent) == null ? void 0 : h.componentInstance, schema: t == null ? void 0 : t.schema, styles: o, designerClass: r, canAccepts: f, getBelongedComponentInstance: c, getDraggableDesignItemElement: u, getDraggingDisplayText: m, getPropConfig: g, getDragScopeElement: p, onAcceptMovedChildElement: E, onChildElementMovedOut: v, addNewChildComponentSchema: C, triggerBelongedComponentToMoveWhenMoved: !!e && e.triggerBelongedComponentToMoveWhenMoved || x(!1), triggerBelongedComponentToDeleteWhenDeleted: !!e && e.triggerBelongedComponentToDeleteWhenDeleted || x(!1), onRemoveComponent: _, getCustomButtons: S, onPropertyChanged: T }, a; } function es() { function n(t, e) { var i; if (!t) return !1; const o = ((i = t.targetContainer) == null ? void 0 : i.componentInstance) && t.targetContainer.componentInstance.value; if (!o) return !1; const r = o.schema.type, a = e == null ? void 0 : e.formSchemaUtils.getComponentById(o.belongedComponentId); return !((t.componentCategory === "input" || t.componentType === "form-group") && ![ie["response-layout-item"].type, ie["response-form"].type, ie.fieldset.type].includes(r) || (t.componentType === ie.tabs.type || t.componentType === ie.section.type) && ((a == null ? void 0 : a.componentType) !== "frame" || ![ie["content-container"].type, ie["splitter-pane"].type, ie["response-layout-item"].type].includes(r)) || t.componentType === ie["query-solution"].type || t.componentType === ie.fieldset.type && r !== ie["response-form"].type); } return { basalDragulaRuleForContainer: n }; } class ts { getTemplateRule(t, e) { const o = e == null ? void 0 : e.formSchemaUtils, r = o == null ? void 0 : o.getFormTemplateRule(), a = { canAccept: !0, canDelete: !0, canMove: !0 }; if (!r) return a; const i = this.getComponentContext(t), { componentClassList: s } = i; return s.forEach((l) => { if (!l || !r[l]) return; const { canMove: d, canDelete: c, canAccept: u } = r[l]; a.canMove = a.canMove && this.resolveRuleValue(d, i), a.canDelete = a.canDelete && this.resolveRuleValue(c, i), a.canAccept = a.canAccept && this.resolveRuleValue(u, i); }), a; } resolveRuleValue(t, e) { return typeof t == "boolean" ? t : this.parseRuleValueSchema(t, e); } parseRuleValueSchema(t, e) { const o = t.invalidContext || []; let r = !0; for (const a of o) { if (a.firstLevelChild) { if (a.firstLevelChild.class) { const { firstLevelChildClassList: i } = e; if (i && !i.includes(a.firstLevelChild.class)) { r = !1; continue; } } if (a.firstLevelChild.type) { const { firstLevelChildSchema: i } = e; if (!i || i.type !== a.firstLevelChild.type) { r = !1; continue; } } } if (a.secondLevelChild) { if (a.secondLevelChild.class) { const { secondLevelChildClassList: i } = e; if (i && !i.includes(a.secondLevelChild.class)) { r = !1; continue; } } if (a.secondLevelChild.type) { const { secondLevelChildSchema: i } = e; if (!i || i.type !== a.secondLevelChild.type) { r = !1; continue; } } } if (a.parent) { if (a.parent.class) { const { parentClassList: i } = e; if (i && !i.includes(a.parent.class)) { r = !1; continue; } } if (a.parent.type) { const { parentSchema: i } = e; if (i && i.type !== a.parent.type) { r = !1; continue; } } } r = !0; break; } return !r; } getComponentContext(t) { var E, C, v, g; const e = t.schema, o = e.appearance && e.appearance.class || "", r = o.split(" ") || [], a = e.contents || [], i = a.length ? a[0] : null, s = i && i.appearance ? i.appearance.class : "", l = s ? s.split(" ") : [], d = (E = i == null ? void 0 : i.contents) != null && E.length ? i == null ? void 0 : i.contents[0] : null, c = d && d.appearance ? d.appearance.class : "", u = c ? c.split(" ") : [], f = e.type === "component" ? (v = (C = t.parent) == null ? void 0 : C.parent) == null ? void 0 : v.schema : (g = t.parent) == null ? void 0 : g.schema, m = f && f.appearance && f.appearance.class || "", p = m ? m.split(" ") : []; return { componentClass: o, componentClassList: r, childContents: a, firstLevelChildSchema: i, firstLevelChildClass: s, firstLevelChildClassList: l, secondLevelChildSchema: d, secondLevelChildClass: c, secondLevelChildClassList: u, parentSchema: f, parentClass: m, parentClassList: p }; } } const ns = x(0); function uo() { ns.value++; } const en = x(0); function os(n, t) { const e = t.getBoundingClientRect(), o = n.getBoundingClientRect(), r = o.top >= e.top, a = o.top <= e.bottom; return r && a; } function rs(n) { const t = n.querySelector(".component-btn-group"); if (!t) return; t.style.display = ""; const e = t.getBoundingClientRect(); if (!(e.top === 0 && e.left === 0)) { const o = t.querySelector("div"); if (o) { const r = o.getBoundingClientRect(); o.style.top = e.top + "px"; let a = e.left - r.width; const i = document.querySelector(".editorDiv"); if (i) { const s = i.getBoundingClientRect(); a < s.left && ({ left: a } = n.getBoundingClientRect()); } o.style.left = a + "px"; } } } function as(n) { if (!window.scrollContainerList) return; const t = Array.from(window.scrollContainerList); if (t.length && t.length === 1) { const e = t[0], o = document.querySelector(`[id=${e}]`); if (o && o.contains(n)) return o; } } function co(n) { if (!n) return; const t = n.getBoundingClientRect(); if (t.width === 0 && t.height === 0) return; const e = n.querySelector(".component-btn-group"); if (e) { let o = !0; const r = as(n); if (r && (o = os(n, r)), !o) { e.style.display = "none"; return; } rs(n); } } function is(n) { if (!n) return; let t; n.className.includes("dgComponentSelected") ? t = n : t = n.querySelector(".dgComponentSelected"), t && co(t); } function ss(n) { const { formSchemaUtils: t, formStateMachineUtils: e } = n; function o(l, d = "") { return { path: d + l.code, field: l.id, fullPath: l.code }; } function r(l, d = "") { return t.getViewModelById(l).states.map((u) => o(u, d)); } function a(l) { const d = t.getRootViewModelId(), c = r(l); if (l === d) return c; const u = r(d, "root-component."); return [...c, ...u]; } function i(l) { return l.binding && l.binding.path || l.id || ""; } function s() { return e && e.getRenderStates() || []; } return { getVariables: a, getControlName: i, getStateMachines: s }; } class ls { constructor(t) { L(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'" } ]); L(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); L(this, "getExpressionConverter", (t, e) => ({ convertFrom: (o, r, a, i) => { const s = a.getExpressionRuleValue(t, e || r); return s && s.value || ""; }, convertTo: (o, r, a, i, s) => { var l; if (r === "dataPicking" && (a != null && a.target)) { const d = `${a.target}_dataPicking`; ((l = a.rules) == null ? void 0 : l.some( (u) => u.id === d && u.value )) ? o.dictPickingExpressionId = d : delete o.dictPickingExpressionId; } i.updateExpression(a); } })); this.formSchemaService = t; } getExpressionRule(t, e) { const o = this.formSchemaService.getExpressions(); if (!o) return ""; const r = o.find((i) => i.target === t); if (!r) return ""; const a = r.rules.find((i) => i.type === e); return a || ""; } // 获取上下文表单变量 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 r = []; return o.states.forEach((a) => { r.push({ key: a.code, name: a.name, description: a.name, category: a.category }); }), r; } createTreeNode(t, e, o = "label") { return { id: t.id, name: t.name, bindingPath: t[o], parents: e }; } buildEntityFieldsTreeData(t = null, e) { const o = []; return t == null || t.forEach((r) => { var s; const a = this.createTreeNode(r, e); let i = []; (s = r.type) != null && s.fields && (i = this.buildEntityFieldsTreeData(r.type.fields, [...e, r.label])), o.push({ data: a, children: i, expanded: !0 }); }), o; } buildChildEntityTreeData(t = null, e) { const o = []; return t == null || t.forEach((r) => { var l, d; const a = this.createTreeNode(r, e), i = this.buildEntityFieldsTreeData((l = r.type) == null ? void 0 : l.fields, [...e, r.label]), s = this.buildChildEntityTreeData((d = r.type) == null ? void 0 : d.entities, [...e, r.label]); s != null && s.length && (i == null || i.push(...s)), o.push({ data: a, children: i || [], // 空值回退 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]), r = this.buildChildEntityTreeData(e.type.entities, [e.code]); return r != null && r.length && (o == null || o.push(...r)), { 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 r = o === "Field" ? t.binding.field : t.id, a = this.getExpressionRule(r, e), i = this.getEntitiesAndVariables(), s = { message: ["validate", "required", "dataPicking"].includes(e) && a ? a.message : "", ...i }; return a.messageType != null && (s.messageType = a.messageType), s; } buildRule(t, e, o, r) { const { expression: a, message: i, messageType: s } = e, l = { id: `${t}_${o}`, type: o, value: a }; return (o === "validate" || o === "dataPicking" || o === "required") && (l.message = i), o === "dataPicking" && (l.messageType = s), o === "validate" && r && (l.elementId = r), l; } getExpressionData() { const { expressions: t } = this.formSchemaService.getFormSchema().module; return t || []; } updateExpression(t, e, o, r) { const a = e === "Field" ? t.binding.field : t.id, i = this.buildRule(a, o, r, t.type === "form-group" ? t.id : ""); let l = this.getExpressionData().find((c) => c.targetType === e && c.target === a); const d = (c) => c.value.trim() === ""; if (l) { const c = l.rules.find((u) => u.id === i.id); if (c) d(i) ? l.rules = l.rules.filter((u) => u.id !== i.id) : (Object.assign(c, i), r === "validate" && t.type === "form-group" && (c.elementId = t.id)); else { if (d(i)) return null; l.rules = l.rules || [], l.rules.push(i); } } else { if (d(i)) return null; l = { target: `${a}`, rules: [i], targetType: e }; } return l; } getExpressionEditorOptions(t, e, o, r) { return o.reduce((a, i) => { var l, d; const s = e === "Field" ? (l = t == null ? void 0 : t.binding) == null ? void 0 : l.field : t.id; return a[i] = { hide: e === "Field" ? !!((d = t == null ? void 0 : t.binding) != null && d.field) : !1, description: "", title: this.expressionNames[i], type: "string", $converter: this.getExpressionConverter(s), editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[i]}编辑器`, showMessage: i === "validate" || i === "dataPicking" || i === "required", showMessageType: i === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(t, i, e), onSubmitModal: (c) => { const u = this.updateExpression(t, e, c, i); if (r) { const f = this.buildRule(s, c, i); r(f); } return u; } } }, a; }, {}); } getExpressionInfo(t, e, o) { const r = e === "Field" ? t.binding.field : t.id, a = this.getExpressionRule(r, o), i = { value: a && a.value, targetId: r, targetType: e, expressionType: o }; return a && a.message && (i.message = a.message), i; } getExpressionConfig(t, e, o = ["compute", "dependency", "validate"], r) { return { description: "表达式", title: "表达式", properties: { ...this.getExpressionEditorOptions(t, e, o, r) } }; } getExpressionOptions(t, e, o) { const r = this.getExpressionInfo(t, e, o); return { dialogTitle: `${this.expressionNames[o]}编辑器`, singleExpand: !1, showMessage: o === "required", beforeOpen: () => this.onBeforeOpenExpression(t, o, e), expressionInfo: r }; } } class fo { constructor(t, e) { L(this, "componentId"); L(this, "viewModelId"); L(this, "eventsEditorUtils"); L(this, "formSchemaUtils"); L(this, "formMetadataConverter"); L(this, "designViewModelUtils"); L(this, "designViewModelField"); L(this, "controlCreatorUtils"); L(this, "designerHostService"); L(this, "schemaService", null); L(this, "metadataService", null); L(this, "propertyConfig", { type: "object", categories: {} }); 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; } 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 r = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = r.fields.find((a) => a.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: ie[t.type].name }] } } } }; } getAppearanceConfig(t = null, e = {}, o) { const r = { title: "外观", description: "Appearance" }, a = { 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 e) a[i] = Object.assign(a[i] || {}, e[i]); return { ...r, properties: { ...a }, setPropertyRelates(i, s) { if (i) { switch (i && i.propertyID) { case "class": case "style": { en.value++; break; } } o && o(i, t, s); } } }; } getPropertyEditorParams(t, e = [], o = "visible", r = {}, a = {}) { const { getVariables: i, getControlName: s, getStateMachines: l } = ss(this.designerHostService), d = this.getRealTargetType(t), c = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], u = { type: "property-editor", propertyTypes: c }; return c.map((f) => { switch (f) { case "Const": Object.assign(u, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, r); break; case "Expression": u.expressionConfig = this.getExpressionOptions(t, d, o); break; case "StateMachine": u.stateMachines = l(); break; case "Variable": Object.assign(u, { controlName: s(t), newVariablePrefix: "is", newVariableType: "Boolean", variables: i(this.viewModelId), onBeforeOpenVariables: (m) => { m.value = i(this.viewModelId); } }, a); break; } }), u; } getVisibleProperty(t, e = "") { return { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(t, e === "gridFieldEditor" ? ["Const", "Expression"] : ["Const", "Variable", "StateMachine", "Expression"], "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(t, e = "", o = {}, r) { const a = { title: "行为", description: "" }, i = this.getVisibleProperty(t, e); for (const l in o) i[l] = Object.assign(i[l] || {}, o[l]); const s = this; return { ...a, properties: { ...i }, setPropertyRelates(l, d) { if (l) { switch (l.propertyID) { case "disabled": case "readonly": case "visible": s.afterMutilEditorChanged(t, l); break; } r && r(l, d); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(t, e) { this.addNewVariableToViewModel(e, this.viewModelId), this.updateExpressionValue(e), this.clearExpression(e, t); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(t, e) { const o = e && e.parent && e.parent.schema; if (!o) return; const r = o.contents.findIndex((i) => i.id === t), a = Et(o.contents[r]); o.contents.splice(r, 1), o.contents.splice(r, 0, a), uo(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到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 i = { id: o.field, category: "locale", code: o.fullPath, name: o.fullPath, type: o.newVariableType || "String" }; delete o.newVariableType, delete o.isNewVariable, this.formSchemaUtils.getVariableByCode(i.code) || this.formSchemaUtils.getViewModelById(e).states.push(i); } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(t) { const e = t.propertyValue; if (!((e && e.type) === "Expression" && e.expressionInfo)) return; const { expressionId: a, expressionInfo: i } = e, { targetId: s, targetType: l, expressionType: d, value: c, message: u } = i, f = this.formSchemaUtils.getModule(); f.expressions ?? (f.expressions = []); const { expressions: m } = f; let p = m.find((C) => C.target === s); p || (p = { target: s, rules: [], targetType: l }, m.push(p)); const E = p.rules.find((C) => C.type === d); if (E) E.value = c, E.message = u; else { const C = { id: a, type: d, value: c, message: u }; p.rules.push(C); } delete e.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(t, e) { const o = t.propertyValue; if (o && o.type === "Expression") return; const a = t.propertyID, i = this.formSchemaUtils.getExpressions(), s = e.binding ? e.binding.field : e.id, l = i.find((d) => d.target === s); !l || !l.rules || (l.rules = l.rules.filter((d) => d.type !== a)); } getExpressionOptions(t, e, o) { return new ls(this.formSchemaUtils).getExpressionOptions(t, e, o); } getRealTargetType(t) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item"].indexOf(t.type) > -1 ? "Button" : t.binding && t.binding.field ? "Field" : "Container"; } } class us { constructor() { /** 控件标题 */ L(this, "label", ""); /** 控件id */ L(this, "id", ""); /** 每个控件占用的栅格数 */ L(this, "columnInSM", 12); L(this, "columnInMD", 6); L(this, "columnInLG", 3); L(this, "columnInEL", 2); /** 每个控件占用的列数 */ L(this, "displayWidthInSM", 1); L(this, "displayWidthInMD", 1); L(this, "displayWidthInLG", 1); L(this, "displayWidthInEL", 1); /** 编辑器内部默认显示的屏幕大小-----可以去掉 */ L(this, "displayColumnCountAtBreakPoint", "md"); /** 控件所在行,传0即可-----编辑器内部使用 */ L(this, "tagRow", 0); /** 控件是否显示上方空白:传0即可-----编辑器内部使用 */ L(this, "showTopBorder", 0); /** 区域,从1开始。卡片内的控件从上往下,从左往右划分区域,遇到分组fieldSet时group+1,分组结束后group+1 */ L(this, "group", 1); /** 控件是否符合标准的class配置(设计器用的) */ L(this, "isSupportedClass", !0); /** 控件所在分组id(设计器用的) */ L(this, "fieldSetId", ""); } } function cs(n) { let t, e; const o = /* @__PURE__ */ new Map(); let r = []; function a(c, u) { const m = c.split(" ").filter((g) => g.startsWith("col-")); if (m.length === 0) { u.isSupportedClass = !1; return; } let p = m.find((g) => /^col-([1-9]|10|11|12)$/.test(g)), E = m.find((g) => /^col-md-([1-9]|10|11|12)$/.test(g)), C = m.find((g) => /^col-xl-([1-9]|10|11|12)$/.test(g)), v = m.find((g) => /^col-el-([1-9]|10|11|12)$/.test(g)); p = p || "col-12", u.columnInSM = parseInt(p.replace("col-", ""), 10), u.displayWidthInSM = u.columnInSM / 12, u.displayWidthInSM !== 1 && (u.isSupportedClass = !1), E = E || "col-md-" + u.columnInSM, u.columnInMD = parseInt(E.replace("col-md-", ""), 10), u.displayWidthInMD = u.columnInMD / 6, [1, 2].includes(u.displayWidthInMD) || (u.isSupportedClass = !1), C = C || "col-xl-" + u.columnInMD, u.columnInLG = parseInt(C.replace("col-xl-", ""), 10), u.displayWidthInLG = u.columnInLG / 3, [1, 2, 3, 4].includes(u.displayWidthInLG