UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,745 lines (1,744 loc) 136 kB
var Jt = Object.defineProperty; var Zt = (n, t, e) => t in n ? Jt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var U = (n, t, e) => Zt(n, typeof t != "symbol" ? t + "" : t, e); import { defineComponent as me, ref as H, computed as ee, watch as he, createVNode as M, createTextVNode as xe, getCurrentInstance as gt, reactive as Se, withDirectives as Ee, resolveDirective as Pe, onMounted as Ce, onUnmounted as ht, nextTick as be, inject as ae, provide as mt, onBeforeUnmount as Kt, withModifiers as en } from "vue"; import { isPlainObject as at, cloneDeep as ge } from "lodash-es"; import tn from "../response-toolbar/index.esm.js"; import "bignumber.js"; import { getCustomClass as pe, withInstall as nn } from "../common/index.esm.js"; import { useDesignerInnerComponent as on, useDesignerComponent as rn } from "../designer-canvas/index.esm.js"; const vt = {}, bt = {}; function Ue(n) { const { properties: t, title: e, ignore: o } = n, r = o && Array.isArray(o), i = Object.keys(t).reduce((s, u) => ((!r || !o.find((c) => c === u)) && (s[u] = t[u].type === "object" && t[u].properties ? Ue(t[u]) : ge(t[u].default)), s), {}); if (e && (!r || !o.find((s) => s === "id"))) { const s = e.toLowerCase().replace(/-/g, "_"); i.id = `${s}_${Math.random().toString().slice(2, 6)}`; } return i; } function sn(n) { const { properties: t, title: e, required: o } = n; if (o && Array.isArray(o)) { const r = o.reduce((i, s) => (i[s] = t[s].type === "object" && t[s].properties ? Ue(t[s]) : ge(t[s].default), i), {}); if (e && o.find((i) => i === "id")) { const i = e.toLowerCase().replace(/-/g, "_"); r.id = `${i}_${Math.random().toString().slice(2, 6)}`; } return r; } return { type: e }; } function ve(n, t = {}, e) { const o = vt[n]; if (o) { let r = sn(o); const i = bt[n]; return r = i ? i({ getSchemaByType: ve }, r, t, e) : r, r; } return null; } function an(n, t) { const e = Ue(t); return Object.keys(e).reduce((o, r) => (Object.prototype.hasOwnProperty.call(n, r) && (o[r] && at(o[r]) && at(n[r] || !n[r]) ? Object.assign(o[r], n[r] || {}) : o[r] = n[r]), o), e), e; } function yt(n, t) { return Object.keys(n).filter((o) => n[o] != null).reduce((o, r) => { if (t.has(r)) { const i = t.get(r); if (typeof i == "string") o[i] = n[r]; else { const s = i(r, n[r], n); Object.assign(o, s); } } else o[r] = n[r]; return o; }, {}); } function ln(n, t, e = /* @__PURE__ */ new Map()) { const o = an(n, t); return yt(o, e); } function cn(n = {}) { function t(f, h, a, g) { if (typeof a == "number") return g[f].length === a; if (typeof a == "object") { const p = Object.keys(a)[0], m = a[p]; if (p === "not") return Number(g[f].length) !== Number(m); if (p === "moreThan") return Number(g[f].length) >= Number(m); if (p === "lessThan") return Number(g[f].length) <= Number(m); } return !1; } function e(f, h, a, g) { return g[f] && g[f].propertyValue && String(g[f].propertyValue.value) === String(a); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", e] ]); Object.keys(n).reduce((f, h) => (f.set(h, n[h]), f), o); function r(f, h) { const a = f; return typeof h == "number" ? [{ target: a, operator: "length", param: null, value: Number(h) }] : typeof h == "boolean" ? [{ target: a, operator: "getProperty", param: f, value: !!h }] : typeof h == "object" ? Object.keys(h).map((g) => { if (g === "length") return { target: a, operator: "length", param: null, value: h[g] }; const p = g, m = h[g]; return { target: a, operator: "getProperty", param: p, value: m }; }) : []; } function i(f) { return Object.keys(f).reduce((a, g) => { const p = r(g, f[g]); return a.push(...p), a; }, []); } function s(f, h) { if (o.has(f.operator)) { const a = o.get(f.operator); return a && a(f.target, f.param, f.value, h) || !1; } return !1; } function u(f, h) { return i(f).reduce((p, m) => p && s(m, h), !0); } function c(f, h) { const a = Object.keys(f), g = a.includes("allOf"), p = a.includes("anyOf"), m = g || p, v = (m ? f[m ? g ? "allOf" : "anyOf" : "allOf"] : [f]).map((C) => u(C, h)); return g ? !v.includes(!1) : v.includes(!0); } return { parseValueSchema: c }; } const un = { 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: "筛选条" } }, dn = {}, fn = {}; cn(); function He(n, t, e = /* @__PURE__ */ new Map(), o = (s, u, c, f) => u, r = {}, i = (s) => s) { return vt[t.title] = t, bt[t.title] = o, dn[t.title] = r, fn[t.title] = i, (s = {}, u = !0) => { if (!u) return yt(s, e); const c = ln(s, t, e), f = Object.keys(n).reduce((h, a) => (h[a] = n[a].default, h), {}); return Object.assign(f, c); }; } function Ct(n, t) { return { customClass: t.class, customStyle: t.style }; } function pn(n, t) { var o, r; const e = {}; if (t != null && t.buttons) { const i = []; (o = t == null ? void 0 : t.buttons) == null || o.map((s) => { const u = {}; Object.keys(s).map((c) => { var f; c === "appearance" ? u.class = ((f = s[c]) == null ? void 0 : f.class) || "" : u[c] = s[c]; }), i.push(u); }), e.buttons = i; } return (r = t == null ? void 0 : t.appearance) != null && r.class && (e.buttonClass = t.appearance.class || "col-6"), t != null && t.id && (e.toolbarId = t.id), t && Object.prototype.hasOwnProperty.call(t, "visible") && (e.buttonsVisible = t.visible), e; } function wt(n, t) { if (!n || n.length < 1) return null; for (const e of n) { if (e.id === t) return e; if (e.children) { const o = e.children.find((r) => r.id === t); if (o) return o; } } return null; } function gn() { function n(t, e) { var u; const o = (u = t.toolbar) == null ? void 0 : u.buttons; if (!o || o.length < 1) return null; const [r, i] = e.payloads, s = wt(o, i); return s ? s.onClick || s.click : null; } return { resolve: n }; } function hn() { function n(t, e) { const o = t.buttons; if (!o || o.length < 1) return null; const [r, i] = e.payloads, s = wt(o, i); return s ? s.onClick || s.click : null; } return { resolve: n }; } const mn = /* @__PURE__ */ new Map([ ["appearance", Ct], ["toolbar", pn] // 内部处理可见、Id、样式、按钮 ]), vn = "https://json-schema.org/draft/2020-12/schema", bn = "https://farris-design.gitee.io/page-header.schema.json", yn = "page-header", Cn = "A Farris Container Component", wn = "object", xn = { id: { description: "The unique identifier for a Page Header", type: "string" }, type: { description: "The type string of Page Header component", type: "string", default: "page-header" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, showIcon: { description: "", type: "boolean", default: !0 }, icon: { description: "", type: "string", default: "f-icon-page-title-record" }, iconClass: { description: "", type: "string", default: "f-text-orna-bill" }, title: { description: "", type: "string", default: "" }, subTitle: { description: "", type: "string", default: "" }, toolbar: { description: "", type: "object", properties: { appearance: { description: "", type: "object", properties: { class: { type: "string", default: "col-6" } } }, id: { description: "", type: "string" }, type: { description: "", type: "string", default: "response-toolbar" }, alignment: { description: "The alignment of Response Toolbar Button.", type: "string", default: "right" }, buttons: { description: "The items of Response Toolbar.", type: "array", default: [] }, visible: { description: "", type: "boolean", default: !0 } } }, buttonClass: { description: "", type: "string", default: "col-6" }, toolbarId: { description: "", type: "string", default: "" }, titleContentClass: { description: "", type: "string", default: "" }, contentClass: { description: "", type: "string", default: "" }, downContentClass: { description: "", type: "string", default: "" }, showPagination: { description: "", type: "boolean", default: !1 }, prePaginationDisabled: { description: "", type: "boolean", default: !0 }, nextPaginationDisabled: { description: "", type: "boolean", default: !1 }, visible: { description: "", type: "boolean", default: !0 } }, Tn = [ "id", "type" ], Sn = { $schema: vn, $id: bn, title: yn, description: Cn, type: wn, properties: xn, required: Tn }; function En(n, t, e) { return t.title = "标题", t; } const We = { /** 组件自定义样式 */ customClass: { type: String, default: "" }, /** 是否显示图标 */ showIcon: { type: Boolean, default: !0 }, /** 图标的名称 */ icon: { type: String, default: "f-icon-page-title-record" }, /** 图标自定义样式,比如颜色、背景 */ iconClass: { type: String, default: "f-text-orna-bill" }, /** 主标题 */ title: { type: String, default: "" }, /** 副标题 */ subTitle: { type: String, default: "" }, /** 按钮组的样式 */ buttonClass: { type: String, default: "col-6" }, /** 按钮组的标识 */ toolbarId: { type: String, default: "" }, /** 按钮组 */ buttons: { type: Array, default: [] }, /** 标题区域模板自定义样式 */ titleContentClass: { type: String, default: "" }, /** 内容区域模板自定义样式 */ contentClass: { type: String, default: "" }, /** 下方扩展区域模板自定义样式 */ downContentClass: { type: String, default: "" }, /** 是否显示翻页图标 */ showPagination: { type: Boolean, default: !1 }, /** 向前翻页是否禁用 */ prePaginationDisabled: { type: Boolean, default: !0 }, /** 向后翻页是否禁用 */ nextPaginationDisabled: { type: Boolean, default: !1 }, /** 控制是否可见 */ visible: { type: Boolean, default: !0 }, /** 控制按钮是否可见 */ buttonsVisible: { type: Boolean, default: !0 } }, Pn = Object.assign({}, We, { componentId: { type: String, default: "" } }), lt = He(We, Sn, mn, En), Dn = gn(), Fe = /* @__PURE__ */ me({ name: "FPageHeader", props: We, emits: ["click", "prePaginationClick", "nextPaginationClick"], setup(n, t) { const e = H(n.buttons), o = (C, k) => { t.emit("click", C, k); }; function r(C, k) { C && k && k.split(" ").reduce((V, O) => (V[O] = !0, V), C); } const i = ee(() => { const C = { "f-page-header": !0, "d-none": !n.visible }; return r(C, n.customClass), C; }), s = ee(() => { const C = { "f-title-icon": !0 }; return r(C, n.iconClass), C; }), u = ee(() => { const C = { "f-icon": !0 }; return r(C, n.icon), C; }), c = ee(() => { const C = { "f-title": !0 }; return r(C, n.titleContentClass), C; }), f = ee(() => { const C = { "f-content": !0 }; return r(C, n.contentClass), C; }), h = ee(() => { const C = { "f-content": !0 }; return r(C, n.downContentClass), C; }), a = ee(() => ({ "f-icon f-icon-arrow-w": !0, "f-state-disabled": n.prePaginationDisabled })), g = ee(() => ({ "f-icon f-icon-arrow-e": !0, "f-state-disabled": n.nextPaginationDisabled })); function p(C) { n.prePaginationDisabled || t.emit("prePaginationClick", C); } function m(C) { n.nextPaginationDisabled || t.emit("nextPaginationClick", C); } function y() { return t.slots.titleContent ? M("div", { class: c.value }, [xe(" "), t.slots.titleContent()]) : M("div", { class: "f-title" }, [n.showIcon && n.icon ? M("span", { class: s.value }, [M("i", { class: u.value }, null)]) : "", M("h4", { class: "f-title-text" }, [n.title]), n.subTitle ? M("h5", { class: "f-title-subtitle" }, [n.subTitle]) : "", n.showPagination ? M("div", { class: "f-title-pagination" }, [M("span", { class: a.value, onClick: p }, null), M("span", { class: g.value, onClick: m }, null)]) : ""]); } function P() { return t.slots.content ? M("div", { class: f.value }, [xe(" "), t.slots.content()]) : ""; } function v() { if (n.buttons && n.buttons.length > 0) return M(tn, { id: n.toolbarId, customClass: n.buttonClass, visible: n.buttonsVisible, items: e.value, onClick: o }, null); } function d() { return t.slots.downContent ? M("div", { class: h.value }, [xe(" "), t.slots.downContent()]) : ""; } return he(() => n.buttons, (C) => { e.value = C; }, { deep: !0 }), () => n.visible ? M("div", { class: i.value }, [M("nav", { class: "f-page-header-base" }, [y(), P(), v()]), d()]) : null; } }); function Mn(n, t, e) { var O; const o = e && e.getStyles && e.getStyles() || "", r = e && e.getDesignerClass && e.getDesignerClass() || "", i = H(); function s() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanMoveComponent ? e.checkCanMoveComponent() : !0; } function u() { return !1; } function c() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanDeleteComponent ? e.checkCanDeleteComponent() : !0; } function f() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !0 : e && e.hideNestedPaddingInDesginerView ? e.hideNestedPaddingInDesginerView() : !1; } function h(E) { if (!E || !E.value) return null; if (E.value.schema && E.value.schema.type === "component") return E.value; const F = H(E == null ? void 0 : E.value.parent), w = h(F); return w || null; } function a(E = t) { var S; if (e != null && e.getDraggableDesignItemElement) return e.getDraggableDesignItemElement(E); const { componentInstance: F, designerItemElementRef: w } = E; if (!F || !F.value) return null; const { getCustomButtons: l } = F.value; return F.value.canMove || l && ((S = l()) != null && S.length) ? w : a(E.parent); } function g(E) { return !!e && e.canAccepts(E); } function p() { return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name); } function m() { } function y(E, F) { var w; !E || !F || (e != null && e.onAcceptMovedChildElement && e.onAcceptMovedChildElement(E, F), (w = t == null ? void 0 : t.setupContext) == null || w.emit("dragEnd")); } function P(E, F) { const { componentType: w } = E; let l = ve(w, E, F); e && e.onResolveNewComponentSchema && (l = e.onResolveNewComponentSchema(E, l)); const S = w.toLowerCase().replace(/-/g, "_"); return l && !l.id && l.type === w && (l.id = `${S}_${Math.random().toString().slice(2, 6)}`), l; } function v(E) { E && e != null && e.onChildElementMovedOut && e.onChildElementMovedOut(E); } function d(...E) { if (e && e.getPropsConfig) return e.getPropsConfig(...E); } function C(E) { if (!E) return; const F = t == null ? void 0 : t.schema, { formSchemaUtils: w } = E; if (F && w.getExpressions().length) { const l = w.getExpressions().findIndex((S) => S.target === F.id); l > -1 && w.getExpressions().splice(l, 1); } } function k(E) { e && e.onRemoveComponent && e.onRemoveComponent(), C(E), t != null && t.schema.contents && t.schema.contents.map((F) => { let w = F.id; F.type === "component-ref" && (w = F.component); const l = n.value.querySelectorAll(`#${w}-design-item`); l != null && l.length && Array.from(l).map((S) => { var A; (A = S == null ? void 0 : S.componentInstance) != null && A.value.onRemoveComponent && S.componentInstance.value.onRemoveComponent(E); }); }); } function B() { if (e && e.getCustomButtons) return e.getCustomButtons(); } function V(E) { if (e && e.onPropertyChanged) return e.onPropertyChanged(E); } return i.value = { canMove: s(), canSelectParent: u(), canDelete: c(), canNested: !f(), contents: t == null ? void 0 : t.schema.contents, elementRef: n, parent: (O = t == null ? void 0 : t.parent) == null ? void 0 : O.componentInstance, schema: t == null ? void 0 : t.schema, styles: o, designerClass: r, canAccepts: g, getBelongedComponentInstance: h, getDraggableDesignItemElement: a, getDraggingDisplayText: p, getPropConfig: d, getDragScopeElement: m, onAcceptMovedChildElement: y, onChildElementMovedOut: v, addNewChildComponentSchema: P, triggerBelongedComponentToMoveWhenMoved: !!e && e.triggerBelongedComponentToMoveWhenMoved || H(!1), triggerBelongedComponentToDeleteWhenDeleted: !!e && e.triggerBelongedComponentToDeleteWhenDeleted || H(!1), onRemoveComponent: k, getCustomButtons: B, onPropertyChanged: V }, i; } const kn = H(0); function In() { kn.value++; } const ye = H(0); function Bn(n, t) { const e = t.getBoundingClientRect(), o = n.getBoundingClientRect(), r = o.top >= e.top, i = o.top <= e.bottom; return r && i; } function xt(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 i = e.left - r.width; const s = document.querySelector(".editorDiv"); if (s) { const u = s.getBoundingClientRect(); i < u.left && ({ left: i } = n.getBoundingClientRect()); } o.style.left = i + "px"; } } } function An(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 Tt(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 = An(n); if (r && (o = Bn(n, r)), !o) { e.style.display = "none"; return; } xt(n); } } function Rn(n) { if (!n) return; let t; n.className.includes("dgComponentSelected") ? t = n : t = n.querySelector(".dgComponentSelected"), t && Tt(t); } function Vn(n) { const { formSchemaUtils: t, formStateMachineUtils: e } = n; function o(c, f = "") { return { path: f + c.code, field: c.id, fullPath: c.code }; } function r(c, f = "") { return t.getViewModelById(c).states.map((a) => o(a, f)); } function i(c) { const f = t.getRootViewModelId(), h = r(c); if (c === f) return h; const a = r(f, "root-component."); return [...h, ...a]; } function s(c) { return c.binding && c.binding.path || c.id || ""; } function u() { return e && e.getRenderStates() || []; } return { getVariables: i, getControlName: s, getStateMachines: u }; } class Nn { constructor(t) { U(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'" } ]); U(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); U(this, "getExpressionConverter", (t, e) => ({ convertFrom: (o, r, i, s) => { const u = i.getExpressionRuleValue(t, e || r); return u && u.value || ""; }, convertTo: (o, r, i, s, u) => { var c; if (r === "dataPicking" && (i != null && i.target)) { const f = `${i.target}_dataPicking`; ((c = i.rules) == null ? void 0 : c.some( (a) => a.id === f && a.value )) ? o.dictPickingExpressionId = f : delete o.dictPickingExpressionId; } s.updateExpression(i); } })); this.formSchemaService = t; } getExpressionRule(t, e) { const o = this.formSchemaService.getExpressions(); if (!o) return ""; const r = o.find((s) => s.target === t); if (!r) return ""; const i = r.rules.find((s) => s.type === e); return i || ""; } // 获取上下文表单变量 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((i) => { r.push({ key: i.code, name: i.name, description: i.name, category: i.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 u; const i = this.createTreeNode(r, e); let s = []; (u = r.type) != null && u.fields && (s = this.buildEntityFieldsTreeData(r.type.fields, [...e, r.label])), o.push({ data: i, children: s, expanded: !0 }); }), o; } buildChildEntityTreeData(t = null, e) { const o = []; return t == null || t.forEach((r) => { var c, f; const i = this.createTreeNode(r, e), s = this.buildEntityFieldsTreeData((c = r.type) == null ? void 0 : c.fields, [...e, r.label]), u = this.buildChildEntityTreeData((f = r.type) == null ? void 0 : f.entities, [...e, r.label]); u != null && u.length && (s == null || s.push(...u)), o.push({ data: i, children: s || [], // 空值回退 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, i = this.getExpressionRule(r, e), s = this.getEntitiesAndVariables(), u = { message: ["validate", "required", "dataPicking"].includes(e) && i ? i.message : "", ...s }; return i.messageType != null && (u.messageType = i.messageType), u; } buildRule(t, e, o, r) { const { expression: i, message: s, messageType: u } = e, c = { id: `${t}_${o}`, type: o, value: i }; return (o === "validate" || o === "dataPicking" || o === "required") && (c.message = s), o === "dataPicking" && (c.messageType = u), o === "validate" && r && (c.elementId = r), c; } getExpressionData() { const { expressions: t } = this.formSchemaService.getFormSchema().module; return t || []; } updateExpression(t, e, o, r) { const i = e === "Field" ? t.binding.field : t.id, s = this.buildRule(i, o, r, t.type === "form-group" ? t.id : ""); let c = this.getExpressionData().find((h) => h.targetType === e && h.target === i); const f = (h) => h.value.trim() === ""; if (c) { const h = c.rules.find((a) => a.id === s.id); if (h) f(s) ? c.rules = c.rules.filter((a) => a.id !== s.id) : (Object.assign(h, s), r === "validate" && t.type === "form-group" && (h.elementId = t.id)); else { if (f(s)) return null; c.rules = c.rules || [], c.rules.push(s); } } else { if (f(s)) return null; c = { target: `${i}`, rules: [s], targetType: e }; } return c; } getExpressionEditorOptions(t, e, o, r) { return o.reduce((i, s) => { var c, f; const u = e === "Field" ? (c = t == null ? void 0 : t.binding) == null ? void 0 : c.field : t.id; return i[s] = { hide: e === "Field" ? !!((f = t == null ? void 0 : t.binding) != null && f.field) : !1, description: "", title: this.expressionNames[s], type: "string", $converter: this.getExpressionConverter(u), editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[s]}编辑器`, showMessage: s === "validate" || s === "dataPicking" || s === "required", showMessageType: s === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(t, s, e), onSubmitModal: (h) => { const a = this.updateExpression(t, e, h, s); if (r) { const g = this.buildRule(u, h, s); r(g); } return a; } } }, i; }, {}); } getExpressionInfo(t, e, o) { const r = e === "Field" ? t.binding.field : t.id, i = this.getExpressionRule(r, o), s = { value: i && i.value, targetId: r, targetType: e, expressionType: o }; return i && i.message && (s.message = i.message), s; } 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 Me { constructor(t, e) { U(this, "componentId"); U(this, "viewModelId"); U(this, "eventsEditorUtils"); U(this, "formSchemaUtils"); U(this, "formMetadataConverter"); U(this, "designViewModelUtils"); U(this, "designViewModelField"); U(this, "controlCreatorUtils"); U(this, "designerHostService"); U(this, "schemaService", null); U(this, "metadataService", null); U(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((i) => i.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: un[t.type].name }] } } } }; } getAppearanceConfig(t = null, e = {}, o) { const r = { title: "外观", description: "Appearance" }, i = { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter" } }; for (const s in e) i[s] = Object.assign(i[s] || {}, e[s]); return { ...r, properties: { ...i }, setPropertyRelates(s, u) { if (s) { switch (s && s.propertyID) { case "class": case "style": { ye.value++; break; } } o && o(s, t, u); } } }; } getPropertyEditorParams(t, e = [], o = "visible", r = {}, i = {}) { const { getVariables: s, getControlName: u, getStateMachines: c } = Vn(this.designerHostService), f = this.getRealTargetType(t), h = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], a = { type: "property-editor", propertyTypes: h }; return h.map((g) => { switch (g) { case "Const": Object.assign(a, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, r); break; case "Expression": a.expressionConfig = this.getExpressionOptions(t, f, o); break; case "StateMachine": a.stateMachines = c(); break; case "Variable": Object.assign(a, { controlName: u(t), newVariablePrefix: "is", newVariableType: "Boolean", variables: s(this.viewModelId), onBeforeOpenVariables: (p) => { p.value = s(this.viewModelId); } }, i); break; } }), a; } 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 i = { title: "行为", description: "" }, s = this.getVisibleProperty(t, e); for (const c in o) s[c] = Object.assign(s[c] || {}, o[c]); const u = this; return { ...i, properties: { ...s }, setPropertyRelates(c, f) { if (c) { switch (c.propertyID) { case "disabled": case "readonly": case "visible": u.afterMutilEditorChanged(t, c); break; } r && r(c, f); } } }; } /** * 当多值编辑器变更时 * @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((s) => s.id === t), i = ge(o.contents[r]); o.contents.splice(r, 1), o.contents.splice(r, 0, i), In(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到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 s = { id: o.field, category: "locale", code: o.fullPath, name: o.fullPath, type: o.newVariableType || "String" }; delete o.newVariableType, delete o.isNewVariable, this.formSchemaUtils.getVariableByCode(s.code) || this.formSchemaUtils.getViewModelById(e).states.push(s); } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(t) { const e = t.propertyValue; if (!((e && e.type) === "Expression" && e.expressionInfo)) return; const { expressionId: i, expressionInfo: s } = e, { targetId: u, targetType: c, expressionType: f, value: h, message: a } = s, g = this.formSchemaUtils.getModule(); g.expressions ?? (g.expressions = []); const { expressions: p } = g; let m = p.find((P) => P.target === u); m || (m = { target: u, rules: [], targetType: c }, p.push(m)); const y = m.rules.find((P) => P.type === f); if (y) y.value = h, y.message = a; else { const P = { id: i, type: f, value: h, message: a }; m.rules.push(P); } delete e.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(t, e) { const o = t.propertyValue; if (o && o.type === "Expression") return; const i = t.propertyID, s = this.formSchemaUtils.getExpressions(), u = e.binding ? e.binding.field : e.id, c = s.find((f) => f.target === u); !c || !c.rules || (c.rules = c.rules.filter((f) => f.type !== i)); } getExpressionOptions(t, e, o) { return new Nn(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 On extends Me { constructor(t, e) { super(t, e); } getPropertyConfig(t) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(t), this.propertyConfig.categories.appearance = this.getAppearanceProperties(t), this.propertyConfig.categories.behavior = this.getBehaviorConfig(t), this.propertyConfig; } getAppearanceProperties(t) { return { title: "外观", description: "", properties: { class: { title: "class样式", type: "string", description: "组件的CSS样式" }, icon: { title: "图标", type: "string", description: "图标" }, title: { title: "标题", type: "string", description: "标题" } }, setPropertyRelates(e, o) { if (e) switch (e && e.propertyID) { case "title": { e.needRefreshControlTree = !0; break; } } } }; } } function $n(n, t) { function e(u) { return !1; } function o() { return !1; } function r() { return !1; } function i() { return !0; } function s(u) { return new On(u, t).getPropertyConfig(n); } return { canAccepts: e, hideNestedPaddingInDesginerView: i, getPropsConfig: s, checkCanDeleteComponent: o, checkCanMoveComponent: r }; } class St { constructor(t) { /** 工具栏项标识 */ U(this, "id", ""); /** 工具栏项自定义样式 */ U(this, "class", "btn-secondary"); /** 图标 */ U(this, "icon", ""); /** 所属分组 */ U(this, "groupId", ""); /** 收藏顺序 */ U(this, "order", -1); /** 是否作为下拉菜单的顶层按钮 */ U(this, "asDropDownTop", !1); /** 文本 */ U(this, "text", ""); /** 是否可见原值 */ U(this, "visible", !0); /** 控制界面是否显示 */ U(this, "shown", !0); U(this, "responsed", !1); /** 是否启用提示消息 */ U(this, "tipsEnable", !1); /** 提示消息内容 */ U(this, "tipsText", ""); /** 记录宽度 */ U(this, "width", 0); /** 下拉时的样式名 */ U(this, "dropdownClass", ""); U(this, "onClick", () => { }); U(this, "options"); var o, r; this.options = t; const e = [ "id", "class", "icon", "groupId", "order", "asDropDownTop", "text", "isDP", "visible", "responsed", "width", "tipsEnable", "tipsText", "dropdownClass", "onClick" ]; Object.keys(t).filter((i) => e.indexOf(i) > -1).forEach((i) => { i === "visible" ? this[i] = t[i] === void 0 ? !0 : t[i] : this[i] = t[i]; }), this.shown = this.visible, (o = t.appearance) != null && o.class && (this.class = (r = t.appearance) == null ? void 0 : r.class); } /** 是否可用 */ get enable() { return Object.keys(this.options).indexOf("disabled") > -1 ? !this.options.disabled : ee(() => !0); } /** 设置宽度 */ setWidth(t) { this.width = parseInt(t, 10); } /** 获取宽度 */ getWidth() { return this.visible ? this.width : !1; } } class _n extends St { constructor(t) { super(t); } } function Et() { function n(t) { const e = []; return t.reduce((o, r) => (r.children && r.children.length > 0 ? o.push(new Te(r)) : o.push(new _n(r)), o), e), e; } return { buildResponseToolbarItems: n }; } const { buildResponseToolbarItems: Fn } = Et(); class Te extends St { constructor(e) { super(e); U(this, "placement", ""); // 下拉位置 /** 是否可见 */ U(this, "visible", !0); /** 下拉class */ U(this, "dropdownClass", ""); /** 下拉菜单class */ U(this, "menuClass", ""); /** 是否用分开的下拉按钮 */ U(this, "split", !1); U(this, "children", []); U(this, "expanded", !1); U(this, "shown", !0); const o = ["visible", "icon", "isDP", "class", "dropdownClass", "menuClass", "placement", "split", "expanded"]; Object.keys(e).filter((r) => o.indexOf(r) > -1).forEach((r) => { r === "visible" ? this[r] = e[r] === void 0 ? !0 : e[r] : this[r] = e[r]; }), this.shown = this.visible, e.children && e.children.length && (this.children = Fn(e.children)); } } const Ln = /* @__PURE__ */ new Map([ ["buttons", "items"], ["appearance", Ct] ]); function Pt(n, t, e) { return t; } const jn = "https://json-schema.org/draft/2020-12/schema", qn = "https://farris-design.gitee.io/response-toolbar.schema.json", Un = "response-toolbar", Hn = "A Farris Toolbar Component", Wn = "object", zn = { id: { description: "The unique identifier for a Response Toolbar", type: "string" }, type: { description: "The type string of Response Toolbar", type: "string", default: "response-toolbar" }, appearance: { description: "", type: "object", properties: { class: { type: "string", default: "" } } }, alignment: { description: "The alignment of Response Toolbar Button.", type: "string", default: "right" }, buttons: { description: "The items of Response Toolbar.", type: "array", default: [] }, buttonSize: { type: "string", default: "" }, visible: { description: "", type: "boolean", default: !0 } }, Xn = [ "id", "type", "buttons" ], Yn = { onClick: "点击事件" }, Gn = { $schema: jn, $id: qn, title: Un, description: Hn, type: Wn, properties: zn, required: Xn, events: Yn }, Qn = "https://json-schema.org/draft/2020-12/schema", Jn = "https://farris-design.gitee.io/response-toolbar-item.schema.json", Zn = "response-toolbar-item", Kn = "A Farris Toolbar Item Component", eo = "object", to = { id: { description: "The unique identifier for a Response Toolbar", type: "string" }, type: { description: "The type string of Response Toolbar", type: "string", default: "response-toolbar-item" }, appearance: { description: "", type: "object", properties: { class: { type: "string", default: "" } } }, alignment: { description: "对齐", type: "string", default: "right" }, text: { description: "文本", type: "string", default: "按钮" }, icon: { description: "图标", type: "string", default: "" }, disabled: { description: "禁用", type: "boolean", default: !1 }, visible: { description: "是否可见", type: "boolean", default: !0 }, onClick: { description: "点击事件", type: "string", default: "" }, tipsEnable: { description: "", type: "boolean", default: !1 }, tipsText: { description: "", type: "string", default: "" }, dropdownClass: { description: "处于下拉菜单时的样式", type: "string", default: "" }, split: { description: "", type: "boolean", default: !1 } }, no = [ "id", "type", "text" ], oo = { $schema: Qn, $id: Jn, title: Zn, description: Kn, type: eo, properties: to, required: no }, ze = { id: { type: String, default: "" }, /** 组件自定义样式 */ customClass: { type: String, default: "" }, alignment: { Type: String, default: "right" }, items: { Type: Array, default: [] }, /** 控制是否可见 */ visible: { type: Boolean, default: !0 } }, ro = Object.assign({}, ze, { componentId: { type: String, default: "" } }), Xe = He( ze, Gn, Ln, Pt ), Dt = { id: { type: String, default: "" }, item: { type: Object, default: {} }, items: { type: Object, default: {} }, class: { type: String, default: "btn-secondary" }, text: { type: String, default: "" }, disabled: { type: Boolean, default: !1 }, icon: { type: String, default: "" }, componentId: { type: String, default: "" }, // 是否展开子级 expanded: { type: Boolean, default: !1 }, alignment: { Type: String, default: "right" }, split: { type: Boolean, default: !1 }, // 是否下拉 isDP: { type: Boolean, default: !1 }, // 是否下拉项 isDPItem: { type: Boolean, default: !1 } }, io = He( Dt, oo, void 0, Pt ), so = hn(); function Ye() { function n(e) { const o = { "f-icon": !0 }; if (e.icon) { const r = e.icon.trim().split(" "); r && r.length && r.reduce((i, s) => (i[s] = !0, i), o); } return o; } function t(e) { return !!(e.icon && e.icon.trim()); } return { iconClass: n, shouldShowIcon: t }; } const ao = ["moz", "ms", "webkit"]; function lo() { let n = 0; return (t) => { const e = (/* @__PURE__ */ new Date()).getTime(), o = Math.max(0, 16 - (e - n)), r = setTimeout(() => { t(e + o); }, o); return n = e + o, r; }; } function co() { if (typeof window > "u") return () => 0; if (window.requestAnimationFrame) return window.requestAnimationFrame.bind(window); const n = ao.filter((t) => `${t}RequestAnimationFrame` in window)[0]; return n ? window[`${n}RequestAnimationFrame`] : lo(); } co(); function Le(n, t) { return ((t == null ? void 0 : t.split(" ")) || []).reduce((o, r) => (r && (o[r] = !0), o), n), n; } function uo(n, t) { function e(v) { const d = { "dropdown-menu": !0 }; if (v.class) { const C = v.menuClass.split(" "); C && C.length && C.reduce((k, B) => (k[B] = !0, k), d); } return d; } function o(v) { const d = { disabled: !v.enable, "dropdown-submenu": !0, "f-rt-dropdown": !0, "text-truncate": !0 }; return Le(d, v.dropdownClass); } function r(v) { const d = { disabled: !v.enable, "dropdown-item": !0, "f-rt-btn": !0, "text-truncate": !0 }; return Le(d, v.dropdownClass); } function i(v) { const d = { disabled: !v.enable, "dropdown-item": !0, "f-rt-btn": !0, "text-truncate": !0, "f-rt-toggle": !0 }; return Le(d, v.dropdownClass); } let s; const u = /* @__PURE__ */ new Map(); function c(v, d, C) { v.stopPropagation(); const k = C ? C.id : "__top_item__"; if (d.children && d.children.length && (d.expanded = !d.expanded, d.expanded)) { if (u.has(k) && u.get(k) !== d) { const B = u.get(k); B && (B.expanded = !1, u.delete(k)); } u.set(k, d); } } function f(v, d) { document.body.click(), d.enable && (v.stopPropagation(), typeof d.onClick == "function" && d.onClick(v, d.id), n.emit("click", v, d.id)); } function h(v, d) { const C = v.target; C.className.indexOf("dropdown-item") < 0 || (C.title = C.scrollWidth > C.clientWidth ? d : ""); } function a(v, d) { if (d.tipsEnable && d.tipsText) { const C = Se({ content: d.tipsText, enable: d.tipsEnable }); return Ee(M("li", { class: r(d), id: d.id, onClick: (k) => f(k, d) }, [M("span", { class: "f-rt-btn text-truncate" }, [t.shouldShowIcon(d) && M("i", { class: t.iconClass(d) }, null), d.text])]), [[Pe("tooltip"), C]]); } return M("li", { class: r(d), id: d.id, onClick: (C) => f(C, d) }, [M("span", { class: "f-rt-btn text-truncate", onMouseenter: (C) => h(C, d.text) }, [t.shouldShowIcon(d) && M("i", { class: t.iconClass(d) }, null), d.text])]); } function g(v, d, C) { d.enable && (typeof d.onClick == "function" && C.onClick(v, d.id), n.emit("click", v, d.id), c(v, d, C)); } function p(v, d) { if (d.tipsEnable && d.tipsText) { const C = Se({ content: d.tipsText, enable: d.tipsEnable }); return M("li", { class: o(d), id: d.id, onClick: (k) => g(k, d, v) }, [Ee(M("span", { class: i(d) }, [t.shouldShowIcon(d) && M("i", { class: t.iconClass(d) }, null), d.text]), [[Pe("tooltip"), C]]), s(d, d)]); } return M("li", {