UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,696 lines (1,695 loc) 121 kB
var qt = Object.defineProperty; var Ut = (o, e, t) => e in o ? qt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t; var q = (o, e, t) => Ut(o, typeof e != "symbol" ? e + "" : e, t); import { computed as le, getCurrentInstance as at, createVNode as V, reactive as we, withDirectives as Ce, resolveDirective as xe, ref as X, defineComponent as Se, onMounted as Ie, onUnmounted as ct, watch as Te, nextTick as he, inject as ce, provide as ut, onBeforeUnmount as Ht, withModifiers as Wt, createTextVNode as zt } from "vue"; import { isPlainObject as ot, cloneDeep as ge } from "lodash-es"; import "bignumber.js"; import { getCustomClass as pe, withInstall as Xt } from "../common/index.esm.js"; import { useDesignerInnerComponent as Yt, useDesignerComponent as Gt } from "../designer-canvas/index.esm.js"; class dt { constructor(e) { /** 工具栏项标识 */ q(this, "id", ""); /** 工具栏项自定义样式 */ q(this, "class", "btn-secondary"); /** 图标 */ q(this, "icon", ""); /** 所属分组 */ q(this, "groupId", ""); /** 收藏顺序 */ q(this, "order", -1); /** 是否作为下拉菜单的顶层按钮 */ q(this, "asDropDownTop", !1); /** 文本 */ q(this, "text", ""); /** 是否可见原值 */ q(this, "visible", !0); /** 控制界面是否显示 */ q(this, "shown", !0); q(this, "responsed", !1); /** 是否启用提示消息 */ q(this, "tipsEnable", !1); /** 提示消息内容 */ q(this, "tipsText", ""); /** 记录宽度 */ q(this, "width", 0); /** 下拉时的样式名 */ q(this, "dropdownClass", ""); q(this, "onClick", () => { }); q(this, "options"); var n, r; this.options = e; const t = [ "id", "class", "icon", "groupId", "order", "asDropDownTop", "text", "isDP", "visible", "responsed", "width", "tipsEnable", "tipsText", "dropdownClass", "onClick" ]; Object.keys(e).filter((i) => t.indexOf(i) > -1).forEach((i) => { i === "visible" ? this[i] = e[i] === void 0 ? !0 : e[i] : this[i] = e[i]; }), this.shown = this.visible, (n = e.appearance) != null && n.class && (this.class = (r = e.appearance) == null ? void 0 : r.class); } /** 是否可用 */ get enable() { return Object.keys(this.options).indexOf("disabled") > -1 ? !this.options.disabled : le(() => !0); } /** 设置宽度 */ setWidth(e) { this.width = parseInt(e, 10); } /** 获取宽度 */ getWidth() { return this.visible ? this.width : !1; } } class Qt extends dt { constructor(e) { super(e); } } function ft() { function o(e) { const t = []; return e.reduce((n, r) => (r.children && r.children.length > 0 ? n.push(new ye(r)) : n.push(new Qt(r)), n), t), t; } return { buildResponseToolbarItems: o }; } const { buildResponseToolbarItems: Jt } = ft(); class ye extends dt { constructor(t) { super(t); q(this, "placement", ""); // 下拉位置 /** 是否可见 */ q(this, "visible", !0); /** 下拉class */ q(this, "dropdownClass", ""); /** 下拉菜单class */ q(this, "menuClass", ""); /** 是否用分开的下拉按钮 */ q(this, "split", !1); q(this, "children", []); q(this, "expanded", !1); q(this, "shown", !0); const n = ["visible", "icon", "isDP", "class", "dropdownClass", "menuClass", "placement", "split", "expanded"]; Object.keys(t).filter((r) => n.indexOf(r) > -1).forEach((r) => { r === "visible" ? this[r] = t[r] === void 0 ? !0 : t[r] : this[r] = t[r]; }), this.shown = this.visible, t.children && t.children.length && (this.children = Jt(t.children)); } } class co { constructor(e, t) { q(this, "id"); q(this, "name"); /** 记录元素的Id */ q(this, "presetId", []); /** 记录转变为下拉时元素的位置 */ q(this, "responsedIndex", []); /** 记录宽度 */ q(this, "width"); this.id = e, this.name = t, this.width = 0; } // 设置宽度 setWidth(e) { this.width = parseInt(e + "", 10); } // 获取宽度 getWidth() { return this.width; } // 更新presetIndex setPreset(e) { Array.isArray(e) ? this.presetId = this.presetId.concat(e) : this.presetId.push(e); } // 清除preset delPreset() { this.presetId = []; } // 删除 removeResponsed(e) { this.responsedIndex.splice(e, 1); } // 更新responsedIndex setResponsed(e) { Array.isArray(e) ? this.responsedIndex = this.responsedIndex.concat(e) : this.responsedIndex.push(e); } // 是否已经开始处理响应式 isResponsing() { return this.responsedIndex.length > 0; } // 是否已经处理完响应式 isResponsed() { return this.presetId.length === this.responsedIndex.length; } } const pt = {}, gt = {}; function Fe(o) { const { properties: e, title: t, ignore: n } = o, r = n && Array.isArray(n), i = Object.keys(e).reduce((s, p) => ((!r || !n.find((c) => c === p)) && (s[p] = e[p].type === "object" && e[p].properties ? Fe(e[p]) : ge(e[p].default)), s), {}); if (t && (!r || !n.find((s) => s === "id"))) { const s = t.toLowerCase().replace(/-/g, "_"); i.id = `${s}_${Math.random().toString().slice(2, 6)}`; } return i; } function Zt(o) { const { properties: e, title: t, required: n } = o; if (n && Array.isArray(n)) { const r = n.reduce((i, s) => (i[s] = e[s].type === "object" && e[s].properties ? Fe(e[s]) : ge(e[s].default), i), {}); if (t && n.find((i) => i === "id")) { const i = t.toLowerCase().replace(/-/g, "_"); r.id = `${i}_${Math.random().toString().slice(2, 6)}`; } return r; } return { type: t }; } function ve(o, e = {}, t) { const n = pt[o]; if (n) { let r = Zt(n); const i = gt[o]; return r = i ? i({ getSchemaByType: ve }, r, e, t) : r, r; } return null; } function Kt(o, e) { const t = Fe(e); return Object.keys(t).reduce((n, r) => (Object.prototype.hasOwnProperty.call(o, r) && (n[r] && ot(n[r]) && ot(o[r] || !o[r]) ? Object.assign(n[r], o[r] || {}) : n[r] = o[r]), n), t), t; } function ht(o, e) { return Object.keys(o).filter((n) => o[n] != null).reduce((n, r) => { if (e.has(r)) { const i = e.get(r); if (typeof i == "string") n[i] = o[r]; else { const s = i(r, o[r], o); Object.assign(n, s); } } else n[r] = o[r]; return n; }, {}); } function en(o, e, t = /* @__PURE__ */ new Map()) { const n = Kt(o, e); return ht(n, t); } function tn(o = {}) { function e(f, h, l, g) { if (typeof l == "number") return g[f].length === l; if (typeof l == "object") { const d = Object.keys(l)[0], m = l[d]; if (d === "not") return Number(g[f].length) !== Number(m); if (d === "moreThan") return Number(g[f].length) >= Number(m); if (d === "lessThan") return Number(g[f].length) <= Number(m); } return !1; } function t(f, h, l, g) { return g[f] && g[f].propertyValue && String(g[f].propertyValue.value) === String(l); } const n = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(o).reduce((f, h) => (f.set(h, o[h]), f), n); function r(f, h) { const l = f; return typeof h == "number" ? [{ target: l, operator: "length", param: null, value: Number(h) }] : typeof h == "boolean" ? [{ target: l, operator: "getProperty", param: f, value: !!h }] : typeof h == "object" ? Object.keys(h).map((g) => { if (g === "length") return { target: l, operator: "length", param: null, value: h[g] }; const d = g, m = h[g]; return { target: l, operator: "getProperty", param: d, value: m }; }) : []; } function i(f) { return Object.keys(f).reduce((l, g) => { const d = r(g, f[g]); return l.push(...d), l; }, []); } function s(f, h) { if (n.has(f.operator)) { const l = n.get(f.operator); return l && l(f.target, f.param, f.value, h) || !1; } return !1; } function p(f, h) { return i(f).reduce((d, m) => d && s(m, h), !0); } function c(f, h) { const l = Object.keys(f), g = l.includes("allOf"), d = l.includes("anyOf"), m = g || d, b = (m ? f[m ? g ? "allOf" : "anyOf" : "allOf"] : [f]).map((E) => p(E, h)); return g ? !b.includes(!1) : b.includes(!0); } return { parseValueSchema: c }; } const nn = { 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: "筛选条" } }, on = {}, rn = {}; tn(); function mt(o, e, t = /* @__PURE__ */ new Map(), n = (s, p, c, f) => p, r = {}, i = (s) => s) { return pt[e.title] = e, gt[e.title] = n, on[e.title] = r, rn[e.title] = i, (s = {}, p = !0) => { if (!p) return ht(s, t); const c = en(s, e, t), f = Object.keys(o).reduce((h, l) => (h[l] = o[l].default, h), {}); return Object.assign(f, c); }; } function sn(o, e) { return { customClass: e.class, customStyle: e.style }; } function ln(o, e) { if (!o || o.length < 1) return null; for (const t of o) { if (t.id === e) return t; if (t.children) { const n = t.children.find((r) => r.id === e); if (n) return n; } } return null; } function an() { function o(e, t) { const n = e.buttons; if (!n || n.length < 1) return null; const [r, i] = t.payloads, s = ln(n, i); return s ? s.onClick || s.click : null; } return { resolve: o }; } const cn = /* @__PURE__ */ new Map([ ["buttons", "items"], ["appearance", sn] ]); function vt(o, e, t) { return e; } const un = "https://json-schema.org/draft/2020-12/schema", dn = "https://farris-design.gitee.io/response-toolbar.schema.json", fn = "response-toolbar", pn = "A Farris Toolbar Component", gn = "object", hn = { 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 } }, mn = [ "id", "type", "buttons" ], vn = { onClick: "点击事件" }, bn = { $schema: un, $id: dn, title: fn, description: pn, type: gn, properties: hn, required: mn, events: vn }, yn = "https://json-schema.org/draft/2020-12/schema", wn = "https://farris-design.gitee.io/response-toolbar-item.schema.json", Cn = "response-toolbar-item", xn = "A Farris Toolbar Item Component", Tn = "object", En = { 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 } }, Sn = [ "id", "type", "text" ], In = { $schema: yn, $id: wn, title: Cn, description: xn, type: Tn, properties: En, required: Sn }, Le = { id: { type: String, default: "" }, /** 组件自定义样式 */ customClass: { type: String, default: "" }, alignment: { Type: String, default: "right" }, items: { Type: Array, default: [] }, /** 控制是否可见 */ visible: { type: Boolean, default: !0 } }, Pn = Object.assign({}, Le, { componentId: { type: String, default: "" } }), qe = mt( Le, bn, cn, vt ), bt = { 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 } }, Mn = mt( bt, In, void 0, vt ), kn = an(); function Ue() { function o(t) { const n = { "f-icon": !0 }; if (t.icon) { const r = t.icon.trim().split(" "); r && r.length && r.reduce((i, s) => (i[s] = !0, i), n); } return n; } function e(t) { return !!(t.icon && t.icon.trim()); } return { iconClass: o, shouldShowIcon: e }; } const Dn = ["moz", "ms", "webkit"]; function Rn() { let o = 0; return (e) => { const t = (/* @__PURE__ */ new Date()).getTime(), n = Math.max(0, 16 - (t - o)), r = setTimeout(() => { e(t + n); }, n); return o = t + n, r; }; } function Bn() { if (typeof window > "u") return () => 0; if (window.requestAnimationFrame) return window.requestAnimationFrame.bind(window); const o = Dn.filter((e) => `${e}RequestAnimationFrame` in window)[0]; return o ? window[`${o}RequestAnimationFrame`] : Rn(); } Bn(); function _e(o, e) { return ((e == null ? void 0 : e.split(" ")) || []).reduce((n, r) => (r && (n[r] = !0), n), o), o; } function An(o, e) { function t(b) { const u = { "dropdown-menu": !0 }; if (b.class) { const E = b.menuClass.split(" "); E && E.length && E.reduce((D, M) => (D[M] = !0, D), u); } return u; } function n(b) { const u = { disabled: !b.enable, "dropdown-submenu": !0, "f-rt-dropdown": !0, "text-truncate": !0 }; return _e(u, b.dropdownClass); } function r(b) { const u = { disabled: !b.enable, "dropdown-item": !0, "f-rt-btn": !0, "text-truncate": !0 }; return _e(u, b.dropdownClass); } function i(b) { const u = { disabled: !b.enable, "dropdown-item": !0, "f-rt-btn": !0, "text-truncate": !0, "f-rt-toggle": !0 }; return _e(u, b.dropdownClass); } let s; const p = /* @__PURE__ */ new Map(); function c(b, u, E) { b.stopPropagation(); const D = E ? E.id : "__top_item__"; if (u.children && u.children.length && (u.expanded = !u.expanded, u.expanded)) { if (p.has(D) && p.get(D) !== u) { const M = p.get(D); M && (M.expanded = !1, p.delete(D)); } p.set(D, u); } } function f(b, u) { document.body.click(), u.enable && (b.stopPropagation(), typeof u.onClick == "function" && u.onClick(b, u.id), o.emit("click", b, u.id)); } function h(b, u) { const E = b.target; E.className.indexOf("dropdown-item") < 0 || (E.title = E.scrollWidth > E.clientWidth ? u : ""); } function l(b, u) { if (u.tipsEnable && u.tipsText) { const E = we({ content: u.tipsText, enable: u.tipsEnable }); return Ce(V("li", { class: r(u), id: u.id, onClick: (D) => f(D, u) }, [V("span", { class: "f-rt-btn text-truncate" }, [e.shouldShowIcon(u) && V("i", { class: e.iconClass(u) }, null), u.text])]), [[xe("tooltip"), E]]); } return V("li", { class: r(u), id: u.id, onClick: (E) => f(E, u) }, [V("span", { class: "f-rt-btn text-truncate", onMouseenter: (E) => h(E, u.text) }, [e.shouldShowIcon(u) && V("i", { class: e.iconClass(u) }, null), u.text])]); } function g(b, u, E) { u.enable && (typeof u.onClick == "function" && E.onClick(b, u.id), o.emit("click", b, u.id), c(b, u, E)); } function d(b, u) { if (u.tipsEnable && u.tipsText) { const E = we({ content: u.tipsText, enable: u.tipsEnable }); return V("li", { class: n(u), id: u.id, onClick: (D) => g(D, u, b) }, [Ce(V("span", { class: i(u) }, [e.shouldShowIcon(u) && V("i", { class: e.iconClass(u) }, null), u.text]), [[xe("tooltip"), E]]), s(u, u)]); } return V("li", { class: n(u), id: u.id, onClick: (E) => g(E, u, b), onMouseenter: (E) => h(E, u.text) }, [V("span", { class: i(u) }, [e.shouldShowIcon(u) && V("i", { class: e.iconClass(u) }, null), u.text]), s(u, u)]); } function m(b) { return b.children.filter((u) => u.visible).map((u) => u.children && u.children.length ? d(b, u) : l(b, u)); } function w(b, u, E) { var j; const D = { display: b.expanded ? "block" : "none", position: "fixed", maxWidth: "300px", minWidth: "120px", zIndex: 1040 }, M = (j = document.getElementsByTagName("body")[0].getClientRects()[0]) == null ? void 0 : j.width, O = u, N = O == null ? void 0 : O.getClientRects(); if (O && N && N.length) { const { top: U, width: x, left: a, right: S, height: k } = N[0], y = Math.ceil(k + U); D.top = `${y}px`, D.left = `${a}px`; const I = b.id + "_menu", B = u ? u.querySelector("#" + I) : null; if (B) { B.style.visibility = "hidden", B.style.display = "block"; const C = B.offsetHeight; D.display === "block" && (B.style.display = "block"); const T = B.getBoundingClientRect(); if (E) { D.top = `${U - 6}px`; const _ = Math.ceil(x + a); D.left = `${_}px`; } M - a - x < T.width && (D.left = `${(E ? a : S) - T.width}px`), window.innerHeight - U - k < C && (U > C ? D.top = `${U - C - 6}px` : (D.maxHeight = `${U - 16}px`, D.overflowY = "auto", U - k > window.innerHeight - U && (D.top = "10px"))), B.style.visibility = "visible"; } } return D; } s = function(b, u) { var O, N; const E = at(), D = u ? u.id : b.id, M = (N = (O = E == null ? void 0 : E.exposed) == null ? void 0 : O.elementRef.value) == null ? void 0 : N.querySelector("#" + D); return V("ul", { class: t(b), style: w(b, M, u), id: b.id + "_menu" }, [m(b)]); }; function P() { p.forEach((b) => { b.expanded = !1; }), p.clear(); } return { renderDropdownMenu: s, clearAllDropDownMenu: P }; } function On(o, e, t) { const n = X(o.alignment), { renderDropdownMenu: r, clearAllDropDownMenu: i } = An(e, t); function s(l) { const g = { "btn-group": !0, "f-rt-dropdown": !0, "f-btn-ml": n.value === "right" || n.value === "center", "f-btn-mr": n.value === "left" }, d = l.dropdownClass.split(" "); return d && d.length && d.reduce((m, w) => (m[w] = !0, m), g), g; } function p(l) { const g = { btn: !0, disabled: !l.enable, "f-rt-btn": !0, "btn-icontext": !!(l.icon && l.icon.trim()) }; if (l.class) { const d = l.class.split(" "); d && d.length && d.reduce((m, w) => (m[w] = !0, m), g); } return g; } function c(l, g) { l.stopPropagation(); const d = g.expanded; document.body.click(), typeof g.onClick == "function" && g.onClick(l, g.id), e.emit("click", l, g.id), g.expanded = !d; } function f(l, g = !0) { if (l.tipsEnable && l.tipsText) { const d = we({ content: l.tipsText, enable: l.tipsEnable }); return V("div", { id: l.id, class: s(l) }, [Ce(V("div", { class: p(l), style: "display: flex;padding-right: 0.1rem;border-top-right-radius: 6px;border-bottom-right-radius: 6px", onClick: (m) => l.enable && c(m, l) }, [t.shouldShowIcon(l) && V("i", { class: t.iconClass(l) }, null), V("span", null, [l.text]), V("i", { class: "f-icon f-icon-arrow-chevron-down", style: "display: inline-block;float: right;line-height: 1.25rem;margin-left: .25rem;margin-right: .25rem;" }, null)]), [[xe("tooltip"), d]]), g && r(l)]); } return V("div", { id: l.id, class: s(l) }, [V("div", { class: p(l), style: "display: flex;padding-right: 0.1rem;border-top-right-radius: 6px;border-bottom-right-radius: 6px", onClick: (d) => l.enable && c(d, l) }, [t.shouldShowIcon(l) && V("i", { class: t.iconClass(l) }, null), V("span", null, [l.text]), V("i", { class: "f-icon f-icon-arrow-chevron-down", style: "display: inline-block;float: right;line-height: 1.25rem;margin-left: .25rem;margin-right: .25rem;" }, null)]), g && r(l)]); } function h() { i(); } return { renderToolbarDropdown: f, clearAllDropDown: h }; } const { buildResponseToolbarItems: rt } = ft(), Ee = /* @__PURE__ */ Se({ name: "FResponseToolbar", props: Le, emits: ["click"], setup(o, e) { const t = X(rt(o.items)), n = X(), r = X(), i = X(), s = { id: "__more_buttons__", text: "更多" }, p = X(new ye(s)), c = { id: s.id + "width", text: s.text }, f = X(-1), h = Ue(); let l = !1; const g = le(() => p.value.children.length > 0), d = le(() => { const C = { "f-toolbar": !0, "f-response-toolbar": !0, "position-relative": !0, "f-response-toolbar-sm": o.buttonSize === "sm", "f-response-toolbar-lg": o.buttonSize === "lg", "d-none": !o.visible }; return pe(C, o.customClass); }), m = le(() => ({ "w-100": !0, "d-flex": !0, "flex-nowrap": !0, "justify-content-end": o.alignment === "right", "justify-content-start": o.alignment === "left", "justify-content-center": o.alignment === "center" })), { renderToolbarDropdown: w, clearAllDropDown: P } = On(o, e, h); function b(C) { C && C.target.closest("ul.dropdown-menu") && C.type === "wheel" || (t.value.filter((T) => T.children && T.children.length > 0).forEach((T) => { T.expanded = !1; }), p.value.expanded = !1, P()); } function u(C, T) { var L; const _ = { btn: !0, "f-rt-btn": !0, "f-btn-ml": o.alignment === "right" || T > 0 && o.alignment === "center", "f-btn-mr": o.alignment === "left", "btn-icontext": !!(C.icon && C.icon.trim()) }, H = ((L = C == null ? void 0 : C.appearance) == null ? void 0 : L.class) || C.class || "btn-secondary"; if (H) { const z = H.split(" "); z && z.length && z.reduce((Y, J) => (Y[J] = !0, Y), _); } return _; } function E(C, T) { document.body.click(), typeof T.onClick == "function" && T.onClick(C, T.id), e.emit("click", C, T.id); } function D(C, T) { if (C.tipsEnable && C.tipsText) { const _ = we({ content: C.tipsText, enable: C.tipsEnable }); return Ce(V("button", { type: "button", class: u(C, T), id: C.id, disabled: !C.enable, onClick: (H) => E(H, C) }, [h.shouldShowIcon(C) && V("i", { class: h.iconClass(C) }, null), C.text]), [[xe("tooltip"), _]]); } return V("button", { type: "button", class: u(C, T), id: C.id, disabled: !C.enable, onClick: (_) => E(_, C) }, [h.shouldShowIcon(C) && V("i", { class: h.iconClass(C) }, null), C.text]); } let M = /* @__PURE__ */ new Map(), O = []; function N(C) { const T = C.computedStyleMap().get("margin-left"), _ = C.computedStyleMap().get("margin-right"); return (T ? T.value : 0) + C.getBoundingClientRect().width + (_ ? _.value : 0); } function j(C, T, _) { if (T < f.value) { let H = _ - 1; for (; H >= 0; H--) { const L = C[H], z = N(L); if (T += z, T >= f.value) break; } _ = H; } return T -= f.value, { start: _, space: T }; } function U(C) { const T = i.value; let _ = C; const L = Array.from(T.children).filter((ee) => ee.id !== "__more_buttons__"), z = L.length; let Y = !1, J = 0; for (; J < z; J++) { const ee = L[J], re = N(ee); if (re <= _) _ -= re; else { const Z = j(L, _, J); J = Z.start, _ = Z.space, Y = !0; break; } } if (!Y && O.length > 0) { const ee = j(L, _, J); J = ee.start, _ = ee.space; } const W = O.length > 0; for (; J < z; J++) { const ee = L[J], re = N(ee); M.set(ee.id, !0), O[W ? "unshift" : "push"]({ id: ee.id, width: re }); } return _; } function x(C) { let T = U(C); if (O.length) { let z = 0; for (; z < O.length; z++) { const Y = o.items.find((J) => J.id === O[z].id); if (Y && Y.visible !== !1) { const J = O[z].width; if (T >= J || z === O.length - 1 && T + f.value >= J) T -= J; else break; } } for (let Y = 0; Y < z; Y++) M.delete(O[Y].id); O.splice(0, z - 1); } const _ = Object.assign({}, p.value); _.children = []; const H = new ye(_), L = t.value.reduce((z, Y) => { const J = o.items.find((W) => W.id === Y.id); return M.has(Y.id) ? (H.children.push(Y), Y.shown = !1) : Y.shown = J.visible !== !1, z.push(Y), z; }, []); p.value = H, t.value = L; } function a(C = -1) { if (C === 0 || !i.value || !r.value) return; C < 0 && (C = r.value.getBoundingClientRect().width); const T = i.value.getBoundingClientRect().width; (C >= 0 && C < T || O.length) && (x(C), b()); } function S() { return f.value < 0 && V("div", { style: "position:absolute;top:-30px;visibility:hidden;" }, [w(new ye(c))]); } const k = new ResizeObserver((C) => { if (C.length) { const _ = C[0].contentRect.width; a(_); } }); function y() { M = /* @__PURE__ */ new Map(), O = []; } function I() { r.value && !l && (k.observe(r.value), l = !0); } function B() { if (n.value && f.value < 0) { const C = n.value.querySelector("#" + c.id); C && (f.value = N(C)); } } return Ie(() => { B(), a(), I(), document.body.addEventListener("click", b), document.body.addEventListener("wheel", b); }), ct(() => { k.disconnect(), document.body.removeEventListener("click", b), document.body.removeEventListener("wheel", b); }), Te(() => o.items, () => { t.value = rt(o.items), p.value.children = [], he(() => { y(), a(); }); }, { deep: !0 }), Te(() => o.visible, (C) => { C && he(() => { B(), a(), I(); }); }), e.expose({ elementRef: n }), () => V("div", { class: d.value, id: o.id, ref: n, style: { "overflow-y": f.value < 0 ? "hidden" : "initial" } }, [o.visible && S(), o.visible && V("div", { ref: r, class: m.value }, [V("div", { ref: i, class: "d-inline-block f-response-content", style: "white-space: nowrap;" }, [t.value.filter((C) => C.shown).map((C, T) => C.children && C.children.length > 0 ? w(C) : D(C, T)), g.value && w(p.value)])])]); } }), Vn = X(0); function Nn() { Vn.value++; } const me = X(0); function _n(o, e) { const t = e.getBoundingClientRect(), n = o.getBoundingClientRect(), r = n.top >= t.top, i = n.top <= t.bottom; return r && i; } function yt(o) { const e = o.querySelector(".component-btn-group"); if (!e) return; e.style.display = ""; const t = e.getBoundingClientRect(); if (!(t.top === 0 && t.left === 0)) { const n = e.querySelector("div"); if (n) { const r = n.getBoundingClientRect(); n.style.top = t.top + "px"; let i = t.left - r.width; const s = document.querySelector(".editorDiv"); if (s) { const p = s.getBoundingClientRect(); i < p.left && ({ left: i } = o.getBoundingClientRect()); } n.style.left = i + "px"; } } } function jn(o) { if (!window.scrollContainerList) return; const e = Array.from(window.scrollContainerList); if (e.length && e.length === 1) { const t = e[0], n = document.querySelector(`[id=${t}]`); if (n && n.contains(o)) return n; } } function wt(o) { if (!o) return; const e = o.getBoundingClientRect(); if (e.width === 0 && e.height === 0) return; const t = o.querySelector(".component-btn-group"); if (t) { let n = !0; const r = jn(o); if (r && (n = _n(o, r)), !n) { t.style.display = "none"; return; } yt(o); } } function $n(o) { if (!o) return; let e; o.className.includes("dgComponentSelected") ? e = o : e = o.querySelector(".dgComponentSelected"), e && wt(e); } function Fn(o) { const { formSchemaUtils: e, formStateMachineUtils: t } = o; function n(c, f = "") { return { path: f + c.code, field: c.id, fullPath: c.code }; } function r(c, f = "") { return e.getViewModelById(c).states.map((l) => n(l, f)); } function i(c) { const f = e.getRootViewModelId(), h = r(c); if (c === f) return h; const l = r(f, "root-component."); return [...h, ...l]; } function s(c) { return c.binding && c.binding.path || c.id || ""; } function p() { return t && t.getRenderStates() || []; } return { getVariables: i, getControlName: s, getStateMachines: p }; } class Ln { constructor(e) { q(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'" } ]); q(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); q(this, "getExpressionConverter", (e, t) => ({ convertFrom: (n, r, i, s) => { const p = i.getExpressionRuleValue(e, t || r); return p && p.value || ""; }, convertTo: (n, r, i, s, p) => { var c; if (r === "dataPicking" && (i != null && i.target)) { const f = `${i.target}_dataPicking`; ((c = i.rules) == null ? void 0 : c.some( (l) => l.id === f && l.value )) ? n.dictPickingExpressionId = f : delete n.dictPickingExpressionId; } s.updateExpression(i); } })); this.formSchemaService = e; } getExpressionRule(e, t) { const n = this.formSchemaService.getExpressions(); if (!n) return ""; const r = n.find((s) => s.target === e); if (!r) return ""; const i = r.rules.find((s) => s.type === t); return i || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: e } = this.formSchemaService.getFormSchema(); if (!e.viewmodels || e.viewmodels.length === 0) return []; const t = this.formSchemaService.getRootViewModelId(), n = this.formSchemaService.getViewModelById(t); if (!n || !n.states || n.states.length === 0) return []; const r = []; return n.states.forEach((i) => { r.push({ key: i.code, name: i.name, description: i.name, category: i.category }); }), r; } createTreeNode(e, t, n = "label") { return { id: e.id, name: e.name, bindingPath: e[n], parents: t }; } buildEntityFieldsTreeData(e = null, t) { const n = []; return e == null || e.forEach((r) => { var p; const i = this.createTreeNode(r, t); let s = []; (p = r.type) != null && p.fields && (s = this.buildEntityFieldsTreeData(r.type.fields, [...t, r.label])), n.push({ data: i, children: s, expanded: !0 }); }), n; } buildChildEntityTreeData(e = null, t) { const n = []; return e == null || e.forEach((r) => { var c, f; const i = this.createTreeNode(r, t), s = this.buildEntityFieldsTreeData((c = r.type) == null ? void 0 : c.fields, [...t, r.label]), p = this.buildChildEntityTreeData((f = r.type) == null ? void 0 : f.entities, [...t, r.label]); p != null && p.length && (s == null || s.push(...p)), n.push({ data: i, children: s || [], // 空值回退 expanded: !0 }); }), n; } getEntitiesTreeData() { const e = this.formSchemaService.getSchemaEntities(); if (!(e != null && e.length)) return []; const t = e[0]; if (!(t != null && t.type)) return []; const n = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), r = this.buildChildEntityTreeData(t.type.entities, [t.code]); return r != null && r.length && (n == null || n.push(...r)), { entityCode: t.code, fields: [{ data: this.createTreeNode(t, [], "code"), children: n || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(e, t, n) { const r = n === "Field" ? e.binding.field : e.id, i = this.getExpressionRule(r, t), s = this.getEntitiesAndVariables(), p = { message: ["validate", "required", "dataPicking"].includes(t) && i ? i.message : "", ...s }; return i.messageType != null && (p.messageType = i.messageType), p; } buildRule(e, t, n, r) { const { expression: i, message: s, messageType: p } = t, c = { id: `${e}_${n}`, type: n, value: i }; return (n === "validate" || n === "dataPicking" || n === "required") && (c.message = s), n === "dataPicking" && (c.messageType = p), n === "validate" && r && (c.elementId = r), c; } getExpressionData() { const { expressions: e } = this.formSchemaService.getFormSchema().module; return e || []; } updateExpression(e, t, n, r) { const i = t === "Field" ? e.binding.field : e.id, s = this.buildRule(i, n, r, e.type === "form-group" ? e.id : ""); let c = this.getExpressionData().find((h) => h.targetType === t && h.target === i); const f = (h) => h.value.trim() === ""; if (c) { const h = c.rules.find((l) => l.id === s.id); if (h) f(s) ? c.rules = c.rules.filter((l) => l.id !== s.id) : (Object.assign(h, s), r === "validate" && e.type === "form-group" && (h.elementId = e.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: t }; } return c; } getExpressionEditorOptions(e, t, n, r) { return n.reduce((i, s) => { var c, f; const p = t === "Field" ? (c = e == null ? void 0 : e.binding) == null ? void 0 : c.field : e.id; return i[s] = { hide: t === "Field" ? !!((f = e == null ? void 0 : e.binding) != null && f.field) : !1, description: "", title: this.expressionNames[s], type: "string", $converter: this.getExpressionConverter(p), editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[s]}编辑器`, showMessage: s === "validate" || s === "dataPicking" || s === "required", showMessageType: s === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(e, s, t), onSubmitModal: (h) => { const l = this.updateExpression(e, t, h, s); if (r) { const g = this.buildRule(p, h, s); r(g); } return l; } } }, i; }, {}); } getExpressionInfo(e, t, n) { const r = t === "Field" ? e.binding.field : e.id, i = this.getExpressionRule(r, n), s = { value: i && i.value, targetId: r, targetType: t, expressionType: n }; return i && i.message && (s.message = i.message), s; } getExpressionConfig(e, t, n = ["compute", "dependency", "validate"], r) { return { description: "表达式", title: "表达式", properties: { ...this.getExpressionEditorOptions(e, t, n, r) } }; } getExpressionOptions(e, t, n) { const r = this.getExpressionInfo(e, t, n); return { dialogTitle: `${this.expressionNames[n]}编辑器`, singleExpand: !1, showMessage: n === "required", beforeOpen: () => this.onBeforeOpenExpression(e, n, t), expressionInfo: r }; } } class He { constructor(e, t) { q(this, "componentId"); q(this, "viewModelId"); q(this, "eventsEditorUtils"); q(this, "formSchemaUtils"); q(this, "formMetadataConverter"); q(this, "designViewModelUtils"); q(this, "designViewModelField"); q(this, "controlCreatorUtils"); q(this, "designerHostService"); q(this, "schemaService", null); q(this, "metadataService", null); q(this, "propertyConfig", { type: "object", categories: {} }); var n; this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((n = this.formSchemaUtils) == null ? void 0 : n.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = t.designViewModelUtils, this.controlCreatorUtils = t.controlCreatorUtils, this.metadataService = t.metadataService, this.schemaService = t.schemaService; } getTableInfo() { var e; return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(e) { var n; const t = e.binding && e.binding.type === "Form" && e.binding.field; if (t) { if (!this.designViewModelField) { const r = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = r.fields.find((i) => i.id === t); } e.updateOn = (n = this.designViewModelField) == null ? void 0 : n.updateOn; } } getBasicPropConfig(e) { return { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "combo-list", textField: "name", valueField: "value", idField: "value", editable: !1, data: [{ value: e.type, name: nn[e.type].name }] } } } }; } getAppearanceConfig(e = null, t = {}, n) { 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 t) i[s] = Object.assign(i[s] || {}, t[s]); return { ...r, properties: { ...i }, setPropertyRelates(s, p) { if (s) { switch (s && s.propertyID) { case "class": case "style": { me.value++; break; } } n && n(s, e, p); } } }; } getPropertyEditorParams(e, t = [], n = "visible", r = {}, i = {}) { const { getVariables: s, getControlName: p, getStateMachines: c } = Fn(this.designerHostService), f = this.getRealTargetType(e), h = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], l = { type: "property-editor", propertyTypes: h }; return h.map((g) => { switch (g) { case "Const": Object.assign(l, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, r); break; case "Expression": l.expressionConfig = this.getExpressionOptions(e, f, n); break; case "StateMachine": l.stateMachines = c(); break; case "Variable": Object.assign(l, { controlName: p(e), newVariablePrefix: "is", newVariableType: "Boolean", variables: s(this.viewModelId), onBeforeOpenVariables: (d) => { d.value = s(this.viewModelId); } }, i); break; } }), l; } getVisibleProperty(e, t = "") { return { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(e, t === "gridFieldEditor" ? ["Const", "Expression"] : ["Const", "Variable", "StateMachine", "Expression"], "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(e, t = "", n = {}, r) { const i = { title: "行为", description: "" }, s = this.getVisibleProperty(e, t); for (const c in n) s[c] = Object.assign(s[c] || {}, n[c]); const p = this; return { ...i, properties: { ...s }, setPropertyRelates(c, f) { if (c) { switch (c.propertyID) { case "disabled": case "readonly": case "visible": p.afterMutilEditorChanged(e, c); break; } r && r(c, f); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(e, t) { this.addNewVariableToViewModel(t, this.viewModelId), this.updateExpressionValue(t), this.clearExpression(t, e); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(e, t) { const n = t && t.parent && t.parent.schema; if (!n) return; const r = n.contents.findIndex((s) => s.id === e), i = ge(n.contents[r]); n.contents.splice(r, 1), n.contents.splice(r, 0, i), Nn(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(e, t) { const n = e.propertyValue; if (!(n && typeof n == "object") || !(n.type === "Variable" && n.isNewVariable)) return; const s = { id: n.field, category: "locale", code: n.fullPath, name: n.fullPath, type: n.newVariableType || "String" }; delete n.newVariableType, delete n.isNewVariable, this.formSchemaUtils.getVariableByCode(s.code) || this.formSchemaUtils.getViewModelById(t).states.push(s); } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(e) { const t = e.propertyValue; if (!((t && t.type) === "Expression" && t.expressionInfo)) return; const { expressionId: i, expressionInfo: s } = t, { targetId: p, targetType: c, expressionType: f, value: h, message: l } = s, g = this.formSchemaUtils.getModule(); g.expressions ?? (g.expressions = []); const { expressions: d } = g; let m = d.find((P) => P.target === p); m || (m = { target: p, rules: [], targetType: c }, d.push(m)); const w = m.rules.find((P) => P.type === f); if (w) w.value = h, w.message = l; else { const P = { id: i, type: f, value: h, message: l }; m.rules.push(P); } delete t.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(e, t) { const n = e.propertyValue; if (n && n.type === "Expression") return; const i = e.propertyID, s = this.formSchemaUtils.getExpressions(), p = t.binding ? t.binding.field : t.id, c = s.find((f) => f.target === p); !c || !c.rules || (c.rules = c.rules.filter((f) => f.type !== i)); } getExpressionOptions(e, t, n) { return new Ln(this.formSchemaUtils).getExpressionOptions(e, t, n); } getRealTargetType(e) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item"].indexOf(e.type) > -1 ? "Button" : e.binding && e.binding.field ? "Field" : "Container"; } } class qn extends He { constructor(e, t) { super(e, t); } getPropertyConfig(e) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(e), this.getAppearancePropConfig(e), this.propertyConfig.categories.behavior = this.getBehaviorConfig(e), this.propertyConfig; } getAppearancePropConfig(e) { this.propertyConfig.categories.appearance = { title: "外观", description: "Appearance", properties: { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter" } } }; } getBehaviorProperties(e) { this.propertyConfig.categories.behavior = { title: "行为", description: "", properties: { alignment: { title: "对齐方式", description: "在工具栏区域内按钮组的位置", type: "enum", editor: { type: "combo-list", textField: "name", valueField: "value", data: [ { value: "left", name: "左对齐" }, { value: "center", name: "居中" }, { value: "right", name: "右对齐" } ] }