UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,661 lines 386 kB
var bo = Object.defineProperty; var Co = (e, t, n) => t in e ? bo(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n; var q = (e, t, n) => Co(e, typeof t != "symbol" ? t + "" : t, n); import { defineComponent as Fe, ref as C, computed as N, createVNode as w, Teleport as pn, createApp as Jt, onUnmounted as Bt, Fragment as xt, watch as he, onBeforeMount as wo, onMounted as Je, Transition as mn, shallowRef as So, nextTick as St, render as Ht, h as xo, cloneVNode as _o, mergeProps as ct, inject as qe, withDirectives as vn, vShow as To, reactive as pt, createTextVNode as Ie, onBeforeUnmount as hn, resolveDirective as Fo, provide as ko, triggerRef as Io, isVNode as Bo, onUpdated as gn } from "vue"; import { isPlainObject as an, cloneDeep as mt, isUndefined as rn } from "lodash-es"; import { resolveAppearance as Eo, createPropsResolver as Mo } from "../dynamic-resolver/index.esm.js"; import yn from "../tags/index.esm.js"; import Oo from "../popover/index.esm.js"; import bn from "../list-view/index.esm.js"; import Qt from "../button-edit/index.esm.js"; import { useDesignerComponent as Cn, DgControl as sn } from "../designer-canvas/index.esm.js"; import "bignumber.js"; import { useDateFormat as Vo, useNumberFormat as Ro, resolveField as Ke, setFieldValue as qt, getCustomClass as At, withInstall as $t, FormSchemaEntityField$Type as un, FormSchemaEntityFieldType$Type as Do } from "../common/index.esm.js"; import { useResizeObserver as wn } from "@vueuse/core"; import { useIdentify as No, useGroupData as Po, useFilter as $o, useHierarchy as Lo, useLoading as jo, useDataView as Wo, useSelection as Ho, useSelectHierarchyItem as Ao, useDataViewContainerStyle as Go, useCommandColumn as zo, useColumn as qo, useSort as Uo, useGroupColumn as Yo, useRow as Xo, useEdit as Ko, useVisualDataBound as Jo, useVisualDataCell as Qo, useVisualDataRow as Zo, useVisualData as el, useCellPosition as tl, useSidebar as nl, useVirtualScroll as ol, useFitColumn as ll, useFilterHistory as al, useColumnFilter as il, useDragColumn as rl, getColumnHeader as sl, getSidebar as ul, getDisableMask as cl, getHorizontalScrollbar as dl, getVerticalScrollbar as fl, getEmpty as pl } from "../data-view/index.esm.js"; import "../modal/index.esm.js"; import ml from "../transfer/index.esm.js"; import vl from "../tabs/index.esm.js"; import hl from "../order/index.esm.js"; import "../condition/index.esm.js"; import gl, { FCheckbox as yl } from "../checkbox/index.esm.js"; import bl from "../filter-bar/index.esm.js"; import cn from "../tooltip/index.esm.js"; import Cl from "../pagination/index.esm.js"; import wl from "../button/index.esm.js"; import Sl from "../search-box/index.esm.js"; import xl, { FDynamicFormGroup as _l, FDynamicFormInput as Tl } from "../dynamic-form/index.esm.js"; import Fl from "../binding-selector/index.esm.js"; import "../notify/index.esm.js"; import kl from "../accordion/index.esm.js"; import Il from "../avatar/index.esm.js"; import Bl from "../button-group/index.esm.js"; import El from "../calendar/index.esm.js"; import Ml from "../capsule/index.esm.js"; import Ol from "../color-picker/index.esm.js"; import Ut from "../combo-list/index.esm.js"; import Vl from "../content-container/index.esm.js"; import Rl from "../data-grid/index.esm.js"; import Dl from "../date-picker/index.esm.js"; import Nl from "../dropdown/index.esm.js"; import "../external-container/index.esm.js"; import Pl from "../events-editor/index.esm.js"; import $l from "../image-cropper/index.esm.js"; import Ll from "../input-group/index.esm.js"; import jl from "../layout/index.esm.js"; import Wl from "../list-nav/index.esm.js"; import Hl from "../lookup/index.esm.js"; import Al from "../nav/index.esm.js"; import Gl from "../number-spinner/index.esm.js"; import zl from "../number-range/index.esm.js"; import ql from "../page-header/index.esm.js"; import Ul from "../page-footer/index.esm.js"; import Yl from "../progress/index.esm.js"; import Xl from "../query-solution/index.esm.js"; import Kl from "../radio-group/index.esm.js"; import Jl from "../rate/index.esm.js"; import Ql from "../response-toolbar/index.esm.js"; import Zl from "../response-layout/index.esm.js"; import ea from "../response-layout-editor/index.esm.js"; import ta from "../section/index.esm.js"; import na from "../smoke-detector/index.esm.js"; import oa from "../splitter/index.esm.js"; import la from "../step/index.esm.js"; import aa from "../switch/index.esm.js"; import ia from "../text/index.esm.js"; import ra from "../time-picker/index.esm.js"; import Sn from "../tree-view/index.esm.js"; import sa from "../uploader/index.esm.js"; import ua from "../verify-detail/index.esm.js"; import ca from "../component/index.esm.js"; import da from "../video/index.esm.js"; import fa from "../textarea/index.esm.js"; import pa from "../tree-grid/index.esm.js"; import ma from "../fieldset/index.esm.js"; import va from "../drawer/index.esm.js"; import ha from "../combo-tree/index.esm.js"; import ga from "../field-selector/index.esm.js"; import ya from "../mapping-editor/index.esm.js"; import ba from "../schema-selector/index.esm.js"; import Ca from "../event-parameter/index.esm.js"; import wa from "../filter-condition-editor/index.esm.js"; import Sa from "../sort-condition-editor/index.esm.js"; import xa from "../menu-lookup/index.esm.js"; const xn = {}, _n = {}; function Zt(e) { const { properties: t, title: n, ignore: o } = e, l = o && Array.isArray(o), a = Object.keys(t).reduce((i, u) => ((!l || !o.find((c) => c === u)) && (i[u] = t[u].type === "object" && t[u].properties ? Zt(t[u]) : mt(t[u].default)), i), {}); if (n && (!l || !o.find((i) => i === "id"))) { const i = n.toLowerCase().replace(/-/g, "_"); a.id = `${i}_${Math.random().toString().slice(2, 6)}`; } return a; } function _a(e) { const { properties: t, title: n, required: o } = e; if (o && Array.isArray(o)) { const l = o.reduce((a, i) => (a[i] = t[i].type === "object" && t[i].properties ? Zt(t[i]) : mt(t[i].default), a), {}); if (n && o.find((a) => a === "id")) { const a = n.toLowerCase().replace(/-/g, "_"); l.id = `${a}_${Math.random().toString().slice(2, 6)}`; } return l; } return { type: n }; } function Tn(e, t = {}, n) { const o = xn[e]; if (o) { let l = _a(o); const a = _n[e]; return l = a ? a({ getSchemaByType: Tn }, l, t, n) : l, l; } return null; } function Ta(e, t) { const n = Zt(t); return Object.keys(n).reduce((o, l) => (Object.prototype.hasOwnProperty.call(e, l) && (o[l] && an(o[l]) && an(e[l] || !e[l]) ? Object.assign(o[l], e[l] || {}) : o[l] = e[l]), o), n), n; } function Fn(e, t) { return Object.keys(e).filter((o) => e[o] != null).reduce((o, l) => { if (t.has(l)) { const a = t.get(l); if (typeof a == "string") o[a] = e[l]; else { const i = a(l, e[l], e); Object.assign(o, i); } } else o[l] = e[l]; return o; }, {}); } function Fa(e, t, n = /* @__PURE__ */ new Map()) { const o = Ta(e, t); return Fn(o, n); } function ka(e = {}) { function t(f, d, r, s) { if (typeof r == "number") return s[f].length === r; if (typeof r == "object") { const v = Object.keys(r)[0], g = r[v]; if (v === "not") return Number(s[f].length) !== Number(g); if (v === "moreThan") return Number(s[f].length) >= Number(g); if (v === "lessThan") return Number(s[f].length) <= Number(g); } return !1; } function n(f, d, r, s) { return s[f] && s[f].propertyValue && String(s[f].propertyValue.value) === String(r); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((f, d) => (f.set(d, e[d]), f), o); function l(f, d) { const r = f; return typeof d == "number" ? [{ target: r, operator: "length", param: null, value: Number(d) }] : typeof d == "boolean" ? [{ target: r, operator: "getProperty", param: f, value: !!d }] : typeof d == "object" ? Object.keys(d).map((s) => { if (s === "length") return { target: r, operator: "length", param: null, value: d[s] }; const v = s, g = d[s]; return { target: r, operator: "getProperty", param: v, value: g }; }) : []; } function a(f) { return Object.keys(f).reduce((r, s) => { const v = l(s, f[s]); return r.push(...v), r; }, []); } function i(f, d) { if (o.has(f.operator)) { const r = o.get(f.operator); return r && r(f.target, f.param, f.value, d) || !1; } return !1; } function u(f, d) { return a(f).reduce((v, g) => v && i(g, d), !0); } function c(f, d) { const r = Object.keys(f), s = r.includes("allOf"), v = r.includes("anyOf"), g = s || v, h = (g ? f[g ? s ? "allOf" : "anyOf" : "allOf"] : [f]).map((T) => u(T, d)); return s ? !h.includes(!1) : h.includes(!0); } return { parseValueSchema: c }; } const re = { button: { type: "button", name: "按钮" }, "response-toolbar": { type: "response-toolbar", name: "工具栏" }, "response-toolbar-item": { type: "response-toolbar-item", name: "按钮" }, "content-container": { type: "content-container", name: "容器" }, "input-group": { type: "input-group", name: "文本" }, textarea: { type: "textarea", name: "多行文本" }, lookup: { type: "lookup", name: "帮助" }, "number-spinner": { type: "number-spinner", name: "数值" }, "date-picker": { type: "date-picker", name: "日期" }, switch: { type: "switch", name: "开关" }, "radio-group": { type: "radio-group", name: "单选组" }, "check-box": { type: "check-box", name: "复选框" }, "check-group": { type: "check-group", name: "复选框组" }, "combo-list": { type: "combo-list", name: "下拉列表" }, "response-form": { type: "response-form", name: "卡片面板" }, "response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" }, "response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" }, "tree-grid": { type: "tree-grid", name: "树表格" }, "tree-grid-column": { type: "tree-grid-column", name: "树表格列" }, "data-grid": { type: "data-grid", name: "表格" }, "data-grid-column": { type: "data-grid-column", name: "表格列" }, module: { type: "Module", name: "模块" }, component: { type: "component", name: "组件" }, tabs: { type: "tabs", name: "标签页" }, "tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" }, "tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" }, "time-picker": { type: "time-picker", name: "时间选择" }, section: { type: "section", name: "分组面板" }, "section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" }, "section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" }, splitter: { type: "splitter", name: "分栏面板" }, "splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" }, "component-ref": { type: "component-ref", name: "组件引用节点" }, uploader: { type: "uploader", name: "附件上传" }, "page-header": { type: "page-header", name: "页头" }, "page-footer": { type: "page-footer", name: "页脚" }, "tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" }, fieldset: { type: "fieldset", name: "分组" }, "query-solution": { type: "query-solution", name: "筛选方案" }, drawer: { type: "drawer", name: "抽屉" } }, Ia = {}, Ba = {}; ka(); function Qe(e, t, n = /* @__PURE__ */ new Map(), o = (i, u, c, f) => u, l = {}, a = (i) => i) { return xn[t.title] = t, _n[t.title] = o, Ia[t.title] = l, Ba[t.title] = a, (i = {}, u = !0) => { if (!u) return Fn(i, n); const c = Fa(i, t, n), f = Object.keys(e).reduce((d, r) => (d[r] = e[r].default, d), {}); return Object.assign(f, c); }; } function Tt(e, t) { return { customClass: t.class, customStyle: t.style }; } function Ea() { function e(t, n) { const { dataSource: o } = t || {}; return o === void 0 ? {} : {}; } return { resolve: e }; } function Ma() { function e(t, n) { return t.selectItemById(n); } return { selectItemById: e }; } function Oa() { function e(t, n) { const { columns: o } = n; return t.updateColumns(o); } return { updateColumns: e }; } const Va = "https://json-schema.org/draft/2020-12/schema", Ra = "https://farris-design.gitee.io/field-selector.schema.json", Da = "field-selector", Na = "A Farris Input Component", Pa = "object", $a = { disabled: { description: "", type: "boolean", default: "false" }, readonly: { description: "", type: "boolean", default: "false" }, modelValue: { description: "", type: "object", default: null }, repositoryToken: { description: "", type: "object", default: null }, fields: { description: "", type: "array", default: null }, editorParams: { type: "object", default: null }, displayText: { description: "", type: "string", default: "" }, enableClear: { description: "", type: "boolean", default: !0 }, beforeOpen: { description: "", type: "function", default: null }, onSubmitModal: { description: "", type: "function", default: null } }, La = { $schema: Va, $id: Ra, title: Da, description: Na, type: Pa, properties: $a }, kn = { disabled: { type: Boolean, default: !1 }, readonly: { type: Boolean, default: !1 }, enableClear: { type: Boolean, default: !0 }, displayText: { type: String, default: "" }, enableExpress: { type: Boolean, default: !1 }, modelValue: { type: Array, default: [] }, insertType: { type: String, default: "below" // 'above'|'below' }, fields: { type: Array, default: [] }, repositoryToken: { type: Object, default: null }, editorParams: { type: Object, default: null }, onSubmitModal: { type: Function, default: null }, beforeOpen: { type: Function, default: null } }, ja = Qe(kn, La), Wa = /* @__PURE__ */ new Map([ ["appearance", Eo] ]); function Ha(e, t, n) { return t; } const Aa = "https://json-schema.org/draft/2020-12/schema", Ga = "https://farris-design.gitee.io/button-edit.schema.json", za = "button-edit", qa = "A Farris Input Component", Ua = "object", Ya = { 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: "" } }, Xa = [ "id", "type" ], Ka = { $schema: Aa, $id: Ga, title: za, description: qa, type: Ua, properties: Ya, required: Xa }, Ja = "buttonEdit", Qa = "A Farris Component", Za = "object", ei = { 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: "右对齐" } ] } } } } }, ti = { title: Ja, description: Qa, type: Za, categories: ei }, en = { /** * 组件标识 */ 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 } }, In = Qe(en, Ka, Wa, Ha, ti), ni = { popupContentPosition: { type: Object, default: { left: 0, top: 0 } }, host: { type: Object }, backgroundColor: { type: String, default: "" } }, oi = /* @__PURE__ */ Fe({ name: "FOverlay", props: ni, emits: ["click"], setup(e, t) { const n = C(e.popupContentPosition), o = C(e.host), l = N(() => ({ backgroundColor: e.backgroundColor || "", pointerEvents: "auto" })); function a(u) { t.emit("click"), u.preventDefault(), u.stopPropagation(); } N(() => { const u = o.value; if (u) { const c = u.getBoundingClientRect(), { left: f, top: d, height: r } = c; return { left: f, top: d + r }; } return n.value; }); const i = N(() => ({ // position: 'relative', // left: `${position.value.left}px`, // top: `${position.value.top}px` })); return () => w(pn, { to: "body" }, { default: () => { var u, c; return [w("div", { class: "overlay-container", onClick: (f) => a(f), style: l.value }, [w("div", { style: i.value }, [(c = (u = t.slots).default) == null ? void 0 : c.call(u)])])]; } }); } }); function li(e) { if (e.content && e.content.render) return e.content.render; if (e.render && typeof e.render == "function") return e.render; } function ai(e) { const t = document.createElement("div"); t.style.display = "contents"; let n; const o = e.onClickCallback || (() => { }), l = () => { o(), n && n.unmount(); }; return n = Jt({ setup() { Bt(() => { document.body.removeChild(t); }); const a = li(e); return () => w(oi, { "popup-content-position": e.popupPosition, host: e.host, onClick: l, backgroundColor: e.backgroundColor }, { default: () => [a && a()] }); } }), document.body.appendChild(t), n.mount(t), n; } class ii { static show(t) { return ai(t); } } const ri = { /** * 自定义类 */ 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 Ve { 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 l = parseInt(o[4], 10), a = parseInt(o[5], 10); return { x: l, y: a }; } return { x: 0, y: 0 }; } static fromEvent(t, n = null) { if (this.isMouseEvent(t)) return new Ve(t.clientX, t.clientY); if (n === null || t.changedTouches.length === 1) return new Ve(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 Ve(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 Ve(0, 0); if (window) { const o = window.getComputedStyle(t); if (o) { const l = parseInt(o.getPropertyValue("left"), 10), a = parseInt(o.getPropertyValue("top"), 10); n.x = isNaN(l) ? 0 : l, n.y = isNaN(a) ? 0 : a; } return n; } return null; } static copy(t) { return new Ve(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 bt { constructor(t, n) { this.width = t, this.height = n; } static getCurrent(t) { const n = new bt(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 bt(0, 0).set(t); } set(t) { return this.width = t.width, this.height = t.height, this; } } function si(e, t) { const n = C(), o = C(), l = C(), a = C(), i = C(), u = C(), c = C(), f = C(), d = C(), r = C(), s = C(), v = C(), g = C(e.draggable), I = C(!1); function b() { const M = o.value || document.body, P = window.getComputedStyle(M); if (!P || !n.value) return; const H = Ve.getTransformInfo(n.value), K = {}; c.value && (K.deltaL = n.value.offsetLeft - c.value.x, K.deltaT = n.value.offsetTop - c.value.y); const oe = P.getPropertyValue("position"); K.width = M.clientWidth, K.height = M.clientHeight, K.pr = parseInt(P.getPropertyValue("padding-right"), 10), K.pb = parseInt(P.getPropertyValue("padding-bottom"), 10), K.position = P.getPropertyValue("position"), oe === "static" && (M.style.position = "relative"), K.translateX = H.x, K.translateY = H.y, r.value = K; } function h(M) { if (n.value) { a.value = bt.getCurrent(n.value), i.value = Ve.getCurrent(n.value), u.value = a.value ? bt.copy(a.value) : null, c.value = i.value ? Ve.copy(i.value) : null, b(); const P = M.target.getAttribute("type") || ""; f.value = { n: !!P.match(/n/), s: !!P.match(/s/), w: !!P.match(/w/), e: !!P.match(/e/) }; } } function m() { var M, P, H, K; if (n.value) { const oe = n.value; f.value && ((f.value.n || f.value.s) && ((M = u.value) != null && M.height) && (oe.style.height = u.value.height + "px"), (f.value.w || f.value.e) && ((P = u.value) != null && P.width) && (oe.style.width = u.value.width + "px"), c.value && ((H = c.value) != null && H.x && (oe.style.left = c.value.x + "px"), (K = c.value) != null && K.y && (oe.style.top = c.value.y + "px"))); } } function T() { const M = e.minHeight ? e.minHeight : 1, P = e.minWidth ? e.minWidth : 1; u.value && c.value && f.value && a.value && (u.value.height < M && (u.value.height = M, f.value.n && i.value && (c.value.y = i.value.y + (a.value.height - M))), u.value.width < P && (u.value.width = P, f.value.w && i.value && (c.value.x = i.value.x + (a.value.width - P))), e.maxHeight && u.value.height > e.maxHeight && (u.value.height = e.maxHeight, i.value && f.value.n && (c.value.y = i.value.y + (a.value.height - e.maxHeight))), e.maxWidth && u.value.width > e.maxWidth && (u.value.width = e.maxWidth, f.value.w && i.value && (c.value.x = i.value.x + (a.value.width - e.maxWidth)))); } function y() { if (o.value) { const M = r.value; if (c.value && u.value && f.value && a.value) { const P = M.width - M.pr - M.deltaL - M.translateX - c.value.x, H = M.height - M.pb - M.deltaT - M.translateY - c.value.y; f.value.n && c.value.y + M.translateY < 0 && i.value && (c.value.y = -M.translateY, u.value.height = a.value.height + i.value.y + M.translateY), f.value.w && c.value.x + M.translateX < 0 && i.value && (c.value.x = -M.translateX, u.value.width = a.value.width + i.value.x + M.translateX), u.value.width > P && (u.value.width = P), u.value.height > H && (u.value.height = H); } } } function k(M) { if (!l.value || !a.value || !i.value || !f.value) return; M.subtract(l.value); const P = M.x, H = M.y; f.value.n ? (c.value.y = i.value.y + H, u.value.height = a.value.height - H) : f.value.s && (u.value.height = a.value.height + H), f.value.e ? u.value.width = a.value.width + P : f.value.w && (u.value.width = a.value.width - P, c.value.x = i.value.x + P), y(), T(), m(); } function B(M) { if (!d.value) return; const P = Ve.fromEvent(M); P && k(P); } function p() { if (n.value) { const { width: M, height: P, x: H, y: K } = n.value.getBoundingClientRect(), oe = Ve.getTransformInfo(n.value); return { size: { width: M, height: P }, position: { x: H - oe.x, y: K - oe.y } }; } return null; } function F(M) { if (n.value) { const P = p(); s.value = P; } l.value = void 0, a.value = null, i.value = null, u.value = null, c.value = null, f.value = null, d.value = null, document.removeEventListener("mousemove", B), document.removeEventListener("mouseup", F); } function S() { document.addEventListener("mousemove", B), document.addEventListener("mouseup", F); } function x(M) { M instanceof MouseEvent && M.button === 2 || g.value && (document.body.click(), M.stopPropagation(), M.preventDefault(), l.value = Ve.fromEvent(M), d.value = M.target, h(M), S()); } function _(M) { return n.value = M, w(xt, null, [w("div", { class: "fv-resizable-handle fv-resizable-n", type: "n", onMousedown: (P) => x(P) }, null), w("div", { class: "fv-resizable-handle fv-resizable-e", type: "e", onMousedown: (P) => x(P) }, null), w("div", { class: "fv-resizable-handle fv-resizable-s", type: "s", onMousedown: (P) => x(P) }, null), w("div", { class: "fv-resizable-handle fv-resizable-w", type: "w", onMousedown: (P) => x(P) }, null), w("div", { class: "fv-resizable-handle fv-resizable-ne", type: "ne", onMousedown: (P) => x(P) }, null), w("div", { class: "fv-resizable-handle fv-resizable-se fv-resizable-diagonal", type: "se", onMousedown: (P) => x(P) }, null), w("div", { class: "fv-resizable-handle fv-resizable-sw", type: "sw", onMousedown: (P) => x(P) }, null), w("div", { class: "fv-resizable-handle fv-resizable-nw", type: "nw", onMousedown: (P) => x(P) }, null)]); } function O(M = !0) { document.body.click(); const P = o.value || document.body, H = bt.getCurrent(P), K = n.value; M && K && (v.value = p(), v.value.transform = K.style.transform), H && K && (u.value = H, K.style.height = u.value.height - 14 + "px", K.style.width = u.value.width - 14 + "px", K.style.left = "7px", K.style.top = "7px", K.style.transform = "", s.value = { size: u.value, position: { x: 0, y: 0 } }, g.value = !1, I.value = !0); } function R() { var M, P; if (document.body.click(), v.value) { const H = { width: v.value.size.width || 0, height: v.value.size.height || 0 }, K = { x: (window.innerWidth - H.width) / 2, y: (window.innerHeight - H.height) / 2 }; (M = u.value) == null || M.set(H), (P = c.value) == null || P.set(K); const oe = n.value; oe.style.height = H.height + "px", oe.style.width = H.width + "px", oe.style.left = `${K.x}px`, oe.style.top = `${K.y}px`, oe.style.transform = "", s.value = { size: H, position: K }, g.value = e.draggable, I.value = !1; } } function V() { if (n.value) { const M = bt.getCurrent(n.value); if (M) { const { width: P, height: H } = M; n.value.style.left = `${(window.innerWidth - P) / 2}px`, n.value.style.top = `${(window.innerHeight - H) / 2}px`, n.value.style.transform = ""; } } } function E() { const M = () => { I.value ? O(!1) : V(), document.body.click(); }; return window.addEventListener("resize", M), () => { window.removeEventListener("resize", M); }; } const D = E(); return { renderResizeBar: _, boundingElement: o, resizedEventParam: s, maximize: O, restore: R, allowDrag: g, isMaximized: I, unWindowResizeHandle: D }; } function ui(e, t, n) { const o = C(), l = C(e.draggable), a = C(e.lockAxis), i = C(), u = C(), c = C(!1), f = C(new Ve(0, 0)), d = C(new Ve(0, 0)), r = C(new Ve(0, 0)), s = C(new Ve(0, 0)); he(() => n.value, (p) => { i.value.style.cursor = p ? "move" : "default"; }); function v(p, F) { if (F.tagName === "BUTTON") return !1; if (F === p) return !0; for (const S in F.children) if (Object.prototype.hasOwnProperty.call(F.children, S) && v(p, F.children[S])) return !0; return !1; } function g() { var x, _; let p = r.value.x + d.value.x, F = r.value.y + d.value.y; a.value === "x" ? (p = ((x = f.value) == null ? void 0 : x.x) || 0, r.value.x = 0) : a.value === "y" && (F = ((_ = f.value) == null ? void 0 : _.y) || 0, r.value.y = 0); const S = `translate3d(${Math.round(p)}px, ${Math.round(F)}px, 0px)`; o.value && (o.value.style.transform = S), s.value.x = p, s.value.y = F; } function I() { if (!u.value || !o.value) return null; const p = u.value.getBoundingClientRect(), F = o.value.getBoundingClientRect(), S = { top: p.top < F.top, right: p.right > F.right, bottom: p.bottom > F.bottom, left: p.left < F.left }; return S.top || (r.value.y -= F.top - p.top), S.bottom || (r.value.y -= F.bottom - p.bottom), S.right || (r.value.x -= F.right - p.right), S.left || (r.value.x -= F.left - p.left), g(), S; } function b(p) { p && (f.value && p.subtract(f.value), r.value.set(p), g(), I()); } function h(p) { c.value && l.value && (p.stopPropagation(), p.preventDefault(), b(Ve.fromEvent(p, i.value))); } function m() { var p; c.value && (c.value = !1, d.value.add(r.value), r.value.reset(), (p = o.value) == null || p.classList.remove("ng-dragging"), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", m)); } function T() { !c.value && i.value && (c.value = !0, i.value.classList.add("ng-dragging"), document.addEventListener("mousemove", h), document.addEventListener("mouseup", m)); } function y() { if (o.value) { const p = Ve.getTransformInfo(o.value); d.value.set(p); return; } d.value.reset(); } function k(p) { if (!n.value || p instanceof MouseEvent && p.button === 2) return; const F = p.target || p.srcElement; i.value !== void 0 && F && !v(F, i.value) || l.value !== !1 && (document.body.click(), p.stopPropagation(), p.preventDefault(), f.value = Ve.fromEvent(p, o.value), y(), T()); } function B(p, F, S) { if (l.value && F) { if (p) i.value = p; else if (e.dragHandle) { if (e.dragHandle instanceof HTMLElement) i.value = e.dragHandle; else if (typeof e.dragHandle == "string") { const x = F.querySelector(e.dragHandle); x && (i.value = x); } } o.value = F, u.value = S, i.value ? (i.value.classList.add("ng-draggable"), i.value.addEventListener("mousedown", k)) : l.value = !1; } } return { registerDraggle: B, resetTranslate: y }; } function Bn(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 ci(e, t) { const n = C(e.enableEsc); let o = null; return n.value ? (o = Bn("Escape", (l) => { t.emit("esc", { event: l.event, type: "esc" }); }), { remove: o }) : null; } function di(e, t) { const n = C(e.enableEnter); let o = null; return n.value ? (o = Bn("Enter", (l) => { t.emit("enter", { event: l.event, type: "enter" }); }), { remove: o }) : null; } const Ft = /* @__PURE__ */ Fe({ name: "FModal", props: ri, emits: ["update:modelValue", "accept", "cancel", "closed", "resize", "esc", "enter"], setup(e, t) { const n = C(e.width || 300), o = C(e.height || 200), l = C(e.modelValue), a = C(""), i = C(e.class), u = C(e.fitContent), c = C(e.showHeader), f = C(""), d = C(e.showCloseButton), r = C(e.showMaxButton), s = C(!1), v = C(e.dialogType), g = C(e.src), I = C(""), b = C(e.showButtons), h = C(e.title), m = C(e.resizeable), T = C(e.containment || null), y = C(), k = C(!1); function B(ne, Ce) { l.value = !1, t.emit("update:modelValue", !1), Ce != null && t.emit(Ce ? "accept" : "cancel"), t.emit("closed", ne); } const p = [{ name: "cancel", text: "取消", class: "btn btn-secondary", handle: (ne) => { B(ne, !1); } }, { name: "accept", text: "确定", class: "btn btn-primary", handle: (ne) => { B(ne, !0); } }], F = C(e.buttons && e.buttons.length ? e.buttons : p), S = N(() => !!f.value), x = N(() => !!b.value && !!F.value), _ = C(), O = C(), R = C(!1), { renderResizeBar: V, maximize: E, restore: D, boundingElement: M, resizedEventParam: P, allowDrag: H, unWindowResizeHandle: K } = si(e), { registerDraggle: oe } = ui(e, t, H); function te() { return !!document.querySelectorAll(".farris-modal").length && document.body.classList.contains("modal-open"); } function pe() { const ne = document.querySelectorAll(".farris-modal").length; (!ne || ne - 1 <= 0) && document.body.classList.remove("modal-open"), y.value && y.value.classList.remove("show"); } he(() => e.title, (ne, Ce) => { ne !== Ce && (h.value = ne); }), he(() => e.modelValue, (ne, Ce) => { ne !== Ce && (l.value = ne, ne || pe()), l.value && (k.value = te()); }), he(() => e.showHeader, (ne, Ce) => { ne !== Ce && (c.value = ne); }), he(() => e.showButtons, (ne, Ce) => { ne !== Ce && (b.value = ne); }), he(() => P.value, (ne, Ce) => { const Ee = ne || {}, De = Ce || {}; JSON.stringify(Ee) !== JSON.stringify(De) && t.emit("resize", { newSize: ne, oldSize: Ce }); }); const W = N(() => (l.value && document.body.classList.add("modal-open"), l.value)), j = N(() => { const ne = { modal: !0, "farris-modal": !0, fade: !0 }; return ne["f-modal-fitContent"] = !!u.value, ne.show = !!W.value, ne; }), A = N(() => { var Ee; const ne = { "modal-dialog": !0 }, Ce = (Ee = i.value) == null ? void 0 : Ee.split(" "); return Ce == null || Ce.reduce((De, Be) => (De[Be] = !0, De), ne), ne; }), Y = N(() => ({ position: "absolute", top: `${(window.innerHeight - o.value) / 2}px`, left: `${(window.innerWidth - n.value) / 2}px`, width: `${n.value}px`, height: u.value ? "auto" : `${o.value}px` })), Q = N(() => ({ "modal-content": !0, "modal-content-has-header": c.value })), X = N(() => { const ne = { display: c.value ? "" : "none" }; return ne["pointer-events"] = H.value ? "auto" : "none", ne; }), $ = N(() => ({ "f-icon": !0, modal_maximize: !0, modalrevert: R.value })), z = N(() => ({ "modal-body": !0, "f-utils-flex-column": v.value === "iframe", "f-utils-fill": !0 })); function ae() { return { height: `${e.footerHeight || 60}px` }; } const Z = N(() => { const ne = { textAlgin: I.value }, Ce = ae(); return Object.assign(ne, Ce); }); function ee(ne) { if (ne.stopPropagation(), R.value) { R.value = !1, D(); return; } E(), R.value = !0; } async function _e(ne, Ce) { ne.handle && await ne.handle(Ce, ne) && t.emit("closed", Ce); } function ke(ne) { ne.width && (n.value = ne.width), ne.height && (o.value = ne.height), ne.buttons && (F.value = ne.buttons), ne.title && (h.value = ne.title); } const Te = N(() => { const ne = { display: "inline-block" }; return k.value && (ne["background-color"] = "transparent"), ne; }); let He = null, Pe = null; wo(() => { k.value = te(); }), Je(() => { O.value && !T.value && (T.value = O.value.parentElement, M.value = T.value, oe(_.value, O.value, M.value)), W.value && document.body.classList.add("modal-open"), He = ci(e, t), Pe = di(e, t); }), Bt(() => { K && K(), He && He.remove(), Pe && Pe.remove(); }), t.expose({ modalElementRef: O, updateModalOptions: ke, close: B, maxDialog: ee }); function Oe() { return w("ul", null, [s.value && w("li", { class: "f-btn-icon f-bare" }, [w("span", { class: "f-icon modal_minimize" }, null)]), r.value && w("li", { onClick: ee, class: "f-btn-icon f-bare", style: "pointer-events: auto;" }, [w("span", { class: $.value }, null)]), d.value && w("li", { class: "f-btn-icon f-bare", onClick: (ne) => B(ne, !1), style: "pointer-events: auto;" }, [w("span", { class: "f-icon modal_close" }, null)])]); } function Ue() { return w("div", { class: "modal-footer", style: Z.value }, [F.value && F.value.map((ne) => w("button", { name: ne.name, type: "button", class: ne.class + (ne.iconClass ? " btn-icontext" : ""), onClick: (Ce) => { _e(ne, Ce); } }, [!!ne.iconClass && w("i", { class: ne.iconClass }, null), ne.text]))]); } function Ge() { return w("div", { ref: _, class: "modal-header", style: X.value }, [w("div", { class: "modal-title" }, [S.value && w("span", { class: f.value, style: "margin-right: 8px" }, null), w("span", { class: "modal-title-label" }, [h.value])]), w("div", { class: "actions" }, [Oe()])]); } function dt(ne) { ne.stopPropagation(); } return () => w(pn, { to: "body" }, { default: () => [W.value && w(mn, { name: "fade", appear: !0 }, { default: () => { var ne, Ce; return [w("div", { class: j.value, style: Te.value, ref: y, onClick: dt }, [w("div", { id: a.value, class: A.value, style: Y.value, ref: O }, [w("div", { class: Q.value }, [c.value && Ge(), w("div", { class: z.value }, [(Ce = (ne = t.slots).default) == null ? void 0 : Ce.call(ne), v.value === "iframe" && w("iframe", { title: a.value, class: "f-utils-fill", width: "100%", frameborder: "0", src: g.value }, null)]), x.value && Ue()]), !u.value && m.value && O.value && !R.value && V(O.value)])])]; } })] }); } }); function En(e) { if (e.content && e.content.render) return e.content.render; if (e.render && typeof e.render == "function") return e.render; } function fi(e) { const t = document.createElement("div"); t.style.display = "contents"; const n = Jt({ setup(o, l) { Bt(() => { document.body.removeChild(t); }); const a = C(), i = C(e.class || ""), u = C(!!e.showButtons), c = C(!!e.showHeader), f = C(e.showCloseButton == null ? !0 : e.showCloseButton), d = C(!0), r = C(e.title || ""), s = e.acceptCallback || (() => { }), v = e.rejectCallback || (() => { }), g = e.closedCallback || ((m) => { }), I = e.resizeHandle || ((m) => { }), b = En(e), h = (m) => { d.value = !1, n.unmount(), g(m); }; return Je(() => { }), l.expose({ modalRef: a }), () => w(Ft, { ref: a, class: i.value, modelValue: d.value, "onUpdate:modelValue": (m) => d.value = m, title: r.value, width: e.width, height: e.height, buttons: e.buttons, "show-header": c.value, "show-buttons": u.value, "show-close-button": f.value, "show-max-button": !1, onAccept: s, onCancel: v, fitContent: e.fitContent == null ? !0 : e.fitContent, onClosed: h, onResize: I }, { default: () => [b && b(n)] }); } }); return document.body.appendChild(t), n.mount(t), n; } class Mn { constructor(t) { q(this, "appContext", null); q(this, "modalRef", C()); q(this, "activeModalIndex", C(0)); q(this, "modalRefs", {}); q(this, "isUseEscCloseModal", C(!1)); q(this, "activeModalInstance", N(() => 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: l } = { width: window.innerWidth, height: window.innerHeight }; return o < t && (t = o), l < n && (n = l), { width: t, height: n }; } static show(t) { const n = Object.assign({ title: "", showButtons: !0, showHeader: !0 }, t); return fi(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 = So(Object.assign({ title: "", showButtons: !0, showHeader: !0 }, t)), l = C(!0), a = o.value.acceptCallback || (() => { }), i = o.value.rejectCallback || (() => { }), u = o.value.closedCallback || ((y, k) => { }), c = o.value.resizeHandle || ((y) => { }); let f; const d = En(o.value), r = (y) => { var B; l.value = !1; const k = (B = y == null ? void 0 : y.target) == null ? void 0 : B.classList.contains("modal_close"); u(y, this.isUseEscCloseModal.value ? "esc" : k ? "icon" : "button"); }, s = (y) => { r(y), f && St(() => { if (this.modalRefs[this.activeModalIndex.value] && delete this.modalRefs[this.activeModalIndex.value], Ht(null, n), f = null, this.modalRef.value = null, this.modalRefs) { const k = Object.keys(this.modalRefs).map((B) => Number(B)); k.length > 0 ? this.activeModalIndex.value = Math.max(...k) : this.activeModalIndex.value = 0; } this.isUseEscCloseModal.value = !1; }); }, v = (y) => { var k; this.isUseEscCloseModal.value = !0, this.activeModalInstance && ((k = this.activeModalInstance.value) == null ||