UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,608 lines 482 kB
var La = Object.defineProperty; var Na = (e, t, n) => t in e ? La(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var J = (e, t, n) => Na(e, typeof t != "symbol" ? t + "" : t, n); import { ref as h, watch as pe, nextTick as je, computed as O, createVNode as f, onMounted as Fe, withDirectives as Xt, vModelText as jn, createTextVNode as ke, Fragment as Ue, defineComponent as Se, shallowRef as Et, provide as Ft, inject as _e, onUnmounted as pt, isVNode as Kt, onBeforeUnmount as gn, withModifiers as Ln, resolveComponent as Aa, reactive as gt, createApp as Qt, Transition as Nn, mergeProps as ft, resolveDirective as Ha, triggerRef as Wa, onBeforeMount as za, Teleport as An, render as an, h as Ga, cloneVNode as qa, watchEffect as Ua, vShow as Ya } from "vue"; import { cloneDeep as yt, isPlainObject as Mn, isUndefined as En } from "lodash-es"; import Hn from "../capsule/index.esm.js"; import hn from "../response-toolbar/index.esm.js"; import { useResizeObserver as yn } from "@vueuse/core"; import { createPropsResolver as Wn, resolveAppearance as Xa } from "../dynamic-resolver/index.esm.js"; import zn from "../section/index.esm.js"; import { useDesignerInnerComponent as Ka, useDesignerComponent as Qa } from "../designer-canvas/index.esm.js"; import { getCustomClass as Dt, withInstall as Gn, useDateFormat as Ja, useNumberFormat as Za, resolveField as tt, setFieldValue as un } from "../common/index.esm.js"; import "bignumber.js"; import qn from "../button-edit/index.esm.js"; import Un from "../list-view/index.esm.js"; import ei from "../loading/index.esm.js"; import { useFilter as Yn, useIdentify as Xn, useHierarchy as Kn, useGroupData as Qn, useDataView as Jn, useSelection as Zn, useRow as eo, useEdit as to, useVisualDataBound as no, useVisualDataCell as oo, useVisualDataRow as ao, useVisualGroupRow as ti, useVisualSummaryRow as ni, useVisualData as io, useLoading as oi, useSelectHierarchyItem as ai, useDataViewContainerStyle as ii, useCommandColumn as li, useColumn as ri, useSort as si, useGroupColumn as ui, useCellPosition as ci, useSidebar as di, useVirtualScroll as fi, useFitColumn as pi, useFilterHistory as vi, useColumnFilter as mi, useDragColumn as gi, getColumnHeader as hi, getSidebar as yi, getDisableMask as bi, getHorizontalScrollbar as Ci, getVerticalScrollbar as wi, getEmpty as Si } from "../data-view/index.esm.js"; import xi, { FCheckbox as Jt } from "../checkbox/index.esm.js"; import "../modal/index.esm.js"; import Ti from "../transfer/index.esm.js"; import _i from "../tabs/index.esm.js"; import Ii from "../order/index.esm.js"; import "../condition/index.esm.js"; import ki from "../filter-bar/index.esm.js"; import Dn from "../tooltip/index.esm.js"; import Fi from "../pagination/index.esm.js"; import Bi from "../button/index.esm.js"; import Oi from "../search-box/index.esm.js"; import lo from "../tags/index.esm.js"; import Mi, { FDynamicFormGroup as Ei, FDynamicFormInput as Di } from "../dynamic-form/index.esm.js"; import Pi from "../accordion/index.esm.js"; import Vi from "../avatar/index.esm.js"; import Ri from "../button-group/index.esm.js"; import $i from "../calendar/index.esm.js"; import ji from "../color-picker/index.esm.js"; import cn from "../combo-list/index.esm.js"; import Li from "../content-container/index.esm.js"; import Ni from "../data-grid/index.esm.js"; import Ai from "../date-picker/index.esm.js"; import Hi from "../dropdown/index.esm.js"; import "../external-container/index.esm.js"; import Wi from "../events-editor/index.esm.js"; import zi from "../image-cropper/index.esm.js"; import Gi from "../input-group/index.esm.js"; import qi from "../layout/index.esm.js"; import Ui from "../list-nav/index.esm.js"; import Yi from "../lookup/index.esm.js"; import Xi from "../nav/index.esm.js"; import Ki from "../number-spinner/index.esm.js"; import Qi from "../number-range/index.esm.js"; import Ji from "../page-header/index.esm.js"; import Zi from "../page-footer/index.esm.js"; import el from "../progress/index.esm.js"; import tl from "../query-solution/index.esm.js"; import nl from "../radio-group/index.esm.js"; import ol from "../rate/index.esm.js"; import al from "../response-layout/index.esm.js"; import il from "../response-layout-editor/index.esm.js"; import ll from "../smoke-detector/index.esm.js"; import rl from "../splitter/index.esm.js"; import sl from "../step/index.esm.js"; import ul from "../switch/index.esm.js"; import cl from "../text/index.esm.js"; import dl from "../time-picker/index.esm.js"; import fl from "../tree-view/index.esm.js"; import pl from "../uploader/index.esm.js"; import vl from "../verify-detail/index.esm.js"; import ml from "../component/index.esm.js"; import gl from "../video/index.esm.js"; import hl from "../textarea/index.esm.js"; import yl from "../tree-grid/index.esm.js"; import bl from "../fieldset/index.esm.js"; import Cl from "../drawer/index.esm.js"; import wl from "../binding-selector/index.esm.js"; import "../notify/index.esm.js"; import Sl from "../combo-tree/index.esm.js"; import xl from "../field-selector/index.esm.js"; import Tl from "../mapping-editor/index.esm.js"; import _l from "../schema-selector/index.esm.js"; import Il from "../event-parameter/index.esm.js"; import kl from "../filter-condition-editor/index.esm.js"; import Fl from "../sort-condition-editor/index.esm.js"; import Bl from "../menu-lookup/index.esm.js"; import Ol from "../popover/index.esm.js"; const Ml = { injectSymbolToken: { type: Symbol }, /** 待选数据视图集合 */ viewOptions: { type: Array, default: [] }, /** 数据视图类型 */ viewType: { type: String, default: "Tabs" }, editorParams: { type: Object, default: null }, showFooter: { type: Boolean, default: !1 } }, ro = {}, so = {}; function bn(e) { const { properties: t, title: n, ignore: o } = e, a = o && Array.isArray(o), i = Object.keys(t).reduce((l, r) => ((!a || !o.find((s) => s === r)) && (l[r] = t[r].type === "object" && t[r].properties ? bn(t[r]) : yt(t[r].default)), l), {}); if (n && (!a || !o.find((l) => l === "id"))) { const l = n.toLowerCase().replace(/-/g, "_"); i.id = `${l}_${Math.random().toString().slice(2, 6)}`; } return i; } function El(e) { const { properties: t, title: n, required: o } = e; if (o && Array.isArray(o)) { const a = o.reduce((i, l) => (i[l] = t[l].type === "object" && t[l].properties ? bn(t[l]) : yt(t[l].default), i), {}); if (n && o.find((i) => i === "id")) { const i = n.toLowerCase().replace(/-/g, "_"); a.id = `${i}_${Math.random().toString().slice(2, 6)}`; } return a; } return { type: n }; } function Bt(e, t = {}, n) { const o = ro[e]; if (o) { let a = El(o); const i = so[e]; return a = i ? i({ getSchemaByType: Bt }, a, t, n) : a, a; } return null; } function Dl(e, t) { const n = bn(t); return Object.keys(n).reduce((o, a) => (Object.prototype.hasOwnProperty.call(e, a) && (o[a] && Mn(o[a]) && Mn(e[a] || !e[a]) ? Object.assign(o[a], e[a] || {}) : o[a] = e[a]), o), n), n; } function uo(e, t) { return Object.keys(e).filter((o) => e[o] != null).reduce((o, a) => { if (t.has(a)) { const i = t.get(a); if (typeof i == "string") o[i] = e[a]; else { const l = i(a, e[a], e); Object.assign(o, l); } } else o[a] = e[a]; return o; }, {}); } function Pl(e, t, n = /* @__PURE__ */ new Map()) { const o = Dl(e, t); return uo(o, n); } function Vl(e = {}) { function t(c, u, d, v) { if (typeof d == "number") return v[c].length === d; if (typeof d == "object") { const m = Object.keys(d)[0], g = d[m]; if (m === "not") return Number(v[c].length) !== Number(g); if (m === "moreThan") return Number(v[c].length) >= Number(g); if (m === "lessThan") return Number(v[c].length) <= Number(g); } return !1; } function n(c, u, d, v) { return v[c] && v[c].propertyValue && String(v[c].propertyValue.value) === String(d); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((c, u) => (c.set(u, e[u]), c), o); function a(c, u) { const d = c; return typeof u == "number" ? [{ target: d, operator: "length", param: null, value: Number(u) }] : typeof u == "boolean" ? [{ target: d, operator: "getProperty", param: c, value: !!u }] : typeof u == "object" ? Object.keys(u).map((v) => { if (v === "length") return { target: d, operator: "length", param: null, value: u[v] }; const m = v, g = u[v]; return { target: d, operator: "getProperty", param: m, value: g }; }) : []; } function i(c) { return Object.keys(c).reduce((d, v) => { const m = a(v, c[v]); return d.push(...m), d; }, []); } function l(c, u) { if (o.has(c.operator)) { const d = o.get(c.operator); return d && d(c.target, c.param, c.value, u) || !1; } return !1; } function r(c, u) { return i(c).reduce((m, g) => m && l(g, u), !0); } function s(c, u) { const d = Object.keys(c), v = d.includes("allOf"), m = d.includes("anyOf"), g = v || m, y = (g ? c[g ? v ? "allOf" : "anyOf" : "allOf"] : [c]).map((T) => r(T, u)); return v ? !y.includes(!1) : y.includes(!0); } return { parseValueSchema: s }; } const ie = { button: { type: "button", name: "按钮" }, "response-toolbar": { type: "response-toolbar", name: "工具栏" }, "response-toolbar-item": { type: "response-toolbar-item", name: "按钮" }, "content-container": { type: "content-container", name: "容器" }, "input-group": { type: "input-group", name: "文本" }, textarea: { type: "textarea", name: "多行文本" }, lookup: { type: "lookup", name: "帮助" }, "number-spinner": { type: "number-spinner", name: "数值" }, "date-picker": { type: "date-picker", name: "日期" }, switch: { type: "switch", name: "开关" }, "radio-group": { type: "radio-group", name: "单选组" }, "check-box": { type: "check-box", name: "复选框" }, "check-group": { type: "check-group", name: "复选框组" }, "combo-list": { type: "combo-list", name: "下拉列表" }, "response-form": { type: "response-form", name: "卡片面板" }, "response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" }, "response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" }, "tree-grid": { type: "tree-grid", name: "树表格" }, "tree-grid-column": { type: "tree-grid-column", name: "树表格列" }, "data-grid": { type: "data-grid", name: "表格" }, "data-grid-column": { type: "data-grid-column", name: "表格列" }, module: { type: "Module", name: "模块" }, component: { type: "component", name: "组件" }, tabs: { type: "tabs", name: "标签页" }, "tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" }, "tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" }, "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: "抽屉" } }, Rl = {}, $l = {}; Vl(); function Re(e, t, n = /* @__PURE__ */ new Map(), o = (l, r, s, c) => r, a = {}, i = (l) => l) { return ro[t.title] = t, so[t.title] = o, Rl[t.title] = a, $l[t.title] = i, (l = {}, r = !0) => { if (!r) return uo(l, n); const s = Pl(l, t, n), c = Object.keys(e).reduce((u, d) => (u[d] = e[d].default, u), {}); return Object.assign(c, s); }; } function lt(e, t) { return { customClass: t.class, customStyle: t.style }; } function jl() { function e(t, n) { const { dataSource: o } = t || {}; return o === void 0 ? {} : {}; } return { resolve: e }; } function Ll() { function e(t, n) { return t.selectItemById(n); } return { selectItemById: e }; } function Nl() { function e(t, n) { const o = t.contents; if (!o || o.length < 1) return null; const a = o.reduce((s, c) => { const u = c.toolbar && c.toolbar.buttons || []; return s.push(...u), s; }, []); if (!a || a.length < 1) return; const [i, l] = n.payloads, r = a.find((s) => s.id === l); return r ? r.onClick || r.click : null; } return { resolve: e }; } function Al() { function e(t, n) { const { columns: o } = n; return t.updateColumns(o); } return { updateColumns: e }; } const Cn = /* @__PURE__ */ new Map([ ["appearance", lt] ]); function Hl(e, t) { const n = Math.random().toString().slice(2, 6), o = t.parentComponentInstance, a = e.getSchemaByType("tab-page"); a.id = `tab-page-${n}`, a.title = "标题"; const i = e.getSchemaByType("tabs"); Object.assign(i, { id: `tabs-${n}`, appearance: { class: "f-component-tabs f-tabs-has-grid" }, contents: [a], activeId: a.id }); const l = e.getSchemaByType("section"); Object.assign(l, { id: `section-${n}`, appearance: { class: "f-section-tabs f-section-in-mainsubcard" }, fill: !1, showHeader: !1, contents: [i] }); const r = e.getSchemaByType("content-container"); Object.assign(r, { id: `container-${n}`, appearance: { class: "f-struct-wrapper" }, contents: [l] }); const s = o.schema; switch (s && s.type) { case ie["splitter-pane"].type: { l.appearance.class = "f-section-tabs f-section-in-main", i.appearance.class = "f-component-tabs"; break; } } const c = o.elementRef, u = window.getComputedStyle(c); return u && u.display === "flex" && (r.appearance.class += " d-block"), r; } function co(e, t, n) { if (n.parentComponentInstance) return Hl(e, n); { const a = e.getSchemaByType("tab-page"); return t.contents = [a], t; } } function Wl(e, t, n) { return t; } const zl = "https://json-schema.org/draft/2020-12/schema", Gl = "https://farris-design.gitee.io/tabs.schema.json", ql = "tabs", Ul = "A Farris Container Component", Yl = "object", Xl = { 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", default: 0 }, titleLength: { description: "", type: "number", default: 7 }, fill: { description: "", type: "boolean", default: !1 } }, Kl = [ "id", "type", "contents" ], fo = { $schema: zl, $id: Gl, title: ql, description: Ul, type: Yl, properties: Xl, required: Kl }, wn = { /** 标签页头部区域的展示类型 */ 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 }, selectedTab: { type: String, default: "" }, width: { type: Number }, height: { type: Number }, searchBoxVisible: { type: Boolean, default: !0 }, titleWidth: { type: Number, default: 0 }, customClass: { type: String, default: "" }, /** 同上selectedTab属性 */ activeId: { type: String }, /** 标签页内容区域是否填充 */ fill: { type: Boolean, default: !1 }, justifyContent: { type: String, default: "left" } }, Ql = Re(wn, fo, Cn, co), po = Object.assign({}, wn, { componentId: { type: String, default: "" } }), Jl = Re(po, fo, Cn, co), Zl = Nl(); function er(e, t, n) { const o = h([]), a = h(e.activeId || ""), i = h(!0), l = h([]), r = h(0); function s(y) { const b = y.findIndex((T) => T.props.show !== !1 && !a.value && !T.props.disabled); if (l.value = [], !a.value && b !== -1) { a.value = y[b].props.id; const T = y[b]; T && T.props.toolbar && T.props.toolbar.buttons && T.props.toolbar.buttons.length && (l.value = [...T.props.toolbar.buttons]); } } function c(y) { let b = !1; const T = o.value.find((w) => w.props.id === y); b = !T || T.props.show === !1 || T.props.disabled === !1, b ? s(o.value) : a.value = y; } pe(() => e.activeId, (y, b) => { y !== b && c(y); }); function u(y) { var T; if (e.autoTitleWidth) return; const b = (T = y.value) == null ? void 0 : T.querySelectorAll(".st-tab-text"); if (b) for (let w = 0; w < b.length; w++) { const B = b[w].parentNode; b[w].scrollWidth > B.offsetWidth ? b[w].classList.contains("farris-title-text-custom") || b[w].classList.add("farris-title-text-custom") : b[w].classList.remove("farris-title-text-custom"); } } const d = (y) => { y.preventDefault(), y.stopPropagation(); }; function v(y, b, T = !1) { const w = o.value.findIndex((B) => B.props.id === b); o.value = o.value.filter((B) => B.props.id !== b), a.value === b && (a.value = "", s(o.value)), d(y), je(() => { r.value++, u(n), T && (i.value = !0), t.emit("tabRemove", { removeIndex: w, removeId: b, activeId: a.value }); }); } function m(y) { const b = a.value; a.value = y; const T = o.value.find((w) => w.props.id === y); l.value = [], T && T.props.toolbar && T.props.toolbar.buttons && T.props.toolbar.buttons.length && (l.value = [...T.props.toolbar.buttons]), t.emit("update:activeId", y), t.emit("tabChange", { prevId: b, nextId: a.value }); } function g(y) { m(y); } function k(y) { o.value.findIndex((T) => T.props.id === y.props.id) === -1 && o.value.push(y), r.value++; } function S(y) { o.value.findIndex((T) => T.props.id === y.props.id) !== -1 && (o.value.forEach((T) => { T.props.id === y.props.id && (T = y); }), je(() => { r.value++, u(n); })); } return { activeId: a, addTab: k, changeTitleStyle: u, removeTab: v, selectTab: g, selectTabByTabId: m, tabPages: o, updateTab: S, toolbarItems: l, needUpdateNavigationLayout: r, checkActiveId: c }; } function tr(e, t, n, o, a) { const { activeId: i, removeTab: l, selectTab: r } = a, s = O(() => ({ "st-tab-text": !0, "text-truncate": !0, "farris-title-auto": e.autoTitleWidth })), c = O(() => ({ "nav-item": !0, "d-none": t.show !== void 0 ? !t.show : !1, "f-state-active": t.id === i.value, "f-state-disabled": t.disabled })), u = O(() => ({ width: `${t.tabWidth}px` })), d = O(() => ({ "nav-link": !0, "tabs-text-truncate": !0, active: t.id === i.value, disabled: t.disabled })); function v(b) { return f("span", { class: s.value, title: b.title }, [b.title]); } function m(b) { return b.slots.title ? b.slots.title : v; } const g = m(n), k = h(t.removeable); function S() { return f("span", { class: "st-drop-close", onClick: (b) => l(b, t.id) }, [f("i", { class: "f-icon f-icon-close" }, null)]); } function y(b) { r(t.id), e.tabType === "one-page" && o.scrollToByPaggId(t.id); } return f("li", { class: c.value, style: u.value }, [f("a", { class: d.value, onClick: y }, [g(t), k.value && S()])]); } function nr(e, t, n, o, a) { const { shouldShowNavigationButtons: i } = n, { tabPages: l } = a, r = O(() => ({ spacer: !0, "f-utils-fill": !0, "spacer-sides-dropdown": i.value })), s = O(() => ({ width: "100%", "justify-content": e.justifyContent })), c = O(() => ({ nav: !0, "farris-nav-tabs": !0, "flex-nowrap": !0, "nav-fill": e.tabType === "fill", "nav-pills": e.tabType === "pills", "flex-row": e.position === "top" || e.position === "bottom", "flex-column": e.position === "left" || e.position === "right" })); return () => f("div", { class: r.value, style: s.value }, [f("ul", { class: c.value, ref: t }, [l.value.map((u) => tr(e, u.props, u, o, a))])]); } function vo(e, t, n, o, a) { const i = h(), { shouldShowNavigationButtons: l } = n, { activeId: r, tabPages: s, selectTab: c } = a, u = h(r.value), d = O(() => s.value.map((k) => ({ name: k.props.title, value: k.props.id, show: k.props.show, disabled: k.props.disabled }))), v = O(() => ({ spacer: !0, "f-utils-fill": !0, "spacer-sides-dropdown": l.value })), m = O(() => ({ width: "100%", display: "flex", "justify-content": e.justifyContent })); Fe(() => { i.value && (t.value = i.value.$el); }); function g(k) { c(k); } return pe(() => r.value, (k) => { k !== u.value && (u.value = k); }, { immediate: !0 }), () => f("div", { class: v.value, style: m.value }, [f(Hn, { items: d.value, modelValue: u.value, "onUpdate:modelValue": (k) => u.value = k, onChange: g, ref: i }, null)]); } function or(e, t, n, o) { const { activeId: a, removeTab: i, tabPages: l } = o, { selectAndScrollToTab: r } = n, { hideDropDown: s, searchTabText: c } = t, u = 600; let d = null; const v = h("auto"), m = O(() => { var C, x; let p = []; return e.searchBoxVisible ? p = (C = l.value) == null ? void 0 : C.filter((F) => F.props.title.includes(c.value)) : p = (x = l.value) == null ? void 0 : x.slice(), p; }), g = O(() => ({ "dropdown-menu": !0, "tabs-pt28": e.searchBoxVisible, show: !s.value })); function k(p) { return { "dropdown-item": !0, "text-truncate": !0, "px-2": !0, disabled: p.props.disabled, active: p.props.id === a.value, "d-none": p.props.show !== !0 }; } function S(p) { p.preventDefault(), p.stopPropagation(); } const y = () => ({ width: v.value }); function b() { d && clearTimeout(d); } function T() { s.value || (d = setTimeout(() => { s.value = !0; }, u)); } function w(p, C) { p.stopPropagation(), r(p, C), s.value = !0; } function B(p, C) { p.stopPropagation(), i(p, C, !0); } function I() { return f("div", { class: g.value, onMouseenter: () => b(), onMouseleave: () => T() }, [e.searchBoxVisible && f("div", { onClick: (p) => S(p), class: "pb-1 tabs-li-absolute" }, [Xt(f("input", { type: "text", class: "form-control k-textbox", "onUpdate:modelValue": (p) => c.value = p }, null), [[jn, c.value]]), f("span", { class: "f-icon f-icon-page-title-query tabs-icon-search" }, null)]), m.value.length ? f("ul", { class: "tab-dropdown-menu--items", style: y() }, [m.value.map((p) => f("li", { class: k(p), onClick: (C) => w(C, p.props) }, [p.props.removeable && f("span", { class: "float-right st-drop-close", onClick: (C) => B(C, p.props.id) }, [f("i", { class: "f-icon f-icon-close" }, null)]), f("a", { class: "dropdown-title", title: p.props.title }, [p.props.title])]))]) : f("div", { class: "dropdown-no-data" }, [ke("没有相关数据")])]); } return { renderDropdownMenu: I }; } function ar(e, t, n, o) { const { hideDropDown: a } = t, { renderDropdownMenu: i } = or(e, t, n, o), l = h(e.showDropdown); function r() { return l.value && f(Ue, null, [f("button", { class: "btn dropdown-toggle-split dropdown-toggle", onClick: () => { a.value = !1; } }, null), i()]); } return { renderMorePagesButtton: r }; } function mo(e, t, n, o) { const a = h(!1), { selectTabByTabId: i, tabPages: l, needUpdateNavigationLayout: r } = o, s = 4; function c() { var b; const S = t.value, y = (b = t.value) == null ? void 0 : b.parentElement; a.value = y && S && y.offsetWidth < S.scrollWidth - s; } const u = O(() => ({ btn: !0, "sc-nav-btn": !0, "px-1": !0, "sc-nav-lr": !0, "d-none": !a.value })), d = O(() => ({ "btn-group": !0, "sc-nav-btn": !0, dropdown: !0, "d-none": !a.value })), v = O(() => ({ btn: !0, "sc-nav-rg": !0, "d-none": !a.value })); function m(S, y) { if (!t.value) return; const b = t.value.scrollLeft, T = t.value.scrollWidth - t.value.offsetWidth; if (y > 0) { if (t.value.scrollLeft >= T) return; t.value.scrollLeft = b + e.scrollStep + S; } else if (y < 0) { if (t.value.scrollLeft <= 0) return; t.value.scrollLeft = b - e.scrollStep - S; } } function g(S) { if (!a.value || !t.value) return; const y = e.tabType === "pills" ? ".f-capsule-item" : ".nav-item", b = t.value.querySelectorAll(y), { parentElement: T } = t.value, w = b[S]; if (w && T) { const B = T.getBoundingClientRect().left, I = T.getBoundingClientRect().right, p = w.getBoundingClientRect().left, C = w.getBoundingClientRect().right; p < B ? m(B - p, -1) : I < C && m(C - I, 1), e.tabType === "one-page" && n.scrollTo(S); } } function k(S, y) { if (y.disabled) return; i(y.id); const b = l.value.findIndex((T) => T.props.id === y.id); je(() => { g(b); }); } return pe(r, () => { c(); }), { previousButtonClass: u, nextButtonGroupClass: d, nextButtonClass: v, scrollTab: m, selectAndScrollToTab: k, shouldShowNavigationButtons: a, updateNavigationLayout: c }; } function go(e, t) { const { tabPages: n } = t, o = h(""), a = h(!0), i = O(() => e.searchBoxVisible), l = O(() => i.value ? n.value.filter((s) => s.props.title.includes(o.value)) : n.value.slice()); return { searchTabText: o, hideDropDown: a, shouldShowSearchBox: i, tabsInDropdownMenu: l }; } function ho(e, t, n) { const o = ".farris-tab-page", { tabPages: a } = n; function i(r) { const s = t.value; if (s) { const c = t.value.querySelectorAll(o); if (c.length > 0) { const u = c[r], { offsetTop: d } = u, v = d - 32 > 0 ? d - 32 : 0; s.scrollTop = v; } } } function l(r) { const s = a.value.findIndex((c) => c.props.id === r); s > -1 && i(s); } return { scrollTo: i, scrollToByPaggId: l }; } const _t = /* @__PURE__ */ Se({ name: "FTabs", props: wn, emits: ["tabChange", "tabRemove", "update:activeId", "Click"], setup(e, t) { const n = h(e.tabType), o = Et(), a = h(e.customClass), i = Et(), l = Et(), r = h(), s = er(e, t, i), { activeId: c, changeTitleStyle: u, tabPages: d, addTab: v, updateTab: m, selectTabByTabId: g, toolbarItems: k, checkActiveId: S } = s, y = ho(e, l, s), b = mo(e, i, y, s), { previousButtonClass: T, nextButtonClass: w, nextButtonGroupClass: B, scrollTab: I, updateNavigationLayout: p } = b, C = go(e, s), x = nr(e, i, b, y, s), F = x, _ = vo(e, i, b, y, s), j = /* @__PURE__ */ new Map([["default", x], ["one-page", F], ["pills", _]]); O(() => { const G = d.value.find((U) => U.props.id === c.value); return G == null ? void 0 : G.slots; }); const P = O(() => { const G = d.value.find((Y) => Y.props.id === c.value); return (G == null ? void 0 : G.props.toolbarPosition) === "inHead"; }), D = O(() => e.fill); Ft("tabs", { activeId: c, addTab: v, updateTab: m, tabPages: d, tabType: n, shouldFillParentContaner: D }); const M = O(() => ({ "farris-tabs-header": !0, "farris-tabs-inHead": P.value, "farris-tabs-inContent": !P.value, "farris-tabs-nav-fill": e.tabType === "fill", "farris-tabs-nav-pills": e.tabType === "pills" })), E = O(() => { const G = { width: P.value && e.titleWidth ? `${e.titleWidth}%` : "" }; return G.width && (G.flex = "unset"), G; }), V = O(() => { const G = { "farris-tabs": !0, "f-utils-fill-flex-column": D.value, "flex-column": e.position === "top", "flex-column-reverse": e.position === "bottom", "flex-row": e.position === "left", "flex-row-reverse": e.position === "right", "one-page": e.tabType === "one-page" }; return a.value && a.value.split(" ").reduce((U, Y) => (U[Y] = !0, U), G), G; }); Fe(() => { d.value.length && (S(e.activeId || d.value[0].props.id), g(c.value)), je(() => { p(); }), u(i), yn(r.value, () => { p(); }); }); function $() { return f("button", { title: "向左", type: "button", class: T.value, onClick: () => { I(0, -1); } }, null); } function R() { return f("button", { title: "向右", type: "button", class: w.value, onClick: () => { I(0, 1); } }, null); } const { renderMorePagesButtton: N } = ar(e, C, b, s), L = (G, U) => { t.emit("Click", G, U, c.value); }; function W() { return k.value.length ? f(hn, { class: "f-utils-fill", items: k.value, onClick: L }, null) : null; } const ae = j.get(e.tabType) || j.get("default"); function H() { var G, U, Y, A; return f("div", { class: M.value }, [f("div", { class: "farris-tabs-header-pre" }, [(U = (G = t.slots).headerPrefix) == null ? void 0 : U.call(G)]), f("div", { class: "farris-tabs-title scroll-tabs", style: E.value, ref: r }, [$(), ae && ae(), f("div", { class: B.value }, [R(), N()])]), W(), f("div", { class: "farris-tabs-header-post" }, [(A = (Y = t.slots).headerSuffix) == null ? void 0 : A.call(Y)])]); } const z = O(() => ({ "farris-tabs-content": !0, "f-utils-fill-flex-column": D.value })); function X() { var G, U; return f("div", { class: z.value, ref: l }, [(U = (G = t.slots).default) == null ? void 0 : U.call(G)]); } return () => f("div", { class: V.value, ref: o }, [H(), X()]); } }); function ir(e, t, n) { return t && t.contents && t.contents.length && (t.contents.forEach((o) => { o.title && (o.text = o.title); }), t.buttons = t.contents, delete t.contents), { toolbar: t }; } const lr = /* @__PURE__ */ new Map([ ["appearance", lt], ["toolbar", ir] ]), rr = "https://json-schema.org/draft/2020-12/schema", sr = "https://farris-design.gitee.io/tab-page.schema.json", ur = "tab-page", cr = "A Farris Container Component", dr = "object", fr = { 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" } }, pr = [ "id", "type", "contents" ], vr = { $schema: rr, $id: sr, title: ur, description: cr, type: dr, properties: fr, required: pr }, Sn = { tabWidth: { type: Number, default: -1 }, 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" } }, yo = Wn(Sn, vr, lr); function mr(e) { return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !Kt(e); } const Ht = /* @__PURE__ */ Se({ name: "FTabPage", props: Sn, emits: [], setup(e, t) { const n = _e("tabs"), o = h(e.show), a = { slots: t.slots, props: e }, i = h((n == null ? void 0 : n.tabType.value) || "default"); Fe(() => { const m = n == null ? void 0 : n.tabPages.value.findIndex((g) => g.props.id === e.id); !m || m === -1 ? n == null || n.addTab(a) : m > -1 && (o.value = !1, console.warn(`已经存在id为${e.id}的页签啦`)); }), pt(() => { }); const l = O(() => (e == null ? void 0 : e.id) === (n == null ? void 0 : n.activeId.value)), r = O(() => ({ display: l.value ? "" : "none" })); pe(() => e, (m) => { n == null || n.updateTab({ props: m, slots: t.slots }); }, { immediate: !0, deep: !0 }); function s() { var g, k; const m = (k = (g = t.slots).default) == null ? void 0 : k.call(g); return f(zn, { "main-title": e.title, class: "farris-tab-page" }, mr(m) ? m : { default: () => [m] }); } const c = O(() => { var g; return { "farris-tab-page": !0, "f-utils-fill-flex-column": l.value && n && ((g = n.shouldFillParentContaner) == null ? void 0 : g.value) }; }); function u() { var g, k; const m = (k = (g = t.slots).default) == null ? void 0 : k.call(g); return f("div", { class: c.value, style: r.value }, [m]); } const v = (/* @__PURE__ */ new Map([["default", u], ["one-page", s]])).get(i.value) || u; return () => o.value ? v() : null; } }); function gr(e, t, n, o, a, i) { const { activeId: l, selectTab: r, removeDesignTab: s, selectDesignTab: c, addTabPageToolbar: u } = a, d = O(() => ({ "st-tab-text": !0, "farris-title-auto": e.autoTitleWidth })), v = O(() => { const _ = { "farris-component": !0, "nav-item": !0, "f-state-active": t.id === l.value, "f-state-disabled": t.disabled }; return _[`${t.id}-design-item`] = !0, _; }), m = O(() => ({ width: `${t.tabWidth}px` })), g = O(() => ({ "nav-link": !0, "tabs-text-truncate": !0, active: t.id === l.value })); function k(_) { return f("span", { class: d.value, title: _.title }, [_.title]); } function S(_) { return _.slots.title ? _.slots.title : k; } const y = S(n), b = h(t.removeable); function T() { return f("span", { class: "st-drop-close", style: { opacity: 0.6 } }, [f("i", { class: "f-icon f-icon-close" }, null)]); } function w(_) { r(t.id), e.tabType === "one-page" && o.scrollToByPaggId(t.id); } function B(_) { _ && (_.stopPropagation(), _.preventDefault()), c(_, t.id, i.value); } function I(_) { s(_, t.id); } function p(_) { u(_, t.id); } function C() { return f("div", { role: "button", class: "btn component-settings-button", title: "删除", ref: "removeComponent", onClick: (_) => I(_) }, [f("i", { class: "f-icon f-icon-yxs_delete" }, null)]); } function x() { return f("div", { role: "button", class: "btn component-settings-button", title: "新增按钮", ref: "addComponent", onClick: (_) => p(_) }, [f("i", { class: "f-icon f-icon-plus-circle" }, null)]); } function F() { return f("div", { class: "component-btn-group", "data-noattach": "true" }, [f("div", null, [C(), !t.toolbar || !t.toolbar.buttons || !t.toolbar.buttons.length ? x() : ""])]); } return f("li", { onClick: (_) => B(_), class: v.value, style: m.value, pageId: `${t.id}-design-item` }, [F(), f("a", { class: g.value, onClick: w, id: `${t.id}-design-item` }, [y(t), b.value && T()])]); } function hr(e, t, n, o, a, i, l) { const { tabPages: r } = a, s = O(() => ({ spacer: !0, "f-utils-fill": !0 })), c = O(() => ({ width: "100%", "justify-content": e.justifyContent })), u = O(() => ({ nav: !0, "farris-nav-tabs": !0, "flex-nowrap": !0, "nav-fill": e.tabType === "fill", "nav-pills": e.tabType === "pills", "flex-row": e.position === "top" || e.position === "bottom", "flex-column": e.position === "left" || e.position === "right" })), d = O(() => ({ overflow: "auto" })), v = function(m) { var S; const g = Bt("tab-page"); g.id = `tab_page_${Math.random().toString().slice(2, 6)}`, g.title = "标题", g.toolbar = { buttons: [] }, (S = i.value.schema.contents) == null || S.push(g); const { selectTabByTabId: k } = a; k(g.id); }; return () => f("div", { class: s.value, style: c.value }, [f("ul", { class: u.value, style: d.value, ref: t }, [r.value.map((m) => gr(e, m.props, m, o, a, i)), f("li", { class: "nav-item no-drag" }, [f("a", { class: "nav-link tabs-text-truncate", title: "添加页签", onClick: (m) => v() }, [f("i", { class: "f-icon f-icon-plus", style: "font-size: 20px;margin: 0 auto;line-height: 24px;" }, null)])])])]); } function Ot(e, t, n) { var I; const o = n && n.getStyles && n.getStyles() || "", a = n && n.getDesignerClass && n.getDesignerClass() || "", i = h(); function l() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : n && n.checkCanMoveComponent ? n.checkCanMoveComponent() : !0; } function r() { return !1; } function s() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : n && n.checkCanDeleteComponent ? n.checkCanDeleteComponent() : !0; } function c() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !0 : n && n.hideNestedPaddingInDesginerView ? n.hideNestedPaddingInDesginerView() : !1; } function u(p) { if (!p || !p.value) return null; if (p.value.schema && p.value.schema.type === "component") return p.value; const C = h(p == null ? void 0 : p.value.parent), x = u(C); return x || null; } function d(p = t) { var _; if (n != null && n.getDraggableDesignItemElement) return n.getDraggableDesignItemElement(p); const { componentInstance: C, designerItemElementRef: x } = p; if (!C || !C.value) return null; const { getCustomButtons: F } = C.value; return C.value.canMove || F && ((_ = F()) != null && _.length) ? x : d(p.parent); } function v(p) { return !!n && n.canAccepts(p); } function m() { return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name); } function g() { } function k(p, C) { var x; !p || !C || (n != null && n.onAcceptMovedChildElement && n.onAcceptMovedChildElement(p, C), (x = t == null ? void 0 : t.setupContext) == null || x.emit("dragEnd")); } function S(p, C) { const { componentType: x } = p; let F = Bt(x, p, C); n && n.onResolveNewComponentSchema && (F = n.onResolveNewComponentSchema(p, F)); const _ = x.toLowerCase().replace(/-/g, "_"); return F && !F.id && F.type === x && (F.id = `${_}_${Math.random().toString().slice(2, 6)}`), F; } function y(p) { p && n != null && n.onChildElementMovedOut && n.onChildElementMovedOut(p); } function b(...p) { if (n && n.getPropsConfig) return n.getPropsConfig(...p); } function T() { n && n.onRemoveComponent && n.onRemoveComponent(), t != null && t.schema.contents && t.schema.contents.map((p) => { let C = p.id; p.type === "component-ref" && (C = p.component); const x = e.value.querySelectorAll(`#${C}-design-item`); x != null && x.length && Array.from(x).map((F) => { var _; (_ = F == null ? void 0 : F.componentInstance) != null && _.value.onRemoveComponent && F.componentInstance.value.onRemoveComponent(); }); }); } function w() { if (n && n.getCustomButtons) return n.getCustomButtons(); } function B(p) { if (n && n.onPropertyChanged) return n.onPropertyChanged(p); } return i.value = { canMove: l(), canSelectParent: r(), canDelete: s(), canNested: !c(), contents: t == null ? void 0 : t.schema.contents, elementRef: e, parent: (I = t == null ? void 0 : t.parent) == null ? void 0 : I.componentInstance, schema: t == null ? void 0 : t.schema, styles: o, designerClass: a, canAccepts: v, getBelongedComponentInstance: u, getDraggableDesignItemElement: d, getDraggingDisplayText: m, getPropConfig: b, getDragScopeElement: g, onAcceptMovedChildElement: k, onChildElementMovedOut: y, addNewChildComponentSchema: S, triggerBelongedComponentToMoveWhenMoved: !!n && n.triggerBelongedComponentToMoveWhenMoved || h(!1), triggerBelongedComponentToDeleteWhenDeleted: !!n && n.triggerBelongedComponentToDeleteWhenDeleted || h(!1), onRemoveComponent: T, getCustomButtons: w, onPropertyChanged: B }, i; } class bo { getTemplateRule(t, n) { const o = n == null ? void 0 : n.formSchemaUtils, a = o == null ? void 0 : o.getFormTemplateRule(), i = { canAccept: !0, canDelete: !0, canMove: !0 }; if (!a) return i; const l = this.getComponentContext(t), { componentClassList: r } = l; return r.forEach((s) => { if (!s || !a[s]) return; const { canMove: c, canDelete: u, canAccept: d } = a[s]; i.canMove = i.canMove && this.resolveRuleValue(c, l), i.canDelete = i.canDelete && this.resolveRuleValue(u, l), i.canAccept = i.canAccept && this.resolveRuleValue(d, l); }), i; } resolveRuleValue(t, n) { return typeof t == "boolean" ? t : this.parseRuleValueSchema(t, n); } parseRuleValueSchema(t, n) { const o = t.invalidContext || []; let a = !0; for (const i of o) { if (i.firstLevelChild) { if (i.firstLevelChild.class) { const { firstLevelChildClassList: l } = n; if (l && !l.includes(i.firstLevelChild.class)) { a = !1; continue; } } if (i.firstLevelChild.type) { const { firstLevelChildSchema: l } = n; if (!l || l.type !== i.firstLevelChild.type) { a = !1; continue; } } } if (i.secondLevelChild) { if (i.secondLevelChild.class) { const { secondLevelChildClassList: l } = n; if (l && !l.includes(i.secondLevelChild.class)) { a = !1; continue; } } if (i.secondLevelChild.type) { const { secondLevelChildSchema: l } = n; if (!l || l.type !== i.secondLevelChild.type) { a = !1; continue; } } } if (i.parent) { if (i.parent.class) { const { parentClassList: l } = n; if (l && !l.includes(i.parent.class)) { a = !1; continue; } } if (i.parent.type) { const { parentSchema: l } = n; if (l && l.type !== i.parent.type) { a = !1; continue; } } } a = !0; break; } return !a; } getComponentContext(t) { var k, S, y, b; const n = t.schema, o = n.appearance && n.appearance.class || "", a = o.split(" ") || [], i = n.contents || [], l = i.length ? i[0] : null, r = l && l.appearance ? l.appearance.class : "", s = r ? r.split(" ") : [], c = (k = l == null ? void 0 : l.contents) != null && k.length ? l == null ? void 0 : l.contents[0] : null, u = c && c.appearance ? c.appearance.class : "", d = u ? u.split(" ") : [], v = n.type === "component" ? (y = (S = t.parent) == null ? void 0 : S.parent) == null ? void 0 : y.schema : (b = t.parent) == null ? void 0 : b.schema, m = v && v.appearance && v.appearance.class || "", g = m ? m.split(" ") : []; return { componentClass: o, componentClassList: a, childContents: i, firstLevelChildSchema: l, firstLevelChildClass: r, firstLevelChildClassList: s, secondLevelChildSchema: c, secondLevelChildClass: u, secondLevelChildClassList: d, parentSchema: v, parentClass: m, parentClassList: g }; } } const yr = h(0); function br() { yr.value++; } const ht = h(0); function Cr(e, t) { const n = t.getBoundingClientRect(), o = e.getBoundingClientRect(), a = o.top >= n.top, i = o.top <= n.bottom; return a && i; } function dn(e) { const t = e.querySelector(".component-btn-group"); if (!t) return; t.style.display = ""; const n = t.getBoundingClientRect(); if (!(n.top === 0 && n.left === 0)) { const o = t.querySelector("div"); if (o) { const a = o.getBoundingClientRect(); o.style.top = n.top + "px"; let i = n.left - a.width; const l = document.querySelector(".editorDiv"); if (l) { const r = l.getBoundingClientRect(); i < r.left && ({ left: i } = e.getBoundingClientRect()); } o.style.left = i + "px"; } } } function wr(e) { if (!window.scrollContainerList) return; const t = Array.from(window.scrollContainerList); if (t.length && t.length === 1) { const n = t[0], o = document.querySelector(`[id=${n}]`); if (o && o.contains(e)) return o; } } function xn(e) { if (!e) return; const t = e.getBoundingClientRect(); if (t.width === 0 && t.height === 0) return; const n = e.querySelector(".component-btn-group"); if (n) { let o = !0; const a = wr(e); if (a && (o = Cr(e, a)), !o) { n.style.display = "none"; return; } dn(e); } } function Co(e) { if (!e) return; let t; e.className.includes("dgComponentSelected") ? t = e : t = e.querySelector(".dgComponentSelected"), t && xn(t); } class Vt { constructor(t, n) { J(this, "componentId"); J(this, "viewModelId"); J(this, "eventsEditorUtils"); J(this, "formSchemaUtils"); J(this, "formMetadataConverter"); J(this, "designViewModelUtils"); J(this, "designViewModelField"); J(this, "controlCreatorUtils"); J(this, "designerHostService"); J(this, "schemaService", null); J(this, "metadataService", null); J(this, "propertyConfig", { type: "object", categories: {} }); var o; this.componentId = t, this.designerHostService = n, this.eventsEditorUtils = n.eventsEditorUtils, this.formSchemaUtils = n.formSchemaUtils, this.formMetadataConverter = n.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.getViewModelIdByComponentId(t)) || "", this.designViewModelUtils = n.designViewModelUtils, this.controlCreatorUtils = n.controlCreatorUtils, this.metadataService = n.metadataService, this.schemaService = n.schemaService; } getTableInfo() { var t; return (t = this.schemaService) == null ? void 0 : t.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(t) { var o; const n = t.binding && t.binding.type === "Form" && t.binding.field; if (n) { if (!this.designViewModelField) { const a = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = a.fields.find((i) => i.id === n); } t.updateOn = (o = this.designViewModelField) == null ? void 0 : o.updateOn; } } getBasicPropConfig(t) { return { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "combo-list", textField: "name", valueField: "value", editable: !1, data: [{ value: t.type, name: ie[t.type].name }] } } } }; } getAppearanceConfig(t = 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(n, o) { if (n) switch (n && n.propertyID) { case "class": case "style": { ht.value++; break; } } } }; } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(t, n) { const o = n && n.parent && n.parent.schema; if (!o) return; const a = o.contents.findIndex((l) => l.id === t), i = yt(o.contents[a]); o.contents.splice(a, 1), o.contents.splice(a, 0, i), br(); } } class