Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-slot-counter

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-slot-counter - npm Package Compare versions

Comparing version 1.13.0 to 1.13.1

2

lib/index.esm.js
'use client';
import n,{memo as e,useState as t,useRef as r,useEffect as a,forwardRef as i,useMemo as o,useCallback as u,useImperativeHandle as l}from"react";var c=function(){return c=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var a in e=arguments[t])Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n},c.apply(this,arguments)};var s=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},d=function(n,e){for(var t=[],r=n;r<e;r+=1)t.push(r);return t},f=function(n,e){var t=Math.random()*(e-n);return Math.floor(t+n)},m=function(n){for(var e,t=function(n,e,t){if(t||2===arguments.length)for(var r,a=0,i=e.length;a<i;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return n.concat(r||Array.prototype.slice.call(e))}([],n,!0),r=t.length-1;r>0;r-=1){var a=Math.floor(Math.random()*(r+1));e=[t[a],t[r]],t[r]=e[0],t[a]=e[1]}return t},v=function(n){return"number"==typeof n?n:(Array.isArray(n)?n.join(""):n).replace(/[,.]/g,"")},h=function(n){return"object"!=typeof n&&!Number.isNaN(v(n))},p=function(n){return"object"==typeof n};var y="index-module_slot_wrap__ZT-DX",g="index-module_slot__DpPgW",_="index-module_separator__7GhtE",b="index-module_numbers__sqlqm",x="index-module_num__j6XH3";!function(n,e){void 0===e&&(e={});var t=e.insertAt;if(n&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===t&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=n:a.appendChild(document.createTextNode(n))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: bottom;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: bottom;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var N="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;var C=e((function(e){var i=e.charClassName,o=e.numbersRef,u=e.active,l=e.isChanged,f=e.effectiveDuration,v=e.delay,p=e.value,y=e.startValue,_=e.dummyList,C=e.hasInfiniteList,A=e.valueClassName,E=e.reverse,M=e.sequentialAnimationMode,w=e.useMonospaceWidth,S=t(!1),T=S[0],j=S[1],k=t(p),q=k[0],D=k[1],L=r(),O=r(p),B=r(null),W=t(M?_:m(_)),V=W[0],X=W[1],Y=t(0),H=Y[0],I=Y[1],P=t(0),R=P[0],G=P[1],Z=t(!1),F=Z[0],J=Z[1],U=H*(_.length+1),z="object"!=typeof p&&h(p);N((function(){J(!0)}),[]),N((function(){var n,e;I(null!==(e=null===(n=B.current)||void 0===n?void 0:n.offsetHeight)&&void 0!==e?e:0)}),[F]),N((function(){if(z&&w){var n=d(0,10).map((function(n){var e,t,r=document.createElement("div");r.style.position="absolute",r.style.top="0",r.style.left="-9999px",r.style.visibility="hidden",r.textContent=n.toString(),null===(e=B.current)||void 0===e||e.appendChild(r);var a=r.getBoundingClientRect().width;return null===(t=B.current)||void 0===t||t.removeChild(r),a})),e=Math.max.apply(Math,n);G(e)}}),[z,w,F]),a((function(){j(u)}),[u]),a((function(){T&&(L.current=O.current,O.current=p,setTimeout((function(){return D(p)}),M?0:1e3*f*1.3/_.length+1e3*v))}),[T,p,f,v,_.length,M]),a((function(){X(M?_:m(_))}),[p,_,M]);var K=function(){return V.map((function(e,t){return n.createElement("span",{key:t,className:x,"aria-hidden":"true"},e)}))};return n.createElement("span",{className:s(g,i),style:{display:"inline-block",width:F&&w?R:void 0,height:F?H:void 0}},n.createElement("span",{ref:o,className:b,style:c({transition:"none",transform:E?"translateY(-".concat(U,"px)"):"translateY(0px)"},T&&l&&{transform:E?"translateY(0px)":"translateY(-".concat(U,"px)"),transition:"transform ".concat(f,"s ").concat(v,"s ease-in-out")})},F?n.createElement(n.Fragment,null,n.createElement("span",{className:x,"aria-hidden":"true",style:{height:H}},M&&(E?q:L.current),!M&&(null!=y?y:q)),K(),n.createElement("span",{className:s(x,A),ref:B},!M&&q,M&&(E?L.current:q)),C?K():null):n.createElement("span",{className:x,"aria-hidden":"true"},y||q)))}));var A=[",","."," "];var E=e(i((function(e,i){var c,m,g,b,x,N,E,M,w=e.value,S=e.startValue,T=e.startValueOnce,j=void 0!==T&&T,k=e.duration,q=void 0===k?.7:k,D=e.dummyCharacters,L=e.dummyCharacterCount,O=void 0===L?6:L,B=e.autoAnimationStart,W=void 0===B||B,V=e.containerClassName,X=e.charClassName,Y=e.separatorClassName,H=e.animateUnchanged,I=void 0!==H&&H,P=e.hasInfiniteList,R=void 0!==P&&P,G=e.valueClassName,Z=e.sequentialAnimationMode,F=void 0!==Z&&Z,J=e.useMonospaceWidth,U=void 0!==J&&J,z=e.direction,K=e.debounceDelay,Q=function(n,e){var r=t(n),i=r[0],o=r[1];return a((function(){if(0===e)return o(n);var t=setTimeout((function(){o(n)}),e);return function(){clearTimeout(t)}}),[n,e]),i}(w,null!=K?K:0),$=o((function(){return function(n){return Array.isArray(n)&&p(n[0])}(Q)?"":JSON.stringify(Q)}),[Q]),nn=t(!1),en=nn[0],tn=nn[1],rn=r(),an=r(null),on=r(Q),un=r(),ln=r(0),cn=r(0),sn=t([]),dn=sn[0],fn=sn[1],mn=r(),vn=null!==(m=null===(c=rn.current)||void 0===c?void 0:c.dummyCharacterCount)&&void 0!==m?m:O,hn=null!==(b=null===(g=rn.current)||void 0===g?void 0:g.duration)&&void 0!==b?b:q;a((function(){fn(d(0,vn-1).map((function(n){if(!D)return f(0,10);var e=n>=D.length?f(0,D.length):n;return D[e]})))}),[D,vn]),o((function(){on.current!==Q&&(un.current=on.current,on.current=Q)}),[Q]);var pn=Array.isArray(un.current)?un.current:null!==(N=null===(x=un.current)||void 0===x?void 0:x.toString().split(""))&&void 0!==N?N:[],yn=Array.isArray(on.current)?on.current:null!==(M=null===(E=on.current)||void 0===E?void 0:E.toString().split(""))&&void 0!==M?M:[],gn=o((function(){return Array.isArray(Q)?Q:Q.toString().split("")}),[Q]),_n=o((function(){return Array.isArray(S)?S:null==S?void 0:S.toString().split("")}),[S]),bn=pn.length!==yn.length,xn=[];yn.forEach((function(n,e){var t=yn.length-e-1;(yn[t]!==pn[t]||bn||I)&&xn.push(t)})),xn.reverse();var Nn=o((function(){return Math.min(.1,hn/gn.length)}),[hn,gn.length]),Cn=u((function(){mn.current&&clearTimeout(mn.current),tn(!1),ln.current=cn.current,ln.current+=1,mn.current=setTimeout((function(){cn.current+=1,tn(!0)}),20)}),[]),An=u((function(n){un.current=void 0,rn.current=n,Cn()}),[Cn]),En=u((function(n){var e=un.current;if(null==e||!h(e)||!h(Q))return[];var t=Number(v(e)),r=Number(v(Q)),a=Math.pow(10,n-1),i=t<r?d(Math.floor(t/a)+1,Math.floor(r/a)):d(Math.floor(r/a)+1,Math.floor(t/a));return Array.from(new Set(i.map((function(n){return n.toString()[n.toString().length-1]})))).filter(Boolean)}),[Q]);return a((function(){null!=un.current&&Cn()}),[$,Cn,W]),a((function(){W&&Cn()}),[W,Cn]),l(i,(function(){return{startAnimation:An}})),n.createElement("span",{className:s(V,y)},gn.map((function(e,t){var r,a,i=xn.includes(t),o=(i?xn.indexOf(t):0)*Nn,u=un.current,l=j&&ln.current>1,c=null!=Q&&null!=u&&h(Q)&&h(u)&&v(Q)<v(u);return(null===(r=rn.current)||void 0===r?void 0:r.direction)&&(c="top-down"===(null===(a=rn.current)||void 0===a?void 0:a.direction)),z&&(c="top-down"===z),!p(e)&&A.includes(e)?n.createElement("span",{key:yn.length-t-1,className:s(_,Y)},e):n.createElement(C,{key:yn.length-t-1,numbersRef:an,active:en,isChanged:i,charClassName:X,effectiveDuration:hn,delay:o,value:e,startValue:l||null==_n?void 0:_n[t],dummyList:F?En(gn.length-t):dn,hasInfiniteList:R,valueClassName:G,reverse:c,sequentialAnimationMode:F,useMonospaceWidth:U})})))})));export{E as default};
import n,{memo as e,useState as t,useRef as r,useEffect as a,forwardRef as i,useMemo as o,useCallback as u,useImperativeHandle as l}from"react";var c=function(){return c=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var a in e=arguments[t])Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n},c.apply(this,arguments)};var s=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},d=function(n,e){for(var t=[],r=n;r<e;r+=1)t.push(r);return t},f=function(n,e){var t=Math.random()*(e-n);return Math.floor(t+n)},m=function(n){for(var e,t=function(n,e,t){if(t||2===arguments.length)for(var r,a=0,i=e.length;a<i;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return n.concat(r||Array.prototype.slice.call(e))}([],n,!0),r=t.length-1;r>0;r-=1){var a=Math.floor(Math.random()*(r+1));e=[t[a],t[r]],t[r]=e[0],t[a]=e[1]}return t},v=function(n){return"number"==typeof n?n:(Array.isArray(n)?n.join(""):n).replace(/[,.]/g,"")},h=function(n){return"object"!=typeof n&&!Number.isNaN(v(n))},p=function(n){return"object"==typeof n};var y="index-module_slot_wrap__ZT-DX",g="index-module_slot__DpPgW",_="index-module_separator__7GhtE",b="index-module_numbers__sqlqm",x="index-module_num__j6XH3";!function(n,e){void 0===e&&(e={});var t=e.insertAt;if(n&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===t&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=n:a.appendChild(document.createTextNode(n))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: bottom;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: bottom;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var N="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;var C=e((function(e){var i=e.charClassName,o=e.numbersRef,u=e.active,l=e.isChanged,f=e.effectiveDuration,v=e.delay,p=e.value,y=e.startValue,_=e.dummyList,C=e.hasInfiniteList,A=e.valueClassName,E=e.reverse,M=e.sequentialAnimationMode,w=e.useMonospaceWidth,S=t(!1),T=S[0],j=S[1],k=t(p),q=k[0],D=k[1],L=r(),O=r(p),B=r(null),W=t(M?_:m(_)),V=W[0],X=W[1],Y=t(0),H=Y[0],I=Y[1],P=t(0),R=P[0],F=P[1],G=t(!1),Z=G[0],J=G[1],U=H*(_.length+1),z="object"!=typeof p&&h(p);N((function(){J(!0)}),[]),N((function(){var n,e;I(null!==(e=null===(n=B.current)||void 0===n?void 0:n.offsetHeight)&&void 0!==e?e:0)}),[Z]),N((function(){if(z&&w){var n=d(0,10).map((function(n){var e,t,r=document.createElement("div");r.style.position="absolute",r.style.top="0",r.style.left="-9999px",r.style.visibility="hidden",r.textContent=n.toString(),null===(e=B.current)||void 0===e||e.appendChild(r);var a=r.getBoundingClientRect().width;return null===(t=B.current)||void 0===t||t.removeChild(r),a})),e=Math.max.apply(Math,n);F(e)}}),[z,w,Z]),a((function(){requestAnimationFrame((function(){j(u)}))}),[u]),a((function(){T&&(L.current=O.current,O.current=p,setTimeout((function(){return D(p)}),M?0:1e3*f*1.3/_.length+1e3*v))}),[T,p,f,v,_.length,M]),a((function(){X(M?_:m(_))}),[p,_,M]);var K=function(){return V.map((function(e,t){return n.createElement("span",{key:t,className:x,"aria-hidden":"true"},e)}))};return n.createElement("span",{className:s(g,i),style:{display:"inline-block",width:Z&&w?R:void 0,height:Z?H:void 0}},n.createElement("span",{ref:o,className:b,style:c({transition:"none",transform:E?"translateY(-".concat(U,"px)"):"translateY(0px)"},T&&l&&{transform:E?"translateY(0px)":"translateY(-".concat(U,"px)"),transition:"transform ".concat(f,"s ").concat(v,"s ease-in-out")})},Z?n.createElement(n.Fragment,null,n.createElement("span",{className:x,"aria-hidden":"true",style:{height:H}},M&&(E?q:L.current),!M&&(E?q:null!=y?y:q)),K(),n.createElement("span",{className:s(x,A),ref:B},M&&(E?L.current:q),!M&&E&&null!=y?y:q),C?K():null):n.createElement("span",{className:x,"aria-hidden":"true"},y||q)))}));var A=[",","."," "];var E=e(i((function(e,i){var c,m,g,b,x,N,E,M,w=e.value,S=e.startValue,T=e.startValueOnce,j=void 0!==T&&T,k=e.duration,q=void 0===k?.7:k,D=e.dummyCharacters,L=e.dummyCharacterCount,O=void 0===L?6:L,B=e.autoAnimationStart,W=void 0===B||B,V=e.containerClassName,X=e.charClassName,Y=e.separatorClassName,H=e.animateUnchanged,I=void 0!==H&&H,P=e.hasInfiniteList,R=void 0!==P&&P,F=e.valueClassName,G=e.sequentialAnimationMode,Z=void 0!==G&&G,J=e.useMonospaceWidth,U=void 0!==J&&J,z=e.direction,K=e.debounceDelay,Q=function(n,e){var r=t(n),i=r[0],o=r[1];return a((function(){if(0===e)return o(n);var t=setTimeout((function(){o(n)}),e);return function(){clearTimeout(t)}}),[n,e]),i}(w,null!=K?K:0),$=o((function(){return function(n){return Array.isArray(n)&&p(n[0])}(Q)?"":JSON.stringify(Q)}),[Q]),nn=t(!1),en=nn[0],tn=nn[1],rn=r(),an=r(null),on=r(Q),un=r(),ln=r(0),cn=r(0),sn=t([]),dn=sn[0],fn=sn[1],mn=r(),vn=null!==(m=null===(c=rn.current)||void 0===c?void 0:c.dummyCharacterCount)&&void 0!==m?m:O,hn=null!==(b=null===(g=rn.current)||void 0===g?void 0:g.duration)&&void 0!==b?b:q;a((function(){fn(d(0,vn-1).map((function(n){if(!D)return f(0,10);var e=n>=D.length?f(0,D.length):n;return D[e]})))}),[D,vn]),o((function(){on.current!==Q&&(un.current=on.current,on.current=Q)}),[Q]);var pn=Array.isArray(un.current)?un.current:null!==(N=null===(x=un.current)||void 0===x?void 0:x.toString().split(""))&&void 0!==N?N:[],yn=Array.isArray(on.current)?on.current:null!==(M=null===(E=on.current)||void 0===E?void 0:E.toString().split(""))&&void 0!==M?M:[],gn=o((function(){return Array.isArray(Q)?Q:Q.toString().split("")}),[Q]),_n=o((function(){return Array.isArray(S)?S:null==S?void 0:S.toString().split("")}),[S]),bn=pn.length!==yn.length,xn=[];yn.forEach((function(n,e){var t=yn.length-e-1;(yn[t]!==pn[t]||bn||I)&&xn.push(t)})),xn.reverse();var Nn=o((function(){return Math.min(.1,hn/gn.length)}),[hn,gn.length]),Cn=u((function(){mn.current&&clearTimeout(mn.current),tn(!1),ln.current=cn.current,ln.current+=1,mn.current=setTimeout((function(){cn.current+=1,tn(!0)}),20)}),[]),An=u((function(n){un.current=void 0,rn.current=n,Cn()}),[Cn]),En=u((function(n){var e=un.current;if(null==e||!h(e)||!h(Q))return[];var t=Number(v(e)),r=Number(v(Q)),a=Math.pow(10,n-1),i=t<r?d(Math.floor(t/a)+1,Math.floor(r/a)):d(Math.floor(r/a)+1,Math.floor(t/a));return Array.from(new Set(i.map((function(n){return n.toString()[n.toString().length-1]})))).filter(Boolean)}),[Q]);return a((function(){null!=un.current&&Cn()}),[$,Cn,W]),a((function(){W&&Cn()}),[W,Cn]),l(i,(function(){return{startAnimation:An}})),n.createElement("span",{className:s(V,y)},gn.map((function(e,t){var r,a,i=xn.includes(t),o=(i?xn.indexOf(t):0)*Nn,u=un.current,l=j&&ln.current>1,c=null!=Q&&null!=u&&h(Q)&&h(u)&&v(Q)<v(u);return(null===(r=rn.current)||void 0===r?void 0:r.direction)&&(c="top-down"===(null===(a=rn.current)||void 0===a?void 0:a.direction)),z&&(c="top-down"===z),!p(e)&&A.includes(e)?n.createElement("span",{key:yn.length-t-1,className:s(_,Y)},e):n.createElement(C,{key:yn.length-t-1,numbersRef:an,active:en,isChanged:i,charClassName:X,effectiveDuration:hn,delay:o,value:e,startValue:l||null==_n?void 0:_n[t],dummyList:Z?En(gn.length-t):dn,hasInfiniteList:R,valueClassName:F,reverse:c,sequentialAnimationMode:Z,useMonospaceWidth:U})})))})));export{E as default};
//# sourceMappingURL=index.esm.js.map
'use client';
"use strict";var e=require("react"),t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},t.apply(this,arguments)};var n=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter(Boolean).join(" ")},r=function(e,t){for(var n=[],r=e;r<t;r+=1)n.push(r);return n},a=function(e,t){var n=Math.random()*(t-e);return Math.floor(n+e)},u=function(e){for(var t,n=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,u=t.length;a<u;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0),r=n.length-1;r>0;r-=1){var a=Math.floor(Math.random()*(r+1));t=[n[a],n[r]],n[r]=t[0],n[a]=t[1]}return n},i=function(e){return"number"==typeof e?e:(Array.isArray(e)?e.join(""):e).replace(/[,.]/g,"")},o=function(e){return"object"!=typeof e&&!Number.isNaN(i(e))},l=function(e){return"object"==typeof e};var s="index-module_slot_wrap__ZT-DX",c="index-module_slot__DpPgW",d="index-module_separator__7GhtE",f="index-module_numbers__sqlqm",m="index-module_num__j6XH3";!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: bottom;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: bottom;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var v="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;var h=e.memo((function(a){var i=a.charClassName,l=a.numbersRef,s=a.active,d=a.isChanged,h=a.effectiveDuration,p=a.delay,y=a.value,g=a.startValue,_=a.dummyList,b=a.hasInfiniteList,C=a.valueClassName,E=a.reverse,x=a.sequentialAnimationMode,N=a.useMonospaceWidth,M=e.useState(!1),A=M[0],S=M[1],w=e.useState(y),R=w[0],k=w[1],T=e.useRef(),j=e.useRef(y),q=e.useRef(null),D=e.useState(x?_:u(_)),L=D[0],O=D[1],B=e.useState(0),W=B[0],H=B[1],I=e.useState(0),V=I[0],X=I[1],Y=e.useState(!1),P=Y[0],G=Y[1],Z=W*(_.length+1),F="object"!=typeof y&&o(y);v((function(){G(!0)}),[]),v((function(){var e,t;H(null!==(t=null===(e=q.current)||void 0===e?void 0:e.offsetHeight)&&void 0!==t?t:0)}),[P]),v((function(){if(F&&N){var e=r(0,10).map((function(e){var t,n,r=document.createElement("div");r.style.position="absolute",r.style.top="0",r.style.left="-9999px",r.style.visibility="hidden",r.textContent=e.toString(),null===(t=q.current)||void 0===t||t.appendChild(r);var a=r.getBoundingClientRect().width;return null===(n=q.current)||void 0===n||n.removeChild(r),a})),t=Math.max.apply(Math,e);X(t)}}),[F,N,P]),e.useEffect((function(){S(s)}),[s]),e.useEffect((function(){A&&(T.current=j.current,j.current=y,setTimeout((function(){return k(y)}),x?0:1e3*h*1.3/_.length+1e3*p))}),[A,y,h,p,_.length,x]),e.useEffect((function(){O(x?_:u(_))}),[y,_,x]);var J=function(){return L.map((function(t,n){return e.createElement("span",{key:n,className:m,"aria-hidden":"true"},t)}))};return e.createElement("span",{className:n(c,i),style:{display:"inline-block",width:P&&N?V:void 0,height:P?W:void 0}},e.createElement("span",{ref:l,className:f,style:t({transition:"none",transform:E?"translateY(-".concat(Z,"px)"):"translateY(0px)"},A&&d&&{transform:E?"translateY(0px)":"translateY(-".concat(Z,"px)"),transition:"transform ".concat(h,"s ").concat(p,"s ease-in-out")})},P?e.createElement(e.Fragment,null,e.createElement("span",{className:m,"aria-hidden":"true",style:{height:W}},x&&(E?R:T.current),!x&&(null!=g?g:R)),J(),e.createElement("span",{className:n(m,C),ref:q},!x&&R,x&&(E?T.current:R)),b?J():null):e.createElement("span",{className:m,"aria-hidden":"true"},g||R)))}));var p=[",","."," "];var y=e.memo(e.forwardRef((function(t,u){var c,f,m,v,y,g,_,b,C=t.value,E=t.startValue,x=t.startValueOnce,N=void 0!==x&&x,M=t.duration,A=void 0===M?.7:M,S=t.dummyCharacters,w=t.dummyCharacterCount,R=void 0===w?6:w,k=t.autoAnimationStart,T=void 0===k||k,j=t.containerClassName,q=t.charClassName,D=t.separatorClassName,L=t.animateUnchanged,O=void 0!==L&&L,B=t.hasInfiniteList,W=void 0!==B&&B,H=t.valueClassName,I=t.sequentialAnimationMode,V=void 0!==I&&I,X=t.useMonospaceWidth,Y=void 0!==X&&X,P=t.direction,G=t.debounceDelay,Z=function(t,n){var r=e.useState(t),a=r[0],u=r[1];return e.useEffect((function(){if(0===n)return u(t);var e=setTimeout((function(){u(t)}),n);return function(){clearTimeout(e)}}),[t,n]),a}(C,null!=G?G:0),F=e.useMemo((function(){return function(e){return Array.isArray(e)&&l(e[0])}(Z)?"":JSON.stringify(Z)}),[Z]),J=e.useState(!1),U=J[0],z=J[1],K=e.useRef(),Q=e.useRef(null),$=e.useRef(Z),ee=e.useRef(),te=e.useRef(0),ne=e.useRef(0),re=e.useState([]),ae=re[0],ue=re[1],ie=e.useRef(),oe=null!==(f=null===(c=K.current)||void 0===c?void 0:c.dummyCharacterCount)&&void 0!==f?f:R,le=null!==(v=null===(m=K.current)||void 0===m?void 0:m.duration)&&void 0!==v?v:A;e.useEffect((function(){ue(r(0,oe-1).map((function(e){if(!S)return a(0,10);var t=e>=S.length?a(0,S.length):e;return S[t]})))}),[S,oe]),e.useMemo((function(){$.current!==Z&&(ee.current=$.current,$.current=Z)}),[Z]);var se=Array.isArray(ee.current)?ee.current:null!==(g=null===(y=ee.current)||void 0===y?void 0:y.toString().split(""))&&void 0!==g?g:[],ce=Array.isArray($.current)?$.current:null!==(b=null===(_=$.current)||void 0===_?void 0:_.toString().split(""))&&void 0!==b?b:[],de=e.useMemo((function(){return Array.isArray(Z)?Z:Z.toString().split("")}),[Z]),fe=e.useMemo((function(){return Array.isArray(E)?E:null==E?void 0:E.toString().split("")}),[E]),me=se.length!==ce.length,ve=[];ce.forEach((function(e,t){var n=ce.length-t-1;(ce[n]!==se[n]||me||O)&&ve.push(n)})),ve.reverse();var he=e.useMemo((function(){return Math.min(.1,le/de.length)}),[le,de.length]),pe=e.useCallback((function(){ie.current&&clearTimeout(ie.current),z(!1),te.current=ne.current,te.current+=1,ie.current=setTimeout((function(){ne.current+=1,z(!0)}),20)}),[]),ye=e.useCallback((function(e){ee.current=void 0,K.current=e,pe()}),[pe]),ge=e.useCallback((function(e){var t=ee.current;if(null==t||!o(t)||!o(Z))return[];var n=Number(i(t)),a=Number(i(Z)),u=Math.pow(10,e-1),l=n<a?r(Math.floor(n/u)+1,Math.floor(a/u)):r(Math.floor(a/u)+1,Math.floor(n/u));return Array.from(new Set(l.map((function(e){return e.toString()[e.toString().length-1]})))).filter(Boolean)}),[Z]);return e.useEffect((function(){null!=ee.current&&pe()}),[F,pe,T]),e.useEffect((function(){T&&pe()}),[T,pe]),e.useImperativeHandle(u,(function(){return{startAnimation:ye}})),e.createElement("span",{className:n(j,s)},de.map((function(t,r){var a,u,s=ve.includes(r),c=(s?ve.indexOf(r):0)*he,f=ee.current,m=N&&te.current>1,v=null!=Z&&null!=f&&o(Z)&&o(f)&&i(Z)<i(f);return(null===(a=K.current)||void 0===a?void 0:a.direction)&&(v="top-down"===(null===(u=K.current)||void 0===u?void 0:u.direction)),P&&(v="top-down"===P),!l(t)&&p.includes(t)?e.createElement("span",{key:ce.length-r-1,className:n(d,D)},t):e.createElement(h,{key:ce.length-r-1,numbersRef:Q,active:U,isChanged:s,charClassName:q,effectiveDuration:le,delay:c,value:t,startValue:m||null==fe?void 0:fe[r],dummyList:V?ge(de.length-r):ae,hasInfiniteList:W,valueClassName:H,reverse:v,sequentialAnimationMode:V,useMonospaceWidth:Y})})))})));module.exports=y;
"use strict";var e=require("react"),t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},t.apply(this,arguments)};var n=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter(Boolean).join(" ")},r=function(e,t){for(var n=[],r=e;r<t;r+=1)n.push(r);return n},a=function(e,t){var n=Math.random()*(t-e);return Math.floor(n+e)},u=function(e){for(var t,n=function(e,t,n){if(n||2===arguments.length)for(var r,a=0,u=t.length;a<u;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}([],e,!0),r=n.length-1;r>0;r-=1){var a=Math.floor(Math.random()*(r+1));t=[n[a],n[r]],n[r]=t[0],n[a]=t[1]}return n},i=function(e){return"number"==typeof e?e:(Array.isArray(e)?e.join(""):e).replace(/[,.]/g,"")},o=function(e){return"object"!=typeof e&&!Number.isNaN(i(e))},l=function(e){return"object"==typeof e};var s="index-module_slot_wrap__ZT-DX",c="index-module_slot__DpPgW",d="index-module_separator__7GhtE",f="index-module_numbers__sqlqm",m="index-module_num__j6XH3";!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: bottom;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: bottom;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var v="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;var h=e.memo((function(a){var i=a.charClassName,l=a.numbersRef,s=a.active,d=a.isChanged,h=a.effectiveDuration,p=a.delay,y=a.value,g=a.startValue,_=a.dummyList,b=a.hasInfiniteList,C=a.valueClassName,E=a.reverse,x=a.sequentialAnimationMode,N=a.useMonospaceWidth,M=e.useState(!1),A=M[0],S=M[1],w=e.useState(y),R=w[0],k=w[1],T=e.useRef(),j=e.useRef(y),q=e.useRef(null),D=e.useState(x?_:u(_)),L=D[0],O=D[1],B=e.useState(0),W=B[0],H=B[1],I=e.useState(0),V=I[0],X=I[1],Y=e.useState(!1),P=Y[0],F=Y[1],G=W*(_.length+1),Z="object"!=typeof y&&o(y);v((function(){F(!0)}),[]),v((function(){var e,t;H(null!==(t=null===(e=q.current)||void 0===e?void 0:e.offsetHeight)&&void 0!==t?t:0)}),[P]),v((function(){if(Z&&N){var e=r(0,10).map((function(e){var t,n,r=document.createElement("div");r.style.position="absolute",r.style.top="0",r.style.left="-9999px",r.style.visibility="hidden",r.textContent=e.toString(),null===(t=q.current)||void 0===t||t.appendChild(r);var a=r.getBoundingClientRect().width;return null===(n=q.current)||void 0===n||n.removeChild(r),a})),t=Math.max.apply(Math,e);X(t)}}),[Z,N,P]),e.useEffect((function(){requestAnimationFrame((function(){S(s)}))}),[s]),e.useEffect((function(){A&&(T.current=j.current,j.current=y,setTimeout((function(){return k(y)}),x?0:1e3*h*1.3/_.length+1e3*p))}),[A,y,h,p,_.length,x]),e.useEffect((function(){O(x?_:u(_))}),[y,_,x]);var J=function(){return L.map((function(t,n){return e.createElement("span",{key:n,className:m,"aria-hidden":"true"},t)}))};return e.createElement("span",{className:n(c,i),style:{display:"inline-block",width:P&&N?V:void 0,height:P?W:void 0}},e.createElement("span",{ref:l,className:f,style:t({transition:"none",transform:E?"translateY(-".concat(G,"px)"):"translateY(0px)"},A&&d&&{transform:E?"translateY(0px)":"translateY(-".concat(G,"px)"),transition:"transform ".concat(h,"s ").concat(p,"s ease-in-out")})},P?e.createElement(e.Fragment,null,e.createElement("span",{className:m,"aria-hidden":"true",style:{height:W}},x&&(E?R:T.current),!x&&(E?R:null!=g?g:R)),J(),e.createElement("span",{className:n(m,C),ref:q},x&&(E?T.current:R),!x&&E&&null!=g?g:R),b?J():null):e.createElement("span",{className:m,"aria-hidden":"true"},g||R)))}));var p=[",","."," "];var y=e.memo(e.forwardRef((function(t,u){var c,f,m,v,y,g,_,b,C=t.value,E=t.startValue,x=t.startValueOnce,N=void 0!==x&&x,M=t.duration,A=void 0===M?.7:M,S=t.dummyCharacters,w=t.dummyCharacterCount,R=void 0===w?6:w,k=t.autoAnimationStart,T=void 0===k||k,j=t.containerClassName,q=t.charClassName,D=t.separatorClassName,L=t.animateUnchanged,O=void 0!==L&&L,B=t.hasInfiniteList,W=void 0!==B&&B,H=t.valueClassName,I=t.sequentialAnimationMode,V=void 0!==I&&I,X=t.useMonospaceWidth,Y=void 0!==X&&X,P=t.direction,F=t.debounceDelay,G=function(t,n){var r=e.useState(t),a=r[0],u=r[1];return e.useEffect((function(){if(0===n)return u(t);var e=setTimeout((function(){u(t)}),n);return function(){clearTimeout(e)}}),[t,n]),a}(C,null!=F?F:0),Z=e.useMemo((function(){return function(e){return Array.isArray(e)&&l(e[0])}(G)?"":JSON.stringify(G)}),[G]),J=e.useState(!1),U=J[0],z=J[1],K=e.useRef(),Q=e.useRef(null),$=e.useRef(G),ee=e.useRef(),te=e.useRef(0),ne=e.useRef(0),re=e.useState([]),ae=re[0],ue=re[1],ie=e.useRef(),oe=null!==(f=null===(c=K.current)||void 0===c?void 0:c.dummyCharacterCount)&&void 0!==f?f:R,le=null!==(v=null===(m=K.current)||void 0===m?void 0:m.duration)&&void 0!==v?v:A;e.useEffect((function(){ue(r(0,oe-1).map((function(e){if(!S)return a(0,10);var t=e>=S.length?a(0,S.length):e;return S[t]})))}),[S,oe]),e.useMemo((function(){$.current!==G&&(ee.current=$.current,$.current=G)}),[G]);var se=Array.isArray(ee.current)?ee.current:null!==(g=null===(y=ee.current)||void 0===y?void 0:y.toString().split(""))&&void 0!==g?g:[],ce=Array.isArray($.current)?$.current:null!==(b=null===(_=$.current)||void 0===_?void 0:_.toString().split(""))&&void 0!==b?b:[],de=e.useMemo((function(){return Array.isArray(G)?G:G.toString().split("")}),[G]),fe=e.useMemo((function(){return Array.isArray(E)?E:null==E?void 0:E.toString().split("")}),[E]),me=se.length!==ce.length,ve=[];ce.forEach((function(e,t){var n=ce.length-t-1;(ce[n]!==se[n]||me||O)&&ve.push(n)})),ve.reverse();var he=e.useMemo((function(){return Math.min(.1,le/de.length)}),[le,de.length]),pe=e.useCallback((function(){ie.current&&clearTimeout(ie.current),z(!1),te.current=ne.current,te.current+=1,ie.current=setTimeout((function(){ne.current+=1,z(!0)}),20)}),[]),ye=e.useCallback((function(e){ee.current=void 0,K.current=e,pe()}),[pe]),ge=e.useCallback((function(e){var t=ee.current;if(null==t||!o(t)||!o(G))return[];var n=Number(i(t)),a=Number(i(G)),u=Math.pow(10,e-1),l=n<a?r(Math.floor(n/u)+1,Math.floor(a/u)):r(Math.floor(a/u)+1,Math.floor(n/u));return Array.from(new Set(l.map((function(e){return e.toString()[e.toString().length-1]})))).filter(Boolean)}),[G]);return e.useEffect((function(){null!=ee.current&&pe()}),[Z,pe,T]),e.useEffect((function(){T&&pe()}),[T,pe]),e.useImperativeHandle(u,(function(){return{startAnimation:ye}})),e.createElement("span",{className:n(j,s)},de.map((function(t,r){var a,u,s=ve.includes(r),c=(s?ve.indexOf(r):0)*he,f=ee.current,m=N&&te.current>1,v=null!=G&&null!=f&&o(G)&&o(f)&&i(G)<i(f);return(null===(a=K.current)||void 0===a?void 0:a.direction)&&(v="top-down"===(null===(u=K.current)||void 0===u?void 0:u.direction)),P&&(v="top-down"===P),!l(t)&&p.includes(t)?e.createElement("span",{key:ce.length-r-1,className:n(d,D)},t):e.createElement(h,{key:ce.length-r-1,numbersRef:Q,active:U,isChanged:s,charClassName:q,effectiveDuration:le,delay:c,value:t,startValue:m||null==fe?void 0:fe[r],dummyList:V?ge(de.length-r):ae,hasInfiniteList:W,valueClassName:H,reverse:v,sequentialAnimationMode:V,useMonospaceWidth:Y})})))})));module.exports=y;
//# sourceMappingURL=index.js.map
{
"name": "react-slot-counter",
"version": "1.13.0",
"description": "A versatile and engaging component to display numbers in a captivating slot machine UI, perfect for enhancing user experience and grabbing attention in your web projects",
"version": "1.13.1",
"description": "Make Your Numbers Pop: Simple and Dynamic Counters for Your UI",
"author": "almond-bongbong",

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

# react-slot-counter 🎰
Transform Your UI with Animated Counters That Your Users Will Love
Make Your Numbers Pop 🌟: Simple and Dynamic Counters for Your UI

@@ -5,0 +5,0 @@ [![NPM](https://img.shields.io/npm/v/react-slot-counter.svg)](https://www.npmjs.com/package/react-slot-counter)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc