UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,173 lines (1,172 loc) 39.4 kB
import { ref as N, computed as ve, onMounted as G, defineComponent as U, createVNode as E, withDirectives as _, vShow as X, Teleport as ye, Fragment as V, inject as ge } from "vue"; import { cloneDeep as x, isPlainObject as J } from "lodash-es"; import { getSchemaByTypeForDesigner as be } from "../dynamic-resolver/index.esm.js"; function I(e, t) { let n; function a(o) { const { properties: l, title: v, ignore: r } = o, i = r && Array.isArray(r), c = Object.keys(l).reduce((b, f) => ((!i || !r.find((s) => s === f)) && (b[f] = l[f].type === "object" && l[f].properties ? a(l[f]) : x(l[f].default)), b), {}); if (v && (!i || !r.find((b) => b === "id"))) { const b = v.toLowerCase().replace(/-/g, "_"); c.id = `${b}_${Math.random().toString().slice(2, 6)}`; } return c; } function T(o) { const { properties: l, title: v, required: r } = o; if (r && Array.isArray(r)) { const i = r.reduce((c, b) => (c[b] = l[b].type === "object" && l[b].properties ? a(l[b]) : x(l[b].default), c), {}); if (v && r.find((c) => c === "id")) { const c = v.toLowerCase().replace(/-/g, "_"); i.id = `${c}_${Math.random().toString().slice(2, 6)}`; } return i; } return { type: v }; } function M(o, l = {}, v) { const r = e[o]; if (r) { let i = T(r); const c = t[o]; return i = c ? c({ getSchemaByType: M }, i, l, v) : i, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(i), i; } return null; } function B(o, l) { const v = a(l); return Object.keys(v).reduce((r, i) => (Object.prototype.hasOwnProperty.call(o, i) && (r[i] && J(r[i]) && J(o[i] || !o[i]) ? Object.assign(r[i], o[i] || {}) : r[i] = o[i]), r), v), v; } function F(o, l) { return Object.keys(o).filter((r) => o[r] != null).reduce((r, i) => { if (l.has(i)) { const c = l.get(i); if (typeof c == "string") r[c] = o[i]; else { const b = c(i, o[i], o); Object.assign(r, b); } } else r[i] = o[i]; return r; }, {}); } function j(o, l, v = /* @__PURE__ */ new Map()) { const r = B(o, l); return F(r, v); } function d(o) { var v; const l = o.type; if (l) { const r = e[l]; if (!r) return o; const i = B(o, r), c = ((v = o.editor) == null ? void 0 : v.type) || ""; if (c) { const b = e[c], f = B(o.editor, b); i.editor = f; } return i; } return o; } function y(o) { n = o; } return { getSchemaByType: M, resolveSchemaWithDefaultValue: d, resolveSchemaToProps: j, mappingSchemaToProps: F, setDesignerContext: y }; } const K = {}, ee = {}, { getSchemaByType: mt, resolveSchemaWithDefaultValue: we, resolveSchemaToProps: he, mappingSchemaToProps: Se, setDesignerContext: vt } = I(K, ee); function Te(e = {}) { function t(d, y, o, l) { if (typeof o == "number") return l[d].length === o; if (typeof o == "object") { const v = Object.keys(o)[0], r = o[v]; if (v === "not") return Number(l[d].length) !== Number(r); if (v === "moreThan") return Number(l[d].length) >= Number(r); if (v === "lessThan") return Number(l[d].length) <= Number(r); } return !1; } function n(d, y, o, l) { return l[d] && l[d].propertyValue && String(l[d].propertyValue.value) === String(o); } const a = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((d, y) => (d.set(y, e[y]), d), a); function T(d, y) { const o = d; return typeof y == "number" ? [{ target: o, operator: "length", param: null, value: Number(y) }] : typeof y == "boolean" ? [{ target: o, operator: "getProperty", param: d, value: !!y }] : typeof y == "object" ? Object.keys(y).map((l) => { if (l === "length") return { target: o, operator: "length", param: null, value: y[l] }; const v = l, r = y[l]; return { target: o, operator: "getProperty", param: v, value: r }; }) : []; } function M(d) { return Object.keys(d).reduce((o, l) => { const v = T(l, d[l]); return o.push(...v), o; }, []); } function B(d, y) { if (a.has(d.operator)) { const o = a.get(d.operator); return o && o(d.target, d.param, d.value, y) || !1; } return !1; } function F(d, y) { return M(d).reduce((v, r) => v && B(r, y), !0); } function j(d, y) { const o = Object.keys(d), l = o.includes("allOf"), v = o.includes("anyOf"), r = l || v, b = (r ? d[r ? l ? "allOf" : "anyOf" : "allOf"] : [d]).map((s) => F(s, y)); return l ? !b.includes(!1) : b.includes(!0); } return { parseValueSchema: j }; } const Fe = { convertTo: (e, t, n, a) => { e.appearance || (e.appearance = {}), e.appearance[t] = n; }, convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t] }, De = { convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无" }, Be = { convertTo: (e, t, n, a) => { e.editor && (e.editor[t] = n); }, convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t] }, te = { 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: "列表导航" }, "list-view": { type: "list-view", name: "列表" }, "filter-bar": { type: "filter-bar", name: "筛选条" }, "language-textbox": { type: "language-textbox", name: "多语输入框" } }, Me = { convertFrom: (e, t, n) => { var T; const a = e.editor && e.editor[t] ? e.editor[t] : e[t]; return ((T = te[a]) == null ? void 0 : T.name) || a; } }, ke = { convertTo: (e, t, n, a) => { e[t] = e[t]; }, convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : "" }, Ee = { convertTo: (e, t, n, a) => { (e.type === "data-grid-column" || e.type === "tree-grid-column") && (e.formatter ? e.formatter[t] = n : e.formatter = { [t]: n }); }, convertFrom: (e, t, n) => { if (e.formatter) { if (t === "trueText") return e.formatter.trueText; if (t === "falseText") return e.formatter.falseText; if (t === "prefix") return e.formatter.prefix; if (t === "suffix") return e.formatter.suffix; if (t === "precision") return e.formatter.precision; if (t === "decimal") return e.formatter.decimal; if (t === "thousand") return e.formatter.thousand; if (t === "tempDateFormat") return e.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : e.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : e.formatter.tempDateFormat || e.formatter.dateFormat || "yyyy-MM-dd"; if (t === "customFormat") return e.formatter.customFormat; if (t === "type") return e.formatter.type || "none"; } return "none"; } }, Oe = { convertTo: (e, t, n, a) => { e.command ? e.command[t] = n : e.command = { [t]: n }, t === "enable" && n && (e.command.commands || (e.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ])); }, convertFrom: (e, t, n) => e.command && t === "enable" ? e.command.enable : "" }, $e = { convertTo: (e, t, n, a) => { e.column ? e.column[t] = n : e.column = { [t]: n }, t === "fitColumns" && n && (e.column.fitMode || (e.column.fitMode = "average")); }, convertFrom: (e, t, n) => { if (e.column) { if (t === "fitColumns") return e.column.fitColumns; if (t === "fitMode") return e.column.fitMode; } return ""; } }, Ne = { convertTo: (e, t, n, a) => { e.summary ? e.summary[t] = n : e.summary = { [t]: n }, t === "enable" && n && (e.summary ? e.summary.groupFields || (e.summary.groupFields = []) : e.summary = { enable: n, groupFields: [] }); }, convertFrom: (e, t, n) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : "" }, je = { convertTo: (e, t, n, a) => { e.group ? e.group[t] = n : e.group = { [t]: n }, t === "enable" && n && (e.group ? e.group.groupFields || (e.group.groupFields = []) : e.group = { enable: n, groupFields: [], showSummary: !1 }); }, convertFrom: (e, t, n) => { if (e.group) { if (t === "enable") return e.group.enable; if (t === "showSummary") return e.group.showSummary; } } }, Re = { convertFrom: (e, t) => e.binding ? e.binding.path : "", convertTo: (e, t, n) => { if (n && n.length > 0) { const a = n[0]; e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = a.bindingField, e.binding.field = a.id, e.binding.fullPath = a.path, e.path = a.bindingPath; } } }, He = { convertTo: (e, t, n, a) => { e.pagination || (e.pagination = {}), e.pagination[t] = n; }, convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t] }, Pe = { convertTo: (e, t, n, a) => { e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n; }, convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t] }, Le = { convertTo: (e, t, n, a) => { e.selection || (e.selection = {}), e.selection[t] = n; }, convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t] }, ze = { convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : "" }, Ae = { convertFrom: (e, t) => e[t] || "", convertTo: (e, t, n) => { e[t] = n; } }, Ce = { convertTo: (e, t, n, a) => { e.size || (e.size = {}), e.size[t] = n; }, convertFrom: (e, t, n) => e.size ? e.size[t] : e[t] }, We = { convertFrom: (e, t, n) => { var a, T; return (a = e.formatter) != null && a.data && t === "formatterEnumData" && !e.formatterEnumData ? (T = e.formatter) == null ? void 0 : T.data : e.formatterEnumData; } }, qe = { convertTo: (e, t, n, a) => { e.sort || (e.sort = {}), e.sort[t] = n; }, convertFrom: (e, t, n) => { var a, T; if (t === "mode") return ((a = e.sort) == null ? void 0 : a.mode) || "client"; if (t === "multiSort") return !!((T = e.sort) != null && T.multiSort); } }, _e = { convertTo: (e, t, n, a) => { e.filter || (e.filter = {}), e.filter[t] = n; }, convertFrom: (e, t, n) => { var a; if (t === "mode") return ((a = e.filter) == null ? void 0 : a.mode) || "client"; } }, Xe = { convertTo: (e, t, n, a) => { e.rowOption ? e.rowOption[t] = n : e.rowOption = { [t]: n }; }, convertFrom: (e, t, n) => { if (e.rowOption) { if (t === "customRowStyle") return e.rowOption.customRowStyle; if (t === "customCellStyle") return e.rowOption.customCellStyle; } return ""; } }; function ne(e, t, n) { const a = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", Fe], ["/converter/buttons.converter", De], ["/converter/property-editor.converter", Be], ["/converter/items-count.converter", ze], ["/converter/type.converter", Me], ["/converter/change-editor.converter", ke], ["/converter/change-formatter.converter", Ee], ["/converter/column-command.converter", Oe], ["/converter/column-option.converter", $e], ["/converter/summary.converter", Ne], ["/converter/group.converter", je], ["/converter/form-group-label.converter", Ae], ["/converter/field-selector.converter", Re], ["/converter/pagination.converter", He], ["/converter/row-number.converter", Pe], ["/converter/grid-selection.converter", Le], ["/converter/size.converter", Ce], ["/converter/change-formatter-enum.converter", We], ["/converter/grid-sort.converter", qe], ["/converter/grid-filter.converter", _e], ["/converter/row-option.converter", Xe] ]), T = /* @__PURE__ */ new Map([ ["string", { type: "input-group", enableClear: !1 }], ["boolean", { type: "combo-list", textField: "name", valueField: "value", idField: "value", enableClear: !1, editable: !1, data: [ { value: !0, name: "是" }, { value: !1, name: "否" } ] }], ["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }], ["array", { type: "button-edit" }], ["number", { type: "number-spinner", placeholder: "" }], ["events-editor", { type: "events-editor", hide: !0 }] ]), M = Te(); function B(r, i) { return () => M.parseValueSchema(r, i); } function F(r, i, c) { return r.includes("visible") && i.visible !== void 0 ? typeof i.visible == "boolean" ? () => !!i.visible : i.visible === void 0 ? !0 : B(i.visible, c) : () => !0; } function j(r, i, c) { return r.includes("readonly") && i.readonly !== void 0 ? typeof i.readonly == "boolean" ? () => !!i.readonly : B(i.readonly, c) : () => !1; } function d(r, i) { const c = r.$converter || i; return typeof c == "string" && c && a.has(c) ? a.get(c) || null : c || null; } function y(r, i, c, b, f, s = "", k = "") { return Object.keys(r).map((w) => { const $ = N(1), O = w, p = r[w], R = Object.keys(p), L = p.title, u = p.type, g = T.get(u) || { type: "input-group", enableClear: !1 }, m = p.editor ? Object.assign({}, g, p.editor) : Object.assign({}, g), h = F(R, p, i), S = j(R, p, i); m.readonly = m.readonly === void 0 ? S() : m.readonly; const H = p.type === "cascade" ? y(p.properties, i, c, b, f, s, k) : [], C = !0; let P = d(p, k); const z = ve({ get() { if ($.value) { if (["class", "style"].find((me) => me === O) && !P && (P = a.get("/converter/appearance.converter") || null), P && P.convertFrom) return P.convertFrom(c, w, f, s); const A = c[w]; return Object.prototype.hasOwnProperty.call(p, "defaultValue") && (A === void 0 || typeof A == "string" && A === "") ? p.type === "boolean" ? p.defaultValue : p.defaultValue || "" : A; } return null; }, set(A) { $.value += 1, P && P.convertTo ? (P.convertTo(b, w, A, f, s), P.convertTo(c, w, A, f, s)) : (b[w] = A, c[w] = A); } }), { refreshPanelAfterChanged: W, description: fe, isExpand: pe, parentPropertyID: de } = p, Z = { propertyID: O, propertyName: L, propertyType: u, propertyValue: z, editor: m, visible: h, readonly: S, cascadeConfig: H, hideCascadeTitle: C, refreshPanelAfterChanged: W, description: fe, isExpand: pe, parentPropertyID: de }; return i[O] = Z, Z; }); } function o(r, i, c = {}) { const b = {}, f = e[r]; return f && f.categories ? Object.keys(f.categories).map((k) => { const D = f.categories[k], w = D == null ? void 0 : D.title, $ = y(D.properties || {}, b, {}, c, i); return { categoryId: k, categoryName: w, properties: $ }; }) : []; } function l(r, i, c, b, f = "") { const s = i.$ref.schema, k = i.$ref.converter, D = c[s], w = D.type, $ = n(D), O = {}, p = e[w]; if (p && p.categories) { const R = p.categories[r], L = R == null ? void 0 : R.title; k && Object.keys(R.properties).forEach((m) => { R.properties[m].$converter = k; }); const u = (R == null ? void 0 : R.properties) || {}, g = y(u, O, $, D, b, f); return { categoryId: r, categoryName: L, properties: g }; } return { categoryId: r, categoryName: "", properties: [] }; } function v(r, i, c, b, f) { const s = r.type, k = n(r), D = {}; let w = f || e[s]; if (w && Object.keys(w).length === 0 && c && c.getPropConfig && (w = c.getPropConfig(b)), w && w.categories) { const $ = []; return Object.keys(w.categories).map((O) => { const p = w.categories[O]; if (p.$ref) { $.push(l(O, p, r, i, b)); return; } const R = p == null ? void 0 : p.title, L = p == null ? void 0 : p.tabId, u = p == null ? void 0 : p.tabName, g = p == null ? void 0 : p.hide, m = p == null ? void 0 : p.hideTitle, h = y(p.properties || {}, D, k, r, i, b, p.$converter), { setPropertyRelates: S } = p, H = p == null ? void 0 : p.parentPropertyID; $.push({ categoryId: O, categoryName: R, tabId: L, tabName: u, hide: g, properties: h, hideTitle: m, setPropertyRelates: S, parentPropertyID: H }); }), $; } return []; } return { getPropertyConfigBySchema: v, getPropertyConfigByType: o, propertyConverterMap: a }; } const oe = {}, re = {}; ne(oe, re, we); const ie = {}, ae = {}, { getSchemaByType: yt, resolveSchemaWithDefaultValue: Ge, resolveSchemaToProps: gt, mappingSchemaToProps: bt, setDesignerContext: wt } = I(ie, ae), se = {}, le = {}; ne(se, le, Ge); function Ue(e, t, n = /* @__PURE__ */ new Map(), a = (B, F, j, d) => F, T = {}, M = (B) => B) { return K[t.title] = t, ee[t.title] = a, oe[t.title] = T, re[t.title] = M, ie[t.title] = t, ae[t.title] = a, se[t.title] = T, le[t.title] = M, (B = {}, F = !0) => { if (!F) return Se(B, n); const j = he(B, t, n), d = Object.keys(e).reduce((y, o) => (y[o] = e[o].default, y), {}); return Object.assign(d, j); }; } function Ye(e, t) { return { customClass: t.class, customStyle: t.style }; } function Ze(e, t, n) { return t; } const xe = /* @__PURE__ */ new Map([ ["appearance", Ye] ]), Je = "https://json-schema.org/draft/2020-12/schema", Qe = "https://farris-design.gitee.io/dropdown.schema.json", Ve = "dropdown", Ie = "A Farris Component", Ke = "object", et = { id: { description: "The unique identifier for dropdown", type: "string" }, type: { description: "The type string of dropdown", type: "string", default: "dropdown" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, disable: { type: "string", default: !1 }, editable: { description: "", type: "boolean", default: !0 }, placeholder: { description: "", type: "string", default: "" }, readonly: { description: "", type: "boolean", default: !1 }, require: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, visible: { description: "", type: "boolean", default: !0 } }, tt = [ "id", "type" ], nt = { $schema: Je, $id: Qe, title: Ve, description: Ie, type: Ke, properties: et, required: tt }, ot = "dropdown", rt = "A Farris Component", it = "object", at = { basic: { description: "Basic Infomation", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "waiting for modification", enum: [] } } } }, behavior: { description: "Basic Infomation", title: "行为", properties: { readonly: { description: "", title: "只读", type: "string" }, required: { description: "", title: "必填", type: "boolean" }, visible: { description: "", title: "可见", type: "boolean" }, placeholder: { description: "", title: "提示文本", type: "string" }, tabindex: { description: "", title: "tab索引", type: "number" } } } }, st = { title: ot, description: rt, type: it, categories: at }, Y = { /** 默认展开或折叠 * 注意: * 1、这个属性在出现滚动条的情况下,滚动会导致收折,看不到展开的面板。 * 2、如果是放置在没有滚动条的界面,可有实际效果 */ show: { type: Boolean, default: !1 }, /** 下拉按钮是否禁用 */ disabled: { type: Boolean, default: !1 }, /** 下拉按钮对应文字 */ title: { type: String, default: "下拉示例" }, /** 下拉按钮大小 */ size: { type: String, default: "" }, /** 下拉按钮类型 */ type: { type: String, default: "primary" }, /** 图标样式 */ iconClass: { type: String, default: "" }, /** 下拉框内容是否被选中 * ---未被使用 */ active: { type: Boolean, default: !1 }, /** 下拉按钮是否分开展示 */ splitButton: { type: Boolean, default: !1 }, /** 下拉框展示方向 */ position: { type: String, default: "bottom" }, /** 下拉框内容 */ model: { type: Array, default: [ { label: "项目一", value: "XM1" }, { label: "项目二", value: "XM2" }, { label: "项目三", value: "XM3" } ] }, onSelect: { type: Function, default: () => { } } }, Q = Ue(Y, nt, xe, Ze, st); function ce(e, t) { let n; const a = N(e.show), T = N(), M = N(), B = N(), F = 10; G(() => { n = M.value; }); const j = (f = 1) => { const s = [ "body>.f-datagrid-settings-simple-host", "body>div", "body>farris-dialog>.farris-modal.show", "body>.farris-modal.show", "body>farris-filter-panel>.f-filter-panel-wrapper", "body .f-sidebar-show>.f-sidebar-main", "body>.popover.show", "body>filter-row-panel>.f-datagrid-filter-panel", "body>.f-section-maximize" ], k = Array.from(document.body.querySelectorAll(s.join(","))).filter((w) => w).map((w) => { const { display: $, zIndex: O } = window.getComputedStyle(w); return $ === "none" ? 0 : parseInt(O, 10); }).filter((w) => w); let D = Math.max(...k); return D < 1040 && (D = 1040), D + f; }, d = (f, s) => { const { height: k, left: D, top: w, width: $ } = f.getBoundingClientRect(), { width: O, height: p, top: R } = s.getBoundingClientRect(); if (f.className.indexOf("dropdown-submenu") > -1 || f.closest(".dropdown-submenu") || f.classList.contains("dropright")) { const u = window.innerWidth - D - f.offsetWidth, g = window.innerHeight - w, { position: m } = getComputedStyle(s); if (m === "fixed") { let h = D + f.offsetWidth; s.offsetWidth > u && D > u && (h = D - O), s.style.left = h + "px", s.style.right = "auto", window.innerHeight - 2 * F < s.offsetHeight ? (s.style.top = F + "px", s.style.bottom = F + "px", s.style.maxHeight = window.innerHeight - 2 * F + "px", s.style.overflowY = "auto", s.className += " dropdown-menu-maxheight") : g < s.offsetHeight ? (s.style.top = "auto", s.style.bottom = F + "px") : (s.style.top = w + "px", s.style.bottom = "auto"); } else { if (s.offsetWidth > u) { const h = -O; s.style.left = h + "px"; } window.innerHeight - 2 * F < s.offsetHeight ? (s.style.top = -1 * (w - F) + "px", s.style.bottom = "auto", s.style.maxHeight = window.innerHeight - 2 * F + "px", s.style.overflowY = "auto", s.className += " dropdown-menu-maxheight") : g < s.offsetHeight && (s.style.top = g - s.offsetHeight - F + "px", s.style.bottom = "auto"); } } else { const { marginTop: u, marginBottom: g } = getComputedStyle(s); let m = 0; const h = Math.ceil(parseFloat(u)) + Math.ceil(parseFloat(g)); let S = w + k, H = D; window.innerHeight - S - h < p && (S = w - p, S < 0 && (window.innerHeight - w - k > w ? (S = w + k, m = window.innerHeight - S - h - F) : (S = F, m = w - S - h))), window.innerWidth - D < O && window.innerWidth - D < D + $ && (H = D - O + $), document.body.append(s), s.style.cssText = `position:fixed;bottom:unset;left:${H}px !important;top:${S}px !important;right: unset;${m ? "max-height:" + m + "px;overflow-y:auto;" : ""}`, m && (s.className += " dropdown-menu-maxheight"), s.style.zIndex = j().toString(); } }, y = () => { d(T.value, M.value); }, o = () => { e.hover || (a.value = !1, M.value.style = null, document.removeEventListener("click", o), n.removeEventListener("click", o), document.removeEventListener("scroll", o), n.removeEventListener("scroll", o)); }, l = (f = null, s = !1) => { e.hover || e.disabled || (f == null || f.stopPropagation(), s ? (setTimeout(() => { y(); }), a.value = !0) : (a.value || setTimeout(() => { y(); }), a.value = !a.value), document.addEventListener("click", o), document.addEventListener("scroll", o), e.hideOnClick || (n.addEventListener("click", (k) => { k.stopPropagation(); }), n.addEventListener("scroll", (k) => { k.stopPropagation(); }))); }; return { show: a, dropdownRef: T, dropdownMenuRef: M, clickEventRef: B, showDropMenu: (f) => { l(f, !1); }, showDropMenuByForce: l, hoverDropdown: (f) => { e.hover && (a.value || setTimeout(() => { }), a.value = !a.value); }, leftButtonClick: () => { }, closeDropMenu: o, selectItem: (f) => { t.emit("select", f); }, resolveSize: (f) => { const s = /px|em|rem|pt|%/; return s.test(f) ? `${parseInt(f, 10)}${f.match(s)[0]}` : `${f}px`; } }; } const lt = { /** 下拉框标签 */ label: { type: String, default: "XM1" }, /** 下拉框名称 */ value: { type: String || Number, default: "项目一" }, /** 是否禁用该下拉框属性 */ disabled: { type: Boolean, default: !1 }, active: { type: Boolean, default: !1 }, divide: { type: Boolean, default: !1 }, onSelect: { type: Function, default: () => { } } }, ue = /* @__PURE__ */ U({ name: "FDropdownItem", props: lt, emits: ["select"], setup(e, t) { const n = N(e.value), a = N(e.label), T = N(e.disabled), M = N(e.active), B = N(e.divide), F = () => { T.value || t.emit("select", e); }; return () => E("div", null, [_(E("div", { class: "dropdown-divider" }, null), [[X, B.value]]), E("li", { class: `dropdown-item${M.value ? " active" : ""} ${T.value ? " disabled" : ""}`, onClick: F, title: n.value.toString() }, [a.value])]); } }), q = /* @__PURE__ */ U({ name: "FDropdown", props: Y, emits: ["select"], setup(e, t) { const n = N(e.model), { show: a, dropdownMenuRef: T, dropdownRef: M, clickEventRef: B, showDropMenu: F, hoverDropdown: j, leftButtonClick: d, showDropMenuByForce: y, closeDropMenu: o, selectItem: l, resolveSize: v } = ce(e, t); function r(c) { o(), t.emit("select", c); } function i() { return [{ "dropdown-item": e.nest }, { "btn-lg": e.size === "large" }, { "btn-sm": e.size === "small" }, { "btn-primary": e.type === "primary" }, { "btn-success": e.type === "success" }, { "btn-warning": e.type === "warning" }, { "btn-danger": e.type === "danger" }, { "btn-info": e.type === "info" }, { "btn-secondary": e.type === "secondary" }, { "btn-link": e.type === "link" }, { disabled: e.disabled }]; } return G(() => { a.value && y(null, !0); }), () => E("div", { ref: M }, [E("div", { class: ["farris-dropdown", "btn-group", { dropup: e.position === "top" }, { dropdown: e.position === "bottom" }, { dropleft: e.position === "left" }, { dropright: e.position === "right" }] }, [e.splitButton && E("span", { class: ["btn", ...i()], style: "width:100%", onClick: d }, [e.title]), E("span", { ref: B, class: ["dropdown-toggle", { btn: !e.nest }, { "dropdown-toggle-split": e.splitButton }, ...i()], style: "width:100%", onClick: F, onMouseenter: j, onMouseleave: j }, [e.splitButton ? "" : e.title, e.iconClass && E("span", { class: `f-icon ${e.iconClass}` }, null)]), E(ye, { to: "body" }, { default: () => [E("div", { ref: T, class: `dropdown-menu${a.value ? " show" : ""}` }, [E(V, null, [n.value.map(({ label: c, value: b, disabled: f, active: s, divide: k }) => E(ue, { value: b.toString(), label: c, disabled: f, active: s, divide: k, onSelect: (D) => r(D) }, null))])])] })])]); } }); function ct(e, t, n) { var L; const a = "", T = "", M = N(); let B; function F() { return (t == null ? void 0 : t.schema.componentType) !== "frame"; } function j() { return !1; } function d() { return (t == null ? void 0 : t.schema.componentType) !== "frame"; } function y() { return (t == null ? void 0 : t.schema.componentType) === "frame"; } function o(u) { if (!u || !u.value) return null; if (u.value.schema && u.value.schema.type === "component") return u.value; const g = N(u == null ? void 0 : u.value.parent), m = o(g); return m || null; } function l(u = t) { var S; const { componentInstance: g, designerItemElementRef: m } = u; if (!g || !g.value) return null; const { getCustomButtons: h } = g.value; return g.value.canMove || h && ((S = h()) != null && S.length) ? m : l(u.parent); } function v(u) { return !!n; } function r() { return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name); } function i() { } function c(u, g) { var m; !u || !g || (m = t == null ? void 0 : t.setupContext) == null || m.emit("dragEnd"); } function b(u, g) { const { componentType: m } = u; let h = be(m, u, g); const S = m.toLowerCase().replace(/-/g, "_"); return h && !h.id && h.type === m && (h.id = `${S}_${Math.random().toString().slice(2, 6)}`), h; } function f(u) { } function s(...u) { } function k(u) { if (!u) return; const g = t == null ? void 0 : t.schema, { formSchemaUtils: m } = u; if (g && m.getExpressions().length) { const h = m.getExpressions().findIndex((S) => S.target === g.id); h > -1 && m.getExpressions().splice(h, 1); } } function D(u) { if (!u || !(t != null && t.schema)) return; const g = t.schema, { formSchemaUtils: m } = u; m.removeCommunicationInComponent(g); } function w(u) { k(u), D(u), t != null && t.schema.contents && t.schema.contents.map((g) => { let m = g.id; g.type === "component-ref" && (m = g.component); const h = e.value.querySelectorAll(`#${m}-design-item`); h != null && h.length && Array.from(h).map((S) => { var H; (H = S == null ? void 0 : S.componentInstance) != null && H.value.onRemoveComponent && S.componentInstance.value.onRemoveComponent(u); }); }); } function $() { } function O(u) { var m, h; if (!((m = t == null ? void 0 : t.schema) != null && m.id)) return; !B && u && (B = u.formSchemaUtils); let g = ""; { const { text: S, title: H, label: C, mainTitle: P, name: z, type: W } = t.schema; g = S || H || C || P || z || ((h = te[W]) == null ? void 0 : h.name); } g && B.getControlBasicInfoMap().set(t.schema.id, { componentTitle: g, parentPathName: g }); } function p(u) { var S; const { changeObject: g } = u, { propertyID: m, propertyValue: h } = g; if (["text", "title", "label", "name", "mainTitle"].includes((S = u == null ? void 0 : u.changeObject) == null ? void 0 : S.propertyID) && m && h && (O(), B)) { const H = B.getControlBasicInfoMap(), C = H.keys().toArray().filter((P) => { var z, W; return ((z = H.get(P)) == null ? void 0 : z.reliedComponentId) === ((W = t == null ? void 0 : t.schema) == null ? void 0 : W.id); }); C != null && C.length && C.forEach((P) => { const z = H.get(P).parentPathName.split(" > "); z[0] = h, H.get(P).parentPathName = z.join(" > "); }); } } function R(u) { p(u); } return M.value = { canMove: F(), canSelectParent: j(), canDelete: d(), canNested: !y(), contents: t == null ? void 0 : t.schema.contents, elementRef: e, parent: (L = t == null ? void 0 : t.parent) == null ? void 0 : L.componentInstance, schema: t == null ? void 0 : t.schema, styles: a, designerClass: T, canAccepts: v, getBelongedComponentInstance: o, getDraggableDesignItemElement: l, getDraggingDisplayText: r, getPropConfig: s, getDragScopeElement: i, onAcceptMovedChildElement: c, onChildElementMovedOut: f, addNewChildComponentSchema: b, triggerBelongedComponentToMoveWhenMoved: N(!1), triggerBelongedComponentToDeleteWhenDeleted: N(!1), onRemoveComponent: w, getCustomButtons: $, onPropertyChanged: R, setComponentBasicInfoMap: O, updateContextSchema: t == null ? void 0 : t.updateContextSchema }, M; } const ut = /* @__PURE__ */ U({ name: "FDropdownDesign", props: Y, emits: ["select"], setup(e, t) { const n = N(e.model), { show: a, showDropMenu: T, hoverDropdown: M, leftButtonClick: B, closeDropMenu: F, selectItem: j, resolveSize: d } = ce(e, t); function y(r) { t.emit("select", r); } const o = N(), l = ge("design-item-context"), v = ct(o, l); return G(() => { o.value.componentInstance = v; }), t.expose(v.value), () => E("div", { ref: o }, [E("div", { class: ["farris-dropdown", "btn-group", { dropup: e.position === "top" }, { dropdown: e.position === "bottom" }, { dropleft: e.position === "left" }, { dropright: e.position === "right" }], style: { width: e.width } }, [e.splitButton && E("span", { class: ["btn", { "dropdown-item": e.nest }, { "btn-lg": e.size === "large" }, { "btn-sm": e.size === "small" }, { "btn-primary": e.type === "primary" }, { "btn-success": e.type === "success" }, { "btn-warning": e.type === "warning" }, { "btn-danger": e.type === "danger" }, { "btn-info": e.type === "info" }], style: "width:100%", onClick: B }, [e.title]), E("span", { class: ["dropdown-toggle", { btn: !e.nest }, { "dropdown-item": e.nest }, { "dropdown-toggle-split": e.splitButton }, { "btn-lg": e.size === "large" }, { "btn-sm": e.size === "small" }, { "btn-primary": e.type === "primary" }, { "btn-success": e.type === "success" }, { "btn-warning": e.type === "warning" }, { "btn-danger": e.type === "danger" }, { "btn-info": e.type === "info" }, { "btn-secondary": e.type === "secondary" }, { "btn-link": e.type === "link" }, { disabled: e.disabled }], style: "width:100%", onClick: T, onMouseenter: M, onMouseleave: M }, [_(E("span", { class: "sr-only" }, null), [[X, e.splitButton]]), e.splitButton ? "" : e.title, _(E("span", { class: `f-icon ${e.iconClass.toString()}` }, null), [[X, e.iconClass]])]), E("div", { class: `dropdown-menu${a.value ? " show" : ""}` }, [E(V, null, [n.value.map(({ label: r, value: i, disabled: c, active: b, divide: f }) => E(ue, { value: i.toString(), label: r, disabled: c, active: b, divide: f, onSelect: (s) => y(s) }, null))])])])]); } }), ht = { install(e) { e.component(q.name, q); }, register(e, t, n, a) { e.dropdown = q, t.dropdown = Q; }, registerDesigner(e, t, n) { e.dropdown = ut, t.dropdown = Q; } }; export { q as Dropdown, ht as default, Y as dropdownProps, Q as propsResolver };