New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trendyol-js/react-carousel

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trendyol-js/react-carousel - npm Package Compare versions

Comparing version

to
1.0.7-beta.3

2

dist/cjs/index.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function i(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var s="styles-module_carousel-base__3keqD",o="styles-module_item-provider__YgMwz",a="styles-module_item-container__a8zaY",l="styles-module_item-tracker__3bypy",u="styles-module_carousel-arrow__26sRw";i(".styles-module_carousel-base__3keqD {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\toutline: none;\n}\n\n.styles-module_item-provider__YgMwz {\n\toverflow: hidden;\n\twidth: 100%;\n\tcursor: pointer;\n}\n\n.styles-module_item-container__a8zaY img {\n\t-webkit-user-select: none;\n\t user-select: none;\n\t-webkit-user-drag: none;\n}\n\n.styles-module_item-tracker__3bypy {\n\theight: 100%;\n\tdisplay: flex;\n}\n\n.styles-module_carousel-arrow__26sRw {\n\tz-index: 1;\n}\n");var c,f=function(e){return n.createElement("button",{className:u,onClick:e.onClick,"data-direction":e.direction})};!function(e){e[e.Right=-1]="Right",e[e.Left=1]="Left"}(c||(c={}));var d=function(){function e(e,t){this.arr=e,this.currentIndex=t}return e.prototype.next=function(){var e=this.currentIndex,t=this.arr;return this.currentIndex=e<t.length-1?e+1:0,this.current()},e.prototype.prev=function(){var e=this.currentIndex,t=this.arr;return this.currentIndex=e>0?e-1:t.length-1,this.current()},e.prototype.current=function(){return this.arr[this.currentIndex]},e}(),h=function(e,t,n){return n*e*t},m=function(e,t,n,r){var i=e>t;return n?{left:i,right:i}:{left:i&&0!==r,right:i&&r+t<e}},v=function(e,t,n){if(!n)return e;for(var r=Array.from(e),i=new d(e,0),s=0;s<t;s++)r.unshift(i.prev());return r};function g(e){return e.nativeEvent instanceof MouseEvent?e.nativeEvent.pageX:e.nativeEvent instanceof TouchEvent?e.nativeEvent.changedTouches[0].pageX:0}function p(e,t,n,r){var i=e.map((function(e){return t.find((function(t){return e.key===t.key}))}));return i.some((function(e){return void 0===e}))?v(t,n,r):i}var y=function(e){var i=t.useState(200),s=i[0],u=i[1],f=t.useCallback((function(t){if(null!==t){var n=t.getBoundingClientRect().width/e.show;u(n),e.widthCallBack(n)}}),[s]);e.responsive&&function(e){var n=t.useState(window.innerWidth),r=n[0],i=n[1];t.useLayoutEffect((function(){var t=function(){var t=r-window.innerWidth;i(window.innerWidth),e(t)};return window.addEventListener("resize",t),function(){return window.removeEventListener("resize",t)}}),[])}((function(e){u(s-e)}));var d=t.useState({initial:e.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0}),h=d[0],m=d[1],v=function(t){t.persist(),m(r(r({},h),{isDown:!0,start:g(t),initial:e.transform,finished:!1}))},p=function(t){if(t.persist(),!h.finished){if(Math.abs(h.drag)<s*e.swipeOn)return e.dragCallback(e.transform),m({initial:e.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0});e.slideCallback(h.drag>0?c.Right:c.Left),m(r(r({},h),{drag:0,isDown:!1,finished:!0,pointers:!0}))}},y=function(e){if(e.persist(),h.isDown){var t=g(e);m(r(r({},h),{drag:h.start-t,pointers:!1}))}},w=e.swiping?{onTouchCancel:p,onTouchEnd:p,onTouchMove:y,onTouchStart:v,onMouseDown:v,onMouseLeave:p,onMouseUp:p,onMouseMove:y}:{};return n.createElement("div",{ref:f,className:o},n.createElement("div",r({"":"trackList"},w,{className:l,style:{transform:"translateX("+(e.transform-h.drag)+"px)",transition:"transform "+e.transition+"s ease 0s",width:s*e.items.length}}),e.items.map((function(e,t){return n.createElement("div",{key:t,style:{width:s,pointerEvents:h.pointers?"all":"none"},className:a},e)}))))},w={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{},dynamic:!1,beforeChange:null,afterChange:null},_="styles-module_sliderBase__swkx1",L="styles-module_slider__o0fqa",b="styles-module_sliding__3T6T6";i(".styles-module_sliderBase__swkx1 {\n\twidth: 100%;\n\tposition: relative;\n}\n\n.styles-module_slider__o0fqa {\n\tdisplay: flex;\n\toverflow-x: auto;\n\tscrollbar-width: none; /* Firefox 64 */\n\t-ms-overflow-style: none; /* Internet Explorer 11 */\n}\n\n.styles-module_slider__o0fqa::-webkit-scrollbar {\n\t/** WebKit */\n\tdisplay: none;\n}\n\n.styles-module_slider__o0fqa > * {\n\tflex: 0 0 auto;\n}\n\n.styles-module_sliding__3T6T6 > * {\n\tpointer-events: none;\n}\n");exports.Carousel=function(e){var i=r(r({},w),e),o=t.useState(v(i.children,i.slide,i.infinite)),a=o[0],l=o[1],u=t.useState(0),g=u[0],_=u[1],L=t.useState({transform:0,transition:0,isSliding:!1}),b=L[0],C=L[1],k=t.useState(0),E=k[0],x=k[1],S=t.useState(m(i.children.length,i.show,i.infinite,E)),M=S[0],R=S[1];i.dynamic&&n.useEffect((function(){var t=p(a,e.children,i.slide,i.infinite);l(t)}),e.children);var T=function(e,t){if(!(b.isSliding||e===c.Right&&!M.right||e===c.Left&&!M.left)){i.beforeChange&&i.beforeChange(e);var n=function(e,t,n,r){var i=e-r*t;return i<0?n+i:n<=i?i-n:i}(E,t,i.children.length,e),r=i.infinite?function(e,t,n,r,i,s){var o=new d(e,n),a=Array.from(t);switch(+s){case c.Left:for(var l=i;l>=0;l--)(i-l<0||!a[l-i])&&a.unshift(o.current()),o.prev();break;case c.Right:for(l=0;l<r+i;l++)a[2*i+l]||a.push(o.current()),o.next()}return a}(i.children,a,n,i.show,t,e):a;i.infinite&&e===c.Right&&l(r),C({transform:b.transform+h(g,t,e),transition:i.transition,isSliding:!0}),x(n),R(m(i.children.length,i.show,i.infinite,n)),setTimeout((function(){i.infinite&&l(function(e,t,n){return n===c.Left?e.slice(0,-1*t):e.slice(t)}(r,t,e)),C({transform:i.infinite?h(g,t,c.Right):b.transform+h(g,t,e),transition:0,isSliding:!1}),i.afterChange&&i.afterChange(e)}),1e3*i.transition)}};return n.createElement("div",r({},i.a11y,{"":"carousel",tabIndex:0},i.useArrowKeys?{onKeyDown:function(e){37===e.keyCode?T(c.Left,i.slide):39===e.keyCode&&T(c.Right,i.slide)}}:{},{className:s+" "+i.className}),M.left&&n.createElement(f,{direction:"left",onClick:function(){return T(c.Left,i.slide)}}),n.createElement(y,r({},i,{transition:b.transition,items:a,transform:b.transform,slideCallback:function(e){T(e,i.slide)},dragCallback:function(e){C({transform:e,transition:i.transition,isSliding:!1}),setTimeout((function(){return C(r(r({},b),{transition:0}))}),1e3*i.transition)},widthCallBack:function(e){_(e),C({transform:i.infinite?h(e,i.slide,c.Right):0,transition:0,isSliding:!1})}})),M.right&&n.createElement(f,{direction:"right",onClick:function(){return T(c.Right,i.slide)}}))},exports.ScrollingCarousel=function(e){var r=e.children,i=e.className,s=t.useRef(null),o=t.useState(!1),a=o[0],l=o[1],u=t.useState({startX:0,scrollLeft:0}),f=u[0],d=u[1],h=function(){var e=s.current;return{left:!!e&&e.scrollLeft>0,right:!!e&&e.scrollWidth>e.scrollLeft+e.offsetWidth}},m=t.useState(h()),v=m[0],g=m[1],p=function(e){g(h())},y=t.useCallback((function(e){null!==e&&(Object.defineProperty(s,"current",{value:e}),g(h()),e.addEventListener("scroll",p))}),[s,r]),w=function(e){l(!1),g(h()),s.current.classList.remove(b)},C=function(e){var t=function(e){for(var t,n,r=s.current,i=e===c.Left?r.scrollLeft+r.offsetWidth:r.scrollLeft,o=0,a=0,l=Array.from(r.children);a<l.length;a++){var u=l[a],f=(t=u,n=void 0,n=getComputedStyle(t),t.offsetWidth+(parseInt(n.marginLeft,10)||0)+(parseInt(n.marginRight,10)||0));if((o+=f)>=i){var d=e===c.Left?o-i:f;return(r.offsetWidth-d)*e}}return r.offsetWidth}(e),n=s.current.scrollLeft;k(500,t,n)},k=function(e,t,n){for(var r=0,i=0;r<=e;i++)window.setTimeout(E,r,i*t/100+n),r+=e/100},E=function(e){s.current.scrollLeft=e};return n.createElement("div",{className:_+" "+i},v.left&&n.createElement("div",{"data-arrow":"left"},n.createElement("button",{onClick:function(){return C(c.Right)}})),v.right&&n.createElement("div",{"data-arrow":"right"},n.createElement("button",{onClick:function(){return C(c.Left)}})),n.createElement("div",{ref:y,onMouseDown:function(e){l(!0),d({startX:e.pageX-s.current.offsetLeft,scrollLeft:s.current.scrollLeft})},onMouseLeave:w,onMouseUp:w,onMouseMove:function(e){if(a){e.preventDefault(),s.current.classList.add(b);var t=e.pageX-s.current.offsetLeft-f.startX;s.current.scrollLeft=f.scrollLeft-t}},className:L},r))};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function i(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var s="styles-module_carousel-base__3keqD",o="styles-module_item-provider__YgMwz",a="styles-module_item-container__a8zaY",l="styles-module_item-tracker__3bypy",u="styles-module_carousel-arrow__26sRw";i(".styles-module_carousel-base__3keqD {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\toutline: none;\n}\n\n.styles-module_item-provider__YgMwz {\n\toverflow: hidden;\n\twidth: 100%;\n\tcursor: pointer;\n}\n\n.styles-module_item-container__a8zaY img {\n\t-webkit-user-select: none;\n\t user-select: none;\n\t-webkit-user-drag: none;\n}\n\n.styles-module_item-tracker__3bypy {\n\theight: 100%;\n\tdisplay: flex;\n}\n\n.styles-module_carousel-arrow__26sRw {\n\tz-index: 1;\n}\n");var c,f=function(e){return n.createElement("button",{className:u,onClick:e.onClick,"data-direction":e.direction})};!function(e){e[e.Right=-1]="Right",e[e.Left=1]="Left"}(c||(c={}));var d=function(){function e(e,t){this.arr=e,this.currentIndex=t}return e.prototype.next=function(){var e=this.currentIndex,t=this.arr;return this.currentIndex=e<t.length-1?e+1:0,this.current()},e.prototype.prev=function(){var e=this.currentIndex,t=this.arr;return this.currentIndex=e>0&&e<t.length?e-1:t.length-1,this.current()},e.prototype.current=function(){return this.arr[this.currentIndex]},e}(),h=function(e,t,n){return n*e*t},m=function(e,t,n,r){var i=e>t;return n?{left:i,right:i}:{left:i&&0!==r,right:i&&r+t<e}},v=function(e,t,n){if(!n)return e;for(var r=Array.from(e),i=new d(e,0),s=0;s<t;s++)r.unshift(i.prev());return r};function g(e){return e.nativeEvent instanceof MouseEvent?e.nativeEvent.pageX:e.nativeEvent instanceof TouchEvent?e.nativeEvent.changedTouches[0].pageX:0}function p(e,t,n,r,i){if(n&&n.length<t.length)return v(t,r,i);var s=e.map((function(e){return t.find((function(t){return e.key===t.key}))}));return s.some((function(e){return void 0===e}))?v(t,r,i):s}var y=function(e){var i=t.useState(200),s=i[0],u=i[1],f=t.useCallback((function(t){if(null!==t){var n=t.getBoundingClientRect().width/e.show;u(n),e.widthCallBack(n)}}),[s]);e.responsive&&function(e){var n=t.useState(window.innerWidth),r=n[0],i=n[1];t.useLayoutEffect((function(){var t=function(){var t=r-window.innerWidth;i(window.innerWidth),e(t)};return window.addEventListener("resize",t),function(){return window.removeEventListener("resize",t)}}),[])}((function(e){u(s-e)}));var d=t.useState({initial:e.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0}),h=d[0],m=d[1],v=function(t){t.persist(),m(r(r({},h),{isDown:!0,start:g(t),initial:e.transform,finished:!1}))},p=function(t){if(t.persist(),!h.finished){if(Math.abs(h.drag)<s*e.swipeOn)return e.dragCallback(e.transform),m({initial:e.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0});e.slideCallback(h.drag>0?c.Right:c.Left),m(r(r({},h),{drag:0,isDown:!1,finished:!0,pointers:!0}))}},y=function(e){if(e.persist(),h.isDown){var t=g(e);m(r(r({},h),{drag:h.start-t,pointers:!1}))}},w=e.swiping?{onTouchCancel:p,onTouchEnd:p,onTouchMove:y,onTouchStart:v,onMouseDown:v,onMouseLeave:p,onMouseUp:p,onMouseMove:y}:{};return n.createElement("div",{ref:f,className:o},n.createElement("div",r({"":"trackList"},w,{className:l,style:{transform:"translateX("+(e.transform-h.drag)+"px)",transition:"transform "+e.transition+"s ease 0s",width:s*e.items.length}}),e.items.map((function(e,t){return n.createElement("div",{key:t,style:{width:s,pointerEvents:h.pointers?"all":"none"},className:a},e)}))))},w={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{},dynamic:!1,paginationCallback:null,pageCount:0},_="styles-module_sliderBase__swkx1",L="styles-module_slider__o0fqa",b="styles-module_sliding__3T6T6";i(".styles-module_sliderBase__swkx1 {\n\twidth: 100%;\n\tposition: relative;\n}\n\n.styles-module_slider__o0fqa {\n\tdisplay: flex;\n\toverflow-x: auto;\n\tscrollbar-width: none; /* Firefox 64 */\n\t-ms-overflow-style: none; /* Internet Explorer 11 */\n}\n\n.styles-module_slider__o0fqa::-webkit-scrollbar {\n\t/** WebKit */\n\tdisplay: none;\n}\n\n.styles-module_slider__o0fqa > * {\n\tflex: 0 0 auto;\n}\n\n.styles-module_sliding__3T6T6 > * {\n\tpointer-events: none;\n}\n");exports.Carousel=function(e){var i,o,a=r(r({},w),e),l=t.useState(v(a.children,a.slide,a.infinite)),u=l[0],g=l[1],_=t.useState(0),L=_[0],b=_[1],k=t.useState({transform:0,transition:0,isSliding:!1}),C=k[0],E=k[1],x=t.useState(0),S=x[0],R=x[1],M=t.useState(m(a.children.length,a.show,a.infinite,S)),T=M[0],N=M[1],D=(i=e.children,o=t.useRef(),t.useEffect((function(){o.current=i})),o.current),I=t.useState(0),W=I[0],z=I[1],X=t.useRef(v(a.children,a.slide,a.infinite)),q=t.useRef(!1);a.dynamic&&t.useEffect((function(){var e=p(X.current,a.children,D,a.slide,a.infinite);g(e),X.current=e,W<a.pageCount&&D&&(null==D?void 0:D.length)<a.children.length&&(B(c.Right),z(W+1))}),[a.children]);var B=function(e){if(!(C.isSliding||e===c.Right&&!T.right||e===c.Left&&!T.left)){if(a.paginationCallback&&e===c.Right&&W<a.pageCount-1&&!q.current)return q.current=!0,void a.paginationCallback(e);var t=a.children,n=function(e,t,n,r){var i=e-r*t;return i<0?n+i:n<=i?i-n:i}(S,a.slide,t.length,e),r=a.infinite?function(e,t,n,r,i,s){var o=new d(e,n),a=Array.from(t);switch(+s){case c.Left:for(var l=i;l>=0;l--)(i-l<0||!a[l-i])&&a.unshift(o.current()),o.prev();break;case c.Right:for(l=0;l<r+i;l++)a[2*i+l]||a.push(o.current()),o.next()}return a}(t,u,n,a.show,a.slide,e):u;a.infinite&&e===c.Right&&(g(r),X.current=r),E({transform:C.transform+h(L,a.slide,e),transition:a.transition,isSliding:!0}),R(n),N(m(t.length,a.show,a.infinite,n)),setTimeout((function(){if(a.infinite){var t=function(e,t,n){return n===c.Left?e.slice(0,-1*t):e.slice(t)}(e===c.Right?X.current:r,a.slide,e);g(t),X.current=t}E({transform:a.infinite?h(L,a.slide,c.Right):C.transform+h(L,a.slide,e),transition:0,isSliding:!1})}),1e3*a.transition),q.current=!1}};return n.createElement("div",r({},a.a11y,{"":"carousel",tabIndex:0},a.useArrowKeys?{onKeyDown:function(e){37===e.keyCode?B(c.Left):39===e.keyCode&&B(c.Right)}}:{},{className:s+" "+a.className}),T.left&&n.createElement(f,{direction:"left",onClick:function(){return B(c.Left)}}),n.createElement(y,r({},a,{transition:C.transition,items:X.current,transform:C.transform,slideCallback:function(e){B(e)},dragCallback:function(e){E({transform:e,transition:a.transition,isSliding:!1}),setTimeout((function(){return E(r(r({},C),{transition:0}))}),1e3*a.transition)},widthCallBack:function(e){b(e),E({transform:a.infinite?h(e,a.slide,c.Right):0,transition:0,isSliding:!1})}})),T.right&&n.createElement(f,{direction:"right",onClick:function(){return B(c.Right)}}))},exports.ScrollingCarousel=function(e){var r=e.children,i=e.className,s=t.useRef(null),o=t.useState(!1),a=o[0],l=o[1],u=t.useState({startX:0,scrollLeft:0}),f=u[0],d=u[1],h=function(){var e=s.current;return{left:!!e&&e.scrollLeft>0,right:!!e&&e.scrollWidth>e.scrollLeft+e.offsetWidth}},m=t.useState(h()),v=m[0],g=m[1],p=function(e){g(h())},y=t.useCallback((function(e){null!==e&&(Object.defineProperty(s,"current",{value:e}),g(h()),e.addEventListener("scroll",p))}),[s,r]),w=function(e){l(!1),g(h()),s.current.classList.remove(b)},k=function(e){var t=function(e){for(var t,n,r=s.current,i=e===c.Left?r.scrollLeft+r.offsetWidth:r.scrollLeft,o=0,a=0,l=Array.from(r.children);a<l.length;a++){var u=l[a],f=(t=u,n=void 0,n=getComputedStyle(t),t.offsetWidth+(parseInt(n.marginLeft,10)||0)+(parseInt(n.marginRight,10)||0));if((o+=f)>=i){var d=e===c.Left?o-i:f;return(r.offsetWidth-d)*e}}return r.offsetWidth}(e),n=s.current.scrollLeft;C(500,t,n)},C=function(e,t,n){for(var r=0,i=0;r<=e;i++)window.setTimeout(E,r,i*t/100+n),r+=e/100},E=function(e){s.current.scrollLeft=e};return n.createElement("div",{className:_+" "+i},v.left&&n.createElement("div",{"data-arrow":"left"},n.createElement("button",{onClick:function(){return k(c.Right)}})),v.right&&n.createElement("div",{"data-arrow":"right"},n.createElement("button",{onClick:function(){return k(c.Left)}})),n.createElement("div",{ref:y,onMouseDown:function(e){l(!0),d({startX:e.pageX-s.current.offsetLeft,scrollLeft:s.current.scrollLeft})},onMouseLeave:w,onMouseUp:w,onMouseMove:function(e){if(a){e.preventDefault(),s.current.classList.add(b);var t=e.pageX-s.current.offsetLeft-f.startX;s.current.scrollLeft=f.scrollLeft-t}},className:L},r))};

@@ -1,2 +0,2 @@

import e,{useState as t,useLayoutEffect as n,useCallback as r,useRef as i}from"react";
import t,{useRef as e,useEffect as n,useState as r,useLayoutEffect as i,useCallback as o}from"react";
/*! *****************************************************************************

@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation. All rights reserved.

and limitations under the License.
***************************************************************************** */var o=function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function s(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var a="styles-module_carousel-base__3keqD",l="styles-module_item-provider__YgMwz",c="styles-module_item-container__a8zaY",f="styles-module_item-tracker__3bypy",u="styles-module_carousel-arrow__26sRw";s(".styles-module_carousel-base__3keqD {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\toutline: none;\n}\n\n.styles-module_item-provider__YgMwz {\n\toverflow: hidden;\n\twidth: 100%;\n\tcursor: pointer;\n}\n\n.styles-module_item-container__a8zaY img {\n\t-webkit-user-select: none;\n\t user-select: none;\n\t-webkit-user-drag: none;\n}\n\n.styles-module_item-tracker__3bypy {\n\theight: 100%;\n\tdisplay: flex;\n}\n\n.styles-module_carousel-arrow__26sRw {\n\tz-index: 1;\n}\n");var d,h=function(t){return e.createElement("button",{className:u,onClick:t.onClick,"data-direction":t.direction})};!function(e){e[e.Right=-1]="Right",e[e.Left=1]="Left"}(d||(d={}));var m=function(){function e(e,t){this.arr=e,this.currentIndex=t}return e.prototype.next=function(){var e=this.currentIndex,t=this.arr;return this.currentIndex=e<t.length-1?e+1:0,this.current()},e.prototype.prev=function(){var e=this.currentIndex,t=this.arr;return this.currentIndex=e>0?e-1:t.length-1,this.current()},e.prototype.current=function(){return this.arr[this.currentIndex]},e}(),v=function(e,t,n){return n*e*t},g=function(e,t,n,r){var i=e>t;return n?{left:i,right:i}:{left:i&&0!==r,right:i&&r+t<e}},p=function(e,t,n){if(!n)return e;for(var r=Array.from(e),i=new m(e,0),o=0;o<t;o++)r.unshift(i.prev());return r};function w(e){return e.nativeEvent instanceof MouseEvent?e.nativeEvent.pageX:e.nativeEvent instanceof TouchEvent?e.nativeEvent.changedTouches[0].pageX:0}function y(e,t,n,r){var i=e.map((function(e){return t.find((function(t){return e.key===t.key}))}));return i.some((function(e){return void 0===e}))?p(t,n,r):i}var _=function(i){var s=t(200),a=s[0],u=s[1],h=r((function(e){if(null!==e){var t=e.getBoundingClientRect().width/i.show;u(t),i.widthCallBack(t)}}),[a]);i.responsive&&function(e){var r=t(window.innerWidth),i=r[0],o=r[1];n((function(){var t=function(){var t=i-window.innerWidth;o(window.innerWidth),e(t)};return window.addEventListener("resize",t),function(){return window.removeEventListener("resize",t)}}),[])}((function(e){u(a-e)}));var m=t({initial:i.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0}),v=m[0],g=m[1],p=function(e){e.persist(),g(o(o({},v),{isDown:!0,start:w(e),initial:i.transform,finished:!1}))},y=function(e){if(e.persist(),!v.finished){if(Math.abs(v.drag)<a*i.swipeOn)return i.dragCallback(i.transform),g({initial:i.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0});i.slideCallback(v.drag>0?d.Right:d.Left),g(o(o({},v),{drag:0,isDown:!1,finished:!0,pointers:!0}))}},_=function(e){if(e.persist(),v.isDown){var t=w(e);g(o(o({},v),{drag:v.start-t,pointers:!1}))}},L=i.swiping?{onTouchCancel:y,onTouchEnd:y,onTouchMove:_,onTouchStart:p,onMouseDown:p,onMouseLeave:y,onMouseUp:y,onMouseMove:_}:{};return e.createElement("div",{ref:h,className:l},e.createElement("div",o({"":"trackList"},L,{className:f,style:{transform:"translateX("+(i.transform-v.drag)+"px)",transition:"transform "+i.transition+"s ease 0s",width:a*i.items.length}}),i.items.map((function(t,n){return e.createElement("div",{key:n,style:{width:a,pointerEvents:v.pointers?"all":"none"},className:c},t)}))))},L={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{},dynamic:!1,beforeChange:null,afterChange:null},b=function(n){var r=o(o({},L),n),i=t(p(r.children,r.slide,r.infinite)),s=i[0],l=i[1],c=t(0),f=c[0],u=c[1],w=t({transform:0,transition:0,isSliding:!1}),b=w[0],E=w[1],k=t(0),C=k[0],x=k[1],T=t(g(r.children.length,r.show,r.infinite,C)),M=T[0],R=T[1];r.dynamic&&e.useEffect((function(){var e=y(s,n.children,r.slide,r.infinite);l(e)}),n.children);var N=function(e,t){if(!(b.isSliding||e===d.Right&&!M.right||e===d.Left&&!M.left)){r.beforeChange&&r.beforeChange(e);var n=function(e,t,n,r){var i=e-r*t;return i<0?n+i:n<=i?i-n:i}(C,t,r.children.length,e),i=r.infinite?function(e,t,n,r,i,o){var s=new m(e,n),a=Array.from(t);switch(+o){case d.Left:for(var l=i;l>=0;l--)(i-l<0||!a[l-i])&&a.unshift(s.current()),s.prev();break;case d.Right:for(l=0;l<r+i;l++)a[2*i+l]||a.push(s.current()),s.next()}return a}(r.children,s,n,r.show,t,e):s;r.infinite&&e===d.Right&&l(i),E({transform:b.transform+v(f,t,e),transition:r.transition,isSliding:!0}),x(n),R(g(r.children.length,r.show,r.infinite,n)),setTimeout((function(){r.infinite&&l(function(e,t,n){return n===d.Left?e.slice(0,-1*t):e.slice(t)}(i,t,e)),E({transform:r.infinite?v(f,t,d.Right):b.transform+v(f,t,e),transition:0,isSliding:!1}),r.afterChange&&r.afterChange(e)}),1e3*r.transition)}};return e.createElement("div",o({},r.a11y,{"":"carousel",tabIndex:0},r.useArrowKeys?{onKeyDown:function(e){37===e.keyCode?N(d.Left,r.slide):39===e.keyCode&&N(d.Right,r.slide)}}:{},{className:a+" "+r.className}),M.left&&e.createElement(h,{direction:"left",onClick:function(){return N(d.Left,r.slide)}}),e.createElement(_,o({},r,{transition:b.transition,items:s,transform:b.transform,slideCallback:function(e){N(e,r.slide)},dragCallback:function(e){E({transform:e,transition:r.transition,isSliding:!1}),setTimeout((function(){return E(o(o({},b),{transition:0}))}),1e3*r.transition)},widthCallBack:function(e){u(e),E({transform:r.infinite?v(e,r.slide,d.Right):0,transition:0,isSliding:!1})}})),M.right&&e.createElement(h,{direction:"right",onClick:function(){return N(d.Right,r.slide)}}))},E="styles-module_sliderBase__swkx1",k="styles-module_slider__o0fqa",C="styles-module_sliding__3T6T6";s(".styles-module_sliderBase__swkx1 {\n\twidth: 100%;\n\tposition: relative;\n}\n\n.styles-module_slider__o0fqa {\n\tdisplay: flex;\n\toverflow-x: auto;\n\tscrollbar-width: none; /* Firefox 64 */\n\t-ms-overflow-style: none; /* Internet Explorer 11 */\n}\n\n.styles-module_slider__o0fqa::-webkit-scrollbar {\n\t/** WebKit */\n\tdisplay: none;\n}\n\n.styles-module_slider__o0fqa > * {\n\tflex: 0 0 auto;\n}\n\n.styles-module_sliding__3T6T6 > * {\n\tpointer-events: none;\n}\n");var x=function(n){var o=n.children,s=n.className,a=i(null),l=t(!1),c=l[0],f=l[1],u=t({startX:0,scrollLeft:0}),h=u[0],m=u[1],v=function(){var e=a.current;return{left:!!e&&e.scrollLeft>0,right:!!e&&e.scrollWidth>e.scrollLeft+e.offsetWidth}},g=t(v()),p=g[0],w=g[1],y=function(e){w(v())},_=r((function(e){null!==e&&(Object.defineProperty(a,"current",{value:e}),w(v()),e.addEventListener("scroll",y))}),[a,o]),L=function(e){f(!1),w(v()),a.current.classList.remove(C)},b=function(e){var t=function(e){for(var t,n,r=a.current,i=e===d.Left?r.scrollLeft+r.offsetWidth:r.scrollLeft,o=0,s=0,l=Array.from(r.children);s<l.length;s++){var c=l[s],f=(t=c,n=void 0,n=getComputedStyle(t),t.offsetWidth+(parseInt(n.marginLeft,10)||0)+(parseInt(n.marginRight,10)||0));if((o+=f)>=i){var u=e===d.Left?o-i:f;return(r.offsetWidth-u)*e}}return r.offsetWidth}(e),n=a.current.scrollLeft;x(500,t,n)},x=function(e,t,n){for(var r=0,i=0;r<=e;i++)window.setTimeout(T,r,i*t/100+n),r+=e/100},T=function(e){a.current.scrollLeft=e};return e.createElement("div",{className:E+" "+s},p.left&&e.createElement("div",{"data-arrow":"left"},e.createElement("button",{onClick:function(){return b(d.Right)}})),p.right&&e.createElement("div",{"data-arrow":"right"},e.createElement("button",{onClick:function(){return b(d.Left)}})),e.createElement("div",{ref:_,onMouseDown:function(e){f(!0),m({startX:e.pageX-a.current.offsetLeft,scrollLeft:a.current.scrollLeft})},onMouseLeave:L,onMouseUp:L,onMouseMove:function(e){if(c){e.preventDefault(),a.current.classList.add(C);var t=e.pageX-a.current.offsetLeft-h.startX;a.current.scrollLeft=h.scrollLeft-t}},className:k},o))};export{b as Carousel,x as ScrollingCarousel};
***************************************************************************** */var s=function(){return(s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function a(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}var l="styles-module_carousel-base__3keqD",c="styles-module_item-provider__YgMwz",u="styles-module_item-container__a8zaY",f="styles-module_item-tracker__3bypy",d="styles-module_carousel-arrow__26sRw";a(".styles-module_carousel-base__3keqD {\n\twidth: 100%;\n\tbox-sizing: border-box;\n\tdisplay: flex;\n\toutline: none;\n}\n\n.styles-module_item-provider__YgMwz {\n\toverflow: hidden;\n\twidth: 100%;\n\tcursor: pointer;\n}\n\n.styles-module_item-container__a8zaY img {\n\t-webkit-user-select: none;\n\t user-select: none;\n\t-webkit-user-drag: none;\n}\n\n.styles-module_item-tracker__3bypy {\n\theight: 100%;\n\tdisplay: flex;\n}\n\n.styles-module_carousel-arrow__26sRw {\n\tz-index: 1;\n}\n");var h,m=function(e){return t.createElement("button",{className:d,onClick:e.onClick,"data-direction":e.direction})};!function(t){t[t.Right=-1]="Right",t[t.Left=1]="Left"}(h||(h={}));var v=function(){function t(t,e){this.arr=t,this.currentIndex=e}return t.prototype.next=function(){var t=this.currentIndex,e=this.arr;return this.currentIndex=t<e.length-1?t+1:0,this.current()},t.prototype.prev=function(){var t=this.currentIndex,e=this.arr;return this.currentIndex=t>0&&t<e.length?t-1:e.length-1,this.current()},t.prototype.current=function(){return this.arr[this.currentIndex]},t}(),g=function(t,e,n){return n*t*e},p=function(t,e,n,r){var i=t>e;return n?{left:i,right:i}:{left:i&&0!==r,right:i&&r+e<t}},w=function(t,e,n){if(!n)return t;for(var r=Array.from(t),i=new v(t,0),o=0;o<e;o++)r.unshift(i.prev());return r};function y(t){return t.nativeEvent instanceof MouseEvent?t.nativeEvent.pageX:t.nativeEvent instanceof TouchEvent?t.nativeEvent.changedTouches[0].pageX:0}function _(t,e,n,r,i){if(n&&n.length<e.length)return w(e,r,i);var o=t.map((function(t){return e.find((function(e){return t.key===e.key}))}));return o.some((function(t){return void 0===t}))?w(e,r,i):o}var L=function(e){var n=r(200),a=n[0],l=n[1],d=o((function(t){if(null!==t){var n=t.getBoundingClientRect().width/e.show;l(n),e.widthCallBack(n)}}),[a]);e.responsive&&function(t){var e=r(window.innerWidth),n=e[0],o=e[1];i((function(){var e=function(){var e=n-window.innerWidth;o(window.innerWidth),t(e)};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[])}((function(t){l(a-t)}));var m=r({initial:e.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0}),v=m[0],g=m[1],p=function(t){t.persist(),g(s(s({},v),{isDown:!0,start:y(t),initial:e.transform,finished:!1}))},w=function(t){if(t.persist(),!v.finished){if(Math.abs(v.drag)<a*e.swipeOn)return e.dragCallback(e.transform),g({initial:e.transform,start:0,isDown:!1,drag:0,finished:!0,pointers:!0});e.slideCallback(v.drag>0?h.Right:h.Left),g(s(s({},v),{drag:0,isDown:!1,finished:!0,pointers:!0}))}},_=function(t){if(t.persist(),v.isDown){var e=y(t);g(s(s({},v),{drag:v.start-e,pointers:!1}))}},L=e.swiping?{onTouchCancel:w,onTouchEnd:w,onTouchMove:_,onTouchStart:p,onMouseDown:p,onMouseLeave:w,onMouseUp:w,onMouseMove:_}:{};return t.createElement("div",{ref:d,className:c},t.createElement("div",s({"":"trackList"},L,{className:f,style:{transform:"translateX("+(e.transform-v.drag)+"px)",transition:"transform "+e.transition+"s ease 0s",width:a*e.items.length}}),e.items.map((function(e,n){return t.createElement("div",{key:n,style:{width:a,pointerEvents:v.pointers?"all":"none"},className:u},e)}))))},k={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{},dynamic:!1,paginationCallback:null,pageCount:0},b=function(i){var o,a,c=s(s({},k),i),u=r(w(c.children,c.slide,c.infinite)),f=u[0],d=u[1],y=r(0),b=y[0],E=y[1],C=r({transform:0,transition:0,isSliding:!1}),x=C[0],R=C[1],T=r(0),M=T[0],N=T[1],D=r(p(c.children.length,c.show,c.infinite,M)),I=D[0],S=D[1],W=(o=i.children,a=e(),n((function(){a.current=o})),a.current),z=r(0),X=z[0],B=z[1],q=e(w(c.children,c.slide,c.infinite)),A=e(!1);c.dynamic&&n((function(){var t=_(q.current,c.children,W,c.slide,c.infinite);d(t),q.current=t,X<c.pageCount&&W&&(null==W?void 0:W.length)<c.children.length&&(O(h.Right),B(X+1))}),[c.children]);var O=function(t){if(!(x.isSliding||t===h.Right&&!I.right||t===h.Left&&!I.left)){if(c.paginationCallback&&t===h.Right&&X<c.pageCount-1&&!A.current)return A.current=!0,void c.paginationCallback(t);var e=c.children,n=function(t,e,n,r){var i=t-r*e;return i<0?n+i:n<=i?i-n:i}(M,c.slide,e.length,t),r=c.infinite?function(t,e,n,r,i,o){var s=new v(t,n),a=Array.from(e);switch(+o){case h.Left:for(var l=i;l>=0;l--)(i-l<0||!a[l-i])&&a.unshift(s.current()),s.prev();break;case h.Right:for(l=0;l<r+i;l++)a[2*i+l]||a.push(s.current()),s.next()}return a}(e,f,n,c.show,c.slide,t):f;c.infinite&&t===h.Right&&(d(r),q.current=r),R({transform:x.transform+g(b,c.slide,t),transition:c.transition,isSliding:!0}),N(n),S(p(e.length,c.show,c.infinite,n)),setTimeout((function(){if(c.infinite){var e=function(t,e,n){return n===h.Left?t.slice(0,-1*e):t.slice(e)}(t===h.Right?q.current:r,c.slide,t);d(e),q.current=e}R({transform:c.infinite?g(b,c.slide,h.Right):x.transform+g(b,c.slide,t),transition:0,isSliding:!1})}),1e3*c.transition),A.current=!1}};return t.createElement("div",s({},c.a11y,{"":"carousel",tabIndex:0},c.useArrowKeys?{onKeyDown:function(t){37===t.keyCode?O(h.Left):39===t.keyCode&&O(h.Right)}}:{},{className:l+" "+c.className}),I.left&&t.createElement(m,{direction:"left",onClick:function(){return O(h.Left)}}),t.createElement(L,s({},c,{transition:x.transition,items:q.current,transform:x.transform,slideCallback:function(t){O(t)},dragCallback:function(t){R({transform:t,transition:c.transition,isSliding:!1}),setTimeout((function(){return R(s(s({},x),{transition:0}))}),1e3*c.transition)},widthCallBack:function(t){E(t),R({transform:c.infinite?g(t,c.slide,h.Right):0,transition:0,isSliding:!1})}})),I.right&&t.createElement(m,{direction:"right",onClick:function(){return O(h.Right)}}))},E="styles-module_sliderBase__swkx1",C="styles-module_slider__o0fqa",x="styles-module_sliding__3T6T6";a(".styles-module_sliderBase__swkx1 {\n\twidth: 100%;\n\tposition: relative;\n}\n\n.styles-module_slider__o0fqa {\n\tdisplay: flex;\n\toverflow-x: auto;\n\tscrollbar-width: none; /* Firefox 64 */\n\t-ms-overflow-style: none; /* Internet Explorer 11 */\n}\n\n.styles-module_slider__o0fqa::-webkit-scrollbar {\n\t/** WebKit */\n\tdisplay: none;\n}\n\n.styles-module_slider__o0fqa > * {\n\tflex: 0 0 auto;\n}\n\n.styles-module_sliding__3T6T6 > * {\n\tpointer-events: none;\n}\n");var R=function(n){var i=n.children,s=n.className,a=e(null),l=r(!1),c=l[0],u=l[1],f=r({startX:0,scrollLeft:0}),d=f[0],m=f[1],v=function(){var t=a.current;return{left:!!t&&t.scrollLeft>0,right:!!t&&t.scrollWidth>t.scrollLeft+t.offsetWidth}},g=r(v()),p=g[0],w=g[1],y=function(t){w(v())},_=o((function(t){null!==t&&(Object.defineProperty(a,"current",{value:t}),w(v()),t.addEventListener("scroll",y))}),[a,i]),L=function(t){u(!1),w(v()),a.current.classList.remove(x)},k=function(t){var e=function(t){for(var e,n,r=a.current,i=t===h.Left?r.scrollLeft+r.offsetWidth:r.scrollLeft,o=0,s=0,l=Array.from(r.children);s<l.length;s++){var c=l[s],u=(e=c,n=void 0,n=getComputedStyle(e),e.offsetWidth+(parseInt(n.marginLeft,10)||0)+(parseInt(n.marginRight,10)||0));if((o+=u)>=i){var f=t===h.Left?o-i:u;return(r.offsetWidth-f)*t}}return r.offsetWidth}(t),n=a.current.scrollLeft;b(500,e,n)},b=function(t,e,n){for(var r=0,i=0;r<=t;i++)window.setTimeout(R,r,i*e/100+n),r+=t/100},R=function(t){a.current.scrollLeft=t};return t.createElement("div",{className:E+" "+s},p.left&&t.createElement("div",{"data-arrow":"left"},t.createElement("button",{onClick:function(){return k(h.Right)}})),p.right&&t.createElement("div",{"data-arrow":"right"},t.createElement("button",{onClick:function(){return k(h.Left)}})),t.createElement("div",{ref:_,onMouseDown:function(t){u(!0),m({startX:t.pageX-a.current.offsetLeft,scrollLeft:a.current.scrollLeft})},onMouseLeave:L,onMouseUp:L,onMouseMove:function(t){if(c){t.preventDefault(),a.current.classList.add(x);var e=t.pageX-a.current.offsetLeft-d.startX;a.current.scrollLeft=d.scrollLeft-e}},className:C},i))};export{b as Carousel,R as ScrollingCarousel};

@@ -19,4 +19,4 @@ import { FunctionComponent } from 'react';

dynamic?: boolean;
beforeChange?: ((direction: SlideDirection) => void) | null;
afterChange?: ((direction: SlideDirection) => void) | null;
paginationCallback?: ((direction: SlideDirection) => any) | null;
pageCount?: number;
}

@@ -23,0 +23,0 @@ export interface CarouselState {

@@ -22,3 +22,3 @@ import { MouseEvent, TouchEvent } from 'react';

export declare function getOuterWidth(el: HTMLElement): number;
export declare function updateNodes(oldItems: Item[], newItems: Item[], slide: number, infinite: boolean): Item[];
export declare function updateNodes(oldItems: Item[], newItems: Item[], prevChildren: Item[] | undefined, slide: number, infinite: boolean): Item[];
export declare function areItemsNotMatched(items: Item[]): boolean;
export declare const useWindowWidthChange: (callBack: (changed: number) => any) => void;
export declare const usePrevious: <T>(value: T) => T | undefined;
{
"name": "@trendyol-js/react-carousel",
"version": "1.0.7-beta.2",
"version": "1.0.7-beta.3",
"description": "Lightweight carousel component for react",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",