@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,631 lines (1,630 loc) • 48.3 kB
JavaScript
var Xe = Object.defineProperty;
var Ye = (e, t, n) => t in e ? Xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var q = (e, t, n) => Ye(e, typeof t != "symbol" ? t + "" : t, n);
import { isMobilePhone as qe, getMaxZIndex as ve, withInstall as Ge } from "../../components/common/index.esm.js";
import { resolveAppearance as Ue, createPropsResolver as Ke } from "../../components/dynamic-resolver/index.esm.js";
import Je, { buttonEditProps as _e } from "../../components/button-edit/index.esm.js";
import { defineComponent as ie, ref as o, computed as H, createVNode as h, Teleport as pe, createApp as he, onUnmounted as se, Fragment as me, watch as A, nextTick as U, onBeforeMount as Ze, onMounted as re, watchEffect as Qe, Transition as et, shallowRef as tt, render as ue, h as nt, cloneVNode as lt, mergeProps as ye, inject as ge } from "vue";
import { LocaleService as Q } from "../../components/locale/index.esm.js";
import "../../components/property-panel/index.esm.js";
import { useDesignerComponent as at } from "../../components/designer-canvas/index.esm.js";
const ot = {
/**
* 组件标识
*/
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 }
}, ut = {
popupContentPosition: { type: Object, default: { left: 0, top: 0 } },
host: { type: Object },
backgroundColor: { type: String, default: "" }
}, it = /* @__PURE__ */ ie({
name: "FOverlay",
props: ut,
emits: ["click"],
setup(e, t) {
const n = o(e.popupContentPosition), a = o(e.host), c = H(() => ({
backgroundColor: e.backgroundColor || "",
pointerEvents: "auto"
}));
function s(i) {
t.emit("click"), i.preventDefault(), i.stopPropagation();
}
H(() => {
const i = a.value;
if (i) {
const d = i.getBoundingClientRect(), {
left: m,
top: B,
height: g
} = d;
return {
left: m,
top: B + g
};
}
return n.value;
});
const p = H(() => ({
// position: 'relative',
// left: `${position.value.left}px`,
// top: `${position.value.top}px`
}));
return () => h(pe, {
to: "body"
}, {
default: () => {
var i, d;
return [h("div", {
class: "overlay-container",
onClick: (m) => s(m),
style: c.value
}, [h("div", {
style: p.value
}, [(d = (i = t.slots).default) == null ? void 0 : d.call(i)])])];
}
});
}
});
function st(e) {
if (e.content && e.content.render)
return e.content.render;
if (e.render && typeof e.render == "function")
return e.render;
}
function rt(e) {
const t = document.createElement("div");
t.style.display = "contents";
let n;
const a = e.onClickCallback || (() => {
}), c = () => {
a(), n && n.unmount();
};
return n = he({
setup() {
se(() => {
document.body.removeChild(t);
});
const s = st(e);
return () => h(it, {
"popup-content-position": e.popupPosition,
host: e.host,
onClick: c,
backgroundColor: e.backgroundColor
}, {
default: () => [s && s()]
});
}
}), document.body.appendChild(t), n.mount(t), n;
}
class ct {
static show(t) {
return rt(t);
}
}
const dt = {
/**
* 允许点击遮罩关闭对话框
*/
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 R {
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 c = parseInt(a[4], 10), s = parseInt(a[5], 10);
return { x: c, y: s };
}
return { x: 0, y: 0 };
}
static fromEvent(t, n = null) {
if (this.isMouseEvent(t))
return new R(t.clientX, t.clientY);
if (n === null || t.changedTouches.length === 1)
return new R(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 R(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 R(0, 0);
if (window) {
const a = window.getComputedStyle(t);
if (a) {
const c = parseInt(a.getPropertyValue("left"), 10), s = parseInt(a.getPropertyValue("top"), 10);
n.x = isNaN(c) ? 0 : c, n.y = isNaN(s) ? 0 : s;
}
return n;
}
return null;
}
static copy(t) {
return new R(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 X {
constructor(t, n) {
this.width = t, this.height = n;
}
static getCurrent(t) {
const n = new X(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 X(0, 0).set(t);
}
set(t) {
return this.width = t.width, this.height = t.height, this;
}
}
function ft(e, t) {
const n = o(), a = o(), c = o(), s = o(), p = o(), i = o(), d = o(), m = o(), B = o(), g = o(), O = o(), C = o(e.resizeable), M = o(), k = o(e.draggable), j = o(!1);
function P() {
const u = a.value || document.body, r = window.getComputedStyle(u);
if (!r || !n.value)
return;
const x = R.getTransformInfo(n.value), w = {};
d.value && (w.deltaL = n.value.offsetLeft - d.value.x, w.deltaT = n.value.offsetTop - d.value.y);
const T = r.getPropertyValue("position");
w.width = u.clientWidth, w.height = u.clientHeight, w.pr = parseInt(r.getPropertyValue("padding-right"), 10), w.pb = parseInt(r.getPropertyValue("padding-bottom"), 10), w.position = r.getPropertyValue("position"), T === "static" && (u.style.position = "relative"), w.translateX = x.x, w.translateY = x.y, g.value = w;
}
function z(u) {
if (n.value) {
s.value = X.getCurrent(n.value), p.value = R.getCurrent(n.value), i.value = s.value ? X.copy(s.value) : null, d.value = p.value ? R.copy(p.value) : null, P();
const r = u.target.getAttribute("type") || "";
m.value = {
n: !!r.match(/n/),
s: !!r.match(/s/),
w: !!r.match(/w/),
e: !!r.match(/e/)
};
}
}
function S() {
var u, r, x, w;
if (n.value) {
const T = n.value;
m.value && ((m.value.n || m.value.s) && ((u = i.value) != null && u.height) && (T.style.height = i.value.height + "px"), (m.value.w || m.value.e) && ((r = i.value) != null && r.width) && (T.style.width = i.value.width + "px"), d.value && ((x = d.value) != null && x.x && (T.style.left = d.value.x + "px"), (w = d.value) != null && w.y && (T.style.top = d.value.y + "px")));
}
}
function V() {
const u = e.minHeight ? e.minHeight : 1, r = e.minWidth ? e.minWidth : 1;
i.value && d.value && m.value && s.value && (i.value.height < u && (i.value.height = u, m.value.n && p.value && (d.value.y = p.value.y + (s.value.height - u))), i.value.width < r && (i.value.width = r, m.value.w && p.value && (d.value.x = p.value.x + (s.value.width - r))), e.maxHeight && i.value.height > e.maxHeight && (i.value.height = e.maxHeight, p.value && m.value.n && (d.value.y = p.value.y + (s.value.height - e.maxHeight))), e.maxWidth && i.value.width > e.maxWidth && (i.value.width = e.maxWidth, m.value.w && p.value && (d.value.x = p.value.x + (s.value.width - e.maxWidth))));
}
function N() {
if (a.value) {
const u = g.value;
if (d.value && i.value && m.value && s.value) {
const r = u.width - u.pr - u.deltaL - u.translateX - d.value.x, x = u.height - u.pb - u.deltaT - u.translateY - d.value.y;
m.value.n && d.value.y + u.translateY < 0 && p.value && (d.value.y = -u.translateY, i.value.height = s.value.height + p.value.y + u.translateY), m.value.w && d.value.x + u.translateX < 0 && p.value && (d.value.x = -u.translateX, i.value.width = s.value.width + p.value.x + u.translateX), i.value.width > r && (i.value.width = r), i.value.height > x && (i.value.height = x);
}
}
}
function W(u) {
if (!c.value || !s.value || !p.value || !m.value)
return;
u.subtract(c.value);
const r = u.x, x = u.y;
m.value.n ? (d.value.y = p.value.y + x, i.value.height = s.value.height - x) : m.value.s && (i.value.height = s.value.height + x), m.value.e ? i.value.width = s.value.width + r : m.value.w && (i.value.width = s.value.width - r, d.value.x = p.value.x + r), N(), V(), S();
}
function v(u) {
if (!B.value)
return;
const r = R.fromEvent(u);
r && W(r);
}
function f() {
if (n.value) {
const {
width: u,
height: r,
x,
y: w
} = n.value.getBoundingClientRect(), T = R.getTransformInfo(n.value);
return {
size: {
width: u,
height: r
},
position: {
x: x - T.x,
y: w - T.y
}
};
}
return null;
}
function b(u) {
if (n.value) {
const r = f();
O.value = r;
}
c.value = void 0, s.value = null, p.value = null, i.value = null, d.value = null, m.value = null, B.value = null, document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", b);
}
function L() {
document.addEventListener("mousemove", v), document.addEventListener("mouseup", b);
}
function E(u) {
u instanceof MouseEvent && u.button === 2 || k.value && (document.body.click(), u.stopPropagation(), u.preventDefault(), c.value = R.fromEvent(u), B.value = u.target, z(u), L());
}
function D(u) {
return n.value = u, C.value && h(me, null, [h("div", {
class: "fv-resizable-handle fv-resizable-n",
type: "n",
onMousedown: (r) => E(r)
}, null), h("div", {
class: "fv-resizable-handle fv-resizable-e",
type: "e",
onMousedown: (r) => E(r)
}, null), h("div", {
class: "fv-resizable-handle fv-resizable-s",
type: "s",
onMousedown: (r) => E(r)
}, null), h("div", {
class: "fv-resizable-handle fv-resizable-w",
type: "w",
onMousedown: (r) => E(r)
}, null), h("div", {
class: "fv-resizable-handle fv-resizable-ne",
type: "ne",
onMousedown: (r) => E(r)
}, null), h("div", {
class: "fv-resizable-handle fv-resizable-se fv-resizable-diagonal",
type: "se",
onMousedown: (r) => E(r)
}, null), h("div", {
class: "fv-resizable-handle fv-resizable-sw",
type: "sw",
onMousedown: (r) => E(r)
}, null), h("div", {
class: "fv-resizable-handle fv-resizable-nw",
type: "nw",
onMousedown: (r) => E(r)
}, null)]);
}
function J(u = !0) {
document.body.click();
const r = a.value || document.body, x = X.getCurrent(r), w = n.value;
u && w && (M.value = f(), M.value.transform = w.style.transform), x && w && (i.value = x, i.value.height -= 14, i.value.width -= 14, w.style.height = i.value.height + "px", w.style.width = i.value.width + "px", w.style.left = "7px", w.style.top = "7px", w.style.transform = "", O.value = {
size: i.value,
position: {
x: 0,
y: 0
}
}, k.value = !1, j.value = !0);
}
function te() {
var u, r;
if (document.body.click(), M.value) {
const x = {
width: M.value.size.width || 0,
height: M.value.size.height || 0
}, w = {
x: (window.innerWidth - x.width) / 2,
y: (window.innerHeight - x.height) / 2
};
(u = i.value) == null || u.set(x), (r = d.value) == null || r.set(w);
const T = n.value;
T.style.height = x.height + "px", T.style.width = x.width + "px", T.style.left = `${w.x}px`, T.style.top = `${w.y}px`, T.style.transform = "", O.value = {
size: x,
position: w
}, k.value = e.draggable, j.value = !1;
}
}
function _() {
if (n.value) {
const u = X.getCurrent(n.value);
if (u) {
const {
width: r,
height: x
} = u;
n.value.style.left = `${(window.innerWidth - r) / 2}px`, n.value.style.top = `${(window.innerHeight - x) / 2}px`, n.value.style.transform = "";
}
}
}
function Y() {
const u = () => {
j.value ? J(!1) : _(), document.body.click();
};
return window.addEventListener("resize", u), () => {
window.removeEventListener("resize", u);
};
}
const ne = Y();
return {
renderResizeBar: D,
boundingElement: a,
resizedEventParam: O,
maximize: J,
restore: te,
allowDrag: k,
isMaximized: j,
unWindowResizeHandle: ne,
moveToCenter: _
};
}
function vt(e, t, n) {
const a = o(), c = o(e.draggable), s = o(e.lockAxis), p = o(), i = o(), d = o(!1), m = o(new R(0, 0)), B = o(new R(0, 0)), g = o(new R(0, 0)), O = o(new R(0, 0));
A(() => n.value, (v) => {
p.value.style.cursor = v ? "move" : "default";
});
function C(v, f) {
if (f.tagName === "BUTTON")
return !1;
if (f === v)
return !0;
for (const b in f.children)
if (Object.prototype.hasOwnProperty.call(f.children, b) && C(v, f.children[b]))
return !0;
return !1;
}
function M() {
var L, E;
let v = g.value.x + B.value.x, f = g.value.y + B.value.y;
s.value === "x" ? (v = ((L = m.value) == null ? void 0 : L.x) || 0, g.value.x = 0) : s.value === "y" && (f = ((E = m.value) == null ? void 0 : E.y) || 0, g.value.y = 0);
const b = `translate3d(${Math.round(v)}px, ${Math.round(f)}px, 0px)`;
a.value && (a.value.style.transform = b), O.value.x = v, O.value.y = f;
}
function k() {
if (!i.value || !a.value)
return null;
const v = i.value.getBoundingClientRect(), f = a.value.getBoundingClientRect(), b = {
top: v.top < f.top,
right: v.right > f.right,
bottom: v.bottom > f.bottom,
left: v.left < f.left
};
return b.top || (g.value.y -= f.top - v.top), b.bottom || (g.value.y -= f.bottom - v.bottom), b.right || (g.value.x -= f.right - v.right), b.left || (g.value.x -= f.left - v.left), M(), b;
}
function j(v) {
v && (m.value && v.subtract(m.value), g.value.set(v), M(), k());
}
function P(v) {
d.value && c.value && (v.stopPropagation(), v.preventDefault(), j(R.fromEvent(v, p.value)));
}
function z() {
var v;
d.value && (d.value = !1, B.value.add(g.value), g.value.reset(), (v = a.value) == null || v.classList.remove("ng-dragging"), t.emit("stopMove"), document.removeEventListener("mousemove", P), document.removeEventListener("mouseup", z));
}
function S() {
!d.value && p.value && (d.value = !0, p.value.classList.add("ng-dragging"), document.addEventListener("mousemove", P), document.addEventListener("mouseup", z));
}
function V() {
if (a.value) {
const v = R.getTransformInfo(a.value);
B.value.set(v);
return;
}
B.value.reset();
}
function N(v) {
if (!n.value || v instanceof MouseEvent && v.button === 2)
return;
const f = v.target || v.srcElement;
p.value !== void 0 && f && !C(f, p.value) || c.value !== !1 && (document.body.click(), v.stopPropagation(), v.preventDefault(), m.value = R.fromEvent(v, a.value), V(), S());
}
function W(v, f, b) {
if (c.value && f) {
if (v)
p.value = v;
else if (e.dragHandle) {
if (e.dragHandle instanceof HTMLElement)
p.value = e.dragHandle;
else if (typeof e.dragHandle == "string") {
const L = f.querySelector(e.dragHandle);
L && (p.value = L);
}
}
a.value = f, i.value = b, p.value ? (p.value.classList.add("ng-draggable"), p.value.addEventListener("mousedown", N)) : c.value = !1;
}
}
return {
registerDraggle: W,
resetTranslate: V
};
}
function be(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 pt(e, t) {
const n = o(e.enableEsc);
let a = null;
return n.value ? (a = be("Escape", (c) => {
t.emit("esc", { event: c.event, type: "esc" });
}), {
remove: a
}) : null;
}
function ht(e, t) {
const n = o(e.enableEnter);
let a = null;
return n.value ? (a = be("Enter", (c) => {
t.emit("enter", { event: c.event, type: "enter" });
}), {
remove: a
}) : null;
}
const K = /* @__PURE__ */ ie({
name: "FModal",
props: dt,
emits: ["update:modelValue", "accept", "cancel", "closed", "resize", "esc", "enter", "stopMove"],
setup(e, t) {
const n = o(e.width || 300), a = o(e.height || 200), c = o(e.modelValue), s = o(""), p = o(e.class), i = o(e.fitContent), d = o(e.showHeader), m = o(""), B = o(e.showCloseButton), g = o(e.showMaxButton), O = o(!1), C = o(e.dialogType), M = o(e.src), k = o(""), j = o(e.showButtons), P = o(e.title), z = o(e.containment || null), S = o();
P.value === "错误提示" && (P.value = Q.getLocaleValue("messageBox.errorTitle"));
const V = o(!1);
function N(l, y) {
const I = y ? "accept" : "cancel";
Promise.resolve().then(() => {
var F;
return (F = e.beforeClose) == null ? void 0 : F.call(e, {
closeType: I
});
}).then((F) => {
F && (c.value = !1, t.emit("update:modelValue", !1), y != null && t.emit(y ? "accept" : "cancel"), t.emit("closed", l));
});
}
const W = [{
name: "cancel",
text: Q.getLocaleValue("messageBox.cancel") || "取消",
class: "btn btn-secondary",
handle: (l) => {
N(l, !1);
}
}, {
name: "accept",
text: Q.getLocaleValue("messageBox.ok") || "确定",
class: "btn btn-primary",
handle: (l) => {
N(l, !0);
}
}], v = o(e.buttons && e.buttons.length ? e.buttons : W), f = H(() => !!m.value), b = H(() => !!j.value && !!v.value), L = o(), E = o(), D = o(e.maximized || !1), {
renderResizeBar: J,
maximize: te,
restore: _,
boundingElement: Y,
resizedEventParam: ne,
allowDrag: u,
unWindowResizeHandle: r,
moveToCenter: x
} = ft(e), {
registerDraggle: w
} = vt(e, t, u);
function T() {
return !!document.querySelectorAll(".farris-modal").length && document.body.classList.contains("modal-open");
}
function Me() {
const l = document.querySelectorAll(".farris-modal").length;
(!l || l - 1 <= 0) && document.body.classList.remove("modal-open"), S.value && S.value.classList.remove("show");
}
A(() => e.title, (l, y) => {
l !== y && (P.value = l);
}), A(() => e.modelValue, (l, y) => {
l !== y && (c.value = l, c.value && e.draggable && U(() => {
E.value && !z.value && (z.value = E.value.parentElement, Y.value = z.value, w(L.value, E.value, Y.value), x());
}), l || (z.value && (z.value = null), Me())), c.value ? V.value = T() : (D.value = !1, u.value = e.draggable);
}), A(() => e.showHeader, (l, y) => {
l !== y && (d.value = l);
}), A(() => e.showButtons, (l, y) => {
l !== y && (j.value = l);
}), A(() => ne.value, (l, y) => {
const I = l || {}, F = y || {};
JSON.stringify(I) !== JSON.stringify(F) && t.emit("resize", {
newSize: l,
oldSize: y,
isMaximized: D.value
});
}), A([() => e.width, () => e.height], (l, y) => {
(l[0] !== y[0] || l[1] !== y[1]) && (n.value = l[0] || 500, a.value = l[1] || 600);
}), A(() => e.class, (l, y) => {
p.value = l;
});
const Z = H(() => (c.value && document.body.classList.add("modal-open"), c.value)), ke = H(() => {
var I;
const l = {
modal: !0,
"farris-modal": !0,
fade: !0
};
l["f-modal-fitContent"] = !!i.value, l.show = !!Z.value;
const y = (I = e.maskClass) == null ? void 0 : I.split(" ");
return y == null || y.reduce((F, $) => (F[$] = !0, F), l), l;
}), Ee = H(() => {
var I;
const l = {
"modal-dialog": !0
}, y = (I = p.value) == null ? void 0 : I.split(" ");
return y == null || y.reduce((F, $) => (F[$] = !0, F), l), l;
}), ce = () => qe() && !e.isMessager, ze = H(() => {
const l = document.documentElement.clientWidth, y = document.documentElement.clientHeight;
if (D.value)
return {
position: "fixed",
top: "0px",
left: "0px",
width: "100vw",
height: "100vh",
margin: "0"
};
const I = Math.min(n.value, l), F = i.value ? "auto" : `${Math.min(a.value, y - 10)}px`, $ = {
position: "absolute",
top: `${(window.innerHeight - parseInt(F === "auto" ? "0" : F)) / 2}px`,
left: `${(window.innerWidth - I) / 2}px`,
width: `${I}px`,
height: F
};
return ce() && ($.top = "0px", $.left = "0px", $.width = `${window.innerWidth}px`, $.height = `${window.innerHeight}px`), e.mask || ($.pointerEvents = "auto"), $;
}), de = o(ve() || 1050), Oe = H(() => {
const l = {
display: "block",
overflow: "hidden"
};
return e.mask || (l.pointerEvents = "none", l.backgroundColor = "transparent"), V.value && (l.backgroundColor = "transparent"), l.zIndex = de.value, l;
}), Se = H(() => ({
"modal-content": !0,
"modal-content-has-header": d.value,
"is-mobile": ce()
})), Ie = H(() => {
const l = {
display: d.value ? "" : "none"
};
return l["pointer-events"] = u.value ? "auto" : "none", l;
}), He = H(() => ({
"f-icon": !0,
modal_maximize: !0,
modalrevert: D.value
})), Re = H(() => ({
"modal-body": !0,
"f-utils-flex-column": C.value === "iframe",
"f-utils-fill": !0
}));
function Te() {
return {
height: `${e.footerHeight || 60}px`
};
}
const Pe = H(() => {
const l = {
textAlgin: k.value
}, y = Te();
return Object.assign(l, y);
});
function le(l) {
if (l == null || l.stopPropagation(), D.value) {
D.value = !1, _();
return;
}
te(), D.value = !0;
}
async function je(l, y) {
l.handle && await l.handle(y, l) && t.emit("closed", y);
}
function Le(l) {
l.width && (n.value = l.width), l.height && (a.value = l.height), l.buttons && (v.value = l.buttons), l.title && (P.value = l.title);
}
let ae = null, oe = null;
Ze(() => {
V.value = T();
}), re(() => {
E.value && !z.value && (z.value = E.value.parentElement, Y.value = z.value, w(L.value, E.value, Y.value)), Z.value && document.body.classList.add("modal-open"), ae = pt(e, t), oe = ht(e, t);
}), se(() => {
r && r(), ae && ae.remove(), oe && oe.remove();
}), t.expose({
modalElementRef: E,
updateModalOptions: Le,
close: N,
maxDialog: le,
isMaximized: D,
disableButtons: (l, y = !0) => {
v.value.forEach((I) => {
I.name && l.includes(I.name) && (I.disabled = y);
});
}
});
function Fe() {
return h("ul", null, [O.value && h("li", {
class: "f-btn-icon f-bare"
}, [h("span", {
class: "f-icon modal_minimize"
}, null)]), g.value && h("li", {
onClick: le,
class: "f-btn-icon f-bare",
style: "pointer-events: auto;"
}, [h("span", {
class: He.value
}, null)]), B.value && h("li", {
class: "f-btn-icon f-bare",
onClick: (l) => N(l, !1),
style: "pointer-events: auto;"
}, [h("span", {
class: "f-icon modal_close"
}, null)])]);
}
function We() {
return h("div", {
class: "modal-footer",
style: Pe.value
}, [v.value && v.value.map((l) => {
const y = o(l.disabled);
return h("button", {
name: l.name,
style: l.styles,
type: "button",
disabled: y.value,
class: l.class + (l.iconClass ? " btn-icontext" : ""),
onClick: (I) => {
je(l, I);
}
}, [!!l.iconClass && h("i", {
class: l.iconClass
}, null), l.text]);
})]);
}
function fe(l) {
g.value && le();
}
function De() {
return h(me, null, [D.value && h("div", {
class: "modal-header",
style: "position: absolute;background: transparent;height: 45px;width: 100%;",
onDblclick: (l) => fe()
}, null), h("div", {
ref: L,
class: "modal-header",
style: Ie.value,
onDblclick: (l) => fe()
}, [t.slots.headerTemplate ? t.slots.headerTemplate() : h("div", {
class: "modal-title"
}, [f.value && h("span", {
class: m.value,
style: "margin-right: 8px"
}, null), h("span", {
class: "modal-title-label"
}, [P.value])]), h("div", {
class: "actions"
}, [Fe()])])]);
}
function Ve() {
return t.slots.footerTemplate ? t.slots.footerTemplate() : b.value && We();
}
function Ne(l) {
if (l.stopPropagation(), e.allowClickMaskToClose) {
if (l.target !== S.value)
return;
N(l, !1);
}
}
function $e() {
var l, y;
return h("div", {
id: s.value,
class: Ee.value,
style: ze.value,
ref: E
}, [h("div", {
class: Se.value
}, [d.value && De(), h("div", {
class: Re.value
}, [(y = (l = t.slots).default) == null ? void 0 : y.call(l), C.value === "iframe" && h("iframe", {
title: s.value,
class: "f-utils-fill",
width: "100%",
frameborder: "0",
src: M.value
}, null)]), Ve()]), !i.value && E.value && !D.value && J(E.value)]);
}
function Ae(l) {
return l || "body";
}
return Qe(() => {
Z.value && (de.value = ve() || 1050);
}), () => h(pe, {
to: Ae(e.host)
}, {
default: () => [Z.value && h(et, {
name: "fade",
appear: !0
}, {
default: () => [h("div", {
ref: S,
class: ke.value,
style: Oe.value,
onClick: Ne
}, [$e()])]
})]
});
}
});
function we(e) {
if (e.content && e.content.render)
return e.content.render;
if (e.render && typeof e.render == "function")
return e.render;
}
function mt(e) {
const t = document.createElement("div");
t.style.display = "contents";
const n = he({
setup(a, c) {
se(() => {
document.body.removeChild(t);
});
const s = o(), p = o(e.class || ""), i = o(!!e.showButtons), d = o(!!e.showHeader), m = o(e.showCloseButton == null ? !0 : e.showCloseButton), B = o(!0), g = o(e.title || ""), O = e.acceptCallback || (() => {
}), C = e.rejectCallback || (() => {
}), M = e.closedCallback || ((S) => {
}), k = e.resizeHandle || ((S) => {
}), j = e.stopMoveHandle || ((S) => {
}), P = we(e), z = (S) => {
B.value = !1, n.unmount(), M(S);
};
return re(() => {
}), c.expose({
modalRef: s
}), () => h(K, {
ref: s,
class: p.value,
modelValue: B.value,
"onUpdate:modelValue": (S) => B.value = S,
title: g.value,
width: e.width,
height: e.height,
buttons: e.buttons,
"show-header": d.value,
"show-buttons": i.value,
"show-close-button": m.value,
"show-max-button": !1,
onAccept: O,
onCancel: C,
fitContent: e.fitContent == null ? !0 : e.fitContent,
onClosed: z,
onResize: k,
onStopMove: j
}, {
default: () => [P && P(n)]
});
}
});
return document.body.appendChild(t), n.use(Q.i18n), n.mount(t), n;
}
class yt {
// private activeModalInstance = computed(() => {
// return this.modalRefs[this.activeModalIndex.value];
// });
constructor(t) {
q(this, "appContext", null);
q(this, "modalRef", o());
q(this, "activeModalIndex", o(0));
q(this, "modalRefs", {});
q(this, "isUseEscCloseModal", o(!1));
this.app = t, this.appContext = t ? t._context : null;
}
getCurrentModal() {
return this.modalRefs[this.activeModalIndex.value];
}
adaptToWindow(t, n) {
const {
width: a,
height: c
} = {
width: window.innerWidth,
height: window.innerHeight
};
return a < t && (t = a - 14), c < n && (n = c - 14), {
width: t,
height: n
};
}
static show(t) {
const n = Object.assign({
title: "",
showButtons: !0,
showHeader: !0
}, t);
return mt(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 = tt(Object.assign({
title: "",
showButtons: !0,
showHeader: !0,
maximized: !1
}, t)), c = o(!0), s = a.value.acceptCallback || (() => {
}), p = a.value.rejectCallback || (() => {
}), i = a.value.closedCallback || ((f, b) => {
}), d = a.value.openedCallback || ((f) => {
}), m = a.value.resizeHandle || ((f) => {
}), B = t.stopMoveHandle || ((f) => {
});
let g;
const O = we(a.value), C = (f) => {
var L;
c.value = !1;
const b = (L = f == null ? void 0 : f.target) == null ? void 0 : L.classList.contains("modal_close");
i(f, this.isUseEscCloseModal.value ? "esc" : b ? "icon" : "button");
}, M = (f) => {
C(f), g && U(() => {
if (this.modalRefs[this.activeModalIndex.value] && delete this.modalRefs[this.activeModalIndex.value], ue(null, n), g = null, this.modalRef.value = null, this.modalRefs) {
const b = Object.keys(this.modalRefs).map((L) => Number(L));
b.length > 0 ? this.activeModalIndex.value = Math.max(...b) : this.activeModalIndex.value = 0;
}
this.isUseEscCloseModal.value = !1;
});
}, k = (f) => {
var b;
this.isUseEscCloseModal.value = !0, (b = this.getCurrentModal()) == null || b.close(f == null ? void 0 : f.event);
}, {
width: j,
height: P
} = a.value, z = this.adaptToWindow(j || 500, P || 320);
Object.assign(a.value, z);
const S = o(), V = () => h(K, ye({
ref: S,
modelValue: c.value,
"onUpdate:modelValue": (f) => c.value = f
}, a.value, {
isMessager: a.value.class && a.value.class.indexOf("modal-message") > -1,
onAccept: s,
onCancel: p,
onClosed: M,
onResize: m,
onEsc: k,
onStopMove: B,
maximized: a.value.maximized
}), {
default: () => [O && O(this.app)]
});
g = ((f) => {
const b = nt(V, f);
return b.appContext = this.appContext, ue(b, n), b;
})({
...a.value
// 'onUpdate:modelValue': onUpdateModelValue,
}), this.activeModalIndex.value++;
const W = this.activeModalIndex.value;
this.modalRefs[W] = S.value;
const v = (f) => {
a.value = {
...a.value,
...f
}, g && ue(lt(g, {
...a
}), n);
};
return U(() => {
this.modalRefs[W] = S.value, this.modalRef.value = S.value, d(new Event("opened"));
}), {
update: v,
destroy: M,
modalRef: this.modalRef,
close: () => {
this.modalRefs[W] && this.modalRefs[W].close();
},
disableButtons: (f, b = !0) => {
this.modalRefs[W] && this.modalRefs[W].disableButtons(f, b);
}
};
}
}
const Ce = Symbol("FModalService");
K.install = (e) => {
e.component(K.name, K);
const t = new yt(e);
e.provide(Ce, t), e.provide("FModalService", t);
};
function xe(e, t) {
function n() {
const a = e.beforeOpen || e.beforeClickButton || null;
let c = Promise.resolve(!0);
if (a) {
const s = a(t.value);
if (typeof s > "u")
return c;
typeof s == "boolean" ? c = Promise.resolve(s) : c = s;
}
return c;
}
return { judgeCanOpen: n };
}
function gt(e, t, n, a, c) {
const s = o(e.buttonBehavior), p = o(e.popupOnInput), i = H(() => ({
"input-group-append": !0,
"append-force-show": e.showButtonWhenDisabled && (e.readonly || e.disable)
})), { judgeCanOpen: d } = xe(e, c), m = H(() => e.showButtonWhenDisabled || (!e.editable || !e.readonly) && !e.disable), B = ge(Ce, null), g = o();
async function O(k) {
if (await d() && m.value) {
const j = !!t.slots.default;
if (s.value === "Modal") {
const P = e.modalOptions, z = B == null ? void 0 : B.open({
...P,
render: () => t.slots.default && t.slots.default()
});
g.value = z == null ? void 0 : z.modalRef;
}
s.value === "Overlay" && ct.show({
// host: buttonEditRef.value,
host: document.body,
backgroundColor: "rgba(0,0,0,.15)",
render: () => t.slots.default && t.slots.default()
}), j && s.value === "Popup" && a.togglePopup(!0), j && p.value && a.hidePopup(), t.emit("clickButton", { origin: k, value: e.modelValue });
}
}
function C(k) {
t.emit("mouseEnterIcon", k);
}
function M(k) {
t.emit("mouseLeaveIcon", k);
}
return {
buttonGroupClass: i,
onClickButton: O,
onMouseEnterButton: C,
onMouseLeaveButton: M,
modalRef: g
};
}
const G = "FarrisVue_PopoverInstancesKey";
function bt(e, t, n, a) {
const c = o(), s = o(!1), { judgeCanOpen: p } = xe(e, a);
A(() => c.value, (C, M) => {
window[G] = window[G] || /* @__PURE__ */ new WeakMap(), C ? window[G].set(n.value, C) : window[G].delete(n.value);
});
function i() {
if (window[G]) {
const C = window[G];
document.querySelectorAll(".f-button-edit,.v-popover").forEach((M) => {
const k = C.get(M);
k && M !== n.value && !n.value.closest(".popover-fitcontent") && k.hide();
});
}
}
function d() {
const C = c.value;
C && C.show(n.value);
}
async function m(C = !1) {
if (!!t.slots.default) {
if (!C && !s.value && !await p())
return;
s.value = !s.value, s.value && (await U(), d());
}
}
async function B(C = !1) {
if (!!t.slots.default) {
if (!C && !await p())
return;
s.value = !0, await U(), d();
}
}
function g() {
s.value = !1;
}
function O() {
s.value = !0, U(() => {
d();
});
}
return { hidePopup: g, showPopup: O, popup: B, shouldPopupContent: s, togglePopup: m, popoverRef: c, closeAllPopover: i };
}
function wt(e, t, n) {
const {
buttonGroupClass: a
} = n, c = o();
return {
renderButtonGroup: () => h("div", {
id: e.id ? `${e.id}-button-group` : void 0,
class: a.value
}, [t.slots.buttonContent ? h("span", {
class: "input-group-text input-group-append-button"
}, [t.slots.buttonContent()]) : e.buttonContent ? h("span", {
class: "input-group-text input-group-append-button",
innerHTML: e.buttonContent,
ref: c
}, null) : null]),
buttonHandleElement: c
};
}
const ee = /* @__PURE__ */ ie({
name: "FButtonEdit",
props: ot,
emits: ["updateExtendInfo", "clear", "change", "click", "clickButton", "blur", "focus", "mouseEnterIcon", "mouseLeaveIcon", "keyup", "keydown", "inputClick", "input", "update:modelValue"],
setup(e, t) {
const n = o(), a = ge("design-item-context"), c = at(n, a), s = o(e.customClass), p = o(e.modelValue), i = bt(e, t, n, p), d = gt(e, t, n, i, p), m = o(), B = H(() => ({
"f-cmp-inputgroup": !0,
"input-group": !0,
"f-state-disabled": !0,
"f-state-editable": !1,
"f-state-readonly": !0
}));
re(() => {
n.value.componentInstance = c;
}), t.expose(c.value);
const g = H(() => {
const C = {
"f-button-edit": !0,
"f-cmp-inputgroup": !0,
"f-button-edit-nowrap": !e.wrapText
};
return s.value && s.value.split(" ").reduce((M, k) => (M[k] = !0, M), C), C;
}), {
renderButtonGroup: O
} = wt(e, t, d);
return () => h("div", ye(t.attrs, {
ref: n,
class: g.value,
id: e.id ? e.id : void 0
}), [h("div", {
class: B.value
}, [h("input", {
ref: m,
class: "form-control",
readonly: !0,
placeholder: e.placeholder
}, null), O()])]);
}
}), Ct = /* @__PURE__ */ new Map([
["appearance", Ue]
]);
function xt(e, t, n) {
return t;
}
const Bt = "https://json-schema.org/draft/2020-12/schema", Mt = "https://farris-design.gitee.io/button-edit.schema.json", kt = "button-edit", Et = "A Farris Input Component", zt = "object", Ot = {
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: "string",
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: "string",
default: ""
},
separator: {
type: "string",
default: ","
},
showButtonWhenDisabled: {
description: "",
type: "boolean",
default: !1
},
wrapText: {
type: "boolean",
default: !1
},
onClear: {
description: "",
type: "string",
default: ""
},
onClickButton: {
description: "",
type: "string",
default: ""
},
modelValue: {
description: "",
type: "string",
default: ""
}
}, St = [
"id",
"type"
], It = {
$schema: Bt,
$id: Mt,
title: kt,
description: Et,
type: zt,
properties: Ot,
required: St
}, Ht = "buttonEdit", Rt = "A Farris Component", Tt = "object", Pt = {
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: "右对齐"
}
]
}
}
}
}
}, jt = {
title: Ht,
description: Rt,
type: Tt,
categories: Pt
}, Be = Ke(
_e,
It,
Ct,
xt,
jt
);
ee.register = (e, t, n, a) => {
e["button-edit"] = Je, t["button-edit"] = Be;
};
ee.registerDesigner = (e, t, n) => {
e["button-edit"] = ee, t["button-edit"] = Be;
};
const Xt = Ge(ee);
export {
ee as FButtonEditDesign,
Xt as default,
Be as propsResolver
};