import { defineComponent as Z, ref as R, computed as j, watch as z, resolveComponent as K, openBlock as A, createElementBlock as D, createBlock as H, resolveDynamicComponent as q, normalizeProps as ie, guardReactiveProps as le, withCtx as $, Fragment as ae, renderList as se, mergeProps as M, createElementVNode as B, createVNode as L, unref as G, createTextVNode as J } from "vue"; import { useUi as W, compute as ue, useI18n as ce, uiContext as de, useTypes as U, useColumns as fe, utils as x, dict as pe } from "@fast-crud/fast-crud"; import { merge as V, cloneDeep as me } from "lodash-es"; const ye = Z({ name: "FsImagesFormat", inheritAttrs: !1, props: { //包裹image的组件配置,antdv是preview-group,element是div wrapper: { type: Object, default: null }, // 图片的url // 'url' 或 ['url','url'] 或 [{url:'url'}] 或 {url:'url'} modelValue: { type: [String, Array, Object], require: !0 }, /** * 构建好的图片链接,如果此处传值,则不走buildUrl方法 * 'url' 或 ['url1','url2'] 或 {url,previewUrl} 或 [{url,previewUrl}] */ urls: { type: [String, Object, Array] }, /** * 加载错误时显示的图片 */ error: { default: 'data:image/svg+xml,%3Csvg xmlns="http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" width="24" height="24" viewBox="0 0 24 24"%3E%3Cpath fill="%23888" d="M5 21q-.825 0-1.413-.588T3 19v-6.6l3 3l4-4l4 4l4-4l3 3V19q0 .825-.588 1.413T19 21H5ZM5 3h14q.825 0 1.413.588T21 5v6.575l-3-3l-4 4l-4-4l-4 4l-3-3V5q0-.825.588-1.413T5 3Z"%2F%3E%3C%2Fsvg%3E' }, /** * 从value构建图片下载url的方法 * 支持异步 * (value)=>Promise */ buildUrl: { type: Function, default: function(e) { return e; } }, /** * (values)=>Promise */ buildUrls: { type: Function, default: null }, /** * 从value或url构建预览大图的方法 * (url,value)=>Promise */ buildPreviewUrl: { type: Function, default: function({ url: e, value: t, index: n }) { return e; } }, /** * (list,values)=>Promise */ buildPreviewUrls: { type: Function, default: null } }, setup(e, t) { const { ui: n } = W(), i = R([]), r = j(() => V({ style: {} }, { style: t.attrs.style })), o = j(() => { const a = []; if (e.modelValue == null || e.modelValue === "") return a; if (typeof e.modelValue == "string") a.push(e.modelValue); else if (Array.isArray(e.modelValue)) for (const s of e.modelValue) s != null && (s.url != null ? s.previewUrl != null ? a.push(s) : a.push(s.url) : a.push(s)); else e.modelValue.url != null ? e.modelValue.previewUrl != null ? a.push(e.modelValue) : a.push(e.modelValue.url) : a.push(e.modelValue); return a; }); function l(a) { const s = [], p = []; for (let v = 0; v < a.length; v++) { const T = a[v]; s.push(T.url), p.push(T.previewUrl); } const m = []; for (let v = 0; v < a.length; v++) { const T = a[v], k = T.url, S = T.previewUrl || T.url, N = n.image.buildPreviewBind({ url: k, urls: s, previewUrl: S, previewUrls: p, index: v }); m.push({ fit: "contain", src: k, [n.image.fallback]: e.error, ...t.attrs, ...N }); } return m; } async function f(a) { if (e.buildUrls) { const s = a.map((v) => v.value), p = await e.buildUrls(s); for (let v = 0; v < a.length; v++) a[v].url = p[v]; let m = p; e.buildPreviewUrls && (m = await e.buildPreviewUrls(a, s)); for (let v = 0; v < a.length; v++) a[v].previewUrl = m[v]; } else if (e.buildUrl) for (let s of a) s.url = await e.buildUrl(s.value), e.buildPreviewUrl ? s.previewUrl = await e.buildPreviewUrl(s, s.value) : s.previewUrl = s.previewUrl || s.url; else for (let s = 0; s < a.length; s++) a[s].url = a[s].value, a[s].previewUrl = a[s].value; } async function g(a) { const s = []; for (let p = 0; p < a.length; p++) { let m = a[p]; s.push({ value: m, index: p }); } return await f(s), l(s); } async function C(a) { const s = []; if (typeof a == "string") s.push({ value: a, url: a, index: 0, previewUrl: a }); else if (a instanceof Array) { if (a.length > 0) if (typeof a[0] == "string") for (let p = 0; p < a.length; p++) { const m = a[p]; s.push({ value: m, url: m, previewUrl: m, index: p }); } else for (let p = 0; p < a.length; p++) { const m = a[p]; s.push({ value: m.url, ...m, index: p }); } } else s.push({ value: a.url, ...a, index: 0 }); return l(s); } return z( () => o.value, async (a) => { e.urls || (i.value = await g(a)); }, { immediate: !0 } ), z( () => e.urls, async (a) => { a && (i.value = await C(a)); }, { immediate: !0 } ), { imageListRef: i, ui: n, errorBinding: r }; } }); const ge = (e, t) => { const n = e.__vccOpts || e; for (const [i, r] of t) n[i] = r; return n; }, he = { class: "fs-image-format" }, ve = { class: "fs-image-slot" }, be = { class: "fs-image-slot" }, Ce = ["src"]; function we(e, t, n, i, r, o) { const l = K("fs-loading"); return A(), D("div", he, [ (A(), H(q(e.ui.imageGroup.name), ie(le(e.wrapper)), { default: $(() => [ (A(!0), D(ae, null, se(e.imageListRef, (f) => (A(), H(q(e.ui.image.name), M({ key: f.src, class: "fs-image-item" }, { ref_for: !0 }, f), { placeholder: $(() => [ B("div", ve, [ L(l, M({ loading: !0 }, { ref_for: !0 }, e.errorBinding), null, 16) ]) ]), error: $(() => [ B("div", be, [ B("img", M({ src: e.error }, { ref_for: !0 }, e.errorBinding), null, 16, Ce) ]) ]), _: 2 }, 1040))), 128)) ]), _: 1 }, 16)) ]); } const Ee = /* @__PURE__ */ ge(ye, [["render", we]]), Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Ee }, Symbol.toStringTag, { value: "Module" })), Te = (e) => async (t, n) => { const i = await e(t.fullField, !0); if (i && i.hasUploading()) throw new Error("还有未上传完成的文件"); return !0; }, F = () => ue(({ getComponentRef: e }) => Te(e)), pt = (e, t) => (e == null && (e = []), e.push({ //@ts-ignore validator: F(), message: t || "还有文件正在上传,请稍候" // trigger: "blur" // <-------注意使用blur事件,否则会闪现 }), e); function _e() { const { t: e } = ce(), t = de.get(); return { "image-uploader": { form: { component: { name: "fs-file-uploader", listType: t.upload.typeImageCard, accept: ".png,.jpeg,.jpg,.ico,.bmp,.gif,.webp,.svg" }, [t.formItem.rules]: [{ validator: F(), message: e("fs.extends.fileUploader.hasUploading"), trigger: "blur" }] }, column: { component: { name: "fs-images-format", style: "width:30px", previewTeleported: !0, // @ts-ignore previewMask: () => L("div", { class: "ant-mask-info" }, [L(K("fs-icon"), { icon: t.icons.eye }, null)]) } }, viewForm: { component: { height: 100, width: 100 } } }, "avatar-uploader": { form: { [t.formItem.rules]: [{ validator: F(), message: e("fs.extends.fileUploader.hasUploading"), trigger: "blur" }], component: { name: "fs-file-uploader", limit: 1, listType: t.upload.typeImageCard, accept: ".png,.jpeg,.jpg,.ico,.bmp,.gif,.webp,.svg" } }, column: { align: "center", component: { name: "fs-images-format", style: "width:30px", previewTeleported: !0 } }, viewForm: { component: { height: 100, width: 100 } }, valueResolve({ row: n, key: i }) { const r = n[i]; r != null && r instanceof Array && (r.length >= 0 ? n[i] = r[0].url : n[i] = null); } }, "file-uploader": { form: { component: { name: "fs-file-uploader", listType: "text" }, [t.formItem.rules]: [{ validator: F(), message: e("fs.extends.fileUploader.hasUploading"), trigger: "blur" }] }, column: { component: { name: "fs-files-format" } } }, "cropper-uploader": { form: { component: { name: "fs-cropper-uploader", accept: ".png,.jpeg,.jpg,.ico,.bmp,.gif,.svg,.webp", cropper: { aspectRatio: 1, autoCropArea: 1, viewMode: 0 } }, [t.formItem.rules]: [{ validator: F(), message: e("fs.extends.fileUploader.hasUploading"), trigger: "blur" }] }, column: { align: "center", component: { name: "fs-images-format", style: "width:30px", previewTeleported: !0 } }, viewForm: { component: { height: 100, width: 100 } } } }; } const xe = { defaultType: "cos", cos: { // 腾讯云 cos 的配置 domain: "https://d2p-demo-1251260344.cos.ap-guangzhou.myqcloud.com", bucket: "d2p-demo-1251260344", region: "", secretId: "", secretKey: "", async getAuthorization(e) { throw new Error("请配置config.cos.getAuthorization 或 uploader.getAuthorization"); } }, alioss: { domain: "https://d2p-demo.oss-cn-shenzhen.aliyuncs.com", bucket: "d2p-demo", region: "oss-cn-shenzhen", accessKeyId: "", accessKeySecret: "", getAuthorization(e) { return new Promise((t, n) => { n(new Error("请实现config.alioss.getAuthorization,返回Promise获取临时授权token")); }); }, keepName: !1, sdkOpts: { // sdk配置 // secure: false // 默认为非https上传,为了安全,你可以设置为true } }, qiniu: { bucket: "d2p-demo", async getToken(e) { throw new Error("请实现config.qiniu.getToken方法,返回Promise获取七牛的授权token{token:xxx,expires:xxx}"); }, domain: "http://pzrsldiu3.bkt.clouddn.com" }, s3: { bucket: "fast-crud", sdkOpts: { region: "us-east-1", forcePathStyle: !0, endpoint: "https://play.min.io", credentials: { accessKeyId: "", secretAccessKey: "" //访问密码 } } }, form: { successHandle(e) { return e; }, action: void 0, name: "file", headers: {}, data: {} // async uploadRequest({ file, action }) { // 自定义文件上传请求 // return await axios.request(); // } }, async buildKey(e) { const { fileName: t } = e, n = /* @__PURE__ */ new Date(), i = e.fileType ?? "file", r = e.keepName ?? !1; let o = ""; return r ? o = "/" + t : t.lastIndexOf(".") >= 0 && (o = t.substring(t.lastIndexOf("."))), i + "/" + n.getFullYear() + "/" + (n.getMonth() + 1) + "/" + n.getDate() + "/" + Math.floor(Math.random() * 1e14) + o; } }, P = me(xe); function ke(e, t) { V(P, t); } const mt = F, Se = { install(e, t) { const n = _e(), { addTypes: i } = U(); i(n), ke(e, t); } }; async function Ae(e) { let t = null; return e === "alioss" ? t = await import("./uploader-alioss-4003d93a.mjs") : e === "cos" ? t = await import("./uploader-cos-e64b150f.mjs") : e === "form" ? t = await import("./uploader-form-8595f8fc.mjs") : e === "qiniu" ? t = await import("./uploader-qiniu-7f53ab0b.mjs") : e === "s3" ? t = await import("./uploader-s3-77927a69.mjs") : console.error(`未找到${e}的上传实现`), t; } async function yt(e, t, n) { return n.buildKey({ fileName: t, file: e, ...n }); } function gt() { function e() { const i = P; return i == null ? void 0 : i.defaultType; } function t(i) { i == null && (i = e()); const r = P, o = P[i]; return o.buildKey == null && (o.buildKey = r.buildKey), o; } async function n(i) { return await Ae(i || e()); } return { getConfig: t, getDefaultType: e, getUploaderImpl: n }; } const Fe = /* @__PURE__ */ Object.assign({ "./components/fs-cropper-uploader.vue": () => import("./fs-cropper-uploader-c3fbe88c.mjs"), "./components/fs-cropper.vue": () => import("./fs-cropper-d9786edb.mjs"), "./components/fs-file-uploader.vue": () => import("./fs-file-uploader-506e96b9.mjs"), "./components/fs-files-format.vue": () => import("./fs-files-format-ff815381.mjs"), "./components/fs-images-format.vue": () => Promise.resolve().then(() => Q), "./components/fs-uploader.vue": () => import("./fs-uploader-cf0ce557.mjs") }), Ve = /* @__PURE__ */ Object.assign({ "./components/fs-images-format.vue": Q }), { registerMergeColumnPlugin: Ue } = fe(); Ue({ name: "uploader-merge-plugin", order: 5, handle: (e = {}, t = {}) => { if (typeof e.type == "string" && e.type.endsWith("uploader")) { const n = e.buildUrl, i = e.buildUrls; V(e, { form: { component: { buildUrl: n, buildUrls: i } }, column: { component: { buildUrl: n, buildUrls: i } } }); } return e; } }); const Ne = { install(e) { x.vite.installAsyncComponents(e, Fe, ["FsImagesFormat"], null, null), x.vite.installSyncComponents(e, Ve, null, null, null); } }, ht = { install(e, t) { e.use(Se, t), e.use(Ne); } }; function Oe() { return { "editor-wang": { form: { component: { name: "fs-editor-wang" } } }, "editor-wang5": { form: { component: { name: "fs-editor-wang5", style: { zIndex: 800 }, toolbarAttrs: { style: { zIndex: 800 } } } } } }; } const je = { wangEditor: {}, wangEditor5: { editorConfig: {}, toolbarConfig: {} } }; function Me(e, t) { e.config.globalProperties.$fs_editor_config = V(je, t); } const Ie = { install(e, t) { const n = Oe(), { addTypes: i } = U(); i(n), Me(e, t); } }, Le = /* @__PURE__ */ Object.assign({ "./components/fs-editor-wang/index.vue": () => import("./index-61efc2d4.mjs"), "./components/fs-editor-wang5/index.vue": () => import("./index-4d97297b.mjs") }), Pe = { install(e) { x.vite.installAsyncComponents(e, Le, null, /^.*\/([^\/]+)\/.*.vue$/, null); } }, vt = { install(e, t) { e.use(Ie, t), e.use(Pe); } }; function $e() { return { json: { form: { component: { name: "fs-json-editor" } } } }; } const Be = { install(e) { const t = $e(), { addTypes: n } = U(); n(t); } }, Re = /* @__PURE__ */ Object.assign({ "./components/fs-json-editor.vue": () => import("./fs-json-editor-985ed0b5.mjs") }), ze = { install(e) { x.vite.installAsyncComponents(e, Re, [], null, null); } }, bt = { install(e) { e.use(Be), e.use(ze); } }; function De() { return { copyable: { column: { component: { name: "fs-copyable", vModel: "modelValue" } } } }; } const He = { install(e) { const t = De(), { addTypes: n } = U(); n(t); } }; /*! * @soerenmartius/vue3-clipboard v0.1.2 * (c) 2021 Soeren Martius * @license MIT */ var qe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Ke(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } function Ye(e, t, n) { return n = { path: t, exports: {}, require: function(i, r) { return Ge(i, r ?? n.path); } }, e(n, n.exports), n.exports; } function Ge() { throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); } var Je = Ye(function(e, t) { /*! * clipboard.js v2.0.6 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */ (function(i, r) { e.exports = r(); })(qe, function() { return ( /******/ function(n) { var i = {}; function r(o) { if (i[o]) return i[o].exports; var l = i[o] = { /******/ i: o, /******/ l: !1, /******/ exports: {} /******/ }; return n[o].call(l.exports, l, l.exports, r), l.l = !0, l.exports; } return r.m = n, r.c = i, r.d = function(o, l, f) { r.o(o, l) || Object.defineProperty(o, l, { enumerable: !0, get: f }); }, r.r = function(o) { typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(o, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(o, "__esModule", { value: !0 }); }, r.t = function(o, l) { if (l & 1 && (o = r(o)), l & 8 || l & 4 && typeof o == "object" && o && o.__esModule) return o; var f = /* @__PURE__ */ Object.create(null); if (r.r(f), Object.defineProperty(f, "default", { enumerable: !0, value: o }), l & 2 && typeof o != "string") for (var g in o) r.d(f, g, (function(C) { return o[C]; }).bind(null, g)); return f; }, r.n = function(o) { var l = o && o.__esModule ? ( /******/ function() { return o.default; } ) : ( /******/ function() { return o; } ); return r.d(l, "a", l), l; }, r.o = function(o, l) { return Object.prototype.hasOwnProperty.call(o, l); }, r.p = "", r(r.s = 6); }([ /* 0 */ /***/ function(n, i) { function r(o) { var l; if (o.nodeName === "SELECT") o.focus(), l = o.value; else if (o.nodeName === "INPUT" || o.nodeName === "TEXTAREA") { var f = o.hasAttribute("readonly"); f || o.setAttribute("readonly", ""), o.select(), o.setSelectionRange(0, o.value.length), f || o.removeAttribute("readonly"), l = o.value; } else { o.hasAttribute("contenteditable") && o.focus(); var g = window.getSelection(), C = document.createRange(); C.selectNodeContents(o), g.removeAllRanges(), g.addRange(C), l = g.toString(); } return l; } n.exports = r; }, /* 1 */ /***/ function(n, i) { function r() { } r.prototype = { on: function(o, l, f) { var g = this.e || (this.e = {}); return (g[o] || (g[o] = [])).push({ fn: l, ctx: f }), this; }, once: function(o, l, f) { var g = this; function C() { g.off(o, C), l.apply(f, arguments); } return C._ = l, this.on(o, C, f); }, emit: function(o) { var l = [].slice.call(arguments, 1), f = ((this.e || (this.e = {}))[o] || []).slice(), g = 0, C = f.length; for (g; g < C; g++) f[g].fn.apply(f[g].ctx, l); return this; }, off: function(o, l) { var f = this.e || (this.e = {}), g = f[o], C = []; if (g && l) for (var a = 0, s = g.length; a < s; a++) g[a].fn !== l && g[a].fn._ !== l && C.push(g[a]); return C.length ? f[o] = C : delete f[o], this; } }, n.exports = r, n.exports.TinyEmitter = r; }, /* 2 */ /***/ function(n, i, r) { var o = r(3), l = r(4); function f(s, p, m) { if (!s && !p && !m) throw new Error("Missing required arguments"); if (!o.string(p)) throw new TypeError("Second argument must be a String"); if (!o.fn(m)) throw new TypeError("Third argument must be a Function"); if (o.node(s)) return g(s, p, m); if (o.nodeList(s)) return C(s, p, m); if (o.string(s)) return a(s, p, m); throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList"); } function g(s, p, m) { return s.addEventListener(p, m), { destroy: function() { s.removeEventListener(p, m); } }; } function C(s, p, m) { return Array.prototype.forEach.call(s, function(v) { v.addEventListener(p, m); }), { destroy: function() { Array.prototype.forEach.call(s, function(v) { v.removeEventListener(p, m); }); } }; } function a(s, p, m) { return l(document.body, s, p, m); } n.exports = f; }, /* 3 */ /***/ function(n, i) { i.node = function(r) { return r !== void 0 && r instanceof HTMLElement && r.nodeType === 1; }, i.nodeList = function(r) { var o = Object.prototype.toString.call(r); return r !== void 0 && (o === "[object NodeList]" || o === "[object HTMLCollection]") && "length" in r && (r.length === 0 || i.node(r[0])); }, i.string = function(r) { return typeof r == "string" || r instanceof String; }, i.fn = function(r) { var o = Object.prototype.toString.call(r); return o === "[object Function]"; }; }, /* 4 */ /***/ function(n, i, r) { var o = r(5); function l(C, a, s, p, m) { var v = g.apply(this, arguments); return C.addEventListener(s, v, m), { destroy: function() { C.removeEventListener(s, v, m); } }; } function f(C, a, s, p, m) { return typeof C.addEventListener == "function" ? l.apply(null, arguments) : typeof s == "function" ? l.bind(null, document).apply(null, arguments) : (typeof C == "string" && (C = document.querySelectorAll(C)), Array.prototype.map.call(C, function(v) { return l(v, a, s, p, m); })); } function g(C, a, s, p) { return function(m) { m.delegateTarget = o(m.target, a), m.delegateTarget && p.call(C, m); }; } n.exports = f; }, /* 5 */ /***/ function(n, i) { var r = 9; if (typeof Element < "u" && !Element.prototype.matches) { var o = Element.prototype; o.matches = o.matchesSelector || o.mozMatchesSelector || o.msMatchesSelector || o.oMatchesSelector || o.webkitMatchesSelector; } function l(f, g) { for (; f && f.nodeType !== r; ) { if (typeof f.matches == "function" && f.matches(g)) return f; f = f.parentNode; } } n.exports = l; }, /* 6 */ /***/ function(n, i, r) { r.r(i); var o = r(0), l = /* @__PURE__ */ r.n(o), f = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(y) { return typeof y; } : function(y) { return y && typeof Symbol == "function" && y.constructor === Symbol && y !== Symbol.prototype ? "symbol" : typeof y; }, g = function() { function y(u, c) { for (var d = 0; d < c.length; d++) { var w = c[d]; w.enumerable = w.enumerable || !1, w.configurable = !0, "value" in w && (w.writable = !0), Object.defineProperty(u, w.key, w); } } return function(u, c, d) { return c && y(u.prototype, c), d && y(u, d), u; }; }(); function C(y, u) { if (!(y instanceof u)) throw new TypeError("Cannot call a class as a function"); } var a = function() { function y(u) { C(this, y), this.resolveOptions(u), this.initSelection(); } return g(y, [{ key: "resolveOptions", value: function() { var c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; this.action = c.action, this.container = c.container, this.emitter = c.emitter, this.target = c.target, this.text = c.text, this.trigger = c.trigger, this.selectedText = ""; } /** * Decides which selection strategy is going to be applied based * on the existence of `text` and `target` properties. */ }, { key: "initSelection", value: function() { this.text ? this.selectFake() : this.target && this.selectTarget(); } /** * Creates a fake textarea element, sets its value from `text` property, * and makes a selection on it. */ }, { key: "selectFake", value: function() { var c = this, d = document.documentElement.getAttribute("dir") == "rtl"; this.removeFake(), this.fakeHandlerCallback = function() { return c.removeFake(); }, this.fakeHandler = this.container.addEventListener("click", this.fakeHandlerCallback) || !0, this.fakeElem = document.createElement("textarea"), this.fakeElem.style.fontSize = "12pt", this.fakeElem.style.border = "0", this.fakeElem.style.padding = "0", this.fakeElem.style.margin = "0", this.fakeElem.style.position = "absolute", this.fakeElem.style[d ? "right" : "left"] = "-9999px"; var w = window.pageYOffset || document.documentElement.scrollTop; this.fakeElem.style.top = w + "px", this.fakeElem.setAttribute("readonly", ""), this.fakeElem.value = this.text, this.container.appendChild(this.fakeElem), this.selectedText = l()(this.fakeElem), this.copyText(); } /** * Only removes the fake element after another click event, that way * a user can hit `Ctrl+C` to copy because selection still exists. */ }, { key: "removeFake", value: function() { this.fakeHandler && (this.container.removeEventListener("click", this.fakeHandlerCallback), this.fakeHandler = null, this.fakeHandlerCallback = null), this.fakeElem && (this.container.removeChild(this.fakeElem), this.fakeElem = null); } /** * Selects the content from element passed on `target` property. */ }, { key: "selectTarget", value: function() { this.selectedText = l()(this.target), this.copyText(); } /** * Executes the copy operation based on the current selection. */ }, { key: "copyText", value: function() { var c = void 0; try { c = document.execCommand(this.action); } catch { c = !1; } this.handleResult(c); } /** * Fires an event based on the copy operation result. * @param {Boolean} succeeded */ }, { key: "handleResult", value: function(c) { this.emitter.emit(c ? "success" : "error", { action: this.action, text: this.selectedText, trigger: this.trigger, clearSelection: this.clearSelection.bind(this) }); } /** * Moves focus away from `target` and back to the trigger, removes current selection. */ }, { key: "clearSelection", value: function() { this.trigger && this.trigger.focus(), document.activeElement.blur(), window.getSelection().removeAllRanges(); } /** * Sets the `action` to be performed which can be either 'copy' or 'cut'. * @param {String} action */ }, { key: "destroy", /** * Destroy lifecycle. */ value: function() { this.removeFake(); } }, { key: "action", set: function() { var c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "copy"; if (this._action = c, this._action !== "copy" && this._action !== "cut") throw new Error('Invalid "action" value, use either "copy" or "cut"'); }, get: function() { return this._action; } /** * Sets the `target` property using an element * that will be have its content copied. * @param {Element} target */ }, { key: "target", set: function(c) { if (c !== void 0) if (c && (typeof c > "u" ? "undefined" : f(c)) === "object" && c.nodeType === 1) { if (this.action === "copy" && c.hasAttribute("disabled")) throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); if (this.action === "cut" && (c.hasAttribute("readonly") || c.hasAttribute("disabled"))) throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`); this._target = c; } else throw new Error('Invalid "target" value, use a valid Element'); }, get: function() { return this._target; } }]), y; }(), s = a, p = r(1), m = /* @__PURE__ */ r.n(p), v = r(2), T = /* @__PURE__ */ r.n(v), k = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(y) { return typeof y; } : function(y) { return y && typeof Symbol == "function" && y.constructor === Symbol && y !== Symbol.prototype ? "symbol" : typeof y; }, S = function() { function y(u, c) { for (var d = 0; d < c.length; d++) { var w = c[d]; w.enumerable = w.enumerable || !1, w.configurable = !0, "value" in w && (w.writable = !0), Object.defineProperty(u, w.key, w); } } return function(u, c, d) { return c && y(u.prototype, c), d && y(u, d), u; }; }(); function N(y, u) { if (!(y instanceof u)) throw new TypeError("Cannot call a class as a function"); } function h(y, u) { if (!y) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return u && (typeof u == "object" || typeof u == "function") ? u : y; } function b(y, u) { if (typeof u != "function" && u !== null) throw new TypeError("Super expression must either be null or a function, not " + typeof u); y.prototype = Object.create(u && u.prototype, { constructor: { value: y, enumerable: !1, writable: !0, configurable: !0 } }), u && (Object.setPrototypeOf ? Object.setPrototypeOf(y, u) : y.__proto__ = u); } var E = function(y) { b(u, y); function u(c, d) { N(this, u); var w = h(this, (u.__proto__ || Object.getPrototypeOf(u)).call(this)); return w.resolveOptions(d), w.listenClick(c), w; } return S(u, [{ key: "resolveOptions", value: function() { var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; this.action = typeof d.action == "function" ? d.action : this.defaultAction, this.target = typeof d.target == "function" ? d.target : this.defaultTarget, this.text = typeof d.text == "function" ? d.text : this.defaultText, this.container = k(d.container) === "object" ? d.container : document.body; } /** * Adds a click event listener to the passed trigger. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger */ }, { key: "listenClick", value: function(d) { var w = this; this.listener = T()(d, "click", function(O) { return w.onClick(O); }); } /** * Defines a new `ClipboardAction` on each click event. * @param {Event} e */ }, { key: "onClick", value: function(d) { var w = d.delegateTarget || d.currentTarget; this.clipboardAction && (this.clipboardAction = null), this.clipboardAction = new s({ action: this.action(w), target: this.target(w), text: this.text(w), container: this.container, trigger: w, emitter: this }); } /** * Default `action` lookup function. * @param {Element} trigger */ }, { key: "defaultAction", value: function(d) { return _("action", d); } /** * Default `target` lookup function. * @param {Element} trigger */ }, { key: "defaultTarget", value: function(d) { var w = _("target", d); if (w) return document.querySelector(w); } /** * Returns the support of the given action, or all actions if no action is * given. * @param {String} [action] */ }, { key: "defaultText", /** * Default `text` lookup function. * @param {Element} trigger */ value: function(d) { return _("text", d); } /** * Destroy lifecycle. */ }, { key: "destroy", value: function() { this.listener.destroy(), this.clipboardAction && (this.clipboardAction.destroy(), this.clipboardAction = null); } }], [{ key: "isSupported", value: function() { var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ["copy", "cut"], w = typeof d == "string" ? [d] : d, O = !!document.queryCommandSupported; return w.forEach(function(re) { O = O && !!document.queryCommandSupported(re); }), O; } }]), u; }(m.a); function _(y, u) { var c = "data-clipboard-" + y; if (u.hasAttribute(c)) return u.getAttribute(c); } i.default = E; } /******/ ]).default ); }); }), ee = /* @__PURE__ */ Ke(Je); const I = { autoSetContainer: !1, appendToBody: !0 }, Xe = { config: (e) => { const { autoSetContainer: t, appendToBody: n } = e; I.autoSetContainer = t || !1, I.appendToBody = n || !0; }, install: (e) => { e.config.globalProperties.$vclipboard = X, e.directive("clipboard", { beforeMount(t, n) { if (n.arg === "success") t._vClipboard_success = n.value; else if (n.arg === "error") t._vClipboard_error = n.value; else { const i = new ee(t, { text: () => n.value, action: () => n.arg === "cut" ? "cut" : "copy", container: I.autoSetContainer ? t : void 0 }); i.on("success", (r) => { const o = t._vClipboard_success; o && o(r); }), i.on("error", (r) => { const o = t._vClipboard_error; o && o(r); }), t._vClipboard = i; } }, updated(t, n) { n.arg === "success" ? t._vClipboard_success = n.value : n.arg === "error" ? t._vClipboard_error = n.value : (t._vClipboard.text = () => n.value, t._vClipboard.action = () => n.arg === "cut" ? "cut" : "copy"); }, unmounted(t, n) { n.arg === "success" ? delete t._vClipboard_success : n.arg === "error" ? delete t._vClipboard_error : (t._vClipboard.destroy(), delete t._vClipboard); } }); }, toClipboard: (e, t) => X(e, t) }, X = (e, t = "copy") => new Promise((n, i) => { const r = document.createElement("button"), o = new ee(r, { text: () => e, action: () => t }); o.on("success", (l) => { o.destroy(), n(l); }), o.on("error", (l) => { o.destroy(), i(l); }), I.appendToBody && document.body.appendChild(r), r.click(), I.appendToBody && document.body.removeChild(r); }), Ze = /* @__PURE__ */ Object.assign({ "./components/fs-copyable.vue": () => import("./fs-copyable-07963571.mjs") }), We = { install(e) { x.vite.installAsyncComponents(e, Ze, [], null, null); } }, Ct = { install(e) { e.use(He), e.use(We), e.use(Xe); } }; function Qe() { return { "time-humanize": { column: { component: { name: "fs-time-humanize", vModel: "modelValue" } } } }; } const et = { install(e) { const t = Qe(), { addTypes: n } = U(); n(t); } }, tt = /* @__PURE__ */ Object.assign({ "./components/fs-time-humanize.vue": () => import("./fs-time-humanize-ddeec7a4.mjs") }), nt = { install(e) { x.vite.installAsyncComponents(e, tt, [], null, null); } }, wt = { install(e) { e.use(et), e.use(nt); } }; async function Y() { const e = /* @__PURE__ */ Object.assign({ "./phoneCodeCountries.ts": () => import("./phoneCodeCountries-923a4b31.mjs") }), { countries: t } = await e["./phoneCodeCountries.ts"](); return t; } async function te(e) { const t = await Y(); let n = null; return e != null && (e.countryCode != null ? n = t.find((i) => i.iso2 === e.countryCode) : e.callingCode != null && (n = t.find((i) => i.dialCode === e.callingCode))), n != null && (n = { callingCode: n.dialCode, countryCode: n.iso2 }), n; } const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, getCountries: Y, getCountryByValue: te }, Symbol.toStringTag, { value: "Module" })), rt = { class: "fs-phone-input" }, Et = /* @__PURE__ */ Z({ __name: "fs-phone-input", props: { select: {}, input: {}, modelValue: {}, onlyCountries: {}, ignoredCountries: {}, priorityCountries: {}, clearable: { type: Boolean }, filterable: { type: Boolean }, defaultCountry: { default: "CN" }, disabled: { type: Boolean }, readonly: { type: Boolean } }, emits: ["change", "input", "update:modelValue"], setup(e, { emit: t }) { const { ui: n } = W(), i = n.formItem.injectFormItemContext(), r = e, o = t, l = R( r.modelValue || { callingCode: void 0, // 电话区号 countryCode: void 0, // 国家代码 phoneNumber: void 0 // 电话号码 } ), f = pe({ value: "iso2", label: "label" }), g = R([]); async function C() { g.value = await Y(); } C(); const a = j(() => { const h = g.value; let b = []; if (r.onlyCountries != null && r.onlyCountries.length > 0) for (let E of h) r.onlyCountries.find((_) => _.toLowerCase() === E.iso2.toLowerCase()) && b.push(E); else { const E = r.priorityCountries || [], _ = r.ignoredCountries || [], y = [], u = []; for (let c of h) E.find((d) => d.toLowerCase() === c.iso2.toLowerCase()) && y.push(c), _.find((d) => d.toLowerCase() === c.iso2.toLowerCase()) || u.push(c); b = y.concat(u); } return b = b.map((E) => ({ ...E, label: E.name + "(" + E.dialCode + ")" })), b; }), s = j(() => { const h = { placeholder: "请选择", [n.select.filterable]: !0, [n.select.clearable]: !0, [n.select.modelValue]: l.value.countryCode, ["onUpdate:" + n.select.modelValue]: T }; return V(h, r.select); }), p = j(() => { const h = { placeholder: "请输入", [n.select.clearable]: !0, [n.input.modelValue]: l.value.phoneNumber, [`onUpdate:${n.input.modelValue}`]: k }; return V(h, r.input); }); async function m(h) { l.value = { callingCode: void 0, countryCode: void 0, phoneNumber: void 0 }; const b = await v(h); b != null && (l.value.callingCode = b.callingCode, l.value.countryCode = b.countryCode), h && h.phoneNumber ? l.value.phoneNumber = h.phoneNumber : l.value.phoneNumber = void 0; } async function v(h) { let b = null; return h != null && (h.countryCode != null ? b = a.value.find((E) => E.iso2 === h.countryCode) : h.callingCode != null && (b = a.value.find((E) => E.dialCode === h.callingCode))), b != null && (b = { callingCode: b.dialCode, countryCode: b.iso2 }), b == null && (b = await te({ countryCode: r.defaultCountry })), b; } async function T(h) { await N(h); let b = S(); o("update:modelValue", b), o("input", b), o("change", b), await i.onChange(), await i.onBlur(); } async function k(h) { if (l.value.phoneNumber = h, l.value.callingCode == null && l.value.countryCode == null) { l.value.countryCode = r.defaultCountry; const E = await v(l.value); E && (l.value.callingCode = E.callingCode); } let b = S(); o("update:modelValue", b), o("input", b), o("change", b), await i.onChange(), await i.onBlur(); } function S() { return { countryCode: l.value.countryCode, callingCode: l.value.callingCode, phoneNumber: l.value.phoneNumber }; } async function N(h) { h || (l.value.callingCode = void 0), l.value.countryCode = h; let b = await v(l.value); b && (l.value.callingCode = b.callingCode); } return z( () => r.modelValue, async (h, b) => { await m(h), o("change", l.value); }, { immediate: !0 } ), (h, b) => { const E = K("fs-dict-select"); return A(), D("div", rt, [ L(E, M({ disabled: h.disabled, readonly: h.readonly, filterable: h.filterable, clearable: h.clearable, options: a.value, dict: G(f), "show-search": !0, "allow-clear": !0 }, s.value), null, 16, ["disabled", "readonly", "filterable", "clearable", "options", "dict"]), (A(), H(q(G(n).input.name), M({ type: "text", clearable: h.clearable, disabled: h.disabled, readonly: h.readonly, "allow-clear": !0 }, p.value), null, 16, ["clearable", "disabled", "readonly"])) ]); }; } }); async function ne({ phoneNumber: e, countryCode: t }) { const i = (await import("./index-95df7f7f.mjs")).parsePhoneNumberFromString, r = e && t ? i(e, t) : null; return { phoneNumber: e || null, countryCode: t, isValid: !1, ...r ? { formattedNumber: r.number, nationalNumber: r.nationalNumber, isValid: r.isValid(), type: r.getType(), formatInternational: r.formatInternational(), formatNational: r.formatNational(), uri: r.getURI(), e164: r.format("E.164") } : null }; } async function oe(e) { const t = /* @__PURE__ */ Object.assign({ "./utils.ts": () => Promise.resolve().then(() => ot) }), { getCountryByValue: n } = await t["./utils.ts"](); return n(e); } async function Tt(e, t) { if (!t || t.phoneNumber == null || t.phoneNumber === "") return !0; if (!t.countryCode && t.callingCode) { const i = await oe(t); i && (t.countryCode = i.countryCode); } const n = await ne({ phoneNumber: t.phoneNumber, countryCode: t.countryCode }); if (!n.isValid) throw console.warn("parse:", n), new Error("电话号码错误"); return !0; } async function it(e, t, n) { if (!t || t.phoneNumber == null || t.phoneNumber === "" || t.countryCode == null || t.countryCode === "") return !0; if (!t.countryCode && t.callingCode) { const r = await oe(t); r && (t.countryCode = r.countryCode); } const i = await ne({ phoneNumber: t.phoneNumber, countryCode: t.countryCode }); if (!i.isValid || i.type !== "MOBILE" && i.type !== "FIXED_LINE_OR_MOBILE") throw console.warn("parse:", i), new Error("手机号错误"); return !0; } async function _t(e, t) { const n = t.countryCode == null || t.countryCode === "", i = t.callingCode == null || t.callingCode === "", r = t.phoneNumber == null || t.phoneNumber === ""; if (!t || r || n && i) throw new Error("该项必填"); return !0; } function lt() { return { phone: { column: { cellRender({ value: e }) { return !e || !e.phoneNumber ? "" : L("div", null, [J("("), e.callingCode || "86", J(")"), e.phoneNumber]); } }, form: { component: { name: "fs-phone-input", vModel: "modelValue" }, rules: [{ validator: it, message: "请填写正确的手机号码" }] } } }; } const at = { install(e) { const t = lt(), { addTypes: n } = U(); n(t); } }, st = /* @__PURE__ */ Object.assign({ "./components/fs-phone-input/fs-phone-input.vue": () => import("./fs-phone-input-51dfe04c.mjs") }), ut = { install(e) { x.vite.installAsyncComponents(e, st, [], null, null); } }, xt = { install(e) { e.use(at), e.use(ut); } }; export { mt as A, ht as F, ge as _, Et as a, yt as b, Te as c, je as d, F as e, pt as f, vt as g, bt as h, Ct as i, wt as j, xt as k, Ae as l, ne as m, it as n, _t as o, Tt as p, gt as u }; //# sourceMappingURL=index-50ffe046.mjs.map