UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,521 lines 153 kB
var Cn = Object.defineProperty; var Sn = (e, t, n) => t in e ? Cn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var ge = (e, t, n) => Sn(e, typeof t != "symbol" ? t + "" : t, n); import { ref as w, computed as V, createVNode as S, Fragment as at, defineComponent as Ue, watch as Se, nextTick as jt, onBeforeMount as Tn, onMounted as it, onUnmounted as pt, Teleport as xn, Transition as Wt, shallowRef as kn, createApp as Gt, render as Mt, h as Fn, cloneVNode as Bn, mergeProps as Dt, reactive as He, createTextVNode as Mn, inject as En } from "vue"; import { useI18n as Nt } from "vue-i18n"; import { resolveAppearance as On, createPropsResolver as Ut, getSchemaByTypeForDesigner as Rn } from "../dynamic-resolver/index.esm.js"; import { LocaleService as mt } from "../locale/index.esm.js"; import { cloneDeep as Et, isPlainObject as At, isUndefined as Pe } from "lodash-es"; import "../accordion/index.esm.js"; import "../avatar/index.esm.js"; import "../../designer/button-edit/index.esm.js"; import "../button-group/index.esm.js"; import "../calendar/index.esm.js"; import "../capsule/index.esm.js"; import "../../designer/checkbox/index.esm.js"; import "../../designer/checkbox-group/index.esm.js"; import "../combo-list/index.esm.js"; import "../combo-tree/index.esm.js"; import "../component/index.esm.js"; import "../color-picker/index.esm.js"; import "../content-container/index.esm.js"; import "../date-picker/index.esm.js"; import "../../designer/data-grid/index.esm.js"; import "../dropdown/index.esm.js"; import "../dynamic-form/index.esm.js"; import "../events-editor/index.esm.js"; import "../filter-bar/index.esm.js"; import "../field-selector/index.esm.js"; import "../binding-selector/index.esm.js"; import "../image-cropper/index.esm.js"; import "../../designer/input-group/index.esm.js"; import "../layout/index.esm.js"; import "../list-nav/index.esm.js"; import "../../designer/list-view/index.esm.js"; import "../lookup/index.esm.js"; import "../mapping-editor/index.esm.js"; import "../nav/index.esm.js"; import "../number-range/index.esm.js"; import "../number-spinner/index.esm.js"; import "../order/index.esm.js"; import "../page-header/index.esm.js"; import "../page-footer/index.esm.js"; import "../pagination/index.esm.js"; import "../progress/index.esm.js"; import "../query-solution/index.esm.js"; import "../../designer/radio-group/index.esm.js"; import "../rate/index.esm.js"; import "../response-toolbar/index.esm.js"; import "../response-layout/index.esm.js"; import "../response-layout-editor/index.esm.js"; import "../search-box/index.esm.js"; import "../section/index.esm.js"; import "../smoke-detector/index.esm.js"; import "../splitter/index.esm.js"; import "../step/index.esm.js"; import "../switch/index.esm.js"; import "../tabs/index.esm.js"; import "../tags/index.esm.js"; import "../text/index.esm.js"; import "../time-picker/index.esm.js"; import "../transfer/index.esm.js"; import "../tree-view/index.esm.js"; import "../uploader/index.esm.js"; import "../verify-detail/index.esm.js"; import "../video/index.esm.js"; import "../textarea/index.esm.js"; import "../schema-selector/index.esm.js"; import "../../designer/tree-grid/index.esm.js"; import "../event-parameter/index.esm.js"; import "../filter-condition-editor/index.esm.js"; import "../fieldset/index.esm.js"; import "../sort-condition-editor/index.esm.js"; import "../menu-lookup/index.esm.js"; import "../../designer/drawer/index.esm.js"; import "../json-editor/index.esm.js"; import "../property-editor/index.esm.js"; import "../expression-editor/index.esm.js"; import "../code-editor/index.esm.js"; import "../html-template/index.esm.js"; import "../collection-property-editor/index.esm.js"; import "../modal/index.esm.js"; import "../external-container/index.esm.js"; import "../language-textbox/index.esm.js"; import "../designer-canvas/index.esm.js"; import { getCustomClass as Ot, withInstall as jn, FormSchemaEntityField$Type as Vt, FormSchemaEntityFieldTypeName as _t } from "../common/index.esm.js"; import { useResizeObserver as Dn } from "@vueuse/core"; import { getHierarchyRow as Nn, useIdentify as Pn, useGroupData as In, useFilter as Hn, useHierarchy as $n, useLoading as zn, useDataView as Ln, useSelection as An, useSelectHierarchyItem as Vn, usePagination as _n, useDataViewContainerStyle as qn, useCommandColumn as Wn, useSettingColumn as Gn, useColumn as Un, useSort as Yn, useGroupColumn as Xn, useRow as Jn, useEdit as Qn, useVisualDataBound as Zn, useVisualDataCell as Kn, useVisualDataRow as eo, useVisualData as to, useCellPosition as no, useSidebar as oo, useVirtualScroll as ro, useFitColumn as ao, useFilterHistory as io, useColumnFilter as lo, useDragColumn as so, getColumnHeader as uo, getSidebar as co, getDisableMask as fo, getHorizontalScrollbar as po, getVerticalScrollbar as mo, getEmpty as vo, getPagination as ho, getSummary as go } from "../data-view/index.esm.js"; import "../property-panel/index.esm.js"; import "../notify/index.esm.js"; const yo = { width: { Type: Number, default: 400 }, type: { Type: String, default: "info" }, title: { Type: String, default: "" }, detail: { Type: String, default: "" }, okButtonText: { Type: String, default: "确定" }, showOkButton: { Type: Boolean, default: !0 }, showCancelButton: { Type: Boolean, default: !0 }, cancelButtonText: { Type: String, default: "取消" }, exceptionInfo: { Type: Object, default: null }, promptEditorType: { Type: String, default: "text-area" }, buttons: { type: Object, default: [] } }; function Pt() { return new DOMException("The request is not allowed", "NotAllowedError"); } async function bo(e) { if (!navigator.clipboard) throw Pt(); return navigator.clipboard.writeText(e); } async function wo(e) { const t = document.createElement("span"); t.textContent = e, t.style.whiteSpace = "pre", t.style.webkitUserSelect = "auto", t.style.userSelect = "all", document.body.appendChild(t); const n = window.getSelection(), o = window.document.createRange(); n == null || n.removeAllRanges(), o.selectNode(t), n == null || n.addRange(o); let r = !1; try { r = window.document.execCommand("copy"); } finally { n == null || n.removeAllRanges(), window.document.body.removeChild(t); } if (!r) throw Pt(); } async function Co(e) { try { await bo(e); } catch (t) { try { await wo(e); } catch (n) { throw n || t || Pt(); } } } function So() { async function e(t) { await Co(t); } return { onCopy: e }; } function To(e, t, n, o) { const r = w(14), i = w(140), a = w(""), d = w(o.value.length), u = V(() => o.value), l = V(() => ({ "font-size": `${r.value}px`, height: "100%" })); function h(s) { if (s.currentTarget) { const p = s.currentTarget.value || ""; d.value = p.length; } } return () => S(at, null, [S("textarea", { title: "promptMessage", name: "promptMessage", class: "form-control", style: l.value, rows: "4", maxlength: i.value, onInput: (s) => h(s) }, [u.value]), S("span", { class: "textarea-wordcount", title: a.value, style: "position: absolute; bottom: 76px; right: 32px; cursor: pointer; text-align: right;" }, [d.value + " / " + i.value])]); } function xo(e, t, n, o) { const r = To(e, t, n, o), i = /* @__PURE__ */ new Map([["text-area", r]]); function a(d) { return i.get(d) || null; } return { getEditorRender: a }; } function ko() { const e = w(!1), t = w("复制成功"); return { feedbackStyle: V(() => { const o = { position: "absolute", left: "50%", top: "50%", "min-width": "100px", height: "40px", background: "#303C53", "line-height": "40px", "text-align": "center", "margin-left": "-30px", "margin-top": "-50px", "border-radius": "10px", "box-shadow": "0px 2px 8px 0px", color: "#fff", transition: "all .3s ease", padding: "0 10px" }; return o.opacity = e.value ? "0.8" : "0", o.display = e.value ? "" : "none", o; }), feedbackMessage: t, toShowFeedback: e }; } function Fo(e, t) { const n = t.getEditorRender(e.promptEditorType); return () => n && n(); } function Bo(e, t) { function n(c) { if (c == null) return 0; let f = 0; for (let g = 0; g < c.length; g++) { const B = c.charCodeAt(g); B >= 0 && B <= 128 ? f++ : f = f + 2; } return f; } function o(c, f) { if (c !== "" && c !== void 0 && c !== null) { c = "" + c; const g = c.length; let B = "", E = 0; for (let N = 0; N < g; N++) { const _ = c.charAt(N); if (E++, encodeURI(_).length > 4 && E++, B = B.concat(_), E >= f) return B = B.concat("..."), B; } if (E < f) return c; } return ""; } const r = V(() => !!e.value && !!e.value.date), i = V(() => { const c = e.value && e.value.date || ""; return `${t.exception.happend} : ${c}`; }), a = V(() => !!e.value && !!e.value.detail), d = V(() => e.value ? n(e.value.detail) > 160 : !1), u = w(!1), l = V(() => u.value ? t.exception.collapse : t.exception.expand), h = V(() => { const c = t.exception.detail + " : " + (e.value && e.value.detail) || ""; return u.value ? c : o(c, 160); }), s = V(() => ({ position: "absolute", right: 0, bottom: u.value ? 0 : "2px", color: "#2A87FF", cursor: "pointer" })); function p() { u.value = !u.value; } return () => S("div", { class: "toast-msg-detail" }, [r.value && S("div", null, [i.value]), a.value && S("div", { class: "exception_wrap" }, [S("div", { class: "exception_error_msg" }, [S("div", { innerHTML: h.value }, null), d.value && S("span", { style: s.value, onClick: p }, [l.value])])])]); } function Mo(e) { return () => S("p", { class: "toast-msg-detail", innerHTML: e.value }, null); } function Eo(e, t, n, o, r) { const i = w(e.exceptionInfo), a = V(() => { const f = t.value === "question" ? "warning" : t.value, g = { "f-icon": !0 }, B = `f-icon-${f}`; return g[B] = !0, g; }), d = V(() => n.value || i.value && i.value.message), u = V(() => o.value), l = V(() => !!o.value), h = V(() => !!i.value); function s() { return h.value ? Bo(i, r) : l.value ? Mo(u) : () => null; } const p = s(), c = V(() => r.locale === "en" ? { wordBreak: "keep-all", overflowWrap: "break-word" } : {}); return () => S(at, null, [S("div", { class: "float-left modal-tips-iconwrap" }, [S("span", { class: a.value }, null)]), S("div", { class: "modal-tips-content" }, [S("p", { class: "toast-msg-title", innerHTML: d.value, style: c.value }, null), p()])]); } function Oo(e, t, n, o) { const { onCopy: r } = t, { toShowFeedback: i } = n, a = w(o.exception.copySuccess || "复制成功"), d = w(o.exception.copy || "复制详细信息"), u = w(e.exceptionInfo || { date: "", message: "", detail: "" }), l = V(() => u.value && u.value.detail || ""); function h(s) { r(l.value).catch((p) => { a.value = o.exception.copyFailed || "复制失败"; }).finally(() => { i.value = !0, setTimeout(() => { i.value = !1; }, 700); }); } return () => S("span", { style: "width: 100%;color: #2A87FF;padding-left: 37px;" }, [S("span", { onClick: h, style: "cursor: pointer;" }, [d.value])]); } function Ro(e, t, n, o, r) { const i = w(e.type), a = w(e.buttons), d = w(e.exceptionInfo), u = w(r.ok || e.okButtonText), l = w(r.cancel || e.cancelButtonText), h = w(e.showCancelButton), s = w(e.showOkButton), p = V(() => !!(a.value && a.value.length)), c = V(() => d.value && d.value.message && d.value.detail), f = V(() => !(a.value && a.value.length) && (s.value || h.value)), g = Oo(e, n, o, r); u.value === "关闭" ? u.value = r.close : u.value === "知道了" && (u.value = r.exception.roger); function B(N) { i.value === "question" && t.emit("reject"), t.emit("close"); } function E(N) { i.value === "question" && t.emit("accept"), t.emit("close"); } return () => S("div", { class: "modal-footer" }, [c.value && g(), f.value && h.value && S("button", { type: "button", class: "btn btn-secondary btn-lg", onClick: B }, [l.value]), f.value && s.value && S("button", { type: "button", class: "btn btn-primary btn-lg", onClick: E }, [u.value]), p.value && a.value.length && a.value.map((N) => S("button", { type: "button", onClick: N.handle, class: N.class }, [N.iconClass && S("span", { class: N.iconClass }, null), N.text]))]); } function jo(e) { const { t, locale: n } = Nt(); function o(r, i, a) { return i === a ? t(r) : i; } return { yes: o("messageBox.yes") || "是", no: o("messageBox.no") || "否", close: o("messageBox.close") || "关闭", ok: o("messageBox.ok", e.okButtonText, "确定") || "确定", cancel: o("messageBox.cancel", e.cancelButtonText, "取消") || "取消", title: o("messageBox.title") || "系统提示", errorTitle: o("messageBox.errorTitle") || "错误提示", exception: { expand: o("messageBox.exception.expand") || "展开", collapse: o("messageBox.exception.collapse") || "收起", happend: o("messageBox.exception.happend") || "发生时间", detail: o("messageBox.exception.detail") || "详细信息", copy: o("messageBox.exception.copy") || "复制详细信息", copySuccess: o("messageBox.exception.copySuccess") || "复制成功", copyFailed: o("messageBox.exception.copyFailed") || "复制失败", roger: o("messageBox.exception.roger") || "知道了" }, locale: n.value }; } const ct = /* @__PURE__ */ Ue({ name: "FMessageBox", props: yo, emits: ["accept", "reject", "close"], setup(e, t) { const n = jo(e), o = w(e.type), r = w(e.title), i = w(e.detail), a = V(() => { const E = { "modal-tips": !0, "d-flex": !0, "flex-row": !0 }, N = `messager-type-${o.value}`; return E[N] = !0, E; }), d = V(() => { const E = { cursor: "default" }; return o.value === "prompt" ? E.padding = "0.5rem 0.5rem 1rem 1.5rem" : o.value === "error" && (E.padding = "0.5rem 1.5rem 1rem 1.5rem"), E; }), u = So(), l = xo(e, o, r, i), h = ko(), { feedbackStyle: s, feedbackMessage: p } = h; p.value = n.exception.copySuccess; function c() { return S("div", { style: s.value }, [p.value]); } function f() { switch (o.value) { case "prompt": return Fo(e, l); default: return Eo(e, o, r, i, n); } } const g = f(), B = Ro(e, t, u, h, n); return () => S("div", { class: "farris-messager" }, [!e.exceptionInfo && S("div", { style: "height: 30px;width: 100%;position: absolute;", class: "messager-draggable" }, null), S("section", { class: a.value, style: d.value }, [g()]), B(), c()]); } }), Do = "https://json-schema.org/draft/2020-12/schema", No = "https://farris-design.gitee.io/modal.schema.json", Po = "modal", Io = "弹窗组件", Ho = "object", $o = { id: { description: "组件唯一标识", type: "string" }, type: { description: "组件类型", type: "string", default: "modal" }, appearance: { description: "组件外观", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, name: { description: "名称", type: "string", default: null }, title: { description: "标题", type: "string" }, width: { description: "窗口宽度", type: "number", default: 900 }, height: { description: "窗口高度", type: "number", default: 600 }, contents: { description: "弹窗子组件集合", type: "array", default: [] }, modelValue: { description: "是否显示", type: "boolean", default: !1 }, showCloseButton: { description: "显示关闭按钮", type: "boolean", default: !0 }, showMaxButton: { description: "显示最大化按钮", type: "boolean", default: !0 }, enableEsc: { description: "允许ESC关闭", type: "boolean", default: !0 }, resizeable: { description: "允许调整窗口尺寸", type: "boolean", default: !0 }, fitContent: { description: "是否自适应", type: "boolean", default: !1 }, showButtons: { description: "是否显示底部按钮", type: "boolean", default: !0 }, mask: { description: "是否模态", type: "boolean", default: !0 }, draggable: { description: "是否允许拖拽调整位置", type: "boolean", default: !0 }, onAccept: { description: "确定事件", type: "object", default: null }, onCancel: { description: "取消事件", type: "object", default: null }, beforeClose: { description: "关闭前回调", type: "object", default: null } }, zo = [ "id", "type" ], Lo = { onAccept: "确定事件", onCancel: "取消事件", beforeClose: "关闭前回调" }, Ao = { $schema: Do, $id: No, title: Po, description: Io, type: Ho, properties: $o, required: zo, events: Lo }, Vo = /* @__PURE__ */ new Map([ ["appearance", On] ]); function _o(e, t, n) { return t; } function qo() { function e(t, n) { const o = {}; return o.beforeClose = (r) => n.call("beforeClose", [r, t]), o; } return { resolve: e }; } const Yt = { /** * 允许点击遮罩关闭对话框 */ 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 }, 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" } }, Wo = Ut(Yt, Ao, Vo, _o), Go = qo(); class re { constructor(t, n) { this.x = t, this.y = n; } static getTransformInfo(t) { const o = window.getComputedStyle(t).getPropertyValue("transform").replace(/[^-\d,]/g, "").split(","); if (o.length >= 6) { const r = parseInt(o[4], 10), i = parseInt(o[5], 10); return { x: r, y: i }; } return { x: 0, y: 0 }; } static fromEvent(t, n = null) { if (this.isMouseEvent(t)) return new re(t.clientX, t.clientY); if (n === null || t.changedTouches.length === 1) return new re(t.changedTouches[0].clientX, t.changedTouches[0].clientY); for (let o = 0; o < t.changedTouches.length; o++) if (t.changedTouches[o].target === n) return new re(t.changedTouches[o].clientX, t.changedTouches[o].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 re(0, 0); if (window) { const o = window.getComputedStyle(t); if (o) { const r = parseInt(o.getPropertyValue("left"), 10), i = parseInt(o.getPropertyValue("top"), 10); n.x = isNaN(r) ? 0 : r, n.y = isNaN(i) ? 0 : i; } return n; } return null; } static copy(t) { return new re(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 We { constructor(t, n) { this.width = t, this.height = n; } static getCurrent(t) { const n = new We(0, 0); if (window) { const o = window.getComputedStyle(t); return o && (n.width = parseInt(o.getPropertyValue("width"), 10), n.height = parseInt(o.getPropertyValue("height"), 10)), n; } return null; } static copy(t) { return new We(0, 0).set(t); } set(t) { return this.width = t.width, this.height = t.height, this; } } function Uo(e, t) { const n = w(), o = w(), r = w(), i = w(), a = w(), d = w(), u = w(), l = w(), h = w(), s = w(), p = w(), c = w(e.resizeable), f = w(), g = w(e.draggable), B = w(!1); function E() { const P = o.value || document.body, R = window.getComputedStyle(P); if (!R || !n.value) return; const U = re.getTransformInfo(n.value), L = {}; u.value && (L.deltaL = n.value.offsetLeft - u.value.x, L.deltaT = n.value.offsetTop - u.value.y); const ee = R.getPropertyValue("position"); L.width = P.clientWidth, L.height = P.clientHeight, L.pr = parseInt(R.getPropertyValue("padding-right"), 10), L.pb = parseInt(R.getPropertyValue("padding-bottom"), 10), L.position = R.getPropertyValue("position"), ee === "static" && (P.style.position = "relative"), L.translateX = U.x, L.translateY = U.y, s.value = L; } function N(P) { if (n.value) { i.value = We.getCurrent(n.value), a.value = re.getCurrent(n.value), d.value = i.value ? We.copy(i.value) : null, u.value = a.value ? re.copy(a.value) : null, E(); const R = P.target.getAttribute("type") || ""; l.value = { n: !!R.match(/n/), s: !!R.match(/s/), w: !!R.match(/w/), e: !!R.match(/e/) }; } } function _() { var P, R, U, L; if (n.value) { const ee = n.value; l.value && ((l.value.n || l.value.s) && ((P = d.value) != null && P.height) && (ee.style.height = d.value.height + "px"), (l.value.w || l.value.e) && ((R = d.value) != null && R.width) && (ee.style.width = d.value.width + "px"), u.value && ((U = u.value) != null && U.x && (ee.style.left = u.value.x + "px"), (L = u.value) != null && L.y && (ee.style.top = u.value.y + "px"))); } } function T() { const P = e.minHeight ? e.minHeight : 1, R = e.minWidth ? e.minWidth : 1; d.value && u.value && l.value && i.value && (d.value.height < P && (d.value.height = P, l.value.n && a.value && (u.value.y = a.value.y + (i.value.height - P))), d.value.width < R && (d.value.width = R, l.value.w && a.value && (u.value.x = a.value.x + (i.value.width - R))), e.maxHeight && d.value.height > e.maxHeight && (d.value.height = e.maxHeight, a.value && l.value.n && (u.value.y = a.value.y + (i.value.height - e.maxHeight))), e.maxWidth && d.value.width > e.maxWidth && (d.value.width = e.maxWidth, l.value.w && a.value && (u.value.x = a.value.x + (i.value.width - e.maxWidth)))); } function m() { if (o.value) { const P = s.value; if (u.value && d.value && l.value && i.value) { const R = P.width - P.pr - P.deltaL - P.translateX - u.value.x, U = P.height - P.pb - P.deltaT - P.translateY - u.value.y; l.value.n && u.value.y + P.translateY < 0 && a.value && (u.value.y = -P.translateY, d.value.height = i.value.height + a.value.y + P.translateY), l.value.w && u.value.x + P.translateX < 0 && a.value && (u.value.x = -P.translateX, d.value.width = i.value.width + a.value.x + P.translateX), d.value.width > R && (d.value.width = R), d.value.height > U && (d.value.height = U); } } } function v(P) { if (!r.value || !i.value || !a.value || !l.value) return; P.subtract(r.value); const R = P.x, U = P.y; l.value.n ? (u.value.y = a.value.y + U, d.value.height = i.value.height - U) : l.value.s && (d.value.height = i.value.height + U), l.value.e ? d.value.width = i.value.width + R : l.value.w && (d.value.width = i.value.width - R, u.value.x = a.value.x + R), m(), T(), _(); } function k(P) { if (!h.value) return; const R = re.fromEvent(P); R && v(R); } function x() { if (n.value) { const { width: P, height: R, x: U, y: L } = n.value.getBoundingClientRect(), ee = re.getTransformInfo(n.value); return { size: { width: P, height: R }, position: { x: U - ee.x, y: L - ee.y } }; } return null; } function C(P) { if (n.value) { const R = x(); p.value = R; } r.value = void 0, i.value = null, a.value = null, d.value = null, u.value = null, l.value = null, h.value = null, document.removeEventListener("mousemove", k), document.removeEventListener("mouseup", C); } function O() { document.addEventListener("mousemove", k), document.addEventListener("mouseup", C); } function b(P) { P instanceof MouseEvent && P.button === 2 || g.value && (document.body.click(), P.stopPropagation(), P.preventDefault(), r.value = re.fromEvent(P), h.value = P.target, N(P), O()); } function F(P) { return n.value = P, c.value && S(at, null, [S("div", { class: "fv-resizable-handle fv-resizable-n", type: "n", onMousedown: (R) => b(R) }, null), S("div", { class: "fv-resizable-handle fv-resizable-e", type: "e", onMousedown: (R) => b(R) }, null), S("div", { class: "fv-resizable-handle fv-resizable-s", type: "s", onMousedown: (R) => b(R) }, null), S("div", { class: "fv-resizable-handle fv-resizable-w", type: "w", onMousedown: (R) => b(R) }, null), S("div", { class: "fv-resizable-handle fv-resizable-ne", type: "ne", onMousedown: (R) => b(R) }, null), S("div", { class: "fv-resizable-handle fv-resizable-se fv-resizable-diagonal", type: "se", onMousedown: (R) => b(R) }, null), S("div", { class: "fv-resizable-handle fv-resizable-sw", type: "sw", onMousedown: (R) => b(R) }, null), S("div", { class: "fv-resizable-handle fv-resizable-nw", type: "nw", onMousedown: (R) => b(R) }, null)]); } function j(P = !0) { document.body.click(); const R = o.value || document.body, U = We.getCurrent(R), L = n.value; P && L && (f.value = x(), f.value.transform = L.style.transform), U && L && (d.value = U, d.value.height -= 14, d.value.width -= 14, L.style.height = d.value.height + "px", L.style.width = d.value.width + "px", L.style.left = "7px", L.style.top = "7px", L.style.transform = "", p.value = { size: d.value, position: { x: 0, y: 0 } }, g.value = !1, B.value = !0); } function D() { var P, R; if (document.body.click(), f.value) { const U = { width: f.value.size.width || 0, height: f.value.size.height || 0 }, L = { x: (window.innerWidth - U.width) / 2, y: (window.innerHeight - U.height) / 2 }; (P = d.value) == null || P.set(U), (R = u.value) == null || R.set(L); const ee = n.value; ee.style.height = U.height + "px", ee.style.width = U.width + "px", ee.style.left = `${L.x}px`, ee.style.top = `${L.y}px`, ee.style.transform = "", p.value = { size: U, position: L }, g.value = e.draggable, B.value = !1; } } function $() { if (n.value) { const P = We.getCurrent(n.value); if (P) { const { width: R, height: U } = P; n.value.style.left = `${(window.innerWidth - R) / 2}px`, n.value.style.top = `${(window.innerHeight - U) / 2}px`, n.value.style.transform = ""; } } } function G() { const P = () => { B.value ? j(!1) : $(), document.body.click(); }; return window.addEventListener("resize", P), () => { window.removeEventListener("resize", P); }; } const K = G(); return { renderResizeBar: F, boundingElement: o, resizedEventParam: p, maximize: j, restore: D, allowDrag: g, isMaximized: B, unWindowResizeHandle: K, moveToCenter: $ }; } function Yo(e, t, n) { const o = w(), r = w(e.draggable), i = w(e.lockAxis), a = w(), d = w(), u = w(!1), l = w(new re(0, 0)), h = w(new re(0, 0)), s = w(new re(0, 0)), p = w(new re(0, 0)); Se(() => n.value, (k) => { a.value.style.cursor = k ? "move" : "default"; }); function c(k, x) { if (x.tagName === "BUTTON") return !1; if (x === k) return !0; for (const C in x.children) if (Object.prototype.hasOwnProperty.call(x.children, C) && c(k, x.children[C])) return !0; return !1; } function f() { var O, b; let k = s.value.x + h.value.x, x = s.value.y + h.value.y; i.value === "x" ? (k = ((O = l.value) == null ? void 0 : O.x) || 0, s.value.x = 0) : i.value === "y" && (x = ((b = l.value) == null ? void 0 : b.y) || 0, s.value.y = 0); const C = `translate3d(${Math.round(k)}px, ${Math.round(x)}px, 0px)`; o.value && (o.value.style.transform = C), p.value.x = k, p.value.y = x; } function g() { if (!d.value || !o.value) return null; const k = d.value.getBoundingClientRect(), x = o.value.getBoundingClientRect(), C = { top: k.top < x.top, right: k.right > x.right, bottom: k.bottom > x.bottom, left: k.left < x.left }; return C.top || (s.value.y -= x.top - k.top), C.bottom || (s.value.y -= x.bottom - k.bottom), C.right || (s.value.x -= x.right - k.right), C.left || (s.value.x -= x.left - k.left), f(), C; } function B(k) { k && (l.value && k.subtract(l.value), s.value.set(k), f(), g()); } function E(k) { u.value && r.value && (k.stopPropagation(), k.preventDefault(), B(re.fromEvent(k, a.value))); } function N() { var k; u.value && (u.value = !1, h.value.add(s.value), s.value.reset(), (k = o.value) == null || k.classList.remove("ng-dragging"), t.emit("stopMove"), document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", N)); } function _() { !u.value && a.value && (u.value = !0, a.value.classList.add("ng-dragging"), document.addEventListener("mousemove", E), document.addEventListener("mouseup", N)); } function T() { if (o.value) { const k = re.getTransformInfo(o.value); h.value.set(k); return; } h.value.reset(); } function m(k) { if (!n.value || k instanceof MouseEvent && k.button === 2) return; const x = k.target || k.srcElement; a.value !== void 0 && x && !c(x, a.value) || r.value !== !1 && (document.body.click(), k.stopPropagation(), k.preventDefault(), l.value = re.fromEvent(k, o.value), T(), _()); } function v(k, x, C) { if (r.value && x) { if (k) a.value = k; else if (e.dragHandle) { if (e.dragHandle instanceof HTMLElement) a.value = e.dragHandle; else if (typeof e.dragHandle == "string") { const O = x.querySelector(e.dragHandle); O && (a.value = O); } } o.value = x, d.value = C, a.value ? (a.value.classList.add("ng-draggable"), a.value.addEventListener("mousedown", m)) : r.value = !1; } } return { registerDraggle: v, resetTranslate: T }; } function Xt(e, t) { if (e) { const n = (o) => { o.key.toLowerCase() === e.toLowerCase() && t({ event: o, key: e }); }; return document.addEventListener("keydown", n), () => { document.removeEventListener("keydown", n); }; } } function Xo(e, t) { const n = w(e.enableEsc); let o = null; return n.value ? (o = Xt("Escape", (r) => { t.emit("esc", { event: r.event, type: "esc" }); }), { remove: o }) : null; } function Jo(e, t) { const n = w(e.enableEnter); let o = null; return n.value ? (o = Xt("Enter", (r) => { t.emit("enter", { event: r.event, type: "enter" }); }), { remove: o }) : null; } const Ge = /* @__PURE__ */ Ue({ name: "FModal", props: Yt, emits: ["update:modelValue", "accept", "cancel", "closed", "resize", "esc", "enter", "stopMove"], setup(e, t) { const n = w(e.width || 300), o = w(e.height || 200), r = w(e.modelValue), i = w(""), a = w(e.class), d = w(e.fitContent), u = w(e.showHeader), l = w(""), h = w(e.showCloseButton), s = w(e.showMaxButton), p = w(!1), c = w(e.dialogType), f = w(e.src), g = w(""), B = w(e.showButtons), E = w(e.title), N = w(e.containment || null), _ = w(), { t: T } = Nt(); E.value === "错误提示" && (E.value = T("messageBox.errorTitle")); const m = w(!1); function v(M, J) { const ae = J ? "accept" : "cancel"; Promise.resolve().then(() => { var ie; return (ie = e.beforeClose) == null ? void 0 : ie.call(e, { closeType: ae }); }).then((ie) => { ie && (r.value = !1, t.emit("update:modelValue", !1), J != null && t.emit(J ? "accept" : "cancel"), t.emit("closed", M)); }); } const k = [{ name: "cancel", text: T("messageBox.cancel") || "取消", class: "btn btn-secondary", handle: (M) => { v(M, !1); } }, { name: "accept", text: T("messageBox.ok") || "确定", class: "btn btn-primary", handle: (M) => { v(M, !0); } }], x = w(e.buttons && e.buttons.length ? e.buttons : k), C = V(() => !!l.value), O = V(() => !!B.value && !!x.value), b = w(), F = w(), j = w(!1), { renderResizeBar: D, maximize: $, restore: G, boundingElement: K, resizedEventParam: P, allowDrag: R, unWindowResizeHandle: U, moveToCenter: L } = Uo(e), { registerDraggle: ee } = Yo(e, t, R); function me() { return !!document.querySelectorAll(".farris-modal").length && document.body.classList.contains("modal-open"); } function ve() { const M = document.querySelectorAll(".farris-modal").length; (!M || M - 1 <= 0) && document.body.classList.remove("modal-open"), _.value && _.value.classList.remove("show"); } Se(() => e.title, (M, J) => { M !== J && (E.value = M); }), Se(() => e.modelValue, (M, J) => { M !== J && (r.value = M, r.value && e.draggable && jt(() => { F.value && !N.value && (N.value = F.value.parentElement, K.value = N.value, ee(b.value, F.value, K.value), L()); }), M || (N.value && (N.value = null), ve())), r.value ? m.value = me() : (j.value = !1, R.value = e.draggable); }), Se(() => e.showHeader, (M, J) => { M !== J && (u.value = M); }), Se(() => e.showButtons, (M, J) => { M !== J && (B.value = M); }), Se(() => P.value, (M, J) => { const ae = M || {}, ie = J || {}; JSON.stringify(ae) !== JSON.stringify(ie) && t.emit("resize", { newSize: M, oldSize: J, isMaximized: j.value }); }); const X = V(() => (r.value && document.body.classList.add("modal-open"), r.value)), oe = V(() => { var ae; const M = { modal: !0, "farris-modal": !0, fade: !0 }; M["f-modal-fitContent"] = !!d.value, M.show = !!X.value; const J = (ae = e.maskClass) == null ? void 0 : ae.split(" "); return J == null || J.reduce((ie, Ne) => (ie[Ne] = !0, ie), M), M; }), le = V(() => { var ae; const M = { "modal-dialog": !0 }, J = (ae = a.value) == null ? void 0 : ae.split(" "); return J == null || J.reduce((ie, Ne) => (ie[Ne] = !0, ie), M), M; }), te = V(() => { const M = { position: "absolute", top: `${(window.innerHeight - o.value) / 2}px`, left: `${(window.innerWidth - n.value) / 2}px`, width: `${n.value}px`, height: d.value ? "auto" : `${o.value}px` }; return e.mask || (M.pointerEvents = "auto"), M; }), q = V(() => { const M = { display: "block" }; return e.mask || (M.pointerEvents = "none", M.backgroundColor = "transparent"), m.value && (M.backgroundColor = "transparent"), M; }), ne = V(() => ({ "modal-content": !0, "modal-content-has-header": u.value })), $e = V(() => { const M = { display: u.value ? "" : "none" }; return M["pointer-events"] = R.value ? "auto" : "none", M; }), Ee = V(() => ({ "f-icon": !0, modal_maximize: !0, modalrevert: j.value })), Te = V(() => ({ "modal-body": !0, "f-utils-flex-column": c.value === "iframe", "f-utils-fill": !0 })); function Ye() { return { height: `${e.footerHeight || 60}px` }; } const ze = V(() => { const M = { textAlgin: g.value }, J = Ye(); return Object.assign(M, J); }); function Le(M) { if (M == null || M.stopPropagation(), j.value) { j.value = !1, G(); return; } $(), j.value = !0; } async function se(M, J) { M.handle && await M.handle(J, M) && t.emit("closed", J); } function Ze(M) { M.width && (n.value = M.width), M.height && (o.value = M.height), M.buttons && (x.value = M.buttons), M.title && (E.value = M.title); } let xe = null, Oe = null; Tn(() => { m.value = me(); }), it(() => { F.value && !N.value && (N.value = F.value.parentElement, K.value = N.value, ee(b.value, F.value, K.value)), X.value && document.body.classList.add("modal-open"), xe = Xo(e, t), Oe = Jo(e, t); }), pt(() => { U && U(), xe && xe.remove(), Oe && Oe.remove(); }), t.expose({ modalElementRef: F, updateModalOptions: Ze, close: v, maxDialog: Le, isMaximized: j }); function Re() { return S("ul", null, [p.value && S("li", { class: "f-btn-icon f-bare" }, [S("span", { class: "f-icon modal_minimize" }, null)]), s.value && S("li", { onClick: Le, class: "f-btn-icon f-bare", style: "pointer-events: auto;" }, [S("span", { class: Ee.value }, null)]), h.value && S("li", { class: "f-btn-icon f-bare", onClick: (M) => v(M, !1), style: "pointer-events: auto;" }, [S("span", { class: "f-icon modal_close" }, null)])]); } function je() { return S("div", { class: "modal-footer", style: ze.value }, [x.value && x.value.map((M) => { const J = w(M.disabled); return S("button", { name: M.name, type: "button", disabled: J.value, class: M.class + (M.iconClass ? " btn-icontext" : ""), onClick: (ae) => { se(M, ae); } }, [!!M.iconClass && S("i", { class: M.iconClass }, null), M.text]); })]); } function Ke() { return S("div", { ref: b, class: "modal-header", style: $e.value }, [t.slots.headerTemplate ? t.slots.headerTemplate() : S("div", { class: "modal-title" }, [C.value && S("span", { class: l.value, style: "margin-right: 8px" }, null), S("span", { class: "modal-title-label" }, [E.value])]), S("div", { class: "actions" }, [Re()])]); } function Ae() { return t.slots.footerTemplate ? t.slots.footerTemplate() : O.value && je(); } function Me(M) { if (M.stopPropagation(), e.allowClickMaskToClose) { if (M.target !== _.value) return; v(M, !1); } } function De() { var M, J; return S("div", { id: i.value, class: le.value, style: te.value, ref: F }, [S("div", { class: ne.value }, [u.value && Ke(), S("div", { class: Te.value }, [(J = (M = t.slots).default) == null ? void 0 : J.call(M), c.value === "iframe" && S("iframe", { title: i.value, class: "f-utils-fill", width: "100%", frameborder: "0", src: f.value }, null)]), Ae()]), !d.value && F.value && !j.value && D(F.value)]); } function Xe(M) { return M || "body"; } return () => S(xn, { to: Xe(e.host) }, { default: () => [X.value && S(Wt, { name: "fade", appear: !0 }, { default: () => [S("div", { ref: _, class: oe.value, style: q.value, onClick: Me }, [De()])] })] }); } }); function Jt(e) { if (e.content && e.content.render) return e.content.render; if (e.render && typeof e.render == "function") return e.render; } function Qo(e) { const t = document.createElement("div"); t.style.display = "contents"; const n = Gt({ setup(o, r) { pt(() => { document.body.removeChild(t); }); const i = w(), a = w(e.class || ""), d = w(!!e.showButtons), u = w(!!e.showHeader), l = w(e.showCloseButton == null ? !0 : e.showCloseButton), h = w(!0), s = w(e.title || ""), p = e.acceptCallback || (() => { }), c = e.rejectCallback || (() => { }), f = e.closedCallback || ((_) => { }), g = e.resizeHandle || ((_) => { }), B = e.stopMoveHandle || ((_) => { }), E = Jt(e), N = (_) => { h.value = !1, n.unmount(), f(_); }; return it(() => { }), r.expose({ modalRef: i }), () => S(Ge, { ref: i, class: a.value, modelValue: h.value, "onUpdate:modelValue": (_) => h.value = _, title: s.value, width: e.width, height: e.height, buttons: e.buttons, "show-header": u.value, "show-buttons": d.value, "show-close-button": l.value, "show-max-button": !1, onAccept: p, onCancel: c, fitContent: e.fitContent == null ? !0 : e.fitContent, onClosed: N, onResize: g, onStopMove: B }, { default: () => [E && E(n)] }); } }); return document.body.appendChild(t), n.use(mt.i18n), n.mount(t), n; } class Qt { constructor(t) { ge(this, "appContext", null); ge(this, "modalRef", w()); ge(this, "activeModalIndex", w(0)); ge(this, "modalRefs", {}); ge(this, "isUseEscCloseModal", w(!1)); ge(this, "activeModalInstance", V(() => this.modalRefs[this.activeModalIndex.value])); this.app = t, this.appContext = t ? t._context : null; } getCurrentModal() { return this.activeModalInstance.value; } adaptToWindow(t, n) { const { width: o, height: r } = { width: window.innerWidth, height: window.innerHeight }; return o < t && (t = o - 14), r < n && (n = r - 14), { width: t, height: n }; } static show(t) { const n = Object.assign({ title: "", showButtons: !0, showHeader: !0 }, t); return Qo(n); } close(t) { var n, o; t ? (o = t.value) == null || o.close() : (n = this.getCurrentModal()) == null || n.close(); } open(t) { const n = document.createDocumentFragment(); t.showMaxButton && t.fitContent && (t.showMaxButton = !1); const o = kn(Object.assign({ title: "", showButtons: !0, showHeader: !0 }, t)), r = w(!0), i = o.value.acceptCallback || (() => { }), a = o.value.rejectCallback || (() => { }), d = o.value.closedCallback || ((m, v) => { }), u = o.value.resizeHandle || ((m) => { }), l = t.stopMoveHandle || ((m) => { }); let h; const s = Jt(o.value), p = (m) => { var k; r.value = !1; const v = (k = m == null ? void 0 : m.target) == null ? void 0 : k.classList.contains("modal_close"); d(m, this.isUseEscCloseModal.value ? "esc" : v ? "icon" : "button"); }, c = (m) => { p(m), h && jt(() => { if (this.modalRefs[this.activeModalIndex.value] && delete this.modalRefs[this.activeModalIndex.value], Mt(null, n), h = null, this.modalRef.value = null, this.modalRefs) { const v = Object.keys(this.modalRefs).map((k) => Number(k)); v.length > 0 ? this.activeModalIndex.value = Math.max(...v) : this.activeModalIndex.value = 0; } this.isUseEscCloseModal.value = !1; }); }, f = (m) => { var v; this.isUseEscCloseModal.value = !0, this.activeModalInstance && ((v = this.activeModalInstance.value) == null || v.close(m == null ? void 0 : m.event)); }, { width: g, height: B } = o.value, E = this.adaptToWindow(g || 500, B || 320); Object.assign(o.value, E); const N = () => S(Ge, Dt({ ref: this.modalRef, modelValue: r.value, "onUpdate:modelValue": (m) => r.value = m }, o.value, { onAccept: i, onCancel: a, onClosed: c, onResize: u, onEsc: f, onStopMove: l }), { default: () => [s && s(this.app)] }); return h = ((m) => { const v = Fn(N, m); return v.appContext = this.appContext, Mt(v, n), v; })({ ...o.value // 'onUpdate:modelValue': onUpdateModelValue, }), this.activeModalIndex.value++, this.modalRefs[this.activeModalIndex.value] = this.modalRef.value, { update: (m) => { o.value = { ...o.value, ...m }, h && Mt(Bn(h, { ...o }), n); }, destroy: c, modalRef: this.activeModalInstance, close: () => this.close() }; } } function Zo(e = {}) { function t(l, h, s, p) { if (typeof s == "number") return p[l].length === s; if (typeof s == "object") { const c = Object.keys(s)[0], f = s[c]; if (c === "not") return Number(p[l].length) !== Number(f); if (c === "moreThan") return Number(p[l].length) >= Number(f); if (c === "lessThan") return Number(p[l].length) <= Number(f); } return !1; } function n(l, h, s, p) { return p[l] && p[l].propertyValue && String(p[l].propertyValue.value) === String(s); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((l, h) => (l.set(h, e[h]), l), o); function r(l, h) { const s = l; return typeof h == "number" ? [{ target: s, operator: "length", param: null, value: Number(h) }] : typeof h == "boolean" ? [{ target: s, operator: "getProperty", param: l, value: !!h }] : typeof h == "object" ? Object.keys(h).map((p) => { if (p === "length") return { target: s, operator: "length", param: null, value: h[p] }; const c = p, f = h[p]; return { target: s, operator: "getProperty", param: c, value: f }; }) : []; } function i(l) { return Object.keys(l).reduce((s, p) => { const c = r(p, l[p]); return s.push(...c), s; }, []); } function a(l, h) { if (o.has(l.operator)) { const s = o.get(l.operator); return s && s(l.target, l.param, l.value, h) || !1; } return !1; } function d(l, h) { return i(l).reduce((c, f) => c && a(f, h), !0); } function u(l, h) { const s = Object.keys(l), p = s.includes("allOf"), c = s.includes("anyOf"), f = p || c, E = (f ? l[f ? p ? "allOf" : "anyOf" : "allOf"] : [l]).map((_) => d(_, h)); return p ? !E.includes(!1) : E.includes(!0); } return { parseValueSchema: u }; } const Ko = { convertTo: (e, t, n, o) => { e.appearance || (e.appearance = {}), e.appearance[t] = n; }, convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t] }, er = { convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无" }, tr = { convertTo: (e, t, n, o) => { e.editor && (e.editor[t] = n); }, convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t] }, H = { button: { type: "button", name: "按钮" }, "response-toolbar": { type: "response-toolbar", name: "工具栏" }, "response-toolbar-item": { type: "response-toolbar-item", name: "按钮" }, "content-container": { type: "content-container", name: "容器" }, "input-group": { type: "input-group", name: "文本" }, textarea: { type: "textarea", name: "多行文本" }, lookup: { type: "lookup", name: "帮助" }, "number-spinner": { type: "number-spinner", name: "数值" }, "date-picker": { type: "date-picker", name: "日期" }, switch: { type: "switch", name: "开关" }, "radio-group": { type: "radio-group", name: "单选组" }, "check-box": { type: "check-box", name: "复选框" }, "check-group": { type: "check-group", name: "复选框组" }, "combo-list": { type: "combo-list", name: "下拉列表" }, "response-form": { type: "response-form", name: "卡片面板" }, "response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" }, "response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" }, "tree-grid": { type: "tree-grid", name: "树表格" }, "tree-grid-column": { type: "tree-grid-column", name: "树表格列" }, "data-grid": { type: "data-grid", name: "表格" }, "data-grid-column": { type: "data-grid-column", name: "表格列" }, module: {