@gx-design-vue/image 0.2.0-beta.31 → 0.2.0-beta.32

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.
@@ -1,12 +1,12 @@
1
1
  /*!
2
2
  * Gx Design Pro
3
- * Version: 0.2.0-beta.30
3
+ * Version: 0.2.0-beta.31
4
4
  * Author: gx12358
5
5
  * Copyright (C) 2024 gx12358
6
6
  * License: MIT License
7
7
  * Description: Gx Design Image
8
- * Date Created: 2025-08-15
8
+ * Date Created: 2025-08-17
9
9
  * Homepage:
10
10
  * Contact: gx12358@gmail.com
11
11
  */
12
- (function(b,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@ant-design/icons-vue"),require("@gx-design-vue/pro-provider"),require("@gx-design-vue/pro-utils"),require("@vueuse/core"),require("lodash-es"),require("@gx-design-vue/pro-hooks"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","vue","@ant-design/icons-vue","@gx-design-vue/pro-provider","@gx-design-vue/pro-utils","@vueuse/core","lodash-es","@gx-design-vue/pro-hooks","@ctrl/tinycolor"],t):(b=typeof globalThis<"u"?globalThis:b||self,t(b.GImage={},b.vue,b.iconsVue,b.proProvider,b.proUtils,b.core,b.lodashEs,b.proHooks,b.tinycolor))})(this,(function(b,t,O,L,f,A,U,P,B){"use strict";const H={infinite:{type:Boolean,default:!0},zIndex:{type:Number,default:2e3},current:{type:Number,default:0},getContainer:{type:String}},le={preview:{type:[Object,Boolean],default:!0},src:{type:String,default:""},alt:{type:String,default:""},loading:{type:String},fit:{type:String,default:"contain"},crossOrigin:{type:String},lazy:Boolean,scrollContainer:{type:[String,Object]},placeholder:{type:[Function,Object,Boolean],default:()=>{}},fallback:{type:[Function,Object],default:()=>{}},onLoad:{type:Function},onError:{type:Function},onClick:{type:Function},imageStyle:{type:Object,default:()=>({})},imageClass:String,size:Number,width:Number,height:Number,zIndex:H.zIndex,getContainer:H.getContainer},_={urls:{type:Array,default:()=>[]},open:{type:Boolean,default:!1},scaleStep:{type:Number,default:.5},minScale:{type:Number,default:.32},maxScale:{type:Number,default:32},movable:{type:Boolean,default:!0},disabled:Boolean,zIndex:H.zIndex,current:H.current,infinite:H.infinite,getContainer:le.getContainer,onHideOnClickModal:{type:Boolean,default:!0},countRender:[Function,Array,Object],icons:{type:Object,default:()=>({})},onTransform:Function,onOpenChange:Function,"onUpdate:open":Function};let ge=e=>setTimeout(e,16),me=e=>clearTimeout(e);typeof window<"u"&&"requestAnimationFrame"in window&&(ge=e=>window.requestAnimationFrame(e),me=e=>window.cancelAnimationFrame(e));let ve=0;const re=new Map;function he(e){re.delete(e)}function we(e,n=1){ve+=1;const i=ve;function a(o){if(o===0)he(i),e();else{const s=ge(()=>{a(o-1)});re.set(i,s)}}return a(n),i}we.cancel=e=>{const n=re.get(e);return he(n),me(n)};const ne={x:0,y:0,rotate:0,scale:1,flipX:!1,flipY:!1};function Me(e,n,i,a){const o=t.ref(null),s=t.ref([]),[u,p]=P.useState(ne),m=h=>{p(ne),U.isEqual(ne,u.value)||a?.({transform:ne,action:h})},d=(h,x)=>{o.value===null&&(s.value=[],o.value=we(()=>{let I=U.cloneDeep(u.value);s.value.forEach(l=>{I={...I,...l}}),o.value=null,a?.({transform:I,action:x}),p(I)})),s.value.push({...u.value,...h})};return{transform:u,resetTransform:m,updateTransform:d,dispatchZoomChange:(h,x,I,l,r)=>{const{width:y,height:w,offsetWidth:S,offsetHeight:C,offsetLeft:M,offsetTop:E}=e.value;let T=h,N=u.value.scale*h;N>i.value?(N=i.value,T=i.value/u.value.scale):N<n.value&&(N=r?N:n.value,T=N/u.value.scale);const k=I??innerWidth/2,Q=l??innerHeight/2,X=T-1,$=X*y*.5,j=X*w*.5,F=X*(k-u.value.x-M),J=X*(Q-u.value.y-E);let W=u.value.x-(F-$),Z=u.value.y-(J-j);if(h<1&&N===1){const R=S*N,g=C*N,{width:Y,height:D}=A.useWindowSize();R<=Y.value&&g<=D.value&&(W=0,Z=0)}d({x:W,y:Z,scale:N},x)}}}function Te(e,n){process.env.NODE_ENV!=="production"&&console!==void 0&&console.error(`Warning: ${n}`)}let pe=!1;try{const e=Object.defineProperty({},"passive",{get(){pe=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch{}function G(e,n,i,a){if(e&&e.addEventListener){let o=a;o===void 0&&pe&&(n==="touchstart"||n==="touchmove"||n==="wheel")&&(o={passive:!1}),e.addEventListener(n,i,o)}return{remove:()=>{e&&e.removeEventListener&&e.removeEventListener(n,i)}}}const q=1,$e=1;function ye(e,n,i,a){const o=n+i,s=(i-a)/2;if(i>a){if(n>0)return{[e]:s};if(n<0&&o<a)return{[e]:-s}}else if(n<0||o>a)return{[e]:n<0?s:-s};return{}}function Se(e,n,i,a){const{width:o,height:s}=A.useWindowSize();let u=null;return e<=o.value&&n<=s.value?u={x:0,y:0}:(e>o.value||n>s.value)&&(u={...ye("x",i,e,o.value),...ye("y",a,n,s.value)}),u}function ze(e,n,i,a,o,s,u){const[p,m]=P.useState(!1),d=t.ref({diffX:0,diffY:0,transformX:0,transformY:0}),v=l=>{!n||l.button!==0||(l.preventDefault(),l.stopPropagation(),d.value={diffX:l.pageX-o.value.x,diffY:l.pageY-o.value.y,transformX:o.value.x,transformY:o.value.y},m(!0))},h=l=>{i&&p.value&&s({x:l.pageX-d.value.diffX,y:l.pageY-d.value.diffY},"move")},x=()=>{if(i&&p.value){m(!1);const{transformX:l,transformY:r}=d.value;if(!(o.value.x!==l&&o.value.y!==r))return;const w=e.value.offsetWidth*o.value.scale,S=e.value.offsetHeight*o.value.scale,{left:C,top:M}=e.value.getBoundingClientRect(),E=o.value.rotate%180!==0,T=Se(E?S:w,E?w:S,C,M);T&&s({...T},"dragRebound")}},I=l=>{if(!i||l.deltaY===0)return;const r=Math.abs(l.deltaY/100),y=Math.min(r,$e);let w=q+y*a.value;l.deltaY>0&&(w=q/w),u(w,"wheel",l.clientX,l.clientY)};return P.useEffect(()=>{let l,r,y,w;if(n){y=G(window,"mouseup",x,!1),w=G(window,"mousemove",h,!1);try{window.top!==window.self&&(l=G(window.top,"mouseup",x,!1),r=G(window.top,"mousemove",h,!1))}catch(S){Te(!1,`[rc-image] ${S}`)}}return()=>{y?.remove(),w?.remove(),l?.remove(),r?.remove()}},[i,p,()=>o.value.x,()=>o.value.y,()=>o.value.rotate,n]),{isMoving:p,onMouseDown:v,onMouseMove:h,onMouseUp:x,onWheel:I}}function oe(e,n){const i=e.x-n.x,a=e.y-n.y;return Math.hypot(i,a)}function Oe(e,n,i,a){const o=oe(e,i),s=oe(n,a);if(o===0&&s===0)return[e.x,e.y];const u=o/(o+s),p=e.x+u*(n.x-e.x),m=e.y+u*(n.y-e.y);return[p,m]}function Ae(e,n,i,a,o,s,u){const[p,m]=P.useState(!1),d=t.ref({point1:{x:0,y:0},point2:{x:0,y:0},eventType:"none"}),v=l=>{d.value={...d.value,...l}},h=l=>{if(!n.value)return;l.stopPropagation(),m(!0);const{touches:r=[]}=l;r.length>1?v({point1:{x:r[0].clientX,y:r[0].clientY},point2:{x:r[1].clientX,y:r[1].clientY},eventType:"touchZoom"}):v({point1:{x:r[0].clientX-o.value.x,y:r[0].clientY-o.value.y},eventType:"move"})},x=l=>{const{touches:r=[]}=l,{point1:y,point2:w,eventType:S}=d.value;if(r.length>1&&S==="touchZoom"){const C={x:r[0].clientX,y:r[0].clientY},M={x:r[1].clientX,y:r[1].clientY},[E,T]=Oe(y,w,C,M),N=oe(C,M)/oe(y,w);u(N,"touchZoom",E,T,!0),v({point1:C,point2:M,eventType:"touchZoom"})}else S==="move"&&(s({x:r[0].clientX-y.x,y:r[0].clientY-y.y},"move"),v({eventType:"move"}))},I=()=>{if(!i.value)return;if(p&&m(!1),v({eventType:"none"}),a.value>o.value.scale)return s({x:0,y:0,scale:a.value},"touchZoom");const l=e.value.offsetWidth*o.value.scale,r=e.value.offsetHeight*o.value.scale,{left:y,top:w}=e.value.getBoundingClientRect(),S=o.value.rotate%180!==0,C=Se(S?r:l,S?l:r,y,w);C&&s({...C},"dragRebound")};return P.useEffect(()=>{let l;return i.value&&n.value&&(l=G(window,"touchmove",r=>r.preventDefault(),{passive:!1})),()=>{l?.remove()}},[i,n]),{isTouching:p,onTouchStart:h,onTouchMove:x,onTouchEnd:I}}const Ee=t.defineComponent({name:"Operations",inheritAttrs:!1,props:{open:Boolean,count:{type:Number,default:0},current:{type:Number,default:0},showSwitch:Boolean,showProgress:Boolean,prefixCls:String,hashId:String,zIndex:_.zIndex,icons:_.icons,infinite:_.infinite,getContainer:_.getContainer,countRender:_.countRender,tools:Array,onClose:Function,onActive:Function},setup(e){const n=(i,a)=>{i.preventDefault(),i.stopPropagation(),e.onActive?.(a)};return()=>{const{prefixCls:i,hashId:a,tools:o}=e,s=L.getTransitionProps(`${e.prefixCls}-fade`),u=`${i}-operations-operation`,p=`${i}-operations-icon`;return t.createVNode(t.Teleport,{to:e.getContainer||"body"},{default:()=>[t.createVNode(t.Transition,s,{default:()=>[t.withDirectives(t.createVNode("div",{class:f.classNames(`${i}-operations-wrapper`,a),style:{zIndex:e.zIndex}},[e.icons?.close===null?null:t.createVNode("button",{class:`${i}-close ${a}`,onClick:e.onClose},[e.icons?.close||t.createVNode(O.CloseOutlined,null,null)]),e.showSwitch&&t.createVNode(t.Fragment,null,[t.createVNode("div",{class:f.classNames(`${i}-switch-left ${a}`,{[`${i}-switch-left-disabled`]:e.infinite?!1:e.current===0}),onClick:m=>n(m,-1)},[e.icons?.left||t.createVNode(O.LeftOutlined,null,null)]),t.createVNode("div",{class:f.classNames(`${i}-switch-right ${a}`,{[`${i}-switch-right-disabled`]:e.infinite?!1:e.current===e.count-1}),onClick:m=>n(m,1)},[e.icons?.right||t.createVNode(O.RightOutlined,null,null)])]),t.createVNode("div",{class:`${i}-footer ${a}`},[e.showProgress&&t.createVNode("div",{class:`${i}-progress`},[e.countRender?e.countRender(e.current+1,e.count):`${e.current+1} / ${e.count}`]),t.createVNode("div",{class:`${e.prefixCls}-operations`},[o?.map(({icon:m,onClick:d,type:v,disabled:h})=>t.createVNode("div",{class:f.classNames(u,{[`${e.prefixCls}-operations-operation-disabled`]:h&&h?.value}),onClick:d,key:v},[t.cloneVNode(m,{class:p})]))])])]),[[t.vShow,e.open]])]})]})}}}),Re=new L.Keyframe("viewFadeIn",{"0%":{opacity:0},"100%":{opacity:1}}),De=new L.Keyframe("viewFadeOut",{"0%":{opacity:1},"100%":{opacity:0}}),Ve=new L.Keyframe("viewZoomBadgeIn",{"0%":{transform:"scale(0)",opacity:0},"100%":{transform:"scale(1)",opacity:1}}),Pe=new L.Keyframe("viewZoomBadgeOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0)",opacity:0}}),Ce=e=>({position:e||"absolute",inset:0});function se(e){return{position:e,top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0}}const Xe=e=>{const{previewCls:n,modalMaskBg:i,marginXL:a,margin:o,colorTextLightSolid:s,previewOperationColorDisabled:u,previewOperationHoverColor:p,motionDurationSlow:m,iconCls:d}=e,v=new B.TinyColor(i).setAlpha(.1),h=v.clone().setAlpha(.2),x=new B.TinyColor(i).setAlpha(.5),I=new B.TinyColor(i).setAlpha(.03);return{[`${n}-footer`]:{position:"fixed",bottom:a,left:{_skip_check_:!0,value:"50%"},display:"flex",flexDirection:"column",alignItems:"center",color:e.previewOperationColor,transform:"translateX(-50%)"},[`${n}-progress`]:{marginBottom:o},[`${n}-close`]:{position:"fixed",top:a,right:{_skip_check_:!0,value:a},display:"flex",alignItems:"center",justifyContent:"center",color:s,backgroundColor:v.toRgbString(),borderRadius:e.borderRadiusLG,backdropFilter:"saturate(180%) blur(10px)",width:e.sizeXL,height:e.sizeXL,outline:0,border:0,cursor:"pointer",transition:`all ${m}`,"&:hover":{backgroundColor:h.toRgbString()},[`& > ${d}`]:{fontSize:e.previewOperationSize}},[`${n}-operations`]:{display:"flex",alignItems:"center",gap:e.sizeXXS,padding:e.paddingXXS,border:`1px solid ${e.colorBorderSecondary}`,backgroundColor:x.toRgbString(),borderRadius:e.borderRadiusLG,backdropFilter:"saturate(150%) blur(10px)","&-operation":{display:"flex",alignItems:"center",justifyContent:"center",width:e.sizeXL+4,height:e.sizeXL+4,cursor:"pointer",color:s,borderRadius:e.borderRadiusSM,transition:`all ${m}`,userSelect:"none",[`&:not(${n}-operations-operation-disabled):hover > ${d}`]:{color:p},"&:hover":{backgroundColor:I.toRgbString()},"&-disabled":{color:u,cursor:"not-allowed"},"&:first-of-type":{marginInlineStart:0},[`& > ${d}`]:{fontSize:e.previewOperationSize}}}}},je=e=>{const{modalMaskBg:n,iconCls:i,previewOperationColorDisabled:a,previewCls:o,zIndexPopup:s,motionDurationSlow:u,colorTextLightSolid:p}=e,m=new B.TinyColor(n).setAlpha(.1),d=m.clone().setAlpha(.2);return{[`${o}-switch-left, ${o}-switch-right`]:{position:"fixed",insetBlockStart:"50%",zIndex:e.calc(s).add(1).equal(),display:"flex",alignItems:"center",justifyContent:"center",borderRadius:e.borderRadius,backdropFilter:"saturate(180%) blur(10px)",width:e.imagePreviewSwitchSize,height:e.imagePreviewSwitchSize,marginTop:e.calc(e.imagePreviewSwitchSize).mul(-1).div(2).equal(),color:p,background:m.toRgbString(),transform:"translateY(-50%)",cursor:"pointer",transition:`all ${u}`,userSelect:"none","&:hover":{background:d.toRgbString()},"&-disabled":{"&, &:hover":{color:a,background:"transparent",cursor:"not-allowed",[`> ${i}`]:{cursor:"not-allowed"}}},[`> ${i}`]:{fontSize:e.previewOperationSize}},[`${o}-switch-left`]:{insetInlineStart:e.marginSM},[`${o}-switch-right`]:{insetInlineEnd:e.marginSM}}},Ye=e=>{const{motionEaseOut:n,motionDurationSlow:i}=e;return{[e.componentCls]:{height:"100%",textAlign:"center",pointerEvents:"none","&-root":{...se("fixed"),zIndex:e.zIndexPopup,overflow:"auto",outline:0,WebkitOverflowScrolling:"touch"},"&-wrap":{...se("fixed"),zIndex:e.zIndexPopup,overflow:"auto",outline:0,WebkitOverflowScrolling:"touch"},"&-mask":{...se("fixed"),zIndex:e.zIndexPopupBase,height:"100%",backgroundColor:e.colorBgMask,backdropFilter:"blur(8px)"},"&-body":{...Ce(),overflow:"hidden"},"&-img":{maxWidth:"100%",maxHeight:"70%",verticalAlign:"middle",transform:"scale3d(1, 1, 1)",cursor:"grab",transition:`transform ${i} ${n} 0s`,userSelect:"none","&-wrapper":{...Ce(),transition:`transform ${i} ${n} 0s`,display:"flex",justifyContent:"center",alignItems:"center","& > *":{pointerEvents:"auto"},"&::before":{display:"inline-block",width:1,height:"50%",marginInlineEnd:-1,content:'""'}}},"&-moving":{[`${e.componentCls}-view-img`]:{cursor:"grabbing","&-wrapper":{transitionDuration:"0s"}}},"&-mask-zoom-appear, &-mask-zoom-enter":{animationName:Re,animationDuration:e.motionDurationSlow,animationTimingFunction:"linear",userSelect:"none"},"&-mask-zoom-leave":{animationName:De,animationDuration:e.motionDurationSlow,animationTimingFunction:"linear",pointerEvents:"none"},"&-zoom-appear, &-zoom-enter":{animationName:Ve,opacity:0,animationTimingFunction:e.motionEaseOutCirc,animationFillMode:"both",transform:"none",animationDuration:e.motionDurationMid,userSelect:"none"},"&-zoom-enter-active":{animationPlayState:"running"},"&-zoom-leave":{animationName:Pe,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseInOutCirc,animationFillMode:"both"}},[`${e.componentCls}-root`]:{[`${e.componentCls}-wrapper`]:{zIndex:e.zIndexPopup}},[`${e.componentCls}-operations-wrapper`]:{position:"fixed",insetBlockStart:0,insetInlineEnd:0,zIndex:e.calc(e.zIndexPopup).add(1).equal(),width:"100%"},"&":[Xe(e),je(e)]}};function Be(e){return L.useStyle("ImageViewer",n=>{const i=L.mergeToken(n,{zIndexPopup:n.zIndexPopupBase+80,previewOperationColor:new B.TinyColor(n.colorTextLightSolid).setAlpha(.65).toRgbString(),previewOperationHoverColor:new B.TinyColor(n.colorTextLightSolid).setAlpha(.85).toRgbString(),previewOperationColorDisabled:new B.TinyColor(n.colorTextLightSolid).setAlpha(.25).toRgbString(),imagePreviewSwitchSize:n.sizeXL,modalMaskBg:new B.TinyColor("#000").setAlpha(.45).toRgbString(),previewOperationSize:n.fontSizeIcon*1.5,iconCls:".anticon",previewCls:n.componentCls});return[Ye(i)]},e)}const ce={ESC:27,LEFT:37,RIGHT:39},K={rotateLeft:t.createVNode(O.RotateLeftOutlined,null,null),rotateRight:t.createVNode(O.RotateRightOutlined,null,null),zoomIn:t.createVNode(O.ZoomInOutlined,null,null),zoomOut:t.createVNode(O.ZoomOutOutlined,null,null),flipX:t.createVNode(O.SwapOutlined,null,null),flipY:t.createVNode(O.SwapOutlined,{rotate:90},null)},xe=t.defineComponent({name:"GImagePreview",props:_,inheritAttrs:!1,slots:Object,emits:{close:()=>!0,transform:e=>!0,"update:open":e=>!0},setup:(e,{emit:n,expose:i,slots:a})=>{const o=f.getPrefixCls({suffixCls:"image-view"}),{wrapSSR:s,hashId:u}=Be(o),[p,m,d]=P.useMergedState(e.open,{value:t.toRef(e,"open"),onChange:c=>{e.onOpenChange?.(c),n("update:open",c)}}),[v,h]=P.useState(!1),[x,I]=P.useState(!0),l=t.ref(),{transform:r,resetTransform:y,updateTransform:w,dispatchZoomChange:S}=Me(l,t.toRef(e,"minScale"),t.toRef(e,"maxScale"),e.onTransform),{isMoving:C,onMouseDown:M,onWheel:E}=ze(l,t.toRef(e,"movable"),d,t.toRef(e,"scaleStep"),r,w,S),{isTouching:T,onTouchStart:N,onTouchMove:k,onTouchEnd:Q}=Ae(l,t.toRef(e,"movable"),d,t.toRef(e,"minScale"),r,w,S);P.useEffect(()=>{x.value||I(!0)},[x]);const X=t.ref(null),$=t.ref(e.current),j=t.reactive(new Map),F=t.computed(()=>new Map(Array.from(j).map(([c,{url:z}])=>[c,z]))),J=t.computed(()=>F.value.get($.value)),W=t.computed(()=>F.value.size),Z=t.computed(()=>Array.from(F.value.keys())),R=t.computed(()=>Z.value.indexOf($.value)),g=t.computed(()=>W.value>1),Y=t.computed(()=>W.value>=1);t.watch(d,c=>{c&&(v.value=!0)});const D=c=>{$.value=c};t.watch(()=>e.current,c=>{f.isNumber(c)&&D(c)});function de(c,z){j.set(c,{url:z,loading:!0,canPreview:!1})}const te=()=>{h(!1)},ie=()=>{y("close"),n("close")},_e=c=>{C.value||X.value===c?.target&&te()},Ge=()=>{const c=j.get($.value);c&&(c.loading=!1,c.canPreview=!0)},qe=c=>{const z=j.get($.value);z&&(z.loading=!1,z.canPreview=!1),c.target.alt="加载失败"},be=()=>{if(R.value>0||e.infinite){const c=R.value-1<0?e.urls.length-1:R.value-1;D(Z.value[c]),y("prev")}},Ne=()=>{if(R.value<W.value-1||e.infinite){const c=R.value+1>e.urls.length-1?0:R.value+1;D(Z.value[c]),y("next")}},Ke=()=>{S(q+e.scaleStep,"zoomIn")},Qe=()=>{S(q/(q+e.scaleStep),"zoomOut")},Je=()=>{w({rotate:r.value.rotate+90},"rotateRight")},Ue=()=>{w({rotate:r.value.rotate-90},"rotateLeft")},et=()=>{w({flipX:!r.value.flipX},"flipX")},tt=()=>{w({flipY:!r.value.flipY},"flipY")},Le=[{icon:f.getSlotVNode(a,e.icons,"flipY")||K.flipY,onClick:tt,type:"flipY"},{icon:f.getSlotVNode(a,e.icons,"flipX")||K.flipX,onClick:et,type:"flipX"},{icon:f.getSlotVNode(a,e.icons,"rotateLeft")||K.rotateLeft,onClick:Ue,type:"rotateLeft"},{icon:f.getSlotVNode(a,e.icons,"rotateRight")||K.rotateRight,onClick:Je,type:"rotateRight"},{icon:f.getSlotVNode(a,e.icons,"zoomOut")||K.zoomOut,onClick:()=>Qe(),type:"zoomOut",disabled:t.computed(()=>r.value.scale<=e.minScale)},{icon:f.getSlotVNode(a,e.icons,"zoomIn")||K.zoomIn,onClick:()=>Ke(),type:"zoomIn",disabled:t.computed(()=>r.value.scale===e.maxScale)}],nt=c=>{d.value&&(r.value.scale!==1?w({x:0,y:0,scale:1},"doubleClick"):S(q+e.scaleStep,"doubleClick",c.clientX,c.clientY))},ot=c=>{c.keyCode===ce.ESC&&te(),!(!d.value||!g.value)&&(c.keyCode===ce.LEFT?be():c.keyCode===ce.RIGHT&&Ne())};let fe=()=>{};return t.onMounted(()=>{t.watch(()=>e.urls,c=>{f.isArray(c)&&c.forEach((z,ae)=>{de(ae,z)})},{flush:"post",immediate:!0}),t.watch([()=>d.value,()=>C.value],()=>{fe();const c=G(window,"keydown",ot,!1);fe=()=>{c.remove()}},{flush:"post",immediate:!0})}),t.onUnmounted(()=>{fe()}),i({setOpen:c=>{m(c),$.value=e.current}}),()=>{const c=L.getTransitionProps(`${o}-mask-zoom`),z=L.getTransitionProps(`${o}-zoom`),ae={};for(const V in e.icons)ae[V]=f.getSlotVNode(a,e.icons,V);return s(t.createVNode(t.Fragment,null,[t.createVNode(t.Teleport,{to:e.getContainer||"body"},{default:()=>[d.value&&t.createVNode(t.Fragment,null,[t.createVNode("div",{class:`${o}-root ${u.value}`},[t.createVNode(t.Transition,c,{default:()=>[t.withDirectives(t.createVNode("div",{class:`${o}-mask ${u.value}`},null),[[t.vShow,d.value&&v.value]])]}),t.createVNode("div",{ref:X,tabindex:-1,class:[`${o}-wrap`,`${u.value}`,C.value&&`${o}-moving`],onClick:V=>e.onHideOnClickModal&&_e(V)},[t.createVNode(t.Transition,t.mergeProps(z,{onAfterLeave:()=>ie()}),{default:()=>[t.withDirectives(t.createVNode("div",{role:"dialog",class:`${o} ${u.value}`},[t.createVNode("div",{class:`${o}-content ${u.value}`},[t.createVNode("div",{class:`${o}-body ${u.value}`},[t.createVNode("div",{class:`${o}-img-wrapper ${u.value}`},[t.createVNode("img",{ref:l,class:`${o}-img ${u.value}`,src:J.value,onLoad:()=>Ge(),onError:V=>qe(V),style:{transform:`translate3d(${r.value.x}px, ${r.value.y}px, 0) scale3d(${r.value.flipX?"-":""}${r.value.scale}, ${r.value.flipY?"-":""}${r.value.scale}, 1) rotate(${r.value.rotate}deg)`,transitionDuration:!x.value||T.value?"0s":void 0},onWheel:E,onMousedown:M,onDblclick:nt,onTouchstart:N,onTouchmove:k,onTouchend:Q,onTouchcancel:Q},null)])])])]),[[t.vShow,d.value&&v.value]])]})])])])]}),d.value&&v.value&&t.createVNode(Ee,{open:d.value&&v.value,hashId:u.value,count:e.urls.length,current:$.value,zIndex:e.zIndex+1,getContainer:e.getContainer,prefixCls:o,icons:U.omit(ae,Le.map(({type:V})=>V)),tools:Le,infinite:e.infinite,countRender:f.getSlot(a,e,"countRender"),showSwitch:g.value,showProgress:Y.value,onClose:te,onActive:V=>V>0?Ne():be()},null)]))}}}),ue={width:"100%",height:"100%"},Fe={overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},We=e=>{const{motionDurationSlow:n,paddingXXS:i,marginXXS:a,colorTextLightSolid:o}=e,s=".anticon";return{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:o,background:new L.FastColor("#000").setA(.5).toRgbString(),cursor:"pointer",opacity:0,transition:`opacity ${n}`,[`.${e.componentCls}-mask-info`]:{...Fe,padding:`0 ${L.unit(i)}`,[s]:{marginInlineEnd:a,svg:{verticalAlign:"baseline"}}}}},Ze=e=>({position:e||"absolute",inset:0}),ke=e=>({[e.componentCls]:{display:"inline-block",position:"relative",overflow:"hidden",[`${e.componentCls}-img`]:{...ue,verticalAlign:"top",opacity:1,[`&${e.componentCls}-img-preview`]:{userSelect:"none",cursor:"pointer"},"&-placeholder":{...ue,backgroundColor:e.colorBgContainerDisabled,backgroundImage:"url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",backgroundRepeat:"no-repeat",backgroundPosition:"center center",backgroundSize:"30%"}},[`${e.componentCls}-error`]:{...ue,display:"flex",alignItems:"center",justifyContent:"center"},[`${e.componentCls}-placeholder`]:{...Ze()},[`${e.componentCls}-mask`]:{...We(e)},[`${e.componentCls}-mask:hover`]:{opacity:1}}}),He=e=>typeof Element>"u"?!1:e instanceof Element;let Ie="";const ee=t.defineComponent({props:le,name:"GImage",inheritAttrs:!1,emits:{click:()=>!0,load:e=>!0,error:e=>!0},slots:Object,setup(e,{slots:n,emit:i,attrs:a}){const o=A.isClient&&"loading"in HTMLImageElement.prototype,s=f.getPrefixCls({suffixCls:"image"}),{wrapSSR:u,hashId:p}=L.useProStyle("Image",[ke],s),m=t.ref(),d=t.ref(),v=t.ref(!1),h=t.ref(!0),x=t.ref(!1),I=t.ref(),l=t.ref();let r,y;const w=t.computed(()=>e.loading==="eager"?!1:!o&&e.loading==="lazy"||e.lazy),S=t.computed(()=>A.isClient&&e.fit?{...e.imageStyle,objectFit:e.fit}:e.imageStyle),C=t.computed(()=>typeof e.preview=="object"?e.preview:{}),M=t.computed(()=>!!e.preview),E=t.computed(()=>{const{urls:g=[],current:Y=0}=C.value;if(f.isNumber(Y))return g.length>=Y?Y:0;const D=g.indexOf(e.src);return D>=0?D:0}),T=t.computed(()=>L.unit(e.width)),N=t.computed(()=>L.unit(e.height)),k=()=>{A.isClient&&(h.value=!0,v.value=!1,d.value=e.src)};function Q(g){v.value||(h.value=!1,v.value=!1,i("load",g))}function X(g){h.value=!1,v.value=!0,i("error",g)}function $(){f.isInContainer(I.value,l.value)&&(k(),J())}const j=A.useThrottleFn($,200,!0);async function F(){if(!A.isClient)return;await t.nextTick();const{scrollContainer:g}=e;He(g)?l.value=g:f.isString(g)&&g!==""?l.value=document.querySelector(g)??void 0:I.value&&(l.value=f.getScrollContainer(I.value)),l.value&&(r=A.useEventListener(l,"scroll",j),setTimeout(()=>$(),100))}function J(){!A.isClient||!l.value||!j||(r?.(),l.value=void 0)}function W(g){if(g.ctrlKey){if(g.deltaY<0)return g.preventDefault(),!1;if(g.deltaY>0)return g.preventDefault(),!1}}const Z=()=>{i("click"),!(h.value||v.value)&&M.value&&(y=A.useEventListener("wheel",W,{passive:!1}),Ie=document.body.style.overflow,document.body.style.overflow="hidden",x.value=!0)},R=()=>{y?.(),document.body.style.overflow=Ie,x.value=!1};return t.watch(()=>e.src,()=>{w.value?(h.value=!0,v.value=!1,J(),F()):k()}),t.watchEffect(()=>{M.value&&x.value?m.value?.setOpen(!0):m.value?.setOpen(!1)}),t.onMounted(()=>{w.value?F():k()}),()=>{const g=U.fromPairs(Object.entries(a).filter(([ie])=>/^(?:data-|on[A-Z])/i.test(ie)||["id","style","class"].includes(ie))),Y=U.omit(a,Object.keys(g)),D=f.getSlot(n,e,"fallback",{render:!0}),de=f.getSlot(n,e,"mask",{render:!0}),te=f.getSlot(n,e,"placeholder",{render:!0});return u(t.createVNode("div",t.mergeProps({class:{[`${p.value}`]:!0,[`${s}`]:!0},ref:I},g,{style:{width:L.unit(e.size)||T.value,height:L.unit(e.size)||N.value,...g.style||{}}}),[v.value?t.createVNode("div",{class:f.classNames(p.value,`${s}-error`)},[D]):t.createVNode(t.Fragment,null,[t.createVNode("img",t.mergeProps(Y,{src:d.value,loading:e.loading,style:S.value,class:f.classNames(p.value,e.imageClass,`${s}-img`,{[`${s}-img-placeholder`]:e.placeholder===!0,[`${s}-img-preview`]:M.value}),crossorigin:e.crossOrigin,width:T.value,height:N.value,onClick:Z,onLoad:Q,onError:X}),null),h.value&&t.createVNode("div",{class:f.classNames(`${s}-placeholder`,p.value)},[te])]),C.value.mask&&M.value&&t.createVNode("div",{class:f.classNames(`${s}-mask`,C.value.maskClass,p.value),style:{display:g.style?.display==="none"?"none":void 0}},[de||t.createVNode("div",{class:f.classNames(`${s}-mask-info`,p.value)},[t.createVNode(O.EyeOutlined,null,null)])]),M.value&&t.createVNode(xe,t.mergeProps({ref:m},C.value,{urls:C.value.urls||[e.src],current:E.value,onClose:()=>R()}),n)]))}}});ee.isGImage=!0,ee.install=e=>(e.component(ee.name,ee),e),b.GImage=ee,b.GImagePreview=xe,b.baseProps=H,b.imageProps=le,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
12
+ (function(b,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@ant-design/icons-vue"),require("@gx-design-vue/pro-provider"),require("@gx-design-vue/pro-utils"),require("@vueuse/core"),require("lodash-es"),require("@gx-design-vue/pro-hooks"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","vue","@ant-design/icons-vue","@gx-design-vue/pro-provider","@gx-design-vue/pro-utils","@vueuse/core","lodash-es","@gx-design-vue/pro-hooks","@ctrl/tinycolor"],t):(b=typeof globalThis<"u"?globalThis:b||self,t(b.GImage={},b.vue,b.iconsVue,b.proProvider,b.proUtils,b.core,b.lodashEs,b.proHooks,b.tinycolor))})(this,(function(b,t,A,L,y,E,U,X,F){"use strict";const H={infinite:{type:Boolean,default:!0},zIndex:{type:Number,default:2e3},current:{type:Number,default:0},getContainer:{type:String}},ae={preview:{type:[Object,Boolean],default:!0},src:{type:String,default:""},alt:{type:String,default:""},loading:{type:String},fit:{type:String,default:"contain"},crossOrigin:{type:String},lazy:Boolean,scrollContainer:{type:[String,Object]},placeholder:{type:[Function,Object,Boolean],default:()=>{}},fallback:{type:[Function,Object],default:()=>{}},onLoad:{type:Function},onError:{type:Function},onClick:{type:Function},imageStyle:{type:Object,default:()=>({})},imageClass:String,size:Number,width:Number,height:Number,zIndex:H.zIndex,getContainer:H.getContainer},_={urls:{type:Array,default:()=>[]},open:{type:Boolean,default:!1},scaleStep:{type:Number,default:.5},minScale:{type:Number,default:.32},maxScale:{type:Number,default:32},movable:{type:Boolean,default:!0},disabled:Boolean,zIndex:H.zIndex,current:H.current,infinite:H.infinite,getContainer:ae.getContainer,onHideOnClickModal:{type:Boolean,default:!0},countRender:[Function,Array,Object],icons:{type:Object,default:()=>({})},onTransform:Function,onOpenChange:Function,"onUpdate:open":Function};let fe=e=>setTimeout(e,16),ge=e=>clearTimeout(e);typeof window<"u"&&"requestAnimationFrame"in window&&(fe=e=>window.requestAnimationFrame(e),ge=e=>window.cancelAnimationFrame(e));let me=0;const le=new Map;function ve(e){le.delete(e)}function he(e,n=1){me+=1;const i=me;function s(o){if(o===0)ve(i),e();else{const c=fe(()=>{s(o-1)});le.set(i,c)}}return s(n),i}he.cancel=e=>{const n=le.get(e);return ve(n),ge(n)};const te={x:0,y:0,rotate:0,scale:1,flipX:!1,flipY:!1};function Le(e,n,i,s){const o=t.ref(null),c=t.ref([]),[u,p]=X.useState(te),g=v=>{p(te),U.isEqual(te,u.value)||s?.({transform:te,action:v})},d=(v,x)=>{o.value===null&&(c.value=[],o.value=he(()=>{let I=U.cloneDeep(u.value);c.value.forEach(a=>{I={...I,...a}}),o.value=null,s?.({transform:I,action:x}),p(I)})),c.value.push({...u.value,...v})};return{transform:u,resetTransform:g,updateTransform:d,dispatchZoomChange:(v,x,I,a,l)=>{const{width:w,height:h,offsetWidth:S,offsetHeight:C,offsetLeft:T,offsetTop:R}=e.value;let M=v,N=u.value.scale*v;N>i.value?(N=i.value,M=i.value/u.value.scale):N<n.value&&(N=l?N:n.value,M=N/u.value.scale);const k=I??innerWidth/2,Q=a??innerHeight/2,j=M-1,$=j*w*.5,V=j*h*.5,B=j*(k-u.value.x-T),J=j*(Q-u.value.y-R);let W=u.value.x-(B-$),Z=u.value.y-(J-V);if(v<1&&N===1){const D=S*N,f=C*N,{width:Y,height:z}=E.useWindowSize();D<=Y.value&&f<=z.value&&(W=0,Z=0)}d({x:W,y:Z,scale:N},x)}}}function Te(e,n){process.env.NODE_ENV!=="production"&&console!==void 0&&console.error(`Warning: ${n}`)}let pe=!1;try{const e=Object.defineProperty({},"passive",{get(){pe=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch{}function G(e,n,i,s){if(e&&e.addEventListener){let o=s;o===void 0&&pe&&(n==="touchstart"||n==="touchmove"||n==="wheel")&&(o={passive:!1}),e.addEventListener(n,i,o)}return{remove:()=>{e&&e.removeEventListener&&e.removeEventListener(n,i)}}}const q=1,Me=1;function we(e,n,i,s){const o=n+i,c=(i-s)/2;if(i>s){if(n>0)return{[e]:c};if(n<0&&o<s)return{[e]:-c}}else if(n<0||o>s)return{[e]:n<0?c:-c};return{}}function ye(e,n,i,s){const{width:o,height:c}=E.useWindowSize();let u=null;return e<=o.value&&n<=c.value?u={x:0,y:0}:(e>o.value||n>c.value)&&(u={...we("x",i,e,o.value),...we("y",s,n,c.value)}),u}function $e(e,n,i,s,o,c,u){const[p,g]=X.useState(!1),d=t.ref({diffX:0,diffY:0,transformX:0,transformY:0}),m=a=>{!n||a.button!==0||(a.preventDefault(),a.stopPropagation(),d.value={diffX:a.pageX-o.value.x,diffY:a.pageY-o.value.y,transformX:o.value.x,transformY:o.value.y},g(!0))},v=a=>{i&&p.value&&c({x:a.pageX-d.value.diffX,y:a.pageY-d.value.diffY},"move")},x=()=>{if(i&&p.value){g(!1);const{transformX:a,transformY:l}=d.value;if(!(o.value.x!==a&&o.value.y!==l))return;const h=e.value.offsetWidth*o.value.scale,S=e.value.offsetHeight*o.value.scale,{left:C,top:T}=e.value.getBoundingClientRect(),R=o.value.rotate%180!==0,M=ye(R?S:h,R?h:S,C,T);M&&c({...M},"dragRebound")}},I=a=>{if(!i||a.deltaY===0)return;const l=Math.abs(a.deltaY/100),w=Math.min(l,Me);let h=q+w*s.value;a.deltaY>0&&(h=q/h),u(h,"wheel",a.clientX,a.clientY)};return X.useEffect(()=>{let a,l,w,h;if(n){w=G(window,"mouseup",x,!1),h=G(window,"mousemove",v,!1);try{window.top!==window.self&&(a=G(window.top,"mouseup",x,!1),l=G(window.top,"mousemove",v,!1))}catch(S){Te(!1,`[rc-image] ${S}`)}}return()=>{w?.remove(),h?.remove(),a?.remove(),l?.remove()}},[i,p,()=>o.value.x,()=>o.value.y,()=>o.value.rotate,n]),{isMoving:p,onMouseDown:m,onMouseMove:v,onMouseUp:x,onWheel:I}}function ne(e,n){const i=e.x-n.x,s=e.y-n.y;return Math.hypot(i,s)}function ze(e,n,i,s){const o=ne(e,i),c=ne(n,s);if(o===0&&c===0)return[e.x,e.y];const u=o/(o+c),p=e.x+u*(n.x-e.x),g=e.y+u*(n.y-e.y);return[p,g]}function Oe(e,n,i,s,o,c,u){const[p,g]=X.useState(!1),d=t.ref({point1:{x:0,y:0},point2:{x:0,y:0},eventType:"none"}),m=a=>{d.value={...d.value,...a}},v=a=>{if(!n.value)return;a.stopPropagation(),g(!0);const{touches:l=[]}=a;l.length>1?m({point1:{x:l[0].clientX,y:l[0].clientY},point2:{x:l[1].clientX,y:l[1].clientY},eventType:"touchZoom"}):m({point1:{x:l[0].clientX-o.value.x,y:l[0].clientY-o.value.y},eventType:"move"})},x=a=>{const{touches:l=[]}=a,{point1:w,point2:h,eventType:S}=d.value;if(l.length>1&&S==="touchZoom"){const C={x:l[0].clientX,y:l[0].clientY},T={x:l[1].clientX,y:l[1].clientY},[R,M]=ze(w,h,C,T),N=ne(C,T)/ne(w,h);u(N,"touchZoom",R,M,!0),m({point1:C,point2:T,eventType:"touchZoom"})}else S==="move"&&(c({x:l[0].clientX-w.x,y:l[0].clientY-w.y},"move"),m({eventType:"move"}))},I=()=>{if(!i.value)return;if(p&&g(!1),m({eventType:"none"}),s.value>o.value.scale)return c({x:0,y:0,scale:s.value},"touchZoom");const a=e.value.offsetWidth*o.value.scale,l=e.value.offsetHeight*o.value.scale,{left:w,top:h}=e.value.getBoundingClientRect(),S=o.value.rotate%180!==0,C=ye(S?l:a,S?a:l,w,h);C&&c({...C},"dragRebound")};return X.useEffect(()=>{let a;return i.value&&n.value&&(a=G(window,"touchmove",l=>l.preventDefault(),{passive:!1})),()=>{a?.remove()}},[i,n]),{isTouching:p,onTouchStart:v,onTouchMove:x,onTouchEnd:I}}const Ae=t.defineComponent({name:"Operations",inheritAttrs:!1,props:{open:Boolean,count:{type:Number,default:0},current:{type:Number,default:0},showSwitch:Boolean,showProgress:Boolean,prefixCls:String,hashId:String,zIndex:_.zIndex,icons:_.icons,infinite:_.infinite,getContainer:_.getContainer,countRender:_.countRender,tools:Array,onClose:Function,onActive:Function},setup(e){const n=(i,s)=>{i.preventDefault(),i.stopPropagation(),e.onActive?.(s)};return()=>{const{prefixCls:i,hashId:s,tools:o}=e,c=L.getTransitionProps(`${e.prefixCls}-fade`),u=`${i}-operations-operation`,p=`${i}-operations-icon`;return t.createVNode(t.Teleport,{to:e.getContainer||"body"},{default:()=>[t.createVNode(t.Transition,c,{default:()=>[t.withDirectives(t.createVNode("div",{class:y.classNames(`${i}-operations-wrapper`,s),style:{zIndex:e.zIndex}},[e.icons?.close===null?null:t.createVNode("button",{class:`${i}-close ${s}`,onClick:e.onClose},[e.icons?.close||t.createVNode(A.CloseOutlined,null,null)]),e.showSwitch&&t.createVNode(t.Fragment,null,[t.createVNode("div",{class:y.classNames(`${i}-switch-left ${s}`,{[`${i}-switch-left-disabled`]:e.infinite?!1:e.current===0}),onClick:g=>n(g,-1)},[e.icons?.left||t.createVNode(A.LeftOutlined,null,null)]),t.createVNode("div",{class:y.classNames(`${i}-switch-right ${s}`,{[`${i}-switch-right-disabled`]:e.infinite?!1:e.current===e.count-1}),onClick:g=>n(g,1)},[e.icons?.right||t.createVNode(A.RightOutlined,null,null)])]),t.createVNode("div",{class:`${i}-footer ${s}`},[e.showProgress&&t.createVNode("div",{class:`${i}-progress`},[e.countRender?e.countRender(e.current+1,e.count):`${e.current+1} / ${e.count}`]),t.createVNode("div",{class:`${e.prefixCls}-operations`},[o?.map(({icon:g,onClick:d,type:m,disabled:v})=>t.createVNode("div",{class:y.classNames(u,{[`${e.prefixCls}-operations-operation-disabled`]:v&&v?.value}),onClick:d,key:m},[t.cloneVNode(g,{class:p})]))])])]),[[t.vShow,e.open]])]})]})}}}),Ee=new L.Keyframe("viewFadeIn",{"0%":{opacity:0},"100%":{opacity:1}}),Re=new L.Keyframe("viewFadeOut",{"0%":{opacity:1},"100%":{opacity:0}}),De=new L.Keyframe("viewZoomBadgeIn",{"0%":{transform:"scale(0)",opacity:0},"100%":{transform:"scale(1)",opacity:1}}),Pe=new L.Keyframe("viewZoomBadgeOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0)",opacity:0}}),Se=e=>({position:e||"absolute",inset:0});function re(e){return{position:e,top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0}}const Xe=e=>{const{previewCls:n,modalMaskBg:i,marginXL:s,margin:o,colorTextLightSolid:c,previewOperationColorDisabled:u,previewOperationHoverColor:p,motionDurationSlow:g,iconCls:d}=e,m=new F.TinyColor(i).setAlpha(.1),v=m.clone().setAlpha(.2),x=new F.TinyColor(i).setAlpha(.5),I=new F.TinyColor(i).setAlpha(.03);return{[`${n}-footer`]:{position:"fixed",bottom:s,left:{_skip_check_:!0,value:"50%"},display:"flex",flexDirection:"column",alignItems:"center",color:e.previewOperationColor,transform:"translateX(-50%)"},[`${n}-progress`]:{marginBottom:o},[`${n}-close`]:{position:"fixed",top:s,right:{_skip_check_:!0,value:s},display:"flex",alignItems:"center",justifyContent:"center",color:c,backgroundColor:m.toRgbString(),borderRadius:e.borderRadiusLG,backdropFilter:"saturate(180%) blur(10px)",width:e.sizeXL,height:e.sizeXL,outline:0,border:0,cursor:"pointer",transition:`all ${g}`,"&:hover":{backgroundColor:v.toRgbString()},[`& > ${d}`]:{fontSize:e.previewOperationSize}},[`${n}-operations`]:{display:"flex",alignItems:"center",gap:e.sizeXXS,padding:e.paddingXXS,border:`1px solid ${e.colorBorderSecondary}`,backgroundColor:x.toRgbString(),borderRadius:e.borderRadiusLG,backdropFilter:"saturate(150%) blur(10px)","&-operation":{display:"flex",alignItems:"center",justifyContent:"center",width:e.sizeXL+4,height:e.sizeXL+4,cursor:"pointer",color:c,borderRadius:e.borderRadiusSM,transition:`all ${g}`,userSelect:"none",[`&:not(${n}-operations-operation-disabled):hover > ${d}`]:{color:p},"&:hover":{backgroundColor:I.toRgbString()},"&-disabled":{color:u,cursor:"not-allowed"},"&:first-of-type":{marginInlineStart:0},[`& > ${d}`]:{fontSize:e.previewOperationSize}}}}},je=e=>{const{modalMaskBg:n,iconCls:i,previewOperationColorDisabled:s,previewCls:o,zIndexPopup:c,motionDurationSlow:u,colorTextLightSolid:p}=e,g=new F.TinyColor(n).setAlpha(.1),d=g.clone().setAlpha(.2);return{[`${o}-switch-left, ${o}-switch-right`]:{position:"fixed",insetBlockStart:"50%",zIndex:e.calc(c).add(1).equal(),display:"flex",alignItems:"center",justifyContent:"center",borderRadius:e.borderRadius,backdropFilter:"saturate(180%) blur(10px)",width:e.imagePreviewSwitchSize,height:e.imagePreviewSwitchSize,marginTop:e.calc(e.imagePreviewSwitchSize).mul(-1).div(2).equal(),color:p,background:g.toRgbString(),transform:"translateY(-50%)",cursor:"pointer",transition:`all ${u}`,userSelect:"none","&:hover":{background:d.toRgbString()},"&-disabled":{"&, &:hover":{color:s,background:"transparent",cursor:"not-allowed",[`> ${i}`]:{cursor:"not-allowed"}}},[`> ${i}`]:{fontSize:e.previewOperationSize}},[`${o}-switch-left`]:{insetInlineStart:e.marginSM},[`${o}-switch-right`]:{insetInlineEnd:e.marginSM}}},Ve=e=>{const{motionEaseOut:n,motionDurationSlow:i}=e;return{[e.componentCls]:{height:"100%",textAlign:"center",pointerEvents:"none","&-root":{...re("fixed"),zIndex:e.zIndexPopup,overflow:"auto",outline:0,WebkitOverflowScrolling:"touch"},"&-wrap":{...re("fixed"),zIndex:e.zIndexPopup,overflow:"auto",outline:0,WebkitOverflowScrolling:"touch"},"&-mask":{...re("fixed"),zIndex:e.zIndexPopupBase,height:"100%",backgroundColor:e.colorBgMask,backdropFilter:"blur(8px)"},"&-body":{...Se(),overflow:"hidden"},"&-img":{maxWidth:"100%",maxHeight:"70%",verticalAlign:"middle",transform:"scale3d(1, 1, 1)",cursor:"grab",transition:`transform ${i} ${n} 0s`,userSelect:"none","&-wrapper":{...Se(),transition:`transform ${i} ${n} 0s`,display:"flex",justifyContent:"center",alignItems:"center","& > *":{pointerEvents:"auto"},"&::before":{display:"inline-block",width:1,height:"50%",marginInlineEnd:-1,content:'""'}}},"&-moving":{[`${e.componentCls}-view-img`]:{cursor:"grabbing","&-wrapper":{transitionDuration:"0s"}}},"&-mask-zoom-appear, &-mask-zoom-enter":{animationName:Ee,animationDuration:e.motionDurationSlow,animationTimingFunction:"linear",userSelect:"none"},"&-mask-zoom-leave":{animationName:Re,animationDuration:e.motionDurationSlow,animationTimingFunction:"linear",pointerEvents:"none"},"&-zoom-appear, &-zoom-enter":{animationName:De,opacity:0,animationTimingFunction:e.motionEaseOutCirc,animationFillMode:"both",transform:"none",animationDuration:e.motionDurationMid,userSelect:"none"},"&-zoom-enter-active":{animationPlayState:"running"},"&-zoom-leave":{animationName:Pe,animationDuration:e.motionDurationSlow,animationTimingFunction:e.motionEaseInOutCirc,animationFillMode:"both"}},[`${e.componentCls}-root`]:{[`${e.componentCls}-wrapper`]:{zIndex:e.zIndexPopup}},[`${e.componentCls}-operations-wrapper`]:{position:"fixed",insetBlockStart:0,insetInlineEnd:0,zIndex:e.calc(e.zIndexPopup).add(1).equal(),width:"100%"},"&":[Xe(e),je(e)]}};function Ye(e){return L.useStyle("ImageViewer",n=>{const i=L.mergeToken(n,{zIndexPopup:n.zIndexPopupBase+80,previewOperationColor:new F.TinyColor(n.colorTextLightSolid).setAlpha(.65).toRgbString(),previewOperationHoverColor:new F.TinyColor(n.colorTextLightSolid).setAlpha(.85).toRgbString(),previewOperationColorDisabled:new F.TinyColor(n.colorTextLightSolid).setAlpha(.25).toRgbString(),imagePreviewSwitchSize:n.sizeXL,modalMaskBg:new F.TinyColor("#000").setAlpha(.45).toRgbString(),previewOperationSize:n.fontSizeIcon*1.5,iconCls:".anticon",previewCls:n.componentCls});return[Ve(i)]},e)}const se={ESC:27,LEFT:37,RIGHT:39},K={rotateLeft:t.createVNode(A.RotateLeftOutlined,null,null),rotateRight:t.createVNode(A.RotateRightOutlined,null,null),zoomIn:t.createVNode(A.ZoomInOutlined,null,null),zoomOut:t.createVNode(A.ZoomOutOutlined,null,null),flipX:t.createVNode(A.SwapOutlined,null,null),flipY:t.createVNode(A.SwapOutlined,{rotate:90},null)},Ce=t.defineComponent({name:"GImagePreview",props:_,inheritAttrs:!1,slots:Object,emits:{close:()=>!0,transform:e=>!0,"update:open":e=>!0},setup:(e,{emit:n,expose:i,slots:s})=>{const o=y.getPrefixCls({suffixCls:"image-view"}),{wrapSSR:c,hashId:u}=Ye(o),[p,g,d]=X.useMergedState(e.open,{value:t.toRef(e,"open"),onChange:r=>{e.onOpenChange?.(r),n("update:open",r)}}),[m,v]=X.useState(!1),[x,I]=X.useState(!0),a=t.ref(),{transform:l,resetTransform:w,updateTransform:h,dispatchZoomChange:S}=Le(a,t.toRef(e,"minScale"),t.toRef(e,"maxScale"),e.onTransform),{isMoving:C,onMouseDown:T,onWheel:R}=$e(a,t.toRef(e,"movable"),d,t.toRef(e,"scaleStep"),l,h,S),{isTouching:M,onTouchStart:N,onTouchMove:k,onTouchEnd:Q}=Oe(a,t.toRef(e,"movable"),d,t.toRef(e,"minScale"),l,h,S);X.useEffect(()=>{x.value||I(!0)},[x]);const j=t.ref(null),$=t.ref(e.current),V=t.reactive(new Map),B=t.computed(()=>new Map(Array.from(V).map(([r,{url:O}])=>[r,O]))),J=t.computed(()=>B.value.get($.value)),W=t.computed(()=>B.value.size),Z=t.computed(()=>Array.from(B.value.keys())),D=t.computed(()=>Z.value.indexOf($.value)),f=t.computed(()=>W.value>1),Y=t.computed(()=>W.value>=1);t.watch(d,r=>{r&&(m.value=!0)});const z=r=>{$.value=r};t.watch(()=>e.current,r=>{y.isNumber(r)&&z(r)});function oe(r,O){V.set(r,{url:O,loading:!0,canPreview:!1})}const ue=()=>{v(!1)},He=()=>{w("close"),n("close")},_e=r=>{C.value||j.value===r?.target&&ue()},Ge=()=>{const r=V.get($.value);r&&(r.loading=!1,r.canPreview=!0)},qe=r=>{const O=V.get($.value);O&&(O.loading=!1,O.canPreview=!1),r.target.alt="加载失败"},Ie=()=>{if(D.value>0||e.infinite){const r=D.value-1<0?e.urls.length-1:D.value-1;z(Z.value[r]),w("prev")}},be=()=>{if(D.value<W.value-1||e.infinite){const r=D.value+1>e.urls.length-1?0:D.value+1;z(Z.value[r]),w("next")}},Ke=()=>{S(q+e.scaleStep,"zoomIn")},Qe=()=>{S(q/(q+e.scaleStep),"zoomOut")},Je=()=>{h({rotate:l.value.rotate+90},"rotateRight")},Ue=()=>{h({rotate:l.value.rotate-90},"rotateLeft")},et=()=>{h({flipX:!l.value.flipX},"flipX")},tt=()=>{h({flipY:!l.value.flipY},"flipY")},Ne=()=>{const r=y.getSlotsProps({slots:s,props:e.icons,keys:["flipY","flipX","rotateLeft","rotateRight","zoomOut","zoomIn"],render:!0,defaultVNodes:[K.flipY,K.flipX,K.rotateLeft,K.rotateRight,K.zoomOut,K.zoomIn]});return[{icon:r.flipY,onClick:tt,type:"flipY"},{icon:r.flipX,onClick:et,type:"flipX"},{icon:r.rotateLeft,onClick:Ue,type:"rotateLeft"},{icon:r.rotateRight,onClick:Je,type:"rotateRight"},{icon:r.zoomOut,onClick:()=>Qe(),type:"zoomOut",disabled:t.computed(()=>l.value.scale<=e.minScale)},{icon:r.zoomIn,onClick:()=>Ke(),type:"zoomIn",disabled:t.computed(()=>l.value.scale===e.maxScale)}]},nt=r=>{d.value&&(l.value.scale!==1?h({x:0,y:0,scale:1},"doubleClick"):S(q+e.scaleStep,"doubleClick",r.clientX,r.clientY))},ot=r=>{r.keyCode===se.ESC&&ue(),!(!d.value||!f.value)&&(r.keyCode===se.LEFT?Ie():r.keyCode===se.RIGHT&&be())};let de=()=>{};return t.onMounted(()=>{t.watch(()=>e.urls,r=>{y.isArray(r)&&r.forEach((O,ie)=>{oe(ie,O)})},{flush:"post",immediate:!0}),t.watch([()=>d.value,()=>C.value],()=>{de();const r=G(window,"keydown",ot,!1);de=()=>{r.remove()}},{flush:"post",immediate:!0})}),t.onUnmounted(()=>{de()}),i({setOpen:r=>{g(r),$.value=e.current}}),()=>{const r=L.getTransitionProps(`${o}-mask-zoom`),O=L.getTransitionProps(`${o}-zoom`),ie={};for(const P in e.icons)ie[P]=getSlotVNode(s,e.icons,P);return c(t.createVNode(t.Fragment,null,[t.createVNode(t.Teleport,{to:e.getContainer||"body"},{default:()=>[d.value&&t.createVNode(t.Fragment,null,[t.createVNode("div",{class:`${o}-root ${u.value}`},[t.createVNode(t.Transition,r,{default:()=>[t.withDirectives(t.createVNode("div",{class:`${o}-mask ${u.value}`},null),[[t.vShow,d.value&&m.value]])]}),t.createVNode("div",{ref:j,tabindex:-1,class:[`${o}-wrap`,`${u.value}`,C.value&&`${o}-moving`],onClick:P=>e.onHideOnClickModal&&_e(P)},[t.createVNode(t.Transition,t.mergeProps(O,{onAfterLeave:()=>He()}),{default:()=>[t.withDirectives(t.createVNode("div",{role:"dialog",class:`${o} ${u.value}`},[t.createVNode("div",{class:`${o}-content ${u.value}`},[t.createVNode("div",{class:`${o}-body ${u.value}`},[t.createVNode("div",{class:`${o}-img-wrapper ${u.value}`},[t.createVNode("img",{ref:a,class:`${o}-img ${u.value}`,src:J.value,onLoad:()=>Ge(),onError:P=>qe(P),style:{transform:`translate3d(${l.value.x}px, ${l.value.y}px, 0) scale3d(${l.value.flipX?"-":""}${l.value.scale}, ${l.value.flipY?"-":""}${l.value.scale}, 1) rotate(${l.value.rotate}deg)`,transitionDuration:!x.value||M.value?"0s":void 0},onWheel:R,onMousedown:T,onDblclick:nt,onTouchstart:N,onTouchmove:k,onTouchend:Q,onTouchcancel:Q},null)])])])]),[[t.vShow,d.value&&m.value]])]})])])])]}),d.value&&m.value&&t.createVNode(Ae,{open:d.value&&m.value,hashId:u.value,count:e.urls.length,current:$.value,zIndex:e.zIndex+1,getContainer:e.getContainer,prefixCls:o,icons:U.omit(ie,Ne().map(({type:P})=>P)),tools:Ne(),infinite:e.infinite,countRender:y.getSlot({slots:s,props:e,key:"countRender"}),showSwitch:f.value,showProgress:Y.value,onClose:ue,onActive:P=>P>0?be():Ie()},null)]))}}}),ce={width:"100%",height:"100%"},Fe={overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},Be=e=>{const{motionDurationSlow:n,paddingXXS:i,marginXXS:s,colorTextLightSolid:o}=e,c=".anticon";return{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:o,background:new L.FastColor("#000").setA(.5).toRgbString(),cursor:"pointer",opacity:0,transition:`opacity ${n}`,[`.${e.componentCls}-mask-info`]:{...Fe,padding:`0 ${L.unit(i)}`,[c]:{marginInlineEnd:s,svg:{verticalAlign:"baseline"}}}}},We=e=>({position:e||"absolute",inset:0}),Ze=e=>({[e.componentCls]:{display:"inline-block",position:"relative",overflow:"hidden",[`${e.componentCls}-img`]:{...ce,verticalAlign:"top",opacity:1,[`&${e.componentCls}-img-preview`]:{userSelect:"none",cursor:"pointer"},"&-placeholder":{...ce,backgroundColor:e.colorBgContainerDisabled,backgroundImage:"url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",backgroundRepeat:"no-repeat",backgroundPosition:"center center",backgroundSize:"30%"}},[`${e.componentCls}-error`]:{...ce,display:"flex",alignItems:"center",justifyContent:"center"},[`${e.componentCls}-placeholder`]:{...We()},[`${e.componentCls}-mask`]:{...Be(e)},[`${e.componentCls}-mask:hover`]:{opacity:1}}}),ke=e=>typeof Element>"u"?!1:e instanceof Element;let xe="";const ee=t.defineComponent({props:ae,name:"GImage",inheritAttrs:!1,emits:{click:()=>!0,load:e=>!0,error:e=>!0},slots:Object,setup(e,{slots:n,emit:i,attrs:s}){const o=E.isClient&&"loading"in HTMLImageElement.prototype,c=y.getPrefixCls({suffixCls:"image"}),{wrapSSR:u,hashId:p}=L.useProStyle("Image",[Ze],c),g=t.ref(),d=t.ref(),m=t.ref(!1),v=t.ref(!0),x=t.ref(!1),I=t.ref(),a=t.ref();let l,w;const h=t.computed(()=>e.loading==="eager"?!1:!o&&e.loading==="lazy"||e.lazy),S=t.computed(()=>E.isClient&&e.fit?{...e.imageStyle,objectFit:e.fit}:e.imageStyle),C=t.computed(()=>typeof e.preview=="object"?e.preview:{}),T=t.computed(()=>!!e.preview),R=t.computed(()=>{const{urls:f=[],current:Y=0}=C.value;if(y.isNumber(Y))return f.length>=Y?Y:0;const z=f.indexOf(e.src);return z>=0?z:0}),M=t.computed(()=>L.unit(e.width)),N=t.computed(()=>L.unit(e.height)),k=()=>{E.isClient&&(v.value=!0,m.value=!1,d.value=e.src)};function Q(f){m.value||(v.value=!1,m.value=!1,i("load",f))}function j(f){v.value=!1,m.value=!0,i("error",f)}function $(){y.isInContainer(I.value,a.value)&&(k(),J())}const V=E.useThrottleFn($,200,!0);async function B(){if(!E.isClient)return;await t.nextTick();const{scrollContainer:f}=e;ke(f)?a.value=f:y.isString(f)&&f!==""?a.value=document.querySelector(f)??void 0:I.value&&(a.value=y.getScrollContainer(I.value)),a.value&&(l=E.useEventListener(a,"scroll",V),setTimeout(()=>$(),100))}function J(){!E.isClient||!a.value||!V||(l?.(),a.value=void 0)}function W(f){if(f.ctrlKey){if(f.deltaY<0)return f.preventDefault(),!1;if(f.deltaY>0)return f.preventDefault(),!1}}const Z=()=>{i("click"),!(v.value||m.value)&&T.value&&(w=E.useEventListener("wheel",W,{passive:!1}),xe=document.body.style.overflow,document.body.style.overflow="hidden",x.value=!0)},D=()=>{w?.(),document.body.style.overflow=xe,x.value=!1};return t.watch(()=>e.src,()=>{h.value?(v.value=!0,m.value=!1,J(),B()):k()}),t.watchEffect(()=>{T.value&&x.value?g.value?.setOpen(!0):g.value?.setOpen(!1)}),t.onMounted(()=>{h.value?B():k()}),()=>{const f=U.fromPairs(Object.entries(s).filter(([oe])=>/^(?:data-|on[A-Z])/i.test(oe)||["id","style","class"].includes(oe))),Y=U.omit(s,Object.keys(f)),z=y.getSlotsProps({slots:n,props:e,keys:["fallback","mask","placeholder"],render:!0});return u(t.createVNode("div",t.mergeProps({class:{[`${p.value}`]:!0,[`${c}`]:!0},ref:I},f,{style:{width:L.unit(e.size)||M.value,height:L.unit(e.size)||N.value,...f.style||{}}}),[m.value?t.createVNode("div",{class:y.classNames(p.value,`${c}-error`)},[z.fallback]):t.createVNode(t.Fragment,null,[t.createVNode("img",t.mergeProps(Y,{src:d.value,loading:e.loading,style:S.value,class:y.classNames(p.value,e.imageClass,`${c}-img`,{[`${c}-img-placeholder`]:e.placeholder===!0,[`${c}-img-preview`]:T.value}),crossorigin:e.crossOrigin,width:M.value,height:N.value,onClick:Z,onLoad:Q,onError:j}),null),v.value&&t.createVNode("div",{class:y.classNames(`${c}-placeholder`,p.value)},[z.placeholder])]),C.value.mask&&T.value&&t.createVNode("div",{class:y.classNames(`${c}-mask`,C.value.maskClass,p.value),style:{display:f.style?.display==="none"?"none":void 0}},[z.mask||t.createVNode("div",{class:y.classNames(`${c}-mask-info`,p.value)},[t.createVNode(A.EyeOutlined,null,null)])]),T.value&&t.createVNode(Ce,t.mergeProps({ref:g},C.value,{urls:C.value.urls||[e.src],current:R.value,onClose:()=>D()}),n)]))}}});ee.isGImage=!0,ee.install=e=>(e.component(ee.name,ee),e),b.GImage=ee,b.GImagePreview=Ce,b.baseProps=H,b.imageProps=ae,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gx-design-vue/image",
3
3
  "type": "module",
4
- "version": "0.2.0-beta.31",
4
+ "version": "0.2.0-beta.32",
5
5
  "description": "Gx Design Image",
6
6
  "exports": {
7
7
  ".": {
@@ -30,9 +30,9 @@
30
30
  "vue": ">=3.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@gx-design-vue/pro-hooks": "^0.2.0-beta.51",
34
- "@gx-design-vue/pro-provider": "^0.1.0-beta.116",
35
- "@gx-design-vue/pro-utils": "^0.2.0-beta.72",
33
+ "@gx-design-vue/pro-hooks": "^0.2.0-beta.54",
34
+ "@gx-design-vue/pro-provider": "^0.1.0-beta.119",
35
+ "@gx-design-vue/pro-utils": "^0.2.0-beta.80",
36
36
  "@vueuse/core": "^9.10.0",
37
37
  "lodash-es": "^4.17.21"
38
38
  },