UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,467 lines (1,466 loc) 413 kB
var Qo = Object.defineProperty; var Ko = (n, t, e) => t in n ? Qo(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var L = (n, t, e) => Ko(n, typeof t != "symbol" ? t + "" : t, e); import { defineComponent as Xe, computed as Y, createVNode as P, ref as I, inject as ct, onMounted as Et, watch as Me, Fragment as Qt, reactive as wt, createApp as Jn, onUnmounted as sn, Transition as Zn, mergeProps as $t, createTextVNode as vt, onBeforeUnmount as eo, withDirectives as Jo, resolveDirective as Zo, nextTick as ln, onBeforeMount as er, Teleport as tr, shallowRef as nr, render as fn, h as or, cloneVNode as rr, provide as ar, triggerRef as ir, isVNode as sr } from "vue"; import { isPlainObject as Nn, cloneDeep as kt, isUndefined as ut, throttle as lr } from "lodash-es"; import { useResizeObserver as to } from "@vueuse/core"; import { useIdentify as ur, useGroupData as cr, useFilter as dr, useHierarchy as fr, useLoading as pr, useDataView as mr, useSelection as hr, useSelectHierarchyItem as vr, useDataViewContainerStyle as gr, useCommandColumn as yr, useColumn as br, useSort as wr, useGroupColumn as Cr, useRow as _r, useEdit as xr, useVisualDataBound as Tr, useVisualDataCell as Sr, useVisualDataRow as Fr, useVisualData as Mr, useCellPosition as kr, useSidebar as Ir, useVirtualScroll as Er, useFitColumn as Or, useFilterHistory as Dr, useColumnFilter as Pr, useDragColumn as Vr, getColumnHeader as Br, getSidebar as Nr, getDisableMask as Rr, getHorizontalScrollbar as Lr, getVerticalScrollbar as $r, getEmpty as Wr } from "../data-view/index.esm.js"; import "../modal/index.esm.js"; import jr from "../transfer/index.esm.js"; import Ar from "../tabs/index.esm.js"; import Hr from "../order/index.esm.js"; import "../condition/index.esm.js"; import { FCheckbox as qr } from "../checkbox/index.esm.js"; import { useGuid as yn, resolveField as rt, FormSchemaEntityFieldTypeName as Rn, useCommonUtils as Gr, useDateFormat as zr, useNumberFormat as Yr, setFieldValue as bn, getCustomClass as pn, withInstall as Ur } from "../common/index.esm.js"; import Xr from "../filter-bar/index.esm.js"; import Ln from "../tooltip/index.esm.js"; import Qr from "../pagination/index.esm.js"; import Kr from "../button/index.esm.js"; import Jr from "../search-box/index.esm.js"; import Zr from "../tags/index.esm.js"; import ea, { FDynamicFormGroup as ta, FDynamicFormInput as na } from "../dynamic-form/index.esm.js"; import { getSchemaByType as oa, schemaMap as ra, createPropsResolver as aa } from "../dynamic-resolver/index.esm.js"; import { DgControl as Kt } from "../designer-canvas/index.esm.js"; import { FormBindingType as Nt } from "../property-panel/index.esm.js"; import ia from "../accordion/index.esm.js"; import sa from "../avatar/index.esm.js"; import la from "../../designer/button-edit/index.esm.js"; import ua from "../button-group/index.esm.js"; import ca from "../calendar/index.esm.js"; import da from "../capsule/index.esm.js"; import $n from "../../designer/checkbox/index.esm.js"; import Wn from "../../designer/checkbox-group/index.esm.js"; import wn from "../combo-list/index.esm.js"; import fa from "../combo-tree/index.esm.js"; import pa from "../component/index.esm.js"; import ma from "../color-picker/index.esm.js"; import ha from "../content-container/index.esm.js"; import va from "../date-picker/index.esm.js"; import ga from "../../designer/data-grid/index.esm.js"; import ya from "../dropdown/index.esm.js"; import ba from "../events-editor/index.esm.js"; import wa from "../field-selector/index.esm.js"; import Ca from "../binding-selector/index.esm.js"; import _a from "../image-cropper/index.esm.js"; import xa from "../../designer/input-group/index.esm.js"; import Ta from "../layout/index.esm.js"; import Sa from "../list-nav/index.esm.js"; import Fa from "../list-view/index.esm.js"; import Ma from "../lookup/index.esm.js"; import ka from "../mapping-editor/index.esm.js"; import Ia from "../nav/index.esm.js"; import Ea from "../number-range/index.esm.js"; import Oa from "../number-spinner/index.esm.js"; import Da from "../page-header/index.esm.js"; import Pa from "../page-footer/index.esm.js"; import Va from "../progress/index.esm.js"; import Ba from "../query-solution/index.esm.js"; import Na from "../../designer/radio-group/index.esm.js"; import Ra from "../rate/index.esm.js"; import La from "../response-toolbar/index.esm.js"; import $a from "../response-layout/index.esm.js"; import Wa from "../response-layout-editor/index.esm.js"; import ja from "../section/index.esm.js"; import Aa from "../smoke-detector/index.esm.js"; import Ha from "../splitter/index.esm.js"; import qa from "../step/index.esm.js"; import Ga from "../switch/index.esm.js"; import za from "../text/index.esm.js"; import Ya from "../time-picker/index.esm.js"; import Ua from "../tree-view/index.esm.js"; import Xa from "../uploader/index.esm.js"; import Qa from "../verify-detail/index.esm.js"; import Ka from "../video/index.esm.js"; import Ja from "../textarea/index.esm.js"; import Za from "../schema-selector/index.esm.js"; import ei from "../tree-grid/index.esm.js"; import ti from "../event-parameter/index.esm.js"; import ni from "../filter-condition-editor/index.esm.js"; import oi from "../fieldset/index.esm.js"; import ri from "../sort-condition-editor/index.esm.js"; import ai from "../menu-lookup/index.esm.js"; import ii from "../drawer/index.esm.js"; import si from "../json-editor/index.esm.js"; import li from "../property-editor/index.esm.js"; import ui from "../expression-editor/index.esm.js"; import ci from "../code-editor/index.esm.js"; import di from "../html-template/index.esm.js"; import "../external-container/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]) : kt(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 fi(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]) : kt(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 un(n, t = {}, e) { const o = no[n]; if (o) { let r = fi(o); const a = oo[n]; return r = a ? a({ getSchemaByType: un }, r, t, e) : r, r; } return null; } function pi(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 ro(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 mi(n, t, e = /* @__PURE__ */ new Map()) { const o = pi(n, t); return ro(o, e); } function hi(n = {}) { function t(c, d, u, m) { if (typeof u == "number") return m[c].length === u; if (typeof u == "object") { const f = Object.keys(u)[0], p = u[f]; if (f === "not") return Number(m[c].length) !== Number(p); if (f === "moreThan") return Number(m[c].length) >= Number(p); if (f === "lessThan") return Number(m[c].length) <= Number(p); } return !1; } function e(c, d, u, m) { return m[c] && m[c].propertyValue && String(m[c].propertyValue.value) === String(u); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", e] ]); Object.keys(n).reduce((c, d) => (c.set(d, n[d]), c), o); function r(c, d) { const u = c; return typeof d == "number" ? [{ target: u, operator: "length", param: null, value: Number(d) }] : typeof d == "boolean" ? [{ target: u, operator: "getProperty", param: c, value: !!d }] : typeof d == "object" ? Object.keys(d).map((m) => { if (m === "length") return { target: u, operator: "length", param: null, value: d[m] }; const f = m, p = d[m]; return { target: u, operator: "getProperty", param: f, value: p }; }) : []; } function a(c) { return Object.keys(c).reduce((u, m) => { const f = r(m, c[m]); return u.push(...f), u; }, []); } function i(c, d) { if (o.has(c.operator)) { const u = o.get(c.operator); return u && u(c.target, c.param, c.value, d) || !1; } return !1; } function s(c, d) { return a(c).reduce((f, p) => f && i(p, d), !0); } function l(c, d) { const u = Object.keys(c), m = u.includes("allOf"), f = u.includes("anyOf"), p = m || f, h = (p ? c[p ? m ? "allOf" : "anyOf" : "allOf"] : [c]).map((g) => s(g, d)); return m ? !h.includes(!1) : h.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: "筛选条" } }, vi = {}, gi = {}; hi(); function Ct(n, t, e = /* @__PURE__ */ new Map(), o = (i, s, l, c) => s, r = {}, a = (i) => i) { return no[t.title] = t, oo[t.title] = o, vi[t.title] = r, gi[t.title] = a, (i = {}, s = !0) => { if (!s) return ro(i, e); const l = mi(i, t, e), c = Object.keys(n).reduce((d, u) => (d[u] = n[u].default, d), {}); return Object.assign(c, l); }; } function cn(n, t) { return { customClass: t.class, customStyle: t.style }; } function yi() { function n(t, e) { const { dataSource: o } = t || {}; return o === void 0 ? {} : {}; } return { resolve: n }; } function bi() { function n(t, e) { return t.selectItemById(e); } return { selectItemById: n }; } function wi() { function n(t, e) { const { columns: o } = e; return t.updateColumns(o); } return { updateColumns: n }; } const ao = /* @__PURE__ */ new Map([ ["appearance", cn] ]); function Ci(n, t, e) { if (e.componentFeature) { const o = JSON.parse(e.componentFeature); t.appearance = { class: "bg-white" }, t.contents = String(o.splitter).split(":").map((r) => { const a = n.getSchemaByType("response-layout-item"); return a.appearance = { class: `h-100 col-${r} px-0` }, a; }); } return t; } const _i = "https://json-schema.org/draft/2020-12/schema", xi = "https://farris-design.gitee.io/response-layout.schema.json", Ti = "response-layout", Si = "A Farris Container Component", Fi = "object", Mi = { id: { description: "The unique identifier for a Respnse Layout", type: "string" }, type: { description: "The type string of Respnse Layout component", type: "string", default: "response-layout" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, size: { description: "", type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, default: null }, visible: { description: "", type: "boolean", default: !0 } }, ki = [ "id", "type", "contents" ], Ii = { $schema: _i, $id: xi, title: Ti, description: Si, type: Fi, properties: Mi, required: ki }, Fn = { customClass: { type: String, default: "" }, customStyle: { type: String, default: "" } }, jn = Ct(Fn, Ii, ao, Ci), mn = /* @__PURE__ */ Xe({ name: "FResponseLayout", props: Fn, emits: [], setup(n, t) { function e(r, a) { r && a && a.split(" ").reduce((s, l) => (s[l] = !0, s), r); } const o = Y(() => { const r = { "d-flex": !0 }; return e(r, n.customClass), r; }); return () => P("div", { class: o.value, style: n.customStyle }, [t.slots.default && t.slots.default()]); } }), Ei = "https://json-schema.org/draft/2020-12/schema", Oi = "https://farris-design.gitee.io/response-layout-item.schema.json", Di = "response-layout-item", Pi = "A Farris Container Component", Vi = "object", Bi = { id: { description: "The unique identifier for a Respnse Layout Item", type: "string" }, type: { description: "The type string of Respnse Layout Item component", type: "string", default: "response-layout-item" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, size: { description: "", type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, default: null }, visible: { description: "", type: "boolean", default: !0 } }, Ni = [ "id", "type", "contents" ], Ri = { $schema: Ei, $id: Oi, title: Di, description: Pi, type: Vi, properties: Bi, required: Ni }, Mn = { customClass: { type: String, default: "" }, customStyle: { type: String, default: "" } }, An = Ct(Mn, Ri, ao), hn = /* @__PURE__ */ Xe({ name: "FResponseLayoutItem", props: Mn, emits: [], setup(n, t) { return () => P("div", { class: n.customClass, style: n.customStyle }, [t.slots.default && t.slots.default()]); } }); function kn(n, t, e) { var v; const o = e && e.getStyles && e.getStyles() || "", r = e && e.getDesignerClass && e.getDesignerClass() || "", a = I(); 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 c() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !0 : e && e.hideNestedPaddingInDesginerView ? e.hideNestedPaddingInDesginerView() : !1; } function d(S) { if (!S || !S.value) return null; if (S.value.schema && S.value.schema.type === "component") return S.value; const x = I(S == null ? void 0 : S.value.parent), E = d(x); return E || null; } function u(S = t) { var $; if (e != null && e.getDraggableDesignItemElement) return e.getDraggableDesignItemElement(S); const { componentInstance: x, designerItemElementRef: E } = S; if (!x || !x.value) return null; const { getCustomButtons: y } = x.value; return x.value.canMove || y && (($ = y()) != null && $.length) ? E : u(S.parent); } function m(S) { return !!e && e.canAccepts(S); } function f() { 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 F(S, x) { var E; !S || !x || (e != null && e.onAcceptMovedChildElement && e.onAcceptMovedChildElement(S, x), (E = t == null ? void 0 : t.setupContext) == null || E.emit("dragEnd")); } function w(S, x) { const { componentType: E } = S; let y = un(E, S, x); e && e.onResolveNewComponentSchema && (y = e.onResolveNewComponentSchema(S, y)); const $ = E.toLowerCase().replace(/-/g, "_"); return y && !y.id && y.type === E && (y.id = `${$}_${Math.random().toString().slice(2, 6)}`), y; } function h(S) { S && e != null && e.onChildElementMovedOut && e.onChildElementMovedOut(S); } function C(...S) { if (e && e.getPropsConfig) return e.getPropsConfig(...S); } function g(S) { if (!S) return; const x = t == null ? void 0 : t.schema, { formSchemaUtils: E } = S; if (x && E.getExpressions().length) { const y = E.getExpressions().findIndex(($) => $.target === x.id); y > -1 && E.getExpressions().splice(y, 1); } } function _(S) { e && e.onRemoveComponent && e.onRemoveComponent(), g(S), t != null && t.schema.contents && t.schema.contents.map((x) => { let E = x.id; x.type === "component-ref" && (E = x.component); const y = n.value.querySelectorAll(`#${E}-design-item`); y != null && y.length && Array.from(y).map(($) => { var W; (W = $ == null ? void 0 : $.componentInstance) != null && W.value.onRemoveComponent && $.componentInstance.value.onRemoveComponent(S); }); }); } function k() { if (e && e.getCustomButtons) return e.getCustomButtons(); } function M(S) { if (e && e.onPropertyChanged) return e.onPropertyChanged(S); } return a.value = { canMove: i(), canSelectParent: s(), canDelete: l(), canNested: !c(), contents: t == null ? void 0 : t.schema.contents, elementRef: n, parent: (v = t == null ? void 0 : t.parent) == null ? void 0 : v.componentInstance, schema: t == null ? void 0 : t.schema, styles: o, designerClass: r, canAccepts: m, getBelongedComponentInstance: d, getDraggableDesignItemElement: u, getDraggingDisplayText: f, getPropConfig: C, getDragScopeElement: p, onAcceptMovedChildElement: F, onChildElementMovedOut: h, addNewChildComponentSchema: w, triggerBelongedComponentToMoveWhenMoved: !!e && e.triggerBelongedComponentToMoveWhenMoved || I(!1), triggerBelongedComponentToDeleteWhenDeleted: !!e && e.triggerBelongedComponentToDeleteWhenDeleted || I(!1), onRemoveComponent: _, getCustomButtons: k, onPropertyChanged: M }, a; } const zt = I(0); function Li(n, t) { const e = t.getBoundingClientRect(), o = n.getBoundingClientRect(), r = o.top >= e.top, a = o.top <= e.bottom; return r && a; } function $i(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 Wi(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 io(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 = Wi(n); if (r && (o = Li(n, r)), !o) { e.style.display = "none"; return; } $i(n); } } function ji(n) { if (!n) return; let t; n.className.includes("dgComponentSelected") ? t = n : t = n.querySelector(".dgComponentSelected"), t && io(t); } const Ai = I(0); function so() { Ai.value++; } function Hi(n) { const { formSchemaUtils: t, formStateMachineUtils: e } = n; function o(l, c = "") { return { path: c + l.code, field: l.id, fullPath: l.code }; } function r(l, c = "") { return t.getViewModelById(l).states.map((u) => o(u, c)); } function a(l) { const c = t.getRootViewModelId(), d = r(l); if (l === c) return d; const u = r(c, "root-component."); return [...d, ...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 qi { 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 c = `${a.target}_dataPicking`; ((l = a.rules) == null ? void 0 : l.some( (u) => u.id === c && u.value )) ? o.dictPickingExpressionId = c : 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, c; const a = this.createTreeNode(r, e), i = this.buildEntityFieldsTreeData((l = r.type) == null ? void 0 : l.fields, [...e, r.label]), s = this.buildChildEntityTreeData((c = r.type) == null ? void 0 : c.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((d) => d.targetType === e && d.target === a); const c = (d) => d.value.trim() === ""; if (l) { const d = l.rules.find((u) => u.id === i.id); if (d) c(i) ? l.rules = l.rules.filter((u) => u.id !== i.id) : (Object.assign(d, i), r === "validate" && t.type === "form-group" && (d.elementId = t.id)); else { if (c(i)) return null; l.rules = l.rules || [], l.rules.push(i); } } else { if (c(i)) return null; l = { target: `${a}`, rules: [i], targetType: e }; } return l; } getExpressionEditorOptions(t, e, o, r) { return o.reduce((a, i) => { var l, c; const s = e === "Field" ? (l = t == null ? void 0 : t.binding) == null ? void 0 : l.field : t.id; return a[i] = { hide: e === "Field" ? !!((c = t == null ? void 0 : t.binding) != null && c.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: (d) => { const u = this.updateExpression(t, e, d, i); if (r) { const m = this.buildRule(s, d, i); r(m); } 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 dn { 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": { zt.value++; break; } } o && o(i, t, s); } } }; } getPropertyEditorParams(t, e = [], o = "visible", r = {}, a = {}) { const { getVariables: i, getControlName: s, getStateMachines: l } = Hi(this.designerHostService), c = this.getRealTargetType(t), d = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], u = { type: "property-editor", propertyTypes: d }; return d.map((m) => { switch (m) { case "Const": Object.assign(u, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, r); break; case "Expression": u.expressionConfig = this.getExpressionOptions(t, c, 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: (f) => { f.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, c) { if (l) { switch (l.propertyID) { case "disabled": case "readonly": case "visible": s.afterMutilEditorChanged(t, l); break; } r && r(l, c); } } }; } /** * 当多值编辑器变更时 * @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 = kt(o.contents[r]); o.contents.splice(r, 1), o.contents.splice(r, 0, a), so(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到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: c, value: d, message: u } = i, m = this.formSchemaUtils.getModule(); m.expressions ?? (m.expressions = []); const { expressions: f } = m; let p = f.find((w) => w.target === s); p || (p = { target: s, rules: [], targetType: l }, f.push(p)); const F = p.rules.find((w) => w.type === c); if (F) F.value = d, F.message = u; else { const w = { id: a, type: c, value: d, message: u }; p.rules.push(w); } 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((c) => c.target === s); !l || !l.rules || (l.rules = l.rules.filter((c) => c.type !== a)); } getExpressionOptions(t, e, o) { return new qi(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 Gi extends dn { constructor(t, e) { super(t, e); } getPropertyConfig(t) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(t), this.propertyConfig.categories.appearance = this.getAppearanceConfig(t), this.propertyConfig.categories.layout = this.getLayoutPropConfig(t, this.viewModelId), this.propertyConfig; } getLayoutPropConfig(t, e) { return { title: "布局", description: "layout", properties: { layout: { type: "select", description: "配置布局容器内区块个数及比例。", editor: { type: "response-layout-splitter", layout: t.contents || [] } } }, setPropertyRelates(o, r) { zt.value++; } }; } } function zi(n, t) { const e = n.schema; function o(s) { return !1; } function r(s) { return new Gi(s, t).getPropertyConfig(e); } function a() { var c; const s = n.designerItemElementRef.value.querySelector(`#${e.id}`); if (!s) return; const l = ((c = n.schema.contents) == null ? void 0 : c.map((d) => d.id)) || []; Array.from(s.children).map((d) => { var m; const u = (m = d.componentInstance) == null ? void 0 : m.value; u != null && u.schema && !l.includes(u.schema.id) && u.onRemoveComponent && u.onRemoveComponent(t); }); } function i(s) { var l; s && ((l = s == null ? void 0 : s.changeObject) == null ? void 0 : l.propertyID) === "layout" && a(); } return { canAccepts: o, getPropsConfig: r, onPropertyChanged: i }; } const Yi = /* @__PURE__ */ Xe({ name: "FResponseLayoutDesign", props: Fn, emits: [], setup(n, t) { const e = I(), o = ct("design-item-context"), r = ct("designer-host-service"), a = zi(o, r), i = kn(e, o, a); Et(() => { e.value.componentInstance = i; }), t.expose(i.value); function s(c, d) { c && d && d.split(" ").reduce((m, f) => (m[f] = !0, m), c); } const l = Y(() => { const c = { "d-flex": !0, "response-layout": !0 }; return s(c, n.customClass), c; }); return () => P("div", { ref: e, class: l.value, style: "height:inherit;" }, [t.slots.default && t.slots.default()]); } }); var St = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Jt(n) { throw new Error('Could not dynamically require "' + n + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var Ui = { exports: {} }; (function(n, t) { (function(e) { n.exports = e(); })(function() { return (/* @__PURE__ */ function() { function e(o, r, a) { function i(c, d) { if (!r[c]) { if (!o[c]) { var u = typeof Jt == "function" && Jt; if (!d && u) return u(c, !0); if (s) return s(c, !0); var m = new Error("Cannot find module '" + c + "'"); throw m.code = "MODULE_NOT_FOUND", m; } var f = r[c] = { exports: {} }; o[c][0].call(f.exports, function(p) { var F = o[c][1][p]; return i(F || p); }, f, f.exports, e, o, r, a); } return r[c].exports; } for (var s = typeof Jt == "function" && Jt, l = 0; l < a.length; l++) i(a[l]); return i; } return e; }())({ 1: [function(e, o, r) { var a = {}, i = "(?:^|\\s)", s = "(?:\\s|$)"; function l(u) { var m = a[u]; return m ? m.lastIndex = 0 : a[u] = m = new RegExp(i + u + s, "g"), m; } function c(u, m) { var f = u.className; f.length ? l(m).test(f) || (u.className += " " + m) : u.className = m; } function d(u, m) { u.className = u.className.replace(l(m), " ").trim(); } o.exports = { add: c, rm: d }; }, {}], 2: [function(e, o, r) { (function(a) { var i = e("contra/emitter"), s = e("crossvent"), l = e("./classes"), c = document, d = c.documentElement; function u(y, $) { var W = arguments.length; W === 1 && Array.isArray(y) === !1 && ($ = y, y = []); var b, T, B, R, V, N, q, D, O, G = null, j, A, U = !1, K = 0, Z, J = $ || {}; J.moves === void 0 && (J.moves = C), J.accepts === void 0 && (J.accepts = C), J.invalid === void 0 && (J.invalid = gt), J.containers === void 0 && (J.containers = y || []), J.isContainer === void 0 && (J.isContainer = h), J.copy === void 0 && (J.copy = !1), J.copySortSource === void 0 && (J.copySortSource = !1), J.revertOnSpill === void 0 && (J.revertOnSpill = !1), J.removeOnSpill === void 0 && (J.removeOnSpill = !1), J.direction === void 0 && (J.direction = "vertical"), J.ignoreInputTextSelection === void 0 && (J.ignoreInputTextSelection = !0), J.mirrorContainer === void 0 && (J.mirrorContainer = c.body); var fe = i({ containers: J.containers, start: De, end: dt, cancel: Ne, remove: qe, destroy: X, canMove: Fe, dragging: !1 }); return J.removeOnSpill === !0 && fe.on("over", xt).on("out", bt), xe(), fe; function ve(H) { return fe.containers.indexOf(H) !== -1 || J.isContainer(H); } function xe(H) { var te = H ? "remove" : "add"; p(d, te, "mousedown", z), p(d, te, "mouseup", Te); } function Pe(H) { var te = H ? "remove" : "add"; p(d, te, "mousemove", ne); } function Re(H) { var te = H ? "remove" : "add"; s[te](d, "selectstart", de), s[te](d, "click", de); } function X() { xe(!0), Te({}); } function de(H) { j && H.preventDefault(); } function z(H) { R = H.clientX, V = H.clientY; var te = F(H) !== 1 || H.metaKey || H.ctrlKey; if (!te) { var re = H.target, oe = be(re); oe && (j = oe, Pe(), H.type === "mousedown" && (M(re) ? re.focus() : H.preventDefault())); } } function ne(H) { if (j) { if (F(H) === 0) { Te({}); return; } if (!(H.clientX !== void 0 && Math.abs(H.clientX - R) <= (J.slideFactorX || 0) && H.clientY !== void 0 && Math.abs(H.clientY - V) <= (J.slideFactorY || 0))) { if (J.ignoreInputTextSelection) { var te = E("clientX", H) || 0, re = E("clientY", H) || 0, oe = c.elementFromPoint(te, re); if (M(oe)) return; } var we = j; Pe(!0), Re(), dt(), ot(we), l.add(D || B, "gu-transit"), Tt(), Dt(), K = 0, ft(H); } } } function be(H) { if (!(fe.dragging && b) && !ve(H)) { for (var te = H; k(H) && ve(k(H)) === !1; ) if (J.invalid(H, te) || (H = k(H), !H)) return; var re = k(H); if (re && !J.invalid(H, te)) { var oe = J.moves(H, re, te, S(H)); if (oe) return { item: H, source: re }; } } } function Fe(H) { return !!be(H); } function De(H) { var te = be(H); te && ot(te); } function ot(H) { Ie(H.item, H.source) && (D = H.item.cloneNode(!0), fe.emit("cloned", D, H.item, "copy")), T = H.source, B = H.item, N = q = S(H.item), fe.dragging = !0, fe.emit("drag", B, T); } function gt() { return !1; } function dt() { if (fe.dragging) { var H = D || B; Oe(H, k(H)); } } function ee() { j = !1, Pe(!0), Re(!0); } function Te(H) { if (ee(), !!fe.dragging) { var te = D || B, re = E("clientX", H) || 0, oe = E("clientY", H) || 0, we = w(b, re, oe), ye = _t(we, re, oe); ye && (D && J.copySortSource || !D || ye !== T) ? Oe(te, ye) : J.removeOnSpill ? qe() : Ne(); } } function Oe(H, te) { var re = k(H); D && J.copySortSource && te === T && re.removeChild(B), yt(te) ? fe.emit("cancel", H, T) : fe.emit("drop", H, te, T, q), it(); } function qe() { if (fe.dragging) { var H = D || B, te = k(H); te && te.removeChild(H), fe.emit(D ? "cancel" : "remove", H, te, T), it(); } } function Ne(H) { if (fe.dragging) { var te = arguments.length > 0 ? H : J.revertOnSpill, re = D || B, oe = k(re), we = yt(oe); we === !1 && te && (D ? oe && oe.removeChild(D) : T.insertBefore(re, N)), we || te ? fe.emit("cancel", re, T, T) : fe.emit("drop", re, oe, T, q), it(); } } function it() { var H = D || B; ee(), ae(), pe(), H && l.rm(H, "gu-transit"), O && clearTimeout(O), fe.dragging = !1, G && fe.emit("out", H, G, T), fe.emit("dragend", H, K), T = B = D = N = q = O = G = null; } function yt(H, te) { var re; return te !== void 0 ? re = te : b ? re = q : re = S(D || B), H === T && re === N; } function _t(H, te, re) { for (var oe = H; oe && !we(); ) oe = k(oe); return oe; function we() { var ye = ve(oe); if (ye === !1) return !1; var Be = ge(oe, H), Se = Ce(oe, Be, te, re), Le = yt(oe, Se); return Le ? !0 : J.accepts(B, oe, T, Se); } } function ft(H) { if (!b) return; H.preventDefault(); var te = E("clientX", H) || 0, re = E("clientY", H) || 0; b.style.left = te - 2 + "px", b.style.top = re - 2 + "px"; var oe = D || B, we = w(b, te, re), ye = _t(we, te, re), Be = ye !== null && ye !== G; (Be || ye === null) && (he(), G = ye, st()), me(we, re); var Se = k(oe); if (ye === T && D && !J.copySortSource) { Se && Se.removeChild(oe); return; } var Le, at = ge(ye, we); if (U = Ve(at, ye), at !== null) Le = Ce(ye, at, te, re); else if (J.revertOnSpill === !0 && !D)