UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,680 lines (1,679 loc) 83.5 kB
var Rt = Object.defineProperty; var Mt = (r, e, t) => e in r ? Rt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t; var _ = (r, e, t) => Mt(r, typeof e != "symbol" ? e + "" : e, t); import { computed as ae, getCurrentInstance as Bt, createVNode as $, ref as j, defineComponent as be, onMounted as Ce, onUnmounted as Ke, watch as ge, nextTick as Be, inject as le, provide as At, onBeforeUnmount as Ot, withModifiers as _t, createTextVNode as jt } from "vue"; import { isPlainObject as Qe, cloneDeep as Ae } from "lodash-es"; import { getCustomClass as ve, withInstall as Nt } from "../common/index.esm.js"; import { useDesignerInnerComponent as Lt, useDesignerComponent as $t } from "../designer-canvas/index.esm.js"; class et { constructor(e) { /** 工具栏项标识 */ _(this, "id", ""); /** 工具栏项自定义样式 */ _(this, "class", "btn-secondary"); /** 图标 */ _(this, "icon", ""); /** 所属分组 */ _(this, "groupId", ""); /** 收藏顺序 */ _(this, "order", -1); /** 是否作为下拉菜单的顶层按钮 */ _(this, "asDropDownTop", !1); /** 文本 */ _(this, "text", ""); /** 是否可见 */ _(this, "visible", !0); _(this, "responsed", !1); /** 是否启用提示消息 */ _(this, "tipsEnable", !1); /** 提示消息内容 */ _(this, "tipsText", ""); /** 记录宽度 */ _(this, "width", 0); _(this, "onClick", () => { }); _(this, "options"); var o, l; this.options = e; const t = [ "id", "class", "icon", "groupId", "order", "asDropDownTop", "text", "isDP", "visible", "responsed", "width", "tipsEnable", "tipsText", "onClick" ]; Object.keys(e).filter((s) => t.indexOf(s) > -1).forEach((s) => { this[s] = e[s]; }), (o = e.appearance) != null && o.class && (this.class = (l = e.appearance) == null ? void 0 : l.class); } /** 是否可用 */ get enable() { return Object.keys(this.options).indexOf("disabled") > -1 ? !this.options.disabled : ae(() => !0); } /** 设置宽度 */ setWidth(e) { this.width = parseInt(e, 10); } /** 获取宽度 */ getWidth() { return this.visible ? this.width : !1; } } class Ft extends et { constructor(e) { super(e); } } function tt() { function r(e) { const t = []; return e.reduce((o, l) => (l.children && l.children.length > 0 ? o.push(new pe(l)) : o.push(new Ft(l)), o), t), t; } return { buildResponseToolbarItems: r }; } const { buildResponseToolbarItems: Vt } = tt(); class pe extends et { constructor(t) { super(t); _(this, "placement", ""); // 下拉位置 /** 下拉class */ _(this, "dropdownClass", ""); /** 下拉菜单class */ _(this, "menuClass", ""); /** 是否用分开的下拉按钮 */ _(this, "split", !1); _(this, "children", []); _(this, "expanded", !1); const o = ["isDP", "class", "dropdownClass", "menuClass", "placement", "split", "expanded"]; Object.keys(t).filter((l) => o.indexOf(l) > -1).forEach((l) => { this[l] = t[l]; }), t.children && t.children.length && (this.children = Vt(t.children)); } } class Hn { constructor(e, t) { _(this, "id"); _(this, "name"); /** 记录元素的Id */ _(this, "presetId", []); /** 记录转变为下拉时元素的位置 */ _(this, "responsedIndex", []); /** 记录宽度 */ _(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 nt = {}, ot = {}; function Oe(r) { const { properties: e, title: t, ignore: o } = r, l = o && Array.isArray(o), s = Object.keys(e).reduce((d, g) => ((!l || !o.find((p) => p === g)) && (d[g] = e[g].type === "object" && e[g].properties ? Oe(e[g]) : Ae(e[g].default)), d), {}); if (t && (!l || !o.find((d) => d === "id"))) { const d = t.toLowerCase().replace(/-/g, "_"); s.id = `${d}_${Math.random().toString().slice(2, 6)}`; } return s; } function qt(r) { const { properties: e, title: t, required: o } = r; if (o && Array.isArray(o)) { const l = o.reduce((s, d) => (s[d] = e[d].type === "object" && e[d].properties ? Oe(e[d]) : Ae(e[d].default), s), {}); if (t && o.find((s) => s === "id")) { const s = t.toLowerCase().replace(/-/g, "_"); l.id = `${s}_${Math.random().toString().slice(2, 6)}`; } return l; } return { type: t }; } function we(r, e = {}, t) { const o = nt[r]; if (o) { let l = qt(o); const s = ot[r]; return l = s ? s({ getSchemaByType: we }, l, e, t) : l, l; } return null; } function Ut(r, e) { const t = Oe(e); return Object.keys(t).reduce((o, l) => (Object.prototype.hasOwnProperty.call(r, l) && (o[l] && Qe(o[l]) && Qe(r[l] || !r[l]) ? Object.assign(o[l], r[l] || {}) : o[l] = r[l]), o), t), t; } function rt(r, e) { return Object.keys(r).filter((o) => r[o] != null).reduce((o, l) => { if (e.has(l)) { const s = e.get(l); if (typeof s == "string") o[s] = r[l]; else { const d = s(l, r[l], r); Object.assign(o, d); } } else o[l] = r[l]; return o; }, {}); } function Ht(r, e, t = /* @__PURE__ */ new Map()) { const o = Ut(r, e); return rt(o, t); } function zt(r = {}) { function e(u, m, a, f) { if (typeof a == "number") return f[u].length === a; if (typeof a == "object") { const n = Object.keys(a)[0], i = a[n]; if (n === "not") return Number(f[u].length) !== Number(i); if (n === "moreThan") return Number(f[u].length) >= Number(i); if (n === "lessThan") return Number(f[u].length) <= Number(i); } return !1; } function t(u, m, a, f) { return f[u] && f[u].propertyValue && String(f[u].propertyValue.value) === String(a); } const o = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(r).reduce((u, m) => (u.set(m, r[m]), u), o); function l(u, m) { const a = u; return typeof m == "number" ? [{ target: a, operator: "length", param: null, value: Number(m) }] : typeof m == "boolean" ? [{ target: a, operator: "getProperty", param: u, value: !!m }] : typeof m == "object" ? Object.keys(m).map((f) => { if (f === "length") return { target: a, operator: "length", param: null, value: m[f] }; const n = f, i = m[f]; return { target: a, operator: "getProperty", param: n, value: i }; }) : []; } function s(u) { return Object.keys(u).reduce((a, f) => { const n = l(f, u[f]); return a.push(...n), a; }, []); } function d(u, m) { if (o.has(u.operator)) { const a = o.get(u.operator); return a && a(u.target, u.param, u.value, m) || !1; } return !1; } function g(u, m) { return s(u).reduce((n, i) => n && d(i, m), !0); } function p(u, m) { const a = Object.keys(u), f = a.includes("allOf"), n = a.includes("anyOf"), i = f || n, B = (i ? u[i ? f ? "allOf" : "anyOf" : "allOf"] : [u]).map((q) => g(q, m)); return f ? !B.includes(!1) : B.includes(!0); } return { parseValueSchema: p }; } const Wt = { 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: "标签页工具栏按钮" }, "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: "抽屉" } }, Xt = {}, Yt = {}; zt(); function it(r, e, t = /* @__PURE__ */ new Map(), o = (d, g, p, u) => g, l = {}, s = (d) => d) { return nt[e.title] = e, ot[e.title] = o, Xt[e.title] = l, Yt[e.title] = s, (d = {}, g = !0) => { if (!g) return rt(d, t); const p = Ht(d, e, t), u = Object.keys(r).reduce((m, a) => (m[a] = r[a].default, m), {}); return Object.assign(u, p); }; } function Gt(r, e) { return { customClass: e.class, customStyle: e.style }; } function Qt() { function r(e, t) { const o = e.buttons; if (!o || o.length < 1) return null; const [l, s] = t.payloads, d = o.find((g) => g.id === s); return d ? d.onClick || d.click : null; } return { resolve: r }; } const Jt = /* @__PURE__ */ new Map([ ["buttons", "items"], ["appearance", Gt] ]); function st(r, e, t) { return e; } const Zt = "https://json-schema.org/draft/2020-12/schema", Kt = "https://farris-design.gitee.io/response-toolbar.schema.json", en = "response-toolbar", tn = "A Farris Toolbar Component", nn = "object", on = { 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: "" } }, rn = [ "id", "type", "buttons" ], sn = { $schema: Zt, $id: Kt, title: en, description: tn, type: nn, properties: on, required: rn }, an = "https://json-schema.org/draft/2020-12/schema", ln = "https://farris-design.gitee.io/response-toolbar-item.schema.json", cn = "response-toolbar-item", un = "A Farris Toolbar Item Component", dn = "object", fn = { 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: "btn-secondary" } } }, alignment: { description: "对齐", type: "string", default: "right" }, text: { description: "文本", type: "string", default: "按钮" }, icon: { description: "图标", type: "string", default: "" }, disabled: { description: "禁用", type: "boolean", default: !1 }, onClick: { description: "点击事件", type: "string", default: "" } }, pn = [ "id", "type", "text" ], mn = { $schema: an, $id: ln, title: cn, description: un, type: dn, properties: fn, required: pn }, _e = { /** 组件自定义样式 */ customClass: { type: String, default: "" }, /** 按钮尺寸 sm 小号 lg 大号 空值 默认 */ buttonSize: { type: String, default: "" }, alignment: { Type: String, default: "right" }, items: { Type: Array, default: [] } }, gn = Object.assign({}, _e, { componentId: { type: String, default: "" } }), je = it( _e, sn, Jt, st ), at = { id: { type: String, default: "" }, items: { type: Object, default: {} }, class: { type: String, default: "" }, text: { type: String, default: "" }, // disabled: {type: Boolean, default: false}, icon: { type: String, default: "" }, componentId: { type: String, default: "" }, alignment: { Type: String, default: "right" } }, vn = it( at, mn, void 0, st ), hn = Qt(); function yn() { function r(t) { const o = { "f-icon": !0 }; if (t.icon) { const l = t.icon.trim().split(" "); l && l.length && l.reduce((s, d) => (s[d] = !0, s), o); } return o; } function e(t) { return !!(t.icon && t.icon.trim()); } return { iconClass: r, shouldShowIcon: e }; } function bn(r, e) { function t(n) { const i = { "dropdown-menu": !0 }; if (n.class) { const y = n.menuClass.split(" "); y && y.length && y.reduce((R, B) => (R[B] = !0, R), i); } return i; } function o(n) { const i = { disabled: !n.enable, "dropdown-submenu": !0, "f-rt-dropdown": !0, "text-truncate": !0 }, y = n.dropdownClass.split(" "); return y && y.length && y.reduce((R, B) => (R[B] = !0, R), i), i; } function l(n) { const i = { disabled: !n.enable, "dropdown-item": !0, "f-rt-btn": !0, "text-truncate": !0 }, y = n.class.split(" "); return y && y.length && y.reduce((R, B) => (R[B] = !0, R), i), i; } let s; const d = /* @__PURE__ */ new Map(); function g(n, i, y) { var B; ((B = n.target) == null ? void 0 : B.id) === i.id && n.stopPropagation(); const R = y ? y.id : "__top_item__"; if (i.children && i.children.length && (i.expanded = !i.expanded, i.expanded ? d.set(R, i) : d.delete(R)), d.has(R) && d.get(R) !== i) { const W = d.get(R); W && (W.expanded = !1); } } function p(n, i) { document.body.click(), i.enable && (typeof i.onClick == "function" && i.onClick(n, i.id), r.emit("click", n, i.id)); } function u(n, i) { const y = n.target; y.className.indexOf("dropdown-item") < 0 || (y.title = y.scrollWidth > y.clientWidth ? i : ""); } function m(n) { return n.children.map((i) => i.children && i.children.length ? $("li", { class: o(i), id: i.id, onClick: (y) => i.enable && g(y, i, n) }, [$("span", { id: i.id, class: l(i), onMouseover: (y) => i.enable && g(y, i, n) }, [i.text, $("i", { class: "f-icon f-icon-arrow-chevron-right", style: "display: inline-block;float: right;line-height: 1.25rem;" }, null)]), s(i, i)]) : $("li", { class: l(i), id: i.id, onClick: (y) => p(y, i), onMouseover: (y) => i.enable && g(y, i, n), onMouseenter: (y) => u(y, i.text) }, [e.shouldShowIcon(i) && $("i", { class: e.iconClass(i) }, null), i.text])); } function a(n, i, y) { var N; const R = { display: n.expanded ? "block" : "none", position: "fixed", maxWidth: "300px", width: "180px", minWidth: "120px", zIndex: 1e4 }, B = (N = document.getElementsByTagName("body")[0].getClientRects()[0]) == null ? void 0 : N.width, W = i, q = W == null ? void 0 : W.getClientRects(); if (W && q && q.length) { const { top: x, width: I, left: b, right: P, height: A } = q[0], V = Math.ceil(A + x); R.top = `${V}px`, R.left = `${b}px`; const h = n.id + "_menu", L = i ? i.querySelector("#" + h) : null; if (L) { L.style.visibility = "hidden", L.style.display = "block"; const E = L.offsetHeight; R.display === "block" && (L.style.display = "block"); const w = L.getBoundingClientRect(); if (y) { R.top = `${x - 6}px`; const v = Math.ceil(I + b); R.left = `${v}px`; } B - b - I < w.width && (R.left = `${(y ? b : P) - w.width}px`), window.innerHeight - x - A < E && (x > E ? R.top = `${x - E - 6}px` : (R.maxHeight = `${x - 16}px`, R.overflowY = "auto", x - A > window.innerHeight - x && (R.top = "10px"))), L.style.visibility = "visible"; } } return R; } s = function(n, i) { var W, q; const y = Bt(), R = i ? i.id : n.id, B = (q = (W = y == null ? void 0 : y.exposed) == null ? void 0 : W.elementRef.value) == null ? void 0 : q.querySelector("#" + R); return $("ul", { class: t(n), style: a(n, B, i), id: n.id + "_menu" }, [m(n)]); }; function f() { d.forEach((n) => { n.expanded = !1; }), d.clear(); } return { renderDropdownMenu: s, clearAllDropDownMenu: f }; } function Cn(r, e, t) { const o = j(r.alignment), { renderDropdownMenu: l, clearAllDropDownMenu: s } = bn(e, t); function d(a) { const f = { "btn-group": !0, "f-rt-dropdown": !0, "f-btn-ml": o.value === "right" || o.value === "center", "f-btn-mr": o.value === "left" }, n = a.dropdownClass.split(" "); return n && n.length && n.reduce((i, y) => (i[y] = !0, i), f), f; } function g(a) { const f = { btn: !0, disabled: !a.enable, "f-rt-btn": !0, "btn-icontext": !!(a.icon && a.icon.trim()) }; if (a.class) { const n = a.class.split(" "); n && n.length && n.reduce((i, y) => (i[y] = !0, i), f); } return f; } function p(a, f) { a.stopPropagation(); const n = f.expanded; document.body.click(), f.expanded = !n; } function u(a, f = !0) { return $("div", { id: a.id, class: d(a) }, [$("div", { class: g(a), style: "display: flex;padding-right: 0.1rem;border-top-right-radius: 6px;border-bottom-right-radius: 6px", onClick: (n) => a.enable && p(n, a) }, [t.shouldShowIcon(a) && $("i", { class: t.iconClass(a) }, null), $("span", null, [a.text]), $("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)]), f && l(a)]); } function m() { s(); } return { renderToolbarDropdown: u, clearAllDropDown: m }; } const { buildResponseToolbarItems: Je } = tt(), he = /* @__PURE__ */ be({ name: "FResponseToolbar", props: _e, emits: ["click"], setup(r, e) { const t = j(Je(r.items)), o = j(), l = j(), s = j(), d = j(r.alignment), g = { id: "__more_buttons__", text: "更多" }, p = j(new pe(g)), u = { id: g.id + "width", text: g.text }, m = j(-1), a = yn(), f = ae(() => p.value.children.length > 0), n = ae(() => { const v = { "f-toolbar": !0, "f-response-toolbar": !0, "position-relative": !0, "f-response-toolbar-sm": r.buttonSize === "sm", "f-response-toolbar-lg": r.buttonSize === "lg" }; return ve(v, r.customClass); }), i = ae(() => ({ "w-100": !0, "d-flex": !0, "flex-nowrap": !0, "justify-content-end": d.value === "right", "justify-content-start": d.value === "left", "justify-content-center": d.value === "center" })), { renderToolbarDropdown: y, clearAllDropDown: R } = Cn(r, e, a); function B(v) { v && v.target.closest("ul.dropdown-menu") && v.type === "wheel" || (t.value.filter((T) => T.children && T.children.length > 0).forEach((T) => { T.expanded = !1; }), p.value.expanded = !1, R()); } function W(v, T) { var J; const F = { btn: !0, "f-rt-btn": !0, "f-btn-ml": d.value === "right" || T > 0 && d.value === "center", "f-btn-mr": d.value === "left", "btn-icontext": !!(v.icon && v.icon.trim()) }, Y = ((J = v == null ? void 0 : v.appearance) == null ? void 0 : J.class) || v.class; if (Y) { const H = Y.split(" "); H && H.length && H.reduce((M, X) => (M[X] = !0, M), F); } return F; } function q(v, T) { document.body.click(), typeof T.onClick == "function" && T.onClick(v, T.id), e.emit("click", v, T.id); } function N(v, T) { return $("button", { type: "button", class: W(v, T), id: v.id, disabled: !v.enable, onClick: (F) => q(F, v) }, [a.shouldShowIcon(v) && $("i", { class: a.iconClass(v) }, null), v.text]); } let x = /* @__PURE__ */ new Map(), I = []; function b(v) { const T = v.computedStyleMap().get("margin-left"), F = v.computedStyleMap().get("margin-right"); return (T ? T.value : 0) + v.getBoundingClientRect().width + (F ? F.value : 0); } function P(v, T, F) { if (T < m.value) { let Y = F - 1; for (; Y >= 0; Y--) { const J = v[Y], H = b(J); if (T += H, T >= m.value) break; } F = Y; } return T -= m.value, { start: F, space: T }; } function A(v) { const T = s.value; let F = v; const J = Array.from(T.children).filter((Z) => Z.id !== "__more_buttons__"), H = J.length; let M = !1, X = 0; for (; X < H; X++) { const Z = J[X], O = b(Z); if (O <= F) F -= O; else { const ie = P(J, F, X); X = ie.start, F = ie.space, M = !0; break; } } if (!M && I.length > 0) { const Z = P(J, F, X); X = Z.start, F = Z.space; } const ne = I.length > 0; for (; X < H; X++) { const Z = J[X], O = b(Z); x.set(Z.id, !0), I[ne ? "unshift" : "push"]({ id: Z.id, width: O }); } return F; } function V(v) { let T = A(v); if (I.length) { let H = 0; for (; H < I.length; H++) { const M = r.items.find((X) => X.id === I[H].id); if (M && M.visible !== !1) { const X = I[H].width; if (T >= X || H === I.length - 1 && T + m.value >= X) T -= X; else break; } } for (let M = 0; M < H; M++) x.delete(I[M].id); I.splice(0, H - 1); } const F = Object.assign({}, p.value); F.children = []; const Y = new pe(F), J = t.value.reduce((H, M) => { const X = r.items.find((ne) => ne.id === M.id); return x.has(M.id) ? (Y.children.push(M), M.visible = !1) : M.visible = X.visible !== !1, H.push(M), H; }, []); p.value = Y, t.value = J; } function h(v = -1) { var Y; if (v === 0) return; v < 0 && (v = ((Y = l.value) == null ? void 0 : Y.getBoundingClientRect().width) || -1); const F = s.value.getBoundingClientRect().width; (v >= 0 && v < F || I.length) && (V(v), B()); } function L() { return m.value < 0 && $("div", { style: "position:absolute;top:-30px;visibility:hidden;" }, [y(new pe(u))]); } const E = new ResizeObserver((v) => { if (v.length) { const F = v[0].contentRect.width; h(F); } }); function w() { x = /* @__PURE__ */ new Map(), I = []; } return Ce(() => { if (m.value < 0) { const T = o.value.querySelector("#" + u.id); T && (m.value = b(T)); } h(); const v = l.value; E.observe(v), document.body.addEventListener("click", B), document.body.addEventListener("wheel", B); }), Ke(() => { E.disconnect(), document.body.removeEventListener("click", B), document.body.removeEventListener("wheel", B); }), ge(() => r.items, () => { t.value = Je(r.items), Be(() => { w(), h(); }); }, { deep: !0 }), e.expose({ elementRef: o }), () => $("div", { class: n.value, ref: o, style: { "overflow-y": m.value < 0 ? "hidden" : "initial" } }, [L(), $("div", { ref: l, class: i.value }, [$("div", { ref: s, class: "d-inline-block f-response-content", style: "white-space: nowrap;" }, [t.value.filter((v) => v.visible).map((v, T) => v.children && v.children.length > 0 ? y(v) : N(v, T)), f.value && y(p.value)])])]); } }), wn = j(0); function Tn() { wn.value++; } const ye = j(0); function xn(r, e) { const t = e.getBoundingClientRect(), o = r.getBoundingClientRect(), l = o.top >= t.top, s = o.top <= t.bottom; return l && s; } function In(r) { const e = r.querySelector(".component-btn-group"); if (!e) return; e.style.display = ""; const t = e.getBoundingClientRect(); if (!(t.top === 0 && t.left === 0)) { const o = e.querySelector("div"); if (o) { const l = o.getBoundingClientRect(); o.style.top = t.top + "px"; let s = t.left - l.width; const d = document.querySelector(".editorDiv"); if (d) { const g = d.getBoundingClientRect(); s < g.left && ({ left: s } = r.getBoundingClientRect()); } o.style.left = s + "px"; } } } function Sn(r) { if (!window.scrollContainerList) return; const e = Array.from(window.scrollContainerList); if (e.length && e.length === 1) { const t = e[0], o = document.querySelector(`[id=${t}]`); if (o && o.contains(r)) return o; } } function lt(r) { if (!r) return; const e = r.getBoundingClientRect(); if (e.width === 0 && e.height === 0) return; const t = r.querySelector(".component-btn-group"); if (t) { let o = !0; const l = Sn(r); if (l && (o = xn(r, l)), !o) { t.style.display = "none"; return; } In(r); } } function En(r) { if (!r) return; let e; r.className.includes("dgComponentSelected") ? e = r : e = r.querySelector(".dgComponentSelected"), e && lt(e); } class Ne { constructor(e, t) { _(this, "componentId"); _(this, "viewModelId"); _(this, "eventsEditorUtils"); _(this, "formSchemaUtils"); _(this, "formMetadataConverter"); _(this, "designViewModelUtils"); _(this, "designViewModelField"); _(this, "controlCreatorUtils"); _(this, "designerHostService"); _(this, "schemaService", null); _(this, "metadataService", null); _(this, "propertyConfig", { type: "object", categories: {} }); var o; this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.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 o; const t = e.binding && e.binding.type === "Form" && e.binding.field; if (t) { if (!this.designViewModelField) { const l = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = l.fields.find((s) => s.id === t); } e.updateOn = (o = this.designViewModelField) == null ? void 0 : o.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", editable: !1, data: [{ value: e.type, name: Wt[e.type].name }] } } } }; } getAppearanceConfig(e = null) { return { title: "外观", description: "Appearance", properties: { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter" } }, setPropertyRelates(t, o) { if (t) switch (t && t.propertyID) { case "class": case "style": { ye.value++; break; } } } }; } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(e, t) { const o = t && t.parent && t.parent.schema; if (!o) return; const l = o.contents.findIndex((d) => d.id === e), s = Ae(o.contents[l]); o.contents.splice(l, 1), o.contents.splice(l, 0, s), Tn(); } } class Pn extends Ne { constructor(e, t) { super(e, t); } getPropertyConfig(e) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(e), this.getAppearancePropConfig(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: "右对齐" } ] } } } }; } } function Dn(r, e) { const t = r.schema; function o(f) { return !1; } function l(f, n) { return n.text = f.label, n; } function s() { return !1; } function d() { return !1; } function g() { return !0; } function p() { return !0; } function u(f) { return new Pn(f, e).getPropertyConfig(t); } function m(f) { f && (f.stopPropagation(), f.preventDefault()); const { schema: n } = r; n.buttons || (n.buttons = []); const i = we("response-toolbar-item"); i.id = `toolbar_item_${Math.random().toString().slice(2, 6)}`, i.appearance = { class: "btn btn-secondary" }, n.buttons.push(i); } function a() { return [ { id: "appendItem", title: "新增按钮", icon: "f-icon f-icon-plus-circle text-white", onClick: (f) => m(f) } ]; } return { canAccepts: o, checkCanAddComponent: g, checkCanDeleteComponent: d, checkCanMoveComponent: s, hideNestedPaddingInDesginerView: p, onResolveNewComponentSchema: l, getPropsConfig: u, getCustomButtons: a }; } const kn = { id: { type: String, default: "" }, componentId: { type: String, default: "" }, canAdd: { type: Boolean, default: !1 }, canDelete: { type: Boolean, default: !1 }, canMove: { type: Boolean, default: !1 }, contentKey: { type: String, default: "contents" }, childLabel: { type: String, default: "" }, childType: { type: String, default: "" }, /** * 组件值 */ modelValue: { type: Object } }; function Rn(r, e, t) { var x; const o = "", l = j(); function s() { return !0; } function d() { return !1; } function g() { return !0; } function p() { return !0; } function u() { return !0; } function m(I) { if (!I || !I.value) return null; const b = j(I == null ? void 0 : I.value.parent), P = m(b); return P || null; } function a(I = e) { const { componentInstance: b, designerItemElementRef: P } = I; return !b || !b.value ? null : b.value.canMove || b.value.canAdd || b.value.canDelete ? P : a(I.parent); } function f(I) { return !!t; } function n() { return (e == null ? void 0 : e.schema.label) || (e == null ? void 0 : e.schema.title) || (e == null ? void 0 : e.schema.name); } function i() { } function y(I, b) { } function R(I) { const { componentType: b } = I, P = le("designer-host-service"); let A = we(b, I, P); const V = b.toLowerCase().replace(/-/g, "_"); return A && !A.id && A.type === b && (A.id = `${V}_${Math.random().toString().slice(2, 6)}`), A; } function B(I) { } function W(...I) { return []; } function q() { } function N(I) { } return l.value = { canMove: s(), canSelectParent: d(), canAdd: p(), canDelete: g(), canNested: !u(), contents: [], elementRef: r, parent: (x = e.parent) == null ? void 0 : x.componentInstance, schema: e.schema, styles: o, canAccepts: f, getBelongedComponentInstance: m, getDraggableDesignItemElement: a, getDraggingDisplayText: n, getPropConfig: W, getDragScopeElement: i, onAcceptMovedChildElement: y, onChildElementMovedOut: B, addNewChildComponentSchema: R, onRemoveComponent: q, triggerBelongedComponentToMoveWhenMoved: j(!1), triggerBelongedComponentToDeleteWhenDeleted: j(!1), onPropertyChanged: N }, l; } const Mn = /* @__PURE__ */ be({ name: "FDesignerInnerItem", props: kn, emits: ["selectionChange", "addComponent", "removeComponent"], setup(r, e) { const t = j(r.canMove), o = j(r.canAdd), l = j(r.canDelete), s = j(!1), d = j(r.contentKey), g = j(r.childType), p = j(r.childLabel), u = j(r.modelValue), m = j(""), a = j(), f = le("canvas-dragula"), n = j(), i = le("design-item-context"), y = { designerItemElementRef: a, componentInstance: n, schema: u.value, parent: i, setupContext: e }; At("design-item-context", y); const R = ae(() => ({ "farris-component": !0, // 受position-relative影响,整个容器的高度不能被撑起 "flex-fill": r.id === "root-component", "position-relative": t.value || l.value, "farris-nested": s.value, "can-move": t.value, "d-none": a.value && a.value.classList.contains("d-none") })), B = ae(() => { const E = {}; return m.value && m.value.split(";").reduce((w, v) => { const [T, F] = v.split(":"); return T && (w[T] = F), w; }, E), E; }); function W(E, w) { if (i && i.schema[d.value]) { const v = i.schema[d.value].findIndex((T) => T.id === w.id); if (v > -1) { const T = i.schema[d.value].length, F = i.schema[d.value][v % T]; i.designerItemElementRef.value.querySelector(`#${F.id}-design-item`), i.schema[d.value].splice(v, 1), ye.value++, e.emit("removeComponent"), e.emit("selectionChange"); } } } function q(E) { if (n.value.addNewChildComponentSchema) { const w = { componentType: g.value, label: p.value, parentComponentInstance: n.value, targetPosition: -1 }, v = n.value.addNewChildComponentSchema(w); u.value[d.value].push(v), e.emit("addComponent"); } } function N() { return o.value && $("div", { role: "button", class: "btn component-settings-button", title: "新增", ref: "removeComponent", onClick: (E) => { q(); } }, [$("i", { class: "f-icon f-icon-plus-circle" }, null)]); } function x(E) { return l.value && $("div", { role: "button", class: "btn component-settings-button", title: "删除", ref: "removeComponent", onClick: _t((w) => W(w, E), ["stop"]) }, [$("i", { class: "f-icon f-icon-yxs_delete" }, null)]); } function I() { return t.value && $("div", { role: "button", class: "btn component-settings-button", title: "移动", ref: "moveComponent" }, [$("i", { "data-dragging-icon": "true", class: "cmp_move f-icon f-icon-yxs_move" }, null)]); } function b(E) { return $("div", { class: "component-btn-group", "data-noattach": "true" }, [$("div", null, [N(), I(), x(E)])]); } ge(() => r.modelValue, (E) => { u.value = E, y.schema = E; }); function P(E) { window.scrollContainerList || (window.scrollContainerList = /* @__PURE__ */ new Set()); const w = E.getAttribute("id"); w && window.scrollContainerList.add(w); } function A(E) { const w = E.target; P(w), En(w); } function V() { var E, w; (w = (E = u.value) == null ? void 0 : E.contents) != null && w.length && a.value && a.value.addEventListener("scroll", A); } function h() { const E = a.value, w = j(E.children[1]); return Rn(w, y).value; } Ce(() => { if (a.value) { const E = a.value.querySelector(`[data-dragref='${u.value.id}-container']`); n.value = E && E.componentInstance ? E.componentInstance.value : h(), f && E && f.attachComponents(E, u.value), s.value = n.value.canNested !== void 0 ? n.value.canNested : s.value, o.value = n.value.canAdd !== void 0 ? n.value.canAdd : o.value, l.value = n.value.canDelete !== void 0 ? n.value.canDelete : l.value, t.value = n.value.canMove !== void 0 ? n.value.canMove : t.value, m.value = n.value.styles || "", a.value && (a.value.componentInstance = n, a.value.designItemContext = y); } V(), ye.value++; }), Ot(() => { a.value && a.value.removeEventListener("scroll", A); }); function L(E) { E && (E.preventDefault(), E.stopPropagation()); let w = y.designerItemElementRef; const v = a.value; if (v) { const T = document.getElementsByClassName("dgComponentFocused"); T && T.length === 1 && T[0] === a.value || (Array.from(T).forEach((Y) => Y.classList.remove("dgComponentFocused")), Array.from(document.getElementsByClassName("dgComponentSelected")).forEach((Y) => Y.classList.remove("dgComponentSelected")), v.classList.add("dgComponentFocused"), e.emit("selectionChange", u.value.type, u.value, r.componentId, n.value), n.value.getDraggableDesignItemElement && (w = n.value.getDraggableDesignItemElement(y), w && w.value && w.value.classList.add("dgComponentSelected"))); } lt(w == null ? void 0 : w.value); } return () => $("div", { id: `${r.id}-design-item`, ref: a, class: R.value, style: B.value, onClick: L }, [b(u.value), e.slots.default && e.slots.default()]); } }); class Bn extends Ne { constructor(e, t) { super(e, t); } getPropertyConfig(e) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(e), this.propertyConfig.categories.basic.properties.text = { title: "文本", type: "string", description: "", refreshPanelAfterChanged: !0 }, this.getAppearanceProperties(e), this.getbBehaviorConfig(), this.getEventPropConfig(e), this.propertyConfig; } getAppearanceProperties(e) { this.propertyConfig.categories.appearance = { title: "外观", properties: { class: { description: "组件的CSS样式", title: "class样式" }, icon: { title: "图标", type: "string", description: "" } } }; } getbBehaviorConfig() { this.propertyConfig.categories.behavior = { title: "行为", description: "Behavior", properties: { disabled: { title: "禁用", type: "boolean", description: "按钮禁用状态", refreshPanelAfterChanged: !0, editor: { enableClear: !0, editable: !0 } } } }; } getEventPropConfig(e) { const t = [ { label: "onClick", name: "点击事件" } ], o = this, l = o.eventsEditorUtils.formProperties(e, o.viewModelId, t), s = {}; s[o.viewModelId] = { type: "events-editor", editor: { initialData: l } }, this.propertyConfig.categories.eventsEditor = { title: "事件", hideTitle: !0, properties: s, // 这个属性,标记当属性变更得时候触发重新更新属性 refreshPanelAfterChanged: !0, tabId: "commands", tabName: "交互", setPropertyRelates(d, g) { const p = d.propertyValue; delete e[o.viewModelId], p && (p.setPropertyRelates = this.setPropertyRelates, o.eventsEditorUtils.saveRelatedParameters(e, o.viewModelId, p.events, p)); } }; } } class An extends Ne { constructor(e, t) { super(e, t); } getPropertyConfig(e) { return this.propertyConfig.categories.basic = this.getBasicPropConfig(e), this.propertyConfig.categories.basic.properties.text = { title: "文本", type: "string", description: "", refreshPanelAfterChanged: !0 }, this.getAppearanceProperties(e), this.getBehaviorConfig(), this.getEventPropConfig(e), this.propertyConfig; } getBehaviorConfig() { this.propertyConfig.categories.behavior = { title: "行为", description: "Behavior", properties: { disabled: { title: "禁用", type: "boolean", description: "按钮禁用状态", refreshPanelAfterChanged: !0, editor: { enableClear: !0, editable: !0 } } } }; } getAppearanceProperties(e) { this.propertyConfig.categories.appearance = { title: "外观", description: "Appearance", properties: { class: { title: "class样式", type: "string", description: "", $converter: "/converter/appearance.converter" }, icon: { title: "图标", type: "string", description: "" } }, setPropertyRelates(t) { if (t) switch (t && t.propertyID) { case "text": { t.needRefreshControlTree = !0; break; } } } }; } getEventPropConfig(e) { const t = [ { label: "onClick", name: "点击事件" } ], o = this, l = o.eventsEditorUtils.formProperties(e, o.viewModelId, t), s = {}; s[o.viewModelId] = { type: "events-editor", editor: { initialData: l } }, this.propertyConfig.categories.eventsEditor = { title: "事件", hideTitle: !0, properties: s, // 这个属性,标记当属性变更得时候触发重新更新属性 refreshPanelAfterChanged: !0, tabId: "commands", tabName: "交互", setPropertyRelates(d, g) { const p = d.propertyValue; delete e[o.viewModelId], p && (p.setPropertyRelates = this.setPropertyRelates, o.eventsEditorUtils.saveRelatedParameters(e, o.viewModelId, p.events, p)); } }; } } function On(r, e) { function t(u) { return !1; } function o() { return !1; } function l() { return !0; } function s() { return !1; } function d(u) { let m; switch (r.schema.type) { case "tab-toolbar-item": m = new Bn(u, e); break; default: m = new An(u, e); } return m.getPropertyConfig(r.schema); } function g() { r.designerItemElementRef.value && Be(() => { r.designerItemElementRef.value.click(); }); } function p(u) { if (!u) return; const { changeObject: m } = u; m && ["text", "icon", "class"].includes(m.propertyID) && g(); } return { canAccepts: t, checkCanMoveComponent: o, checkCanDeleteComponent: l, checkCanAddComponent: s, getPropsConfig: d, onPropertyChanged: p }; } const ct = /* @__PURE__ */ be({ name: "FResponseToolbarItemDesign", props: at, emits: ["Click"], setup(r, e) { j(), j(); const t = j(r.alignment), o = { id: "__more_buttons__", text: "More" }, l = j(new pe(o)); ae(() => l.value.children.length > 0); const s = j(), d = le("designer-host-service"), g = le("design-item-context"), p = On(g, d), u = Lt(s, g, p); le("toolbar-item-handler", () => { }), Ce(() => { s.value.componentInstance = u; }), e.expose(u.value); function m() { const n = { "f-icon": !0 }, i = r.icon ? r.icon.trim() : ""; return ve(n, i); } function a() { return !!(r.icon && r.icon.trim()); } function f() { const n = { btn: !0, "f-rt-btn": !0, "f-btn-ml": t.value === "right" || t.value === "center", "f-btn-mr": t.value === "left", "btn-icontext": !!(r.icon && r.icon.trim()), disabled: r.disabled === !0, "no-drag": !0 }; return ve(n, r.class); } return () => $("div", { ref: s, "data-dragref": `${g.schema.id}-container`, class: "farris-component position-relative", style: "display:inline-block!important;" }, [$("button", { type: "button", class: f(), id: r.id }, [a() && $("i", { class: m() }, null), r.text])]); } }); var de = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function _n(r) { return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; } function me(r) { throw new Error('Could not dynamically require "' + r + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var ut = { exports: {} }; (function(r, e) { (function(t) { r.exports = t(); })(function() { return (/* @__PURE__ */ function() { function t(o, l, s) { function d(u, m) { if (!l[u]) { if (!o[u]) { var a = typeof me == "function" && me; if (!m && a) return a(u, !0); if (g) return g(u, !0); var f = new Error("Cannot find module '" + u + "'"); throw f.code = "MODULE_NOT_FOUND", f; } var n = l[u] = { exports: {} }; o[u][0].call(n.exports, function(i) { var y = o[u][1][i]; return d(y || i); }, n, n.exports, t, o, l, s); } return l[u].exports; } for (var g = typeof me == "function" && me, p = 0; p < s.length; p++) d(s[p]); return d; } return t; }())({ 1: [function(t, o, l) { var s = {}, d = "(?:^|\\s)", g = "(?:\\s|$)"; function p(a) { var f = s[a]; return f ? f.lastIndex = 0 : s[a] = f = new RegExp(d + a + g, "g"), f; } function u(a, f) { var n = a.className; n.length ? p(f).test(n) || (a.className += " " + f) : a.className = f; } function m(a, f) { a.className = a.className.replace(p(f), " ").trim(); } o.exports = { add: u, rm: m }; }, {}], 2: [function(t, o, l) { (function(s) { var d = t("contra/emitter"), g = t("crossvent"), p = t("./classes"), u = document, m = u.documentElement; function a(h, L) { var E = arguments.length; E === 1 && Array.isArray(h) === !1 && (L = h, h = []); var w, v, T, F, Y, J, H, M, X, ne = null, Z, O, ie = !1, fe = 0, Q, D = L || {}; D.moves === void 0 && (D.moves = W), D.accepts === void 0 && (D.accepts = W), D.invalid === void 0 && (D.invalid = vt), D.containers === void 0 && (D.containers = h || []), D.isContainer === void 0 && (D.isContainer = B), D.copy === void 0 && (D.copy = !1), D.copySortSource === void 0 && (D.copySortSource = !1), D.revertOnSpill === void 0 && (D.revertOnSpill = !1), D.removeOnSpill === void 0 && (D.removeOnSpill = !1), D.direction === void 0 && (D.direction = "vertical"), D.ignoreInputTextSelection === void 0 && (D.ignoreInputTextSelection = !0), D.mirrorContainer === void 0 && (D.mirrorContainer = u.body); var G = d({ containers: D.containers, start: gt, end: qe, cancel: We, remove: ze,