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.5

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}};function v(e){return e.nativeEvent instanceof MouseEvent?e.nativeEvent.pageX:e.nativeEvent instanceof TouchEvent?e.nativeEvent.changedTouches[0].pageX:0}var g=n.memo((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,e.slide)}}),[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],g=function(t){t.persist(),m(r(r({},h),{isDown:!0,start:v(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}))}},w=function(e){if(e.persist(),h.isDown){var t=v(e);m(r(r({},h),{drag:h.start-t,pointers:!1}))}},y=e.swiping?{onTouchCancel:p,onTouchEnd:p,onTouchMove:w,onTouchStart:g,onMouseDown:g,onMouseLeave:p,onMouseUp:p,onMouseMove:w}:{};return n.createElement("div",{ref:f,className:o},n.createElement("div",r({"":"trackList"},y,{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)}))))})),p={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{}},w="styles-module_sliderBase__swkx1",y="styles-module_slider__o0fqa",_="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({},p),e),o=t.useState(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}(i.children,i.slide,i.infinite)),a=o[0],l=o[1],u=t.useState(0),v=u[0],w=u[1],y=t.useState({transform:0,transition:0,isSliding:!1}),_=y[0],L=y[1],b=t.useState(0),E=b[0],k=b[1],x=t.useState(m(i.children.length,i.show,i.infinite,E)),C=x[0],S=x[1],M=function(e,t){if(!(_.isSliding||e===c.Right&&!C.right||e===c.Left&&!C.left)){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),L({transform:_.transform+h(v,t,e),transition:i.transition,isSliding:!0}),k(n),S(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)),L({transform:i.infinite?h(v,t,c.Right):_.transform+h(v,t,e),transition:0,isSliding:!1})}),1e3*i.transition)}};return n.createElement("div",r({},i.a11y,{"":"carousel",tabIndex:0},i.useArrowKeys?{onKeyDown:function(e){37===e.keyCode?M(c.Left,i.slide):39===e.keyCode&&M(c.Right,i.slide)}}:{},{className:s+" "+i.className}),C.left&&n.createElement(f,{direction:"left",onClick:function(){return M(c.Left,i.slide)}}),n.createElement(g,r({},i,{transition:_.transition,items:a,transform:_.transform,slideCallback:function(e){M(e,i.slide)},dragCallback:function(e){L({transform:e,transition:i.transition,isSliding:!1}),setTimeout((function(){return L(r(r({},_),{transition:0}))}),1e3*i.transition)},widthCallBack:function(e,t){w(e),L({transform:i.infinite?h(e,t,c.Right):0,transition:0,isSliding:!1})}})),C.right&&n.createElement(f,{direction:"right",onClick:function(){return M(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())},L=t.useCallback((function(e){null!==e&&(Object.defineProperty(s,"current",{value:e}),g(h()),e.addEventListener("scroll",p))}),[s,r]),b=function(e){l(!1),g(h()),s.current.classList.remove(_)},E=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(x,r,i*t/100+n),r+=e/100},x=function(e){s.current.scrollLeft=e};return n.createElement("div",{className:w+" "+i},v.left&&n.createElement("div",{"data-arrow":"left"},n.createElement("button",{onClick:function(){return E(c.Right)}})),v.right&&n.createElement("div",{"data-arrow":"right"},n.createElement("button",{onClick:function(){return E(c.Left)}})),n.createElement("div",{ref:L,onMouseDown:function(e){l(!0),d({startX:e.pageX-s.current.offsetLeft,scrollLeft:s.current.scrollLeft})},onMouseLeave:b,onMouseUp:b,onMouseMove:function(e){if(a){e.preventDefault(),s.current.classList.add(_);var t=e.pageX-s.current.offsetLeft-f.startX;s.current.scrollLeft=f.scrollLeft-t}},className:y},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-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}};function v(e){return e.nativeEvent instanceof MouseEvent?e.nativeEvent.pageX:e.nativeEvent instanceof TouchEvent?e.nativeEvent.changedTouches[0].pageX:0}var g=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,e.slide)}}),[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],g=function(t){t.persist(),m(r(r({},h),{isDown:!0,start:v(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}))}},w=function(e){if(e.persist(),h.isDown){var t=v(e);m(r(r({},h),{drag:h.start-t,pointers:!1}))}},y=e.swiping?{onTouchCancel:p,onTouchEnd:p,onTouchMove:w,onTouchStart:g,onMouseDown:g,onMouseLeave:p,onMouseUp:p,onMouseMove:w}:{};return n.createElement("div",{ref:f,className:o},n.createElement("div",r({"":"trackList"},y,{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)}))))},p={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{}},w="styles-module_sliderBase__swkx1",y="styles-module_slider__o0fqa",_="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({},p),e),o=t.useState(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}(i.children,i.slide,i.infinite)),a=o[0],l=o[1],u=t.useState(0),v=u[0],w=u[1],y=t.useState({transform:0,transition:0,isSliding:!1}),_=y[0],L=y[1],b=t.useState(0),E=b[0],k=b[1],x=t.useState(m(i.children.length,i.show,i.infinite,E)),C=x[0],S=x[1],M=function(e,t){if(!(_.isSliding||e===c.Right&&!C.right||e===c.Left&&!C.left)){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),L({transform:_.transform+h(v,t,e),transition:i.transition,isSliding:!0}),k(n),S(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)),L({transform:i.infinite?h(v,t,c.Right):_.transform+h(v,t,e),transition:0,isSliding:!1})}),1e3*i.transition)}};return n.createElement("div",r({},i.a11y,{"":"carousel",tabIndex:0},i.useArrowKeys?{onKeyDown:function(e){37===e.keyCode?M(c.Left,i.slide):39===e.keyCode&&M(c.Right,i.slide)}}:{},{className:s+" "+i.className}),C.left&&n.createElement(f,{direction:"left",onClick:function(){return M(c.Left,i.slide)}}),n.createElement(g,r({},i,{transition:_.transition,items:a,transform:_.transform,slideCallback:function(e){M(e,i.slide)},dragCallback:function(e){L({transform:e,transition:i.transition,isSliding:!1}),setTimeout((function(){return L(r(r({},_),{transition:0}))}),1e3*i.transition)},widthCallBack:function(e,t){w(e),L({transform:i.infinite?h(e,t,c.Right):0,transition:0,isSliding:!1})}})),C.right&&n.createElement(f,{direction:"right",onClick:function(){return M(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())},L=t.useCallback((function(e){null!==e&&(Object.defineProperty(s,"current",{value:e}),g(h()),e.addEventListener("scroll",p))}),[s,r]),b=function(e){l(!1),g(h()),s.current.classList.remove(_)},E=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(x,r,i*t/100+n),r+=e/100},x=function(e){s.current.scrollLeft=e};return n.createElement("div",{className:w+" "+i},v.left&&n.createElement("div",{"data-arrow":"left"},n.createElement("button",{onClick:function(){return E(c.Right)}})),v.right&&n.createElement("div",{"data-arrow":"right"},n.createElement("button",{onClick:function(){return E(c.Left)}})),n.createElement("div",{ref:L,onMouseDown:function(e){l(!0),d({startX:e.pageX-s.current.offsetLeft,scrollLeft:s.current.scrollLeft})},onMouseLeave:b,onMouseUp:b,onMouseMove:function(e){if(a){e.preventDefault(),s.current.classList.add(_);var t=e.pageX-s.current.offsetLeft-f.startX;s.current.scrollLeft=f.scrollLeft-t}},className:y},r))};

@@ -15,2 +15,2 @@ import e,{useState as t,useLayoutEffect as n,useCallback as r,useRef as i}from"react";

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}};function p(e){return e.nativeEvent instanceof MouseEvent?e.nativeEvent.pageX:e.nativeEvent instanceof TouchEvent?e.nativeEvent.changedTouches[0].pageX:0}var w=e.memo((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,i.slide)}}),[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],w=function(e){e.persist(),g(o(o({},v),{isDown:!0,start:p(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=p(e);g(o(o({},v),{drag:v.start-t,pointers:!1}))}},L=i.swiping?{onTouchCancel:y,onTouchEnd:y,onTouchMove:_,onTouchStart:w,onMouseDown:w,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)}))))})),y={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{}},_=function(n){var r=o(o({},y),n),i=t(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}(r.children,r.slide,r.infinite)),s=i[0],l=i[1],c=t(0),f=c[0],u=c[1],p=t({transform:0,transition:0,isSliding:!1}),_=p[0],L=p[1],E=t(0),b=E[0],k=E[1],x=t(g(r.children.length,r.show,r.infinite,b)),C=x[0],T=x[1],M=function(e,t){if(!(_.isSliding||e===d.Right&&!C.right||e===d.Left&&!C.left)){var n=function(e,t,n,r){var i=e-r*t;return i<0?n+i:n<=i?i-n:i}(b,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),L({transform:_.transform+v(f,t,e),transition:r.transition,isSliding:!0}),k(n),T(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)),L({transform:r.infinite?v(f,t,d.Right):_.transform+v(f,t,e),transition:0,isSliding:!1})}),1e3*r.transition)}};return e.createElement("div",o({},r.a11y,{"":"carousel",tabIndex:0},r.useArrowKeys?{onKeyDown:function(e){37===e.keyCode?M(d.Left,r.slide):39===e.keyCode&&M(d.Right,r.slide)}}:{},{className:a+" "+r.className}),C.left&&e.createElement(h,{direction:"left",onClick:function(){return M(d.Left,r.slide)}}),e.createElement(w,o({},r,{transition:_.transition,items:s,transform:_.transform,slideCallback:function(e){M(e,r.slide)},dragCallback:function(e){L({transform:e,transition:r.transition,isSliding:!1}),setTimeout((function(){return L(o(o({},_),{transition:0}))}),1e3*r.transition)},widthCallBack:function(e,t){u(e),L({transform:r.infinite?v(e,t,d.Right):0,transition:0,isSliding:!1})}})),C.right&&e.createElement(h,{direction:"right",onClick:function(){return M(d.Right,r.slide)}}))},L="styles-module_sliderBase__swkx1",E="styles-module_slider__o0fqa",b="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 k=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]),k=function(e){f(!1),w(v()),a.current.classList.remove(b)},x=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;C(500,t,n)},C=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:L+" "+s},p.left&&e.createElement("div",{"data-arrow":"left"},e.createElement("button",{onClick:function(){return x(d.Right)}})),p.right&&e.createElement("div",{"data-arrow":"right"},e.createElement("button",{onClick:function(){return x(d.Left)}})),e.createElement("div",{ref:_,onMouseDown:function(e){f(!0),m({startX:e.pageX-a.current.offsetLeft,scrollLeft:a.current.scrollLeft})},onMouseLeave:k,onMouseUp:k,onMouseMove:function(e){if(c){e.preventDefault(),a.current.classList.add(b);var t=e.pageX-a.current.offsetLeft-h.startX;a.current.scrollLeft=h.scrollLeft-t}},className:E},o))};export{_ as Carousel,k as ScrollingCarousel};
***************************************************************************** */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}};function p(e){return e.nativeEvent instanceof MouseEvent?e.nativeEvent.pageX:e.nativeEvent instanceof TouchEvent?e.nativeEvent.changedTouches[0].pageX:0}var w=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,i.slide)}}),[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],w=function(e){e.persist(),g(o(o({},v),{isDown:!0,start:p(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=p(e);g(o(o({},v),{drag:v.start-t,pointers:!1}))}},L=i.swiping?{onTouchCancel:y,onTouchEnd:y,onTouchMove:_,onTouchStart:w,onMouseDown:w,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)}))))},y={children:[],show:1,slide:1,transition:.5,swiping:!1,swipeOn:1,responsive:!1,infinite:!0,className:"",useArrowKeys:!1,a11y:{}},_=function(n){var r=o(o({},y),n),i=t(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}(r.children,r.slide,r.infinite)),s=i[0],l=i[1],c=t(0),f=c[0],u=c[1],p=t({transform:0,transition:0,isSliding:!1}),_=p[0],L=p[1],E=t(0),b=E[0],k=E[1],x=t(g(r.children.length,r.show,r.infinite,b)),C=x[0],T=x[1],M=function(e,t){if(!(_.isSliding||e===d.Right&&!C.right||e===d.Left&&!C.left)){var n=function(e,t,n,r){var i=e-r*t;return i<0?n+i:n<=i?i-n:i}(b,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),L({transform:_.transform+v(f,t,e),transition:r.transition,isSliding:!0}),k(n),T(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)),L({transform:r.infinite?v(f,t,d.Right):_.transform+v(f,t,e),transition:0,isSliding:!1})}),1e3*r.transition)}};return e.createElement("div",o({},r.a11y,{"":"carousel",tabIndex:0},r.useArrowKeys?{onKeyDown:function(e){37===e.keyCode?M(d.Left,r.slide):39===e.keyCode&&M(d.Right,r.slide)}}:{},{className:a+" "+r.className}),C.left&&e.createElement(h,{direction:"left",onClick:function(){return M(d.Left,r.slide)}}),e.createElement(w,o({},r,{transition:_.transition,items:s,transform:_.transform,slideCallback:function(e){M(e,r.slide)},dragCallback:function(e){L({transform:e,transition:r.transition,isSliding:!1}),setTimeout((function(){return L(o(o({},_),{transition:0}))}),1e3*r.transition)},widthCallBack:function(e,t){u(e),L({transform:r.infinite?v(e,t,d.Right):0,transition:0,isSliding:!1})}})),C.right&&e.createElement(h,{direction:"right",onClick:function(){return M(d.Right,r.slide)}}))},L="styles-module_sliderBase__swkx1",E="styles-module_slider__o0fqa",b="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 k=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]),k=function(e){f(!1),w(v()),a.current.classList.remove(b)},x=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;C(500,t,n)},C=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:L+" "+s},p.left&&e.createElement("div",{"data-arrow":"left"},e.createElement("button",{onClick:function(){return x(d.Right)}})),p.right&&e.createElement("div",{"data-arrow":"right"},e.createElement("button",{onClick:function(){return x(d.Left)}})),e.createElement("div",{ref:_,onMouseDown:function(e){f(!0),m({startX:e.pageX-a.current.offsetLeft,scrollLeft:a.current.scrollLeft})},onMouseLeave:k,onMouseUp:k,onMouseMove:function(e){if(c){e.preventDefault(),a.current.classList.add(b);var t=e.pageX-a.current.offsetLeft-h.startX;a.current.scrollLeft=h.scrollLeft-t}},className:E},o))};export{_ as Carousel,k as ScrollingCarousel};

@@ -1,5 +0,4 @@

import React, { FunctionComponent } from 'react';
import { FunctionComponent } from 'react';
import { Item, SlideDirection } from '../../types/carousel';
export declare const ItemProviderBase: FunctionComponent<ItemProviderProps>;
export declare const ItemProvider: React.NamedExoticComponent<ItemProviderProps>;
export declare const ItemProvider: FunctionComponent<ItemProviderProps>;
export interface ItemProviderProps {

@@ -6,0 +5,0 @@ items: Item[];

{
"name": "@trendyol-js/react-carousel",
"version": "1.0.4",
"version": "1.0.5",
"description": "Lightweight carousel component for react",

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