@tomik23/react-circular-progress-bar
Advanced tools
Comparing version 0.1.18 to 0.1.19
@@ -1,1 +0,1 @@ | ||
import e,{createContext as t,memo as r,useContext as n,useState as o,useEffect as i,useRef as c}from"react";import a from"prop-types";function l(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 u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(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}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],c=!0,a=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);c=!0);}catch(e){a=!0,o=e}finally{try{c||null==r.return||r.return()}finally{if(a)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(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 d(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 p=t(),m=r((function(){var t=n(p),r=t.id,o=t.number,i=t.counter,c=t.textPosition,a=t.fontSize,l=t.fontWeight,u=t.fontColor;return o?e.createElement("text",{x:"50%",y:"50%",fontSize:a,fontWeight:l,fill:u,textAnchor:"middle",dy:c},i,e.createElement("tspan",{className:"circular-tspan-".concat(r||0)},"%")):null})),y=r((function(){var t=n(p),r=t.stroke,o=t.strokeBottom,i=t.colorCircle;return e.createElement("circle",{cx:"50",cy:"50",r:"42",shapeRendering:"geometricPrecision",fill:"none",stroke:i,strokeWidth:o||r})})),v=r((function(t){var r=t.children,o=n(p),i=o.id,c=o.size;return e.createElement("svg",{role:"img",width:c,height:c,"data-index":i||0,viewBox:"0 0 100 100","aria-labelledby":"circular progress bar"},r)})),b=function(t){var r=t.index,o=n(p).linearGradient,i=-100,c="linear-gradient-".concat(r);return e.createElement("defs",null,e.createElement("linearGradient",{id:c},o.map((function(t,r){return i+=100,e.createElement("stop",{key:r,offset:i/(o.length-1)+"%",stopColor:t})}))))},g=r((function(){var t=n(p),r=t.id,o=t.linearGradient,i=t.counter,c=t.stroke,a=t.round,l=t.colorSlice,u=void 0!==o?"url(#linear-gradient-".concat(r||0,")"):l;return e.createElement(e.Fragment,null,o&&e.createElement(b,{index:r||0,linearGradient:o}),e.createElement("circle",{cx:"50",cy:"50",r:"42",shapeRendering:"geometricPrecision",fill:"none",transform:"rotate(-90, 50, 50)",stroke:u,strokeWidth:c,strokeLinecap:a?"round":"butt",strokeDasharray:2.64*i+", 20000"}))})),h=r((function(){var t=n(p).children;return e.createElement("div",{style:{position:"absolute",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"}},t||null)})),x=a.bool,O=a.number,E=a.string,w=a.array,j={percent:O.isRequired,colorSlice:E,colorCircle:E,stroke:O,strokeBottom:O,round:x,opacity:O,number:x,size:O,speed:O,textPosition:E,fontSize:E,fontWeight:O,fontColor:E,linearGradient:w},P=function(e){var t=e.stroke,r=e.colorSlice,n=e.colorCircle,o=e.opacity,i=e.size;return{position:"relative",width:i,height:i,borderRadius:"50%",boxShadow:void 0===n?"inset 0px 0px ".concat(t,"px ").concat(t,"px ").concat(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r="string"==typeof e?parseInt(e.replace("#",""),16):e;return"rgba(".concat(r>>16,",\n ").concat((65280&r)>>8,", \n ").concat(255&r,", \n ").concat(t/100,")")}(r,o)):""}},S=function(t){var r=t.children,n=t.percent,a=t.speed,l=t.animationOff,s=f(o(l?n:0),2),d=s[0],b=s[1],x=c(),O=function(e){var t=f(o(!1),2),r=t[0],n=t[1];return i((function(){var t=new IntersectionObserver((function(e){var t=f(e,1)[0];t.intersectionRatio>=.5&&n(t.isIntersecting)}),{root:null,rootMargin:"0px",threshold:.5});return e&&e.current&&t.observe(e.current),function(){t.disconnect()}}),[e]),r}(x);i((function(){var e,t;if(O)if(l)b(n);else{var r=Number(null===(e=x.current)||void 0===e||null===(t=e.dataset)||void 0===t?void 0:t.angel);if(!(n>100||n<0||r===n)){var o,i=1e3/a,c=performance.now();return o=requestAnimationFrame((function e(t){o=requestAnimationFrame(e);var a=t-c;a>=i-.1&&(c=t-a%i,r>n&&b((function(e){return e-1})),r<n&&b((function(e){return e+1})))})),function(){return cancelAnimationFrame(o)}}}}),[d,l,a,O,n]);var E=u(u({},t),{},{counter:d});return e.createElement("div",{ref:x,style:P(t),"data-angel":d},e.createElement(p.Provider,{value:E},r&&e.createElement(h,null),e.createElement(v,null,e.createElement(m,null),e.createElement(y,null),e.createElement(g,null))))};S.propTypes=j,S.defaultProps={colorSlice:"#00a1ff",round:!1,number:!0,stroke:10,opacity:10,size:200,speed:1e3,textPosition:".35em",fontSize:"1.6rem",fontColor:"#365b74",fontWeight:400};export{S as CircularProgressBar}; | ||
import e,{createContext as r,useContext as t,useState as n,useEffect as o,useRef as i}from"react";import c from"prop-types";function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((function(r){u(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function u(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function s(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var n,o,i=[],c=!0,a=!1;try{for(t=t.call(e);!(c=(n=t.next()).done)&&(i.push(n.value),!r||i.length!==r);c=!0);}catch(e){a=!0,o=e}finally{try{c||null==t.return||t.return()}finally{if(a)throw o}}return i}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return f(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return f(e,r)}(e,r)||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 f(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var d=r(),m=function(){var r=t(d),n=r.id,o=r.number,i=r.counter,c=r.textPosition,a=r.fontSize,l=r.fontWeight,u=r.fontColor;return o?e.createElement("text",{x:"50%",y:"50%",fontSize:a,fontWeight:l,fill:u,textAnchor:"middle",dy:c},i,e.createElement("tspan",{className:"circular-tspan-".concat(n||0)},"%")):null},p=function(){var r=t(d),n=r.stroke,o=r.strokeBottom,i=r.colorCircle;return e.createElement("circle",{cx:"50",cy:"50",r:"42",shapeRendering:"geometricPrecision",fill:"none",stroke:i,strokeWidth:o||n})},y=function(r){var n=r.children,o=t(d),i=o.id,c=o.size;return e.createElement("svg",{role:"img",width:c,height:c,"data-index":i||0,viewBox:"0 0 100 100","aria-labelledby":"circular progress bar"},n)},v=function(r){var n=r.index,o=t(d).linearGradient,i=-100,c="linear-gradient-".concat(n);return e.createElement("defs",null,e.createElement("linearGradient",{id:c},o.map((function(r,t){return i+=100,e.createElement("stop",{key:t,offset:i/(o.length-1)+"%",stopColor:r})}))))},b=function(){var r=t(d),n=r.id,o=r.linearGradient,i=r.inverse,c=r.counter,a=r.stroke,l=r.round,u=r.colorSlice,s=void 0!==o?"url(#linear-gradient-".concat(n||0,")"):u;return e.createElement(e.Fragment,null,o&&e.createElement(v,{index:n||0,linearGradient:o}),e.createElement("circle",{cx:"50%",cy:"50%",r:"42",shapeRendering:"geometricPrecision",fill:"none",style:{transform:"rotate(-90deg)",transformOrigin:"50% 50%"},stroke:s,strokeWidth:a,strokeLinecap:l?"round":"butt",strokeDashoffset:function(e,r){var t=264-e/100*264;return r?-t:t}(c,i),strokeDasharray:264}))},g=function(){var r=t(d).children;return e.createElement("div",{style:{position:"absolute",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"}},r||null)},h=c.bool,O=c.number,x=c.string,E=c.array,w={percent:O.isRequired,colorSlice:x,colorCircle:x,stroke:O,strokeBottom:O,round:h,opacity:O,number:h,size:O,speed:O,textPosition:x,fontSize:x,fontWeight:O,fontColor:x,linearGradient:E},j=function(e){var r=e.stroke,t=e.colorSlice,n=e.colorCircle,o=e.opacity,i=e.size;return{position:"relative",width:i,height:i,borderRadius:"50%",boxShadow:void 0===n?"inset 0px 0px ".concat(r,"px ").concat(r,"px ").concat(function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,t="string"==typeof e?parseInt(e.replace("#",""),16):e;return"rgba(".concat(t>>16,",\n ").concat((65280&t)>>8,", \n ").concat(255&t,", \n ").concat(r/100,")")}(t,o)):""}},k=function(r){var t=r.children,c=r.percent,a=r.speed,u=r.animationOff,f=s(n(u?c:0),2),v=f[0],h=f[1],O=i(),x=function(e){var r=s(n(!1),2),t=r[0],i=r[1];return o((function(){var r=new IntersectionObserver((function(e){var r=s(e,1)[0];r.intersectionRatio>=.5&&i(r.isIntersecting)}),{root:null,rootMargin:"0px",threshold:.5});return e&&e.current&&r.observe(e.current),function(){r.disconnect()}}),[e]),t}(O);o((function(){var e,r;if(x)if(u)h(c);else{var t=Number(null===(e=O.current)||void 0===e||null===(r=e.dataset)||void 0===r?void 0:r.angel);if(!(c>100||c<0||t===c)){var n,o=1e3/a,i=performance.now();return n=requestAnimationFrame((function e(r){n=requestAnimationFrame(e);var a=r-i;a>=o-.1&&(i=r-a%o,t>c&&h((function(e){return e-1})),t<c&&h((function(e){return e+1})))})),function(){return cancelAnimationFrame(n)}}}}),[v,u,a,x,c]);var E=l(l({},r),{},{counter:v});return e.createElement("div",{ref:O,style:j(r),"data-angel":v},e.createElement(d.Provider,{value:E},t&&e.createElement(g,null),e.createElement(y,null,e.createElement(m,null),e.createElement(p,null),e.createElement(b,null))))};k.propTypes=w,k.defaultProps={colorSlice:"#00a1ff",round:!1,number:!0,stroke:10,opacity:10,size:200,speed:1e3,textPosition:".35em",fontSize:"1.6rem",fontColor:"#365b74",fontWeight:400};export{k as CircularProgressBar}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("prop-types");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),o=r(t);function i(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 a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(l)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(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 u(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 f=e.createContext(),s=e.memo((function(){var t=e.useContext(f),r=t.id,o=t.number,i=t.counter,a=t.textPosition,l=t.fontSize,c=t.fontWeight,u=t.fontColor;return o?n.default.createElement("text",{x:"50%",y:"50%",fontSize:l,fontWeight:c,fill:u,textAnchor:"middle",dy:a},i,n.default.createElement("tspan",{className:"circular-tspan-".concat(r||0)},"%")):null})),d=e.memo((function(){var t=e.useContext(f),r=t.stroke,o=t.strokeBottom,i=t.colorCircle;return n.default.createElement("circle",{cx:"50",cy:"50",r:"42",shapeRendering:"geometricPrecision",fill:"none",stroke:i,strokeWidth:o||r})})),m=e.memo((function(t){var r=t.children,o=e.useContext(f),i=o.id,a=o.size;return n.default.createElement("svg",{role:"img",width:a,height:a,"data-index":i||0,viewBox:"0 0 100 100","aria-labelledby":"circular progress bar"},r)})),p=function(t){var r=t.index,o=e.useContext(f).linearGradient,i=-100,a="linear-gradient-".concat(r);return n.default.createElement("defs",null,n.default.createElement("linearGradient",{id:a},o.map((function(e,t){return i+=100,n.default.createElement("stop",{key:t,offset:i/(o.length-1)+"%",stopColor:e})}))))},y=e.memo((function(){var t=e.useContext(f),r=t.id,o=t.linearGradient,i=t.counter,a=t.stroke,l=t.round,c=t.colorSlice,u=void 0!==o?"url(#linear-gradient-".concat(r||0,")"):c;return n.default.createElement(n.default.Fragment,null,o&&n.default.createElement(p,{index:r||0,linearGradient:o}),n.default.createElement("circle",{cx:"50",cy:"50",r:"42",shapeRendering:"geometricPrecision",fill:"none",transform:"rotate(-90, 50, 50)",stroke:u,strokeWidth:a,strokeLinecap:l?"round":"butt",strokeDasharray:2.64*i+", 20000"}))})),v=e.memo((function(){var t=e.useContext(f).children;return n.default.createElement("div",{style:{position:"absolute",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"}},t||null)})),b=o.default.bool,g=o.default.number,h=o.default.string,x=o.default.array,E={percent:g.isRequired,colorSlice:h,colorCircle:h,stroke:g,strokeBottom:g,round:b,opacity:g,number:b,size:g,speed:g,textPosition:h,fontSize:h,fontWeight:g,fontColor:h,linearGradient:x},O=function(e){var t=e.stroke,r=e.colorSlice,n=e.colorCircle,o=e.opacity,i=e.size;return{position:"relative",width:i,height:i,borderRadius:"50%",boxShadow:void 0===n?"inset 0px 0px ".concat(t,"px ").concat(t,"px ").concat(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r="string"==typeof e?parseInt(e.replace("#",""),16):e;return"rgba(".concat(r>>16,",\n ").concat((65280&r)>>8,", \n ").concat(255&r,", \n ").concat(t/100,")")}(r,o)):""}},j=function(t){var r=t.children,o=t.percent,i=t.speed,l=t.animationOff,u=c(e.useState(l?o:0),2),p=u[0],b=u[1],g=e.useRef(),h=function(t){var r=c(e.useState(!1),2),n=r[0],o=r[1];return e.useEffect((function(){var e=new IntersectionObserver((function(e){var t=c(e,1)[0];t.intersectionRatio>=.5&&o(t.isIntersecting)}),{root:null,rootMargin:"0px",threshold:.5});return t&&t.current&&e.observe(t.current),function(){e.disconnect()}}),[t]),n}(g);e.useEffect((function(){var e,t;if(h)if(l)b(o);else{var r=Number(null===(e=g.current)||void 0===e||null===(t=e.dataset)||void 0===t?void 0:t.angel);if(!(o>100||o<0||r===o)){var n,a=1e3/i,c=performance.now();return n=requestAnimationFrame((function e(t){n=requestAnimationFrame(e);var i=t-c;i>=a-.1&&(c=t-i%a,r>o&&b((function(e){return e-1})),r<o&&b((function(e){return e+1})))})),function(){return cancelAnimationFrame(n)}}}}),[p,l,i,h,o]);var x=a(a({},t),{},{counter:p});return n.default.createElement("div",{ref:g,style:O(t),"data-angel":p},n.default.createElement(f.Provider,{value:x},r&&n.default.createElement(v,null),n.default.createElement(m,null,n.default.createElement(s,null),n.default.createElement(d,null),n.default.createElement(y,null))))};j.propTypes=E,j.defaultProps={colorSlice:"#00a1ff",round:!1,number:!0,stroke:10,opacity:10,size:200,speed:1e3,textPosition:".35em",fontSize:"1.6rem",fontColor:"#365b74",fontWeight:400},exports.CircularProgressBar=j; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("prop-types");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),o=r(t);function i(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 a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],a=!0,l=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(l)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(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 u(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 f=e.createContext(),s=function(){var t=e.useContext(f),r=t.id,o=t.number,i=t.counter,a=t.textPosition,l=t.fontSize,c=t.fontWeight,u=t.fontColor;return o?n.default.createElement("text",{x:"50%",y:"50%",fontSize:l,fontWeight:c,fill:u,textAnchor:"middle",dy:a},i,n.default.createElement("tspan",{className:"circular-tspan-".concat(r||0)},"%")):null},d=function(){var t=e.useContext(f),r=t.stroke,o=t.strokeBottom,i=t.colorCircle;return n.default.createElement("circle",{cx:"50",cy:"50",r:"42",shapeRendering:"geometricPrecision",fill:"none",stroke:i,strokeWidth:o||r})},p=function(t){var r=t.children,o=e.useContext(f),i=o.id,a=o.size;return n.default.createElement("svg",{role:"img",width:a,height:a,"data-index":i||0,viewBox:"0 0 100 100","aria-labelledby":"circular progress bar"},r)},m=function(t){var r=t.index,o=e.useContext(f).linearGradient,i=-100,a="linear-gradient-".concat(r);return n.default.createElement("defs",null,n.default.createElement("linearGradient",{id:a},o.map((function(e,t){return i+=100,n.default.createElement("stop",{key:t,offset:i/(o.length-1)+"%",stopColor:e})}))))},v=function(){var t=e.useContext(f),r=t.id,o=t.linearGradient,i=t.inverse,a=t.counter,l=t.stroke,c=t.round,u=t.colorSlice,s=void 0!==o?"url(#linear-gradient-".concat(r||0,")"):u;return n.default.createElement(n.default.Fragment,null,o&&n.default.createElement(m,{index:r||0,linearGradient:o}),n.default.createElement("circle",{cx:"50%",cy:"50%",r:"42",shapeRendering:"geometricPrecision",fill:"none",style:{transform:"rotate(-90deg)",transformOrigin:"50% 50%"},stroke:s,strokeWidth:l,strokeLinecap:c?"round":"butt",strokeDashoffset:function(e,t){var r=264-e/100*264;return t?-r:r}(a,i),strokeDasharray:264}))},y=function(){var t=e.useContext(f).children;return n.default.createElement("div",{style:{position:"absolute",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"}},t||null)},b=o.default.bool,g=o.default.number,h=o.default.string,x=o.default.array,O={percent:g.isRequired,colorSlice:h,colorCircle:h,stroke:g,strokeBottom:g,round:b,opacity:g,number:b,size:g,speed:g,textPosition:h,fontSize:h,fontWeight:g,fontColor:h,linearGradient:x},E=function(e){var t=e.stroke,r=e.colorSlice,n=e.colorCircle,o=e.opacity,i=e.size;return{position:"relative",width:i,height:i,borderRadius:"50%",boxShadow:void 0===n?"inset 0px 0px ".concat(t,"px ").concat(t,"px ").concat(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r="string"==typeof e?parseInt(e.replace("#",""),16):e;return"rgba(".concat(r>>16,",\n ").concat((65280&r)>>8,", \n ").concat(255&r,", \n ").concat(t/100,")")}(r,o)):""}},j=function(t){var r=t.children,o=t.percent,i=t.speed,l=t.animationOff,u=c(e.useState(l?o:0),2),m=u[0],b=u[1],g=e.useRef(),h=function(t){var r=c(e.useState(!1),2),n=r[0],o=r[1];return e.useEffect((function(){var e=new IntersectionObserver((function(e){var t=c(e,1)[0];t.intersectionRatio>=.5&&o(t.isIntersecting)}),{root:null,rootMargin:"0px",threshold:.5});return t&&t.current&&e.observe(t.current),function(){e.disconnect()}}),[t]),n}(g);e.useEffect((function(){var e,t;if(h)if(l)b(o);else{var r=Number(null===(e=g.current)||void 0===e||null===(t=e.dataset)||void 0===t?void 0:t.angel);if(!(o>100||o<0||r===o)){var n,a=1e3/i,c=performance.now();return n=requestAnimationFrame((function e(t){n=requestAnimationFrame(e);var i=t-c;i>=a-.1&&(c=t-i%a,r>o&&b((function(e){return e-1})),r<o&&b((function(e){return e+1})))})),function(){return cancelAnimationFrame(n)}}}}),[m,l,i,h,o]);var x=a(a({},t),{},{counter:m});return n.default.createElement("div",{ref:g,style:E(t),"data-angel":m},n.default.createElement(f.Provider,{value:x},r&&n.default.createElement(y,null),n.default.createElement(p,null,n.default.createElement(s,null),n.default.createElement(d,null),n.default.createElement(v,null))))};j.propTypes=O,j.defaultProps={colorSlice:"#00a1ff",round:!1,number:!0,stroke:10,opacity:10,size:200,speed:1e3,textPosition:".35em",fontSize:"1.6rem",fontColor:"#365b74",fontWeight:400},exports.CircularProgressBar=j; |
{ | ||
"name": "@tomik23/react-circular-progress-bar", | ||
"version": "0.1.18", | ||
"version": "0.1.19", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -10,3 +10,8 @@ <h1 align="center"> | ||
<p align="center"> | ||
<img src="https://img.shields.io/github/package-json/v/tomik23/react-circular-progress-bar"> | ||
<a href="https://www.npmjs.com/package/@tomik23/react-circular-progress-bar"> | ||
<img src="https://badge.fury.io/js/%40tomik23%2Freact-circular-progress-bar.svg"> | ||
</a> | ||
<a href="https://bundlephobia.com/package/@tomik23/react-circular-progress-bar"> | ||
<img src="https://img.shields.io/bundlephobia/min/@tomik23/react-circular-progress-bar"> | ||
</a> | ||
<a href="LICENSE"> | ||
@@ -173,2 +178,3 @@ <img src="https://img.shields.io/badge/License-MIT-green.svg"> | ||
round | boolean | `false` | | Path rounding | ||
invers | boolean | `false` | | Counterclockwise animation | ||
opacity | number | `10` | | Opacity box-shadow, 10 = 1, 9 = 0.9 ... 1 = 0.1 | ||
@@ -175,0 +181,0 @@ number | boolean | `true` | | Add props number and set to false to hide the number with percent |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22863
45
195
0