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

react-countdown-circle-timer

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-countdown-circle-timer - npm Package Compare versions

Comparing version 2.3.11 to 2.3.12

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [2.3.12](https://github.com/vydimitrov/react-countdown-circle-timer/compare/v2.3.11...v2.3.12) (2021-01-14)
### Bug Fixes
* **web:** support for IE11 ([201f996](https://github.com/vydimitrov/react-countdown-circle-timer/commit/201f996c478d961a02d90997bd4e3ef8a9ef8434))
## [2.3.11](https://github.com/vydimitrov/react-countdown-circle-timer/compare/v2.3.10...v2.3.11) (2021-01-10)

@@ -8,0 +19,0 @@

2

lib/index.js

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

module.exports=(()=>{var e={54:(e,t,r)=>{"use strict";r.r(t),r.d(t,{CountdownCircleTimer:()=>L});var n=r(297),o=r.n(n),i=function(e){return{position:"relative",width:e,height:e}},a={display:"flex",justifyContent:"center",alignItems:"center",position:"absolute",left:0,top:0,width:"100%",height:"100%"},u=function(e){return e.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)},c=function(e,t){return"Invalid prop '".concat(e,"' supplied to '").concat(t,"'")},l=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"array";return new Error("".concat(c(e,t),". Expect ").concat("array"===r?"an array of tuples where the first element is a":""," HEX color code string.\n ."))},s=function(e,t){return 0===t?0:"number"==typeof e?t-e:0},f=r(980),p=r.n(f),d={duration:p().number.isRequired,colors:function(e,t,r){var n=e[t];return"string"==typeof n?function(e,t,r){if(!u(e))return l(t,r,"string")}(n,t,r):function(e,t,r){for(var n=0;n<e.length;n+=1){var o=e[n][0],i=e[n][1];if(!u(o))return l(t,r);if(!(void 0===i||i>=0&&i<=1))return new Error("".concat(c(t,r),".\n Expect an array of tuples where the second element is a number between 0 and 1 representing color transition duration."))}}(n,t,r)},children:p().oneOfType([p().func,p().node]),size:p().number,strokeWidth:p().number,trailColor:p().string,isPlaying:p().bool,strokeLinecap:p().oneOf(["round","square"]),isLinearGradient:p().bool,gradientUniqueKey:p().string,onComplete:p().func,ariaLabel:p().string,renderAriaTime:p().func,initialRemainingTime:p().number,rotation:p().oneOf(["clockwise","counterclockwise"])};function y(){return(y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function m(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var v=function(e){var t=e.gradientId,r=e.colors,n=e.defs,i=void 0===n?"defs":n,a=e.linearGradient,u=void 0===a?"linearGradient":a,c=e.stop,l=void 0===c?"stop":c;return o().createElement(i,null,o().createElement(u,{id:t,x1:"1",y1:"0",x2:"0",y2:"0"},function(e){var t="string"==typeof e;if(t||1===e.length)return[{offset:1,stopColor:t?e:e[0][0],key:0}];var r,n=e.length,o=0;return[{offset:0,stopColor:e[0][0],key:0}].concat(function(e){if(Array.isArray(e))return b(e)}(r=e.map((function(e,t){var r,i,a=(i=2,function(e){if(Array.isArray(e))return e}(r=e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(r,i)||m(r,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=a[0],c=a[1];return o+=c,{offset:n===t+1?1:o,stopColor:u,key:t+1}})))||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(r)||m(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}(r).map((function(e){return o().createElement(l,y({},e,{key:e.key}))}))))},g=p().oneOfType([p().func,p().string]);v.propTypes={gradientId:p().string.isRequired,colors:d.colors,defs:g,linearGradient:g,stop:g};var h=r(592),O=function(e,t,r,n){return 0===n?r:t+r*(e/n)};function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach((function(t){S(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function S(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var P=function(e){var t=e.r,r=e.g,n=e.b,o=e.opacity;return"rgba(".concat(t,", ").concat(r,", ").concat(n,", ").concat(o,")")},T=function(e,t){if(1===e.length)return P(e[0]);var r=e.find((function(e){var r=e.colorEndTime;return t<=r}));if(void 0===r.duration)return P(r);var n=t-r.colorStartTime,o=0|O(n,r.r,r.goalR,r.duration),i=0|O(n,r.g,r.goalG,r.duration),a=0|O(n,r.b,r.goalB,r.duration);return P({r:o,g:i,b:a,opacity:r.opacity})},A={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:0,clip:"rect(0 0 0 0)",padding:0,overflow:"hidden",whiteSpace:"nowrap",wordWrap:"normal"};function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var x=function(e){var t=e.isPlaying,r=e.size,o=e.strokeWidth,u=e.duration,c=e.initialRemainingTime,l=e.colors,f=e.isLinearGradient,p=e.gradientUniqueKey,d=e.onComplete,y=e.rotation,m=(0,n.useRef)({duration:u,startAt:s(c,u)}).current,b=m.duration,v=m.startAt,g=(0,n.useMemo)((function(){return function(e,t,r){var n=e/2,o=t/2,i=n-o,a=2*i,u="clockwise"===r?"1,0":"0,1",c=2*Math.PI*i;return{path:"m ".concat(n,",").concat(o,"\n a ").concat(i,",").concat(i," 0 ").concat(u," 0,").concat(a,"\n a ").concat(i,",").concat(i," 0 ").concat(u," 0,-").concat(a),pathLength:c}}(r,o,y)}),[r,o,y]),w=g.path,S=g.pathLength,k=(0,n.useMemo)((function(){return function(e,t,r){var n=function(e,t){var r=function(e){return e.map((function(e){var t=e[0].replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,r,n){return"#".concat(t).concat(t).concat(r).concat(r).concat(n).concat(n)})).substring(1).match(/.{2}/g).map((function(e){return parseInt(e,16)}));return[{r:t[0],g:t[1],b:t[2],opacity:1},e[1]]}))}(e);if(!t)return r;var n=0;return r.map((function(e,t){var o=r.length===t+1,i="0%";if(t>0){var a=r[t-1][1],u=Math.round(100*a);(n+=u)>100||o?(n=100,i="100%"):i="".concat(n,"%")}var c={offset:i,stopColor:P(e[0]),key:t};return[j(j({},e[0]),{},{gradient:c}),e[1]]}))}("string"==typeof e?[[e,1]]:e,r),o=0;return n.map((function(e,r){var i=n.length===r+1;if(o>=t||i)return o=t,j(j({},e[0]),{},{colorEndTime:o});var a=o,u=void 0!==e[1]?a+e[1]*t:t,c=u>=t?t:u,l=n[r+1][0],s={goalR:l.r-e[0].r,goalG:l.g-e[0].g,goalB:l.b-e[0].b};return o=c,j(j(j({},e[0]),s),{},{colorStartTime:a,colorEndTime:c,duration:c-a})}))}(l,b,f)}),[l,b,f]),x=(0,n.useMemo)((function(){return function(e){return"countdown-circle-timer-gradient-".concat(e||Math.random().toString(36).substring(2))}(p)}),[p]),C=(0,h.useElapsedTime)(t,{duration:b,startAt:v,onComplete:"function"==typeof d?function(){var e=d.apply(void 0,arguments)||[],t=E(e,2),r=t[0],n=void 0!==r&&r,o=t[1],i=void 0===o?0:o;return{shouldRepeat:n,delay:i/1e3,newStartAt:0}}:void 0}).elapsedTime;return{path:w,pathLength:S,gradientId:x,stroke:T(k,C),strokeDashoffset:O(C,0,S,b),timeProps:{remainingTime:Math.ceil(b-C),elapsedTime:C},styles:{wrapperStyle:i(r),timeStyle:a,visuallyHidden:A}}};function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var L=function(e){var t=e.size,r=e.strokeWidth,n=e.trailColor,i=e.duration,a=e.isPlaying,u=e.colors,c=e.strokeLinecap,l=e.children,s=e.isLinearGradient,f=e.gradientUniqueKey,p=e.onComplete,d=e.ariaLabel,y=e.renderAriaTime,m=e.initialRemainingTime,b=e.rotation,g=x({isPlaying:a,size:t,strokeWidth:r,duration:i,initialRemainingTime:m,colors:u,isLinearGradient:s,gradientUniqueKey:f,onComplete:p,rotation:b}),h=g.path,O=g.pathLength,w=g.stroke,j=g.strokeDashoffset,S=g.gradientId,P=g.styles,T=g.timeProps;return o().createElement("div",{style:P.wrapperStyle,"aria-label":d},o().createElement("svg",{width:t,height:t,xmlns:"http://www.w3.org/2000/svg"},s&&o().createElement(v,{colors:u,gradientId:S}),o().createElement("path",{d:h,fill:"none",stroke:n,strokeWidth:r}),o().createElement("path",{d:h,fill:"none",stroke:s?"url(#".concat(S,")"):w,strokeLinecap:c,strokeWidth:r,strokeDasharray:O,strokeDashoffset:j})),null!==l&&o().createElement("div",{"aria-hidden":"true",style:I(I({},P.timeStyle),{},{color:w})},o().isValidElement(l)?o().cloneElement(o().Children.only(l),T):l(T)),"function"==typeof y&&o().createElement("div",{role:"timer","aria-live":"assertive",style:P.visuallyHidden},y(T)))};L.propTypes=d,L.defaultProps={size:180,strokeWidth:12,trailColor:"#d9d9d9",isPlaying:!1,strokeLinecap:"round",isLinearGradient:!1,ariaLabel:"Countdown timer",children:null,rotation:"clockwise"},L.displayName="CountdownCircleTimer"},262:(e,t,r)=>{"use strict";var n=r(586);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,i,a){if(a!==n){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return r.PropTypes=r,r}},980:(e,t,r)=>{e.exports=r(262)()},586:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},592:(e,t,r)=>{e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=r(297)},function(e,t,r){"use strict";r.r(t),r.d(t,"useElapsedTime",(function(){return a}));var n=r(0);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.duration,i=t.onComplete,a=t.startAt,c=void 0===a?0:a,l=t.autoResetKey,s=Object(n.useState)(c),f=o(s,2),p=f[0],d=f[1],y=Object(n.useRef)(-1e3*c),m=Object(n.useRef)(null),b=Object(n.useRef)(null),v=Object(n.useRef)(null),g=Object(n.useRef)(!1),h=Object(n.useRef)(!1),O=Object(n.useRef)(0),w=Object(n.useCallback)((function(e){O.current+=1,d("number"==typeof e?e:c)}),[]),j=function e(t){var n=t/1e3;if(null===b.current)return b.current=n,void(m.current=requestAnimationFrame(e));var o=n-b.current;if(b.current=n,d((function(e){var t=e+o;return"number"!=typeof r||t<r?t:(h.current=!0,r)})),h.current){if("function"==typeof i){y.current+=1e3*r;var a=y.current/1e3,u=i(a)||{},c=u.shouldRepeat,l=void 0!==c&&c,s=u.delay,f=void 0===s?0:s,p=u.newStartAt;l&&g.current&&(v.current=setTimeout((function(){w(p)}),1e3*f))}}else m.current=requestAnimationFrame(e)},S=function(){cancelAnimationFrame(m.current),clearTimeout(v.current),b.current=null};return u((function(){return e&&(m.current=requestAnimationFrame(j)),S}),[e]),u((function(){e&&g.current&&(S(),m.current=requestAnimationFrame(j))}),[r]),u((function(){g.current&&w()}),[l]),u((function(){e&&h.current&&(S(),m.current=requestAnimationFrame(j)),h.current=!1}),[O.current]),u((function(){return g.current=!0,function(){g.current=!1}}),[]),{elapsedTime:p,reset:w}},u="undefined"==typeof window?n.useEffect:n.useLayoutEffect}])},297:e=>{"use strict";e.exports=require("react")}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}return r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(54)})();
module.exports=function(){var e={54:function(e,t,r){"use strict";r.r(t),r.d(t,{CountdownCircleTimer:function(){return L}});var n=r(297),o=r.n(n),i=function(e){return{position:"relative",width:e,height:e}},a={display:"flex",justifyContent:"center",alignItems:"center",position:"absolute",left:0,top:0,width:"100%",height:"100%"},u=function(e){return e.match(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)},c=function(e,t){return"Invalid prop '".concat(e,"' supplied to '").concat(t,"'")},l=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"array";return new Error("".concat(c(e,t),". Expect ").concat("array"===r?"an array of tuples where the first element is a":""," HEX color code string.\n ."))},f=function(e,t){return 0===t?0:"number"==typeof e?t-e:0},s=r(980),p=r.n(s),d={duration:p().number.isRequired,colors:function(e,t,r){var n=e[t];return"string"==typeof n?function(e,t,r){if(!u(e))return l(t,r,"string")}(n,t,r):function(e,t,r){for(var n=0;n<e.length;n+=1){var o=e[n][0],i=e[n][1];if(!u(o))return l(t,r);if(!(void 0===i||i>=0&&i<=1))return new Error("".concat(c(t,r),".\n Expect an array of tuples where the second element is a number between 0 and 1 representing color transition duration."))}}(n,t,r)},children:p().oneOfType([p().func,p().node]),size:p().number,strokeWidth:p().number,trailColor:p().string,isPlaying:p().bool,strokeLinecap:p().oneOf(["round","square"]),isLinearGradient:p().bool,gradientUniqueKey:p().string,onComplete:p().func,ariaLabel:p().string,renderAriaTime:p().func,initialRemainingTime:p().number,rotation:p().oneOf(["clockwise","counterclockwise"])};function y(){return(y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function m(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var v=function(e){var t=e.gradientId,r=e.colors,n=e.defs,i=void 0===n?"defs":n,a=e.linearGradient,u=void 0===a?"linearGradient":a,c=e.stop,l=void 0===c?"stop":c;return o().createElement(i,null,o().createElement(u,{id:t,x1:"1",y1:"0",x2:"0",y2:"0"},function(e){var t="string"==typeof e;if(t||1===e.length)return[{offset:1,stopColor:t?e:e[0][0],key:0}];var r,n=e.length,o=0;return[{offset:0,stopColor:e[0][0],key:0}].concat(function(e){if(Array.isArray(e))return b(e)}(r=e.map((function(e,t){var r,i,a=(i=2,function(e){if(Array.isArray(e))return e}(r=e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(r,i)||m(r,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=a[0],c=a[1];return o+=c,{offset:n===t+1?1:o,stopColor:u,key:t+1}})))||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(r)||m(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}(r).map((function(e){return o().createElement(l,y({},e,{key:e.key}))}))))},g=p().oneOfType([p().func,p().string]);v.propTypes={gradientId:p().string.isRequired,colors:d.colors,defs:g,linearGradient:g,stop:g};var h=r(592),O=function(e,t,r,n){return 0===n?r:t+r*(e/n)};function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach((function(t){S(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function S(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var P=function(e){var t=e.r,r=e.g,n=e.b,o=e.opacity;return"rgba(".concat(t,", ").concat(r,", ").concat(n,", ").concat(o,")")},T=function(e,t){if(1===e.length)return P(e[0]);var r=e.find((function(e){var r=e.colorEndTime;return t<=r}));if(void 0===r.duration)return P(r);var n=t-r.colorStartTime,o=0|O(n,r.r,r.goalR,r.duration),i=0|O(n,r.g,r.goalG,r.duration),a=0|O(n,r.b,r.goalB,r.duration);return P({r:o,g:i,b:a,opacity:r.opacity})},A={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:0,clip:"rect(0 0 0 0)",padding:0,overflow:"hidden",whiteSpace:"nowrap",wordWrap:"normal"};function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var x=function(e){var t=e.isPlaying,r=e.size,o=e.strokeWidth,u=e.duration,c=e.initialRemainingTime,l=e.colors,s=e.isLinearGradient,p=e.gradientUniqueKey,d=e.onComplete,y=e.rotation,m=(0,n.useRef)({duration:u,startAt:f(c,u)}).current,b=m.duration,v=m.startAt,g=(0,n.useMemo)((function(){return function(e,t,r){var n=e/2,o=t/2,i=n-o,a=2*i,u="clockwise"===r?"1,0":"0,1",c=2*Math.PI*i;return{path:"m ".concat(n,",").concat(o,"\n a ").concat(i,",").concat(i," 0 ").concat(u," 0,").concat(a,"\n a ").concat(i,",").concat(i," 0 ").concat(u," 0,-").concat(a),pathLength:c}}(r,o,y)}),[r,o,y]),w=g.path,S=g.pathLength,k=(0,n.useMemo)((function(){return function(e,t,r){var n=function(e,t){var r=function(e){return e.map((function(e){var t=e[0].replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,r,n){return"#".concat(t).concat(t).concat(r).concat(r).concat(n).concat(n)})).substring(1).match(/.{2}/g).map((function(e){return parseInt(e,16)}));return[{r:t[0],g:t[1],b:t[2],opacity:1},e[1]]}))}(e);if(!t)return r;var n=0;return r.map((function(e,t){var o=r.length===t+1,i="0%";if(t>0){var a=r[t-1][1],u=Math.round(100*a);(n+=u)>100||o?(n=100,i="100%"):i="".concat(n,"%")}var c={offset:i,stopColor:P(e[0]),key:t};return[j(j({},e[0]),{},{gradient:c}),e[1]]}))}("string"==typeof e?[[e,1]]:e,r),o=0;return n.map((function(e,r){var i=n.length===r+1;if(o>=t||i)return o=t,j(j({},e[0]),{},{colorEndTime:o});var a=o,u=void 0!==e[1]?a+e[1]*t:t,c=u>=t?t:u,l=n[r+1][0],f={goalR:l.r-e[0].r,goalG:l.g-e[0].g,goalB:l.b-e[0].b};return o=c,j(j(j({},e[0]),f),{},{colorStartTime:a,colorEndTime:c,duration:c-a})}))}(l,b,s)}),[l,b,s]),x=(0,n.useMemo)((function(){return function(e){return"countdown-circle-timer-gradient-".concat(e||Math.random().toString(36).substring(2))}(p)}),[p]),C=(0,h.useElapsedTime)(t,{duration:b,startAt:v,onComplete:"function"==typeof d?function(){var e=d.apply(void 0,arguments)||[],t=E(e,2),r=t[0],n=void 0!==r&&r,o=t[1],i=void 0===o?0:o;return{shouldRepeat:n,delay:i/1e3,newStartAt:0}}:void 0}).elapsedTime;return{path:w,pathLength:S,gradientId:x,stroke:T(k,C),strokeDashoffset:O(C,0,S,b),timeProps:{remainingTime:Math.ceil(b-C),elapsedTime:C},styles:{wrapperStyle:i(r),timeStyle:a,visuallyHidden:A}}};function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){R(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var L=function(e){var t=e.size,r=e.strokeWidth,n=e.trailColor,i=e.duration,a=e.isPlaying,u=e.colors,c=e.strokeLinecap,l=e.children,f=e.isLinearGradient,s=e.gradientUniqueKey,p=e.onComplete,d=e.ariaLabel,y=e.renderAriaTime,m=e.initialRemainingTime,b=e.rotation,g=x({isPlaying:a,size:t,strokeWidth:r,duration:i,initialRemainingTime:m,colors:u,isLinearGradient:f,gradientUniqueKey:s,onComplete:p,rotation:b}),h=g.path,O=g.pathLength,w=g.stroke,j=g.strokeDashoffset,S=g.gradientId,P=g.styles,T=g.timeProps;return o().createElement("div",{style:P.wrapperStyle,"aria-label":d},o().createElement("svg",{width:t,height:t,xmlns:"http://www.w3.org/2000/svg"},f&&o().createElement(v,{colors:u,gradientId:S}),o().createElement("path",{d:h,fill:"none",stroke:n,strokeWidth:r}),o().createElement("path",{d:h,fill:"none",stroke:f?"url(#".concat(S,")"):w,strokeLinecap:c,strokeWidth:r,strokeDasharray:O,strokeDashoffset:j})),null!==l&&o().createElement("div",{"aria-hidden":"true",style:I(I({},P.timeStyle),{},{color:w})},o().isValidElement(l)?o().cloneElement(o().Children.only(l),T):l(T)),"function"==typeof y&&o().createElement("div",{role:"timer","aria-live":"assertive",style:P.visuallyHidden},y(T)))};L.propTypes=d,L.defaultProps={size:180,strokeWidth:12,trailColor:"#d9d9d9",isPlaying:!1,strokeLinecap:"round",isLinearGradient:!1,ariaLabel:"Countdown timer",children:null,rotation:"clockwise"},L.displayName="CountdownCircleTimer"},262:function(e,t,r){"use strict";var n=r(586);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,i,a){if(a!==n){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return r.PropTypes=r,r}},980:function(e,t,r){e.exports=r(262)()},586:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},592:function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=r(297)},function(e,t,r){"use strict";r.r(t),r.d(t,"useElapsedTime",(function(){return a}));var n=r(0);function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.duration,i=t.onComplete,a=t.startAt,c=void 0===a?0:a,l=t.autoResetKey,f=Object(n.useState)(c),s=o(f,2),p=s[0],d=s[1],y=Object(n.useRef)(-1e3*c),m=Object(n.useRef)(null),b=Object(n.useRef)(null),v=Object(n.useRef)(null),g=Object(n.useRef)(!1),h=Object(n.useRef)(!1),O=Object(n.useRef)(0),w=Object(n.useCallback)((function(e){O.current+=1,d("number"==typeof e?e:c)}),[]),j=function e(t){var n=t/1e3;if(null===b.current)return b.current=n,void(m.current=requestAnimationFrame(e));var o=n-b.current;if(b.current=n,d((function(e){var t=e+o;return"number"!=typeof r||t<r?t:(h.current=!0,r)})),h.current){if("function"==typeof i){y.current+=1e3*r;var a=y.current/1e3,u=i(a)||{},c=u.shouldRepeat,l=void 0!==c&&c,f=u.delay,s=void 0===f?0:f,p=u.newStartAt;l&&g.current&&(v.current=setTimeout((function(){w(p)}),1e3*s))}}else m.current=requestAnimationFrame(e)},S=function(){cancelAnimationFrame(m.current),clearTimeout(v.current),b.current=null};return u((function(){return e&&(m.current=requestAnimationFrame(j)),S}),[e]),u((function(){e&&g.current&&(S(),m.current=requestAnimationFrame(j))}),[r]),u((function(){g.current&&w()}),[l]),u((function(){e&&h.current&&(S(),m.current=requestAnimationFrame(j)),h.current=!1}),[O.current]),u((function(){return g.current=!0,function(){g.current=!1}}),[]),{elapsedTime:p,reset:w}},u="undefined"==typeof window?n.useEffect:n.useLayoutEffect}])},297:function(e){"use strict";e.exports=require("react")}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}return r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(54)}();
//# sourceMappingURL=index.js.map
{
"name": "react-countdown-circle-timer",
"version": "2.3.11",
"version": "2.3.12",
"description": "Lightweight React countdown timer component with color and progress animation based on SVG",

@@ -49,3 +49,3 @@ "main": "./lib/index.js",

"types": "types/CountdownCircleTimer.d.ts",
"gitHead": "417c7a6d675ca23885fa1bdeaea5176488e79b39"
"gitHead": "67bfc63f87c33526d48b729387ade15ddc76fefd"
}

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