UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,700 lines 176 kB
var tn = Object.defineProperty; var nn = (n, e, t) => e in n ? tn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var oe = (n, e, t) => nn(n, typeof e != "symbol" ? e + "" : e, t); import { ref as _, computed as H, watch as ie, nextTick as ee, reactive as on, createVNode as M, withDirectives as vt, resolveDirective as rn, onMounted as ye, vModelText as sn, createTextVNode as ht, Fragment as an, defineComponent as xe, shallowRef as Be, provide as ke, inject as se, onUnmounted as je, isVNode as gt, getCurrentInstance as ln, onBeforeUnmount as cn, withModifiers as un } from "vue"; import { cloneDeep as Ee, isPlainObject as ft } from "lodash-es"; import { getCustomClass as be } from "../common/index.esm.js"; import dn from "../capsule/index.esm.js"; import bt from "../response-toolbar/index.esm.js"; import { createPropsResolver as fn } from "../dynamic-resolver/index.esm.js"; import pn from "../section/index.esm.js"; import { useDesignerInnerComponent as mn, useDesignerComponent as vn } from "../designer-canvas/index.esm.js"; const yt = {}, Ct = {}; function Qe(n) { const { properties: e, title: t, ignore: o } = n, i = o && Array.isArray(o), r = Object.keys(e).reduce((s, l) => ((!i || !o.find((a) => a === l)) && (s[l] = e[l].type === "object" && e[l].properties ? Qe(e[l]) : Ee(e[l].default)), s), {}); if (t && (!i || !o.find((s) => s === "id"))) { const s = t.toLowerCase().replace(/-/g, "_"); r.id = `${s}_${Math.random().toString().slice(2, 6)}`; } return r; } function hn(n) { const { properties: e, title: t, required: o } = n; if (o && Array.isArray(o)) { const i = o.reduce((r, s) => (r[s] = e[s].type === "object" && e[s].properties ? Qe(e[s]) : Ee(e[s].default), r), {}); if (t && o.find((r) => r === "id")) { const r = t.toLowerCase().replace(/-/g, "_"); i.id = `${r}_${Math.random().toString().slice(2, 6)}`; } return i; } return { type: t }; } function Ie(n, e = {}, t) { const o = yt[n]; if (o) { let i = hn(o); const r = Ct[n]; return i = r ? r({ getSchemaByType: Ie }, i, e, t) : i, i; } return null; } function gn(n, e) { const t = Qe(e); return Object.keys(t).reduce((o, i) => (Object.prototype.hasOwnProperty.call(n, i) && (o[i] && ft(o[i]) && ft(n[i] || !n[i]) ? Object.assign(o[i], n[i] || {}) : o[i] = n[i]), o), t), t; } function wt(n, e) { return Object.keys(n).filter((o) => n[o] != null).reduce((o, i) => { if (e.has(i)) { const r = e.get(i); if (typeof r == "string") o[r] = n[i]; else { const s = r(i, n[i], n); Object.assign(o, s); } } else o[i] = n[i]; return o; }, {}); } function bn(n, e, t = /* @__PURE__ */ new Map()) { const o = gn(n, e); return wt(o, t); } function yn(n = {}) { function e(c, f, u, v) { if (typeof u == "number") return v[c].length === u; if (typeof u == "object") { const d = Object.keys(u)[0], m = u[d]; if (d === "not") return Number(v[c].length) !== Number(m); if (d === "moreThan") return Number(v[c].length) >= Number(m); if (d === "lessThan") return Number(v[c].length) <= Number(m); } return !1; } function t(c, f, u, v) { return v[c] && v[c].propertyValue && String(v[c].propertyValue.value) === String(u); } const o = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(n).reduce((c, f) => (c.set(f, n[f]), c), o); function i(c, f) { const u = c; return typeof f == "number" ? [{ target: u, operator: "length", param: null, value: Number(f) }] : typeof f == "boolean" ? [{ target: u, operator: "getProperty", param: c, value: !!f }] : typeof f == "object" ? Object.keys(f).map((v) => { if (v === "length") return { target: u, operator: "length", param: null, value: f[v] }; const d = v, m = f[v]; return { target: u, operator: "getProperty", param: d, value: m }; }) : []; } function r(c) { return Object.keys(c).reduce((u, v) => { const d = i(v, c[v]); return u.push(...d), u; }, []); } function s(c, f) { if (o.has(c.operator)) { const u = o.get(c.operator); return u && u(c.target, c.param, c.value, f) || !1; } return !1; } function l(c, f) { return r(c).reduce((d, m) => d && s(m, f), !0); } function a(c, f) { const u = Object.keys(c), v = u.includes("allOf"), d = u.includes("anyOf"), m = v || d, T = (m ? c[m ? v ? "allOf" : "anyOf" : "allOf"] : [c]).map((D) => l(D, f)); return v ? !T.includes(!1) : T.includes(!0); } return { parseValueSchema: a }; } const ce = { 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: "筛选条" } }, Cn = {}, wn = {}; yn(); function De(n, e, t = /* @__PURE__ */ new Map(), o = (s, l, a, c) => l, i = {}, r = (s) => s) { return yt[e.title] = e, Ct[e.title] = o, Cn[e.title] = i, wn[e.title] = r, (s = {}, l = !0) => { if (!l) return wt(s, t); const a = bn(s, e, t), c = Object.keys(n).reduce((f, u) => (f[u] = n[u].default, f), {}); return Object.assign(c, a); }; } function Le(n, e) { return { customClass: e.class, customStyle: e.style }; } function Tn(n, e) { if (!n || n.length < 1) return null; for (const t of n) { if (t.id === e) return t; if (t.children) { const o = t.children.find((i) => i.id === e); if (o) return o; } } return null; } function Sn() { function n(e, t) { const { name: o } = t, [i, r] = t.payloads; if (o === "tabChange" || o === "tabRemove") return e[`on${o.charAt(0).toUpperCase()}${o.slice(1)}`]; const s = e.contents; if (!s || s.length < 1) return null; const l = s.reduce((c, f) => { const u = f.toolbar && f.toolbar.buttons || []; return c.push(...u), c; }, []); if (!l || l.length < 1) return; const a = Tn(l, r); return a ? a.onClick || a.click : null; } return { resolve: n }; } const Ze = /* @__PURE__ */ new Map([ ["appearance", Le] ]); function xn(n, e) { const t = Math.random().toString().slice(2, 6), o = e.parentComponentInstance, i = n.getSchemaByType("tab-page"); i.id = `tab-page-${t}`, i.title = "标题", i.toolbar = { id: `tab-page-toolbar-${t}`, buttons: [] }; const r = n.getSchemaByType("tabs"); Object.assign(r, { id: `tabs-${t}`, appearance: { class: "f-component-tabs f-tabs-has-grid" }, contents: [i], activeId: i.id }); const s = n.getSchemaByType("section"); Object.assign(s, { id: `section-${t}`, appearance: { class: "f-section-tabs f-section-in-mainsubcard" }, fill: !1, showHeader: !1, contents: [r] }); const l = n.getSchemaByType("content-container"); Object.assign(l, { id: `container-${t}`, appearance: { class: "f-struct-wrapper" }, contents: [s] }); const a = o.schema; switch (a && a.type) { case ce["splitter-pane"].type: { s.appearance.class = "f-section-tabs f-section-in-main", r.appearance.class = "f-component-tabs"; break; } } const c = o.elementRef, f = window.getComputedStyle(c); return f && f.display === "flex" && (l.appearance.class += " d-block"), l; } function Tt(n, e, t) { if (t.parentComponentInstance) return xn(n, t); { const i = n.getSchemaByType("tab-page"); return e.contents = [i], e; } } function In(n, e, t) { return e; } const Pn = "https://json-schema.org/draft/2020-12/schema", En = "https://farris-design.gitee.io/tabs.schema.json", Mn = "tabs", Dn = "A Farris Container Component", Bn = "object", kn = { id: { description: "The unique identifier for a Tabs", type: "string" }, type: { description: "The type string of Tabs component", type: "string", default: "tabs" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, autoTitleWidth: { description: "", type: "boolean", default: !1 }, titleWidth: { description: "", type: "number" }, titleLength: { description: "", type: "number", default: 7 }, fill: { description: "", type: "boolean", default: !1 }, visible: { description: "", type: "boolean", default: !0 }, activeId: { description: "", type: "string", default: "" } }, An = [ "id", "type", "contents" ], On = { onTabChange: "切换标签页事件", onTabRemove: "移除标签页事件" }, St = { $schema: Pn, $id: En, title: Mn, description: Dn, type: Bn, properties: kn, required: An, events: On }, Je = { /** 标签页头部区域的展示类型 */ tabType: { type: String, default: "default" }, /** 标题自适应宽度 */ autoTitleWidth: { type: Boolean, default: !1 }, titleLength: { type: Number, default: 7 }, position: { type: String, default: "top" }, showDropdown: { type: Boolean, default: !0 }, scrollStep: { type: Number, default: 10 }, autoResize: { type: Boolean, default: !1 }, width: { type: Number }, height: { type: Number }, searchBoxVisible: { type: Boolean, default: !0 }, titleWidth: { type: Number, default: 0 }, customClass: { type: String, default: "" }, /** 指定当前活动Id */ activeId: { type: String }, /** 标签页内容区域是否填充 */ fill: { type: Boolean, default: !1 }, justifyContent: { type: String, default: "left" }, /** 控制是否可见 */ visible: { type: Boolean, default: !0 } }, $n = De(Je, St, Ze, Tt), xt = Object.assign({}, Je, { componentId: { type: String, default: "" } }), Rn = De(xt, St, Ze, Tt), jn = Sn(); function Ln(n, e, t) { const o = _([]), i = _(n.activeId || ""); let r = ""; const s = _(!0), l = _([]), a = _(0), c = H(() => { const C = o.value.find((B) => B.props.id === i.value); return (C == null ? void 0 : C.props.toolbarPosition) === "inHead"; }); function f(C, k = !0) { const B = C.findIndex((b) => b.props.show !== !1 && !b.props.disabled); if (l.value = [], B !== -1) { if (i.value = C[B].props.id, !k) return; const b = C[B]; b && b.props.toolbar && b.props.toolbar.buttons && b.props.toolbar.buttons.length && (l.value = [...b.props.toolbar.buttons]); } } function u(C) { i.value = C; const k = o.value.find((B) => B.props.id === C); l.value = [], k && k.props.toolbar && k.props.toolbar.buttons && k.props.toolbar.buttons.length && (l.value = [...k.props.toolbar.buttons]), e.emit("update:activeId", C), e.emit("tabChange", { prevId: r, nextId: i.value }); } function v(C) { let k = -1; if (!i.value) { if (k = C.findIndex((B) => i.value === B.props.id && B.props.show !== !1 && !B.props.disabled), k > -1) return; r = i.value; } f(C, !1), u(i.value); } function d(C) { let k = !1; if (C) { const B = o.value.find((b) => b.props.id === C); k = !B || B.props.show === !1 || B.props.disabled === !0; } k ? v(o.value) : (i.value !== C && (r = i.value, i.value = C), u(i.value)); } ie(() => n.activeId, (C, k) => { C !== k && d(C); }); function m(C) { var B; if (n.autoTitleWidth) return; const k = (B = C.value) == null ? void 0 : B.querySelectorAll(".st-tab-text"); if (!(!k || n.tabType === "pill")) for (let b = 0; b < k.length; b++) { const R = k[b].parentNode; k[b].scrollWidth > R.offsetWidth ? k[b].classList.contains("farris-title-text-custom") || k[b].classList.add("farris-title-text-custom") : k[b].classList.remove("farris-title-text-custom"); } } const h = (C) => { C.preventDefault(), C.stopPropagation(); }; function E(C, k, B = !1) { const b = o.value.findIndex((R) => R.props.id === k); o.value = o.value.filter((R) => R.props.id !== k), i.value === k && (r = k, i.value = "", f(o.value)), h(C), ee(() => { a.value++, m(t), B && (s.value = !0), e.emit("tabRemove", { removeIndex: b, removeId: k, activeId: i.value }); }); } function T(C, k = !0) { i.value === C && (i.value = "", r = C, d("")), ee(() => { a.value++, k && (s.value = !0); }); } function w(C) { i.value !== C && (r = i.value, u(C)); } function D(C) { o.value.findIndex((B) => B.props.id === C.props.id) === -1 && o.value.push(C), a.value++; } function L(C) { o.value.findIndex((B) => B.props.id === C.props.id) !== -1 && (o.value.forEach((B) => { B.props.id === C.props.id && (B = C); }), C.props.id === i.value && c.value, ee(() => { a.value++, m(t); })); } return { activeId: i, addTab: D, changeTitleStyle: m, removeTab: E, selectTab: w, tabPages: o, updateTab: L, toolbarItems: l, needUpdateNavigationLayout: a, checkActiveIdAndSelect: d, toggleShowTab: T, hasInHeadClass: c }; } function Vn(n, e, t, o, i) { const { activeId: r, removeTab: s, selectTab: l } = i, a = H(() => { const D = { "st-tab-text": !0, "text-truncate": n.tabType === "pill" && !n.autoTitleWidth, "farris-title-auto": n.autoTitleWidth }; return be(D, e.customTitleClass); }), c = H(() => ({ "nav-item": !0, "d-none": e.show !== void 0 ? !e.show : !1, "f-state-active": e.id === r.value, "f-state-disabled": e.disabled })), f = H(() => ({ width: `${e.tabWidth}px` })), u = H(() => ({ "nav-link": !0, "tabs-text-truncate": !0, active: e.id === r.value, disabled: e.disabled })), v = on({ content: e.title, overflowShown: !0 }); function d(D) { return n.tabType !== "pill" && !n.autoTitleWidth ? vt(M("span", { class: a.value, "data-tabid": D.id }, [D.title]), [[rn("tooltip"), v]]) : M("span", { class: a.value, "data-tabid": D.id, title: D.title }, [D.title]); } function m(D) { return D.slots.title ? D.slots.title : d; } const h = m(t), E = _(e.removeable); function T() { return M("span", { class: "st-drop-close", onClick: (D) => s(D, e.id) }, [M("i", { class: "f-icon f-icon-close" }, null)]); } function w(D) { l(e.id), n.tabType === "one-page" && o.scrollToByPaggId(e.id); } return M("li", { class: c.value, style: f.value }, [M("a", { class: u.value, onClick: w }, [h(e), E.value && T()])]); } function Nn(n, e, t, o, i) { const { shouldShowNavigationButtons: r } = t, { tabPages: s } = i, l = H(() => ({ spacer: !0, "f-utils-fill": !0, "spacer-sides-dropdown": r.value })), a = H(() => ({ width: "100%", "justify-content": n.justifyContent })), c = H(() => ({ nav: !0, "farris-nav-tabs": !0, "flex-nowrap": !0, "nav-fill": n.tabType === "fill", "nav-pills": n.tabType === "pills", "flex-row": n.position === "top" || n.position === "bottom", "flex-column": n.position === "left" || n.position === "right" })); return () => M("div", { class: l.value, style: a.value }, [M("ul", { class: c.value, ref: e }, [s.value.map((f) => Vn(n, f.props, f, o, i))])]); } function It(n, e, t, o, i) { const r = _(), { shouldShowNavigationButtons: s } = t, { activeId: l, tabPages: a, selectTab: c } = i, f = _(l.value), u = H(() => a.value.map((h) => ({ name: h.props.title, value: h.props.id, show: h.props.show, disabled: h.props.disabled }))), v = H(() => ({ spacer: !0, "f-utils-fill": !0, "spacer-sides-dropdown": s.value })), d = H(() => ({ width: "100%", display: "flex", "justify-content": n.justifyContent })); ye(() => { r.value && (e.value = r.value.$el); }); function m(h) { c(h); } return ie(() => l.value, (h) => { h !== f.value && (f.value = h); }, { immediate: !0 }), () => M("div", { class: v.value, style: d.value }, [M(dn, { items: u.value, modelValue: f.value, "onUpdate:modelValue": (h) => f.value = h, onChange: m, ref: r }, null)]); } function Fn(n, e, t, o) { const i = _(), { activeId: r, removeTab: s, tabPages: l } = o, { selectAndScrollToTab: a } = t, { hideDropDown: c, searchTabText: f } = e, u = 600; let v = null; const d = H(() => { var R, S; let b = []; return n.searchBoxVisible ? b = (R = l.value) == null ? void 0 : R.filter((p) => p.props.title.includes(f.value)) : b = (S = l.value) == null ? void 0 : S.slice(), b; }), m = H(() => ({ "dropdown-menu": !0, "tabs-pt28": n.searchBoxVisible, // 未看到样式定义 show: !c.value, "d-none": c.value })); let h; function E(b) { h = b; } ie(c, (b) => { if (h.value) if (b) i.value.style.width = null; else { const R = h.value.querySelector(".farris-tabs-header"), S = h.value.clientHeight - R.clientHeight - 20, y = R.querySelector(".farris-tabs-title").clientWidth - 20; i.value.style.maxWidth = y + "px", i.value.style.maxHeight = S + "px", ee(() => { const { width: j } = i.value.getClientRects()[0]; i.value.style.width = j ? j + "px" : null; }); } }); function T(b) { return { "dropdown-item": !0, "text-truncate": !0, "px-2": !0, disabled: b.props.disabled, active: b.props.id === r.value, "d-none": b.props.show !== !0 }; } function w(b) { b.preventDefault(), b.stopPropagation(); } function D() { v && clearTimeout(v); } function L() { c.value || (v = setTimeout(() => { c.value = !0; }, u)); } function C(b, R) { b.stopPropagation(), a(b, R), c.value = !0; } function k(b, R) { b.stopPropagation(), s(b, R, !0); } function B() { return M("div", { ref: i, class: m.value, onMouseenter: () => D(), onMouseleave: () => L() }, [n.searchBoxVisible && M("div", { onClick: (b) => w(b), class: "pb-1 tabs-li-absolute" }, [vt(M("input", { type: "text", class: "form-control", "onUpdate:modelValue": (b) => f.value = b }, null), [[sn, f.value]]), M("span", { class: "f-icon f-icon-page-title-query tabs-icon-search" }, null)]), d.value.length ? M("ul", { class: "tab-dropdown-menu--items flex-fill" }, [d.value.map((b) => M("li", { class: T(b), onClick: (R) => C(R, b.props) }, [b.props.removeable && b.props.disabled !== !0 && M("span", { class: "float-right st-drop-close", onClick: (R) => k(R, b.props.id) }, [M("i", { class: "f-icon f-icon-close" }, null)]), M("a", { class: "dropdown-title", title: b.props.title }, [b.props.title])]))]) : M("div", { class: "dropdown-no-data" }, [ht("没有相关数据")])]); } return { renderDropdownMenu: B, setTabsRef: E }; } function Hn(n, e, t, o) { const { hideDropDown: i } = e, { renderDropdownMenu: r, setTabsRef: s } = Fn(n, e, t, o), l = _(n.showDropdown); function a() { return l.value && M(an, null, [M("button", { class: "btn dropdown-toggle-split dropdown-toggle", onClick: () => { i.value = !1; } }, null), r()]); } return { renderMorePagesButtton: a, setTabsRef: s }; } function Pt(n, e, t, o) { const i = _(!1), { selectTab: r, tabPages: s, needUpdateNavigationLayout: l, activeId: a } = o, c = 4, f = H(() => ({ btn: !0, "sc-nav-btn": !0, "px-1": !0, "sc-nav-lr": !0, "d-none": !i.value })), u = H(() => ({ "btn-group": !0, "sc-nav-btn": !0, dropdown: !0, "d-none": !i.value })), v = H(() => ({ btn: !0, "sc-nav-rg": !0, "d-none": !i.value })); function d(T, w) { if (!e.value) return; const D = e.value.scrollLeft, L = e.value.scrollWidth - e.value.offsetWidth; if (w > 0) { if (e.value.scrollLeft >= L) return; e.value.scrollLeft = D + n.scrollStep + T; } else if (w < 0) { if (e.value.scrollLeft <= 0) return; e.value.scrollLeft = D - n.scrollStep - T; } } function m(T = -1) { if (!i.value || !e.value) return; T < 0 && (T = s.value.findIndex((k) => k.props.id === a.value)); const w = n.tabType === "pills" ? ".f-capsule-item" : ".nav-item", D = e.value.querySelectorAll(w), { parentElement: L } = e.value, C = D[T]; if (C && L) { const k = L.getBoundingClientRect().left, B = L.getBoundingClientRect().right, b = C.getBoundingClientRect().left, R = C.getBoundingClientRect().right; b < k ? d(k - b, -1) : B < R && d(R - B, 1), n.tabType === "one-page" && t.scrollTo(T); } } function h() { var D; if (!e.value) return; const T = e.value, w = (D = e.value) == null ? void 0 : D.parentElement; i.value = w && T && w.offsetWidth < T.scrollWidth - c, i.value && ee(() => { m(); }); } function E(T, w) { w.disabled || (r(w.id), ee(() => { m(); })); } return ie(l, () => { h(); }), { previousButtonClass: f, nextButtonGroupClass: u, nextButtonClass: v, scrollTab: d, selectAndScrollToTab: E, shouldShowNavigationButtons: i, updateNavigationLayout: h }; } function Et(n, e) { const { tabPages: t } = e, o = _(""), i = _(!0), r = H(() => n.searchBoxVisible), s = H(() => r.value ? t.value.filter((a) => a.props.title.includes(o.value)) : t.value.slice()); return ie(i, (l) => { l || (o.value = ""); }), { searchTabText: o, hideDropDown: i, shouldShowSearchBox: r, tabsInDropdownMenu: s }; } function Mt(n, e, t) { const o = ".farris-tab-page", { tabPages: i } = t; function r(l) { const a = e.value; if (a) { const c = e.value.querySelectorAll(o); if (c.length > 0) { const f = c[l], { offsetTop: u } = f, v = u - 32 > 0 ? u - 32 : 0; a.scrollTop = v; } } } function s(l) { const a = i.value.findIndex((c) => c.props.id === l); a > -1 && r(a); } return { scrollTo: r, scrollToByPaggId: s }; } const Me = /* @__PURE__ */ xe({ name: "FTabs", props: Je, emits: ["tabChange", "tabRemove", "update:activeId", "Click"], setup(n, e) { const t = _(n.tabType), o = Be(), i = _(n.customClass), r = Be(), s = Be(), l = _(), a = Ln(n, e, r), { activeId: c, changeTitleStyle: f, tabPages: u, addTab: v, updateTab: d, toolbarItems: m, checkActiveIdAndSelect: h, toggleShowTab: E, hasInHeadClass: T } = a, w = Mt(n, s, a), D = Pt(n, r, w, a), { previousButtonClass: L, nextButtonClass: C, nextButtonGroupClass: k, scrollTab: B, updateNavigationLayout: b } = D, R = Et(n, a), S = Nn(n, r, D, w, a), p = S, y = It(n, r, D, w, a), j = /* @__PURE__ */ new Map([["default", S], ["one-page", p], ["pills", y]]); H(() => { const O = u.value.find((Y) => Y.props.id === c.value); return O == null ? void 0 : O.slots; }); const P = H(() => n.fill); ke("tabs", { activeId: c, addTab: v, updateTab: d, tabPages: u, tabType: t, shouldFillParentContaner: P, toggleShowTab: E }); let $ = !1; const N = H(() => ({ "farris-tabs-header": !0, "farris-tabs-inHead": T.value, "farris-tabs-inContent": !T.value, "farris-tabs-nav-fill": n.tabType === "fill", "farris-tabs-nav-pills": n.tabType === "pills" })), G = H(() => { const O = { width: T.value && n.titleWidth ? `${n.titleWidth}%` : "" }; return O.width && (O.flex = "unset"), O; }), q = H(() => { const O = { "farris-tabs": !0, "f-utils-fill-flex-column": P.value, "flex-column": n.position === "top", "flex-column-reverse": n.position === "bottom", "flex-row": n.position === "left", "flex-row-reverse": n.position === "right", "one-page": n.tabType === "one-page" }; return i.value && i.value.split(" ").reduce((Y, K) => (Y[K] = !0, Y), O), O; }), W = new ResizeObserver((O) => { O.length && b(); }); function Q() { l.value && !$ && (W.observe(l.value), $ = !0); } ie(() => n.visible, (O) => { ee(() => { u.value.length && h(n.activeId || u.value[0].props.id), b(), f(r), Q(); }); }), ie(() => n.autoTitleWidth, (O) => { ee(() => { b(), f(r); }); }), ye(() => { n.visible && (u.value.length && h(n.activeId || u.value[0].props.id), ee(() => { b(), f(r); }), Q()); }); function X() { return M("button", { title: "向左", type: "button", class: L.value, onClick: () => { B(0, -1); } }, null); } function te() { return M("button", { title: "向右", type: "button", class: C.value, onClick: () => { B(0, 1); } }, null); } const { renderMorePagesButtton: ne, setTabsRef: me } = Hn(n, R, D, a); me(o); const z = (O, Y) => { e.emit("Click", O, Y, c.value); }; function fe() { return m.value.length ? M("div", { class: "farris-tabs-toolbar" }, [M(bt, { class: "f-utils-fill", alignment: T.value ? "right" : "left", items: m.value, onClick: z }, null)]) : null; } const ue = j.get(n.tabType) || j.get("default"); function x() { var O, Y, K, de; return M("div", { class: N.value }, [M("div", { class: "farris-tabs-header-pre" }, [(Y = (O = e.slots).headerPrefix) == null ? void 0 : Y.call(O)]), M("div", { class: "farris-tabs-title scroll-tabs", style: G.value, ref: l }, [X(), ue && ue(), M("div", { class: k.value }, [te(), ne()])]), fe(), M("div", { class: "farris-tabs-header-post" }, [(de = (K = e.slots).headerSuffix) == null ? void 0 : de.call(K)])]); } const g = H(() => ({ "farris-tabs-content": !0, "f-utils-fill-flex-column": P.value })); function A() { var O, Y; return M("div", { class: g.value, ref: s }, [(Y = (O = e.slots).default) == null ? void 0 : Y.call(O)]); } return () => n.visible ? M("div", { class: q.value, ref: o }, [x(), A()]) : null; } }); function _n(n, e, t) { return e && e.contents && e.contents.length && (e.contents.forEach((o) => { o.title && (o.text = o.title); }), e.buttons = e.contents, delete e.contents), { toolbar: e }; } const qn = /* @__PURE__ */ new Map([ ["appearance", Le], ["toolbar", _n] ]), Un = "https://json-schema.org/draft/2020-12/schema", Wn = "https://farris-design.gitee.io/tab-page.schema.json", zn = "tab-page", Xn = "A Farris Container Component", Yn = "object", Gn = { id: { description: "The unique identifier for a tab-page Item", type: "string" }, type: { description: "The type string of tab-page Item component", type: "string", default: "tab-page" }, contents: { description: "", type: "array", default: [] }, title: { description: "", type: "string", default: "标题" }, disabled: { description: "", type: "boolean", default: !1 }, removeable: { description: "", type: "boolean", default: !1 }, show: { description: "", type: "boolean", default: !0 }, toolbar: { description: "", type: "object" }, tabWidth: { description: "", type: "number" }, toolbarPosition: { description: "", type: "string", default: "inHead" }, customTitleClass: { description: "", type: "string", default: "" }, onTabChange: { description: "", type: "切换标签页事件", default: "" }, onTabRemove: { description: "", type: "string", default: "移除标签页事件" } }, Qn = [ "id", "type", "contents" ], Zn = { $schema: Un, $id: Wn, title: zn, description: Xn, type: Yn, properties: Gn, required: Qn }, Ke = { tabWidth: { type: Number }, id: { type: String, default: "" }, customTitleClass: { type: String, default: "" }, // 暂未被用到 titleOverflow: { type: Boolean, default: !1 }, title: { type: String, default: "" }, // 暂未被用到 selected: { type: Boolean, default: !1 }, disabled: { type: Boolean, default: !1 }, removeable: { type: Boolean, default: !1 }, show: { type: Boolean, default: !0 }, toolbar: { type: Object, default: {} }, toolbarPosition: { type: String, default: "inHead" } }, Dt = fn(Ke, Zn, qn); function Jn(n) { return typeof n == "function" || Object.prototype.toString.call(n) === "[object Object]" && !gt(n); } const Xe = /* @__PURE__ */ xe({ name: "FTabPage", props: Ke, emits: [], setup(n, e) { const t = se("tabs"), o = _(n.show), i = { slots: e.slots, props: n }, r = _((t == null ? void 0 : t.tabType.value) || "default"); ye(() => { const d = t == null ? void 0 : t.tabPages.value.findIndex((m) => m.props.id === n.id); (!d || d === -1) && (t == null || t.addTab(i)); }), je(() => { }); const s = H(() => (n == null ? void 0 : n.id) === (t == null ? void 0 : t.activeId.value)), l = H(() => ({ display: s.value ? "" : "none" })); ie(() => n, (d) => { t == null || t.updateTab({ props: d, slots: e.slots }); }, { immediate: !0, deep: !0 }), ie(() => n.show, (d) => { t == null || t.toggleShowTab(n.id); }); function a() { var m, h; const d = (h = (m = e.slots).default) == null ? void 0 : h.call(m); return M(pn, { "main-title": n.title, class: ["farris-tab-page", o.value ? "" : "f-tab-d-none"] }, Jn(d) ? d : { default: () => [d] }); } const c = H(() => { var m; return { "farris-tab-page": !0, "f-tab-d-none": !o.value, "f-utils-fill-flex-column": s.value && t && ((m = t.shouldFillParentContaner) == null ? void 0 : m.value) }; }); function f() { var m, h; const d = (h = (m = e.slots).default) == null ? void 0 : h.call(m); return M("div", { class: c.value, style: l.value }, [d]); } const v = (/* @__PURE__ */ new Map([["default", f], ["one-page", a]])).get(r.value) || f; return () => v(); } }); function Kn(n, e, t, o, i, r) { const { activeId: s, selectTab: l, removeDesignTab: a, selectDesignTab: c, addTabPageToolbar: f, resetPositionForSelectedElement: u } = i, v = H(() => ({ "st-tab-text": !0, "farris-title-auto": n.autoTitleWidth })), d = H(() => { const y = { "farris-component": !0, "nav-item": !0, "f-state-active": e.id === s.value }; return y[`${e.id}-design-item`] = !0, y; }), m = H(() => { const y = {}; return e.tabWidth && e.tabWidth > 0 && (y.width = `${e.tabWidth}px`), y; }), h = H(() => ({ "nav-link": !0, "tabs-text-truncate": !0, active: e.id === s.value })); function E(y) { return M("span", { class: v.value, title: y.title }, [y.title]); } function T(y) { return y.slots.title ? y.slots.title : E; } const w = T(t), D = _(e.removeable); function L() { return M("span", { class: "st-drop-close", style: { opacity: 0.6 } }, [M("i", { class: "f-icon f-icon-close" }, null)]); } function C(y) { l(e.id), n.tabType === "one-page" && o.scrollToByPaggId(e.id); } function k(y) { y && (y.stopPropagation(), y.preventDefault()), c(y, e.id, r.value); } function B(y) { a(y, e.id); } function b(y) { f(y, e.id); } ie(() => e.toolbarPosition, () => { ee(() => { u(null); }); }), ie(() => e.tabWidth, () => { ee(() => { u(null); }); }); function R() { return M("div", { role: "button", class: "btn component-settings-button", title: "删除", ref: "removeComponent", onClick: (y) => B(y) }, [M("i", { class: "f-icon f-icon-yxs_delete" }, null)]); } function S() { return M("div", { role: "button", class: "btn component-settings-button", title: "新增按钮", ref: "addComponent", onClick: (y) => b(y) }, [M("i", { class: "f-icon f-icon-plus-circle" }, null)]); } function p() { return M("div", { class: "component-btn-group", "data-noattach": "true" }, [M("div", null, [R(), !e.toolbar || !e.toolbar.buttons || !e.toolbar.buttons.length ? S() : ""])]); } return M("li", { onClick: (y) => k(y), class: d.value, style: m.value, pageId: `${e.id}-design-item` }, [p(), M("a", { class: h.value, onClick: C, id: `${e.id}-design-item` }, [w(e), D.value && L()])]); } function eo(n, e, t, o, i, r, s) { const { tabPages: l, selectTab: a, emitSelectionChange: c } = i, f = H(() => ({ spacer: !0, "f-utils-fill": !0 })), u = H(() => ({ width: "100%", "justify-content": n.justifyContent })), v = H(() => ({ nav: !0, "farris-nav-tabs": !0, "flex-nowrap": !0, "nav-fill": n.tabType === "fill", "nav-pills": n.tabType === "pills", "flex-row": n.position === "top" || n.position === "bottom", "flex-column": n.position === "left" || n.position === "right" })), d = H(() => ({ overflow: "auto" })), m = function(h) { var T; h && (h.stopPropagation(), h.preventDefault()); const E = Ie("tab-page"); E.id = `tab_page_${Math.random().toString().slice(2, 6)}`, E.title = "标题", E.toolbar = { id: `${E.id}_toolbar`, buttons: [] }, (T = r.value.schema.contents) == null || T.push(E), a(E.id), ee(() => { c(E.id, r.value); }); }; return () => M("div", { class: f.value, style: u.value }, [M("ul", { class: v.value, style: d.value, ref: e }, [l.value.map((h) => Kn(n, h.props, h, o, i, r)), M("li", { class: "nav-item no-drag" }, [M("a", { class: "nav-link tabs-text-truncate", title: "添加页签", onClick: (h) => m(h) }, [M("i", { class: "f-icon f-icon-plus", style: "font-size: 20px;margin: 0 auto;line-height: 24px;" }, null)])])])]); } function Bt(n, e, t) { var B; const o = t && t.getStyles && t.getStyles() || "", i = t && t.getDesignerClass && t.getDesignerClass() || "", r = _(); function s() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanMoveComponent ? t.checkCanMoveComponent() : !0; } function l() { return !1; } function a() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanDeleteComponent ? t.checkCanDeleteComponent() : !0; } function c() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !0 : t && t.hideNestedPaddingInDesginerView ? t.hideNestedPaddingInDesginerView() : !1; } function f(b) { if (!b || !b.value) return null; if (b.value.schema && b.value.schema.type === "component") return b.value; const R = _(b == null ? void 0 : b.value.parent), S = f(R); return S || null; } function u(b = e) { var y; if (t != null && t.getDraggableDesignItemElement) return t.getDraggableDesignItemElement(b); const { componentInstance: R, designerItemElementRef: S } = b; if (!R || !R.value) return null; const { getCustomButtons: p } = R.value; return R.value.canMove || p && ((y = p()) != null && y.length) ? S : u(b.parent); } function v(b) { return !!t && t.canAccepts(b); } function d() { return (e == null ? void 0 : e.schema.label) || (e == null ? void 0 : e.schema.title) || (e == null ? void 0 : e.schema.name); } function m() { } function h(b, R) { var S; !b || !R || (t != null && t.onAcceptMovedChildElement && t.onAcceptMovedChildElement(b, R), (S = e == null ? void 0 : e.setupContext) == null || S.emit("dragEnd")); } function E(b, R) { const { componentType: S } = b; let p = Ie(S, b, R); t && t.onResolveNewComponentSchema && (p = t.onResolveNewComponentSchema(b, p)); const y = S.toLowerCase().replace(/-/g, "_"); return p && !p.id && p.type === S && (p.id = `${y}_${Math.random().toString().slice(2, 6)}`), p; } function T(b) { b && t != null && t.onChildElementMovedOut && t.onChildElementMovedOut(b); } function w(...b) { if (t && t.getPropsConfig) return t.getPropsConfig(...b); } function D(b) { if (!b) return; const R = e == null ? void 0 : e.schema, { formSchemaUtils: S } = b; if (R && S.getExpressions().length) { const p = S.getExpressions().findIndex((y) => y.target === R.id); p > -1 && S.getExpressions().splice(p, 1); } } function L(b) { t && t.onRemoveComponent && t.onRemoveComponent(), D(b), e != null && e.schema.contents && e.schema.contents.map((R) => { let S = R.id; R.type === "component-ref" && (S = R.component); const p = n.value.querySelectorAll(`#${S}-design-item`); p != null && p.length && Array.from(p).map((y) => { var j; (j = y == null ? void 0 : y.componentInstance) != null && j.value.onRemoveComponent && y.componentInstance.value.onRemoveComponent(b); }); }); } function C() { if (t && t.getCustomButtons) return t.getCustomButtons(); } function k(b) { if (t && t.onPropertyChanged) return t.onPropertyChanged(b); } return r.value = { canMove: s(), canSelectParent: l(), canDelete: a(), canNested: !c(), contents: e == null ? void 0 : e.schema.contents, elementRef: n, parent: (B = e == null ? void 0 : e.parent) == null ? void 0 : B.componentInstance, schema: e == null ? void 0 : e.schema, styles: o, designerClass: i, canAccepts: v, getBelongedComponentInstance: f, getDraggableDesignItemElement: u, getDraggingDisplayText: d, getPropConfig: w, getDragScopeElement: m, onAcceptMovedChildElement: h, onChildElementMovedOut: T, addNewChildComponentSchema: E, triggerBelongedComponentToMoveWhenMoved: !!t && t.triggerBelongedComponentToMoveWhenMoved || _(!1), triggerBelongedComponentToDeleteWhenDeleted: !!t && t.triggerBelongedComponentToDeleteWhenDeleted || _(!1), onRemoveComponent: L, getCustomButtons: C, onPropertyChanged: k }, r; } class kt { getTemplateRule(e, t) { const o = t == null ? void 0 : t.formSchemaUtils, i = o == null ? void 0 : o.getFormTemplateRule(), r = { canAccept: !0, canDelete: !0, canMove: !0 }; if (!i) return r; const s = this.getComponentContext(e), { componentClassList: l } = s; return l.forEach((a) => { if (!a || !i[a]) return; const { canMove: c, canDelete: f, canAccept: u } = i[a]; r.canMove = r.canMove && this.resolveRuleValue(c, s), r.canDelete = r.canDelete && this.resolveRuleValue(f, s), r.canAccept = r.canAccept && this.resolveRuleValue(u, s); }), r; } resolveRuleValue(e, t) { return typeof e == "boolean" ? e : this.parseRuleValueSchema(e, t); } parseRuleValueSchema(e, t) { const o = e.invalidContext || []; let i = !0; for (const r of o) { if (r.firstLevelChild) { if (r.firstLevelChild.class) { const { firstLevelChildClassList: s } = t; if (s && !s.includes(r.firstLevelChild.class)) { i = !1; continue; } } if (r.firstLevelChild.type) { const { firstLevelChildSchema: s } = t; if (!s || s.type !== r.firstLevelChild.type) { i = !1; continue; } } } if (r.secondLevelChild) { if (r.secondLevelChild.class) { const { secondLevelChildClassList: s } = t; if (s && !s.includes(r.secondLevelChild.class)) { i = !1; continue; } } if (r.secondLevelChild.type) { const { secondLevelChildSchema: s } = t; if (!s || s.type !== r.secondLevelChild.type) { i = !1; continue; } } } if (r.parent) { if (r.parent.class) { const { parentClassList: s } = t; if (s && !s.includes(r.parent.class)) { i = !1; continue; } } if (r.parent.type) { const { parentSchema: s } = t; if (s && s.type !== r.parent.type) { i = !1; continue; } } } i = !0; break; } return !i; } getComponentContext(e) { var h, E, T, w; const t = e.schema, o = t.appearance && t.appearance.class || "", i = o.split(" ") || [], r = t.contents || [], s = r.length ? r[0] : null, l = s && s.appearance ? s.appearance.class : "", a = l ? l.split(" ") : [], c = (h = s == null ? void 0 : s.contents) != null && h.length ? s == null ? void 0 : s.contents[0] : null, f = c && c.appearance ? c.appearance.class : "", u = f ? f.split(" ") : [], v = t.type === "component" ? (T = (E = e.parent) == null ? void 0 : E.parent) == null ? void 0 : T.schema : (w = e.parent) == null ? void 0 : w.schema, d = v && v.appearance && v.appearance.class || "", m = d ? d.split(" ") : []; return { componentClass: o, componentClassList: i, childContents: r, firstLevelChildSchema: s, firstLevelChildClass: l, firstLevelChildClassList: a, secondLevelChildSchema: c, secondLevelChildClass: f, secondLevelChildClassList: u, parentSchema: v, parentClass: d, parentClassList: m }; } } const to = _(0); function no() { to.value++; } const Pe = _(0); function oo(n, e) { const t = e.getBoundingClientRect(), o = n.getBoundingClientRect(), i = o.top >= t.top, r = o.top <= t.bottom; return i && r; } function et(n) { const e = n.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 i = o.getBoundingClientRect(); o.style.top = t.top + "px"; let r = t.left - i.width; const s = document.querySelector(".editorDiv"); if (s) { const l = s.getBoundingClientRect(); r < l.left && ({ left: r } = n.getBoundingClientRect()); } o.style.left = r + "px"; } } } function io(n) { 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(n)) return o; } } function tt(n) { if (!n) return; const e = n.getBoundingClientRect(); if (e.width === 0 && e.height === 0) return; const t = n.querySelector(".component-btn-group"); if (t) { let o = !0; const i = io(n); if (i && (o = oo(n, i)), !o) { t.style.display = "none"; return; } et(n); } } function ro(n) { if (!n) return; let e; n.className.includes("dgComponentSelected") ? e = n : e = n.querySelector(".dgComponentSelected"), e && tt(e); } function so(n) { const { formSchemaUtils: e, formStateMachineUtils: t } = n; function o(a, c = "") { return { path: c + a.code, field: a.id, fullPath: a.code }; } function i(a, c = "") { return e.getViewModelById(a).states.map((u) => o(u, c)); } function r(a) { const c = e.getRootViewModelId(), f = i(a); if (a === c) return f; const u = i(c, "root-component."); return [...f, ...u]; } function s(a) { return a.binding && a.binding.path || a.id || ""; } function l() { return t && t.getRenderStates() || []; } return { getVariables: r, getControlName: s, getStateMachines: l }; } class ao { constructor(e) { oe(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'" } ]); oe(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); oe(this, "getExpressionConverter", (e, t) => ({ convertFrom: (o, i, r, s) => { const l = r.getExpressionRuleValue(e, t || i); return l && l.value || ""; }, convertTo: (o, i, r, s, l) => { var a; if (i === "dataPicking" && (r != null && r.target)) { const c = `${r.target}_dataPicking`; ((a = r.rules) == null ? void 0 : a.some( (u) => u.id === c && u.value )) ? o.dictPickingExpressionId = c : delete o.dictPickingExpressionId; } s.updateExpression(r); } })); this.formSchemaService = e; } getExpressionRule(e, t) { const o = this.formSchemaService.getExpressions(); if (!o) return ""; const i = o.find((s) => s.target === e); if (!i) return ""; const r = i.rules.find((s) => s.type === t); return r || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: e } = this.formSchemaService.getFormSchema(); if (!e.viewmodels || e.viewmodels.length === 0) return []; const t = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(t); if (!o || !o.states || o.states.length === 0) return []; const i = []; return o.states.forEach((r) => { i.push({ key: r.code, name: r.name, description: r.name, category: r.category }); }), i; } createTreeNode(e, t, o = "label") { return { id: e.id, name: e.name, bindingPath: e[o], parents: t }; } buildEntityFieldsTreeData(e = null, t) { const o = []; return e == null || e.forEach((i) => { var l; const r = this.createTreeNode(i, t); let s = []; (l = i.type) != null && l.fields && (s = this.buildEntityFieldsTreeData(i.type.fields, [...t, i.label])), o.push({ data: r, children: s, expanded: !0 }); }), o; } buildChildEntityTreeData(e = null, t) { const o = []; return e == null || e.forEach((i) => { var a, c; const r = this.createTreeNode(i, t), s = this.buildEntityFieldsTreeData((a = i.type) == null ? void 0 : a.fields, [...t, i.label]), l =