Socket
Socket
Sign inDemoInstall

@mohalla-tech/react-swipeable-wrapper

Package Overview
Dependencies
4
Maintainers
14
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.3 to 1.1.4

30

dist/index.es.js

@@ -1447,3 +1447,4 @@ var __defProp = Object.defineProperty;

containerStyles,
disableAutoScroll
disableAutoScroll,
disableAutoAdjustHeight
}, ref) => {

@@ -1467,3 +1468,3 @@ const elementRef = useRef(null);

} = elementRef;
if (el) {
if (el && !disableAutoAdjustHeight && el.children.length > 0) {
el.children[prevIndex].style.height = `${totalHeight.current}px`;

@@ -1475,3 +1476,3 @@ el.children[currIndex].style.height = "auto";

}
}, [disableAutoScroll, onSlideChange, rAF]);
}, [disableAutoAdjustHeight, disableAutoScroll, onSlideChange, rAF]);
const swipeToIndex = useCallback((slideToIndex, avoidAnimation = false) => {

@@ -1552,8 +1553,10 @@ rAF(() => {

totalWidth.current = Math.min(el.parentElement.offsetWidth, window.innerWidth);
totalHeight.current = window.innerHeight - Math.max(el.offsetTop, el.clientTop);
for (let i = 0; i < children.length; i += 1) {
el.children[i].style.height = initialIndex === i ? "auto" : `${totalHeight.current}px`;
if (!disableAutoAdjustHeight) {
totalHeight.current = window.innerHeight - Math.max(el.offsetTop, el.clientTop);
for (let i = 0; i < children.length; i += 1) {
el.children[i].style.height = initialIndex === i ? "auto" : `${totalHeight.current}px`;
}
}
}
}, [children.length, initialIndex]);
}, [children.length, disableAutoAdjustHeight, initialIndex]);
useLayoutEffect(() => {

@@ -1599,6 +1602,7 @@ swipeToIndex(initialIndex, true);

children: children.map((child, loopIndex) => /* @__PURE__ */ jsx("div", {
style: {
width: `${100 / children.length}%`,
style: __spreadValues({
width: `${100 / children.length}%`
}, !disableAutoAdjustHeight ? {
willChange: "height"
},
} : {}),
children: child

@@ -1620,3 +1624,4 @@ }, `tabs-${loopIndex}`))

containerStyles: PropTypes.shape({}),
disableAutoScroll: PropTypes.bool
disableAutoScroll: PropTypes.bool,
disableAutoAdjustHeight: PropTypes.bool
};

@@ -1634,5 +1639,6 @@ SwipeableWrapper.defaultProps = {

containerStyles: {},
disableAutoScroll: false
disableAutoScroll: false,
disableAutoAdjustHeight: false
};
var SwipeableWrapper$1 = memo(SwipeableWrapper);
export { SwipeableWrapper$1 as default };

6

dist/index.umd.js

@@ -1,6 +0,6 @@

var Ae=Object.defineProperty,Ce=Object.defineProperties;var Ie=Object.getOwnPropertyDescriptors;var wt=Object.getOwnPropertySymbols;var je=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var Tt=(u,g,T)=>g in u?Ae(u,g,{enumerable:!0,configurable:!0,writable:!0,value:T}):u[g]=T,J=(u,g)=>{for(var T in g||(g={}))je.call(g,T)&&Tt(u,T,g[T]);if(wt)for(var T of wt(g))Le.call(g,T)&&Tt(u,T,g[T]);return u},Et=(u,g)=>Ce(u,Ie(g));(function(u,g){typeof exports=="object"&&typeof module!="undefined"?module.exports=g(require("react")):typeof define=="function"&&define.amd?define(["react"],g):(u=typeof globalThis!="undefined"?globalThis:u||self,u["react-swipeable-wrapper"]=g(u.react))})(this,function(u){"use strict";function g(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function T(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var F=g(u),j=T(u),Q={exports:{}},Ot="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",St=Ot,kt=St;function Z(){}function tt(){}tt.resetWarningCache=Z;var Pt=function(){function e(r,s,i,a,o,f){if(f!==kt){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:tt,resetWarningCache:Z};return n.PropTypes=n,n};Q.exports=Pt();var v=Q.exports;function xt(e,t,n){return Math.max(t,Math.min(e,n))}const _={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function et(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function nt(e,t,n,r=.15){return r===0?xt(e,t,n):e<t?-et(t-e,n-t,r)+t:e>n?+et(e-n,n-t,r)+n:e}function Dt(e,[t,n],[r,s]){const[[i,a],[o,f]]=e;return[nt(t,i,a,r),nt(n,o,f,s)]}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?rt(Object(n),!0).forEach(function(r){w(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const st={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function it(e){return e?e[0].toUpperCase()+e.slice(1):""}function At(e,t="",n=!1){const r=st[e],s=r&&r[t]||t;return"on"+it(e)+it(s)+(n?"Capture":"")}const Ct=["gotpointercapture","lostpointercapture"];function It(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=Ct.includes(t)?"capturecapture":"capture",s=!!~t.indexOf(r);return s&&(t=t.replace("capture","")),{device:t,capture:s,passive:n}}function jt(e,t=""){const n=st[e],r=n&&n[t]||t;return e+r}function W(e){return"touches"in e}function Lt(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function Mt(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function ot(e){return W(e)?Mt(e)[0]:e}function Rt(e){return Lt(e).map(t=>t.identifier)}function Y(e){const t=ot(e);return W(e)?t.identifier:t.pointerId}function at(e){const t=ot(e);return[t.clientX,t.clientY]}function Ut(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i})}return t}function K(e,...t){return typeof e=="function"?e(...t):e}function Ft(){}function Kt(...e){return e.length===0?Ft:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function ct(e,t){return Object.assign({},t,e||{})}const Nt=32;class Vt{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:s}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=s,t.axis=void 0,t.memo=void 0,t.elapsedTime=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?K(r.from,n):n.offset,n.offset=n.lastOffset),n.startTime=n.timeStamp=t.timeStamp}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:s}=this;n.args=this.args;let i=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ut(t)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const m=n._delta.map(Math.abs);_.addTo(n._distance,m)}const[a,o]=n._movement,[f,h]=r.threshold,{_step:c,values:l}=n;if(r.hasCustomTransform?(c[0]===!1&&(c[0]=Math.abs(a)>=f&&l[0]),c[1]===!1&&(c[1]=Math.abs(o)>=h&&l[1])):(c[0]===!1&&(c[0]=Math.abs(a)>=f&&Math.sign(a)*f),c[1]===!1&&(c[1]=Math.abs(o)>=h&&Math.sign(o)*h)),n.intentional=c[0]!==!1||c[1]!==!1,!n.intentional)return;const y=[0,0];if(r.hasCustomTransform){const[m,A]=l;y[0]=c[0]!==!1?m-c[0]:0,y[1]=c[1]!==!1?A-c[1]:0}else y[0]=c[0]!==!1?a-c[0]:0,y[1]=c[1]!==!1?o-c[1]:0;this.intent&&this.intent(y);const O=n.offset,k=n._active&&!n._blocked||n.active;k&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=s[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=K(r.bounds,n)),this.setup&&this.setup()),n.movement=y,this.computeOffset()));const[S,P]=n.offset,[[x,G],[I,d]]=n._bounds;n.overflow=[S<x?-1:S>G?1:0,P<I?-1:P>d?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const b=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=Dt(n._bounds,n.offset,b),n.delta=_.sub(n.offset,O),this.computeMovement(),k&&(!n.last||i>Nt)){n.delta=_.sub(n.offset,O);const m=n.delta.map(Math.abs);_.addTo(n.distance,m),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&i>0&&(n.velocity=[m[0]/i,m[1]/i])}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const s=this.handler(p(p(p({},n),t),{},{[this.aliasKey]:t.values}));s!==void 0&&(t.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function $t([e,t]){const n=Math.abs(e)-Math.abs(t);if(n>0)return"x";if(n<0)return"y"}function Bt(e,t){switch(t){case"x":e[1]=0;break;case"y":e[0]=0;break}}class Wt extends Vt{constructor(...t){super(...t);w(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=_.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=_.sub(this.state.offset,this.state.lastOffset)}intent(t){this.state.axis=this.state.axis||$t(t),this.state._blocked=(this.config.lockDirection||!!this.config.axis)&&!this.state.axis||!!this.config.axis&&this.config.axis!==this.state.axis,!this.state._blocked&&(this.config.axis||this.config.lockDirection)&&Bt(t,this.state.axis)}}const Yt=e=>e,ut=.15,ft={enabled(e=!0){return e},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[ut,ut];case!1:return[0,0];default:return _.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return _.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||Yt},threshold(e){return _.toVector(e,0)}},L=p(p({},ft),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},bounds(e={}){if(typeof e=="function")return i=>L.bounds(e(i));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:s=1/0}=e;return[[t,n],[r,s]]}}),N=10,lt={ArrowRight:(e=1)=>[N*e,0],ArrowLeft:(e=1)=>[-N*e,0],ArrowUp:(e=1)=>[0,-N*e],ArrowDown:(e=1)=>[0,N*e]};class qt extends Wt{constructor(...t){super(...t);w(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),s={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=L.bounds(s)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons)||(this.ctrl.setEventIds(t),n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!r._pointerActive&&(this.start(t),this.setupPointer(t),r._pointerId=Y(t),r._pointerActive=!0,this.computeValues(at(t)),this.computeInitial(),n.preventScrollAxis?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?this.setupDelayTrigger(t):this.startPointerDrag(t)))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive||n.type===t.type&&t.timeStamp===n.timeStamp)return;const s=Y(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;const i=at(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=_.sub(i,n._values),this.computeValues(i)),_.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const s=Y(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[i,a]=n._distance;if(n.tap=i<=r.tapsThreshold&&a<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[o,f]=n.direction,[h,c]=n.velocity,[l,y]=n.movement,[O,k]=r.swipe.velocity,[S,P]=r.swipe.distance,x=r.swipe.duration;n.elapsedTime<x&&(Math.abs(h)>O&&Math.abs(l)>S&&(n.swipe[0]=o),Math.abs(c)>k&&Math.abs(y)>P&&(n.swipe[1]=f))}this.emit()}pointerClick(t){this.state.tap||(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){zt(t),this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1}),this.eventStore.add(this.sharedConfig.window,"touch","end",this.clean.bind(this)),this.eventStore.add(this.sharedConfig.window,"touch","cancel",this.clean.bind(this)),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=lt[t.key];if(n){const r=this.state,s=t.shiftKey?10:t.altKey?.1:1;r._delta=n(s),this.start(t),r._keyboardActive=!0,_.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in lt&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this)),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function zt(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const M=typeof window!="undefined"&&window.document&&window.document.createElement;function Ht(){return M&&"ontouchstart"in window}function ht(){return Ht()||M&&window.navigator.maxTouchPoints>1}function Xt(){return M&&"onpointerdown"in window}function Gt(){return M&&"exitPointerLock"in window.document}function Jt(){try{return"constructor"in GestureEvent}catch{return!1}}const E={isBrowser:M,gesture:Jt(),touch:ht(),touchscreen:ht(),pointer:Xt(),pointerLock:Gt()},Qt=250,Zt=180,te=.5,ee=50,ne=250,re=p(p({},L),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&E.pointerLock,E.touch&&n?"touch":this.pointerLock?"mouse":E.pointer&&!s?"pointer":E.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?Qt:void 0,!(!E.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1}={}}){return this.pointerButtons=r,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:s=void 0}){const i=_.toVector(e,n?r:s?1:0);return this.filterTaps=n,this.tapsThreshold=r,i},swipe({velocity:e=te,distance:t=ee,duration:n=ne}={}){return{velocity:this.transform(_.toVector(e)),distance:this.transform(_.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return Zt;case!1:return 0;default:return e}}});p(p({},ft),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!E.touch&&E.gesture)return"gesture";if(E.touch&&r)return"touch";if(E.touchscreen){if(E.pointer)return"pointer";if(E.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const s=a=>{const o=ct(K(n,a),{min:-1/0,max:1/0});return[o.min,o.max]},i=a=>{const o=ct(K(r,a),{min:-1/0,max:1/0});return[o.min,o.max]};return typeof n!="function"&&typeof r!="function"?[s(),i()]:a=>[s(a),i(a)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",_.toVector(e,this.lockDirection?[.1,3]:0)}}),p(p({},L),{},{mouseOnly:(e=!0)=>e}),p(p({},L),{},{mouseOnly:(e=!0)=>e});const dt=new Map,q=new Map;function se(e){dt.set(e.key,e.engine),q.set(e.key,e.resolver)}const ie={key:"drag",engine:qt,resolver:re};function oe(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function ae(e,t){if(e==null)return{};var n=oe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,r)||(n[r]=e[r]))}return n}const ce={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=E.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},ue=["target","eventOptions","window","enabled","transform"];function V(e={},t){const n={};for(const[r,s]of Object.entries(t))switch(typeof s){case"function":n[r]=s.call(n,e[r],r,e);break;case"object":n[r]=V(e[r],s);break;case"boolean":s&&(n[r]=e[r]);break}return n}function fe(e,t){const n=e,{target:r,eventOptions:s,window:i,enabled:a,transform:o}=n,f=ae(n,ue),h={shared:V({target:r,eventOptions:s,window:i,enabled:a,transform:o},ce)};if(t){const c=q.get(t);h[t]=V(p({shared:h.shared},f),c)}else for(const c in f){const l=q.get(c);l&&(h[c]=V(p({shared:h.shared},f[c]),l))}return h}class pt{constructor(t){w(this,"_listeners",[]),this._ctrl=t}add(t,n,r,s,i){const a=jt(n,r),o=p(p({},this._ctrl.config.shared.eventOptions),i);t.addEventListener(a,s,o),this._listeners.push(()=>t.removeEventListener(a,s,o))}clean(){this._listeners.forEach(t=>t()),this._listeners=[]}}class le{constructor(){w(this,"_timeouts",new Map)}add(t,n,r=140,...s){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...s))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class he{constructor(t){w(this,"gestures",new Set),w(this,"_targetEventStore",new pt(this)),w(this,"gestureEventStores",{}),w(this,"gestureTimeoutStores",{}),w(this,"handlers",{}),w(this,"config",{}),w(this,"pointerIds",new Set),w(this,"touchIds",new Set),w(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),de(this,t)}setEventIds(t){W(t)?this.touchIds=new Set(Rt(t)):"pointerId"in t&&(t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId))}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=fe(t,n)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r=n.eventOptions,s={};let i;if(n.target&&(i=n.target(),!i))return;const a=pe(s,r,!!i);if(n.enabled){for(const o of this.gestures)if(this.config[o].enabled){const f=dt.get(o);new f(this,t,o).bind(a)}for(const o in this.nativeHandlers)a(o,"",f=>this.nativeHandlers[o](p(p({},this.state.shared),{},{event:f,args:t})),void 0,!0)}for(const o in s)s[o]=Kt(...s[o]);if(!i)return s;for(const o in s){const{device:f,capture:h,passive:c}=It(o);this._targetEventStore.add(i,f,"",s[o],{capture:h,passive:c})}}}function C(e,t){e.gestures.add(t),e.gestureEventStores[t]=new pt(e),e.gestureTimeoutStores[t]=new le}function de(e,t){t.drag&&C(e,"drag"),t.wheel&&C(e,"wheel"),t.scroll&&C(e,"scroll"),t.move&&C(e,"move"),t.pinch&&C(e,"pinch"),t.hover&&C(e,"hover")}const pe=(e,t,n)=>(r,s,i,a={},o=!1)=>{var f,h;const c=(f=a.capture)!==null&&f!==void 0?f:t.capture,l=(h=a.passive)!==null&&h!==void 0?h:t.passive;let y=o?r:At(r,s,c);n&&l&&(y+="Passive"),e[y]=e[y]||[],e[y].push(i)};function me(e,t={},n,r){const s=F.default.useMemo(()=>new he(e),[]);if(s.applyHandlers(e,r),s.applyConfig(t,n),F.default.useEffect(s.effect.bind(s)),F.default.useEffect(()=>s.clean.bind(s),[]),t.target===void 0)return s.bind.bind(s)}function ge(e,t={}){return se(ie),me({drag:e},t,"drag")}const ye=typeof window!="undefined"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame:e=>setTimeout(e,16),_e=()=>{const e=j.useRef(null),t=j.useCallback(n=>{cancelAnimationFrame(e.current),e.current=ye(n)},[]);return j.useEffect(()=>()=>{cancelAnimationFrame(e.current)},[]),t},z=typeof window!="undefined"&&window.document&&window.document.createElement?j.useLayoutEffect:j.useEffect;var mt={exports:{}},R={};/*
var Ce=Object.defineProperty,Ie=Object.defineProperties;var je=Object.getOwnPropertyDescriptors;var Tt=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var Et=(u,g,T)=>g in u?Ce(u,g,{enumerable:!0,configurable:!0,writable:!0,value:T}):u[g]=T,Y=(u,g)=>{for(var T in g||(g={}))Le.call(g,T)&&Et(u,T,g[T]);if(Tt)for(var T of Tt(g))Me.call(g,T)&&Et(u,T,g[T]);return u},Ot=(u,g)=>Ie(u,je(g));(function(u,g){typeof exports=="object"&&typeof module!="undefined"?module.exports=g(require("react")):typeof define=="function"&&define.amd?define(["react"],g):(u=typeof globalThis!="undefined"?globalThis:u||self,u["react-swipeable-wrapper"]=g(u.react))})(this,function(u){"use strict";function g(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function T(e){if(e&&e.__esModule)return e;var t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var K=g(u),j=T(u),Z={exports:{}},St="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",kt=St,Pt=kt;function tt(){}function et(){}et.resetWarningCache=tt;var xt=function(){function e(r,s,i,a,o,l){if(l!==Pt){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:et,resetWarningCache:tt};return n.PropTypes=n,n};Z.exports=xt();var b=Z.exports;function Dt(e,t,n){return Math.max(t,Math.min(e,n))}const _={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function nt(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function rt(e,t,n,r=.15){return r===0?Dt(e,t,n):e<t?-nt(t-e,n-t,r)+t:e>n?+nt(e-n,n-t,r)+n:e}function At(e,[t,n],[r,s]){const[[i,a],[o,l]]=e;return[rt(t,i,a,r),rt(n,o,l,s)]}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function st(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function m(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?st(Object(n),!0).forEach(function(r){v(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):st(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const it={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ot(e){return e?e[0].toUpperCase()+e.slice(1):""}function Ct(e,t="",n=!1){const r=it[e],s=r&&r[t]||t;return"on"+ot(e)+ot(s)+(n?"Capture":"")}const It=["gotpointercapture","lostpointercapture"];function jt(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=It.includes(t)?"capturecapture":"capture",s=!!~t.indexOf(r);return s&&(t=t.replace("capture","")),{device:t,capture:s,passive:n}}function Lt(e,t=""){const n=it[e],r=n&&n[t]||t;return e+r}function q(e){return"touches"in e}function Mt(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function Rt(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function at(e){return q(e)?Rt(e)[0]:e}function Ut(e){return Mt(e).map(t=>t.identifier)}function z(e){const t=at(e);return q(e)?t.identifier:t.pointerId}function ct(e){const t=at(e);return[t.clientX,t.clientY]}function Ft(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:s,ctrlKey:i})}return t}function N(e,...t){return typeof e=="function"?e(...t):e}function Kt(){}function Nt(...e){return e.length===0?Kt:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function ut(e,t){return Object.assign({},t,e||{})}const Vt=32;class $t{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:s}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=s,t.axis=void 0,t.memo=void 0,t.elapsedTime=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?N(r.from,n):n.offset,n.offset=n.lastOffset),n.startTime=n.timeStamp=t.timeStamp}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:s}=this;n.args=this.args;let i=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ft(t)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const p=n._delta.map(Math.abs);_.addTo(n._distance,p)}const[a,o]=n._movement,[l,h]=r.threshold,{_step:c,values:y}=n;if(r.hasCustomTransform?(c[0]===!1&&(c[0]=Math.abs(a)>=l&&y[0]),c[1]===!1&&(c[1]=Math.abs(o)>=h&&y[1])):(c[0]===!1&&(c[0]=Math.abs(a)>=l&&Math.sign(a)*l),c[1]===!1&&(c[1]=Math.abs(o)>=h&&Math.sign(o)*h)),n.intentional=c[0]!==!1||c[1]!==!1,!n.intentional)return;const f=[0,0];if(r.hasCustomTransform){const[p,w]=y;f[0]=c[0]!==!1?p-c[0]:0,f[1]=c[1]!==!1?w-c[1]:0}else f[0]=c[0]!==!1?a-c[0]:0,f[1]=c[1]!==!1?o-c[1]:0;this.intent&&this.intent(f);const k=n.offset,O=n._active&&!n._blocked||n.active;O&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=s[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=N(r.bounds,n)),this.setup&&this.setup()),n.movement=f,this.computeOffset()));const[P,S]=n.offset,[[D,C],[Q,I]]=n._bounds;n.overflow=[P<D?-1:P>C?1:0,S<Q?-1:S>I?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const d=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=At(n._bounds,n.offset,d),n.delta=_.sub(n.offset,k),this.computeMovement(),O&&(!n.last||i>Vt)){n.delta=_.sub(n.offset,k);const p=n.delta.map(Math.abs);_.addTo(n.distance,p),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&i>0&&(n.velocity=[p[0]/i,p[1]/i])}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const s=this.handler(m(m(m({},n),t),{},{[this.aliasKey]:t.values}));s!==void 0&&(t.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Bt([e,t]){const n=Math.abs(e)-Math.abs(t);if(n>0)return"x";if(n<0)return"y"}function Wt(e,t){switch(t){case"x":e[1]=0;break;case"y":e[0]=0;break}}class Yt extends $t{constructor(...t){super(...t);v(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=_.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=_.sub(this.state.offset,this.state.lastOffset)}intent(t){this.state.axis=this.state.axis||Bt(t),this.state._blocked=(this.config.lockDirection||!!this.config.axis)&&!this.state.axis||!!this.config.axis&&this.config.axis!==this.state.axis,!this.state._blocked&&(this.config.axis||this.config.lockDirection)&&Wt(t,this.state.axis)}}const qt=e=>e,ft=.15,lt={enabled(e=!0){return e},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[ft,ft];case!1:return[0,0];default:return _.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return _.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||qt},threshold(e){return _.toVector(e,0)}},L=m(m({},lt),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},bounds(e={}){if(typeof e=="function")return i=>L.bounds(e(i));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:s=1/0}=e;return[[t,n],[r,s]]}}),V=10,ht={ArrowRight:(e=1)=>[V*e,0],ArrowLeft:(e=1)=>[-V*e,0],ArrowUp:(e=1)=>[0,-V*e],ArrowDown:(e=1)=>[0,V*e]};class zt extends Yt{constructor(...t){super(...t);v(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),s={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=L.bounds(s)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons)||(this.ctrl.setEventIds(t),n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!r._pointerActive&&(this.start(t),this.setupPointer(t),r._pointerId=z(t),r._pointerActive=!0,this.computeValues(ct(t)),this.computeInitial(),n.preventScrollAxis?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?this.setupDelayTrigger(t):this.startPointerDrag(t)))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive||n.type===t.type&&t.timeStamp===n.timeStamp)return;const s=z(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;const i=ct(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=_.sub(i,n._values),this.computeValues(i)),_.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const s=z(t);if(n._pointerId!==void 0&&s!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[i,a]=n._distance;if(n.tap=i<=r.tapsThreshold&&a<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[o,l]=n.direction,[h,c]=n.velocity,[y,f]=n.movement,[k,O]=r.swipe.velocity,[P,S]=r.swipe.distance,D=r.swipe.duration;n.elapsedTime<D&&(Math.abs(h)>k&&Math.abs(y)>P&&(n.swipe[0]=o),Math.abs(c)>O&&Math.abs(f)>S&&(n.swipe[1]=l))}this.emit()}pointerClick(t){this.state.tap||(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){Ht(t),this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1}),this.eventStore.add(this.sharedConfig.window,"touch","end",this.clean.bind(this)),this.eventStore.add(this.sharedConfig.window,"touch","cancel",this.clean.bind(this)),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=ht[t.key];if(n){const r=this.state,s=t.shiftKey?10:t.altKey?.1:1;r._delta=n(s),this.start(t),r._keyboardActive=!0,_.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in ht&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this)),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Ht(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const M=typeof window!="undefined"&&window.document&&window.document.createElement;function Xt(){return M&&"ontouchstart"in window}function dt(){return Xt()||M&&window.navigator.maxTouchPoints>1}function Gt(){return M&&"onpointerdown"in window}function Jt(){return M&&"exitPointerLock"in window.document}function Qt(){try{return"constructor"in GestureEvent}catch{return!1}}const E={isBrowser:M,gesture:Qt(),touch:dt(),touchscreen:dt(),pointer:Gt(),pointerLock:Jt()},Zt=250,te=180,ee=.5,ne=50,re=250,se=m(m({},L),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:s=!1}={}}){return this.pointerLock=r&&E.pointerLock,E.touch&&n?"touch":this.pointerLock?"mouse":E.pointer&&!s?"pointer":E.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?Zt:void 0,!(!E.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1}={}}){return this.pointerButtons=r,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:s=void 0}){const i=_.toVector(e,n?r:s?1:0);return this.filterTaps=n,this.tapsThreshold=r,i},swipe({velocity:e=ee,distance:t=ne,duration:n=re}={}){return{velocity:this.transform(_.toVector(e)),distance:this.transform(_.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return te;case!1:return 0;default:return e}}});m(m({},lt),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!E.touch&&E.gesture)return"gesture";if(E.touch&&r)return"touch";if(E.touchscreen){if(E.pointer)return"pointer";if(E.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const s=a=>{const o=ut(N(n,a),{min:-1/0,max:1/0});return[o.min,o.max]},i=a=>{const o=ut(N(r,a),{min:-1/0,max:1/0});return[o.min,o.max]};return typeof n!="function"&&typeof r!="function"?[s(),i()]:a=>[s(a),i(a)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",_.toVector(e,this.lockDirection?[.1,3]:0)}}),m(m({},L),{},{mouseOnly:(e=!0)=>e}),m(m({},L),{},{mouseOnly:(e=!0)=>e});const pt=new Map,H=new Map;function ie(e){pt.set(e.key,e.engine),H.set(e.key,e.resolver)}const oe={key:"drag",engine:zt,resolver:se};function ae(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function ce(e,t){if(e==null)return{};var n=ae(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,r)||(n[r]=e[r]))}return n}const ue={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=E.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},fe=["target","eventOptions","window","enabled","transform"];function $(e={},t){const n={};for(const[r,s]of Object.entries(t))switch(typeof s){case"function":n[r]=s.call(n,e[r],r,e);break;case"object":n[r]=$(e[r],s);break;case"boolean":s&&(n[r]=e[r]);break}return n}function le(e,t){const n=e,{target:r,eventOptions:s,window:i,enabled:a,transform:o}=n,l=ce(n,fe),h={shared:$({target:r,eventOptions:s,window:i,enabled:a,transform:o},ue)};if(t){const c=H.get(t);h[t]=$(m({shared:h.shared},l),c)}else for(const c in l){const y=H.get(c);y&&(h[c]=$(m({shared:h.shared},l[c]),y))}return h}class mt{constructor(t){v(this,"_listeners",[]),this._ctrl=t}add(t,n,r,s,i){const a=Lt(n,r),o=m(m({},this._ctrl.config.shared.eventOptions),i);t.addEventListener(a,s,o),this._listeners.push(()=>t.removeEventListener(a,s,o))}clean(){this._listeners.forEach(t=>t()),this._listeners=[]}}class he{constructor(){v(this,"_timeouts",new Map)}add(t,n,r=140,...s){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...s))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class de{constructor(t){v(this,"gestures",new Set),v(this,"_targetEventStore",new mt(this)),v(this,"gestureEventStores",{}),v(this,"gestureTimeoutStores",{}),v(this,"handlers",{}),v(this,"config",{}),v(this,"pointerIds",new Set),v(this,"touchIds",new Set),v(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),pe(this,t)}setEventIds(t){q(t)?this.touchIds=new Set(Ut(t)):"pointerId"in t&&(t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId))}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=le(t,n)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r=n.eventOptions,s={};let i;if(n.target&&(i=n.target(),!i))return;const a=me(s,r,!!i);if(n.enabled){for(const o of this.gestures)if(this.config[o].enabled){const l=pt.get(o);new l(this,t,o).bind(a)}for(const o in this.nativeHandlers)a(o,"",l=>this.nativeHandlers[o](m(m({},this.state.shared),{},{event:l,args:t})),void 0,!0)}for(const o in s)s[o]=Nt(...s[o]);if(!i)return s;for(const o in s){const{device:l,capture:h,passive:c}=jt(o);this._targetEventStore.add(i,l,"",s[o],{capture:h,passive:c})}}}function A(e,t){e.gestures.add(t),e.gestureEventStores[t]=new mt(e),e.gestureTimeoutStores[t]=new he}function pe(e,t){t.drag&&A(e,"drag"),t.wheel&&A(e,"wheel"),t.scroll&&A(e,"scroll"),t.move&&A(e,"move"),t.pinch&&A(e,"pinch"),t.hover&&A(e,"hover")}const me=(e,t,n)=>(r,s,i,a={},o=!1)=>{var l,h;const c=(l=a.capture)!==null&&l!==void 0?l:t.capture,y=(h=a.passive)!==null&&h!==void 0?h:t.passive;let f=o?r:Ct(r,s,c);n&&y&&(f+="Passive"),e[f]=e[f]||[],e[f].push(i)};function ge(e,t={},n,r){const s=K.default.useMemo(()=>new de(e),[]);if(s.applyHandlers(e,r),s.applyConfig(t,n),K.default.useEffect(s.effect.bind(s)),K.default.useEffect(()=>s.clean.bind(s),[]),t.target===void 0)return s.bind.bind(s)}function ye(e,t={}){return ie(oe),ge({drag:e},t,"drag")}const _e=typeof window!="undefined"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame:e=>setTimeout(e,16),be=()=>{const e=j.useRef(null),t=j.useCallback(n=>{cancelAnimationFrame(e.current),e.current=_e(n)},[]);return j.useEffect(()=>()=>{cancelAnimationFrame(e.current)},[]),t},X=typeof window!="undefined"&&window.document&&window.document.createElement?j.useLayoutEffect:j.useEffect;var gt={exports:{}},R={};/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var gt=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;function we(e){if(e==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function Te(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de",Object.getOwnPropertyNames(e)[0]==="5")return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(i){return t[i]});if(r.join("")!=="0123456789")return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach(function(i){s[i]=i}),Object.keys(Object.assign({},s)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}Te();/** @license React v17.0.2
*/var yt=Object.getOwnPropertySymbols,ve=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;function Te(e){if(e==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function Ee(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de",Object.getOwnPropertyNames(e)[0]==="5")return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(i){return t[i]});if(r.join("")!=="0123456789")return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach(function(i){s[i]=i}),Object.keys(Object.assign({},s)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}Ee();/** @license React v17.0.2
* react-jsx-runtime.production.min.js

@@ -12,2 +12,2 @@ *

* LICENSE file in the root directory of this source tree.
*/var Ee=F.default,yt=60103;if(R.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var _t=Symbol.for;yt=_t("react.element"),R.Fragment=_t("react.fragment")}var Oe=Ee.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Se=Object.prototype.hasOwnProperty,ke={key:!0,ref:!0,__self:!0,__source:!0};function bt(e,t,n){var r,s={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)Se.call(t,r)&&!ke.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:yt,type:e,key:i,ref:a,props:s,_owner:Oe.current}}R.jsx=bt,R.jsxs=bt,mt.exports=R;const H=mt.exports.jsx,Pe=()=>{const e="scrollBehavior"in document.documentElement.style,t={top:0,left:0,behavior:"smooth"};e?window.scroll(t):window.scroll(t.left,t.top)},vt=(e,t)=>e===document?!1:t.includes(e.id)?!0:vt(e.parentNode,t),X=u.forwardRef(({bottomBarRef:e,initialIndex:t,onSlideChange:n,children:r,filterNodes:s,transitionDuration:i,transitionTimingFunction:a,containerStyles:o,disableAutoScroll:f},h)=>{const c=u.useRef(null),l=u.useRef(t),y=u.useRef(t),O=u.useRef(0),k=u.useRef(0),S=_e(),P=u.useCallback(()=>{if(y.current!==l.current){const d=y.current,b=l.current;S(()=>{n(l.current),f||Pe();const{current:m=null}=c;m&&(m.children[d].style.height=`${k.current}px`,m.children[b].style.height="auto")}),y.current=l.current}},[f,n,S]),x=u.useCallback((d,b=!1)=>{S(()=>{const{current:m=null}=c;if(m){m.style.transitionDuration=b?"0s":`${i/1e3}s`;const{current:A=null}=e;A&&(A.style.transitionDuration=b?"0s":`${i/1e3}s`,A.style.transform=`translate3d(${100*d}%, 0px, 0px)`),m.style.transform=`translate3d(${-d*O.current}px, 0px, 0px)`}}),l.current!==d&&(l.current=d)},[e,S,i]);u.useImperativeHandle(h,()=>({getCurrentIndex:()=>l.current,swipeToIndex:x}));const G=ge(({event:d,down:b,movement:[m],velocity:A})=>{if(s.length>0?vt(d.target,s):!1)return;const U=m<0;if(b){let D=Math.abs(m);(l.current===0&&!U||l.current===r.length-1&&U)&&(D=Math.min(D,O.current/4)),S(()=>{const{current:$=null}=c;if($){$.style.transitionDuration!=="0s"&&($.style.transitionDuration="0s");const{current:B=null}=e;if(B){const De=D/O.current;B.style.transitionDuration!=="0s"&&(B.style.transitionDuration="0s"),B.style.transform=`translate3d(${((U?1:-1)*De+l.current)*100}%, 0px, 0px)`}$.style.transform=`translate3d(${(U?-1:1)*D-l.current*O.current}px, 0px, 0px)`}})}else if(!b){const D=l.current+(U?1:-1);x((Math.abs(m)>=O.current/20||A>1.75)&&D>=0&&D<r.length?D:l.current)}},{axis:"x",filterTaps:!0,pointer:{touch:!0}}),I=u.useCallback(()=>{const{current:d=null}=c;if(d){O.current=Math.min(d.parentElement.offsetWidth,window.innerWidth),k.current=window.innerHeight-Math.max(d.offsetTop,d.clientTop);for(let b=0;b<r.length;b+=1)d.children[b].style.height=t===b?"auto":`${k.current}px`}},[r.length,t]);return z(()=>(x(t,!0),I(),window.addEventListener("resize",I),()=>{window.removeEventListener("resize",I)}),[t,I,x]),z(()=>{e!=null&&e.current&&(e.current.style.transition="transform",e.current.style.transitionTimingFunction=a)},[e,a]),z(()=>{const{current:d=null}=c;return d&&d.addEventListener("transitionend",P),()=>{d.removeEventListener("transitionend",P)}},[P]),H("div",{style:J({width:"inherit",overflow:"hidden"},o),children:H("div",Et(J({},G()),{style:{width:`${r.length*100}%`,display:"flex",transition:"transform",transitionTimingFunction:a,willChange:"transform"},ref:c,children:r.map((d,b)=>H("div",{style:{width:`${100/r.length}%`,willChange:"height"},children:d},`tabs-${b}`))}))})});X.propTypes={bottomBarRef:v.shape({current:v.oneOfType([v.node,v.objectOf(v.object)])}),initialIndex:v.number,onSlideChange:v.func,children:v.node.isRequired,filterNodes:v.arrayOf(v.string),transitionDuration:v.number,transitionTimingFunction:v.string,containerStyles:v.shape({}),disableAutoScroll:v.bool},X.defaultProps={bottomBarRef:{current:null},onSlideChange:()=>{},initialIndex:0,filterNodes:[],transitionDuration:300,transitionTimingFunction:"ease-out",containerStyles:{},disableAutoScroll:!1};var xe=u.memo(X);return xe});
*/var Oe=K.default,_t=60103;if(R.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var bt=Symbol.for;_t=bt("react.element"),R.Fragment=bt("react.fragment")}var Se=Oe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ke=Object.prototype.hasOwnProperty,Pe={key:!0,ref:!0,__self:!0,__source:!0};function vt(e,t,n){var r,s={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)ke.call(t,r)&&!Pe.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:_t,type:e,key:i,ref:a,props:s,_owner:Se.current}}R.jsx=vt,R.jsxs=vt,gt.exports=R;const G=gt.exports.jsx,xe=()=>{const e="scrollBehavior"in document.documentElement.style,t={top:0,left:0,behavior:"smooth"};e?window.scroll(t):window.scroll(t.left,t.top)},wt=(e,t)=>e===document?!1:t.includes(e.id)?!0:wt(e.parentNode,t),J=u.forwardRef(({bottomBarRef:e,initialIndex:t,onSlideChange:n,children:r,filterNodes:s,transitionDuration:i,transitionTimingFunction:a,containerStyles:o,disableAutoScroll:l,disableAutoAdjustHeight:h},c)=>{const y=u.useRef(null),f=u.useRef(t),k=u.useRef(t),O=u.useRef(0),P=u.useRef(0),S=be(),D=u.useCallback(()=>{if(k.current!==f.current){const d=k.current,p=f.current;S(()=>{n(f.current),l||xe();const{current:w=null}=y;w&&!h&&w.children.length>0&&(w.children[d].style.height=`${P.current}px`,w.children[p].style.height="auto")}),k.current=f.current}},[h,l,n,S]),C=u.useCallback((d,p=!1)=>{S(()=>{const{current:w=null}=y;if(w){w.style.transitionDuration=p?"0s":`${i/1e3}s`;const{current:U=null}=e;U&&(U.style.transitionDuration=p?"0s":`${i/1e3}s`,U.style.transform=`translate3d(${100*d}%, 0px, 0px)`),w.style.transform=`translate3d(${-d*O.current}px, 0px, 0px)`}}),f.current!==d&&(f.current=d)},[e,S,i]);u.useImperativeHandle(c,()=>({getCurrentIndex:()=>f.current,swipeToIndex:C}));const Q=ye(({event:d,down:p,movement:[w],velocity:U})=>{if(s.length>0?wt(d.target,s):!1)return;const F=w<0;if(p){let x=Math.abs(w);(f.current===0&&!F||f.current===r.length-1&&F)&&(x=Math.min(x,O.current/4)),S(()=>{const{current:B=null}=y;if(B){B.style.transitionDuration!=="0s"&&(B.style.transitionDuration="0s");const{current:W=null}=e;if(W){const Ae=x/O.current;W.style.transitionDuration!=="0s"&&(W.style.transitionDuration="0s"),W.style.transform=`translate3d(${((F?1:-1)*Ae+f.current)*100}%, 0px, 0px)`}B.style.transform=`translate3d(${(F?-1:1)*x-f.current*O.current}px, 0px, 0px)`}})}else if(!p){const x=f.current+(F?1:-1);C((Math.abs(w)>=O.current/20||U>1.75)&&x>=0&&x<r.length?x:f.current)}},{axis:"x",filterTaps:!0,pointer:{touch:!0}}),I=u.useCallback(()=>{const{current:d=null}=y;if(d&&(O.current=Math.min(d.parentElement.offsetWidth,window.innerWidth),!h)){P.current=window.innerHeight-Math.max(d.offsetTop,d.clientTop);for(let p=0;p<r.length;p+=1)d.children[p].style.height=t===p?"auto":`${P.current}px`}},[r.length,h,t]);return X(()=>(C(t,!0),I(),window.addEventListener("resize",I),()=>{window.removeEventListener("resize",I)}),[t,I,C]),X(()=>{e!=null&&e.current&&(e.current.style.transition="transform",e.current.style.transitionTimingFunction=a)},[e,a]),X(()=>{const{current:d=null}=y;return d&&d.addEventListener("transitionend",D),()=>{d.removeEventListener("transitionend",D)}},[D]),G("div",{style:Y({width:"inherit",overflow:"hidden"},o),children:G("div",Ot(Y({},Q()),{style:{width:`${r.length*100}%`,display:"flex",transition:"transform",transitionTimingFunction:a,willChange:"transform"},ref:y,children:r.map((d,p)=>G("div",{style:Y({width:`${100/r.length}%`},h?{}:{willChange:"height"}),children:d},`tabs-${p}`))}))})});J.propTypes={bottomBarRef:b.shape({current:b.oneOfType([b.node,b.objectOf(b.object)])}),initialIndex:b.number,onSlideChange:b.func,children:b.node.isRequired,filterNodes:b.arrayOf(b.string),transitionDuration:b.number,transitionTimingFunction:b.string,containerStyles:b.shape({}),disableAutoScroll:b.bool,disableAutoAdjustHeight:b.bool},J.defaultProps={bottomBarRef:{current:null},onSlideChange:()=>{},initialIndex:0,filterNodes:[],transitionDuration:300,transitionTimingFunction:"ease-out",containerStyles:{},disableAutoScroll:!1,disableAutoAdjustHeight:!1};var De=u.memo(J);return De});
{
"name": "@mohalla-tech/react-swipeable-wrapper",
"version": "1.1.3",
"version": "1.1.4",
"description": "Swipeable views wrapper",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -144,2 +144,5 @@ # react-swipeable-wrapper

| `transitionTimingFunction` | `string` | `ease-out` | Timing function of the transition. |
| `containerStyles` | `object` | `{}` | Styles to override container styles. |
| `disableAutoScroll` | `boolean` | `false` | Disable auto scroll to top. |
| `disableAutoAdjustHeight` | `boolean` | `false` | Disable auto adjust height. |

@@ -146,0 +149,0 @@ ## Functions

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc