react-pic-gallery 1.3.8 → 1.5.2
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/README.md +26 -21
- package/dist/react-pic-gallery.es.js +2013 -0
- package/dist/react-pic-gallery.umd.js +67 -0
- package/package.json +37 -47
- package/dist/CircularLoading.d.ts +0 -1
- package/dist/ImgLazyLoading.d.ts +0 -7
- package/dist/ImgLightbox.d.ts +0 -10
- package/dist/example/src/setupTests.d.ts +0 -1
- package/dist/index.d.ts +0 -27
- package/dist/index.modern.js +0 -341
- package/dist/index.modern.js.map +0 -1
- package/dist/src/index.d.ts +0 -26
- package/dist/styles.d.ts +0 -75
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var An=Object.defineProperty,zn=Object.defineProperties;var En=Object.getOwnPropertyDescriptors;var Mi=Object.getOwnPropertySymbols;var Dn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable;var Hi=(c,b,S)=>b in c?An(c,b,{enumerable:!0,configurable:!0,writable:!0,value:S}):c[b]=S,k=(c,b)=>{for(var S in b||(b={}))Dn.call(b,S)&&Hi(c,S,b[S]);if(Mi)for(var S of Mi(b))Nn.call(b,S)&&Hi(c,S,b[S]);return c},Zi=(c,b)=>zn(c,En(b));(function(c,b){typeof exports=="object"&&typeof module!="undefined"?module.exports=b(require("react")):typeof define=="function"&&define.amd?define(["react"],b):(c=typeof globalThis!="undefined"?globalThis:c||self,c["react-pic-gallery"]=b(c.React))})(this,function(c){"use strict";function b(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var S=b(c),Q={exports:{}},B={};/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/var ri=Object.getOwnPropertySymbols,Ki=Object.prototype.hasOwnProperty,Ri=Object.prototype.propertyIsEnumerable;function Vi(i){if(i==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(i)}function Ui(){try{if(!Object.assign)return!1;var i=new String("abc");if(i[5]="de",Object.getOwnPropertyNames(i)[0]==="5")return!1;for(var r={},e=0;e<10;e++)r["_"+String.fromCharCode(e)]=e;var n=Object.getOwnPropertyNames(r).map(function(o){return r[o]});if(n.join("")!=="0123456789")return!1;var t={};return"abcdefghijklmnopqrst".split("").forEach(function(o){t[o]=o}),Object.keys(Object.assign({},t)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}Ui();/** @license React v17.0.2
|
|
6
|
+
* react-jsx-runtime.production.min.js
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the MIT license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/var Qi=S.default,ti=60103;if(B.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var oi=Symbol.for;ti=oi("react.element"),B.Fragment=oi("react.fragment")}var Fi=Qi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qi=Object.prototype.hasOwnProperty,Gi={key:!0,ref:!0,__self:!0,__source:!0};function ai(i,r,e){var n,t={},o=null,a=null;e!==void 0&&(o=""+e),r.key!==void 0&&(o=""+r.key),r.ref!==void 0&&(a=r.ref);for(n in r)qi.call(r,n)&&!Gi.hasOwnProperty(n)&&(t[n]=r[n]);if(i&&i.defaultProps)for(n in r=i.defaultProps,r)t[n]===void 0&&(t[n]=r[n]);return{$$typeof:ti,type:i,key:o,ref:a,props:t,_owner:Fi.current}}B.jsx=ai,B.jsxs=ai,Q.exports=B;const h=Q.exports.jsx,F=Q.exports.jsxs;var q=function(i,r){return q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])},q(i,r)};function $i(i,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");q(i,r);function e(){this.constructor=i}i.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}var O=function(){return O=Object.assign||function(r){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o])}return r},O.apply(this,arguments)};function li(i,r,e){if(e||arguments.length===2)for(var n=0,t=r.length,o;n<t;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return i.concat(o||r)}var Y=function(i,r){return Number(i.toFixed(r))},Ji=function(i,r){return typeof i=="number"?i:r},C=function(i,r,e){e&&typeof e=="function"&&e(i,r)},xi=function(i){return-Math.cos(i*Math.PI)/2+.5},Ii=function(i){return i},ie=function(i){return i*i},ee=function(i){return i*(2-i)},ne=function(i){return i<.5?2*i*i:-1+(4-2*i)*i},re=function(i){return i*i*i},te=function(i){return--i*i*i+1},oe=function(i){return i<.5?4*i*i*i:(i-1)*(2*i-2)*(2*i-2)+1},ae=function(i){return i*i*i*i},le=function(i){return 1- --i*i*i*i},se=function(i){return i<.5?8*i*i*i*i:1-8*--i*i*i*i},ue=function(i){return i*i*i*i*i},de=function(i){return 1+--i*i*i*i*i},fe=function(i){return i<.5?16*i*i*i*i*i:1+16*--i*i*i*i*i},si={easeOut:xi,linear:Ii,easeInQuad:ie,easeOutQuad:ee,easeInOutQuad:ne,easeInCubic:re,easeOutCubic:te,easeInOutCubic:oe,easeInQuart:ae,easeOutQuart:le,easeInOutQuart:se,easeInQuint:ue,easeOutQuint:de,easeInOutQuint:fe},ui=function(i){typeof i=="number"&&cancelAnimationFrame(i)},_=function(i){!i.mounted||(ui(i.animation),i.animate=!1,i.animation=null,i.velocity=null)};function di(i,r,e,n){if(!!i.mounted){var t=new Date().getTime(),o=1;_(i),i.animation=function(){if(!i.mounted)return ui(i.animation);var a=new Date().getTime()-t,l=a/e,s=si[r],u=s(l);a>=e?(n(o),i.animation=null):i.animation&&(n(u),requestAnimationFrame(i.animation))},requestAnimationFrame(i.animation)}}function z(i,r,e,n){var t=me(r);if(!(!i.mounted||!t)){var o=i.setTransformState,a=i.transformState,l=a.scale,s=a.positionX,u=a.positionY,d=r.scale-l,f=r.positionX-s,m=r.positionY-u;e===0?o(r.scale,r.positionX,r.positionY):di(i,n,e,function(v){var p=l+d*v,g=s+f*v,w=u+m*v;o(p,g,w)})}}function me(i){var r=i.scale,e=i.positionX,n=i.positionY;return!(isNaN(r)||isNaN(e)||isNaN(n))}function ve(i,r,e){var n=i.offsetWidth,t=i.offsetHeight,o=r.offsetWidth,a=r.offsetHeight,l=o*e,s=a*e,u=n-l,d=t-s;return{wrapperWidth:n,wrapperHeight:t,newContentWidth:l,newDiffWidth:u,newContentHeight:s,newDiffHeight:d}}var pe=function(i,r,e,n,t,o,a){var l=i>r?e*(a?1:.5):0,s=n>t?o*(a?1:.5):0,u=i-r-l,d=l,f=n-t-s,m=s;return{minPositionX:u,maxPositionX:d,minPositionY:f,maxPositionY:m}},G=function(i,r){var e=i.wrapperComponent,n=i.contentComponent,t=i.setup.centerZoomedOut;if(!e||!n)throw new Error("Components are not mounted");var o=ve(e,n,r),a=o.wrapperWidth,l=o.wrapperHeight,s=o.newContentWidth,u=o.newDiffWidth,d=o.newContentHeight,f=o.newDiffHeight,m=pe(a,s,u,l,d,f,Boolean(t));return m},W=function(i,r){var e=G(i,r);return i.bounds=e,e};function K(i,r,e,n,t,o,a){var l=e.minPositionX,s=e.minPositionY,u=e.maxPositionX,d=e.maxPositionY,f=0,m=0;a&&(f=t,m=o);var v=$(i,l-f,u+f,n),p=$(r,s-m,d+m,n);return{x:v,y:p}}var $=function(i,r,e,n){return n?i<r?Y(r,2):i>e?Y(e,2):Y(i,2):Y(i,2)};function R(i,r,e,n,t,o){var a=i.transformState,l=a.scale,s=a.positionX,u=a.positionY,d=n-l;if(typeof r!="number"||typeof e!="number")return console.error("Mouse X and Y position were not provided!"),{x:s,y:u};var f=s-r*d,m=u-e*d,v=K(f,m,t,o,0,0,null);return v}function M(i,r,e,n,t){var o=t?n:0,a=r-o;return!isNaN(e)&&i>=e?e:!isNaN(r)&&i<=a?a:i}var fi=function(i,r){var e=i.setup.panning.excluded,n=i.isInitialized,t=i.wrapperComponent,o=r.target,a=t==null?void 0:t.contains(o),l=n&&o&&a;if(!l)return!1;var s=U(o,e);return!s},mi=function(i){var r=i.isInitialized,e=i.isPanning,n=i.setup,t=n.panning.disabled,o=r&&e&&!t;return!!o},ce=function(i,r){var e=i.transformState,n=e.positionX,t=e.positionY;i.isPanning=!0;var o=r.clientX,a=r.clientY;i.startCoords={x:o-n,y:a-t}},he=function(i,r){var e=r.touches,n=i.transformState,t=n.positionX,o=n.positionY;i.isPanning=!0;var a=e.length===1;if(a){var l=e[0].clientX,s=e[0].clientY;i.startCoords={x:l-t,y:s-o}}};function ge(i){var r=i.transformState,e=r.positionX,n=r.positionY,t=r.scale,o=i.setup,a=o.disabled,l=o.limitToBounds,s=o.centerZoomedOut,u=i.wrapperComponent;if(!(a||!u||!i.bounds)){var d=i.bounds,f=d.maxPositionX,m=d.minPositionX,v=d.maxPositionY,p=d.minPositionY,g=e>f||e<m,w=n>v||n<p,P=e>f?u.offsetWidth:i.setup.minPositionX||0,A=n>v?u.offsetHeight:i.setup.minPositionY||0,X=R(i,P,A,t,i.bounds,l||s),E=X.x,D=X.y;return{scale:t,positionX:g?E:e,positionY:w?D:n}}}function Se(i,r,e,n,t){var o=i.setup.limitToBounds,a=i.wrapperComponent,l=i.bounds,s=i.transformState,u=s.scale,d=s.positionX,f=s.positionY,m=r!==d,v=e!==f,p=!m||!v;if(!(!a||p||!l)){var g=K(r,e,l,o,n,t,a),w=g.x,P=g.y;i.setTransformState(u,w,P)}}var we=function(i,r,e){var n=i.startCoords,t=i.transformState,o=i.setup.panning,a=o.lockAxisX,l=o.lockAxisY,s=t.positionX,u=t.positionY;if(!n)return{x:s,y:u};var d=r-n.x,f=e-n.y,m=a?s:d,v=l?u:f;return{x:m,y:v}},V=function(i,r){var e=i.setup,n=i.transformState,t=n.scale,o=e.minScale;return r>0&&t>=o?r:0},ye=function(i){var r=i.mounted,e=i.setup,n=e.disabled,t=e.velocityAnimation,o=i.transformState.scale,a=t.disabled,l=!a||o>1||!n||r;return!!l},be=function(i){var r=i.mounted,e=i.velocity,n=i.bounds,t=i.setup,o=t.disabled,a=t.velocityAnimation,l=i.transformState.scale,s=a.disabled,u=!s||l>1||!o||r;return!(!u||!e||!n)};function Ce(i,r){var e=i.setup.velocityAnimation,n=e.equalToMove,t=e.animationTime,o=e.sensitivity;return n?t*r*o:t}function vi(i,r,e,n,t,o,a,l,s,u){if(t){if(r>a&&e>a){var d=a+(i-a)*u;return d>s?s:d<a?a:d}if(r<o&&e<o){var d=o+(i-o)*u;return d<l?l:d>o?o:d}}return n?r:$(i,o,a,t)}function Pe(i,r){var e=1;return r?Math.min(e,i.offsetWidth/window.innerWidth):e}function Te(i,r){var e=ye(i);if(!!e){var n=i.lastMousePosition,t=i.velocityTime,o=i.setup,a=i.wrapperComponent,l=o.velocityAnimation.equalToMove,s=Date.now();if(n&&t&&a){var u=Pe(a,l),d=r.x-n.x,f=r.y-n.y,m=d/u,v=f/u,p=s-t,g=d*d+f*f,w=Math.sqrt(g)/p;i.velocity={velocityX:m,velocityY:v,total:w}}i.lastMousePosition=r,i.velocityTime=s}}function Ye(i){var r=i.velocity,e=i.bounds,n=i.setup,t=i.wrapperComponent,o=be(i);if(!(!o||!r||!e||!t)){var a=r.velocityX,l=r.velocityY,s=r.total,u=e.maxPositionX,d=e.minPositionX,f=e.maxPositionY,m=e.minPositionY,v=n.limitToBounds,p=n.alignmentAnimation,g=n.zoomAnimation,w=n.panning,P=w.lockAxisY,A=w.lockAxisX,X=g.animationType,E=p.sizeX,D=p.sizeY,N=p.velocityAlignmentTime,L=N,Z=Ce(i,s),pn=Math.max(Z,L),cn=V(i,E),hn=V(i,D),Di=cn*t.offsetWidth/100,Ni=hn*t.offsetHeight/100,gn=u+Di,Sn=d-Di,wn=f+Ni,yn=m-Ni,Wi=i.transformState,bn=new Date().getTime();di(i,X,pn,function(Cn){var ii=i.transformState,Pn=ii.scale,ei=ii.positionX,ni=ii.positionY,Tn=new Date().getTime()-bn,Yn=Tn/L,Xn=si[p.animationType],ji=1-Xn(Math.min(1,Yn)),Li=1-Cn,ki=ei+a*Li,Bi=ni+l*Li,On=vi(ki,Wi.positionX,ei,A,v,d,u,Sn,gn,ji),_n=vi(Bi,Wi.positionY,ni,P,v,m,f,yn,wn,ji);(ei!==ki||ni!==Bi)&&i.setTransformState(Pn,On,_n)})}}function pi(i,r){var e=i.transformState.scale;_(i),W(i,e),r.touches?he(i,r):ce(i,r)}function ci(i,r,e){var n=i.startCoords,t=i.setup,o=t.alignmentAnimation,a=o.sizeX,l=o.sizeY;if(!!n){var s=we(i,r,e),u=s.x,d=s.y,f=V(i,a),m=V(i,l);Te(i,{x:u,y:d}),Se(i,u,d,f,m)}}function Xe(i){if(i.isPanning){var r=i.setup.panning.velocityDisabled,e=i.velocity,n=i.wrapperComponent,t=i.contentComponent;i.isPanning=!1,i.animate=!1,i.animation=null;var o=n==null?void 0:n.getBoundingClientRect(),a=t==null?void 0:t.getBoundingClientRect(),l=(o==null?void 0:o.width)||0,s=(o==null?void 0:o.height)||0,u=(a==null?void 0:a.width)||0,d=(a==null?void 0:a.height)||0,f=l<u||s<d,m=!r&&e&&(e==null?void 0:e.total)>.1&&f;m?Ye(i):hi(i)}}function hi(i){var r=i.transformState.scale,e=i.setup,n=e.minScale,t=e.alignmentAnimation,o=t.disabled,a=t.sizeX,l=t.sizeY,s=t.animationTime,u=t.animationType,d=o||r<n||!a&&!l;if(!d){var f=ge(i);f&&z(i,f,s,u)}}function gi(i,r,e){var n=i.transformState.scale,t=i.wrapperComponent,o=i.setup,a=o.minScale,l=o.limitToBounds,s=o.zoomAnimation,u=s.disabled,d=s.animationTime,f=s.animationType,m=u||n>=a;if((n>=1||l)&&hi(i),!(m||!t||!i.mounted)){var v=r||t.offsetWidth/2,p=e||t.offsetHeight/2,g=J(i,a,v,p);g&&z(i,g,d,f)}}function J(i,r,e,n){var t=i.setup,o=t.minScale,a=t.maxScale,l=t.limitToBounds,s=M(Y(r,2),o,a,0,!1),u=W(i,s),d=R(i,e,n,s,u,l),f=d.x,m=d.y;return{scale:s,positionX:f,positionY:m}}var j={previousScale:1,scale:1,positionX:0,positionY:0},Oe=O(O({},j),{setComponents:function(){},contextInstance:null}),H={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,wheel:{step:.2,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},Si=function(i){var r,e,n,t;return{previousScale:(r=i.initialScale)!==null&&r!==void 0?r:j.scale,scale:(e=i.initialScale)!==null&&e!==void 0?e:j.scale,positionX:(n=i.initialPositionX)!==null&&n!==void 0?n:j.positionX,positionY:(t=i.initialPositionY)!==null&&t!==void 0?t:j.positionY}},wi=function(i){var r=O({},H);return Object.keys(i).forEach(function(e){var n=typeof i[e]!="undefined",t=typeof H[e]!="undefined";if(t&&n){var o=Object.prototype.toString.call(H[e]),a=o==="[object Object]",l=o==="[object Array]";a?r[e]=O(O({},H[e]),i[e]):l?r[e]=li(li([],H[e]),i[e]):r[e]=i[e]}}),r},yi=function(i,r,e){var n=i.transformState.scale,t=i.wrapperComponent,o=i.setup,a=o.maxScale,l=o.minScale,s=o.zoomAnimation,u=s.size;if(!t)throw new Error("Wrapper is not mounted");var d=n*Math.exp(r*e),f=M(Y(d,3),l,a,u,!1);return f};function bi(i,r,e,n,t){var o=i.wrapperComponent,a=i.transformState,l=a.scale,s=a.positionX,u=a.positionY;if(!o)return console.error("No WrapperComponent found");var d=o.offsetWidth,f=o.offsetHeight,m=(d/2-s)/l,v=(f/2-u)/l,p=yi(i,r,e),g=J(i,p,m,v);if(!g)return console.error("Error during zoom event. New transformation state was not calculated.");z(i,g,n,t)}function Ci(i,r,e){var n=i.setup,t=i.wrapperComponent,o=n.limitToBounds,a=Si(i.props),l=i.transformState,s=l.scale,u=l.positionX,d=l.positionY;if(!!t){var f=G(i,a.scale),m=K(a.positionX,a.positionY,f,o,0,0,t),v={scale:a.scale,positionX:m.x,positionY:m.y};s===a.scale&&u===a.positionX&&d===a.positionY||z(i,v,r,e)}}function _e(i,r,e){var n=i.wrapperComponent,t=i.setup,o=t.limitToBounds,a=t.minScale,l=t.maxScale;if(!n)return j;var s=n.getBoundingClientRect(),u=Ae(r),d=u.x,f=u.y,m=r.offsetWidth,v=r.offsetHeight,p=n.offsetWidth/m,g=n.offsetHeight/v,w=M(e||Math.min(p,g),a,l,0,!1),P=(s.width-m*w)/2,A=(s.height-v*w)/2,X=(s.left-d)*w+P,E=(s.top-f)*w+A,D=G(i,w),N=K(X,E,D,o,0,0,n),L=N.x,Z=N.y;return{positionX:L,positionY:Z,scale:w}}function Ae(i){for(var r=i,e=0,n=0;r;)e+=r.offsetLeft,n+=r.offsetTop,r=r.offsetParent;return{x:e,y:n}}function ze(i){if(i){if((i==null?void 0:i.offsetWidth)===void 0||(i==null?void 0:i.offsetHeight)===void 0)return console.error("Zoom node is not valid - it must contain offsetWidth and offsetHeight"),!1}else return console.error("Zoom node not found"),!1;return!0}var Ee=function(i){return function(r,e,n){r===void 0&&(r=.5),e===void 0&&(e=300),n===void 0&&(n="easeOut"),bi(i,1,r,e,n)}},De=function(i){return function(r,e,n){r===void 0&&(r=.5),e===void 0&&(e=300),n===void 0&&(n="easeOut"),bi(i,-1,r,e,n)}},Ne=function(i){return function(r,e,n,t,o){t===void 0&&(t=300),o===void 0&&(o="easeOut");var a=i.transformState,l=a.positionX,s=a.positionY,u=a.scale,d=i.wrapperComponent,f=i.contentComponent,m=i.setup.disabled;if(!(m||!d||!f)){var v={positionX:isNaN(r)?l:r,positionY:isNaN(e)?s:e,scale:isNaN(n)?u:n};z(i,v,t,o)}}},We=function(i){return function(r,e){r===void 0&&(r=200),e===void 0&&(e="easeOut"),Ci(i,r,e)}},je=function(i){return function(r,e,n){e===void 0&&(e=200),n===void 0&&(n="easeOut");var t=i.transformState,o=i.wrapperComponent,a=i.contentComponent;if(o&&a){var l=Ti(r||t.scale,o,a);z(i,l,e,n)}}},Le=function(i){return function(r,e,n,t){n===void 0&&(n=600),t===void 0&&(t="easeOut"),_(i);var o=i.wrapperComponent,a=typeof r=="string"?document.getElementById(r):r;if(o&&ze(a)&&a&&o.contains(a)){var l=_e(i,a,e);z(i,l,n,t)}}},y=function(i){return{instance:i,state:i.transformState,zoomIn:Ee(i),zoomOut:De(i),setTransform:Ne(i),resetTransform:We(i),centerView:je(i),zoomToElement:Le(i)}},x=!1;function I(){try{var i={get passive(){return x=!0,!1}};return i}catch{return x=!1,x}}var U=function(i,r){var e=i.tagName.toUpperCase(),n=r.find(function(o){return o.toUpperCase()===e});if(n)return!0;var t=r.find(function(o){return i.classList.contains(o)});return!!t},Pi=function(i){i&&clearTimeout(i)},ke=function(i,r,e){return"translate3d("+i+"px, "+r+"px, 0) scale("+e+")"},Ti=function(i,r,e){var n=e.offsetWidth*i,t=e.offsetHeight*i,o=(r.offsetWidth-n)/2,a=(r.offsetHeight-t)/2;return{scale:i,positionX:o,positionY:a}},Be=function(i,r){var e=i.setup.wheel,n=e.disabled,t=e.wheelDisabled,o=e.touchPadDisabled,a=e.excluded,l=i.isInitialized,s=i.isPanning,u=r.target,d=l&&!s&&!n&&u;if(!d||t&&!r.ctrlKey||o&&r.ctrlKey)return!1;var f=U(u,a);return!f};function Me(i,r){var e=i?i.deltaY<0?1:-1:0,n=Ji(r,e);return n}function Yi(i,r,e){var n=r.getBoundingClientRect(),t=0,o=0;if("clientX"in i)t=(i.clientX-n.left)/e,o=(i.clientY-n.top)/e;else{var a=i.touches[0];t=(a.clientX-n.left)/e,o=(a.clientY-n.top)/e}return(isNaN(t)||isNaN(o))&&console.error("No mouse or touch offset found"),{x:t,y:o}}var He=function(i,r,e,n,t){var o=i.transformState.scale,a=i.wrapperComponent,l=i.setup,s=l.maxScale,u=l.minScale,d=l.zoomAnimation,f=d.size,m=d.disabled;if(!a)throw new Error("Wrapper is not mounted");var v=o+r*(o-o*e)*e;if(t)return v;var p=n?!1:!m,g=M(Y(v,3),u,s,f,p);return g},Ze=function(i,r){var e=i.previousWheelEvent,n=i.transformState.scale,t=i.setup,o=t.maxScale,a=t.minScale;return e?n<o||n>a||Math.sign(e.deltaY)!==Math.sign(r.deltaY)||e.deltaY>0&&e.deltaY<r.deltaY||e.deltaY<0&&e.deltaY>r.deltaY||Math.sign(e.deltaY)!==Math.sign(r.deltaY):!1},Ke=function(i,r){var e=i.setup.pinch,n=e.disabled,t=e.excluded,o=i.isInitialized,a=r.target,l=o&&!n&&a;if(!l)return!1;var s=U(a,t);return!s},Re=function(i){var r=i.setup.pinch.disabled,e=i.isInitialized,n=i.pinchStartDistance,t=e&&!r&&n;return!!t},Ve=function(i,r,e){var n=e.getBoundingClientRect(),t=i.touches,o=Y(t[0].clientX-n.left,5),a=Y(t[0].clientY-n.top,5),l=Y(t[1].clientX-n.left,5),s=Y(t[1].clientY-n.top,5);return{x:(o+l)/2/r,y:(a+s)/2/r}},Xi=function(i){return Math.sqrt(Math.pow(i.touches[0].pageX-i.touches[1].pageX,2)+Math.pow(i.touches[0].pageY-i.touches[1].pageY,2))},Ue=function(i,r){var e=i.pinchStartScale,n=i.pinchStartDistance,t=i.setup,o=t.maxScale,a=t.minScale,l=t.zoomAnimation,s=l.size,u=l.disabled;if(!e||n===null||!r)throw new Error("Pinch touches distance was not provided");if(r<0)return i.transformState.scale;var d=r/n,f=d*e;return M(Y(f,2),a,o,s,!u)},Qe=160,Fe=100,qe=function(i,r){var e=i.props,n=e.onWheelStart,t=e.onZoomStart;i.wheelStopEventTimer||(_(i),C(y(i),r,n),C(y(i),r,t))},Ge=function(i,r){var e=i.props,n=e.onWheel,t=e.onZoom,o=i.contentComponent,a=i.setup,l=i.transformState,s=l.scale,u=a.limitToBounds,d=a.centerZoomedOut,f=a.zoomAnimation,m=a.wheel,v=f.size,p=f.disabled,g=m.step;if(!o)throw new Error("Component not mounted");r.preventDefault(),r.stopPropagation();var w=Me(r,null),P=He(i,w,g,!r.ctrlKey);if(s!==P){var A=W(i,P),X=Yi(r,o,s),E=p||v===0||d,D=u&&E,N=R(i,X.x,X.y,P,A,D),L=N.x,Z=N.y;i.previousWheelEvent=r,i.setTransformState(P,L,Z),C(y(i),r,n),C(y(i),r,t)}},$e=function(i,r){var e=i.props,n=e.onWheelStop,t=e.onZoomStop;Pi(i.wheelAnimationTimer),i.wheelAnimationTimer=setTimeout(function(){!i.mounted||(gi(i,r.x,r.y),i.wheelAnimationTimer=null)},Fe);var o=Ze(i,r);o&&(Pi(i.wheelStopEventTimer),i.wheelStopEventTimer=setTimeout(function(){!i.mounted||(i.wheelStopEventTimer=null,C(y(i),r,n),C(y(i),r,t))},Qe))},Je=function(i,r){var e=Xi(r);i.pinchStartDistance=e,i.lastDistance=e,i.pinchStartScale=i.transformState.scale,i.isPanning=!1,_(i)},xe=function(i,r){var e=i.contentComponent,n=i.pinchStartDistance,t=i.transformState.scale,o=i.setup,a=o.limitToBounds,l=o.centerZoomedOut,s=o.zoomAnimation,u=s.disabled,d=s.size;if(!(n===null||!e)){var f=Ve(r,t,e);if(!(!isFinite(f.x)||!isFinite(f.y))){var m=Xi(r),v=Ue(i,m);if(v!==t){var p=W(i,v),g=u||d===0||l,w=a&&g,P=R(i,f.x,f.y,v,p,w),A=P.x,X=P.y;i.pinchMidpoint=f,i.lastDistance=m,i.setTransformState(v,A,X)}}}},Ie=function(i){var r=i.pinchMidpoint;i.velocity=null,i.lastDistance=null,i.pinchMidpoint=null,i.pinchStartScale=null,i.pinchStartDistance=null,gi(i,r==null?void 0:r.x,r==null?void 0:r.y)};function en(i,r){var e=i.setup.doubleClick,n=e.disabled,t=e.mode,o=e.step,a=e.animationTime,l=e.animationType;if(!n){if(t==="reset")return Ci(i,a,l);var s=i.transformState.scale,u=i.contentComponent;if(!u)return console.error("No ContentComponent found");var d=t==="zoomOut"?-1:1,f=yi(i,d,o),m=Yi(r,u,s),v=J(i,f,m.x,m.y);if(!v)return console.error("Error during zoom event. New transformation state was not calculated.");z(i,v,a,l)}}var nn=function(i,r){var e=i.isInitialized,n=i.setup,t=i.wrapperComponent,o=n.doubleClick,a=o.disabled,l=o.excluded,s=r.target,u=t==null?void 0:t.contains(s),d=e&&s&&u&&!a;if(!d)return!1;var f=U(s,l);return!(f||!d)},Oi=S.default.createContext(Oe),rn=function(i){$i(r,i);function r(){var e=i!==null&&i.apply(this,arguments)||this;return e.mounted=!0,e.transformState=Si(e.props),e.setup=wi(e.props),e.wrapperComponent=null,e.contentComponent=null,e.isInitialized=!1,e.bounds=null,e.previousWheelEvent=null,e.wheelStopEventTimer=null,e.wheelAnimationTimer=null,e.isPanning=!1,e.startCoords=null,e.lastTouch=null,e.distance=null,e.lastDistance=null,e.pinchStartDistance=null,e.pinchStartScale=null,e.pinchMidpoint=null,e.velocity=null,e.velocityTime=null,e.lastMousePosition=null,e.animate=!1,e.animation=null,e.maxBounds=null,e.pressedKeys={},e.handleInitializeWrapperEvents=function(n){var t=I();n.addEventListener("wheel",e.onWheelZoom,t),n.addEventListener("dblclick",e.onDoubleClick,t),n.addEventListener("touchstart",e.onTouchPanningStart,t),n.addEventListener("touchmove",e.onTouchPanning,t),n.addEventListener("touchend",e.onTouchPanningStop,t)},e.handleInitialize=function(){var n=e.setup.centerOnInit;e.applyTransformation(),e.forceUpdate(),n&&(setTimeout(function(){e.mounted&&e.setCenter()},50),setTimeout(function(){e.mounted&&e.setCenter()},100),setTimeout(function(){e.mounted&&e.setCenter()},200))},e.onWheelZoom=function(n){var t=e.setup.disabled;if(!t){var o=Be(e,n);if(!!o){var a=e.isPressingKeys(e.setup.wheel.activationKeys);!a||(qe(e,n),Ge(e,n),$e(e,n))}}},e.onPanningStart=function(n){var t=e.setup.disabled,o=e.props.onPanningStart;if(!t){var a=fi(e,n);if(!!a){var l=e.isPressingKeys(e.setup.panning.activationKeys);!l||(n.preventDefault(),n.stopPropagation(),_(e),pi(e,n),C(y(e),n,o))}}},e.onPanning=function(n){var t=e.setup.disabled,o=e.props.onPanning;if(!t){var a=mi(e);if(!!a){var l=e.isPressingKeys(e.setup.panning.activationKeys);!l||(n.preventDefault(),n.stopPropagation(),ci(e,n.clientX,n.clientY),C(y(e),n,o))}}},e.onPanningStop=function(n){var t=e.props.onPanningStop;e.isPanning&&(Xe(e),C(y(e),n,t))},e.onPinchStart=function(n){var t=e.setup.disabled,o=e.props,a=o.onPinchingStart,l=o.onZoomStart;if(!t){var s=Ke(e,n);!s||(Je(e,n),_(e),C(y(e),n,a),C(y(e),n,l))}},e.onPinch=function(n){var t=e.setup.disabled,o=e.props,a=o.onPinching,l=o.onZoom;if(!t){var s=Re(e);!s||(n.preventDefault(),n.stopPropagation(),xe(e,n),C(y(e),n,a),C(y(e),n,l))}},e.onPinchStop=function(n){var t=e.props,o=t.onPinchingStop,a=t.onZoomStop;e.pinchStartScale&&(Ie(e),C(y(e),n,o),C(y(e),n,a))},e.onTouchPanningStart=function(n){var t=e.setup.disabled,o=e.props.onPanningStart;if(!t){var a=fi(e,n);if(!!a){var l=e.lastTouch&&+new Date-e.lastTouch<200;if(l&&n.touches.length===1)e.onDoubleClick(n);else{e.lastTouch=+new Date,_(e);var s=n.touches,u=s.length===1,d=s.length===2;u&&(_(e),pi(e,n),C(y(e),n,o)),d&&e.onPinchStart(n)}}}},e.onTouchPanning=function(n){var t=e.setup.disabled,o=e.props.onPanning;if(e.isPanning&&n.touches.length===1){if(t)return;var a=mi(e);if(!a)return;n.preventDefault(),n.stopPropagation();var l=n.touches[0];ci(e,l.clientX,l.clientY),C(y(e),n,o)}else n.touches.length>1&&e.onPinch(n)},e.onTouchPanningStop=function(n){e.onPanningStop(n),e.onPinchStop(n)},e.onDoubleClick=function(n){var t=e.setup.disabled;if(!t){var o=nn(e,n);!o||en(e,n)}},e.clearPanning=function(n){e.isPanning&&e.onPanningStop(n)},e.setKeyPressed=function(n){e.pressedKeys[n.key]=!0},e.setKeyUnPressed=function(n){e.pressedKeys[n.key]=!1},e.isPressingKeys=function(n){return n.length?Boolean(n.find(function(t){return e.pressedKeys[t]})):!0},e.setComponents=function(n,t){e.wrapperComponent=n,e.contentComponent=t,W(e,e.transformState.scale),e.handleInitializeWrapperEvents(n),e.handleInitialize(),e.handleRef(),e.isInitialized=!0,C(y(e),void 0,e.props.onInit)},e.setTransformState=function(n,t,o){!isNaN(n)&&!isNaN(t)&&!isNaN(o)?(n!==e.transformState.scale&&(e.transformState.previousScale=e.transformState.scale,e.transformState.scale=n),e.transformState.positionX=t,e.transformState.positionY=o,e.applyTransformation()):console.error("Detected NaN set state values")},e.setCenter=function(){if(e.wrapperComponent&&e.contentComponent){var n=Ti(e.transformState.scale,e.wrapperComponent,e.contentComponent);e.setTransformState(n.scale,n.positionX,n.positionY)}},e.applyTransformation=function(){if(!(!e.mounted||!e.contentComponent)){var n=e.transformState,t=n.scale,o=n.positionX,a=n.positionY,l=ke(o,a,t);e.contentComponent.style.transform=l,e.handleRef()}},e.handleRef=function(){e.props.setRef(y(e))},e}return r.prototype.componentDidMount=function(){var e=I();window.addEventListener("mousedown",this.onPanningStart,e),window.addEventListener("mousemove",this.onPanning,e),window.addEventListener("mouseup",this.onPanningStop,e),document.addEventListener("mouseleave",this.clearPanning,e),window.addEventListener("keyup",this.setKeyUnPressed,e),window.addEventListener("keydown",this.setKeyPressed,e),this.handleRef()},r.prototype.componentWillUnmount=function(){var e=I();window.removeEventListener("mousedown",this.onPanningStart,e),window.removeEventListener("mousemove",this.onPanning,e),window.removeEventListener("mouseup",this.onPanningStop,e),window.removeEventListener("keyup",this.setKeyUnPressed,e),window.removeEventListener("keydown",this.setKeyPressed,e),_(this)},r.prototype.componentDidUpdate=function(e){e!==this.props&&(W(this,this.transformState.scale),this.setup=wi(this.props))},r.prototype.render=function(){var e=y(this),n=this.props.children,t=typeof n=="function"?n(e):n;return h(Oi.Provider,{value:O(O({},this.transformState),{setComponents:this.setComponents,contextInstance:this}),children:t})},r}(c.Component),tn=S.default.forwardRef(function(i,r){var e=c.useState(null),n=e[0],t=e[1];return c.useImperativeHandle(r,function(){return n},[n]),h(rn,k({},O({},i,{setRef:t})))});function on(i,r){r===void 0&&(r={});var e=r.insertAt;if(!(!i||typeof document=="undefined")){var n=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e==="top"&&n.firstChild?n.insertBefore(t,n.firstChild):n.appendChild(t),t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i))}}var an=`.transform-component-module_wrapper__1_Fgj {
|
|
13
|
+
position: relative;
|
|
14
|
+
width: -moz-fit-content;
|
|
15
|
+
width: fit-content;
|
|
16
|
+
height: -moz-fit-content;
|
|
17
|
+
height: fit-content;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
-webkit-touch-callout: none; /* iOS Safari */
|
|
20
|
+
-webkit-user-select: none; /* Safari */
|
|
21
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
22
|
+
-moz-user-select: none; /* Firefox */
|
|
23
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
24
|
+
user-select: none;
|
|
25
|
+
margin: 0;
|
|
26
|
+
padding: 0;
|
|
27
|
+
}
|
|
28
|
+
.transform-component-module_content__2jYgh {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-wrap: wrap;
|
|
31
|
+
width: -moz-fit-content;
|
|
32
|
+
width: fit-content;
|
|
33
|
+
height: -moz-fit-content;
|
|
34
|
+
height: fit-content;
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
transform-origin: 0% 0%;
|
|
38
|
+
}
|
|
39
|
+
.transform-component-module_content__2jYgh img {
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
}
|
|
42
|
+
`,_i={wrapper:"transform-component-module_wrapper__1_Fgj",content:"transform-component-module_content__2jYgh"};on(an);var ln=function(i){var r=i.children,e=i.wrapperClass,n=e===void 0?"":e,t=i.contentClass,o=t===void 0?"":t,a=i.wrapperStyle,l=i.contentStyle,s=c.useContext(Oi).setComponents,u=c.useRef(null),d=c.useRef(null);return c.useEffect(function(){var f=u.current,m=d.current;f!==null&&m!==null&&s&&s(f,m)},[]),h("div",{ref:u,className:"react-transform-wrapper "+_i.wrapper+" "+n,style:a,children:h("div",{ref:d,className:"react-transform-component "+_i.content+" "+o,style:l,children:r})})};const Ai=`
|
|
43
|
+
.lds-dual-ring {
|
|
44
|
+
display: inline-block;
|
|
45
|
+
width: 40px;
|
|
46
|
+
height: 40px;
|
|
47
|
+
}
|
|
48
|
+
.lds-dual-ring:after {
|
|
49
|
+
content: " ";
|
|
50
|
+
display: block;
|
|
51
|
+
width: 32px;
|
|
52
|
+
height: 32px;
|
|
53
|
+
margin: 8px;
|
|
54
|
+
border-radius: 50%;
|
|
55
|
+
border: 3px solid rgba(185, 185, 185, 0.466);
|
|
56
|
+
border-color: rgba(185, 185, 185, 0.466) transparent rgba(185, 185, 185, 0.466) transparent;
|
|
57
|
+
animation: lds-dual-ring 1.2s linear infinite;
|
|
58
|
+
}
|
|
59
|
+
@keyframes lds-dual-ring {
|
|
60
|
+
0% {
|
|
61
|
+
transform: rotate(0deg);
|
|
62
|
+
}
|
|
63
|
+
100% {
|
|
64
|
+
transform: rotate(360deg);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;function zi(){const i=document.querySelector("#react-pic-style");if(i)i.innerHTML=i.innerHTML+Ai;else{const r=document.createElement("style");r.id="react-pic-style",r.innerHTML=Ai,document.body.appendChild(r)}return h("div",{className:"lds-dual-ring"})}let T={};T.lightbox={position:"fixed",top:0,left:0,width:"100%",height:"100%",background:"rgba(0, 0, 0, 0.454)",backdropFilter:"blur(6px)",zIndex:9999999,display:"grid",gridTemplateRows:"60px | auto | 300px",justifyContent:"center",alignContent:"center"},T.topCustomContent={position:"absolute",top:0},T.bottomCustomContent={position:"absolute",bottom:0},T.LbButton={float:"right",textDecoration:"none",color:"white",padding:"5px",border:"1px solid white",borderRadius:"5px"},T.ABtn={float:"right",textDecoration:"none",color:"white"},T.DescriptionDiv={background:"white",padding:"10px",color:"#666",textAlign:"center",position:"relative",zIndex:-1},T.Wrapper={display:"flex",width:"100%",minWidth:200,height:"100%"},T.Grid={display:"grid",gridTemplateRows:"1fr",gap:"2px",width:"100%",height:"auto"};const Ei=i=>{var t,o,a,l,s;const[r,e]=S.default.useState(""),n=((t=i.options)==null?void 0:t.customLoadComponent)!==void 0?i.options.customLoadComponent:zi;return S.default.useEffect(()=>{var d,f;const u=((d=i.imgObj)==null?void 0:d.fullSrc)?i.imgObj.fullSrc:((f=i.imgObj)==null?void 0:f.thumbnailSrc)?i.imgObj.thumbnailSrc:null;u&&fetch(u).then(m=>m.blob()).then(m=>{e(URL.createObjectURL(m))}),document.body.style.overflow="hidden"},[i.imgObj]),F("div",{className:"reactPic-lightbox",style:T.lightbox,onClick:u=>{document.body.style.overflow="",u.target.className==="reactPic-lightbox"&&i.onClose()},children:[h("div",{style:T.topCustomContent,className:"reactPic-topCustomContent",children:(o=i.topCustomContent)==null?void 0:o.call(i,{closeLightbox:i.onClose,imgObject:i.imgObj})}),r===""?h("div",{style:{display:"block",margin:"auto"},children:h(n,{})}):F("div",{children:[h(tn,{children:h(ln,{children:h("img",{src:r,alt:"",id:"lightboxImg",style:{maxWidth:"80vw",maxHeight:"calc(80vh - 20px)",margin:"auto",zIndex:99999999999}})})}),i.onClickPrevious&&h("div",{className:"react-lightbox-prevBtn",style:{position:"absolute",left:20,top:"50%",fontSize:50,cursor:"pointer",color:"white",display:((a=i.options)==null?void 0:a.hidePagination)?"none":"inherit"},onClick:i.onClickPrevious,children:"\u2039"}),i.onClickNext&&h("div",{className:"react-lightbox-nextBtn",style:{position:"absolute",right:20,top:"50%",fontSize:50,cursor:"pointer",color:"white",display:((l=i.options)==null?void 0:l.hidePagination)?"none":"inherit"},onClick:i.onClickNext,children:"\u203A"})]}),h("div",{style:T.bottomCustomContent,className:"reactPic-bottomCustomContent",children:(s=i.bottomCustomContent)==null?void 0:s.call(i,{closeLightbox:i.onClose,imgObject:i.imgObj})})]})},sn=i=>{var t;const[r,e]=S.default.useState(""),n=((t=i.options)==null?void 0:t.customLoadComponent)!==void 0?i.options.customLoadComponent:zi;return S.default.useEffect(()=>{const o=new AbortController;return i.imgSrc&&fetch(i.imgSrc).then(a=>a.blob()).then(a=>{e(URL.createObjectURL(a))}),()=>{o.abort()}},[i.imgSrc]),r?h("img",{src:r,alt:"",style:k({},i.style),onClick:()=>{i.onClick()}}):h("div",{style:{height:"100%",width:"100%",display:"flex",alignItems:"center",alignContent:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.157)",border:"1px solid rgba(0, 0, 0,0.3)"},children:h(n,{})})};function un(i){var r;return h("div",{className:"reactPic-grid",style:Zi(k({},T.Grid),{gridTemplateColumns:`repeat(${((r=i.options)==null?void 0:r.picsPerRow)?i.options.picsPerRow:"3"}, 1fr)`}),children:i.imgList.map((e,n)=>{var t;return h("div",{className:"reactPic-imgDiv",style:{overflow:"hidden",width:"100%",height:"100%",minHeight:"150px"},children:h("div",{className:"reactPic-innerImgDiv",style:{display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden !important",width:"100%",height:((t=i.options)==null?void 0:t.rowHeight)?i.options.rowHeight:"150px",cursor:"pointer"},children:h(sn,{options:i.options,imgSrc:e.thumbnailSrc?e.thumbnailSrc:e.fullSrc,style:{flexShrink:0,minWidth:"100%",minHeight:"100%"},onClick:()=>i.onOpen(n)})})},e.thumbnailSrc?e.thumbnailSrc:e.fullSrc)})})}var dn=S.default.memo(un);const fn={downloadBtnDisplay:!0,descriptionBoxDisplay:!0,navigation:!0};function mn(i){var l;const[r,e]=S.default.useState(!1),[n,t]=S.default.useState(0),o=k(k({},fn),i.options);c.useEffect(()=>{typeof i.setExtLightboxChildren=="function"&&(r?i.setExtLightboxChildren(h(Ei,{imgObj:i.imgList[n],options:o,onClose:()=>{e(!1)}})):i.setExtLightboxChildren(void 0))},[r]);const a=c.useCallback(s=>{t(s),e(!0)},[]);return F("div",{className:"reactPic-wrapper",style:T.Wrapper,children:[r&&!((l=i.options)==null?void 0:l.externalLightbox)?h(Ei,{imgObj:i.imgList[n],topCustomContent:i.topCustomContent,bottomCustomContent:i.bottomCustomContent,options:o,onClose:()=>e(!1),onClickPrevious:n-1>=0?()=>t(n-1):void 0,onClickNext:n+1<i.imgList.length?()=>t(n+1):void 0}):null,h(dn,{options:i.options,imgList:i.imgList,onOpen:a})]})}var vn=S.default.memo(mn);return vn});
|
package/package.json
CHANGED
|
@@ -1,47 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-pic-gallery",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"react-scripts": "^3.4.1",
|
|
39
|
-
"typescript": "^4.2.4"
|
|
40
|
-
},
|
|
41
|
-
"files": [
|
|
42
|
-
"dist"
|
|
43
|
-
],
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"react-zoom-pan-pinch": "^1.6.1"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "react-pic-gallery",
|
|
3
|
+
"version": "1.5.2",
|
|
4
|
+
"author": "marcelrsoub",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "marcelrsoub/react-pic-gallery",
|
|
7
|
+
"main": "./dist/react-pic-gallery.umd.js",
|
|
8
|
+
"module": "./dist/react-pic-gallery.es.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/react-pic-gallery.es.js",
|
|
15
|
+
"require": "./dist/react-pic-gallery.umd.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite",
|
|
20
|
+
"build": "tsc && vite build",
|
|
21
|
+
"preview": "vite preview",
|
|
22
|
+
"github-pages": "gh-pages -d build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"react-zoom-pan-pinch": "^2.1.3"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"react": "^17.0.2",
|
|
29
|
+
"react-dom": "^17.0.2",
|
|
30
|
+
"@types/node": "^16.11.12",
|
|
31
|
+
"@types/react": "^17.0.33",
|
|
32
|
+
"@types/react-dom": "^17.0.10",
|
|
33
|
+
"@vitejs/plugin-react": "^1.0.7",
|
|
34
|
+
"typescript": "^4.4.4",
|
|
35
|
+
"vite": "^2.7.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function CircularLoading(): any;
|
package/dist/ImgLazyLoading.d.ts
DELETED
package/dist/ImgLightbox.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { imageObject, Options } from 'index';
|
|
2
|
-
declare const ImgLightbox: (props: {
|
|
3
|
-
imgObj: imageObject | null;
|
|
4
|
-
options?: Options;
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
onNavigation?: (arg0: 'next' | 'previous') => void;
|
|
7
|
-
hasPrevious?: boolean;
|
|
8
|
-
hasNext?: boolean;
|
|
9
|
-
}) => any;
|
|
10
|
-
export default ImgLightbox;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom/extend-expect';
|
package/dist/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface imageObject {
|
|
3
|
-
fullSrc: string;
|
|
4
|
-
thumbnailSrc?: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
[key: string]: string;
|
|
7
|
-
}
|
|
8
|
-
export interface Options {
|
|
9
|
-
downloadBtnDisplay?: boolean;
|
|
10
|
-
downloadCustomBtn?: (props: {
|
|
11
|
-
imgObj?: imageObject;
|
|
12
|
-
}) => React.ReactNode;
|
|
13
|
-
descriptionBoxDisplay?: boolean;
|
|
14
|
-
descriptionCustomBox?: (props: {
|
|
15
|
-
imgObj?: imageObject;
|
|
16
|
-
onClose?: () => void;
|
|
17
|
-
}) => React.ReactNode;
|
|
18
|
-
externalLightbox?: boolean;
|
|
19
|
-
hidePagination?: boolean;
|
|
20
|
-
rowHeight?: string | number;
|
|
21
|
-
}
|
|
22
|
-
export default function PicGallery(props: {
|
|
23
|
-
imgList: imageObject[];
|
|
24
|
-
options?: Options;
|
|
25
|
-
bottomCustomContent?: (imgObject: any) => Element;
|
|
26
|
-
setExtLightboxChildren?: (imgLightbox: React.Reacvagaha) => void;
|
|
27
|
-
}): any;
|
package/dist/index.modern.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch';
|
|
3
|
-
|
|
4
|
-
const extraStyle = `
|
|
5
|
-
.lds-dual-ring {
|
|
6
|
-
display: inline-block;
|
|
7
|
-
width: 40px;
|
|
8
|
-
height: 40px;
|
|
9
|
-
}
|
|
10
|
-
.lds-dual-ring:after {
|
|
11
|
-
content: " ";
|
|
12
|
-
display: block;
|
|
13
|
-
width: 32px;
|
|
14
|
-
height: 32px;
|
|
15
|
-
margin: 8px;
|
|
16
|
-
border-radius: 50%;
|
|
17
|
-
border: 3px solid rgba(185, 185, 185, 0.466);
|
|
18
|
-
border-color: rgba(185, 185, 185, 0.466) transparent rgba(185, 185, 185, 0.466) transparent;
|
|
19
|
-
animation: lds-dual-ring 1.2s linear infinite;
|
|
20
|
-
}
|
|
21
|
-
@keyframes lds-dual-ring {
|
|
22
|
-
0% {
|
|
23
|
-
transform: rotate(0deg);
|
|
24
|
-
}
|
|
25
|
-
100% {
|
|
26
|
-
transform: rotate(360deg);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
function CircularLoading() {
|
|
31
|
-
const styleTag = document.querySelector('#react-pic-style');
|
|
32
|
-
|
|
33
|
-
if (!styleTag) {
|
|
34
|
-
const sheet = document.createElement('style');
|
|
35
|
-
sheet.id = 'react-pic-style';
|
|
36
|
-
sheet.innerHTML = extraStyle;
|
|
37
|
-
document.body.appendChild(sheet);
|
|
38
|
-
} else {
|
|
39
|
-
styleTag.innerHTML = styleTag.innerHTML + extraStyle;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return React.createElement("div", {
|
|
43
|
-
className: 'lds-dual-ring'
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const ImgLazyLoading = props => {
|
|
48
|
-
const [imgSrcUrl, setImgSrcUrl] = React.useState('');
|
|
49
|
-
React.useEffect(() => {
|
|
50
|
-
const ac = new AbortController();
|
|
51
|
-
|
|
52
|
-
if (props.imgSrc) {
|
|
53
|
-
fetch(props.imgSrc).then(response => response.blob()).then(blob => {
|
|
54
|
-
setImgSrcUrl(URL.createObjectURL(blob));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return () => {
|
|
59
|
-
ac.abort();
|
|
60
|
-
};
|
|
61
|
-
}, [props.imgSrc]);
|
|
62
|
-
|
|
63
|
-
if (imgSrcUrl) {
|
|
64
|
-
return React.createElement("img", {
|
|
65
|
-
src: imgSrcUrl,
|
|
66
|
-
alt: '',
|
|
67
|
-
style: { ...props.style
|
|
68
|
-
},
|
|
69
|
-
onClick: () => {
|
|
70
|
-
props.onClick();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
return React.createElement("div", {
|
|
75
|
-
style: {
|
|
76
|
-
height: '100%',
|
|
77
|
-
width: '100%',
|
|
78
|
-
display: 'flex',
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
alignContent: 'center',
|
|
81
|
-
justifyContent: 'center',
|
|
82
|
-
background: 'rgba(0, 0, 0, 0.157)',
|
|
83
|
-
border: '1px solid rgba(0, 0, 0,0.3)'
|
|
84
|
-
}
|
|
85
|
-
}, React.createElement(CircularLoading, null));
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
let styles = {};
|
|
90
|
-
styles.ModalDiv = {
|
|
91
|
-
position: 'fixed',
|
|
92
|
-
top: 0,
|
|
93
|
-
left: 0,
|
|
94
|
-
width: '100%',
|
|
95
|
-
height: '100%',
|
|
96
|
-
background: `rgba(0, 0, 0, 0.454)`,
|
|
97
|
-
backdropFilter: 'blur(6px)',
|
|
98
|
-
zIndex: 9999999,
|
|
99
|
-
display: 'grid',
|
|
100
|
-
gridTemplateRows: '60px | auto | 300px',
|
|
101
|
-
justifyContent: 'center',
|
|
102
|
-
alignContent: 'center'
|
|
103
|
-
};
|
|
104
|
-
styles.LbButtonsDiv = {
|
|
105
|
-
position: 'absolute',
|
|
106
|
-
top: '10px',
|
|
107
|
-
width: 'calc(100% - 20px)'
|
|
108
|
-
};
|
|
109
|
-
styles.LbButton = {
|
|
110
|
-
float: 'right',
|
|
111
|
-
textDecoration: 'none',
|
|
112
|
-
color: 'white',
|
|
113
|
-
padding: '5px',
|
|
114
|
-
border: '1px solid white',
|
|
115
|
-
borderRadius: '5px'
|
|
116
|
-
};
|
|
117
|
-
styles.ABtn = {
|
|
118
|
-
float: 'right',
|
|
119
|
-
textDecoration: 'none',
|
|
120
|
-
color: 'white'
|
|
121
|
-
};
|
|
122
|
-
styles.DescriptionDiv = {
|
|
123
|
-
background: 'white',
|
|
124
|
-
padding: '10px',
|
|
125
|
-
color: '#666',
|
|
126
|
-
textAlign: 'center',
|
|
127
|
-
position: 'relative',
|
|
128
|
-
zIndex: -1
|
|
129
|
-
};
|
|
130
|
-
styles.Wrapper = {
|
|
131
|
-
display: 'flex',
|
|
132
|
-
width: '100%',
|
|
133
|
-
minWidth: 200,
|
|
134
|
-
height: '100%'
|
|
135
|
-
};
|
|
136
|
-
styles.Grid = {
|
|
137
|
-
display: 'grid',
|
|
138
|
-
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
139
|
-
gridTemplateRows: '1fr',
|
|
140
|
-
gap: '2px',
|
|
141
|
-
width: '100%',
|
|
142
|
-
height: 'auto'
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const ImgLightbox = props => {
|
|
146
|
-
var _props$options, _props$options2, _props$options3, _props$imgObj3, _props$imgObj4, _props$imgObj5;
|
|
147
|
-
|
|
148
|
-
const [imgSrcUrl, setImgSrcUrl] = React.useState('');
|
|
149
|
-
const DescriptionCustomBox = props.options.descriptionCustomBox;
|
|
150
|
-
React.useEffect(() => {
|
|
151
|
-
var _props$imgObj, _props$imgObj2;
|
|
152
|
-
|
|
153
|
-
const imgSrc = (_props$imgObj = props.imgObj) !== null && _props$imgObj !== void 0 && _props$imgObj.fullSrc ? props.imgObj.fullSrc : (_props$imgObj2 = props.imgObj) !== null && _props$imgObj2 !== void 0 && _props$imgObj2.thumbnailSrc ? props.imgObj.thumbnailSrc : null;
|
|
154
|
-
|
|
155
|
-
if (imgSrc) {
|
|
156
|
-
fetch(imgSrc).then(response => response.blob()).then(blob => {
|
|
157
|
-
setImgSrcUrl(URL.createObjectURL(blob));
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
document.body.style.overflow = 'hidden';
|
|
162
|
-
}, [props.imgObj]);
|
|
163
|
-
return React.createElement("div", {
|
|
164
|
-
className: 'reactPic-lightbox',
|
|
165
|
-
onClick: event => {
|
|
166
|
-
document.body.style.overflow = '';
|
|
167
|
-
const target = event.target;
|
|
168
|
-
|
|
169
|
-
if (target.className === 'reactPic-lightbox') {
|
|
170
|
-
props.onClose();
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
style: styles.ModalDiv
|
|
174
|
-
}, React.createElement("div", {
|
|
175
|
-
style: styles.LbButtonsDiv
|
|
176
|
-
}, (_props$options = props.options) !== null && _props$options !== void 0 && _props$options.downloadBtnDisplay || (_props$options2 = props.options) !== null && _props$options2 !== void 0 && _props$options2.downloadCustomBtn ? props.options.downloadCustomBtn ? React.createElement("a", {
|
|
177
|
-
href: imgSrcUrl,
|
|
178
|
-
download: true,
|
|
179
|
-
style: styles.ABtn
|
|
180
|
-
}, props.options.downloadCustomBtn) : React.createElement("a", {
|
|
181
|
-
href: imgSrcUrl,
|
|
182
|
-
download: true,
|
|
183
|
-
style: styles.LbButton
|
|
184
|
-
}, "Download") : null), imgSrcUrl === '' ? React.createElement("div", {
|
|
185
|
-
style: {
|
|
186
|
-
display: 'block',
|
|
187
|
-
margin: 'auto'
|
|
188
|
-
}
|
|
189
|
-
}, React.createElement(CircularLoading, null)) : React.createElement("div", null, React.createElement(TransformWrapper, {
|
|
190
|
-
defaultScale: 1,
|
|
191
|
-
options: {
|
|
192
|
-
limitToBounds: true,
|
|
193
|
-
limitToWrapper: true,
|
|
194
|
-
transformEnabled: true,
|
|
195
|
-
centerContent: true
|
|
196
|
-
}
|
|
197
|
-
}, React.createElement(TransformComponent, null, React.createElement("img", {
|
|
198
|
-
src: imgSrcUrl,
|
|
199
|
-
alt: '',
|
|
200
|
-
id: 'lightboxImg',
|
|
201
|
-
style: {
|
|
202
|
-
maxWidth: '80vw',
|
|
203
|
-
maxHeight: 'calc(80vh - 20px)',
|
|
204
|
-
margin: 'auto',
|
|
205
|
-
zIndex: 99999999999
|
|
206
|
-
}
|
|
207
|
-
})), (_props$options3 = props.options) !== null && _props$options3 !== void 0 && _props$options3.descriptionBoxDisplay ? (_props$imgObj3 = props.imgObj) !== null && _props$imgObj3 !== void 0 && _props$imgObj3.description || DescriptionCustomBox ? DescriptionCustomBox ? React.createElement(DescriptionCustomBox, {
|
|
208
|
-
imgObj: props.imgObj,
|
|
209
|
-
onClose: props.onClose
|
|
210
|
-
}, (_props$imgObj4 = props.imgObj) === null || _props$imgObj4 === void 0 ? void 0 : _props$imgObj4.description) : React.createElement("div", {
|
|
211
|
-
className: 'reactPic-description',
|
|
212
|
-
style: styles.DescriptionDiv
|
|
213
|
-
}, (_props$imgObj5 = props.imgObj) === null || _props$imgObj5 === void 0 ? void 0 : _props$imgObj5.description) : null : null), props.hasPrevious && React.createElement("div", {
|
|
214
|
-
className: "react-lightbox-prevBtn",
|
|
215
|
-
style: {
|
|
216
|
-
position: 'absolute',
|
|
217
|
-
left: 20,
|
|
218
|
-
top: '50%',
|
|
219
|
-
fontSize: 50,
|
|
220
|
-
cursor: 'pointer',
|
|
221
|
-
color: 'white',
|
|
222
|
-
display: props.options.hidePagination ? 'none' : 'inherit'
|
|
223
|
-
},
|
|
224
|
-
onClick: () => {
|
|
225
|
-
props.onNavigation('previous');
|
|
226
|
-
}
|
|
227
|
-
}, "\u2039"), props.hasNext && React.createElement("div", {
|
|
228
|
-
className: "react-lightbox-nextBtn",
|
|
229
|
-
style: {
|
|
230
|
-
position: 'absolute',
|
|
231
|
-
right: 20,
|
|
232
|
-
top: '50%',
|
|
233
|
-
fontSize: 50,
|
|
234
|
-
cursor: 'pointer',
|
|
235
|
-
color: 'white',
|
|
236
|
-
display: props.options.hidePagination ? 'none' : 'inherit'
|
|
237
|
-
},
|
|
238
|
-
onClick: () => {
|
|
239
|
-
props.onNavigation('next');
|
|
240
|
-
}
|
|
241
|
-
}, "\u203A")));
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
const extraStyle$1 = `
|
|
245
|
-
`;
|
|
246
|
-
const defaultOptions = {
|
|
247
|
-
downloadBtnDisplay: true,
|
|
248
|
-
descriptionBoxDisplay: true,
|
|
249
|
-
navigation: true
|
|
250
|
-
};
|
|
251
|
-
function PicGallery(props) {
|
|
252
|
-
const [open, setOpen] = React.useState(false);
|
|
253
|
-
const [modalImgIndex, setModalImgIndex] = React.useState(0);
|
|
254
|
-
const options = { ...defaultOptions,
|
|
255
|
-
...props.options
|
|
256
|
-
};
|
|
257
|
-
useEffect(() => {
|
|
258
|
-
if (typeof props.setExtLightboxChildren == 'function') {
|
|
259
|
-
if (open) {
|
|
260
|
-
props.setExtLightboxChildren(React.createElement(ImgLightbox, {
|
|
261
|
-
imgObj: props.imgList[modalImgIndex],
|
|
262
|
-
options: options,
|
|
263
|
-
onClose: () => {
|
|
264
|
-
setOpen(false);
|
|
265
|
-
}
|
|
266
|
-
}));
|
|
267
|
-
} else {
|
|
268
|
-
props.setExtLightboxChildren(null);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}, [open]);
|
|
272
|
-
const styleTag = document.querySelector('#react-pic-style');
|
|
273
|
-
|
|
274
|
-
if (!styleTag) {
|
|
275
|
-
const sheet = document.createElement('style');
|
|
276
|
-
sheet.innerHTML = '.react-transform-component { overflow: unset !important; }' + extraStyle$1;
|
|
277
|
-
sheet.id = 'react-pic-style';
|
|
278
|
-
document.body.appendChild(sheet);
|
|
279
|
-
} else {
|
|
280
|
-
styleTag.innerHTML = styleTag.innerHTML + extraStyle$1;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return React.createElement("div", {
|
|
284
|
-
className: 'reactPic-wrapper',
|
|
285
|
-
style: styles.Wrapper
|
|
286
|
-
}, open && !props.options.externalLightbox ? React.createElement(ImgLightbox, {
|
|
287
|
-
imgObj: props.imgList[modalImgIndex],
|
|
288
|
-
options: options,
|
|
289
|
-
onNavigation: action => {
|
|
290
|
-
if (action === 'next' && modalImgIndex + 1 < props.imgList.length) {
|
|
291
|
-
setModalImgIndex(modalImgIndex + 1);
|
|
292
|
-
} else if (action === 'previous' && modalImgIndex - 1 >= 0) {
|
|
293
|
-
setModalImgIndex(modalImgIndex - 1);
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
onClose: () => {
|
|
297
|
-
setOpen(false);
|
|
298
|
-
},
|
|
299
|
-
hasPrevious: modalImgIndex - 1 >= 0 ? true : false,
|
|
300
|
-
hasNext: modalImgIndex + 1 < props.imgList.length ? true : false
|
|
301
|
-
}) : null, React.createElement("div", {
|
|
302
|
-
className: 'reactPic-grid',
|
|
303
|
-
style: styles.Grid
|
|
304
|
-
}, props.imgList.map((element, count) => {
|
|
305
|
-
return React.createElement("div", {
|
|
306
|
-
key: element.thumbnailSrc ? element.thumbnailSrc : element.fullSrc,
|
|
307
|
-
className: 'reactPic-imgDiv',
|
|
308
|
-
style: {
|
|
309
|
-
overflow: 'hidden',
|
|
310
|
-
width: '100%',
|
|
311
|
-
height: '100%',
|
|
312
|
-
minHeight: '150px'
|
|
313
|
-
}
|
|
314
|
-
}, React.createElement("div", {
|
|
315
|
-
className: 'reactPic-innerImgDiv',
|
|
316
|
-
style: {
|
|
317
|
-
display: 'flex',
|
|
318
|
-
justifyContent: 'center',
|
|
319
|
-
alignItems: 'center',
|
|
320
|
-
overflow: 'hidden !important',
|
|
321
|
-
width: '100%',
|
|
322
|
-
height: options.rowHeight ? options.rowHeight : '150px',
|
|
323
|
-
cursor: 'pointer'
|
|
324
|
-
}
|
|
325
|
-
}, React.createElement(ImgLazyLoading, {
|
|
326
|
-
imgSrc: element.thumbnailSrc ? element.thumbnailSrc : element.fullSrc,
|
|
327
|
-
style: {
|
|
328
|
-
flexShrink: 0,
|
|
329
|
-
minWidth: '100%',
|
|
330
|
-
minHeight: '100%'
|
|
331
|
-
},
|
|
332
|
-
onClick: () => {
|
|
333
|
-
setModalImgIndex(count);
|
|
334
|
-
setOpen(!open);
|
|
335
|
-
}
|
|
336
|
-
})));
|
|
337
|
-
})));
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export default PicGallery;
|
|
341
|
-
//# sourceMappingURL=index.modern.js.map
|