UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,643 lines 280 kB
var dn = Object.defineProperty; var fn = (e, t, n) => t in e ? dn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var te = (e, t, n) => fn(e, typeof t != "symbol" ? t + "" : t, n); import { defineComponent as q, ref as d, computed as M, createVNode as i, Teleport as ct, createApp as qe, onUnmounted as Oe, Fragment as re, watch as H, nextTick as oe, onBeforeMount as yn, onMounted as J, watchEffect as mn, Transition as dt, shallowRef as pn, render as Le, h as vn, cloneVNode as hn, mergeProps as he, inject as _, withDirectives as ft, vShow as gn, onUpdated as Ue, onBeforeUnmount as yt, createTextVNode as G, provide as mt, vModelText as bn, reactive as le, getCurrentInstance as Cn } from "vue"; import { createPropsResolver as fe, resolveAppearance as Ye, getPropsResolverGenerator as xn } from "../dynamic-resolver/index.esm.js"; import { LocaleService as Q } from "../locale/index.esm.js"; import { isMobilePhone as kn, getMaxZIndex as nt, useGuid as wn, FormSchemaEntityFieldType$Type as we, withInstall as Ge, getCustomClass as Fn, getCustomStyle as Sn } from "../common/index.esm.js"; import { InputBaseProperty as Tn } from "../property-panel/index.esm.js"; import Bn from "../tags/index.esm.js"; import { debounce as pt, isUndefined as Mn, cloneDeep as pe } from "lodash-es"; import On from "../popover/index.esm.js"; import vt, { FButtonEdit as ht } from "../button-edit/index.esm.js"; import En from "../list-view/index.esm.js"; import Dn from "../../designer/button-edit/index.esm.js"; import { useDesignerComponent as Xe, useDragulaCommonRule as Pn } from "../designer-canvas/index.esm.js"; import gt from "../tree-view/index.esm.js"; import In from "../event-parameter/index.esm.js"; import { FInputGroup as Nn } from "../input-group/index.esm.js"; const Rn = "https://json-schema.org/draft/2020-12/schema", jn = "https://farris-design.gitee.io/field-selector.schema.json", Vn = "field-selector", Ln = "A Farris Input Component", zn = "object", An = { disabled: { description: "", type: "boolean", default: !1 }, readonly: { description: "", type: "boolean", default: !1 }, modelValue: { description: "", type: "string", default: "" }, repositoryToken: { description: "", type: "object", default: null }, fields: { description: "", type: "array", default: null }, editorParams: { type: "object", default: null }, displayText: { description: "", type: "string", default: "" }, enableClear: { description: "", type: "boolean", default: !0 }, beforeOpen: { description: "", type: "function", default: null }, onSubmitModal: { description: "", type: "function", default: null } }, Hn = { $schema: Rn, $id: jn, title: Vn, description: Ln, type: zn, properties: An }, bt = { disabled: { type: Boolean, default: !1 }, readonly: { type: Boolean, default: !1 }, enableClear: { type: Boolean, default: !0 }, displayText: { type: String, default: "" }, enableExpress: { type: Boolean, default: !1 }, modelValue: { type: String, default: "" }, insertType: { type: String, default: "below" // 'above'|'below' }, fields: { type: Array, default: [] }, repositoryToken: { type: Object, default: null }, editorParams: { type: Object, default: null }, onSubmitModal: { type: Function, default: null }, beforeOpen: { type: Function, default: null } }, $n = fe(bt, Hn), Wn = { /** * 组件标识 */ id: { type: String, default: "" }, /** * 扩展按钮显示内容,这是一段现在扩展按钮中的html标签 */ buttonContent: { type: String, default: '<i class="f-icon f-icon-lookup"></i>' }, buttonBehavior: { type: String, default: "Popup" }, /** * 启用输入框自动完成功能 */ autoComplete: { type: Boolean, default: !1 }, /** * 组件自定义样式 */ customClass: { type: String, default: "" }, /** * 禁用组件,既不允许在输入框中录入,也不允许点击扩展按钮。 */ disable: { type: Boolean, default: !1 }, /** * 允许在输入框中录入文本。 */ editable: { type: Boolean, default: !0 }, /** * 显示清空文本按钮 */ enableClear: { type: Boolean, default: !1 }, /** * 组件值 */ modelValue: { type: String, default: "" }, /** * 将组件设置为只读,既不允许在输入框中录入,也不允许点击扩展按钮,但是允许复制输入框中的内容。 */ readonly: { type: Boolean, default: !1 }, /** * 禁用组件时,是否显示扩展按钮 */ showButtonWhenDisabled: { type: Boolean, default: !1 }, /** * 鼠标悬停在组件上时显示文本框内容。 */ enableTitle: { type: Boolean, default: !1 }, /** * 输入框类型 */ inputType: { type: String, default: "text" }, /** * 显示输入框提示信息 */ forcePlaceholder: { type: Boolean, default: !1 }, /** * 输入框提示文本 */ placeholder: { type: String, default: "" }, /** * 输入框最小长度 */ minLength: Number, /** * 输入框最大长度 */ maxLength: { type: Number }, /** * 输入框Tab键索引 */ tabIndex: Number, popupHost: { type: Object }, popupRightBoundary: { type: Object }, popupOffsetX: { type: Object }, popupOnInput: { type: Boolean, default: !1 }, popupOnFocus: { type: Boolean, default: !1 }, popupOnClick: { type: Boolean, default: !1 }, /** * 样式追加到弹出窗口 */ popupClass: { type: String, default: "" }, popupMinWidth: { type: Number, default: 160 }, modalOptions: { type: Object, default: {} }, wrapText: { type: Boolean, default: !1 }, /** * 可选,是否支持多选 * 默认`false` */ multiSelect: { type: Boolean, default: !1 }, /** * 可选,分隔符 * 默认`,` */ separator: { type: String, default: "," }, /** 对齐方式 */ textAlign: { type: String, default: "left" }, /** * 废弃 */ beforeClickButton: { type: Function, default: null }, /** * 作为内嵌编辑器被创建后默认获得焦点 */ focusOnCreated: { type: Boolean, default: !1 }, /** * 作为内嵌编辑器被创建后默认选中文本 */ selectOnCreated: { type: Boolean, default: !1 }, /** * 打开前 */ beforeOpen: { type: Function, default: null }, /** 更新方式 blur | change */ updateOn: { type: String, default: "change" }, keepWidthWithReference: { type: Boolean, default: !0 }, placement: { type: String, default: "bottom-left" }, /** * 根据空间大小重新调整,原下拉面板内容指定的高度 */ limitContentBySpace: { type: Boolean, default: !1 }, beforeClosePopup: { type: Function, default: null } }, qn = { popupContentPosition: { type: Object, default: { left: 0, top: 0 } }, host: { type: Object }, backgroundColor: { type: String, default: "" } }, Un = /* @__PURE__ */ q({ name: "FOverlay", props: qn, emits: ["click"], setup(e, t) { const n = d(e.popupContentPosition), a = d(e.host), l = M(() => ({ backgroundColor: e.backgroundColor || "", pointerEvents: "auto" })); function o(c) { t.emit("click"), c.preventDefault(), c.stopPropagation(); } M(() => { const c = a.value; if (c) { const f = c.getBoundingClientRect(), { left: v, top: b, height: y } = f; return { left: v, top: b + y }; } return n.value; }); const r = M(() => ({ // position: 'relative', // left: `${position.value.left}px`, // top: `${position.value.top}px` })); return () => i(ct, { to: "body" }, { default: () => { var c, f; return [i("div", { class: "overlay-container", onClick: (v) => o(v), style: l.value }, [i("div", { style: r.value }, [(f = (c = t.slots).default) == null ? void 0 : f.call(c)])])]; } }); } }); function Yn(e) { if (e.content && e.content.render) return e.content.render; if (e.render && typeof e.render == "function") return e.render; } function Gn(e) { const t = document.createElement("div"); t.style.display = "contents"; let n; const a = e.onClickCallback || (() => { }), l = () => { a(), n && n.unmount(); }; return n = qe({ setup() { Oe(() => { document.body.removeChild(t); }); const o = Yn(e); return () => i(Un, { "popup-content-position": e.popupPosition, host: e.host, onClick: l, backgroundColor: e.backgroundColor }, { default: () => [o && o()] }); } }), document.body.appendChild(t), n.mount(t), n; } class Xn { static show(t) { return Gn(t); } } const Kn = { /** * 允许点击遮罩关闭对话框 */ allowClickMaskToClose: { type: Boolean, default: !1 }, /** * 关闭对话框前事件, 是个函数,返回true或者false */ beforeClose: { type: Function, default: () => !0 }, /** * 自定义类 */ class: { type: String, default: "" }, /** * 自定义遮罩类 */ maskClass: { type: String, default: "" }, /** * 模态框标题 */ title: { type: String, default: "" }, /** * 模态框宽度 */ width: { type: Number, default: 500 }, /** * 模态框高度 */ height: { type: Number, default: 320 }, /** * 自定义按钮列表 */ buttons: { type: Array, default: [] }, /** * 是否展示模态框 */ modelValue: { type: Boolean, default: !1 }, /** * 是否模态 */ mask: { type: Boolean, default: !0 }, /** * 是否展示头部 */ showHeader: { type: Boolean, default: !0 }, /** * 是否展示默认按钮 */ showButtons: { type: Boolean, default: !0 }, /** * 是否启用自适应样式 */ fitContent: { type: Boolean, default: !0 }, /** * 是否展示右上角按钮 */ showCloseButton: { type: Boolean, default: !0 }, showMaxButton: { type: Boolean, default: !1 }, minHeight: { type: Number }, maxHeight: { type: Number }, minWidth: { type: Number }, maxWidth: { type: Number }, containment: { type: Object, default: null }, resizeable: { type: Boolean, default: !1 }, draggable: { type: Boolean, default: !1 }, dragHandle: { type: Object, default: null }, closedCallback: { type: Function, default: null }, openedCallback: { type: Function, default: null }, // 窗口打开后的回调函数 resizeHandle: { type: Function, default: null }, render: { type: Function, default: null }, acceptCallback: { type: Function, default: null }, rejectCallback: { type: Function, default: null }, enableEsc: { type: Boolean, default: !0 }, enableEnter: { type: Boolean, default: !1 }, dialogType: { type: String, default: "" }, src: { type: String, default: "" }, footerHeight: { type: Number, default: 60 }, host: { type: Object, default: "body" }, isMessager: { type: Boolean, default: !1 }, maximized: { type: Boolean, default: !1 } }; class X { constructor(t, n) { this.x = t, this.y = n; } static getTransformInfo(t) { const a = window.getComputedStyle(t).getPropertyValue("transform").replace(/[^-\d,]/g, "").split(","); if (a.length >= 6) { const l = parseInt(a[4], 10), o = parseInt(a[5], 10); return { x: l, y: o }; } return { x: 0, y: 0 }; } static fromEvent(t, n = null) { if (this.isMouseEvent(t)) return new X(t.clientX, t.clientY); if (n === null || t.changedTouches.length === 1) return new X(t.changedTouches[0].clientX, t.changedTouches[0].clientY); for (let a = 0; a < t.changedTouches.length; a++) if (t.changedTouches[a].target === n) return new X(t.changedTouches[a].clientX, t.changedTouches[a].clientY); } static isMouseEvent(t) { return Object.prototype.toString.apply(t).indexOf("MouseEvent") === 8; } static isIPosition(t) { return !!t && "x" in t && "y" in t; } static getCurrent(t) { const n = new X(0, 0); if (window) { const a = window.getComputedStyle(t); if (a) { const l = parseInt(a.getPropertyValue("left"), 10), o = parseInt(a.getPropertyValue("top"), 10); n.x = isNaN(l) ? 0 : l, n.y = isNaN(o) ? 0 : o; } return n; } return null; } static copy(t) { return new X(0, 0).set(t); } get value() { return { x: this.x, y: this.y }; } add(t) { return this.x += t.x, this.y += t.y, this; } subtract(t) { return this.x -= t.x, this.y -= t.y, this; } multiply(t) { this.x *= t, this.y *= t; } divide(t) { this.x /= t, this.y /= t; } reset() { return this.x = 0, this.y = 0, this; } set(t) { return this.x = t.x, this.y = t.y, this; } } class ce { constructor(t, n) { this.width = t, this.height = n; } static getCurrent(t) { const n = new ce(0, 0); if (window) { const a = window.getComputedStyle(t); return a && (n.width = parseInt(a.getPropertyValue("width"), 10), n.height = parseInt(a.getPropertyValue("height"), 10)), n; } return null; } static copy(t) { return new ce(0, 0).set(t); } set(t) { return this.width = t.width, this.height = t.height, this; } } function Jn(e, t) { const n = d(), a = d(), l = d(), o = d(), r = d(), c = d(), f = d(), v = d(), b = d(), y = d(), m = d(), x = d(e.resizeable), C = d(), k = d(e.draggable), s = d(!1); function u() { const I = a.value || document.body, P = window.getComputedStyle(I); if (!P || !n.value) return; const $ = X.getTransformInfo(n.value), W = {}; f.value && (W.deltaL = n.value.offsetLeft - f.value.x, W.deltaT = n.value.offsetTop - f.value.y); const U = P.getPropertyValue("position"); W.width = I.clientWidth, W.height = I.clientHeight, W.pr = parseInt(P.getPropertyValue("padding-right"), 10), W.pb = parseInt(P.getPropertyValue("padding-bottom"), 10), W.position = P.getPropertyValue("position"), U === "static" && (I.style.position = "relative"), W.translateX = $.x, W.translateY = $.y, y.value = W; } function h(I) { if (n.value) { o.value = ce.getCurrent(n.value), r.value = X.getCurrent(n.value), c.value = o.value ? ce.copy(o.value) : null, f.value = r.value ? X.copy(r.value) : null, u(); const P = I.target.getAttribute("type") || ""; v.value = { n: !!P.match(/n/), s: !!P.match(/s/), w: !!P.match(/w/), e: !!P.match(/e/) }; } } function F() { var I, P, $, W; if (n.value) { const U = n.value; v.value && ((v.value.n || v.value.s) && ((I = c.value) != null && I.height) && (U.style.height = c.value.height + "px"), (v.value.w || v.value.e) && ((P = c.value) != null && P.width) && (U.style.width = c.value.width + "px"), f.value && (($ = f.value) != null && $.x && (U.style.left = f.value.x + "px"), (W = f.value) != null && W.y && (U.style.top = f.value.y + "px"))); } } function B() { const I = e.minHeight ? e.minHeight : 1, P = e.minWidth ? e.minWidth : 1; c.value && f.value && v.value && o.value && (c.value.height < I && (c.value.height = I, v.value.n && r.value && (f.value.y = r.value.y + (o.value.height - I))), c.value.width < P && (c.value.width = P, v.value.w && r.value && (f.value.x = r.value.x + (o.value.width - P))), e.maxHeight && c.value.height > e.maxHeight && (c.value.height = e.maxHeight, r.value && v.value.n && (f.value.y = r.value.y + (o.value.height - e.maxHeight))), e.maxWidth && c.value.width > e.maxWidth && (c.value.width = e.maxWidth, v.value.w && r.value && (f.value.x = r.value.x + (o.value.width - e.maxWidth)))); } function g() { if (a.value) { const I = y.value; if (f.value && c.value && v.value && o.value) { const P = I.width - I.pr - I.deltaL - I.translateX - f.value.x, $ = I.height - I.pb - I.deltaT - I.translateY - f.value.y; v.value.n && f.value.y + I.translateY < 0 && r.value && (f.value.y = -I.translateY, c.value.height = o.value.height + r.value.y + I.translateY), v.value.w && f.value.x + I.translateX < 0 && r.value && (f.value.x = -I.translateX, c.value.width = o.value.width + r.value.x + I.translateX), c.value.width > P && (c.value.width = P), c.value.height > $ && (c.value.height = $); } } } function p(I) { if (!l.value || !o.value || !r.value || !v.value) return; I.subtract(l.value); const P = I.x, $ = I.y; v.value.n ? (f.value.y = r.value.y + $, c.value.height = o.value.height - $) : v.value.s && (c.value.height = o.value.height + $), v.value.e ? c.value.width = o.value.width + P : v.value.w && (c.value.width = o.value.width - P, f.value.x = r.value.x + P), g(), B(), F(); } function w(I) { if (!b.value) return; const P = X.fromEvent(I); P && p(P); } function T() { if (n.value) { const { width: I, height: P, x: $, y: W } = n.value.getBoundingClientRect(), U = X.getTransformInfo(n.value); return { size: { width: I, height: P }, position: { x: $ - U.x, y: W - U.y } }; } return null; } function j(I) { if (n.value) { const P = T(); m.value = P; } l.value = void 0, o.value = null, r.value = null, c.value = null, f.value = null, v.value = null, b.value = null, document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", j); } function L() { document.addEventListener("mousemove", w), document.addEventListener("mouseup", j); } function R(I) { I instanceof MouseEvent && I.button === 2 || k.value && (document.body.click(), I.stopPropagation(), I.preventDefault(), l.value = X.fromEvent(I), b.value = I.target, h(I), L()); } function D(I) { return n.value = I, x.value && i(re, null, [i("div", { class: "fv-resizable-handle fv-resizable-n", type: "n", onMousedown: (P) => R(P) }, null), i("div", { class: "fv-resizable-handle fv-resizable-e", type: "e", onMousedown: (P) => R(P) }, null), i("div", { class: "fv-resizable-handle fv-resizable-s", type: "s", onMousedown: (P) => R(P) }, null), i("div", { class: "fv-resizable-handle fv-resizable-w", type: "w", onMousedown: (P) => R(P) }, null), i("div", { class: "fv-resizable-handle fv-resizable-ne", type: "ne", onMousedown: (P) => R(P) }, null), i("div", { class: "fv-resizable-handle fv-resizable-se fv-resizable-diagonal", type: "se", onMousedown: (P) => R(P) }, null), i("div", { class: "fv-resizable-handle fv-resizable-sw", type: "sw", onMousedown: (P) => R(P) }, null), i("div", { class: "fv-resizable-handle fv-resizable-nw", type: "nw", onMousedown: (P) => R(P) }, null)]); } function S(I = !0) { document.body.click(); const P = a.value || document.body, $ = ce.getCurrent(P), W = n.value; I && W && (C.value = T(), C.value.transform = W.style.transform), $ && W && (c.value = $, c.value.height -= 14, c.value.width -= 14, W.style.height = c.value.height + "px", W.style.width = c.value.width + "px", W.style.left = "7px", W.style.top = "7px", W.style.transform = "", m.value = { size: c.value, position: { x: 0, y: 0 } }, k.value = !1, s.value = !0); } function E() { var I, P; if (document.body.click(), C.value) { const $ = { width: C.value.size.width || 0, height: C.value.size.height || 0 }, W = { x: (window.innerWidth - $.width) / 2, y: (window.innerHeight - $.height) / 2 }; (I = c.value) == null || I.set($), (P = f.value) == null || P.set(W); const U = n.value; U.style.height = $.height + "px", U.style.width = $.width + "px", U.style.left = `${W.x}px`, U.style.top = `${W.y}px`, U.style.transform = "", m.value = { size: $, position: W }, k.value = e.draggable, s.value = !1; } } function N() { if (n.value) { const I = ce.getCurrent(n.value); if (I) { const { width: P, height: $ } = I; n.value.style.left = `${(window.innerWidth - P) / 2}px`, n.value.style.top = `${(window.innerHeight - $) / 2}px`, n.value.style.transform = ""; } } } function V() { const I = () => { s.value ? S(!1) : N(), document.body.click(); }; return window.addEventListener("resize", I), () => { window.removeEventListener("resize", I); }; } const A = V(); return { renderResizeBar: D, boundingElement: a, resizedEventParam: m, maximize: S, restore: E, allowDrag: k, isMaximized: s, unWindowResizeHandle: A, moveToCenter: N }; } function _n(e, t, n) { const a = d(), l = d(e.draggable), o = d(e.lockAxis), r = d(), c = d(), f = d(!1), v = d(new X(0, 0)), b = d(new X(0, 0)), y = d(new X(0, 0)), m = d(new X(0, 0)); H(() => n.value, (w) => { r.value.style.cursor = w ? "move" : "default"; }); function x(w, T) { if (T.tagName === "BUTTON") return !1; if (T === w) return !0; for (const j in T.children) if (Object.prototype.hasOwnProperty.call(T.children, j) && x(w, T.children[j])) return !0; return !1; } function C() { var L, R; let w = y.value.x + b.value.x, T = y.value.y + b.value.y; o.value === "x" ? (w = ((L = v.value) == null ? void 0 : L.x) || 0, y.value.x = 0) : o.value === "y" && (T = ((R = v.value) == null ? void 0 : R.y) || 0, y.value.y = 0); const j = `translate3d(${Math.round(w)}px, ${Math.round(T)}px, 0px)`; a.value && (a.value.style.transform = j), m.value.x = w, m.value.y = T; } function k() { if (!c.value || !a.value) return null; const w = c.value.getBoundingClientRect(), T = a.value.getBoundingClientRect(), j = { top: w.top < T.top, right: w.right > T.right, bottom: w.bottom > T.bottom, left: w.left < T.left }; return j.top || (y.value.y -= T.top - w.top), j.bottom || (y.value.y -= T.bottom - w.bottom), j.right || (y.value.x -= T.right - w.right), j.left || (y.value.x -= T.left - w.left), C(), j; } function s(w) { w && (v.value && w.subtract(v.value), y.value.set(w), C(), k()); } function u(w) { f.value && l.value && (w.stopPropagation(), w.preventDefault(), s(X.fromEvent(w, r.value))); } function h() { var w; f.value && (f.value = !1, b.value.add(y.value), y.value.reset(), (w = a.value) == null || w.classList.remove("ng-dragging"), t.emit("stopMove"), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", h)); } function F() { !f.value && r.value && (f.value = !0, r.value.classList.add("ng-dragging"), document.addEventListener("mousemove", u), document.addEventListener("mouseup", h)); } function B() { if (a.value) { const w = X.getTransformInfo(a.value); b.value.set(w); return; } b.value.reset(); } function g(w) { if (!n.value || w instanceof MouseEvent && w.button === 2) return; const T = w.target || w.srcElement; r.value !== void 0 && T && !x(T, r.value) || l.value !== !1 && (document.body.click(), w.stopPropagation(), w.preventDefault(), v.value = X.fromEvent(w, a.value), B(), F()); } function p(w, T, j) { if (l.value && T) { if (w) r.value = w; else if (e.dragHandle) { if (e.dragHandle instanceof HTMLElement) r.value = e.dragHandle; else if (typeof e.dragHandle == "string") { const L = T.querySelector(e.dragHandle); L && (r.value = L); } } a.value = T, c.value = j, r.value ? (r.value.classList.add("ng-draggable"), r.value.addEventListener("mousedown", g)) : l.value = !1; } } return { registerDraggle: p, resetTranslate: B }; } function Ct(e, t) { if (e) { const n = (a) => { a.key.toLowerCase() === e.toLowerCase() && t({ event: a, key: e }); }; return document.addEventListener("keydown", n), () => { document.removeEventListener("keydown", n); }; } } function Zn(e, t) { const n = d(e.enableEsc); let a = null; return n.value ? (a = Ct("Escape", (l) => { t.emit("esc", { event: l.event, type: "esc" }); }), { remove: a }) : null; } function Qn(e, t) { const n = d(e.enableEnter); let a = null; return n.value ? (a = Ct("Enter", (l) => { t.emit("enter", { event: l.event, type: "enter" }); }), { remove: a }) : null; } const be = /* @__PURE__ */ q({ name: "FModal", props: Kn, emits: ["update:modelValue", "accept", "cancel", "closed", "resize", "esc", "enter", "stopMove"], setup(e, t) { const n = d(e.width || 300), a = d(e.height || 200), l = d(e.modelValue), o = d(""), r = d(e.class), c = d(e.fitContent), f = d(e.showHeader), v = d(""), b = d(e.showCloseButton), y = d(e.showMaxButton), m = d(!1), x = d(e.dialogType), C = d(e.src), k = d(""), s = d(e.showButtons), u = d(e.title), h = d(e.containment || null), F = d(); u.value === "错误提示" && (u.value = Q.getLocaleValue("messageBox.errorTitle")); const B = d(!1); function g(O, z) { const Y = z ? "accept" : "cancel"; Promise.resolve().then(() => { var K; return (K = e.beforeClose) == null ? void 0 : K.call(e, { closeType: Y }); }).then((K) => { K && (l.value = !1, t.emit("update:modelValue", !1), z != null && t.emit(z ? "accept" : "cancel"), t.emit("closed", O)); }); } const p = [{ name: "cancel", text: Q.getLocaleValue("messageBox.cancel") || "取消", class: "btn btn-secondary", handle: (O) => { g(O, !1); } }, { name: "accept", text: Q.getLocaleValue("messageBox.ok") || "确定", class: "btn btn-primary", handle: (O) => { g(O, !0); } }], w = d(e.buttons && e.buttons.length ? e.buttons : p), T = M(() => !!v.value), j = M(() => !!s.value && !!w.value), L = d(), R = d(), D = d(e.maximized || !1), { renderResizeBar: S, maximize: E, restore: N, boundingElement: V, resizedEventParam: A, allowDrag: I, unWindowResizeHandle: P, moveToCenter: $ } = Jn(e), { registerDraggle: W } = _n(e, t, I); function U() { return !!document.querySelectorAll(".farris-modal").length && document.body.classList.contains("modal-open"); } function Ie() { const O = document.querySelectorAll(".farris-modal").length; (!O || O - 1 <= 0) && document.body.classList.remove("modal-open"), F.value && F.value.classList.remove("show"); } H(() => e.title, (O, z) => { O !== z && (u.value = O); }), H(() => e.modelValue, (O, z) => { O !== z && (l.value = O, l.value && e.draggable && oe(() => { R.value && !h.value && (h.value = R.value.parentElement, V.value = h.value, W(L.value, R.value, V.value), $()); }), O || (h.value && (h.value = null), Ie())), l.value ? B.value = U() : (D.value = !1, I.value = e.draggable); }), H(() => e.showHeader, (O, z) => { O !== z && (f.value = O); }), H(() => e.showButtons, (O, z) => { O !== z && (s.value = O); }), H(() => A.value, (O, z) => { const Y = O || {}, K = z || {}; JSON.stringify(Y) !== JSON.stringify(K) && t.emit("resize", { newSize: O, oldSize: z, isMaximized: D.value }); }), H([() => e.width, () => e.height], (O, z) => { (O[0] !== z[0] || O[1] !== z[1]) && (n.value = O[0] || 500, a.value = O[1] || 600); }), H(() => e.class, (O, z) => { r.value = O; }); const ye = M(() => (l.value && document.body.classList.add("modal-open"), l.value)), Ne = M(() => { var Y; const O = { modal: !0, "farris-modal": !0, fade: !0 }; O["f-modal-fitContent"] = !!c.value, O.show = !!ye.value; const z = (Y = e.maskClass) == null ? void 0 : Y.split(" "); return z == null || z.reduce((K, ee) => (K[ee] = !0, K), O), O; }), Yt = M(() => { var Y; const O = { "modal-dialog": !0 }, z = (Y = r.value) == null ? void 0 : Y.split(" "); return z == null || z.reduce((K, ee) => (K[ee] = !0, K), O), O; }), Qe = () => kn() && !e.isMessager, Gt = M(() => { const O = document.documentElement.clientWidth, z = document.documentElement.clientHeight; if (D.value) return { position: "fixed", top: "0px", left: "0px", width: "100vw", height: "100vh", margin: "0" }; const Y = Math.min(n.value, O), K = c.value ? "auto" : `${Math.min(a.value, z - 10)}px`, ee = { position: "absolute", top: `${(window.innerHeight - parseInt(K === "auto" ? "0" : K)) / 2}px`, left: `${(window.innerWidth - Y) / 2}px`, width: `${Y}px`, height: K }; return Qe() && (ee.top = "0px", ee.left = "0px", ee.width = `${window.innerWidth}px`, ee.height = `${window.innerHeight}px`), e.mask || (ee.pointerEvents = "auto"), ee; }), et = d(nt() || 1050), Xt = M(() => { const O = { display: "block", overflow: "hidden" }; return e.mask || (O.pointerEvents = "none", O.backgroundColor = "transparent"), B.value && (O.backgroundColor = "transparent"), O.zIndex = et.value, O; }), Kt = M(() => ({ "modal-content": !0, "modal-content-has-header": f.value, "is-mobile": Qe() })), Jt = M(() => { const O = { display: f.value ? "" : "none" }; return O["pointer-events"] = I.value ? "auto" : "none", O; }), _t = M(() => ({ "f-icon": !0, modal_maximize: !0, modalrevert: D.value })), Zt = M(() => ({ "modal-body": !0, "f-utils-flex-column": x.value === "iframe", "f-utils-fill": !0 })); function Qt() { return { height: `${e.footerHeight || 60}px` }; } const en = M(() => { const O = { textAlgin: k.value }, z = Qt(); return Object.assign(O, z); }); function Re(O) { if (O == null || O.stopPropagation(), D.value) { D.value = !1, N(); return; } E(), D.value = !0; } async function tn(O, z) { O.handle && await O.handle(z, O) && t.emit("closed", z); } function nn(O) { O.width && (n.value = O.width), O.height && (a.value = O.height), O.buttons && (w.value = O.buttons), O.title && (u.value = O.title); } let je = null, Ve = null; yn(() => { B.value = U(); }), J(() => { R.value && !h.value && (h.value = R.value.parentElement, V.value = h.value, W(L.value, R.value, V.value)), ye.value && document.body.classList.add("modal-open"), je = Zn(e, t), Ve = Qn(e, t); }), Oe(() => { P && P(), je && je.remove(), Ve && Ve.remove(); }), t.expose({ modalElementRef: R, updateModalOptions: nn, close: g, maxDialog: Re, isMaximized: D, disableButtons: (O, z = !0) => { w.value.forEach((Y) => { Y.name && O.includes(Y.name) && (Y.disabled = z); }); } }); function an() { return i("ul", null, [m.value && i("li", { class: "f-btn-icon f-bare" }, [i("span", { class: "f-icon modal_minimize" }, null)]), y.value && i("li", { onClick: Re, class: "f-btn-icon f-bare", style: "pointer-events: auto;" }, [i("span", { class: _t.value }, null)]), b.value && i("li", { class: "f-btn-icon f-bare", onClick: (O) => g(O, !1), style: "pointer-events: auto;" }, [i("span", { class: "f-icon modal_close" }, null)])]); } function ln() { return i("div", { class: "modal-footer", style: en.value }, [w.value && w.value.map((O) => { const z = d(O.disabled); return i("button", { name: O.name, style: O.styles, type: "button", disabled: z.value, class: O.class + (O.iconClass ? " btn-icontext" : ""), onClick: (Y) => { tn(O, Y); } }, [!!O.iconClass && i("i", { class: O.iconClass }, null), O.text]); })]); } function tt(O) { y.value && Re(); } function on() { return i(re, null, [D.value && i("div", { class: "modal-header", style: "position: absolute;background: transparent;height: 45px;width: 100%;", onDblclick: (O) => tt() }, null), i("div", { ref: L, class: "modal-header", style: Jt.value, onDblclick: (O) => tt() }, [t.slots.headerTemplate ? t.slots.headerTemplate() : i("div", { class: "modal-title" }, [T.value && i("span", { class: v.value, style: "margin-right: 8px" }, null), i("span", { class: "modal-title-label" }, [u.value])]), i("div", { class: "actions" }, [an()])])]); } function sn() { return t.slots.footerTemplate ? t.slots.footerTemplate() : j.value && ln(); } function rn(O) { if (O.stopPropagation(), e.allowClickMaskToClose) { if (O.target !== F.value) return; g(O, !1); } } function un() { var O, z; return i("div", { id: o.value, class: Yt.value, style: Gt.value, ref: R }, [i("div", { class: Kt.value }, [f.value && on(), i("div", { class: Zt.value }, [(z = (O = t.slots).default) == null ? void 0 : z.call(O), x.value === "iframe" && i("iframe", { title: o.value, class: "f-utils-fill", width: "100%", frameborder: "0", src: C.value }, null)]), sn()]), !c.value && R.value && !D.value && S(R.value)]); } function cn(O) { return O || "body"; } return mn(() => { ye.value && (et.value = nt() || 1050); }), () => i(ct, { to: cn(e.host) }, { default: () => [ye.value && i(dt, { name: "fade", appear: !0 }, { default: () => [i("div", { ref: F, class: Ne.value, style: Xt.value, onClick: rn }, [un()])] })] }); } }); function xt(e) { if (e.content && e.content.render) return e.content.render; if (e.render && typeof e.render == "function") return e.render; } function ea(e) { const t = document.createElement("div"); t.style.display = "contents"; const n = qe({ setup(a, l) { Oe(() => { document.body.removeChild(t); }); const o = d(), r = d(e.class || ""), c = d(!!e.showButtons), f = d(!!e.showHeader), v = d(e.showCloseButton == null ? !0 : e.showCloseButton), b = d(!0), y = d(e.title || ""), m = e.acceptCallback || (() => { }), x = e.rejectCallback || (() => { }), C = e.closedCallback || ((F) => { }), k = e.resizeHandle || ((F) => { }), s = e.stopMoveHandle || ((F) => { }), u = xt(e), h = (F) => { b.value = !1, n.unmount(), C(F); }; return J(() => { }), l.expose({ modalRef: o }), () => i(be, { ref: o, class: r.value, modelValue: b.value, "onUpdate:modelValue": (F) => b.value = F, title: y.value, width: e.width, height: e.height, buttons: e.buttons, "show-header": f.value, "show-buttons": c.value, "show-close-button": v.value, "show-max-button": !1, onAccept: m, onCancel: x, fitContent: e.fitContent == null ? !0 : e.fitContent, onClosed: h, onResize: k, onStopMove: s }, { default: () => [u && u(n)] }); } }); return document.body.appendChild(t), n.use(Q.i18n), n.mount(t), n; } class kt { // private activeModalInstance = computed(() => { // return this.modalRefs[this.activeModalIndex.value]; // }); constructor(t) { te(this, "appContext", null); te(this, "modalRef", d()); te(this, "activeModalIndex", d(0)); te(this, "modalRefs", {}); te(this, "isUseEscCloseModal", d(!1)); this.app = t, this.appContext = t ? t._context : null; } getCurrentModal() { return this.modalRefs[this.activeModalIndex.value]; } adaptToWindow(t, n) { const { width: a, height: l } = { width: window.innerWidth, height: window.innerHeight }; return a < t && (t = a - 14), l < n && (n = l - 14), { width: t, height: n }; } static show(t) { const n = Object.assign({ title: "", showButtons: !0, showHeader: !0 }, t); return ea(n); } close(t) { var n, a; t ? (a = t.value) == null || a.close() : (n = this.getCurrentModal()) == null || n.close(); } open(t) { const n = document.createDocumentFragment(); t.showMaxButton && t.fitContent && (t.showMaxButton = !1); const a = pn(Object.assign({ title: "", showButtons: !0, showHeader: !0, maximized: !1 }, t)), l = d(!0), o = a.value.acceptCallback || (() => { }), r = a.value.rejectCallback || (() => { }), c = a.value.closedCallback || ((T, j) => { }), f = a.value.openedCallback || ((T) => { }), v = a.value.resizeHandle || ((T) => { }), b = t.stopMoveHandle || ((T) => { }); let y; const m = xt(a.value), x = (T) => { var L; l.value = !1; const j = (L = T == null ? void 0 : T.target) == null ? void 0 : L.classList.contains("modal_close"); c(T, this.isUseEscCloseModal.value ? "esc" : j ? "icon" : "button"); }, C = (T) => { x(T), y && oe(() => { if (this.modalRefs[this.activeModalIndex.value] && delete this.modalRefs[this.activeModalIndex.value], Le(null, n), y = null, this.modalRef.value = null, this.modalRefs) { const j = Object.keys(this.modalRefs).map((L) => Number(L)); j.length > 0 ? this.activeModalIndex.value = Math.max(...j) : this.activeModalIndex.value = 0; } this.isUseEscCloseModal.value = !1; }); }, k = (T) => { var j; this.isUseEscCloseModal.value = !0, (j = this.getCurrentModal()) == null || j.close(T == null ? void 0 : T.event); }, { width: s, height: u } = a.value, h = this.adaptToWindow(s || 500, u || 320); Object.assign(a.value, h); const F = d(), B = () => i(be, he({ ref: F, modelValue: l.value, "onUpdate:modelValue": (T) => l.value = T }, a.value, { isMessager: a.value.class && a.value.class.indexOf("modal-message") > -1, onAccept: o, onCancel: r, onClosed: C, onResize: v, onEsc: k, onStopMove: b, maximized: a.value.maximized }), { default: () => [m && m(this.app)] }); y = ((T) => { const j = vn(B, T); return j.appContext = this.appContext, Le(j, n), j; })({ ...a.value // 'onUpdate:modelValue': onUpdateModelValue, }), this.activeModalIndex.value++; const p = this.activeModalIndex.value; this.modalRefs[p] = F.value; const w = (T) => { a.value = { ...a.value, ...T }, y && Le(hn(y, { ...a }), n); }; return oe(() => { this.modalRefs[p] = F.value, this.modalRef.value = F.value, f(new Event("opened")); }), { update: w, destroy: C, modalRef: this.modalRef, close: () => { this.modalRefs[p] && this.modalRefs[p].close(); }, disableButtons: (T, j = !0) => { this.modalRefs[p] && this.modalRefs[p].disableButtons(T, j); } }; } } const Ce = Symbol("FModalService"); be.install = (e) => { e.component(be.name, be); const t = new kt(e); e.provide(Ce, t), e.provide("FModalService", t); }; function wt(e, t) { function n() { const a = e.beforeOpen || e.beforeClickButton || null; let l = Promise.resolve(!0); if (a) { const o = a(t.value); if (typeof o > "u") return l; typeof o == "boolean" ? l = Promise.resolve(o) : l = o; } return l; } return { judgeCanOpen: n }; } function ta(e, t, n, a, l) { const o = d(e.buttonBehavior), r = d(e.popupOnInput), c = M(() => ({ "input-group-append": !0, "append-force-show": e.showButtonWhenDisabled && (e.readonly || e.disable) })), { judgeCanOpen: f } = wt(e, l), v = M(() => e.showButtonWhenDisabled || (!e.editable || !e.readonly) && !e.disable), b = _(Ce, null), y = d(); async function m(k) { if (await f() && v.value) { const s = !!t.slots.default; if (o.value === "Modal") { const u = e.modalOptions, h = b == null ? void 0 : b.open({ ...u, render: () => t.slots.default && t.slots.default() }); y.value = h == null ? void 0 : h.modalRef; } o.value === "Overlay" && Xn.show({ // host: buttonEditRef.value, host: document.body, backgroundColor: "rgba(0,0,0,.15)", render: () => t.slots.default && t.slots.default() }), s && o.value === "Popup" && a.togglePopup(!0), s && r.value && a.hidePopup(), t.emit("clickButton", { origin: k, value: e.modelValue }); } } function x(k) { t.emit("mouseEnterIcon", k); } function C(k) { t.emit("mouseLeaveIcon", k); } return { buttonGroupClass: c, onClickButton: m, onMouseEnterButton: x, onMouseLeaveButton: C, modalRef: y }; } function na(e, t, n, a, l, o) { const r = d(!1), c = M(() => e.enableClear && !e.readonly && !e.disable), { changeTextBoxValue: f, hasClearClass: v } = o; function b(C) { r.value = C, v.value = C; } H(l, () => { b(!!l.value); }); function y(C) { const k = !e.readonly && !e.disable && e.editable, s = !e.editable; C.stopPropagation(), (k || s) && (f(""), l.value = "", b(!r.value), t.emit("clear")); } function m(C) { if (c.value) { if (!n.value) { b(!1); return; } !e.disable && !e.readonly && b(!0); } } function x(C) { c.value && b(!1); } return { enableClearButton: c, showClearButton: r, onClearValue: y, onMouseEnterTextBox: m, onMouseLeaveTextBox: x }; } function aa(e, t, n, a, l) { const o = M(() => e.popupOnInput), r = M(() => e.popupOnFocus), { shouldPopupContent: c, closeAllPopover: f } = l, v = d(!1), b = M(() => e.enableTitle ? n.value : ""), y = M(() => (e.disable || e.readonly) && !e.forcePlaceholder ? "" : e.placeholder), m = M(() => e.readonly || !e.editable), x = d(!1), C = M(() => !e.disable && x.value), k = M(() => ({ "text-left": e.textAlign === "left", "text-center": e.textAlign === "center", "text-right": e.textAlign === "right", "form-control": !0, "f-utils-fill": !0 })), s = M(() => ({ "input-group": !0, "f-state-disabled": e.disable, "f-state-editable": e.editable && !e.disable && !e.readonly, "f-state-readonly": e.readonly, "f-state-focus": C.value, "input-group--has-clear": e.enableClear && v.value })); function u(R, D = !0) { n.value = R, D && (t.emit("change", R), t.emit("update:modelValue", R)); } function h(R) { c.value = !1, u(R, !0); } H( () => e.modelValue, (R) => { n.value = R; } ); function F(R) { x.value = !1, t.emit("blur", R), R.stopPropagation(); } function B(R) { t.emit("click", R), f(), t.slots.default && !e.disable && !e.readonly && e.popupOnClick && l.togglePopup(); } function g(R) { !e.disable && !e.readonly && (x.value = !0, m.value || (t.emit("focus", R), r.value && !c.value && l.popup())); } function p(R) { t.emit("input", R); const D = R.target.value; a.value = D, n.value !== D && u(D, e.updateOn === "change"), o.value && !c.value && l.popup(); } function w(R) { R.target.tagName !== "INPUT" && R.preventDefault(), R.stopPropagation(); } function T(R) { t.emit("keydown", R); } function j(R) { R.key === "Enter" && (o.value || r.value) && l.hidePopup(), t.emit("keyup", R); } function L(R) { const D = R.target.value; R.stopPropagation(), u(D); } return { hasFocusedTextBox: C, isTextBoxReadonly: m, textBoxClass: k, textBoxPlaceholder: y, textBoxTitle: b, inputGroupClass: s, hasClearClass: v, changeTextBoxValue: u, commitValue: h, onBlurTextBox: F, onClickTextBox: B, onFocusTextBox: g, onInput: p, onKeyDownTextBox: T, onKeyUpTextBox: j, onMouseDownTextBox: w, onTextBoxValueChange: L }; } const ue = "FarrisVue_PopoverInstancesKey"; function la(e, t, n, a) { const l = d(), o = d(!1), { judgeCanOpen: r } = wt(e, a); H(() => l.value, (x, C) => { window[ue] = window[ue] || /* @__PURE__ */ new WeakMap(), x ? window[ue].set(n.value, x) : window[ue].delete(n.value); }); function c() { if (window[ue]) { const x = window[ue]; document.querySelectorAll(".f-button-edit,.v-popover").forEach((C) => { const k = x.get(C); k && C !== n.value && !n.value.closest(".popover-fitcontent") && k.hide(); }); } } function f() { const x = l.value; x && x.show(n.value); } async function v(x = !1) { if (!!t.slots.default) { if (!x && !o.value && !await r()) return; o.value = !o.value, o.value && (await oe(), f()); } } async function b(x = !1) { if (!!t.slots.default) { if (!x && !await r()) return; o.value = !0, await oe(), f(); } } function y() { o.value = !1; } function m() { o.value = !0, oe(() => { f(); }); } return { hidePopup: y, showPopup: m, popup: b, shouldPopupContent: o, togglePopup: v, popoverRef: l, closeAllPopover: c }; } function oa(e, t, n) { const a = d(), { isTextBoxReadonly: l, textBoxClass: o, textBoxPlaceholder: r, textBoxTitle: c, onBlurTextBox: f, onClickTextBox: v, onFocusTextBox: b, onInput: y, onKeyDownTextBox: m, onKeyUpTextBox: x, onMouseDownTextBox: C, onTextBoxValueChange: k } = n, s = d(e.id), { uuid: u } = wn(), h = M(() => ({ // 'border-top-right-radius': '6px', // 'border-bottom-right-radius': '6px' })); J(() => { var w, T; e.selectOnCreated && ((w = a.value) == null || w.select()), e.focusOnCreated && ((T = a.value) == null || T.focus({ preventScroll: !0 })), s.value || (s.value = "button-edit_" + u(8)), s.value = s.value + "-textbox"; }); const F = d(!1), B = (w) => { w.preventDefault(), F.value = !0; }, g = (w) => { w.preventDefault(), F.value = !1, y(w); }; function p(w) { F.value || y(w); } return () => i("input", { id: e.id ? e.id + "-textbox" : void 0, ref: a, name: "input-group-value", autocomplete: e.autoComplete ? "on" : "off", class: o.value, style: h.value, disabled: e.disable, maxlength: e.maxLength, minlength: e.minLength, placeholder: r.value, readonly: l.value, tabindex: e.tabIndex, title: c.value, type: e.inputType, value: t.value, onBlur: f, onChange: k, onClick: v, onFocus: b, onInput: p, onKeydown: m, onKeyup: x, onMousedown: C, onCompositionend: g, onCompositionstart: B }, null); } function ia(e, t, n) { const a = d(e.separator), l = M(() => e.readonly || e.disable), { changeTextBoxValue: o, onFocusTextBox: r, onBlurTextBox: c, onClickTextBox: f, textBoxPlaceholder: v } = n, b = M(() => t.value ? t.value.split(a.value).map((C) => ({ name: C, selectable: !0 })) : []); function y(C) { o(C.map((k) => k.name).join(a.value), !0); } H(() => e.separator, (C) => { a.value = C; }); const m = d(!e.disable && !e.readonly); H([() => e.disable, () => e.readonly], ([C, k], [s, u]) => { m.value = !C && !k; }); function x(C) { f(C); } return () => i(Bn, { tabindex: e.tabIndex, onFocus: r, onBlur: c, id: `${e.id}-tag-editor`, class: "form-control", placeholder: v.value, data: b.value, showClose: !l.value, showInput: !0, disable: l.value, onChange: y, onClick: x }, null); } function sa(e, t, n, a) { const { buttonGroupClass: l, onClickButton: o, onMouseEnterButton: r, onMouseLeaveButton: c } = n, { enableClearButton: f, showClearButton: v, onClearValue: b } = a, y = d(), m = pt((C) => { o(C); }, e.buttonBehavior === "Modal" ? 0 : 200), x = () => { t.emit("beforeClearValue"); }; return { renderButtonGroup: () => i("div", { id: e.id ? `${e.id}-button-group` : void 0, class: l.value }, [f.value && ft(i("span", { class: "input-group-text input-group-clear", onClick: b, onMousedown: x }, [i("i", { class: "f-icon modal_close" }, null)]), [[gn, v.value]]), t.slots.buttonContent ? i("span", { class: "input-group-text input-group-append-button", onClick: m, onMouseenter: r, onMouseleave: c }, [t.slots.buttonContent()]) : e.buttonContent ? i("span", { class: "input-group-text input-group-append-button", innerHTML: e.buttonContent, ref: y, onClick: (C) => m(C), onMouseenter: r, onMouseleave: c }, null) : null]), buttonHandleElement: y }; } function ra(e, t, n) { const a = d(e.popupMinWidth), { hidePopup: l, popoverRef: o } = n, r = () => { t.emit("shown"); }; return () => i(On, { id: `${e.id}-popover`, ref: o, placement: e.placement, host: e.popupHost, "keep-width-with-reference": e.keepWidthWithReference, fitContent: !0, "right-boundary": e.popupRightBoundary, minWidth: a.value, class: e.popupClass, offsetX: e.popupOffsetX, onHidden: l, onShown: r, beforeClose: e.beforeClosePopup, limitContentBySpace: e.limitContentBySpace }, { default: () => { var c, f; return [(f = (c = t.slots).default) == null ? void 0 : f.call(c)]; } }); } const Ee = /* @__PURE__ */ q({ name: "FButtonEdit", props: Wn, emits: ["updateExtendInfo", "clear", "change", "click", "clickButton", "blur", "focus", "mouseEnterIcon", "mouseLeaveIcon", "keyup", "keydown", "inputClick", "input", "update:modelValue", "beforeClearValue", "