UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,748 lines 54.7 kB
var Ne = Object.defineProperty; var Ae = (e, t, n) => t in e ? Ne(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var A = (e, t, n) => Ae(e, typeof t != "symbol" ? t + "" : t, n); import { defineComponent as J, ref as r, computed as E, createVNode as g, Teleport as ce, createApp as de, onUnmounted as ae, Fragment as fe, watch as D, onBeforeMount as $e, onMounted as U, Transition as Ge, shallowRef as Xe, nextTick as q, render as le, h as Ue, cloneVNode as Ye, mergeProps as oe, inject as ve, withDirectives as qe, vShow as _e } from "vue"; import { isPlainObject as re, cloneDeep as Je } from "lodash-es"; import { resolveAppearance as Qe } from "../dynamic-resolver/index.esm.js"; import Ze from "../tags/index.esm.js"; import Ke from "../popover/index.esm.js"; import { useDesignerComponent as et } from "../designer-canvas/index.esm.js"; import { withInstall as tt } from "../common/index.esm.js"; const nt = {}, lt = {}; function pe(e) { const { properties: t, title: n, ignore: l } = e, a = l && Array.isArray(l), i = Object.keys(t).reduce((s, o) => ((!a || !l.find((d) => d === o)) && (s[o] = t[o].type === "object" && t[o].properties ? pe(t[o]) : Je(t[o].default)), s), {}); if (n && (!a || !l.find((s) => s === "id"))) { const s = n.toLowerCase().replace(/-/g, "_"); i.id = `${s}_${Math.random().toString().slice(2, 6)}`; } return i; } function at(e, t) { const n = pe(t); return Object.keys(n).reduce((l, a) => (Object.prototype.hasOwnProperty.call(e, a) && (l[a] && re(l[a]) && re(e[a] || !e[a]) ? Object.assign(l[a], e[a] || {}) : l[a] = e[a]), l), n), n; } function he(e, t) { return Object.keys(e).filter((l) => e[l] != null).reduce((l, a) => { if (t.has(a)) { const i = t.get(a); if (typeof i == "string") l[i] = e[a]; else { const s = i(a, e[a], e); Object.assign(l, s); } } else l[a] = e[a]; return l; }, {}); } function ot(e, t, n = /* @__PURE__ */ new Map()) { const l = at(e, t); return he(l, n); } function ut(e = {}) { function t(u, v, f, h) { if (typeof f == "number") return h[u].length === f; if (typeof f == "object") { const C = Object.keys(f)[0], w = f[C]; if (C === "not") return Number(h[u].length) !== Number(w); if (C === "moreThan") return Number(h[u].length) >= Number(w); if (C === "lessThan") return Number(h[u].length) <= Number(w); } return !1; } function n(u, v, f, h) { return h[u] && h[u].propertyValue && String(h[u].propertyValue.value) === String(f); } const l = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((u, v) => (u.set(v, e[v]), u), l); function a(u, v) { const f = u; return typeof v == "number" ? [{ target: f, operator: "length", param: null, value: Number(v) }] : typeof v == "boolean" ? [{ target: f, operator: "getProperty", param: u, value: !!v }] : typeof v == "object" ? Object.keys(v).map((h) => { if (h === "length") return { target: f, operator: "length", param: null, value: v[h] }; const C = h, w = v[h]; return { target: f, operator: "getProperty", param: C, value: w }; }) : []; } function i(u) { return Object.keys(u).reduce((f, h) => { const C = a(h, u[h]); return f.push(...C), f; }, []); } function s(u, v) { if (l.has(u.operator)) { const f = l.get(u.operator); return f && f(u.target, u.param, u.value, v) || !1; } return !1; } function o(u, v) { return i(u).reduce((C, w) => C && s(w, v), !0); } function d(u, v) { const f = Object.keys(u), h = f.includes("allOf"), C = f.includes("anyOf"), w = h || C, P = (w ? u[w ? h ? "allOf" : "anyOf" : "allOf"] : [u]).map((V) => o(V, v)); return h ? !P.includes(!1) : P.includes(!0); } return { parseValueSchema: d }; } const it = {}, st = {}; ut(); function rt(e, t, n = /* @__PURE__ */ new Map(), l = (s, o, d, u) => o, a = {}, i = (s) => s) { return nt[t.title] = t, lt[t.title] = l, it[t.title] = a, st[t.title] = i, (s = {}, o = !0) => { if (!o) return he(s, n); const d = ot(s, t, n), u = Object.keys(e).reduce((v, f) => (v[f] = e[f].default, v), {}); return Object.assign(u, d); }; } const ct = /* @__PURE__ */ new Map([ ["appearance", Qe] ]); function dt(e, t, n) { return t; } const ft = "https://json-schema.org/draft/2020-12/schema", vt = "https://farris-design.gitee.io/button-edit.schema.json", pt = "button-edit", ht = "A Farris Input Component", mt = "object", gt = { id: { description: "The unique identifier for a Input Group", type: "string" }, type: { description: "The type string of Input Group component", type: "string", default: "button-edit" }, 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 }, enableLinkLabel: { description: "", type: "boolean", default: !1 }, label: { description: "", type: "string", default: "" }, lableWidth: { description: "", type: "number" }, placeholder: { description: "", type: "string", default: "" }, forcePlaceholder: { description: "", type: "boolean", default: !1 }, readonly: { description: "", type: "boolean", default: !1 }, require: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, textAlign: { description: "", type: "string", enum: [ "left", "middle", "right" ], default: "left" }, visible: { description: "", type: "boolean", default: !0 }, onBlur: { description: "", type: "string", default: "" }, onClickLinkLabel: { description: "", type: "sting", default: "" }, autoComplete: { description: "", type: "boolean", default: !1 }, buttonContent: { description: "", type: "string", default: "" }, enableClear: { description: "", type: "boolean", default: !0 }, inputType: { description: "", type: "string", enum: [ "text", "tag" ], default: "text" }, multiSelect: { description: "", type: "boolean", default: !1 }, popup: { description: "", type: "object", properties: { footerButtons: { type: "array", default: [] }, height: { type: "number", default: 600 }, dataMapping: { type: "object" }, contents: { type: "array", default: [] }, showMaxButton: { type: "boolean", default: !0 }, showCloseButton: { type: "boolean", default: !0 }, showFooter: { type: "boolean", default: !0 }, title: { type: "string", default: "" }, width: { type: "number", default: 800 } } }, popupClass: { description: "", type: "sting", default: "" }, separator: { type: "string", default: "," }, showButtonWhenDisabled: { description: "", type: "boolean", default: !1 }, wrapText: { type: "boolean", default: !1 }, onClear: { description: "", type: "string", default: "" } }, yt = [ "id", "type" ], bt = { $schema: ft, $id: vt, title: pt, description: ht, type: mt, properties: gt, required: yt }, Ct = "buttonEdit", wt = "A Farris Component", xt = "object", Bt = { 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: { editable: { description: "", title: "允许编辑", type: "boolean" }, 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" }, textAlign: { description: "", title: "对齐方式", type: "enum", editor: { type: "combo-list", textField: "name", valueField: "value", data: [ { value: "left", name: "左对齐" }, { value: "center", name: "居中" }, { value: "right", name: "右对齐" } ] } } } } }, Mt = { title: Ct, description: wt, type: xt, categories: Bt }, ue = { /** * 组件标识 */ id: String, /** * 扩展按钮显示内容,这是一段现在扩展按钮中的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: 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" }, preventScroll: { type: Boolean, default: !1 } }, me = rt(ue, bt, ct, dt, Mt), Et = { popupContentPosition: { type: Object, default: { left: 0, top: 0 } }, host: { type: Object }, backgroundColor: { type: String, default: "" } }, Ot = /* @__PURE__ */ J({ name: "FOverlay", props: Et, emits: ["click"], setup(e, t) { const n = r(e.popupContentPosition), l = r(e.host), a = E(() => ({ backgroundColor: e.backgroundColor || "", pointerEvents: "auto" })); function i(o) { t.emit("click"), o.preventDefault(), o.stopPropagation(); } E(() => { const o = l.value; if (o) { const d = o.getBoundingClientRect(), { left: u, top: v, height: f } = d; return { left: u, top: v + f }; } return n.value; }); const s = E(() => ({ // position: 'relative', // left: `${position.value.left}px`, // top: `${position.value.top}px` })); return () => g(ce, { to: "body" }, { default: () => { var o, d; return [g("div", { class: "overlay-container", onClick: (u) => i(u), style: a.value }, [g("div", { style: s.value }, [(d = (o = t.slots).default) == null ? void 0 : d.call(o)])])]; } }); } }); function kt(e) { if (e.content && e.content.render) return e.content.render; if (e.render && typeof e.render == "function") return e.render; } function Tt(e) { const t = document.createElement("div"); t.style.display = "contents"; let n; const l = e.onClickCallback || (() => { }), a = () => { l(), n && n.unmount(); }; return n = de({ setup() { ae(() => { document.body.removeChild(t); }); const i = kt(e); return () => g(Ot, { "popup-content-position": e.popupPosition, host: e.host, onClick: a, backgroundColor: e.backgroundColor }, { default: () => [i && i()] }); } }), document.body.appendChild(t), n.mount(t), n; } class Rt { static show(t) { return Tt(t); } } const It = { /** * 自定义类 */ class: { 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 }, /** * 是否展示头部 */ 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 }, 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 } }; class S { constructor(t, n) { this.x = t, this.y = n; } static getTransformInfo(t) { const l = window.getComputedStyle(t).getPropertyValue("transform").replace(/[^-\d,]/g, "").split(","); if (l.length >= 6) { const a = parseInt(l[4], 10), i = parseInt(l[5], 10); return { x: a, y: i }; } return { x: 0, y: 0 }; } static fromEvent(t, n = null) { if (this.isMouseEvent(t)) return new S(t.clientX, t.clientY); if (n === null || t.changedTouches.length === 1) return new S(t.changedTouches[0].clientX, t.changedTouches[0].clientY); for (let l = 0; l < t.changedTouches.length; l++) if (t.changedTouches[l].target === n) return new S(t.changedTouches[l].clientX, t.changedTouches[l].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 S(0, 0); if (window) { const l = window.getComputedStyle(t); if (l) { const a = parseInt(l.getPropertyValue("left"), 10), i = parseInt(l.getPropertyValue("top"), 10); n.x = isNaN(a) ? 0 : a, n.y = isNaN(i) ? 0 : i; } return n; } return null; } static copy(t) { return new S(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 $ { constructor(t, n) { this.width = t, this.height = n; } static getCurrent(t) { const n = new $(0, 0); if (window) { const l = window.getComputedStyle(t); return l && (n.width = parseInt(l.getPropertyValue("width"), 10), n.height = parseInt(l.getPropertyValue("height"), 10)), n; } return null; } static copy(t) { return new $(0, 0).set(t); } set(t) { return this.width = t.width, this.height = t.height, this; } } function Pt(e, t) { const n = r(), l = r(), a = r(), i = r(), s = r(), o = r(), d = r(), u = r(), v = r(), f = r(), h = r(), C = r(), w = r(e.draggable), O = r(!1); function T() { const p = l.value || document.body, m = window.getComputedStyle(p); if (!m || !n.value) return; const k = S.getTransformInfo(n.value), M = {}; d.value && (M.deltaL = n.value.offsetLeft - d.value.x, M.deltaT = n.value.offsetTop - d.value.y); const F = m.getPropertyValue("position"); M.width = p.clientWidth, M.height = p.clientHeight, M.pr = parseInt(m.getPropertyValue("padding-right"), 10), M.pb = parseInt(m.getPropertyValue("padding-bottom"), 10), M.position = m.getPropertyValue("position"), F === "static" && (p.style.position = "relative"), M.translateX = k.x, M.translateY = k.y, f.value = M; } function P(p) { if (n.value) { i.value = $.getCurrent(n.value), s.value = S.getCurrent(n.value), o.value = i.value ? $.copy(i.value) : null, d.value = s.value ? S.copy(s.value) : null, T(); const m = p.target.getAttribute("type") || ""; u.value = { n: !!m.match(/n/), s: !!m.match(/s/), w: !!m.match(/w/), e: !!m.match(/e/) }; } } function z() { var p, m, k, M; if (n.value) { const F = n.value; u.value && ((u.value.n || u.value.s) && ((p = o.value) != null && p.height) && (F.style.height = o.value.height + "px"), (u.value.w || u.value.e) && ((m = o.value) != null && m.width) && (F.style.width = o.value.width + "px"), d.value && ((k = d.value) != null && k.x && (F.style.left = d.value.x + "px"), (M = d.value) != null && M.y && (F.style.top = d.value.y + "px"))); } } function V() { const p = e.minHeight ? e.minHeight : 1, m = e.minWidth ? e.minWidth : 1; o.value && d.value && u.value && i.value && (o.value.height < p && (o.value.height = p, u.value.n && s.value && (d.value.y = s.value.y + (i.value.height - p))), o.value.width < m && (o.value.width = m, u.value.w && s.value && (d.value.x = s.value.x + (i.value.width - m))), e.maxHeight && o.value.height > e.maxHeight && (o.value.height = e.maxHeight, s.value && u.value.n && (d.value.y = s.value.y + (i.value.height - e.maxHeight))), e.maxWidth && o.value.width > e.maxWidth && (o.value.width = e.maxWidth, u.value.w && s.value && (d.value.x = s.value.x + (i.value.width - e.maxWidth)))); } function B() { if (l.value) { const p = f.value; if (d.value && o.value && u.value && i.value) { const m = p.width - p.pr - p.deltaL - p.translateX - d.value.x, k = p.height - p.pb - p.deltaT - p.translateY - d.value.y; u.value.n && d.value.y + p.translateY < 0 && s.value && (d.value.y = -p.translateY, o.value.height = i.value.height + s.value.y + p.translateY), u.value.w && d.value.x + p.translateX < 0 && s.value && (d.value.x = -p.translateX, o.value.width = i.value.width + s.value.x + p.translateX), o.value.width > m && (o.value.width = m), o.value.height > k && (o.value.height = k); } } } function I(p) { if (!a.value || !i.value || !s.value || !u.value) return; p.subtract(a.value); const m = p.x, k = p.y; u.value.n ? (d.value.y = s.value.y + k, o.value.height = i.value.height - k) : u.value.s && (o.value.height = i.value.height + k), u.value.e ? o.value.width = i.value.width + m : u.value.w && (o.value.width = i.value.width - m, d.value.x = s.value.x + m), B(), V(), z(); } function L(p) { if (!v.value) return; const m = S.fromEvent(p); m && I(m); } function b() { if (n.value) { const { width: p, height: m, x: k, y: M } = n.value.getBoundingClientRect(), F = S.getTransformInfo(n.value); return { size: { width: p, height: m }, position: { x: k - F.x, y: M - F.y } }; } return null; } function x(p) { if (n.value) { const m = b(); h.value = m; } a.value = void 0, i.value = null, s.value = null, o.value = null, d.value = null, u.value = null, v.value = null, document.removeEventListener("mousemove", L), document.removeEventListener("mouseup", x); } function j() { document.addEventListener("mousemove", L), document.addEventListener("mouseup", x); } function y(p) { p instanceof MouseEvent && p.button === 2 || w.value && (document.body.click(), p.stopPropagation(), p.preventDefault(), a.value = S.fromEvent(p), v.value = p.target, P(p), j()); } function H(p) { return n.value = p, g(fe, null, [g("div", { class: "fv-resizable-handle fv-resizable-n", type: "n", onMousedown: (m) => y(m) }, null), g("div", { class: "fv-resizable-handle fv-resizable-e", type: "e", onMousedown: (m) => y(m) }, null), g("div", { class: "fv-resizable-handle fv-resizable-s", type: "s", onMousedown: (m) => y(m) }, null), g("div", { class: "fv-resizable-handle fv-resizable-w", type: "w", onMousedown: (m) => y(m) }, null), g("div", { class: "fv-resizable-handle fv-resizable-ne", type: "ne", onMousedown: (m) => y(m) }, null), g("div", { class: "fv-resizable-handle fv-resizable-se fv-resizable-diagonal", type: "se", onMousedown: (m) => y(m) }, null), g("div", { class: "fv-resizable-handle fv-resizable-sw", type: "sw", onMousedown: (m) => y(m) }, null), g("div", { class: "fv-resizable-handle fv-resizable-nw", type: "nw", onMousedown: (m) => y(m) }, null)]); } function W(p = !0) { document.body.click(); const m = l.value || document.body, k = $.getCurrent(m), M = n.value; p && M && (C.value = b(), C.value.transform = M.style.transform), k && M && (o.value = k, M.style.height = o.value.height - 14 + "px", M.style.width = o.value.width - 14 + "px", M.style.left = "7px", M.style.top = "7px", M.style.transform = "", h.value = { size: o.value, position: { x: 0, y: 0 } }, w.value = !1, O.value = !0); } function N() { var p, m; if (document.body.click(), C.value) { const k = { width: C.value.size.width || 0, height: C.value.size.height || 0 }, M = { x: (window.innerWidth - k.width) / 2, y: (window.innerHeight - k.height) / 2 }; (p = o.value) == null || p.set(k), (m = d.value) == null || m.set(M); const F = n.value; F.style.height = k.height + "px", F.style.width = k.width + "px", F.style.left = `${M.x}px`, F.style.top = `${M.y}px`, F.style.transform = "", h.value = { size: k, position: M }, w.value = e.draggable, O.value = !1; } } function Q() { if (n.value) { const p = $.getCurrent(n.value); if (p) { const { width: m, height: k } = p; n.value.style.left = `${(window.innerWidth - m) / 2}px`, n.value.style.top = `${(window.innerHeight - k) / 2}px`, n.value.style.transform = ""; } } } function Z() { const p = () => { O.value ? W(!1) : Q(), document.body.click(); }; return window.addEventListener("resize", p), () => { window.removeEventListener("resize", p); }; } const K = Z(); return { renderResizeBar: H, boundingElement: l, resizedEventParam: h, maximize: W, restore: N, allowDrag: w, isMaximized: O, unWindowResizeHandle: K }; } function zt(e, t, n) { const l = r(), a = r(e.draggable), i = r(e.lockAxis), s = r(), o = r(), d = r(!1), u = r(new S(0, 0)), v = r(new S(0, 0)), f = r(new S(0, 0)), h = r(new S(0, 0)); D(() => n.value, (b) => { s.value.style.cursor = b ? "move" : "default"; }); function C(b, x) { if (x.tagName === "BUTTON") return !1; if (x === b) return !0; for (const j in x.children) if (Object.prototype.hasOwnProperty.call(x.children, j) && C(b, x.children[j])) return !0; return !1; } function w() { var y, H; let b = f.value.x + v.value.x, x = f.value.y + v.value.y; i.value === "x" ? (b = ((y = u.value) == null ? void 0 : y.x) || 0, f.value.x = 0) : i.value === "y" && (x = ((H = u.value) == null ? void 0 : H.y) || 0, f.value.y = 0); const j = `translate3d(${Math.round(b)}px, ${Math.round(x)}px, 0px)`; l.value && (l.value.style.transform = j), h.value.x = b, h.value.y = x; } function O() { if (!o.value || !l.value) return null; const b = o.value.getBoundingClientRect(), x = l.value.getBoundingClientRect(), j = { top: b.top < x.top, right: b.right > x.right, bottom: b.bottom > x.bottom, left: b.left < x.left }; return j.top || (f.value.y -= x.top - b.top), j.bottom || (f.value.y -= x.bottom - b.bottom), j.right || (f.value.x -= x.right - b.right), j.left || (f.value.x -= x.left - b.left), w(), j; } function T(b) { b && (u.value && b.subtract(u.value), f.value.set(b), w(), O()); } function P(b) { d.value && a.value && (b.stopPropagation(), b.preventDefault(), T(S.fromEvent(b, s.value))); } function z() { var b; d.value && (d.value = !1, v.value.add(f.value), f.value.reset(), (b = l.value) == null || b.classList.remove("ng-dragging"), document.removeEventListener("mousemove", P), document.removeEventListener("mouseup", z)); } function V() { !d.value && s.value && (d.value = !0, s.value.classList.add("ng-dragging"), document.addEventListener("mousemove", P), document.addEventListener("mouseup", z)); } function B() { if (l.value) { const b = S.getTransformInfo(l.value); v.value.set(b); return; } v.value.reset(); } function I(b) { if (!n.value || b instanceof MouseEvent && b.button === 2) return; const x = b.target || b.srcElement; s.value !== void 0 && x && !C(x, s.value) || a.value !== !1 && (document.body.click(), b.stopPropagation(), b.preventDefault(), u.value = S.fromEvent(b, l.value), B(), V()); } function L(b, x, j) { if (a.value && x) { if (b) s.value = b; else if (e.dragHandle) { if (e.dragHandle instanceof HTMLElement) s.value = e.dragHandle; else if (typeof e.dragHandle == "string") { const y = x.querySelector(e.dragHandle); y && (s.value = y); } } l.value = x, o.value = j, s.value ? (s.value.classList.add("ng-draggable"), s.value.addEventListener("mousedown", I)) : a.value = !1; } } return { registerDraggle: L, resetTranslate: B }; } function ge(e, t) { if (e) { const n = (l) => { l.key.toLowerCase() === e.toLowerCase() && t({ event: l, key: e }); }; return document.addEventListener("keydown", n), () => { document.removeEventListener("keydown", n); }; } } function jt(e, t) { const n = r(e.enableEsc); let l = null; return n.value ? (l = ge("Escape", (a) => { t.emit("esc", { event: a.event, type: "esc" }); }), { remove: l }) : null; } function Ht(e, t) { const n = r(e.enableEnter); let l = null; return n.value ? (l = ge("Enter", (a) => { t.emit("enter", { event: a.event, type: "enter" }); }), { remove: l }) : null; } const X = /* @__PURE__ */ J({ name: "FModal", props: It, emits: ["update:modelValue", "accept", "cancel", "closed", "resize", "esc", "enter"], setup(e, t) { const n = r(e.width || 300), l = r(e.height || 200), a = r(e.modelValue), i = r(""), s = r(e.class), o = r(e.fitContent), d = r(e.showHeader), u = r(""), v = r(e.showCloseButton), f = r(e.showMaxButton), h = r(!1), C = r(e.dialogType), w = r(e.src), O = r(""), T = r(e.showButtons), P = r(e.title), z = r(e.resizeable), V = r(e.containment || null), B = r(), I = r(!1); function L(c, R) { a.value = !1, t.emit("update:modelValue", !1), R != null && t.emit(R ? "accept" : "cancel"), t.emit("closed", c); } const b = [{ name: "cancel", text: "取消", class: "btn btn-secondary", handle: (c) => { L(c, !1); } }, { name: "accept", text: "确定", class: "btn btn-primary", handle: (c) => { L(c, !0); } }], x = r(e.buttons && e.buttons.length ? e.buttons : b), j = E(() => !!u.value), y = E(() => !!T.value && !!x.value), H = r(), W = r(), N = r(!1), { renderResizeBar: Q, maximize: Z, restore: K, boundingElement: p, resizedEventParam: m, allowDrag: k, unWindowResizeHandle: M } = Pt(e), { registerDraggle: F } = zt(e, t, k); function ie() { return !!document.querySelectorAll(".farris-modal").length && document.body.classList.contains("modal-open"); } function Be() { const c = document.querySelectorAll(".farris-modal").length; (!c || c - 1 <= 0) && document.body.classList.remove("modal-open"), B.value && B.value.classList.remove("show"); } D(() => e.title, (c, R) => { c !== R && (P.value = c); }), D(() => e.modelValue, (c, R) => { c !== R && (a.value = c, c || Be()), a.value && (I.value = ie()); }), D(() => e.showHeader, (c, R) => { c !== R && (d.value = c); }), D(() => e.showButtons, (c, R) => { c !== R && (T.value = c); }), D(() => m.value, (c, R) => { const G = c || {}, Y = R || {}; JSON.stringify(G) !== JSON.stringify(Y) && t.emit("resize", { newSize: c, oldSize: R }); }); const ee = E(() => (a.value && document.body.classList.add("modal-open"), a.value)), Me = E(() => { const c = { modal: !0, "farris-modal": !0, fade: !0 }; return c["f-modal-fitContent"] = !!o.value, c.show = !!ee.value, c; }), Ee = E(() => { var G; const c = { "modal-dialog": !0 }, R = (G = s.value) == null ? void 0 : G.split(" "); return R == null || R.reduce((Y, De) => (Y[De] = !0, Y), c), c; }), Oe = E(() => ({ position: "absolute", top: `${(window.innerHeight - l.value) / 2}px`, left: `${(window.innerWidth - n.value) / 2}px`, width: `${n.value}px`, height: o.value ? "auto" : `${l.value}px` })), ke = E(() => ({ "modal-content": !0, "modal-content-has-header": d.value })), Te = E(() => { const c = { display: d.value ? "" : "none" }; return c["pointer-events"] = k.value ? "auto" : "none", c; }), Re = E(() => ({ "f-icon": !0, modal_maximize: !0, modalrevert: N.value })), Ie = E(() => ({ "modal-body": !0, "f-utils-flex-column": C.value === "iframe", "f-utils-fill": !0 })); function Pe() { return { height: `${e.footerHeight || 60}px` }; } const ze = E(() => { const c = { textAlgin: O.value }, R = Pe(); return Object.assign(c, R); }); function se(c) { if (c.stopPropagation(), N.value) { N.value = !1, K(); return; } Z(), N.value = !0; } async function je(c, R) { c.handle && await c.handle(R, c) && t.emit("closed", R); } function He(c) { c.width && (n.value = c.width), c.height && (l.value = c.height), c.buttons && (x.value = c.buttons), c.title && (P.value = c.title); } const Se = E(() => { const c = { display: "inline-block" }; return I.value && (c["background-color"] = "transparent"), c; }); let te = null, ne = null; $e(() => { I.value = ie(); }), U(() => { W.value && !V.value && (V.value = W.value.parentElement, p.value = V.value, F(H.value, W.value, p.value)), ee.value && document.body.classList.add("modal-open"), te = jt(e, t), ne = Ht(e, t); }), ae(() => { M && M(), te && te.remove(), ne && ne.remove(); }), t.expose({ modalElementRef: W, updateModalOptions: He, close: L, maxDialog: se }); function Le() { return g("ul", null, [h.value && g("li", { class: "f-btn-icon f-bare" }, [g("span", { class: "f-icon modal_minimize" }, null)]), f.value && g("li", { onClick: se, class: "f-btn-icon f-bare", style: "pointer-events: auto;" }, [g("span", { class: Re.value }, null)]), v.value && g("li", { class: "f-btn-icon f-bare", onClick: (c) => L(c, !1), style: "pointer-events: auto;" }, [g("span", { class: "f-icon modal_close" }, null)])]); } function Fe() { return g("div", { class: "modal-footer", style: ze.value }, [x.value && x.value.map((c) => g("button", { name: c.name, type: "button", class: c.class + (c.iconClass ? " btn-icontext" : ""), onClick: (R) => { je(c, R); } }, [!!c.iconClass && g("i", { class: c.iconClass }, null), c.text]))]); } function Ve() { return g("div", { ref: H, class: "modal-header", style: Te.value }, [g("div", { class: "modal-title" }, [j.value && g("span", { class: u.value, style: "margin-right: 8px" }, null), g("span", { class: "modal-title-label" }, [P.value])]), g("div", { class: "actions" }, [Le()])]); } function We(c) { c.stopPropagation(); } return () => g(ce, { to: "body" }, { default: () => [ee.value && g(Ge, { name: "fade", appear: !0 }, { default: () => { var c, R; return [g("div", { class: Me.value, style: Se.value, ref: B, onClick: We }, [g("div", { id: i.value, class: Ee.value, style: Oe.value, ref: W }, [g("div", { class: ke.value }, [d.value && Ve(), g("div", { class: Ie.value }, [(R = (c = t.slots).default) == null ? void 0 : R.call(c), C.value === "iframe" && g("iframe", { title: i.value, class: "f-utils-fill", width: "100%", frameborder: "0", src: w.value }, null)]), y.value && Fe()]), !o.value && z.value && W.value && !N.value && Q(W.value)])])]; } })] }); } }); function ye(e) { if (e.content && e.content.render) return e.content.render; if (e.render && typeof e.render == "function") return e.render; } function St(e) { const t = document.createElement("div"); t.style.display = "contents"; const n = de({ setup(l, a) { ae(() => { document.body.removeChild(t); }); const i = r(), s = r(e.class || ""), o = r(!!e.showButtons), d = r(!!e.showHeader), u = r(e.showCloseButton == null ? !0 : e.showCloseButton), v = r(!0), f = r(e.title || ""), h = e.acceptCallback || (() => { }), C = e.rejectCallback || (() => { }), w = e.closedCallback || ((z) => { }), O = e.resizeHandle || ((z) => { }), T = ye(e), P = (z) => { v.value = !1, n.unmount(), w(z); }; return U(() => { }), a.expose({ modalRef: i }), () => g(X, { ref: i, class: s.value, modelValue: v.value, "onUpdate:modelValue": (z) => v.value = z, title: f.value, width: e.width, height: e.height, buttons: e.buttons, "show-header": d.value, "show-buttons": o.value, "show-close-button": u.value, "show-max-button": !1, onAccept: h, onCancel: C, fitContent: e.fitContent == null ? !0 : e.fitContent, onClosed: P, onResize: O }, { default: () => [T && T(n)] }); } }); return document.body.appendChild(t), n.mount(t), n; } class Lt { constructor(t) { A(this, "appContext", null); A(this, "modalRef", r()); A(this, "activeModalIndex", r(0)); A(this, "modalRefs", {}); A(this, "isUseEscCloseModal", r(!1)); A(this, "activeModalInstance", E(() => this.modalRefs[this.activeModalIndex.value])); this.app = t, this.appContext = t ? t._context : null; } getCurrentModal() { return this.activeModalInstance.value; } adaptToWindow(t, n) { const { width: l, height: a } = { width: window.innerWidth, height: window.innerHeight }; return l < t && (t = l), a < n && (n = a), { width: t, height: n }; } static show(t) { const n = Object.assign({ title: "", showButtons: !0, showHeader: !0 }, t); return St(n); } close(t) { var n, l; t ? (l = t.value) == null || l.close() : (n = this.getCurrentModal()) == null || n.close(); } open(t) { const n = document.createDocumentFragment(); t.showMaxButton && t.fitContent && (t.showMaxButton = !1); const l = Xe(Object.assign({ title: "", showButtons: !0, showHeader: !0 }, t)), a = r(!0), i = l.value.acceptCallback || (() => { }), s = l.value.rejectCallback || (() => { }), o = l.value.closedCallback || ((B, I) => { }), d = l.value.resizeHandle || ((B) => { }); let u; const v = ye(l.value), f = (B) => { var L; a.value = !1; const I = (L = B == null ? void 0 : B.target) == null ? void 0 : L.classList.contains("modal_close"); o(B, this.isUseEscCloseModal.value ? "esc" : I ? "icon" : "button"); }, h = (B) => { f(B), u && q(() => { if (this.modalRefs[this.activeModalIndex.value] && delete this.modalRefs[this.activeModalIndex.value], le(null, n), u = null, this.modalRef.value = null, this.modalRefs) { const I = Object.keys(this.modalRefs).map((L) => Number(L)); I.length > 0 ? this.activeModalIndex.value = Math.max(...I) : this.activeModalIndex.value = 0; } this.isUseEscCloseModal.value = !1; }); }, C = (B) => { var I; this.isUseEscCloseModal.value = !0, this.activeModalInstance && ((I = this.activeModalInstance.value) == null || I.close(B == null ? void 0 : B.event)); }, { width: w, height: O } = l.value, T = this.adaptToWindow(w || 500, O || 320); Object.assign(l.value, T); const P = () => g(X, oe({ ref: this.modalRef, modelValue: a.value, "onUpdate:modelValue": (B) => a.value = B }, l.value, { onAccept: i, onCancel: s, onClosed: h, onResize: d, onEsc: C }), { default: () => [v && v(this.app)] }); return u = ((B) => { const I = Ue(P, B); return I.appContext = this.appContext, le(I, n), I; })({ ...l.value // 'onUpdate:modelValue': onUpdateModelValue, }), this.activeModalIndex.value++, this.modalRefs[this.activeModalIndex.value] = this.modalRef.value, { update: (B) => { l.value = { ...l.value, ...B }, u && le(Ye(u, { ...l }), n); }, destroy: h, modalRef: this.activeModalInstance, close: this.close }; } } const be = Symbol("FModalService"); X.install = (e) => { e.component(X.name, X); const t = new Lt(e); e.provide(be, t), e.provide("FModalService", t); }; function Ce(e, t) { function n() { const l = e.beforeOpen || e.beforeClickButton || null; let a = Promise.resolve(!0); if (l) { const i = l(t.value); if (typeof i > "u") return a; typeof i == "boolean" ? a = Promise.resolve(i) : a = i; } return a; } return { judgeCanOpen: n }; } function we(e, t, n, l, a) { const i = r(e.buttonBehavior), s = r(e.popupOnInput), o = E(() => ({ "input-group-append": !0, "append-force-show": e.showButtonWhenDisabled && (e.readonly || e.disable) })), { judgeCanOpen: d } = Ce(e, a), u = E(() => e.showButtonWhenDisabled || (!e.editable || !e.readonly) && !e.disable), v = ve(be, null), f = r(); async function h(O) { if (await d() && u.value) { const T = !!t.slots.default; if (i.value === "Modal") { const P = e.modalOptions, z = v == null ? void 0 : v.open({ ...P, render: () => t.slots.default && t.slots.default() }); f.value = z == null ? void 0 : z.modalRef; } i.value === "Overlay" && Rt.show({ // host: buttonEditRef.value, host: document.body, backgroundColor: "rgba(0,0,0,.15)", render: () => t.slots.default && t.slots.default() }), T && i.value === "Popup" && l.togglePopup(!0), T && s.value && l.hidePopup(), t.emit("clickButton", { origin: O, value: e.modelValue }); } } function C(O) { t.emit("mouseEnterIcon", O); } function w(O) { t.emit("mouseLeaveIcon", O); } return { buttonGroupClass: o, onClickButton: h, onMouseEnterButton: C, onMouseLeaveButton: w, modalRef: f }; } function Ft(e, t, n, l, a, i) { const s = r(!1), o = E(() => e.enableClear && !e.readonly && !e.disable), { changeTextBoxValue: d, hasClearClass: u } = i; function v(w) { s.value = w, u.value = w; } D(a, () => { v(!!a.value); }); function f(w) { const O = !e.readonly && !e.disable && e.editable, T = !e.editable; w.stopPropagation(), (O || T) && (d(""), v(!s.value), t.emit("clear")); } function h(w) { if (o.value) { if (!n.value) { v(!1); return; } !e.disable && !e.readonly && v(!0); } } function C(w) { o.value && v(!1); } return { enableClearButton: o, showClearButton: s, onClearValue: f, onMouseEnterTextBox: h, onMouseLeaveTextBox: C }; } function Vt(e, t, n, l, a) { const i = E(() => e.popupOnInput), s = E(() => e.popupOnFocus), { shouldPopupContent: o } = a, d = r(!1), u = E(() => e.enableTitle ? n.value : ""), v = E(() => (e.disable || e.readonly) && !e.forcePlaceholder ? "" : e.placeholder), f = E(() => e.readonly || !e.editable), h = r(!1), C = E(() => !e.disable && h.value), w = E(() => ({ "text-left": e.textAlign === "left", "text-center": e.textAlign === "center", "text-right": e.textAlign === "right", "form-control": !0, "f-utils-fill": !0 })), O = E(() => ({ "input-group": !0, "f-state-disabled": e.disable, "f-state-editable": e.editable && !e.disable && !e.readonly, "f-state-readonly": e.readonly && !e.disable, "f-state-focus": C.value, "input-group--has-clear": d.value })); function T(y, H = !0) { n.value = y, H && (t.emit("change", y), t.emit("update:modelValue", y)); } function P(y) { o.value = !1, T(y, !0); } D( () => e.modelValue, (y) => { n.value = y; } ); function z(y) { h.value = !1, t.emit("blur", y), y.stopPropagation(); } function V(y) { t.emit("click", y), !e.disable && !e.readonly && e.popupOnClick && (a.togglePopup(), document.body.click()); } function B(y) { e.disable || (h.value = !0, f.value || (t.emit("focus", y), s.value && !o.value && a.popup())); } function I(y) { t.emit("input", y.target.value); const H = y.target.value; l.value = H, n.value !== H && T(H, e.updateOn === "change"), i.value && !o.value && a.popup(); } function L(y) { y.target.tagName !== "INPUT" && y.preventDefault(), y.stopPropagation(); } function b(y) { t.emit("keydown", y); } function x(y) { y.key === "Enter" && (i.value || s.value) && a.hidePopup(), t.emit("keyup", y); } function j(y) { const H = y.target.value; y.stopPropagation(), T(H); } return { hasFocusedTextBox: C, isTextBoxReadonly: f, textBoxClass: w, textBoxPlaceholder: v, textBoxTitle: u, inputGroupClass: O, hasClearClass: d, changeTextBoxValue: T, commitValue: P, onBlurTextBox: z, onClickTextBox: V, onFocusTextBox: B, onInput: I, onKeyDownTextBox: b, onKeyUpTextBox: x, onMouseDownTextBox: L, onTextBoxValueChange: j }; } function xe(e, t, n, l) { const a = r(), i = r(!1), { judgeCanOpen: s } = Ce(e, l); function o() { const h = a.value; h && h.show(n.value); } async function d(h = !1) { if (!!t.slots.default) { if (!h && !i.value && !await s()) return; i.value = !i.value, await q(), o(); } } async function u(h = !1) { if (!!t.slots.default) { if (!h && !await s()) return; i.value = !0, await q(), o(); } } function v() { i.value = !1; } function f() { i.value = !0, q(() => { o(); }); } return { hidePopup: v, showPopup: f, popup: u, shouldPopupContent: i, togglePopup: d, popoverRef: a }; } function Wt(e, t, n) { const l = r(), { isTextBoxReadonly: a, textBoxClass: i, textBoxPlaceholder: s, textBoxTitle: o, onBlurTextBox: d, onClickTextBox: u, onFocusTextBox: v, onInput: f, onKeyDownTextBox: h, onKeyUpTextBox: C, onMouseDownTextBox: w, onTextBoxValueChange: O } = n; return U(() => { var T, P; e.selectOnCreated && ((T = l.value) == null || T.select()), e.focusOnCreated && ((P = l.value) == null || P.focus({ preventScroll: e.preventScroll })); }), () => g("input", { ref: l, name: "input-group-value", autocomplete: e.autoComplete ? "on" : "off", class: i.value, disabled: e.disable, maxlength: e.maxLength, minlength: e.minLength, placeholder: s.value, readonly: a.value, tabindex: e.tabIndex, title: o.value, type: e.inputType, value: t.value, onBlur: d, onChange: O, onClick: u, onFocus: v, onInput: f, onKeydown: h, onKeyup: C, onMousedown: w }, null); } function Dt(e, t, n) { const l = r(e.separator), { changeTextBoxValue: a } = n, i = E(() => t.value ? t.value.split(l.value).map((o) => ({ name: o, selectable: !0 })) : []); function s(o) { a(o.map((d) => d.name).join(l.value), !0); } return () => g(Ze, { id: `${e.id}-tag-editor`, class: "form-control", data: i.value, showClose: !0, showInput: !0, onChange: s }, null); } function Nt(e, t, n, l) { const { buttonGroupClass: a, onClickButton: i, onMouseEnterButton: s, onMouseLeaveButton: o } = n, { enableClearButton: d, showClearButton: u, onClearValue: v } = l, f = r(); return { renderButtonGroup: () => g("div", { id: `${e.id}-button-group`, class: a.value }, [d.value && qe(g("span", { class: "input-group-text input-group-clear", onClick: v }, [g("i", { class: "f-icon modal_close" }, null)]), [[_e, u.value]]), t.slots.buttonContent ? g("span", { class: "input-group-text input-group-append-button", onClick: i, onMouseenter: s, onMouseleave: o }, [t.slots.buttonContent()]) : e.buttonContent ? g("span", { class: "input-group-text input-group-append-button", innerHTML: e.buttonContent, ref: f, onClick: i, onMouseenter: s, onMouseleave: o }, null) : null]), buttonHandleElement: f }; } function At(e, t, n) { const l = r(e.popupMinWidth), { hidePopup: a, popoverRef: i } = n; return () => g(Ke, { id: `${e.id}-popover`, ref: i, visible: !0, placement: e.placement, host: e.popupHost, "keep-width-with-reference": e.keepWidthWithReference, fitContent: !0, "right-boundary": e.popupRightBoundary, minWidth: l.value, class: e.popupClass, offsetX: e.popupOffsetX, onHidden: a }, { default: () => { var s, o; return [(o = (s = t.slots).default) == null ? void 0 : o.call(s)]; } }); } const _ = /* @__PURE__ */ J({ name: "FButtonEdit", props: ue, emits: ["updateExtendInfo", "clear", "change", "click", "clickButton", "blur", "focus", "mouseEnterIcon", "mouseLeaveIcon", "keyup", "keydown", "inputClick", "input