basic-file-preview 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/DocxPreview.js +19 -1
- package/dist/lib/ExcelPreview.js +20 -1
- package/dist/lib/ImagePreview.js +670 -1
- package/dist/lib/JsonPreview.js +42 -1
- package/dist/lib/MarkdownPreview.js +50 -1
- package/dist/lib/PdfPreview.js +42 -1
- package/dist/lib/PptPreview.js +203 -1
- package/dist/lib/TxtPreview.js +39 -2
- package/dist/lib/_plugin-vue_export-helper.js +9 -1
- package/dist/lib/index.js +3142 -5
- package/dist/types/components/FilePreview/index.d.ts +11 -4
- package/package.json +3 -4
- package/dist/index.cjs.js +0 -2
package/dist/lib/ImagePreview.js
CHANGED
|
@@ -1 +1,670 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index.js"),e=require("vue");var ie=/\s/;function ce(n){for(var c=n.length;c--&&ie.test(n.charAt(c)););return c}var ue=/^\s+/;function de(n){return n&&n.slice(0,ce(n)+1).replace(ue,"")}var re=NaN,fe=/^[-+]0x[0-9a-f]+$/i,me=/^0b[01]+$/i,ve=/^0o[0-7]+$/i,pe=parseInt;function ae(n){if(typeof n=="number")return n;if(t.isSymbol(n))return re;if(t.isObject$1(n)){var c=typeof n.valueOf=="function"?n.valueOf():n;n=t.isObject$1(c)?c+"":c}if(typeof n!="string")return n===0?n:+n;n=de(n);var f=me.test(n);return f||ve.test(n)?pe(n.slice(2),f?2:8):fe.test(n)?re:+n}var te=function(){return t.root.Date.now()},ge="Expected a function",he=Math.max,Ee=Math.min;function we(n,c,f){var s,o,h,p,g,l,z=0,b=!1,y=!1,k=!0;if(typeof n!="function")throw new TypeError(ge);c=ae(c)||0,t.isObject$1(f)&&(b=!!f.leading,y="maxWait"in f,h=y?he(ae(f.maxWait)||0,c):h,k="trailing"in f?!!f.trailing:k);function x(d){var E=s,I=o;return s=o=void 0,z=d,p=n.apply(I,E),p}function C(d){return z=d,g=setTimeout(v,c),b?x(d):p}function N(d){var E=d-l,I=d-z,D=c-E;return y?Ee(D,h-I):D}function O(d){var E=d-l,I=d-z;return l===void 0||E>=c||E<0||y&&I>=h}function v(){var d=te();if(O(d))return V(d);g=setTimeout(v,N(d))}function V(d){return g=void 0,k&&s?x(d):(s=o=void 0,p)}function u(){g!==void 0&&clearTimeout(g),z=0,s=l=o=g=void 0}function P(){return g===void 0?p:V(te())}function _(){var d=te(),E=O(d);if(s=arguments,o=this,l=d,E){if(g===void 0)return C(l);if(y)return clearTimeout(g),g=setTimeout(v,c),x(l)}return g===void 0&&(g=setTimeout(v,c)),p}return _.cancel=u,_.flush=P,_}var ye="Expected a function";function K(n,c,f){var s=!0,o=!0;if(typeof n!="function")throw new TypeError(ye);return t.isObject$1(f)&&(s="leading"in f?!!f.leading:s,o="trailing"in f?!!f.trailing:o),we(n,c,{leading:s,maxWait:c,trailing:o})}const Ce=["class","style"],ke=/^on[A-Z]/,Ne=(n={})=>{const{excludeListeners:c=!1,excludeKeys:f}=n,s=e.computed(()=>(f?.value||[]).concat(Ce)),o=e.getCurrentInstance();return o?e.computed(()=>t.fromPairs(Object.entries(o.proxy?.$attrs).filter(([h])=>!s.value.includes(h)&&!(c&&ke.test(h))))):(t.debugWarn("use-attrs","getCurrentInstance() returned null. useAttrs() must be called at the top of a setup function"),e.computed(()=>({})))},be=t.buildProps({hideOnClickModal:Boolean,src:{type:String,default:""},fit:{type:String,values:["","contain","cover","fill","none","scale-down"],default:""},loading:{type:String,values:["eager","lazy"]},lazy:Boolean,scrollContainer:{type:t.definePropType([String,Object])},previewSrcList:{type:t.definePropType(Array),default:()=>t.mutable([])},previewTeleported:Boolean,zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},scale:{type:Number,default:1},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7},showProgress:Boolean,crossorigin:{type:t.definePropType(String)}}),Ie={load:n=>n instanceof Event,error:n=>n instanceof Event,switch:n=>t.isNumber(n),close:()=>!0,show:()=>!0},xe=t.buildProps({urlList:{type:t.definePropType(Array),default:()=>t.mutable([])},zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},hideOnClickModal:Boolean,teleported:Boolean,closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},scale:{type:Number,default:1},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7},showProgress:Boolean,crossorigin:{type:t.definePropType(String)}}),Se={close:()=>!0,error:n=>n instanceof Event,switch:n=>t.isNumber(n),rotate:n=>t.isNumber(n)},Te=["src","crossorigin"];var ze=e.defineComponent({name:"ElImageViewer",__name:"image-viewer",props:xe,emits:Se,setup(n,{expose:c,emit:f}){const s={CONTAIN:{name:"contain",icon:e.markRaw(t.full_screen_default)},ORIGINAL:{name:"original",icon:e.markRaw(t.scale_to_original_default)}},o=n,h=f;let p;const{t:g}=t.useLocale(),l=t.useNamespace("image-viewer"),{nextZIndex:z}=t.useZIndex(),b=e.ref(),y=e.ref(),k=e.effectScope(),x=e.computed(()=>{const{scale:r,minScale:i,maxScale:m}=o;return t.clamp(r,i,m)}),C=e.ref(!0),N=e.ref(!1),O=e.ref(!1),v=e.ref(o.initialIndex),V=e.shallowRef(s.CONTAIN),u=e.ref({scale:x.value,deg:0,offsetX:0,offsetY:0,enableTransition:!1}),P=e.ref(o.zIndex??z());t.useLockscreen(O,{ns:l});const _=e.computed(()=>{const{urlList:r}=o;return r.length<=1}),d=e.computed(()=>v.value===0),E=e.computed(()=>v.value===o.urlList.length-1),I=e.computed(()=>o.urlList[v.value]),D=e.computed(()=>[l.e("btn"),l.e("prev"),l.is("disabled",!o.infinite&&d.value)]),q=e.computed(()=>[l.e("btn"),l.e("next"),l.is("disabled",!o.infinite&&E.value)]),F=e.computed(()=>{const{scale:r,deg:i,offsetX:m,offsetY:L,enableTransition:$}=u.value;let S=m/r,T=L/r;const X=i*Math.PI/180,M=Math.cos(X),Y=Math.sin(X);S=S*M+T*Y,T=T*M-m/r*Y;const ee={transform:`scale(${r}) rotate(${i}deg) translate(${S}px, ${T}px)`,transition:$?"transform .3s":""};return V.value.name===s.CONTAIN.name&&(ee.maxWidth=ee.maxHeight="100%"),ee}),W=e.computed(()=>`${v.value+1} / ${o.urlList.length}`);function R(){U(),p?.(),O.value=!1,h("close")}function j(){const r=K(m=>{switch(t.getEventCode(m)){case t.EVENT_CODE.esc:o.closeOnPressEscape&&R();break;case t.EVENT_CODE.space:G();break;case t.EVENT_CODE.left:J();break;case t.EVENT_CODE.up:B("zoomIn");break;case t.EVENT_CODE.right:Q();break;case t.EVENT_CODE.down:B("zoomOut");break}}),i=K(m=>{B((m.deltaY||m.deltaX)<0?"zoomIn":"zoomOut",{zoomRate:o.zoomRate,enableTransition:!1})});k.run(()=>{t.useEventListener(document,"keydown",r),t.useEventListener(b,"wheel",i)})}function U(){k.stop()}function Z(){C.value=!1}function a(r){N.value=!0,C.value=!1,h("error",r),r.target.alt=g("el.image.error")}function A(r){if(C.value||r.button!==0||!b.value)return;u.value.enableTransition=!1;const{offsetX:i,offsetY:m}=u.value,L=r.pageX,$=r.pageY,S=K(M=>{u.value={...u.value,offsetX:i+M.pageX-L,offsetY:m+M.pageY-$}}),T=t.useEventListener(document,"mousemove",S),X=t.useEventListener(document,"mouseup",()=>{T(),X()});r.preventDefault()}function w(r){if(C.value||!b.value||r.touches.length!==1)return;u.value.enableTransition=!1;const{offsetX:i,offsetY:m}=u.value,{pageX:L,pageY:$}=r.touches[0],S=K(M=>{const Y=M.touches[0];u.value={...u.value,offsetX:i+Y.pageX-L,offsetY:m+Y.pageY-$}}),T=t.useEventListener(document,"touchmove",S),X=t.useEventListener(document,"touchend",()=>{T(),X()});r.preventDefault()}function ne(){u.value={scale:x.value,deg:0,offsetX:0,offsetY:0,enableTransition:!1}}function G(){if(C.value||N.value)return;const r=t.keysOf(s),i=Object.values(s),m=V.value.name;V.value=s[r[(i.findIndex(L=>L.name===m)+1)%r.length]],ne()}function H(r){N.value=!1;const i=o.urlList.length;v.value=(r+i)%i}function J(){d.value&&!o.infinite||H(v.value-1)}function Q(){E.value&&!o.infinite||H(v.value+1)}function B(r,i={}){if(C.value||N.value)return;const{minScale:m,maxScale:L}=o,{zoomRate:$,rotateDeg:S,enableTransition:T}={zoomRate:o.zoomRate,rotateDeg:90,enableTransition:!0,...i};switch(r){case"zoomOut":u.value.scale>m&&(u.value.scale=Number.parseFloat((u.value.scale/$).toFixed(3)));break;case"zoomIn":u.value.scale<L&&(u.value.scale=Number.parseFloat((u.value.scale*$).toFixed(3)));break;case"clockwise":u.value.deg+=S,h("rotate",u.value.deg);break;case"anticlockwise":u.value.deg-=S,h("rotate",u.value.deg);break}u.value.enableTransition=T}function oe(r){r.detail?.focusReason==="pointer"&&r.preventDefault()}function le(){o.closeOnPressEscape&&R()}function se(r){if(r.ctrlKey){if(r.deltaY<0)return r.preventDefault(),!1;if(r.deltaY>0)return r.preventDefault(),!1}}return e.watch(()=>x.value,r=>{u.value.scale=r}),e.watch(I,()=>{e.nextTick(()=>{y.value?.complete||(C.value=!0)})}),e.watch(v,r=>{ne(),h("switch",r)}),e.onMounted(()=>{O.value=!0,j(),p=t.useEventListener("wheel",se,{passive:!1})}),c({setActiveItem:H}),(r,i)=>(e.openBlock(),e.createBlock(e.unref(t.ElTeleport),{to:"body",disabled:!n.teleported},{default:e.withCtx(()=>[e.createVNode(e.Transition,{name:"viewer-fade",appear:""},{default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"wrapper",ref:b,tabindex:-1,class:e.normalizeClass(e.unref(l).e("wrapper")),style:e.normalizeStyle({zIndex:P.value})},[e.createVNode(e.unref(t.focus_trap_default$1),{loop:"",trapped:"","focus-trap-el":b.value,"focus-start-el":"container",onFocusoutPrevented:oe,onReleaseRequested:le},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("mask")),onClick:i[0]||(i[0]=e.withModifiers(m=>n.hideOnClickModal&&R(),["self"]))},null,2),e.createCommentVNode(" CLOSE "),e.createElementVNode("span",{class:e.normalizeClass([e.unref(l).e("btn"),e.unref(l).e("close")]),onClick:R},[e.createVNode(e.unref(t.ElIcon),null,{default:e.withCtx(()=>[e.createVNode(e.unref(t.close_default))]),_:1})],2),e.createCommentVNode(" ARROW "),_.value?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("span",{class:e.normalizeClass(D.value),onClick:J},[e.createVNode(e.unref(t.ElIcon),null,{default:e.withCtx(()=>[e.createVNode(e.unref(t.arrow_left_default))]),_:1})],2),e.createElementVNode("span",{class:e.normalizeClass(q.value),onClick:Q},[e.createVNode(e.unref(t.ElIcon),null,{default:e.withCtx(()=>[e.createVNode(e.unref(t.arrow_right_default))]),_:1})],2)],64)),r.$slots.progress||n.showProgress?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass([e.unref(l).e("btn"),e.unref(l).e("progress")])},[e.renderSlot(r.$slots,"progress",{activeIndex:v.value,total:n.urlList.length},()=>[e.createTextVNode(e.toDisplayString(W.value),1)])],2)):e.createCommentVNode("v-if",!0),e.createCommentVNode(" ACTIONS "),e.createElementVNode("div",{class:e.normalizeClass([e.unref(l).e("btn"),e.unref(l).e("actions")])},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("actions__inner"))},[e.renderSlot(r.$slots,"toolbar",{actions:B,prev:J,next:Q,reset:G,activeIndex:v.value,setActiveItem:H},()=>[e.createVNode(e.unref(t.ElIcon),{onClick:i[1]||(i[1]=m=>B("zoomOut"))},{default:e.withCtx(()=>[e.createVNode(e.unref(t.zoom_out_default))]),_:1}),e.createVNode(e.unref(t.ElIcon),{onClick:i[2]||(i[2]=m=>B("zoomIn"))},{default:e.withCtx(()=>[e.createVNode(e.unref(t.zoom_in_default))]),_:1}),e.createElementVNode("i",{class:e.normalizeClass(e.unref(l).e("actions__divider"))},null,2),e.createVNode(e.unref(t.ElIcon),{onClick:G},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(V.value.icon)))]),_:1}),e.createElementVNode("i",{class:e.normalizeClass(e.unref(l).e("actions__divider"))},null,2),e.createVNode(e.unref(t.ElIcon),{onClick:i[3]||(i[3]=m=>B("anticlockwise"))},{default:e.withCtx(()=>[e.createVNode(e.unref(t.refresh_left_default))]),_:1}),e.createVNode(e.unref(t.ElIcon),{onClick:i[4]||(i[4]=m=>B("clockwise"))},{default:e.withCtx(()=>[e.createVNode(e.unref(t.refresh_right_default))]),_:1})])],2)],2),e.createCommentVNode(" CANVAS "),e.createElementVNode("div",{class:e.normalizeClass(e.unref(l).e("canvas"))},[N.value&&r.$slots["viewer-error"]?e.renderSlot(r.$slots,"viewer-error",{key:0,activeIndex:v.value,src:I.value}):(e.openBlock(),e.createElementBlock("img",{ref_key:"imgRef",ref:y,key:I.value,src:I.value,style:e.normalizeStyle(F.value),class:e.normalizeClass(e.unref(l).e("img")),crossorigin:n.crossorigin,onLoad:Z,onError:a,onMousedown:A,onTouchstart:w},null,46,Te))],2),e.renderSlot(r.$slots,"default")]),_:3},8,["focus-trap-el"])],6)]),_:3})]),_:3},8,["disabled"]))}}),Ve=ze;const Le=t.withInstall(Ve),Oe=["src","loading","crossorigin"],Be={key:0};var $e=e.defineComponent({name:"ElImage",inheritAttrs:!1,__name:"image",props:be,emits:Ie,setup(n,{expose:c,emit:f}){const s=n,o=f,{t:h}=t.useLocale(),p=t.useNamespace("image"),g=e.useAttrs(),l=e.computed(()=>t.fromPairs(Object.entries(g).filter(([a])=>/^(data-|on[A-Z])/i.test(a)||["id","style"].includes(a)))),z=Ne({excludeListeners:!0,excludeKeys:e.computed(()=>Object.keys(l.value))}),b=e.ref(),y=e.ref(!1),k=e.ref(!0),x=e.ref(!1),C=e.ref(),N=e.ref(),O=t.isClient&&"loading"in HTMLImageElement.prototype;let v;const V=e.computed(()=>[p.e("inner"),P.value&&p.e("preview"),k.value&&p.is("loading")]),u=e.computed(()=>{const{fit:a}=s;return t.isClient&&a?{objectFit:a}:{}}),P=e.computed(()=>{const{previewSrcList:a}=s;return t.isArray(a)&&a.length>0}),_=e.computed(()=>{const{previewSrcList:a,initialIndex:A}=s;let w=A;return A>a.length-1&&(w=0),w}),d=e.computed(()=>s.loading==="eager"?!1:!O&&s.loading==="lazy"||s.lazy),E=()=>{t.isClient&&(k.value=!0,y.value=!1,b.value=s.src)};function I(a){k.value=!1,y.value=!1,o("load",a)}function D(a){k.value=!1,y.value=!0,o("error",a)}function q(a){a&&(E(),R())}const F=t.useThrottleFn(q,200,!0);async function W(){if(!t.isClient)return;await e.nextTick();const{scrollContainer:a}=s;if(t.isElement(a))N.value=a;else if(t.isString(a)&&a!=="")N.value=document.querySelector(a)??void 0;else if(C.value){const w=t.getScrollContainer(C.value);N.value=t.isWindow(w)?void 0:w}const{stop:A}=t.useIntersectionObserver(C,([w])=>{F(w.isIntersecting)},{root:N});v=A}function R(){!t.isClient||!F||(v?.(),N.value=void 0,v=void 0)}function j(){P.value&&(x.value=!0,o("show"))}function U(){x.value=!1,o("close")}function Z(a){o("switch",a)}return e.watch(()=>s.src,()=>{d.value?(k.value=!0,y.value=!1,R(),W()):E()}),e.onMounted(()=>{d.value?W():E()}),c({showPreview:j}),(a,A)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({ref_key:"container",ref:C},l.value,{class:[e.unref(p).b(),a.$attrs.class]}),[y.value?e.renderSlot(a.$slots,"error",{key:0},()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(p).e("error"))},e.toDisplayString(e.unref(h)("el.image.error")),3)]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[b.value!==void 0?(e.openBlock(),e.createElementBlock("img",e.mergeProps({key:0},e.unref(z),{src:b.value,loading:n.loading,style:u.value,class:V.value,crossorigin:n.crossorigin,onClick:j,onLoad:I,onError:D}),null,16,Oe)):e.createCommentVNode("v-if",!0),k.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(e.unref(p).e("wrapper"))},[e.renderSlot(a.$slots,"placeholder",{},()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(p).e("placeholder"))},null,2)])],2)):e.createCommentVNode("v-if",!0)],64)),P.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[x.value?(e.openBlock(),e.createBlock(e.unref(Le),{key:0,"z-index":n.zIndex,"initial-index":_.value,infinite:n.infinite,"zoom-rate":n.zoomRate,"min-scale":n.minScale,"max-scale":n.maxScale,"show-progress":n.showProgress,"url-list":n.previewSrcList,scale:n.scale,crossorigin:n.crossorigin,"hide-on-click-modal":n.hideOnClickModal,teleported:n.previewTeleported,"close-on-press-escape":n.closeOnPressEscape,onClose:U,onSwitch:Z},e.createSlots({toolbar:e.withCtx(w=>[e.renderSlot(a.$slots,"toolbar",e.normalizeProps(e.guardReactiveProps(w)))]),default:e.withCtx(()=>[a.$slots.viewer?(e.openBlock(),e.createElementBlock("div",Be,[e.renderSlot(a.$slots,"viewer")])):e.createCommentVNode("v-if",!0)]),_:2},[a.$slots.progress?{name:"progress",fn:e.withCtx(w=>[e.renderSlot(a.$slots,"progress",e.normalizeProps(e.guardReactiveProps(w)))]),key:"0"}:void 0,a.$slots["viewer-error"]?{name:"viewer-error",fn:e.withCtx(w=>[e.renderSlot(a.$slots,"viewer-error",e.normalizeProps(e.guardReactiveProps(w)))]),key:"1"}:void 0]),1032,["z-index","initial-index","infinite","zoom-rate","min-scale","max-scale","show-progress","url-list","scale","crossorigin","hide-on-click-modal","teleported","close-on-press-escape"])):e.createCommentVNode("v-if",!0)],64)):e.createCommentVNode("v-if",!0)],16))}}),Pe=$e;const _e=t.withInstall(Pe),Re=e.defineComponent({name:"ImagePreview",__name:"ImagePreview",props:{url:{}},setup(n){return(c,f)=>{const s=_e;return e.openBlock(),e.createBlock(s,{src:n.url,fit:"contain",class:"w-full h-full"},null,8,["src"])}}});exports.default=Re;
|
|
1
|
+
import { d as Fe, e as ue, f as Ve, j as We, k as Ne, l as ke, m as Oe, n as ne, o as $e, s as He, p as Ke, q as Re, t as Ae, v as je, w as qe, x as Ue, y as Z, E as Ze, z as Ge, A as W, B as Je, C as Qe, D as et, F as tt, G as nt, H as at, I as st, J as rt, K as Q, L as ot, M as _e, i as te, N as lt, O as it, P as ut, a as ct, Q as ft, R as dt, S as vt } from "./index.js";
|
|
2
|
+
import { computed as m, getCurrentInstance as mt, defineComponent as Ee, markRaw as Le, ref as L, effectScope as gt, shallowRef as pt, watch as ie, nextTick as Pe, onMounted as Me, openBlock as C, createBlock as ce, unref as a, withCtx as I, createVNode as p, Transition as ht, createElementVNode as O, normalizeStyle as Se, normalizeClass as k, withModifiers as yt, createCommentVNode as R, createElementBlock as Y, Fragment as Ie, renderSlot as P, createTextVNode as wt, toDisplayString as Xe, resolveDynamicComponent as bt, useAttrs as kt, mergeProps as Te, createSlots as It, normalizeProps as ye, guardReactiveProps as we } from "vue";
|
|
3
|
+
var Et = /\s/;
|
|
4
|
+
function xt(e) {
|
|
5
|
+
for (var i = e.length; i-- && Et.test(e.charAt(i)); )
|
|
6
|
+
;
|
|
7
|
+
return i;
|
|
8
|
+
}
|
|
9
|
+
var Lt = /^\s+/;
|
|
10
|
+
function St(e) {
|
|
11
|
+
return e && e.slice(0, xt(e) + 1).replace(Lt, "");
|
|
12
|
+
}
|
|
13
|
+
var Ce = NaN, Tt = /^[-+]0x[0-9a-f]+$/i, Ct = /^0b[01]+$/i, zt = /^0o[0-7]+$/i, Nt = parseInt;
|
|
14
|
+
function ze(e) {
|
|
15
|
+
if (typeof e == "number")
|
|
16
|
+
return e;
|
|
17
|
+
if (Fe(e))
|
|
18
|
+
return Ce;
|
|
19
|
+
if (ue(e)) {
|
|
20
|
+
var i = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
21
|
+
e = ue(i) ? i + "" : i;
|
|
22
|
+
}
|
|
23
|
+
if (typeof e != "string")
|
|
24
|
+
return e === 0 ? e : +e;
|
|
25
|
+
e = St(e);
|
|
26
|
+
var f = Ct.test(e);
|
|
27
|
+
return f || zt.test(e) ? Nt(e.slice(2), f ? 2 : 8) : Tt.test(e) ? Ce : +e;
|
|
28
|
+
}
|
|
29
|
+
var be = function() {
|
|
30
|
+
return Ve.Date.now();
|
|
31
|
+
}, Ot = "Expected a function", $t = Math.max, Rt = Math.min;
|
|
32
|
+
function At(e, i, f) {
|
|
33
|
+
var o, s, y, g, h, r, M = 0, z = !1, E = !1, S = !0;
|
|
34
|
+
if (typeof e != "function")
|
|
35
|
+
throw new TypeError(Ot);
|
|
36
|
+
i = ze(i) || 0, ue(f) && (z = !!f.leading, E = "maxWait" in f, y = E ? $t(ze(f.maxWait) || 0, i) : y, S = "trailing" in f ? !!f.trailing : S);
|
|
37
|
+
function $(c) {
|
|
38
|
+
var w = o, N = s;
|
|
39
|
+
return o = s = void 0, M = c, g = e.apply(N, w), g;
|
|
40
|
+
}
|
|
41
|
+
function x(c) {
|
|
42
|
+
return M = c, h = setTimeout(v, i), z ? $(c) : g;
|
|
43
|
+
}
|
|
44
|
+
function T(c) {
|
|
45
|
+
var w = c - r, N = c - M, G = i - w;
|
|
46
|
+
return E ? Rt(G, y - N) : G;
|
|
47
|
+
}
|
|
48
|
+
function D(c) {
|
|
49
|
+
var w = c - r, N = c - M;
|
|
50
|
+
return r === void 0 || w >= i || w < 0 || E && N >= y;
|
|
51
|
+
}
|
|
52
|
+
function v() {
|
|
53
|
+
var c = be();
|
|
54
|
+
if (D(c))
|
|
55
|
+
return X(c);
|
|
56
|
+
h = setTimeout(v, T(c));
|
|
57
|
+
}
|
|
58
|
+
function X(c) {
|
|
59
|
+
return h = void 0, S && o ? $(c) : (o = s = void 0, g);
|
|
60
|
+
}
|
|
61
|
+
function u() {
|
|
62
|
+
h !== void 0 && clearTimeout(h), M = 0, o = r = s = h = void 0;
|
|
63
|
+
}
|
|
64
|
+
function H() {
|
|
65
|
+
return h === void 0 ? g : X(be());
|
|
66
|
+
}
|
|
67
|
+
function K() {
|
|
68
|
+
var c = be(), w = D(c);
|
|
69
|
+
if (o = arguments, s = this, r = c, w) {
|
|
70
|
+
if (h === void 0)
|
|
71
|
+
return x(r);
|
|
72
|
+
if (E)
|
|
73
|
+
return clearTimeout(h), h = setTimeout(v, i), $(r);
|
|
74
|
+
}
|
|
75
|
+
return h === void 0 && (h = setTimeout(v, i)), g;
|
|
76
|
+
}
|
|
77
|
+
return K.cancel = u, K.flush = H, K;
|
|
78
|
+
}
|
|
79
|
+
var _t = "Expected a function";
|
|
80
|
+
function le(e, i, f) {
|
|
81
|
+
var o = !0, s = !0;
|
|
82
|
+
if (typeof e != "function")
|
|
83
|
+
throw new TypeError(_t);
|
|
84
|
+
return ue(f) && (o = "leading" in f ? !!f.leading : o, s = "trailing" in f ? !!f.trailing : s), At(e, i, {
|
|
85
|
+
leading: o,
|
|
86
|
+
maxWait: i,
|
|
87
|
+
trailing: s
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const Pt = ["class", "style"], Mt = /^on[A-Z]/, Xt = (e = {}) => {
|
|
91
|
+
const { excludeListeners: i = !1, excludeKeys: f } = e, o = m(() => (f?.value || []).concat(Pt)), s = mt();
|
|
92
|
+
return s ? m(() => Ne(Object.entries(s.proxy?.$attrs).filter(([y]) => !o.value.includes(y) && !(i && Mt.test(y))))) : (We("use-attrs", "getCurrentInstance() returned null. useAttrs() must be called at the top of a setup function"), m(() => ({})));
|
|
93
|
+
}, Bt = Oe({
|
|
94
|
+
hideOnClickModal: Boolean,
|
|
95
|
+
src: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: ""
|
|
98
|
+
},
|
|
99
|
+
fit: {
|
|
100
|
+
type: String,
|
|
101
|
+
values: [
|
|
102
|
+
"",
|
|
103
|
+
"contain",
|
|
104
|
+
"cover",
|
|
105
|
+
"fill",
|
|
106
|
+
"none",
|
|
107
|
+
"scale-down"
|
|
108
|
+
],
|
|
109
|
+
default: ""
|
|
110
|
+
},
|
|
111
|
+
loading: {
|
|
112
|
+
type: String,
|
|
113
|
+
values: ["eager", "lazy"]
|
|
114
|
+
},
|
|
115
|
+
lazy: Boolean,
|
|
116
|
+
scrollContainer: { type: ne([String, Object]) },
|
|
117
|
+
previewSrcList: {
|
|
118
|
+
type: ne(Array),
|
|
119
|
+
default: () => $e([])
|
|
120
|
+
},
|
|
121
|
+
previewTeleported: Boolean,
|
|
122
|
+
zIndex: { type: Number },
|
|
123
|
+
initialIndex: {
|
|
124
|
+
type: Number,
|
|
125
|
+
default: 0
|
|
126
|
+
},
|
|
127
|
+
infinite: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: !0
|
|
130
|
+
},
|
|
131
|
+
closeOnPressEscape: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
default: !0
|
|
134
|
+
},
|
|
135
|
+
zoomRate: {
|
|
136
|
+
type: Number,
|
|
137
|
+
default: 1.2
|
|
138
|
+
},
|
|
139
|
+
scale: {
|
|
140
|
+
type: Number,
|
|
141
|
+
default: 1
|
|
142
|
+
},
|
|
143
|
+
minScale: {
|
|
144
|
+
type: Number,
|
|
145
|
+
default: 0.2
|
|
146
|
+
},
|
|
147
|
+
maxScale: {
|
|
148
|
+
type: Number,
|
|
149
|
+
default: 7
|
|
150
|
+
},
|
|
151
|
+
showProgress: Boolean,
|
|
152
|
+
crossorigin: { type: ne(String) }
|
|
153
|
+
}), Yt = {
|
|
154
|
+
load: (e) => e instanceof Event,
|
|
155
|
+
error: (e) => e instanceof Event,
|
|
156
|
+
switch: (e) => ke(e),
|
|
157
|
+
close: () => !0,
|
|
158
|
+
show: () => !0
|
|
159
|
+
}, Dt = Oe({
|
|
160
|
+
urlList: {
|
|
161
|
+
type: ne(Array),
|
|
162
|
+
default: () => $e([])
|
|
163
|
+
},
|
|
164
|
+
zIndex: { type: Number },
|
|
165
|
+
initialIndex: {
|
|
166
|
+
type: Number,
|
|
167
|
+
default: 0
|
|
168
|
+
},
|
|
169
|
+
infinite: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
default: !0
|
|
172
|
+
},
|
|
173
|
+
hideOnClickModal: Boolean,
|
|
174
|
+
teleported: Boolean,
|
|
175
|
+
closeOnPressEscape: {
|
|
176
|
+
type: Boolean,
|
|
177
|
+
default: !0
|
|
178
|
+
},
|
|
179
|
+
zoomRate: {
|
|
180
|
+
type: Number,
|
|
181
|
+
default: 1.2
|
|
182
|
+
},
|
|
183
|
+
scale: {
|
|
184
|
+
type: Number,
|
|
185
|
+
default: 1
|
|
186
|
+
},
|
|
187
|
+
minScale: {
|
|
188
|
+
type: Number,
|
|
189
|
+
default: 0.2
|
|
190
|
+
},
|
|
191
|
+
maxScale: {
|
|
192
|
+
type: Number,
|
|
193
|
+
default: 7
|
|
194
|
+
},
|
|
195
|
+
showProgress: Boolean,
|
|
196
|
+
crossorigin: { type: ne(String) }
|
|
197
|
+
}), Ft = {
|
|
198
|
+
close: () => !0,
|
|
199
|
+
error: (e) => e instanceof Event,
|
|
200
|
+
switch: (e) => ke(e),
|
|
201
|
+
rotate: (e) => ke(e)
|
|
202
|
+
}, Vt = ["src", "crossorigin"];
|
|
203
|
+
var Wt = /* @__PURE__ */ Ee({
|
|
204
|
+
name: "ElImageViewer",
|
|
205
|
+
__name: "image-viewer",
|
|
206
|
+
props: Dt,
|
|
207
|
+
emits: Ft,
|
|
208
|
+
setup(e, { expose: i, emit: f }) {
|
|
209
|
+
const o = {
|
|
210
|
+
CONTAIN: {
|
|
211
|
+
name: "contain",
|
|
212
|
+
icon: Le(Ke)
|
|
213
|
+
},
|
|
214
|
+
ORIGINAL: {
|
|
215
|
+
name: "original",
|
|
216
|
+
icon: Le(He)
|
|
217
|
+
}
|
|
218
|
+
}, s = e, y = f;
|
|
219
|
+
let g;
|
|
220
|
+
const { t: h } = Re(), r = Ae("image-viewer"), { nextZIndex: M } = je(), z = L(), E = L(), S = gt(), $ = m(() => {
|
|
221
|
+
const { scale: t, minScale: l, maxScale: d } = s;
|
|
222
|
+
return qe(t, l, d);
|
|
223
|
+
}), x = L(!0), T = L(!1), D = L(!1), v = L(s.initialIndex), X = pt(o.CONTAIN), u = L({
|
|
224
|
+
scale: $.value,
|
|
225
|
+
deg: 0,
|
|
226
|
+
offsetX: 0,
|
|
227
|
+
offsetY: 0,
|
|
228
|
+
enableTransition: !1
|
|
229
|
+
}), H = L(s.zIndex ?? M());
|
|
230
|
+
Ue(D, { ns: r });
|
|
231
|
+
const K = m(() => {
|
|
232
|
+
const { urlList: t } = s;
|
|
233
|
+
return t.length <= 1;
|
|
234
|
+
}), c = m(() => v.value === 0), w = m(() => v.value === s.urlList.length - 1), N = m(() => s.urlList[v.value]), G = m(() => [
|
|
235
|
+
r.e("btn"),
|
|
236
|
+
r.e("prev"),
|
|
237
|
+
r.is("disabled", !s.infinite && c.value)
|
|
238
|
+
]), fe = m(() => [
|
|
239
|
+
r.e("btn"),
|
|
240
|
+
r.e("next"),
|
|
241
|
+
r.is("disabled", !s.infinite && w.value)
|
|
242
|
+
]), ae = m(() => {
|
|
243
|
+
const { scale: t, deg: l, offsetX: d, offsetY: B, enableTransition: V } = u.value;
|
|
244
|
+
let A = d / t, _ = B / t;
|
|
245
|
+
const J = l * Math.PI / 180, U = Math.cos(J), ee = Math.sin(J);
|
|
246
|
+
A = A * U + _ * ee, _ = _ * U - d / t * ee;
|
|
247
|
+
const he = {
|
|
248
|
+
transform: `scale(${t}) rotate(${l}deg) translate(${A}px, ${_}px)`,
|
|
249
|
+
transition: V ? "transform .3s" : ""
|
|
250
|
+
};
|
|
251
|
+
return X.value.name === o.CONTAIN.name && (he.maxWidth = he.maxHeight = "100%"), he;
|
|
252
|
+
}), se = m(() => `${v.value + 1} / ${s.urlList.length}`);
|
|
253
|
+
function j() {
|
|
254
|
+
de(), g?.(), D.value = !1, y("close");
|
|
255
|
+
}
|
|
256
|
+
function re() {
|
|
257
|
+
const t = le((d) => {
|
|
258
|
+
switch (rt(d)) {
|
|
259
|
+
case Q.esc:
|
|
260
|
+
s.closeOnPressEscape && j();
|
|
261
|
+
break;
|
|
262
|
+
case Q.space:
|
|
263
|
+
me();
|
|
264
|
+
break;
|
|
265
|
+
case Q.left:
|
|
266
|
+
ge();
|
|
267
|
+
break;
|
|
268
|
+
case Q.up:
|
|
269
|
+
F("zoomIn");
|
|
270
|
+
break;
|
|
271
|
+
case Q.right:
|
|
272
|
+
pe();
|
|
273
|
+
break;
|
|
274
|
+
case Q.down:
|
|
275
|
+
F("zoomOut");
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}), l = le((d) => {
|
|
279
|
+
F((d.deltaY || d.deltaX) < 0 ? "zoomIn" : "zoomOut", {
|
|
280
|
+
zoomRate: s.zoomRate,
|
|
281
|
+
enableTransition: !1
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
S.run(() => {
|
|
285
|
+
Z(document, "keydown", t), Z(z, "wheel", l);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function de() {
|
|
289
|
+
S.stop();
|
|
290
|
+
}
|
|
291
|
+
function ve() {
|
|
292
|
+
x.value = !1;
|
|
293
|
+
}
|
|
294
|
+
function n(t) {
|
|
295
|
+
T.value = !0, x.value = !1, y("error", t), t.target.alt = h("el.image.error");
|
|
296
|
+
}
|
|
297
|
+
function q(t) {
|
|
298
|
+
if (x.value || t.button !== 0 || !z.value) return;
|
|
299
|
+
u.value.enableTransition = !1;
|
|
300
|
+
const { offsetX: l, offsetY: d } = u.value, B = t.pageX, V = t.pageY, A = le((U) => {
|
|
301
|
+
u.value = {
|
|
302
|
+
...u.value,
|
|
303
|
+
offsetX: l + U.pageX - B,
|
|
304
|
+
offsetY: d + U.pageY - V
|
|
305
|
+
};
|
|
306
|
+
}), _ = Z(document, "mousemove", A), J = Z(document, "mouseup", () => {
|
|
307
|
+
_(), J();
|
|
308
|
+
});
|
|
309
|
+
t.preventDefault();
|
|
310
|
+
}
|
|
311
|
+
function b(t) {
|
|
312
|
+
if (x.value || !z.value || t.touches.length !== 1) return;
|
|
313
|
+
u.value.enableTransition = !1;
|
|
314
|
+
const { offsetX: l, offsetY: d } = u.value, { pageX: B, pageY: V } = t.touches[0], A = le((U) => {
|
|
315
|
+
const ee = U.touches[0];
|
|
316
|
+
u.value = {
|
|
317
|
+
...u.value,
|
|
318
|
+
offsetX: l + ee.pageX - B,
|
|
319
|
+
offsetY: d + ee.pageY - V
|
|
320
|
+
};
|
|
321
|
+
}), _ = Z(document, "touchmove", A), J = Z(document, "touchend", () => {
|
|
322
|
+
_(), J();
|
|
323
|
+
});
|
|
324
|
+
t.preventDefault();
|
|
325
|
+
}
|
|
326
|
+
function xe() {
|
|
327
|
+
u.value = {
|
|
328
|
+
scale: $.value,
|
|
329
|
+
deg: 0,
|
|
330
|
+
offsetX: 0,
|
|
331
|
+
offsetY: 0,
|
|
332
|
+
enableTransition: !1
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function me() {
|
|
336
|
+
if (x.value || T.value) return;
|
|
337
|
+
const t = ot(o), l = Object.values(o), d = X.value.name;
|
|
338
|
+
X.value = o[t[(l.findIndex((B) => B.name === d) + 1) % t.length]], xe();
|
|
339
|
+
}
|
|
340
|
+
function oe(t) {
|
|
341
|
+
T.value = !1;
|
|
342
|
+
const l = s.urlList.length;
|
|
343
|
+
v.value = (t + l) % l;
|
|
344
|
+
}
|
|
345
|
+
function ge() {
|
|
346
|
+
c.value && !s.infinite || oe(v.value - 1);
|
|
347
|
+
}
|
|
348
|
+
function pe() {
|
|
349
|
+
w.value && !s.infinite || oe(v.value + 1);
|
|
350
|
+
}
|
|
351
|
+
function F(t, l = {}) {
|
|
352
|
+
if (x.value || T.value) return;
|
|
353
|
+
const { minScale: d, maxScale: B } = s, { zoomRate: V, rotateDeg: A, enableTransition: _ } = {
|
|
354
|
+
zoomRate: s.zoomRate,
|
|
355
|
+
rotateDeg: 90,
|
|
356
|
+
enableTransition: !0,
|
|
357
|
+
...l
|
|
358
|
+
};
|
|
359
|
+
switch (t) {
|
|
360
|
+
case "zoomOut":
|
|
361
|
+
u.value.scale > d && (u.value.scale = Number.parseFloat((u.value.scale / V).toFixed(3)));
|
|
362
|
+
break;
|
|
363
|
+
case "zoomIn":
|
|
364
|
+
u.value.scale < B && (u.value.scale = Number.parseFloat((u.value.scale * V).toFixed(3)));
|
|
365
|
+
break;
|
|
366
|
+
case "clockwise":
|
|
367
|
+
u.value.deg += A, y("rotate", u.value.deg);
|
|
368
|
+
break;
|
|
369
|
+
case "anticlockwise":
|
|
370
|
+
u.value.deg -= A, y("rotate", u.value.deg);
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
u.value.enableTransition = _;
|
|
374
|
+
}
|
|
375
|
+
function Be(t) {
|
|
376
|
+
t.detail?.focusReason === "pointer" && t.preventDefault();
|
|
377
|
+
}
|
|
378
|
+
function Ye() {
|
|
379
|
+
s.closeOnPressEscape && j();
|
|
380
|
+
}
|
|
381
|
+
function De(t) {
|
|
382
|
+
if (t.ctrlKey) {
|
|
383
|
+
if (t.deltaY < 0)
|
|
384
|
+
return t.preventDefault(), !1;
|
|
385
|
+
if (t.deltaY > 0)
|
|
386
|
+
return t.preventDefault(), !1;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return ie(() => $.value, (t) => {
|
|
390
|
+
u.value.scale = t;
|
|
391
|
+
}), ie(N, () => {
|
|
392
|
+
Pe(() => {
|
|
393
|
+
E.value?.complete || (x.value = !0);
|
|
394
|
+
});
|
|
395
|
+
}), ie(v, (t) => {
|
|
396
|
+
xe(), y("switch", t);
|
|
397
|
+
}), Me(() => {
|
|
398
|
+
D.value = !0, re(), g = Z("wheel", De, { passive: !1 });
|
|
399
|
+
}), i({ setActiveItem: oe }), (t, l) => (C(), ce(a(Ze), {
|
|
400
|
+
to: "body",
|
|
401
|
+
disabled: !e.teleported
|
|
402
|
+
}, {
|
|
403
|
+
default: I(() => [p(ht, {
|
|
404
|
+
name: "viewer-fade",
|
|
405
|
+
appear: ""
|
|
406
|
+
}, {
|
|
407
|
+
default: I(() => [O("div", {
|
|
408
|
+
ref_key: "wrapper",
|
|
409
|
+
ref: z,
|
|
410
|
+
tabindex: -1,
|
|
411
|
+
class: k(a(r).e("wrapper")),
|
|
412
|
+
style: Se({ zIndex: H.value })
|
|
413
|
+
}, [p(a(Ge), {
|
|
414
|
+
loop: "",
|
|
415
|
+
trapped: "",
|
|
416
|
+
"focus-trap-el": z.value,
|
|
417
|
+
"focus-start-el": "container",
|
|
418
|
+
onFocusoutPrevented: Be,
|
|
419
|
+
onReleaseRequested: Ye
|
|
420
|
+
}, {
|
|
421
|
+
default: I(() => [
|
|
422
|
+
O("div", {
|
|
423
|
+
class: k(a(r).e("mask")),
|
|
424
|
+
onClick: l[0] || (l[0] = yt((d) => e.hideOnClickModal && j(), ["self"]))
|
|
425
|
+
}, null, 2),
|
|
426
|
+
R(" CLOSE "),
|
|
427
|
+
O("span", {
|
|
428
|
+
class: k([a(r).e("btn"), a(r).e("close")]),
|
|
429
|
+
onClick: j
|
|
430
|
+
}, [p(a(W), null, {
|
|
431
|
+
default: I(() => [p(a(Je))]),
|
|
432
|
+
_: 1
|
|
433
|
+
})], 2),
|
|
434
|
+
R(" ARROW "),
|
|
435
|
+
K.value ? R("v-if", !0) : (C(), Y(Ie, { key: 0 }, [O("span", {
|
|
436
|
+
class: k(G.value),
|
|
437
|
+
onClick: ge
|
|
438
|
+
}, [p(a(W), null, {
|
|
439
|
+
default: I(() => [p(a(Qe))]),
|
|
440
|
+
_: 1
|
|
441
|
+
})], 2), O("span", {
|
|
442
|
+
class: k(fe.value),
|
|
443
|
+
onClick: pe
|
|
444
|
+
}, [p(a(W), null, {
|
|
445
|
+
default: I(() => [p(a(et))]),
|
|
446
|
+
_: 1
|
|
447
|
+
})], 2)], 64)),
|
|
448
|
+
t.$slots.progress || e.showProgress ? (C(), Y("div", {
|
|
449
|
+
key: 1,
|
|
450
|
+
class: k([a(r).e("btn"), a(r).e("progress")])
|
|
451
|
+
}, [P(t.$slots, "progress", {
|
|
452
|
+
activeIndex: v.value,
|
|
453
|
+
total: e.urlList.length
|
|
454
|
+
}, () => [wt(Xe(se.value), 1)])], 2)) : R("v-if", !0),
|
|
455
|
+
R(" ACTIONS "),
|
|
456
|
+
O("div", { class: k([a(r).e("btn"), a(r).e("actions")]) }, [O("div", { class: k(a(r).e("actions__inner")) }, [P(t.$slots, "toolbar", {
|
|
457
|
+
actions: F,
|
|
458
|
+
prev: ge,
|
|
459
|
+
next: pe,
|
|
460
|
+
reset: me,
|
|
461
|
+
activeIndex: v.value,
|
|
462
|
+
setActiveItem: oe
|
|
463
|
+
}, () => [
|
|
464
|
+
p(a(W), { onClick: l[1] || (l[1] = (d) => F("zoomOut")) }, {
|
|
465
|
+
default: I(() => [p(a(tt))]),
|
|
466
|
+
_: 1
|
|
467
|
+
}),
|
|
468
|
+
p(a(W), { onClick: l[2] || (l[2] = (d) => F("zoomIn")) }, {
|
|
469
|
+
default: I(() => [p(a(nt))]),
|
|
470
|
+
_: 1
|
|
471
|
+
}),
|
|
472
|
+
O("i", { class: k(a(r).e("actions__divider")) }, null, 2),
|
|
473
|
+
p(a(W), { onClick: me }, {
|
|
474
|
+
default: I(() => [(C(), ce(bt(X.value.icon)))]),
|
|
475
|
+
_: 1
|
|
476
|
+
}),
|
|
477
|
+
O("i", { class: k(a(r).e("actions__divider")) }, null, 2),
|
|
478
|
+
p(a(W), { onClick: l[3] || (l[3] = (d) => F("anticlockwise")) }, {
|
|
479
|
+
default: I(() => [p(a(at))]),
|
|
480
|
+
_: 1
|
|
481
|
+
}),
|
|
482
|
+
p(a(W), { onClick: l[4] || (l[4] = (d) => F("clockwise")) }, {
|
|
483
|
+
default: I(() => [p(a(st))]),
|
|
484
|
+
_: 1
|
|
485
|
+
})
|
|
486
|
+
])], 2)], 2),
|
|
487
|
+
R(" CANVAS "),
|
|
488
|
+
O("div", { class: k(a(r).e("canvas")) }, [T.value && t.$slots["viewer-error"] ? P(t.$slots, "viewer-error", {
|
|
489
|
+
key: 0,
|
|
490
|
+
activeIndex: v.value,
|
|
491
|
+
src: N.value
|
|
492
|
+
}) : (C(), Y("img", {
|
|
493
|
+
ref_key: "imgRef",
|
|
494
|
+
ref: E,
|
|
495
|
+
key: N.value,
|
|
496
|
+
src: N.value,
|
|
497
|
+
style: Se(ae.value),
|
|
498
|
+
class: k(a(r).e("img")),
|
|
499
|
+
crossorigin: e.crossorigin,
|
|
500
|
+
onLoad: ve,
|
|
501
|
+
onError: n,
|
|
502
|
+
onMousedown: q,
|
|
503
|
+
onTouchstart: b
|
|
504
|
+
}, null, 46, Vt))], 2),
|
|
505
|
+
P(t.$slots, "default")
|
|
506
|
+
]),
|
|
507
|
+
_: 3
|
|
508
|
+
}, 8, ["focus-trap-el"])], 6)]),
|
|
509
|
+
_: 3
|
|
510
|
+
})]),
|
|
511
|
+
_: 3
|
|
512
|
+
}, 8, ["disabled"]));
|
|
513
|
+
}
|
|
514
|
+
}), Ht = Wt;
|
|
515
|
+
const Kt = _e(Ht), jt = [
|
|
516
|
+
"src",
|
|
517
|
+
"loading",
|
|
518
|
+
"crossorigin"
|
|
519
|
+
], qt = { key: 0 };
|
|
520
|
+
var Ut = /* @__PURE__ */ Ee({
|
|
521
|
+
name: "ElImage",
|
|
522
|
+
inheritAttrs: !1,
|
|
523
|
+
__name: "image",
|
|
524
|
+
props: Bt,
|
|
525
|
+
emits: Yt,
|
|
526
|
+
setup(e, { expose: i, emit: f }) {
|
|
527
|
+
const o = e, s = f, { t: y } = Re(), g = Ae("image"), h = kt(), r = m(() => Ne(Object.entries(h).filter(([n]) => /^(data-|on[A-Z])/i.test(n) || ["id", "style"].includes(n)))), M = Xt({
|
|
528
|
+
excludeListeners: !0,
|
|
529
|
+
excludeKeys: m(() => Object.keys(r.value))
|
|
530
|
+
}), z = L(), E = L(!1), S = L(!0), $ = L(!1), x = L(), T = L(), D = te && "loading" in HTMLImageElement.prototype;
|
|
531
|
+
let v;
|
|
532
|
+
const X = m(() => [
|
|
533
|
+
g.e("inner"),
|
|
534
|
+
H.value && g.e("preview"),
|
|
535
|
+
S.value && g.is("loading")
|
|
536
|
+
]), u = m(() => {
|
|
537
|
+
const { fit: n } = o;
|
|
538
|
+
return te && n ? { objectFit: n } : {};
|
|
539
|
+
}), H = m(() => {
|
|
540
|
+
const { previewSrcList: n } = o;
|
|
541
|
+
return lt(n) && n.length > 0;
|
|
542
|
+
}), K = m(() => {
|
|
543
|
+
const { previewSrcList: n, initialIndex: q } = o;
|
|
544
|
+
let b = q;
|
|
545
|
+
return q > n.length - 1 && (b = 0), b;
|
|
546
|
+
}), c = m(() => o.loading === "eager" ? !1 : !D && o.loading === "lazy" || o.lazy), w = () => {
|
|
547
|
+
te && (S.value = !0, E.value = !1, z.value = o.src);
|
|
548
|
+
};
|
|
549
|
+
function N(n) {
|
|
550
|
+
S.value = !1, E.value = !1, s("load", n);
|
|
551
|
+
}
|
|
552
|
+
function G(n) {
|
|
553
|
+
S.value = !1, E.value = !0, s("error", n);
|
|
554
|
+
}
|
|
555
|
+
function fe(n) {
|
|
556
|
+
n && (w(), j());
|
|
557
|
+
}
|
|
558
|
+
const ae = it(fe, 200, !0);
|
|
559
|
+
async function se() {
|
|
560
|
+
if (!te) return;
|
|
561
|
+
await Pe();
|
|
562
|
+
const { scrollContainer: n } = o;
|
|
563
|
+
if (ut(n)) T.value = n;
|
|
564
|
+
else if (ct(n) && n !== "") T.value = document.querySelector(n) ?? void 0;
|
|
565
|
+
else if (x.value) {
|
|
566
|
+
const b = ft(x.value);
|
|
567
|
+
T.value = dt(b) ? void 0 : b;
|
|
568
|
+
}
|
|
569
|
+
const { stop: q } = vt(x, ([b]) => {
|
|
570
|
+
ae(b.isIntersecting);
|
|
571
|
+
}, { root: T });
|
|
572
|
+
v = q;
|
|
573
|
+
}
|
|
574
|
+
function j() {
|
|
575
|
+
!te || !ae || (v?.(), T.value = void 0, v = void 0);
|
|
576
|
+
}
|
|
577
|
+
function re() {
|
|
578
|
+
H.value && ($.value = !0, s("show"));
|
|
579
|
+
}
|
|
580
|
+
function de() {
|
|
581
|
+
$.value = !1, s("close");
|
|
582
|
+
}
|
|
583
|
+
function ve(n) {
|
|
584
|
+
s("switch", n);
|
|
585
|
+
}
|
|
586
|
+
return ie(() => o.src, () => {
|
|
587
|
+
c.value ? (S.value = !0, E.value = !1, j(), se()) : w();
|
|
588
|
+
}), Me(() => {
|
|
589
|
+
c.value ? se() : w();
|
|
590
|
+
}), i({ showPreview: re }), (n, q) => (C(), Y("div", Te({
|
|
591
|
+
ref_key: "container",
|
|
592
|
+
ref: x
|
|
593
|
+
}, r.value, { class: [a(g).b(), n.$attrs.class] }), [E.value ? P(n.$slots, "error", { key: 0 }, () => [O("div", { class: k(a(g).e("error")) }, Xe(a(y)("el.image.error")), 3)]) : (C(), Y(Ie, { key: 1 }, [z.value !== void 0 ? (C(), Y("img", Te({ key: 0 }, a(M), {
|
|
594
|
+
src: z.value,
|
|
595
|
+
loading: e.loading,
|
|
596
|
+
style: u.value,
|
|
597
|
+
class: X.value,
|
|
598
|
+
crossorigin: e.crossorigin,
|
|
599
|
+
onClick: re,
|
|
600
|
+
onLoad: N,
|
|
601
|
+
onError: G
|
|
602
|
+
}), null, 16, jt)) : R("v-if", !0), S.value ? (C(), Y("div", {
|
|
603
|
+
key: 1,
|
|
604
|
+
class: k(a(g).e("wrapper"))
|
|
605
|
+
}, [P(n.$slots, "placeholder", {}, () => [O("div", { class: k(a(g).e("placeholder")) }, null, 2)])], 2)) : R("v-if", !0)], 64)), H.value ? (C(), Y(Ie, { key: 2 }, [$.value ? (C(), ce(a(Kt), {
|
|
606
|
+
key: 0,
|
|
607
|
+
"z-index": e.zIndex,
|
|
608
|
+
"initial-index": K.value,
|
|
609
|
+
infinite: e.infinite,
|
|
610
|
+
"zoom-rate": e.zoomRate,
|
|
611
|
+
"min-scale": e.minScale,
|
|
612
|
+
"max-scale": e.maxScale,
|
|
613
|
+
"show-progress": e.showProgress,
|
|
614
|
+
"url-list": e.previewSrcList,
|
|
615
|
+
scale: e.scale,
|
|
616
|
+
crossorigin: e.crossorigin,
|
|
617
|
+
"hide-on-click-modal": e.hideOnClickModal,
|
|
618
|
+
teleported: e.previewTeleported,
|
|
619
|
+
"close-on-press-escape": e.closeOnPressEscape,
|
|
620
|
+
onClose: de,
|
|
621
|
+
onSwitch: ve
|
|
622
|
+
}, It({
|
|
623
|
+
toolbar: I((b) => [P(n.$slots, "toolbar", ye(we(b)))]),
|
|
624
|
+
default: I(() => [n.$slots.viewer ? (C(), Y("div", qt, [P(n.$slots, "viewer")])) : R("v-if", !0)]),
|
|
625
|
+
_: 2
|
|
626
|
+
}, [n.$slots.progress ? {
|
|
627
|
+
name: "progress",
|
|
628
|
+
fn: I((b) => [P(n.$slots, "progress", ye(we(b)))]),
|
|
629
|
+
key: "0"
|
|
630
|
+
} : void 0, n.$slots["viewer-error"] ? {
|
|
631
|
+
name: "viewer-error",
|
|
632
|
+
fn: I((b) => [P(n.$slots, "viewer-error", ye(we(b)))]),
|
|
633
|
+
key: "1"
|
|
634
|
+
} : void 0]), 1032, [
|
|
635
|
+
"z-index",
|
|
636
|
+
"initial-index",
|
|
637
|
+
"infinite",
|
|
638
|
+
"zoom-rate",
|
|
639
|
+
"min-scale",
|
|
640
|
+
"max-scale",
|
|
641
|
+
"show-progress",
|
|
642
|
+
"url-list",
|
|
643
|
+
"scale",
|
|
644
|
+
"crossorigin",
|
|
645
|
+
"hide-on-click-modal",
|
|
646
|
+
"teleported",
|
|
647
|
+
"close-on-press-escape"
|
|
648
|
+
])) : R("v-if", !0)], 64)) : R("v-if", !0)], 16));
|
|
649
|
+
}
|
|
650
|
+
}), Zt = Ut;
|
|
651
|
+
const Gt = _e(Zt), en = /* @__PURE__ */ Ee({
|
|
652
|
+
name: "ImagePreview",
|
|
653
|
+
__name: "ImagePreview",
|
|
654
|
+
props: {
|
|
655
|
+
url: {}
|
|
656
|
+
},
|
|
657
|
+
setup(e) {
|
|
658
|
+
return (i, f) => {
|
|
659
|
+
const o = Gt;
|
|
660
|
+
return C(), ce(o, {
|
|
661
|
+
src: e.url,
|
|
662
|
+
fit: "contain",
|
|
663
|
+
class: "w-full h-full"
|
|
664
|
+
}, null, 8, ["src"]);
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
export {
|
|
669
|
+
en as default
|
|
670
|
+
};
|