react-simply-carousel
Advanced tools
Comparing version 6.0.3 to 7.0.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define("ReactSimplyCarousel",["react"],t):"object"==typeof exports?exports.ReactSimplyCarousel=t(require("react")):e.ReactSimplyCarousel=t(e.React)}(this,(e=>(()=>{"use strict";var t={244:t=>{t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};return(()=>{n.d(o,{default:()=>O});var e=n(244),t=n.n(e),r=["responsiveProps"],i=["minWidth","maxWidth"],a=["style","onClickCapture"],c=["style"],u=["style","onTouchStart","onMouseDown","onTransitionEnd"],l=["children","show"],s=["children","show"],d=["className","style"],f=["show","activeClassName"],v=["className","onClick","style"],m=["props"];function h(){return h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h.apply(this,arguments)}function p(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||x(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){w(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}(e,t)||x(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){if(e){if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function C(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function k(n){var o=n.responsiveProps,b=void 0===o?[]:o,w=C(n,r),x=g((0,e.useState)(0),2),E=x[0],k=x[1],O=g((0,e.useState)(w.activeSlideIndex),2),S=O[0],T=O[1],j=(0,e.useRef)(null),P=(0,e.useRef)(null),L=(0,e.useRef)(null),M=(0,e.useRef)(0),W=(0,e.useRef)(!1),I=(0,e.useRef)(""),A=(0,e.useRef)(null),N=(0,e.useRef)(null),R=(0,e.useRef)(0),D=b.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.minWidth,n=void 0===r?0:r,o=t.maxWidth,a=void 0===o?null:o,c=C(t,i);return E>n&&(!a||E<=a)?y(y({},e),c):e}),w),X=e.Children.toArray(D.children),z=E?y(y({},D),{},{activeSlideIndex:Math.max(0,Math.min(D.activeSlideIndex,X.length-1)),itemsToShow:Math.min(X.length,D.itemsToShow||0),itemsToScroll:Math.min(X.length,D.itemsToScroll||1)}):w,q=z.containerProps,V=(q=void 0===q?{}:q).style,B=void 0===V?{}:V,_=q.onClickCapture,F=void 0===_?null:_,U=C(q,a),$=z.innerProps,G=($=void 0===$?{}:$).style,H=void 0===G?{}:G,J=C($,c),K=z.itemsListProps,Q=(K=void 0===K?{}:K).style,Y=void 0===Q?{}:Q,Z=K.onTouchStart,ee=void 0===Z?null:Z,te=K.onMouseDown,re=void 0===te?null:te,ne=K.onTransitionEnd,oe=void 0===ne?null:ne,ie=C(K,u),ae=z.backwardBtnProps,ce=(ae=void 0===ae?{}:ae).children,ue=void 0===ce?null:ce,le=ae.show,se=void 0===le||le,de=C(ae,l),fe=z.forwardBtnProps,ve=(fe=void 0===fe?{}:fe).children,me=void 0===ve?null:ve,he=fe.show,pe=void 0===he||he,be=C(fe,s),ye=z.activeSlideProps,we=(ye=void 0===ye?{}:ye).className,ge=void 0===we?"":we,xe=ye.style,Ee=void 0===xe?{}:xe,Ce=C(ye,d),ke=z.updateOnItemClick,Oe=void 0!==ke&&ke,Se=z.activeSlideIndex,Te=z.onRequestChange,je=z.speed,Pe=void 0===je?0:je,Le=z.delay,Me=void 0===Le?0:Le,We=z.easing,Ie=void 0===We?"linear":We,Ae=z.itemsToShow,Ne=void 0===Ae?0:Ae,Re=z.itemsToScroll,De=void 0===Re?1:Re,Xe=z.children,ze=z.onAfterChange,qe=z.autoplay,Ve=void 0!==qe&&qe,Be=z.autoplayDirection,_e=void 0===Be?"forward":Be,Fe=z.disableNavIfAllVisible,Ue=void 0===Fe||Fe,$e=z.hideNavIfAllVisible,Ge=void 0===$e||$e,He=z.centerMode,Je=void 0!==He&&He,Ke=z.infinite,Qe=void 0===Ke||Ke,Ye=z.disableNavIfEdgeVisible,Ze=void 0===Ye||Ye,et=z.disableNavIfEdgeActive,tt=void 0===et||et,rt=z.dotsNav,nt=void 0===rt?{}:rt,ot=z.dotsNavWrapperProps,it=void 0===ot?{}:ot,at=nt||{},ct=at.show,ut=void 0!==ct&&ct,lt=at.activeClassName,st=void 0===lt?"":lt,dt=C(at,f),ft=(0,e.useMemo)((function(){return E?Qe?p(L.current.children).slice(X.length-S,X.length-S+X.length):p(L.current.children):[]}),[S,X.length,E,Qe]),vt=E?L.current.offsetWidth-P.current.offsetWidth:0,mt=function(e){var t=ft.reduce((function(t,r,n){return n>=e?t:t+(r.offsetWidth||0)}),0);return Qe?t:Math.min(vt,t)},ht=(0,e.useMemo)((function(){return E&&Ne?ft.reduce((function(e,t,r){return r>=Se&&r<Se+Ne||r<Se&&r<Se+Ne-ft.length?e+t.offsetWidth:e}),0):0}),[Se,Ne,ft,E]),pt=e.Children.count(Xe)-1,bt=Ne===X.length,yt=Ge&&bt,wt=Ue&&bt,gt=Se-S!=0,xt=E&>&&Qe?mt(S):0,Et=!E||!gt&&Qe?0:mt(Se),Ct=E?ft[Se].offsetWidth:0,kt=E&&Je&&Qe?-(Math.min(ht||P.current.offsetWidth,P.current.offsetWidth)-Ct)/2:0,Ot=(0,e.useMemo)((function(){return Qe&&E?L.current.offsetWidth/3:0}),[E,Qe]),St=S-Se!=0&&L.current?"forward"===I.current.toLowerCase()&&Se<S?Ot:"backward"===I.current.toLowerCase()&&Se>S?-Ot:0:0,Tt=gt&&(Pe||Me)?"transform ".concat(Pe,"ms ").concat(Ie," ").concat(Me,"ms"):"none",jt=wt||!E?0:Et-xt+kt+St+Ot,Pt=E?"translateX(-".concat(jt,"px)"):"none",Lt=(0,e.useCallback)((function(e){if("forward"===e){var t=Se+De;return t>pt?Qe?t-pt-1:Se:t}if("backward"===e){var r=Se-De;return r<0?Qe?pt+1+r:Se:r}return Se}),[Se,De,pt,Qe]),Mt=(0,e.useCallback)((function(e,t){I.current=t,L.current.style.transition=Pe||Me?"transform ".concat(Pe,"ms ").concat(Ie," ").concat(Me,"ms"):"none",e!==Se?(clearTimeout(A.current),Te(e)):(M.current=0,W.current=!1,L.current.style.transform="translateX(-".concat(kt+Ot+(Qe?0:jt),"px)"))}),[Se,kt,Me,Ie,Pe,Te,Ot,Qe,jt]),Wt=(0,e.useCallback)((function(){Ve&&(clearTimeout(A.current),A.current=setTimeout((function(){Mt(Lt(_e),_e)}),Me))}),[Ve,_e,Mt,Lt,Me]),It=(0,e.useCallback)((function(e){W.current&&(e.preventDefault(),e.stopPropagation(),F&&F(e))}),[F]),At=(0,e.useCallback)((function(){Mt(Lt("backward"),"backward")}),[Mt,Lt]),Nt=(0,e.useCallback)((function(e){W.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,r=M.current-t+kt+Ot+(Qe?0:jt),n=L.current.offsetWidth-P.current.offsetWidth,o=Math.max(Math.min(0,-r),-n);L.current.style.transition="none",L.current.style.transform="translateX(".concat(o,"px)")}),[kt,Ot,Qe,jt]),Rt=(0,e.useCallback)((function(e){if(L.current.removeEventListener("mouseout",Rt),L.current.removeEventListener("dragstart",Rt),document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",Rt),document.removeEventListener("touchmove",Nt),document.removeEventListener("touchend",Rt),W.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,r=M.current-t;r>Ct/2?Mt(Lt("forward"),"forward"):r<-Ct/2?Mt(Lt("backward"),"backward"):Mt(Se,"forward")}}),[Se,Ct,Mt,Lt,Nt]),Dt=(0,e.useCallback)((function(e){clearTimeout(A.current),W.current||(M.current=e.clientX,document.addEventListener("mousemove",Nt),document.addEventListener("mouseup",Rt),L.current.addEventListener("mouseout",Rt),L.current.addEventListener("dragstart",Rt)),re&&re(e)}),[Nt,Rt]),Xt=(0,e.useCallback)((function(e){clearTimeout(A.current),W.current||(M.current=e.touches[0].clientX,document.addEventListener("touchmove",Nt),document.addEventListener("touchend",Rt)),ee&&ee(e)}),[Nt,Rt]),zt=(0,e.useCallback)((function(e){T(Se),oe&&oe(e)}),[Se]),qt=(0,e.useCallback)((function(){Mt(Lt("forward"),"forward")}),[Mt,Lt]),Vt=function(e,t,r){return e.map((function(e,n){var o=e.props,i=(o=void 0===o?{}:o).className,a=void 0===i?"":i,c=o.onClick,u=void 0===c?null:c,l=o.style,s=void 0===l?{}:l,d=C(o,v),f=C(e,m),h=Qe?R.current>=X.length?"forward":"backward":n>=Se?"forward":"backward",p=n+t===Se,b="".concat(a," ").concat(h," ").concat(p?ge:""),w=y(y(y({},s),p?Ee:{}),{},{boxSizing:"border-box",margin:0}),g=!r&&Oe?function(e){var t=e.direction,r=e.index,n=e.onClick;return function(e){Mt(r,t||(Se<r?"forward":"")||(Se>r?"backward":"")),n&&n(e)}}({direction:h,index:n+t,onClick:u}):u,x=y(y({role:"tabpanel",className:b,style:w,onClick:g},d),p?Ce:{});return R.current+=1,y({props:x},f)}))};return(0,e.useEffect)((function(){return M.current=0,W.current=!1,I.current="",Se!==S?Pe||Me||T(Se):(ze&&ze(Se,S),(Qe||"forward"===_e&&Se!==pt||"backward"===_e&&0!==Se)&&Wt()),function(){clearTimeout(A.current)}}),[S,Se,ze,Pe,Me,Wt,Qe,pt,_e]),(0,e.useEffect)((function(){return E&&Wt(),function(){clearTimeout(A.current)}}),[E]),(0,e.useEffect)((function(){var e=L.current;function t(){clearTimeout(N.current),clearTimeout(A.current),N.current=setTimeout((function(){k(window.innerWidth)}),400)}return k(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(N.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",Rt),document.removeEventListener("touchmove",Nt),document.removeEventListener("touchend",Rt),e.removeEventListener("mouseout",Rt),e.removeEventListener("dragstart",Rt)}}),[Nt,Rt]),R.current=0,E&&(L.current.style.transform=Pt),t().createElement("div",h({onClickCapture:It,style:y({display:"flex",boxSizing:"border-box",justifyContent:"center"},B)},U,{ref:j}),se&&!yt&&t().createElement("button",h({},de,{type:"button",onClick:(0===jt&&Ze||0===Se&&tt)&&!Qe?void 0:At,disabled:"boolean"==typeof de.disabled?de.disabled:!(!(0===jt&&Ze||0===Se&&tt)||Qe)}),ue),t().createElement("div",h({},J,{style:y(y({},H),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:ht?"".concat(ht,"px"):"100%"}),ref:P}),t().createElement("div",h({},ie,{style:y(y({},Y),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:Tt,transform:Pt}),"data-transform":Pt,onTouchStart:wt?void 0:Xt,onMouseDown:wt?void 0:Dt,onTransitionEnd:Pe||Me?zt:void 0,tabIndex:-1,role:"presentation",ref:L}),!wt&&Qe&&Vt(X.slice(S),S),Vt(X,0,wt),!wt&&Qe&&Vt(X,0),!wt&&Qe&&Vt(X.slice(0,S),0))),pe&&!yt&&t().createElement("button",h({},be,{type:"button",onClick:(jt===vt&&Ze||Se===pt&&tt)&&!Qe?void 0:qt,disabled:"boolean"==typeof be.disabled?be.disabled:!(!(jt===vt&&Ze||Se===pt&&tt)||Qe)}),me),!Qe&&!!ut&&t().createElement("div",it,Array.from({length:Math.ceil(X.length/De)}).map((function(e,r){return t().createElement("button",h({type:"button",key:r,title:"".concat(r)},dt,{className:"".concat(dt.className||""," ").concat(r*De===Se?st:""),onClick:function(){Mt(Math.min(r*De,X.length-1),Math.min(r*De,X.length-1)>Se?"forward":"backward")}}))}))))}const O=(0,e.memo)(k)})(),o.default})())); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactSimplyCarousel=t(e.React)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(){return a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a.apply(this,arguments)}function c(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f=["responsiveProps"],v=["minWidth","maxWidth"],m=["style","onClickCapture"],h=["style"],b=["style","onTouchStart","onMouseDown","onTransitionEnd"],p=["children","show"],y=["children","show"],w=["className","style"],g=["show","activeClassName"],E=["className","onClick","style"],k=["props"];function C(t){var r=t.responsiveProps,i=void 0===r?[]:r,s=c(t,f),d=u(e.useState(0),2),C=d[0],x=d[1],S=u(e.useState(s.activeSlideIndex),2),O=S[0],T=S[1],j=e.useRef(null),L=e.useRef(null),P=e.useRef(null),M=e.useRef(0),W=e.useRef(!1),I=e.useRef(""),A=e.useRef(null),N=e.useRef(null),R=e.useRef(0),D=i.reduce((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.minWidth,r=void 0===n?0:n,i=t.maxWidth,a=void 0===i?null:i,u=c(t,v);return C>r&&(!a||C<=a)?o(o({},e),u):e}),s),X=e.Children.toArray(D.children),z=C?o(o({},D),{},{activeSlideIndex:Math.max(0,Math.min(D.activeSlideIndex,X.length-1)),itemsToShow:Math.min(X.length,D.itemsToShow||0),itemsToScroll:Math.min(X.length,D.itemsToScroll||1)}):s,V=z.containerProps,q=(V=void 0===V?{}:V).style,B=void 0===q?{}:q,F=V.onClickCapture,U=void 0===F?null:F,$=c(V,m),G=z.innerProps,H=(G=void 0===G?{}:G).style,J=void 0===H?{}:H,K=c(G,h),Q=z.itemsListProps,Y=(Q=void 0===Q?{}:Q).style,Z=void 0===Y?{}:Y,_=Q.onTouchStart,ee=void 0===_?null:_,te=Q.onMouseDown,ne=void 0===te?null:te,re=Q.onTransitionEnd,oe=void 0===re?null:re,ie=c(Q,b),ae=z.backwardBtnProps,ce=(ae=void 0===ae?{}:ae).children,ue=void 0===ce?null:ce,le=ae.show,se=void 0===le||le,de=c(ae,p),fe=z.forwardBtnProps,ve=(fe=void 0===fe?{}:fe).children,me=void 0===ve?null:ve,he=fe.show,be=void 0===he||he,pe=c(fe,y),ye=z.activeSlideProps,we=(ye=void 0===ye?{}:ye).className,ge=void 0===we?"":we,Ee=ye.style,ke=void 0===Ee?{}:Ee,Ce=c(ye,w),xe=z.updateOnItemClick,Se=void 0!==xe&&xe,Oe=z.activeSlideIndex,Te=z.onRequestChange,je=z.speed,Le=void 0===je?0:je,Pe=z.delay,Me=void 0===Pe?0:Pe,We=z.easing,Ie=void 0===We?"linear":We,Ae=z.itemsToShow,Ne=void 0===Ae?0:Ae,Re=z.itemsToScroll,De=void 0===Re?1:Re,Xe=z.children,ze=z.onAfterChange,Ve=z.autoplay,qe=void 0!==Ve&&Ve,Be=z.autoplayDirection,Fe=void 0===Be?"forward":Be,Ue=z.disableNavIfAllVisible,$e=void 0===Ue||Ue,Ge=z.hideNavIfAllVisible,He=void 0===Ge||Ge,Je=z.centerMode,Ke=void 0!==Je&&Je,Qe=z.infinite,Ye=void 0===Qe||Qe,Ze=z.disableNavIfEdgeVisible,_e=void 0===Ze||Ze,et=z.disableNavIfEdgeActive,tt=void 0===et||et,nt=z.dotsNav,rt=void 0===nt?{}:nt,ot=z.dotsNavWrapperProps,it=void 0===ot?{}:ot,at=rt||{},ct=at.show,ut=void 0!==ct&&ct,lt=at.activeClassName,st=void 0===lt?"":lt,dt=c(at,g),ft=e.useMemo((function(){return C?Ye?l(P.current.children).slice(X.length-O,X.length-O+X.length):l(P.current.children):[]}),[O,X.length,C,Ye]),vt=C?P.current.offsetWidth-L.current.offsetWidth:0,mt=function(e){var t=ft.reduce((function(t,n,r){return r>=e?t:t+(n.offsetWidth||0)}),0);return Ye?t:Math.min(vt,t)},ht=e.useMemo((function(){return C&&Ne?ft.reduce((function(e,t,n){return n>=Oe&&n<Oe+Ne||n<Oe&&n<Oe+Ne-ft.length?e+t.offsetWidth:e}),0):0}),[Oe,Ne,ft,C]),bt=e.Children.count(Xe)-1,pt=Ne===X.length,yt=He&&pt,wt=$e&&pt,gt=Oe-O!=0,Et=C&>&&Ye?mt(O):0,kt=!C||!gt&&Ye?0:mt(Oe),Ct=C?ft[Oe].offsetWidth:0,xt=C&&(Ke&&Ye)?-(Math.min(ht||L.current.offsetWidth,L.current.offsetWidth)-Ct)/2:0,St=e.useMemo((function(){return Ye&&C?P.current.offsetWidth/3:0}),[C,Ye]),Ot=O-Oe!=0&&P.current?"forward"===I.current.toLowerCase()&&Oe<O?St:"backward"===I.current.toLowerCase()&&Oe>O?-St:0:0,Tt=gt&&(Le||Me)?"transform ".concat(Le,"ms ").concat(Ie," ").concat(Me,"ms"):"none",jt=wt||!C?0:kt-Et+xt+Ot+St,Lt=C?"translateX(-".concat(jt,"px)"):"none",Pt=e.useCallback((function(e){if("forward"===e){var t=Oe+De;return t>bt?Ye?t-bt-1:Oe:t}if("backward"===e){var n=Oe-De;return n<0?Ye?bt+1+n:Oe:n}return Oe}),[Oe,De,bt,Ye]),Mt=e.useCallback((function(e,t){I.current=t,P.current.style.transition=Le||Me?"transform ".concat(Le,"ms ").concat(Ie," ").concat(Me,"ms"):"none",e!==Oe?(clearTimeout(A.current),Te(e)):(M.current=0,W.current=!1,P.current.style.transform="translateX(-".concat(xt+St+(Ye?0:jt),"px)"))}),[Oe,xt,Me,Ie,Le,Te,St,Ye,jt]),Wt=e.useCallback((function(){qe&&(clearTimeout(A.current),A.current=setTimeout((function(){Mt(Pt(Fe),Fe)}),Me))}),[qe,Fe,Mt,Pt,Me]),It=e.useCallback((function(e){W.current&&(e.preventDefault(),e.stopPropagation(),U&&U(e))}),[U]),At=e.useCallback((function(){Mt(Pt("backward"),"backward")}),[Mt,Pt]),Nt=e.useCallback((function(e){W.current=!0;var t=e.touches&&e.touches[0]?e.touches[0].clientX:e.clientX,n=M.current-t+xt+St+(Ye?0:jt),r=P.current.offsetWidth-L.current.offsetWidth,o=Math.max(Math.min(0,-n),-r);P.current.style.transition="none",P.current.style.transform="translateX(".concat(o,"px)")}),[xt,St,Ye,jt]),Rt=e.useCallback((function(e){if(P.current.removeEventListener("mouseout",Rt),P.current.removeEventListener("dragstart",Rt),document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",Rt),document.removeEventListener("touchmove",Nt),document.removeEventListener("touchend",Rt),W.current){var t=e.changedTouches&&e.changedTouches.length?e.changedTouches[e.changedTouches.length-1].clientX:e.clientX,n=M.current-t;n>Ct/2?Mt(Pt("forward"),"forward"):n<-Ct/2?Mt(Pt("backward"),"backward"):Mt(Oe,"forward")}}),[Oe,Ct,Mt,Pt,Nt]),Dt=e.useCallback((function(e){clearTimeout(A.current),W.current||(M.current=e.clientX,document.addEventListener("mousemove",Nt),document.addEventListener("mouseup",Rt),P.current.addEventListener("mouseout",Rt),P.current.addEventListener("dragstart",Rt)),ne&&ne(e)}),[Nt,Rt]),Xt=e.useCallback((function(e){clearTimeout(A.current),W.current||(M.current=e.touches[0].clientX,document.addEventListener("touchmove",Nt),document.addEventListener("touchend",Rt)),ee&&ee(e)}),[Nt,Rt]),zt=e.useCallback((function(e){T(Oe),oe&&oe(e)}),[Oe]),Vt=e.useCallback((function(){Mt(Pt("forward"),"forward")}),[Mt,Pt]),qt=function(e,t,n){return e.map((function(e,r){var i=e.props,a=(i=void 0===i?{}:i).className,u=void 0===a?"":a,l=i.onClick,s=void 0===l?null:l,d=i.style,f=void 0===d?{}:d,v=c(i,E),m=c(e,k),h=Ye?R.current>=X.length?"forward":"backward":r>=Oe?"forward":"backward",b=r+t===Oe,p="".concat(u," ").concat(h," ").concat(b?ge:""),y=o(o(o({},f),b?ke:{}),{},{boxSizing:"border-box",margin:0}),w=!n&&Se?function(e){var t=e.direction,n=e.index,r=e.onClick;return function(e){Mt(n,t||(Oe<n?"forward":"")||(Oe>n?"backward":"")),r&&r(e)}}({direction:h,index:r+t,onClick:s}):s,g=o(o({role:"tabpanel",className:p,style:y,onClick:w},v),b?Ce:{});return R.current+=1,o({props:g},m)}))};return e.useEffect((function(){return M.current=0,W.current=!1,I.current="",Oe!==O?Le||Me||T(Oe):(ze&&ze(Oe,O),(Ye||"forward"===Fe&&Oe!==bt||"backward"===Fe&&0!==Oe)&&Wt()),function(){clearTimeout(A.current)}}),[O,Oe,ze,Le,Me,Wt,Ye,bt,Fe]),e.useEffect((function(){return C&&Wt(),function(){clearTimeout(A.current)}}),[C]),e.useEffect((function(){var e=P.current;function t(){clearTimeout(N.current),clearTimeout(A.current),N.current=setTimeout((function(){x(window.innerWidth)}),400)}return x(window.innerWidth),window.addEventListener("resize",t),function(){clearTimeout(N.current),window.removeEventListener("resize",t),document.removeEventListener("mousemove",Nt),document.removeEventListener("mouseup",Rt),document.removeEventListener("touchmove",Nt),document.removeEventListener("touchend",Rt),e.removeEventListener("mouseout",Rt),e.removeEventListener("dragstart",Rt)}}),[Nt,Rt]),R.current=0,C&&(P.current.style.transform=Lt),n.default.createElement("div",a({onClickCapture:It,style:o({display:"flex",boxSizing:"border-box",justifyContent:"center"},B)},$,{ref:j}),se&&!yt&&n.default.createElement("button",a({},de,{type:"button",onClick:(0===jt&&_e||0===Oe&&tt)&&!Ye?void 0:At,disabled:"boolean"==typeof de.disabled?de.disabled:!(!(0===jt&&_e||0===Oe&&tt)||Ye)}),ue),n.default.createElement("div",a({},K,{style:o(o({},J),{},{display:"flex",boxSizing:"border-box",flexFlow:"row wrap",padding:"0",overflow:"hidden",maxWidth:ht?"".concat(ht,"px"):"100%"}),ref:L}),n.default.createElement("div",a({},ie,{style:o(o({},Z),{},{display:"flex",boxSizing:"border-box",outline:"none",transition:Tt,transform:Lt}),"data-transform":Lt,onTouchStart:wt?void 0:Xt,onMouseDown:wt?void 0:Dt,onTransitionEnd:Le||Me?zt:void 0,tabIndex:-1,role:"presentation",ref:P}),!wt&&Ye&&qt(X.slice(O),O),qt(X,0,wt),!wt&&Ye&&qt(X,0),!wt&&Ye&&qt(X.slice(0,O),0))),be&&!yt&&n.default.createElement("button",a({},pe,{type:"button",onClick:(jt===vt&&_e||Oe===bt&&tt)&&!Ye?void 0:Vt,disabled:"boolean"==typeof pe.disabled?pe.disabled:!(!(jt===vt&&_e||Oe===bt&&tt)||Ye)}),me),!Ye&&!!ut&&n.default.createElement("div",it,Array.from({length:Math.ceil(X.length/De)}).map((function(e,t){return n.default.createElement("button",a({type:"button",key:t,title:"".concat(t)},dt,{className:"".concat(dt.className||""," ").concat(t*De===Oe?st:""),onClick:function(){Mt(Math.min(t*De,X.length-1),Math.min(t*De,X.length-1)>Oe?"forward":"backward")}}))}))))}return e.memo(C)})); |
{ | ||
"name": "react-simply-carousel", | ||
"version": "6.0.3", | ||
"version": "7.0.0", | ||
"description": "A simple, lightweight, fully controlled isomorphic (with SSR support) React.js carousel component. Touch enabled and responsive. With support for autoplay and infinity options. Fully customizable", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist/" | ||
], | ||
"unpkg": "dist/index.js", | ||
"module": "dist/index.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"scripts": { | ||
"build": "rm -rf dist && yarn lint && yarn generate-types && webpack --mode=production", | ||
"build:dev": "yarn generate-types && webpack --mode=development", | ||
"build": "rm -rf dist && yarn lint && yarn generate-types && rollup -c", | ||
"generate-types": "tsc --emitDeclarationOnly", | ||
@@ -53,2 +51,4 @@ "lint": "eslint . --ext .tsx", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"@types/react": "^18.0.8", | ||
@@ -58,5 +58,3 @@ "@types/react-dom": "^18.0.3", | ||
"@typescript-eslint/parser": "^5.21.0", | ||
"babel-loader": "^8.2.5", | ||
"babel-plugin-transform-remove-console": "^6.9.4", | ||
"clean-webpack-plugin": "^3.0.0", | ||
"eslint": "^8.14.0", | ||
@@ -74,6 +72,5 @@ "eslint-config-airbnb": "^19.0.4", | ||
"react-dom": "^18.1.0", | ||
"typescript": "^4.6.4", | ||
"webpack": "^5.72.0", | ||
"webpack-bundle-analyzer": "^4.5.0", | ||
"webpack-cli": "^4.9.2" | ||
"rollup": "^2.72.1", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.6.4" | ||
}, | ||
@@ -80,0 +77,0 @@ "dependencies": { |
@@ -5,3 +5,3 @@ # react-simply-carousel | ||
[![minified + gzip](https://img.shields.io/bundlephobia/minzip/react-simply-carousel/latest)](https://bundlephobia.com/package/react-simply-carousel) | ||
[![typescript](https://badgen.net/npm/types/react-simply-carousel?6.0.3)](https://unpkg.com/react-simply-carousel/dist/index.d.ts) | ||
[![typescript](https://badgen.net/npm/types/react-simply-carousel)](https://unpkg.com/react-simply-carousel/dist/index.d.ts) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/vadymshymko/react-simply-carousel/blob/master/LICENSE) | ||
@@ -8,0 +8,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44806
27
6
136