react-page-loading-bar 1.0.7 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/build/{index.com.js → index.js} +1 -1
- package/build/index.js.map +1 -0
- package/build/{index.com.module.js → index.modern.js} +1 -1
- package/build/index.modern.js.map +1 -0
- package/build/{index.com.umd.js → index.umd.js} +1 -1
- package/build/{index.com.js.map → index.umd.js.map} +1 -1
- package/package.json +4 -7
- package/build/index.com.modern.js +0 -2
- package/build/index.com.modern.js.map +0 -1
- package/build/index.com.module.js.map +0 -1
- package/build/index.com.umd.js.map +0 -1
@@ -1,2 +1,2 @@
|
|
1
1
|
var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(null,arguments)}var i=function(e){return!!(Array.isArray(e)&&e.length>1)&&"linear-gradient(to right, "+e.join(", ")+")"},a=function(e){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e)},o={top:0,left:0,width:"100%",zIndex:9800,height:"100%",position:"fixed",overflow:"hidden"},u={width:"0%",height:"100%",transition:"all 0.3s ease"},c={left:"-10rem",height:"100%",position:"absolute",transition:"all 0.3s ease",transform:"rotate(3deg) translate(0, -4px)",boxShadow:"0 0 10px var(--color), 0 0 5px var(--color)"},s=t.forwardRef(function(e,s){var f,l,v,d=e.progress,h=e.color,m=void 0===h?"purple":h,p=e.background,g=void 0===p?"transparent":p,w=e.shadow,y=void 0===w||w,S=e.height,b=void 0===S?2:S,E=e.onLoaderFinished,R=e.transitionTime,x=void 0===R?300:R,T=e.waitingTime,j=void 0===T?1e3:T,A=e.className,I=void 0===A?"":A,N=e.containerClassName,k=void 0===N?"":N,F=e.style,M=void 0===F?{}:F,O=e.containerStyle,P=void 0===O?{}:O,q=e.shadowStyle,z=void 0===q?{}:q,C=t.useState(0),H=C[0],L=C[1],$=t.useState(!1),B=$[0],D=$[1],G=t.useState(!1),J=G[0],K=G[1],Q=t.useState(n({},u,{height:b,width:H+"%",transition:"all "+x+"ms ease-out",background:i(m)||(a(m)?m:"purple")},M)),U=Q[0],V=Q[1],W=t.useState(n({},o,{height:b,background:g},P))[0],X=t.useRef(!1),Y=t.useRef({active:!1,refreshRate:1e3}),Z=t.useRef({active:!1,value:0});t.useImperativeHandle(s,function(){return{continuousStart:function(e,t){void 0===e&&(e=10),void 0===t&&(t=1e3),B||(Y.current={active:!0,refreshRate:t},L(e),_(e),K(!1))},staticStart:function(e){void 0===e&&(e=30),B||(Z.current={active:!0,value:e},L(e),_(e),K(!1))},complete:function(){B||(L(100),_(100),K(!0),Y.current.active=!1,Z.current.active=!1)},getProgress:function(){return H}}}),t.useEffect(function(){void 0!==d&&(D(!0),L(d))},[d]),t.useEffect(function(){if(J&&H>=100){var e=setTimeout(function(){E&&E(),L(0),K(!1)},j);return function(){return clearTimeout(e)}}},[J,H,j,E]),f=function(){if(Y.current.active&&!J){var e=Math.floor(10*Math.random()+1);L(function(t){return Math.min(t+e,100)}),H+e>=100&&(Y.current.active=!1,K(!0))}},l=Y.current.active?Y.current.refreshRate:null,v=t.useRef(function(){}),t.useEffect(function(){v.current=f}),t.useEffect(function(){},[void 0,l]),t.useEffect(function(){if(null!==l){var e=setInterval(v.current,l);return function(){return clearInterval(e)}}},[l]);var _=function(e){e>=100?(V(n({},U,{width:"100%"})),setTimeout(function(){X&&(V(n({},U,{opacity:0,width:"100%",transition:"all "+x+"ms ease-out",color:i(m)||(a(m)?m:"purple")})),setTimeout(function(){X&&(Y.current.active&&(Y.current=n({},Y.current,{active:!1}),L(0),_(0)),Z.current.active&&(Z.current=n({},Z.current,{active:!1}),L(0),_(0)),E&&E(),L(0),_(0))},x))},j)):V(function(t){return n({},t,{width:e+"%",opacity:1,transition:"all "+x+"ms ease-out"})})};return t.useEffect(function(){return X.current=!0,function(){X.current=!1}},[]),r.createElement("div",{style:W,className:k},r.createElement("div",{style:U,className:I}," "),y&&r.createElement("div",{style:n({},c,z)}))});module.exports=s;
|
2
|
-
//# sourceMappingURL=index.
|
2
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils/colorUtils.ts","../src/styles/styles.ts","../src/components/LoadingBar.tsx","../src/hooks/useInterval.ts","../src/utils/randomUtils.ts"],"sourcesContent":["export const isGradient = (color: string | string[]): string | false => {\n if (Array.isArray(color) && color.length > 1) {\n return `linear-gradient(to right, ${color.join(\", \")})`;\n }\n return false;\n};\n\nexport const isValidHex = (color: string): boolean => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));","const baseStyles: Record<string, React.CSSProperties> = {\n container: {\n top: 0,\n left: 0,\n width: \"100%\",\n zIndex: 9800,\n height: \"100%\",\n position: \"fixed\",\n overflow: \"hidden\",\n },\n loader: {\n width: \"0%\",\n height: \"100%\",\n transition: \"all 0.3s ease\",\n },\n shadow: {\n left: \"-10rem\",\n height: \"100%\",\n position: \"absolute\",\n transition: \"all 0.3s ease\",\n transform: \"rotate(3deg) translate(0, -4px)\",\n boxShadow: \"0 0 10px var(--color), 0 0 5px var(--color)\",\n }\n};\n\nexport default baseStyles;","import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from \"react\";\n\n// Hooks\nimport { useInterval } from \"../hooks/useInterval\";\n\n// Utils\nimport { randomInt } from \"../utils/randomUtils\";\nimport { isGradient, isValidHex } from \"../utils/colorUtils\";\n\n// Styles\nimport baseStyles from \"../styles/styles\";\n\n// Types\nimport type { LoadingBarRef, LoadingBarProps } from \"../../types\";\n\nconst LoadingBar = forwardRef<LoadingBarRef, LoadingBarProps>(\n (\n {\n progress,\n color = \"purple\",\n background = \"transparent\",\n shadow = true,\n height = 2,\n onLoaderFinished,\n transitionTime = 300,\n waitingTime = 1000,\n className = \"\",\n containerClassName = \"\",\n style = {},\n containerStyle = {},\n shadowStyle = {},\n },\n ref\n ) => {\n // States\n const [localProgress, setLocalProgress] = useState<number>(0);\n const [usingProps, setUsingProps] = useState<boolean>(false);\n const [isComplete, setIsComplete] = useState<boolean>(false);\n\n // Style states\n const [loaderStyle, setLoaderStyle] = useState<React.CSSProperties>({\n ...baseStyles.loader,\n height,\n width: `${localProgress}%`,\n transition: `all ${transitionTime}ms ease-out`,\n background: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\"),\n ...style,\n });\n\n const [containerStyles, setContainerStyles] = useState<React.CSSProperties>({\n ...baseStyles.container,\n height,\n background,\n ...containerStyle,\n })\n\n // Refs\n const isMounted = useRef<boolean>(false);\n\n const continuous = useRef<{ active: boolean; refreshRate: number }>({\n active: false,\n refreshRate: 1000,\n });\n const staticStart = useRef<{ active: boolean; value: number }>({\n active: false,\n value: 0,\n });\n\n useImperativeHandle(ref, () => ({\n continuousStart(startingValue = 10, refreshRate = 1000) {\n if (usingProps) return;\n continuous.current = { active: true, refreshRate };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n staticStart(startingValue = 30) {\n if (usingProps) return;\n staticStart.current = { active: true, value: startingValue };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n complete() {\n if (usingProps) return;\n setLocalProgress(100);\n checkIfFull(100);\n setIsComplete(true);\n continuous.current.active = false;\n staticStart.current.active = false;\n },\n getProgress() {\n return localProgress;\n },\n }));\n\n useEffect(() => {\n if (progress !== undefined) {\n setUsingProps(true);\n setLocalProgress(progress);\n }\n }, [progress]);\n\n useEffect(() => {\n if (isComplete && localProgress >= 100) {\n const timeoutId = setTimeout(() => {\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n setIsComplete(false);\n }, waitingTime);\n\n return () => clearTimeout(timeoutId);\n }\n }, [isComplete, localProgress, waitingTime, onLoaderFinished]);\n\n useInterval(() => {\n if (continuous.current.active && !isComplete) {\n const increment = randomInt(1, 10);\n setLocalProgress((prev) => Math.min(prev + increment, 100));\n if (localProgress + increment >= 100) {\n continuous.current.active = false;\n setIsComplete(true);\n }\n }\n }, continuous.current.active ? continuous.current.refreshRate : null);\n\n // Helpers\n const checkIfFull = (progress: number) => {\n if (progress >= 100) {\n setLoaderStyle({\n ...loaderStyle,\n width: \"100%\"\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n setLoaderStyle({\n ...loaderStyle,\n opacity: 0,\n width: \"100%\",\n transition: `all ${transitionTime}ms ease-out`,\n color: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\")\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n // Handle continuous start\n if (continuous.current.active) {\n\n continuous.current = {\n ...continuous.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n // Handle static start\n if (staticStart.current.active) {\n\n staticStart.current = {\n ...staticStart.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n checkIfFull(0);\n }, transitionTime);\n }, waitingTime);\n } else {\n setLoaderStyle((prev) => (\n {\n ...prev,\n width: `${progress}%`,\n opacity: 1,\n transition: `all ${transitionTime}ms ease-out`,\n }\n ));\n }\n };\n\n // Handle mount\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n }\n }, []);\n\n return (\n <div style={containerStyles} className={containerClassName} >\n <div style={loaderStyle} className={className} > </div>\n {shadow && <div style={{ ...baseStyles.shadow, ...shadowStyle }} />}\n </div>\n );\n }\n);\n\nexport default LoadingBar;","import { useEffect, useRef } from \"react\";\n\nexport const useInterval = (\n callback: () => void,\n delay: number | null,\n immediate?: boolean\n) => {\n const savedCallback = useRef(() => { });\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (immediate && delay !== null) {\n savedCallback.current();\n }\n }, [immediate, delay]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(savedCallback.current, delay);\n return () => clearInterval(id);\n }, [delay]);\n};","const randomValue = (min: number, max: number): number => (Math.random() * (max - min + 1) + min);\n\nexport const randomInt = (min: number, max: number): number => Math.floor(randomValue(min, max));"],"names":["isGradient","color","Array","isArray","length","join","isValidHex","test","baseStyles","top","left","width","zIndex","height","position","overflow","transition","transform","boxShadow","LoadingBar","forwardRef","_ref","ref","callback","delay","savedCallback","progress","_ref$color","_ref$background","background","_ref$shadow","shadow","_ref$height","onLoaderFinished","_ref$transitionTime","transitionTime","_ref$waitingTime","waitingTime","_ref$className","className","_ref$containerClassNa","containerClassName","_ref$style","style","_ref$containerStyle","containerStyle","_ref$shadowStyle","shadowStyle","_useState","useState","localProgress","setLocalProgress","_useState2","usingProps","setUsingProps","_useState3","isComplete","setIsComplete","_useState4","_extends","loaderStyle","setLoaderStyle","containerStyles","isMounted","useRef","continuous","active","refreshRate","staticStart","value","useImperativeHandle","continuousStart","startingValue","current","checkIfFull","complete","getProgress","useEffect","undefined","timeoutId","setTimeout","clearTimeout","increment","Math","floor","random","prev","min","immediate","id","setInterval","clearInterval","opacity","React"],"mappings":"2SAAaA,EAAa,SAACC,GACvB,SAAIC,MAAMC,QAAQF,IAAUA,EAAMG,OAAS,iCACHH,EAAMI,KAAK,WAK1CC,EAAa,SAACL,8CAAiEM,KAAKN,ICP3FO,EACS,CACPC,IAAK,EACLC,KAAM,EACNC,MAAO,OACPC,OAAQ,KACRC,OAAQ,OACRC,SAAU,QACVC,SAAU,UARZP,EAUM,CACJG,MAAO,KACPE,OAAQ,OACRG,WAAY,iBAbdR,EAeM,CACJE,KAAM,SACNG,OAAQ,OACRC,SAAU,WACVE,WAAY,gBACZC,UAAW,kCACXC,UAAW,+CCNbC,EAAaC,aACf,SAAAC,EAgBIC,OC7BJC,EACAC,EAGMC,EDWEC,EAAQL,EAARK,SAAQC,EAAAN,EACRpB,MAAAA,WAAK0B,EAAG,SAAQA,EAAAC,EAAAP,EAChBQ,WAAAA,WAAUD,EAAG,cAAaA,EAAAE,EAAAT,EAC1BU,OAAAA,WAAMD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ACFjB,IAGDE,EAAWQ,QAAQP,SAEnBD,EAAWQ,QAAOd,KACXM,EAAWQ,SACdP,QAAQ,IAGZf,EAAiB,GACjBuB,EAAY,IAIZN,EAAYK,QAAQP,SAEpBE,EAAYK,QAAOd,KACZS,EAAYK,SACfP,QAAQ,IAGZf,EAAiB,GACjBuB,EAAY,IAGZzC,GAAkBA,IACtBkB,EAAiB,GACjBuB,EAAY,KACbvC,KACJE,IAEHwB,EAAe,SAACyB,UAAI3B,KAET2B,GACH3E,MAAUe,MACVkE,QAAS,EACT5E,kBAAmBmB,qBAcnC,OAPA0C,YAAU,WAEN,OADAd,EAAUU,SAAU,aAEhBV,EAAUU,SAAU,IAEzB,IAGCoB,uBAAKlD,MAAOmB,EAAiBvB,UAAWE,GACpCoD,uBAAKlD,MAAOiB,EAAarB,UAAWA,QACnCR,GAAU8D,uBAAKlD,MAAKgB,KAAOnD,EAAsBuC"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import t,{useRef as e,useEffect as n,forwardRef as r,useState as i,useImperativeHandle as o}from"react";function a(){return(a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(null,arguments)}var c=function(t){return!!(Array.isArray(t)&&t.length>1)&&"linear-gradient(to right, "+t.join(", ")+")"},u=function(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)},s={top:0,left:0,width:"100%",zIndex:9800,height:"100%",position:"fixed",overflow:"hidden"},l={width:"0%",height:"100%",transition:"all 0.3s ease"},v={left:"-10rem",height:"100%",position:"absolute",transition:"all 0.3s ease",transform:"rotate(3deg) translate(0, -4px)",boxShadow:"0 0 10px var(--color), 0 0 5px var(--color)"},f=r(function(r,f){var d,h,m,p=r.progress,g=r.color,w=void 0===g?"purple":g,y=r.background,b=void 0===y?"transparent":y,x=r.shadow,T=void 0===x||x,S=r.height,A=void 0===S?2:S,N=r.onLoaderFinished,j=r.transitionTime,k=void 0===j?300:j,E=r.waitingTime,F=void 0===E?1e3:E,I=r.className,M=void 0===I?"":I,O=r.containerClassName,R=void 0===O?"":O,P=r.style,z=void 0===P?{}:P,C=r.containerStyle,L=void 0===C?{}:C,$=r.shadowStyle,q=void 0===$?{}:$,B=i(0),D=B[0],G=B[1],H=i(!1),J=H[0],K=H[1],Q=i(!1),U=Q[0],V=Q[1],W=i(a({},l,{height:A,width:D+"%",transition:"all "+k+"ms ease-out",background:c(w)||(u(w)?w:"purple")},z)),X=W[0],Y=W[1],Z=i(a({},s,{height:A,background:b},L))[0],_=e(!1),tt=e({active:!1,refreshRate:1e3}),et=e({active:!1,value:0});o(f,function(){return{continuousStart:function(t,e){void 0===t&&(t=10),void 0===e&&(e=1e3),J||(tt.current={active:!0,refreshRate:e},G(t),nt(t),V(!1))},staticStart:function(t){void 0===t&&(t=30),J||(et.current={active:!0,value:t},G(t),nt(t),V(!1))},complete:function(){J||(G(100),nt(100),V(!0),tt.current.active=!1,et.current.active=!1)},getProgress:function(){return D}}}),n(function(){void 0!==p&&(K(!0),G(p))},[p]),n(function(){if(U&&D>=100){var t=setTimeout(function(){N&&N(),G(0),V(!1)},F);return function(){return clearTimeout(t)}}},[U,D,F,N]),d=function(){if(tt.current.active&&!U){var t=Math.floor(10*Math.random()+1);G(function(e){return Math.min(e+t,100)}),D+t>=100&&(tt.current.active=!1,V(!0))}},h=tt.current.active?tt.current.refreshRate:null,m=e(function(){}),n(function(){m.current=d}),n(function(){},[void 0,h]),n(function(){if(null!==h){var t=setInterval(m.current,h);return function(){return clearInterval(t)}}},[h]);var nt=function(t){t>=100?(Y(a({},X,{width:"100%"})),setTimeout(function(){_&&(Y(a({},X,{opacity:0,width:"100%",transition:"all "+k+"ms ease-out",color:c(w)||(u(w)?w:"purple")})),setTimeout(function(){_&&(tt.current.active&&(tt.current=a({},tt.current,{active:!1}),G(0),nt(0)),et.current.active&&(et.current=a({},et.current,{active:!1}),G(0),nt(0)),N&&N(),G(0),nt(0))},k))},F)):Y(function(e){return a({},e,{width:t+"%",opacity:1,transition:"all "+k+"ms ease-out"})})};return n(function(){return _.current=!0,function(){_.current=!1}},[]),t.createElement("div",{style:Z,className:R},t.createElement("div",{style:X,className:M}," "),T&&t.createElement("div",{style:a({},v,q)}))});export default f;
|
2
|
-
//# sourceMappingURL=index.
|
2
|
+
//# sourceMappingURL=index.modern.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/utils/colorUtils.ts","../src/styles/styles.ts","../src/components/LoadingBar.tsx","../src/hooks/useInterval.ts","../src/utils/randomUtils.ts"],"sourcesContent":["export const isGradient = (color: string | string[]): string | false => {\n if (Array.isArray(color) && color.length > 1) {\n return `linear-gradient(to right, ${color.join(\", \")})`;\n }\n return false;\n};\n\nexport const isValidHex = (color: string): boolean => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));","const baseStyles: Record<string, React.CSSProperties> = {\n container: {\n top: 0,\n left: 0,\n width: \"100%\",\n zIndex: 9800,\n height: \"100%\",\n position: \"fixed\",\n overflow: \"hidden\",\n },\n loader: {\n width: \"0%\",\n height: \"100%\",\n transition: \"all 0.3s ease\",\n },\n shadow: {\n left: \"-10rem\",\n height: \"100%\",\n position: \"absolute\",\n transition: \"all 0.3s ease\",\n transform: \"rotate(3deg) translate(0, -4px)\",\n boxShadow: \"0 0 10px var(--color), 0 0 5px var(--color)\",\n }\n};\n\nexport default baseStyles;","import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from \"react\";\n\n// Hooks\nimport { useInterval } from \"../hooks/useInterval\";\n\n// Utils\nimport { randomInt } from \"../utils/randomUtils\";\nimport { isGradient, isValidHex } from \"../utils/colorUtils\";\n\n// Styles\nimport baseStyles from \"../styles/styles\";\n\n// Types\nimport type { LoadingBarRef, LoadingBarProps } from \"../../types\";\n\nconst LoadingBar = forwardRef<LoadingBarRef, LoadingBarProps>(\n (\n {\n progress,\n color = \"purple\",\n background = \"transparent\",\n shadow = true,\n height = 2,\n onLoaderFinished,\n transitionTime = 300,\n waitingTime = 1000,\n className = \"\",\n containerClassName = \"\",\n style = {},\n containerStyle = {},\n shadowStyle = {},\n },\n ref\n ) => {\n // States\n const [localProgress, setLocalProgress] = useState<number>(0);\n const [usingProps, setUsingProps] = useState<boolean>(false);\n const [isComplete, setIsComplete] = useState<boolean>(false);\n\n // Style states\n const [loaderStyle, setLoaderStyle] = useState<React.CSSProperties>({\n ...baseStyles.loader,\n height,\n width: `${localProgress}%`,\n transition: `all ${transitionTime}ms ease-out`,\n background: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\"),\n ...style,\n });\n\n const [containerStyles, setContainerStyles] = useState<React.CSSProperties>({\n ...baseStyles.container,\n height,\n background,\n ...containerStyle,\n })\n\n // Refs\n const isMounted = useRef<boolean>(false);\n\n const continuous = useRef<{ active: boolean; refreshRate: number }>({\n active: false,\n refreshRate: 1000,\n });\n const staticStart = useRef<{ active: boolean; value: number }>({\n active: false,\n value: 0,\n });\n\n useImperativeHandle(ref, () => ({\n continuousStart(startingValue = 10, refreshRate = 1000) {\n if (usingProps) return;\n continuous.current = { active: true, refreshRate };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n staticStart(startingValue = 30) {\n if (usingProps) return;\n staticStart.current = { active: true, value: startingValue };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n complete() {\n if (usingProps) return;\n setLocalProgress(100);\n checkIfFull(100);\n setIsComplete(true);\n continuous.current.active = false;\n staticStart.current.active = false;\n },\n getProgress() {\n return localProgress;\n },\n }));\n\n useEffect(() => {\n if (progress !== undefined) {\n setUsingProps(true);\n setLocalProgress(progress);\n }\n }, [progress]);\n\n useEffect(() => {\n if (isComplete && localProgress >= 100) {\n const timeoutId = setTimeout(() => {\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n setIsComplete(false);\n }, waitingTime);\n\n return () => clearTimeout(timeoutId);\n }\n }, [isComplete, localProgress, waitingTime, onLoaderFinished]);\n\n useInterval(() => {\n if (continuous.current.active && !isComplete) {\n const increment = randomInt(1, 10);\n setLocalProgress((prev) => Math.min(prev + increment, 100));\n if (localProgress + increment >= 100) {\n continuous.current.active = false;\n setIsComplete(true);\n }\n }\n }, continuous.current.active ? continuous.current.refreshRate : null);\n\n // Helpers\n const checkIfFull = (progress: number) => {\n if (progress >= 100) {\n setLoaderStyle({\n ...loaderStyle,\n width: \"100%\"\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n setLoaderStyle({\n ...loaderStyle,\n opacity: 0,\n width: \"100%\",\n transition: `all ${transitionTime}ms ease-out`,\n color: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\")\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n // Handle continuous start\n if (continuous.current.active) {\n\n continuous.current = {\n ...continuous.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n // Handle static start\n if (staticStart.current.active) {\n\n staticStart.current = {\n ...staticStart.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n checkIfFull(0);\n }, transitionTime);\n }, waitingTime);\n } else {\n setLoaderStyle((prev) => (\n {\n ...prev,\n width: `${progress}%`,\n opacity: 1,\n transition: `all ${transitionTime}ms ease-out`,\n }\n ));\n }\n };\n\n // Handle mount\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n }\n }, []);\n\n return (\n <div style={containerStyles} className={containerClassName} >\n <div style={loaderStyle} className={className} > </div>\n {shadow && <div style={{ ...baseStyles.shadow, ...shadowStyle }} />}\n </div>\n );\n }\n);\n\nexport default LoadingBar;","import { useEffect, useRef } from \"react\";\n\nexport const useInterval = (\n callback: () => void,\n delay: number | null,\n immediate?: boolean\n) => {\n const savedCallback = useRef(() => { });\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (immediate && delay !== null) {\n savedCallback.current();\n }\n }, [immediate, delay]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(savedCallback.current, delay);\n return () => clearInterval(id);\n }, [delay]);\n};","const randomValue = (min: number, max: number): number => (Math.random() * (max - min + 1) + min);\n\nexport const randomInt = (min: number, max: number): number => Math.floor(randomValue(min, max));"],"names":["isGradient","color","Array","isArray","length","join","isValidHex","test","baseStyles","top","left","width","zIndex","height","position","overflow","transition","transform","boxShadow","LoadingBar","forwardRef","_ref","ref","callback","delay","savedCallback","progress","_ref$color","_ref$background","background","_ref$shadow","shadow","_ref$height","onLoaderFinished","_ref$transitionTime","transitionTime","_ref$waitingTime","waitingTime","_ref$className","className","_ref$containerClassNa","containerClassName","_ref$style","style","_ref$containerStyle","containerStyle","_ref$shadowStyle","shadowStyle","_useState","useState","localProgress","setLocalProgress","_useState2","usingProps","setUsingProps","_useState3","isComplete","setIsComplete","_useState4","_extends","loaderStyle","setLoaderStyle","containerStyles","isMounted","useRef","continuous","active","refreshRate","staticStart","value","useImperativeHandle","continuousStart","startingValue","current","checkIfFull","complete","getProgress","useEffect","undefined","timeoutId","setTimeout","clearTimeout","increment","Math","floor","random","prev","min","immediate","id","setInterval","clearInterval","opacity","React"],"mappings":"mUAAaA,EAAa,SAACC,GACvB,SAAIC,MAAMC,QAAQF,IAAUA,EAAMG,OAAS,iCACHH,EAAMI,KAAK,WAK1CC,EAAa,SAACL,8CAAiEM,KAAKN,ICP3FO,EACS,CACPC,IAAK,EACLC,KAAM,EACNC,MAAO,OACPC,OAAQ,KACRC,OAAQ,OACRC,SAAU,QACVC,SAAU,UARZP,EAUM,CACJG,MAAO,KACPE,OAAQ,OACRG,WAAY,iBAbdR,EAeM,CACJE,KAAM,SACNG,OAAQ,OACRC,SAAU,WACVE,WAAY,gBACZC,UAAW,kCACXC,UAAW,+CCNbC,EAAaC,EACf,SAAAC,EAgBIC,OC7BJC,EACAC,EAGMC,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,UAGXqE,WAAW,WACFjB,IAELF,EAAcF,KACPC,GACHgC,QAAS,EACTjF,MAAO,OACPK,kBAAmBmB,gBACnBlC,MAAOD,EAAWC,KAAWK,EAAWL,GAAoBA,EAAmB,aAGnF+E,WAAW,WACFjB,IAGDE,GAAWQ,QAAQP,SAEnBD,GAAWQ,QAAOd,KACXM,GAAWQ,SACdP,QAAQ,IAGZf,EAAiB,GACjBuB,GAAY,IAIZN,GAAYK,QAAQP,SAEpBE,GAAYK,QAAOd,KACZS,GAAYK,SACfP,QAAQ,IAGZf,EAAiB,GACjBuB,GAAY,IAGZzC,GAAkBA,IACtBkB,EAAiB,GACjBuB,GAAY,KACbvC,KACJE,IAEHwB,EAAe,SAACyB,UAAI3B,KAET2B,GACH3E,MAAUe,MACVkE,QAAS,EACT5E,kBAAmBmB,qBAcnC,OAPA0C,EAAU,WAEN,OADAd,EAAUU,SAAU,aAEhBV,EAAUU,SAAU,IAEzB,IAGCoB,uBAAKlD,MAAOmB,EAAiBvB,UAAWE,GACpCoD,uBAAKlD,MAAOiB,EAAarB,UAAWA,QACnCR,GAAU8D,uBAAKlD,MAAKgB,KAAOnD,EAAsBuC"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).reactPageLoadingBar=t(e.react)}(this,function(e){var t="default"in e?e.default:e;function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}var r=function(e){return!!(Array.isArray(e)&&e.length>1)&&"linear-gradient(to right, "+e.join(", ")+")"},i=function(e){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e)},a={top:0,left:0,width:"100%",zIndex:9800,height:"100%",position:"fixed",overflow:"hidden"},o={width:"0%",height:"100%",transition:"all 0.3s ease"},u={left:"-10rem",height:"100%",position:"absolute",transition:"all 0.3s ease",transform:"rotate(3deg) translate(0, -4px)",boxShadow:"0 0 10px var(--color), 0 0 5px var(--color)"};return e.forwardRef(function(c,s){var f,l,d,v=c.progress,h=c.color,p=void 0===h?"purple":h,m=c.background,g=void 0===m?"transparent":m,y=c.shadow,w=void 0===y||y,S=c.height,b=void 0===S?2:S,E=c.onLoaderFinished,x=c.transitionTime,R=void 0===x?300:x,T=c.waitingTime,j=void 0===T?1e3:T,A=c.className,I=void 0===A?"":A,N=c.containerClassName,k=void 0===N?"":N,F=c.style,M=void 0===F?{}:F,O=c.containerStyle,P=void 0===O?{}:O,L=c.shadowStyle,q=void 0===L?{}:L,z=e.useState(0),B=z[0],C=z[1],H=e.useState(!1),$=H[0],D=H[1],G=e.useState(!1),J=G[0],K=G[1],Q=e.useState(n({},o,{height:b,width:B+"%",transition:"all "+R+"ms ease-out",background:r(p)||(i(p)?p:"purple")},M)),U=Q[0],V=Q[1],W=e.useState(n({},a,{height:b,background:g},P))[0],X=e.useRef(!1),Y=e.useRef({active:!1,refreshRate:1e3}),Z=e.useRef({active:!1,value:0});e.useImperativeHandle(s,function(){return{continuousStart:function(e,t){void 0===e&&(e=10),void 0===t&&(t=1e3),$||(Y.current={active:!0,refreshRate:t},C(e),_(e),K(!1))},staticStart:function(e){void 0===e&&(e=30),$||(Z.current={active:!0,value:e},C(e),_(e),K(!1))},complete:function(){$||(C(100),_(100),K(!0),Y.current.active=!1,Z.current.active=!1)},getProgress:function(){return B}}}),e.useEffect(function(){void 0!==v&&(D(!0),C(v))},[v]),e.useEffect(function(){if(J&&B>=100){var e=setTimeout(function(){E&&E(),C(0),K(!1)},j);return function(){return clearTimeout(e)}}},[J,B,j,E]),f=function(){if(Y.current.active&&!J){var e=Math.floor(10*Math.random()+1);C(function(t){return Math.min(t+e,100)}),B+e>=100&&(Y.current.active=!1,K(!0))}},l=Y.current.active?Y.current.refreshRate:null,d=e.useRef(function(){}),e.useEffect(function(){d.current=f}),e.useEffect(function(){},[void 0,l]),e.useEffect(function(){if(null!==l){var e=setInterval(d.current,l);return function(){return clearInterval(e)}}},[l]);var _=function(e){e>=100?(V(n({},U,{width:"100%"})),setTimeout(function(){X&&(V(n({},U,{opacity:0,width:"100%",transition:"all "+R+"ms ease-out",color:r(p)||(i(p)?p:"purple")})),setTimeout(function(){X&&(Y.current.active&&(Y.current=n({},Y.current,{active:!1}),C(0),_(0)),Z.current.active&&(Z.current=n({},Z.current,{active:!1}),C(0),_(0)),E&&E(),C(0),_(0))},R))},j)):V(function(t){return n({},t,{width:e+"%",opacity:1,transition:"all "+R+"ms ease-out"})})};return e.useEffect(function(){return X.current=!0,function(){X.current=!1}},[]),t.createElement("div",{style:W,className:k},t.createElement("div",{style:U,className:I}," "),w&&t.createElement("div",{style:n({},u,q)}))})});
|
2
|
-
//# sourceMappingURL=index.
|
2
|
+
//# sourceMappingURL=index.umd.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.com.js","sources":["../src/utils/colorUtils.ts","../src/styles/styles.ts","../src/components/LoadingBar.tsx","../src/hooks/useInterval.ts","../src/utils/randomUtils.ts"],"sourcesContent":["export const isGradient = (color: string | string[]): string | false => {\n if (Array.isArray(color) && color.length > 1) {\n return `linear-gradient(to right, ${color.join(\", \")})`;\n }\n return false;\n};\n\nexport const isValidHex = (color: string): boolean => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));","const baseStyles: Record<string, React.CSSProperties> = {\n container: {\n top: 0,\n left: 0,\n width: \"100%\",\n zIndex: 9800,\n height: \"100%\",\n position: \"fixed\",\n overflow: \"hidden\",\n },\n loader: {\n width: \"0%\",\n height: \"100%\",\n transition: \"all 0.3s ease\",\n },\n shadow: {\n left: \"-10rem\",\n height: \"100%\",\n position: \"absolute\",\n transition: \"all 0.3s ease\",\n transform: \"rotate(3deg) translate(0, -4px)\",\n boxShadow: \"0 0 10px var(--color), 0 0 5px var(--color)\",\n }\n};\n\nexport default baseStyles;","import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from \"react\";\n\n// Hooks\nimport { useInterval } from \"../hooks/useInterval\";\n\n// Utils\nimport { randomInt } from \"../utils/randomUtils\";\nimport { isGradient, isValidHex } from \"../utils/colorUtils\";\n\n// Styles\nimport baseStyles from \"../styles/styles\";\n\n// Types\nimport type { LoadingBarRef, LoadingBarProps } from \"../../types\";\n\nconst LoadingBar = forwardRef<LoadingBarRef, LoadingBarProps>(\n (\n {\n progress,\n color = \"purple\",\n background = \"transparent\",\n shadow = true,\n height = 2,\n onLoaderFinished,\n transitionTime = 300,\n waitingTime = 1000,\n className = \"\",\n containerClassName = \"\",\n style = {},\n containerStyle = {},\n shadowStyle = {},\n },\n ref\n ) => {\n // States\n const [localProgress, setLocalProgress] = useState<number>(0);\n const [usingProps, setUsingProps] = useState<boolean>(false);\n const [isComplete, setIsComplete] = useState<boolean>(false);\n\n // Style states\n const [loaderStyle, setLoaderStyle] = useState<React.CSSProperties>({\n ...baseStyles.loader,\n height,\n width: `${localProgress}%`,\n transition: `all ${transitionTime}ms ease-out`,\n background: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\"),\n ...style,\n });\n\n const [containerStyles, setContainerStyles] = useState<React.CSSProperties>({\n ...baseStyles.container,\n height,\n background,\n ...containerStyle,\n })\n\n // Refs\n const isMounted = useRef<boolean>(false);\n\n const continuous = useRef<{ active: boolean; refreshRate: number }>({\n active: false,\n refreshRate: 1000,\n });\n const staticStart = useRef<{ active: boolean; value: number }>({\n active: false,\n value: 0,\n });\n\n useImperativeHandle(ref, () => ({\n continuousStart(startingValue = 10, refreshRate = 1000) {\n if (usingProps) return;\n continuous.current = { active: true, refreshRate };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n staticStart(startingValue = 30) {\n if (usingProps) return;\n staticStart.current = { active: true, value: startingValue };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n complete() {\n if (usingProps) return;\n setLocalProgress(100);\n checkIfFull(100);\n setIsComplete(true);\n continuous.current.active = false;\n staticStart.current.active = false;\n },\n getProgress() {\n return localProgress;\n },\n }));\n\n useEffect(() => {\n if (progress !== undefined) {\n setUsingProps(true);\n setLocalProgress(progress);\n }\n }, [progress]);\n\n useEffect(() => {\n if (isComplete && localProgress >= 100) {\n const timeoutId = setTimeout(() => {\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n setIsComplete(false);\n }, waitingTime);\n\n return () => clearTimeout(timeoutId);\n }\n }, [isComplete, localProgress, waitingTime, onLoaderFinished]);\n\n useInterval(() => {\n if (continuous.current.active && !isComplete) {\n const increment = randomInt(1, 10);\n setLocalProgress((prev) => Math.min(prev + increment, 100));\n if (localProgress + increment >= 100) {\n continuous.current.active = false;\n setIsComplete(true);\n }\n }\n }, continuous.current.active ? continuous.current.refreshRate : null);\n\n // Helpers\n const checkIfFull = (progress: number) => {\n if (progress >= 100) {\n setLoaderStyle({\n ...loaderStyle,\n width: \"100%\"\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n setLoaderStyle({\n ...loaderStyle,\n opacity: 0,\n width: \"100%\",\n transition: `all ${transitionTime}ms ease-out`,\n color: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\")\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n // Handle continuous start\n if (continuous.current.active) {\n\n continuous.current = {\n ...continuous.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n // Handle static start\n if (staticStart.current.active) {\n\n staticStart.current = {\n ...staticStart.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n checkIfFull(0);\n }, transitionTime);\n }, waitingTime);\n } else {\n setLoaderStyle((prev) => (\n {\n ...prev,\n width: `${progress}%`,\n opacity: 1,\n transition: `all ${transitionTime}ms ease-out`,\n }\n ));\n }\n };\n\n // Handle mount\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n }\n }, []);\n\n return (\n <div style={containerStyles} className={containerClassName} >\n <div style={loaderStyle} className={className} > </div>\n {shadow && <div style={{ ...baseStyles.shadow, ...shadowStyle }} />}\n </div>\n );\n }\n);\n\nexport default LoadingBar;","import { useEffect, useRef } from \"react\";\n\nexport const useInterval = (\n callback: () => void,\n delay: number | null,\n immediate?: boolean\n) => {\n const savedCallback = useRef(() => { });\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (immediate && delay !== null) {\n savedCallback.current();\n }\n }, [immediate, delay]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(savedCallback.current, delay);\n return () => clearInterval(id);\n }, [delay]);\n};","const randomValue = (min: number, max: number): number => (Math.random() * (max - min + 1) + min);\n\nexport const randomInt = (min: number, max: number): number => Math.floor(randomValue(min, max));"],"names":["isGradient","color","Array","isArray","length","join","isValidHex","test","baseStyles","top","left","width","zIndex","height","position","overflow","transition","transform","boxShadow","LoadingBar","forwardRef","_ref","ref","callback","delay","savedCallback","progress","_ref$color","_ref$background","background","_ref$shadow","shadow","_ref$height","onLoaderFinished","_ref$transitionTime","transitionTime","_ref$waitingTime","waitingTime","_ref$className","className","_ref$containerClassNa","containerClassName","_ref$style","style","_ref$containerStyle","containerStyle","_ref$shadowStyle","shadowStyle","_useState","useState","localProgress","setLocalProgress","_useState2","usingProps","setUsingProps","_useState3","isComplete","setIsComplete","_useState4","_extends","loaderStyle","setLoaderStyle","containerStyles","isMounted","useRef","continuous","active","refreshRate","staticStart","value","useImperativeHandle","continuousStart","startingValue","current","checkIfFull","complete","getProgress","useEffect","undefined","timeoutId","setTimeout","clearTimeout","increment","Math","floor","random","prev","min","immediate","id","setInterval","clearInterval","opacity","React"],"mappings":"2SAAaA,EAAa,SAACC,GACvB,SAAIC,MAAMC,QAAQF,IAAUA,EAAMG,OAAS,iCACHH,EAAMI,KAAK,WAK1CC,EAAa,SAACL,8CA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QAAQN,YAAc,KCrH9D1C,EAAgBuC,SAAO,cAE7Ba,YAAU,WACNpD,EAAcgD,QAAUlD,IAG5BsD,YAAU,aAIP,MAZHW,EAYehE,IAEfqD,YAAU,WACN,GAAc,OAAVrD,EAAJ,CACA,IAAMiE,EAAKC,YAAYjE,EAAcgD,QAASjD,GAC9C,yBAAamE,cAAcF,MAC5B,CAACjE,IDwGA,IAAMkD,EAAc,SAAChD,GACbA,GAAY,KACZmC,EAAcF,KACPC,GACHjD,MAAO,UAGXqE,WAAW,WACFjB,IAELF,EAAcF,KACPC,GACHgC,QAAS,EACTjF,MAAO,OACPK,kBAAmBmB,gBACnBlC,MAAOD,EAAWC,KAAWK,EAAWL,GAAoBA,EAAmB,aAGnF+E,WAAW,WACFjB,IAGDE,EAAWQ,QAAQP,SAEnBD,EAAWQ,QAAOd,KACXM,EAAWQ,SACdP,QAAQ,IAGZf,EAAiB,GACjBuB,EAAY,IAIZN,EAAYK,QAAQP,SAEpBE,EAAYK,QAAOd,KACZS,EAAYK,SACfP,QAAQ,IAGZf,EAAiB,GACjBuB,EAAY,IAGZzC,GAAkBA,IACtBkB,EAAiB,GACjBuB,EAAY,KACbvC,KACJE,IAEHwB,EAAe,SAACyB,UAAI3B,KAET2B,GACH3E,MAAUe,MACVkE,QAAS,EACT5E,kBAAmBmB,qBAcnC,OAPA0C,YAAU,WAEN,OADAd,EAAUU,SAAU,aAEhBV,EAAUU,SAAU,IAEzB,IAGCoB,uBAAKlD,MAAOmB,EAAiBvB,UAAWE,GACpCoD,uBAAKlD,MAAOiB,EAAarB,UAAWA,QACnCR,GAAU8D,uBAAKlD,MAAKgB,KAAOnD,EAAsBuC"}
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/utils/colorUtils.ts","../src/styles/styles.ts","../src/components/LoadingBar.tsx","../src/hooks/useInterval.ts","../src/utils/randomUtils.ts"],"sourcesContent":["export const isGradient = (color: string | string[]): string | false => {\n if (Array.isArray(color) && color.length > 1) {\n return `linear-gradient(to right, ${color.join(\", \")})`;\n }\n return false;\n};\n\nexport const isValidHex = (color: string): boolean => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));","const baseStyles: Record<string, React.CSSProperties> = {\n container: {\n top: 0,\n left: 0,\n width: \"100%\",\n zIndex: 9800,\n height: \"100%\",\n position: \"fixed\",\n overflow: \"hidden\",\n },\n loader: {\n width: \"0%\",\n height: \"100%\",\n transition: \"all 0.3s ease\",\n },\n shadow: {\n left: \"-10rem\",\n height: \"100%\",\n position: \"absolute\",\n transition: \"all 0.3s ease\",\n transform: \"rotate(3deg) translate(0, -4px)\",\n boxShadow: \"0 0 10px var(--color), 0 0 5px var(--color)\",\n }\n};\n\nexport default baseStyles;","import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from \"react\";\n\n// Hooks\nimport { useInterval } from \"../hooks/useInterval\";\n\n// Utils\nimport { randomInt } from \"../utils/randomUtils\";\nimport { isGradient, isValidHex } from \"../utils/colorUtils\";\n\n// Styles\nimport baseStyles from \"../styles/styles\";\n\n// Types\nimport type { LoadingBarRef, LoadingBarProps } from \"../../types\";\n\nconst LoadingBar = forwardRef<LoadingBarRef, LoadingBarProps>(\n (\n {\n progress,\n color = \"purple\",\n background = \"transparent\",\n shadow = true,\n height = 2,\n onLoaderFinished,\n transitionTime = 300,\n waitingTime = 1000,\n className = \"\",\n containerClassName = \"\",\n style = {},\n containerStyle = {},\n shadowStyle = {},\n },\n ref\n ) => {\n // States\n const [localProgress, setLocalProgress] = useState<number>(0);\n const [usingProps, setUsingProps] = useState<boolean>(false);\n const [isComplete, setIsComplete] = useState<boolean>(false);\n\n // Style states\n const [loaderStyle, setLoaderStyle] = useState<React.CSSProperties>({\n ...baseStyles.loader,\n height,\n width: `${localProgress}%`,\n transition: `all ${transitionTime}ms ease-out`,\n background: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\"),\n ...style,\n });\n\n const [containerStyles, setContainerStyles] = useState<React.CSSProperties>({\n ...baseStyles.container,\n height,\n background,\n ...containerStyle,\n })\n\n // Refs\n const isMounted = useRef<boolean>(false);\n\n const continuous = useRef<{ active: boolean; refreshRate: number }>({\n active: false,\n refreshRate: 1000,\n });\n const staticStart = useRef<{ active: boolean; value: number }>({\n active: false,\n value: 0,\n });\n\n useImperativeHandle(ref, () => ({\n continuousStart(startingValue = 10, refreshRate = 1000) {\n if (usingProps) return;\n continuous.current = { active: true, refreshRate };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n staticStart(startingValue = 30) {\n if (usingProps) return;\n staticStart.current = { active: true, value: startingValue };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n complete() {\n if (usingProps) return;\n setLocalProgress(100);\n checkIfFull(100);\n setIsComplete(true);\n continuous.current.active = false;\n staticStart.current.active = false;\n },\n getProgress() {\n return localProgress;\n },\n }));\n\n useEffect(() => {\n if (progress !== undefined) {\n setUsingProps(true);\n setLocalProgress(progress);\n }\n }, [progress]);\n\n useEffect(() => {\n if (isComplete && localProgress >= 100) {\n const timeoutId = setTimeout(() => {\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n setIsComplete(false);\n }, waitingTime);\n\n return () => clearTimeout(timeoutId);\n }\n }, [isComplete, localProgress, waitingTime, onLoaderFinished]);\n\n useInterval(() => {\n if (continuous.current.active && !isComplete) {\n const increment = randomInt(1, 10);\n setLocalProgress((prev) => Math.min(prev + increment, 100));\n if (localProgress + increment >= 100) {\n continuous.current.active = false;\n setIsComplete(true);\n }\n }\n }, continuous.current.active ? continuous.current.refreshRate : null);\n\n // Helpers\n const checkIfFull = (progress: number) => {\n if (progress >= 100) {\n setLoaderStyle({\n ...loaderStyle,\n width: \"100%\"\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n setLoaderStyle({\n ...loaderStyle,\n opacity: 0,\n width: \"100%\",\n transition: `all ${transitionTime}ms ease-out`,\n color: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\")\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n // Handle continuous start\n if (continuous.current.active) {\n\n continuous.current = {\n ...continuous.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n // Handle static start\n if (staticStart.current.active) {\n\n staticStart.current = {\n ...staticStart.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n checkIfFull(0);\n }, transitionTime);\n }, waitingTime);\n } else {\n setLoaderStyle((prev) => (\n {\n ...prev,\n width: `${progress}%`,\n opacity: 1,\n transition: `all ${transitionTime}ms ease-out`,\n }\n ));\n }\n };\n\n // Handle mount\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n }\n }, []);\n\n return (\n <div style={containerStyles} className={containerClassName} >\n <div style={loaderStyle} className={className} > </div>\n {shadow && <div style={{ ...baseStyles.shadow, ...shadowStyle }} />}\n </div>\n );\n }\n);\n\nexport default LoadingBar;","import { useEffect, useRef } from \"react\";\n\nexport const useInterval = (\n callback: () => void,\n delay: number | null,\n immediate?: boolean\n) => {\n const savedCallback = useRef(() => { });\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (immediate && delay !== null) {\n savedCallback.current();\n }\n }, [immediate, delay]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(savedCallback.current, delay);\n return () => clearInterval(id);\n }, [delay]);\n};","const randomValue = (min: number, max: number): number => (Math.random() * (max - min + 1) + min);\n\nexport const randomInt = (min: number, max: number): number => Math.floor(randomValue(min, max));"],"names":["isGradient","color","Array","isArray","length","join","isValidHex","test","baseStyles","top","left","width","zIndex","height","position","overflow","transition","transform","boxShadow","forwardRef","_ref","ref","callback","delay","savedCallback","progress","_ref$color","_ref$background","background","_ref$shadow","shadow","_ref$height","onLoaderFinished","_ref$transitionTime","transitionTime","_ref$waitingTime","waitingTime","_ref$className","className","_ref$containerClassNa","containerClassName","_ref$style","style","_ref$containerStyle","containerStyle","_ref$shadowStyle","shadowStyle","_useState","useState","localProgress","setLocalProgress","_useState2","usingProps","setUsingProps","_useState3","isComplete","setIsComplete","_useState4","_extends","loaderStyle","setLoaderStyle","containerStyles","isMounted","useRef","continuous","active","refreshRate","staticStart","value","useImperativeHandle","continuousStart","startingValue","current","checkIfFull","complete","getProgress","useEffect","undefined","timeoutId","setTimeout","clearTimeout","increment","Math","floor","random","prev","min","immediate","id","setInterval","clearInterval","opacity","React"],"mappings":"ydAAaA,EAAa,SAACC,GACvB,SAAIC,MAAMC,QAAQF,IAAUA,EAAMG,OAAS,iCACHH,EAAMI,KAAK,WAK1CC,EAAa,SAACL,8CAAiEM,KAAKN,ICP3FO,EACS,CACPC,IAAK,EACLC,KAAM,EACNC,MAAO,OACPC,OAAQ,KACRC,OAAQ,OACRC,SAAU,QACVC,SAAU,UARZP,EAUM,CACJG,MAAO,KACPE,OAAQ,OACRG,WAAY,iBAbdR,EAeM,CACJE,KAAM,SACNG,OAAQ,OACRC,SAAU,WACVE,WAAY,gBACZC,UAAW,kCACXC,UAAW,sDCNAC,aACf,SAAAC,EAgBIC,OC7BJC,EACAC,EAGMC,EDWEC,EAAQL,EAARK,SAAQC,EAAAN,EACRnB,MAAAA,WAAKyB,EAAG,SAAQA,EAAAC,EAAAP,EAChBQ,WAAAA,WAAUD,EAAG,cAAaA,EAAAE,EAAAT,EAC1BU,OAAAA,WAAMD,GAAOA,EAAAE,EAAAX,EACbP,OAAAA,WAAMkB,EAAG,EAACA,EACVC,EAAgBZ,EAAhBY,iBAAgBC,EAAAb,EAChBc,eAAAA,WAAcD,EAAG,IAAGA,EAAAE,EAAAf,EACpBgB,YAAAA,WAAWD,EAAG,IAAIA,EAAAE,EAAAjB,EAClBkB,UAAAA,WAASD,EAAG,GAAEA,EAAAE,EAAAnB,EACdoB,mBAAAA,WAAkBD,EAAG,GAAEA,EAAAE,EAAArB,EACvBsB,MAAAA,WAAKD,EAAG,GAAEA,E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kBAAmBkB,qBAcnC,OAPA0C,YAAU,WAEN,OADAd,EAAUU,SAAU,aAEhBV,EAAUU,SAAU,IAEzB,IAGCoB,uBAAKlD,MAAOmB,EAAiBvB,UAAWE,GACpCoD,uBAAKlD,MAAOiB,EAAarB,UAAWA,QACnCR,GAAU8D,uBAAKlD,MAAKgB,KAAOlD,EAAsBsC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-page-loading-bar",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.9",
|
4
4
|
"description": "A react top loading bar component for page loads",
|
5
5
|
"author": {
|
6
6
|
"name": "SyntaxisCS",
|
@@ -8,12 +8,9 @@
|
|
8
8
|
},
|
9
9
|
"type": "module",
|
10
10
|
"source": "src/index.ts",
|
11
|
-
"main": "./build/index.
|
12
|
-
"module": "./build/index.
|
13
|
-
"
|
14
|
-
"require": "./dist/index.cjs",
|
15
|
-
"default": "./dist/index.modern.js"
|
16
|
-
},
|
11
|
+
"main": "./build/index.js",
|
12
|
+
"module": "./build/index.modern.js",
|
13
|
+
"unpkg": "./build/index.umd.js",
|
17
14
|
"types": "build/index.d.ts",
|
18
15
|
"scripts": {
|
19
16
|
"compile": "tsc",
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import t,{useRef as e,useEffect as n,forwardRef as r,useState as i,useImperativeHandle as o}from"react";function a(){return(a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(null,arguments)}var c=function(t){return!!(Array.isArray(t)&&t.length>1)&&"linear-gradient(to right, "+t.join(", ")+")"},u=function(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)},s={top:0,left:0,width:"100%",zIndex:9800,height:"100%",position:"fixed",overflow:"hidden"},l={width:"0%",height:"100%",transition:"all 0.3s ease"},v={left:"-10rem",height:"100%",position:"absolute",transition:"all 0.3s ease",transform:"rotate(3deg) translate(0, -4px)",boxShadow:"0 0 10px var(--color), 0 0 5px var(--color)"},f=r(function(r,f){var d,h,m,p=r.progress,g=r.color,w=void 0===g?"purple":g,y=r.background,b=void 0===y?"transparent":y,x=r.shadow,T=void 0===x||x,S=r.height,A=void 0===S?2:S,N=r.onLoaderFinished,j=r.transitionTime,k=void 0===j?300:j,E=r.waitingTime,F=void 0===E?1e3:E,I=r.className,M=void 0===I?"":I,O=r.containerClassName,R=void 0===O?"":O,P=r.style,z=void 0===P?{}:P,C=r.containerStyle,L=void 0===C?{}:C,$=r.shadowStyle,q=void 0===$?{}:$,B=i(0),D=B[0],G=B[1],H=i(!1),J=H[0],K=H[1],Q=i(!1),U=Q[0],V=Q[1],W=i(a({},l,{height:A,width:D+"%",transition:"all "+k+"ms ease-out",background:c(w)||(u(w)?w:"purple")},z)),X=W[0],Y=W[1],Z=i(a({},s,{height:A,background:b},L))[0],_=e(!1),tt=e({active:!1,refreshRate:1e3}),et=e({active:!1,value:0});o(f,function(){return{continuousStart:function(t,e){void 0===t&&(t=10),void 0===e&&(e=1e3),J||(tt.current={active:!0,refreshRate:e},G(t),nt(t),V(!1))},staticStart:function(t){void 0===t&&(t=30),J||(et.current={active:!0,value:t},G(t),nt(t),V(!1))},complete:function(){J||(G(100),nt(100),V(!0),tt.current.active=!1,et.current.active=!1)},getProgress:function(){return D}}}),n(function(){void 0!==p&&(K(!0),G(p))},[p]),n(function(){if(U&&D>=100){var t=setTimeout(function(){N&&N(),G(0),V(!1)},F);return function(){return clearTimeout(t)}}},[U,D,F,N]),d=function(){if(tt.current.active&&!U){var t=Math.floor(10*Math.random()+1);G(function(e){return Math.min(e+t,100)}),D+t>=100&&(tt.current.active=!1,V(!0))}},h=tt.current.active?tt.current.refreshRate:null,m=e(function(){}),n(function(){m.current=d}),n(function(){},[void 0,h]),n(function(){if(null!==h){var t=setInterval(m.current,h);return function(){return clearInterval(t)}}},[h]);var nt=function(t){t>=100?(Y(a({},X,{width:"100%"})),setTimeout(function(){_&&(Y(a({},X,{opacity:0,width:"100%",transition:"all "+k+"ms ease-out",color:c(w)||(u(w)?w:"purple")})),setTimeout(function(){_&&(tt.current.active&&(tt.current=a({},tt.current,{active:!1}),G(0),nt(0)),et.current.active&&(et.current=a({},et.current,{active:!1}),G(0),nt(0)),N&&N(),G(0),nt(0))},k))},F)):Y(function(e){return a({},e,{width:t+"%",opacity:1,transition:"all "+k+"ms ease-out"})})};return n(function(){return _.current=!0,function(){_.current=!1}},[]),t.createElement("div",{style:Z,className:R},t.createElement("div",{style:X,className:M}," "),T&&t.createElement("div",{style:a({},v,q)}))});export default f;
|
2
|
-
//# sourceMappingURL=index.com.modern.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.com.modern.js","sources":["../src/utils/colorUtils.ts","../src/styles/styles.ts","../src/components/LoadingBar.tsx","../src/hooks/useInterval.ts","../src/utils/randomUtils.ts"],"sourcesContent":["export const isGradient = (color: string | string[]): string | false => {\n if (Array.isArray(color) && color.length > 1) {\n return `linear-gradient(to right, ${color.join(\", \")})`;\n }\n return false;\n};\n\nexport const isValidHex = (color: string): boolean => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));","const baseStyles: Record<string, React.CSSProperties> = {\n container: {\n top: 0,\n left: 0,\n width: \"100%\",\n zIndex: 9800,\n height: \"100%\",\n position: \"fixed\",\n overflow: \"hidden\",\n },\n loader: {\n width: \"0%\",\n height: \"100%\",\n transition: \"all 0.3s ease\",\n },\n shadow: {\n left: \"-10rem\",\n height: \"100%\",\n position: \"absolute\",\n transition: \"all 0.3s ease\",\n transform: \"rotate(3deg) translate(0, -4px)\",\n boxShadow: \"0 0 10px var(--color), 0 0 5px var(--color)\",\n }\n};\n\nexport default baseStyles;","import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from \"react\";\n\n// Hooks\nimport { useInterval } from \"../hooks/useInterval\";\n\n// Utils\nimport { randomInt } from \"../utils/randomUtils\";\nimport { isGradient, isValidHex } from \"../utils/colorUtils\";\n\n// Styles\nimport baseStyles from \"../styles/styles\";\n\n// Types\nimport type { LoadingBarRef, LoadingBarProps } from \"../../types\";\n\nconst LoadingBar = forwardRef<LoadingBarRef, LoadingBarProps>(\n (\n {\n progress,\n color = \"purple\",\n background = \"transparent\",\n shadow = true,\n height = 2,\n onLoaderFinished,\n transitionTime = 300,\n waitingTime = 1000,\n className = \"\",\n containerClassName = \"\",\n style = {},\n containerStyle = {},\n shadowStyle = {},\n },\n ref\n ) => {\n // States\n const [localProgress, setLocalProgress] = useState<number>(0);\n const [usingProps, setUsingProps] = useState<boolean>(false);\n const [isComplete, setIsComplete] = useState<boolean>(false);\n\n // Style states\n const [loaderStyle, setLoaderStyle] = useState<React.CSSProperties>({\n ...baseStyles.loader,\n height,\n width: `${localProgress}%`,\n transition: `all ${transitionTime}ms ease-out`,\n background: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\"),\n ...style,\n });\n\n const [containerStyles, setContainerStyles] = useState<React.CSSProperties>({\n ...baseStyles.container,\n height,\n background,\n ...containerStyle,\n })\n\n // Refs\n const isMounted = useRef<boolean>(false);\n\n const continuous = useRef<{ active: boolean; refreshRate: number }>({\n active: false,\n refreshRate: 1000,\n });\n const staticStart = useRef<{ active: boolean; value: number }>({\n active: false,\n value: 0,\n });\n\n useImperativeHandle(ref, () => ({\n continuousStart(startingValue = 10, refreshRate = 1000) {\n if (usingProps) return;\n continuous.current = { active: true, refreshRate };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n staticStart(startingValue = 30) {\n if (usingProps) return;\n staticStart.current = { active: true, value: startingValue };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n complete() {\n if (usingProps) return;\n setLocalProgress(100);\n checkIfFull(100);\n setIsComplete(true);\n continuous.current.active = false;\n staticStart.current.active = false;\n },\n getProgress() {\n return localProgress;\n },\n }));\n\n useEffect(() => {\n if (progress !== undefined) {\n setUsingProps(true);\n setLocalProgress(progress);\n }\n }, [progress]);\n\n useEffect(() => {\n if (isComplete && localProgress >= 100) {\n const timeoutId = setTimeout(() => {\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n setIsComplete(false);\n }, waitingTime);\n\n return () => clearTimeout(timeoutId);\n }\n }, [isComplete, localProgress, waitingTime, onLoaderFinished]);\n\n useInterval(() => {\n if (continuous.current.active && !isComplete) {\n const increment = randomInt(1, 10);\n setLocalProgress((prev) => Math.min(prev + increment, 100));\n if (localProgress + increment >= 100) {\n continuous.current.active = false;\n setIsComplete(true);\n }\n }\n }, continuous.current.active ? continuous.current.refreshRate : null);\n\n // Helpers\n const checkIfFull = (progress: number) => {\n if (progress >= 100) {\n setLoaderStyle({\n ...loaderStyle,\n width: \"100%\"\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n setLoaderStyle({\n ...loaderStyle,\n opacity: 0,\n width: \"100%\",\n transition: `all ${transitionTime}ms ease-out`,\n color: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\")\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n // Handle continuous start\n if (continuous.current.active) {\n\n continuous.current = {\n ...continuous.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n // Handle static start\n if (staticStart.current.active) {\n\n staticStart.current = {\n ...staticStart.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n checkIfFull(0);\n }, transitionTime);\n }, waitingTime);\n } else {\n setLoaderStyle((prev) => (\n {\n ...prev,\n width: `${progress}%`,\n opacity: 1,\n transition: `all ${transitionTime}ms ease-out`,\n }\n ));\n }\n };\n\n // Handle mount\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n }\n }, []);\n\n return (\n <div style={containerStyles} className={containerClassName} >\n <div style={loaderStyle} className={className} > </div>\n {shadow && <div style={{ ...baseStyles.shadow, ...shadowStyle }} />}\n </div>\n );\n }\n);\n\nexport default LoadingBar;","import { useEffect, useRef } from \"react\";\n\nexport const useInterval = (\n callback: () => void,\n delay: number | null,\n immediate?: boolean\n) => {\n const savedCallback = useRef(() => { });\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (immediate && delay !== null) {\n savedCallback.current();\n }\n }, [immediate, delay]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(savedCallback.current, delay);\n return () => clearInterval(id);\n }, [delay]);\n};","const randomValue = (min: number, max: number): number => (Math.random() * (max - min + 1) + min);\n\nexport const randomInt = (min: number, max: number): number => Math.floor(randomValue(min, max));"],"names":["isGradient","color","Array","isArray","length","join","isValidHex","test","baseStyles","top","left","width","zIndex","height","position","overflow","transition","transform","boxShadow","LoadingBar","forwardRef","_ref","ref","callback","delay","savedCallback","progress","_ref$color","_ref$background","background","_ref$shadow","shadow","_ref$height","onLoaderFinished","_ref$transitionTime","transitionTime","_ref$waitingTime","waitingTime","_ref$className","className","_ref$containerClassNa","containerClassName","_ref$style","style","_ref$containerStyle","containerStyle","_ref$shadowStyle","shadowStyle","_useState","useState","localProgress","setLocalProgress","_useState2","usingProps","setUsingProps","_useState3","isComplete","setIsComplete","_useState4","_extends","loaderStyle","setLoaderStyle","containerStyles","isMounted","useRef","continuous","active","refreshRate","staticStart","value","useImperativeHandle","continuousStart","startingValue","current","checkIfFull","complete","getProgress","useEffect","undefined","timeoutId","setTimeout","clearTimeout","increment","Math","floor","random","prev","min","immediate","id","setInterval","clearInterval","opacity","React"],"mappings":"mUAAaA,EAAa,SAACC,GACvB,SAAIC,MAAMC,QAAQF,IAAUA,EAAMG,OAAS,iCACHH,EAAMI,KAAK,WAK1CC,EAAa,SAACL,8CAAiEM,KAAKN,ICP3FO,EACS,CACPC,IAAK,EACLC,KAAM,EACNC,MAAO,OACPC,OAAQ,KACRC,OAAQ,OACRC,SAAU,QACVC,SAAU,UARZP,EAUM,CAC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,WACN,GAAc,OAAVrD,EAAJ,CACA,IAAMiE,EAAKC,YAAYjE,EAAcgD,QAASjD,GAC9C,yBAAamE,cAAcF,MAC5B,CAACjE,IDwGA,IAAMkD,GAAc,SAAChD,GACbA,GAAY,KACZmC,EAAcF,KACPC,GACHjD,MAAO,UAGXqE,WAAW,WACFjB,IAELF,EAAcF,KACPC,GACHgC,QAAS,EACTjF,MAAO,OACPK,kBAAmBmB,gBACnBlC,MAAOD,EAAWC,KAAWK,EAAWL,GAAoBA,EAAmB,aAGnF+E,WAAW,WACFjB,IAGDE,GAAWQ,QAAQP,SAEnBD,GAAWQ,QAAOd,KACXM,GAAWQ,SACdP,QAAQ,IAGZf,EAAiB,GACjBuB,GAAY,IAIZN,GAAYK,QAAQP,SAEpBE,GAAYK,QAAOd,KACZS,GAAYK,SACfP,QAAQ,IAGZf,EAAiB,GACjBuB,GAAY,IAGZzC,GAAkBA,IACtBkB,EAAiB,GACjBuB,GAAY,KACbvC,KACJE,IAEHwB,EAAe,SAACyB,UAAI3B,KAET2B,GACH3E,MAAUe,MACVkE,QAAS,EACT5E,kBAAmBmB,qBAcnC,OAPA0C,EAAU,WAEN,OADAd,EAAUU,SAAU,aAEhBV,EAAUU,SAAU,IAEzB,IAGCoB,uBAAKlD,MAAOmB,EAAiBvB,UAAWE,GACpCoD,uBAAKlD,MAAOiB,EAAarB,UAAWA,QACnCR,GAAU8D,uBAAKlD,MAAKgB,KAAOnD,EAAsBuC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.com.module.js","sources":["../src/utils/colorUtils.ts","../src/styles/styles.ts","../src/components/LoadingBar.tsx","../src/hooks/useInterval.ts","../src/utils/randomUtils.ts"],"sourcesContent":["export const isGradient = (color: string | string[]): string | false => {\n if (Array.isArray(color) && color.length > 1) {\n return `linear-gradient(to right, ${color.join(\", \")})`;\n }\n return false;\n};\n\nexport const isValidHex = (color: string): boolean => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));","const baseStyles: Record<string, React.CSSProperties> = {\n container: {\n top: 0,\n left: 0,\n width: \"100%\",\n zIndex: 9800,\n height: \"100%\",\n position: \"fixed\",\n overflow: \"hidden\",\n },\n loader: {\n width: \"0%\",\n height: \"100%\",\n transition: \"all 0.3s ease\",\n },\n shadow: {\n left: \"-10rem\",\n height: \"100%\",\n position: \"absolute\",\n transition: \"all 0.3s ease\",\n transform: \"rotate(3deg) translate(0, -4px)\",\n boxShadow: \"0 0 10px var(--color), 0 0 5px var(--color)\",\n }\n};\n\nexport default baseStyles;","import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from \"react\";\n\n// Hooks\nimport { useInterval } from \"../hooks/useInterval\";\n\n// Utils\nimport { randomInt } from \"../utils/randomUtils\";\nimport { isGradient, isValidHex } from \"../utils/colorUtils\";\n\n// Styles\nimport baseStyles from \"../styles/styles\";\n\n// Types\nimport type { LoadingBarRef, LoadingBarProps } from \"../../types\";\n\nconst LoadingBar = forwardRef<LoadingBarRef, LoadingBarProps>(\n (\n {\n progress,\n color = \"purple\",\n background = \"transparent\",\n shadow = true,\n height = 2,\n onLoaderFinished,\n transitionTime = 300,\n waitingTime = 1000,\n className = \"\",\n containerClassName = \"\",\n style = {},\n containerStyle = {},\n shadowStyle = {},\n },\n ref\n ) => {\n // States\n const [localProgress, setLocalProgress] = useState<number>(0);\n const [usingProps, setUsingProps] = useState<boolean>(false);\n const [isComplete, setIsComplete] = useState<boolean>(false);\n\n // Style states\n const [loaderStyle, setLoaderStyle] = useState<React.CSSProperties>({\n ...baseStyles.loader,\n height,\n width: `${localProgress}%`,\n transition: `all ${transitionTime}ms ease-out`,\n background: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\"),\n ...style,\n });\n\n const [containerStyles, setContainerStyles] = useState<React.CSSProperties>({\n ...baseStyles.container,\n height,\n background,\n ...containerStyle,\n })\n\n // Refs\n const isMounted = useRef<boolean>(false);\n\n const continuous = useRef<{ active: boolean; refreshRate: number }>({\n active: false,\n refreshRate: 1000,\n });\n const staticStart = useRef<{ active: boolean; value: number }>({\n active: false,\n value: 0,\n });\n\n useImperativeHandle(ref, () => ({\n continuousStart(startingValue = 10, refreshRate = 1000) {\n if (usingProps) return;\n continuous.current = { active: true, refreshRate };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n staticStart(startingValue = 30) {\n if (usingProps) return;\n staticStart.current = { active: true, value: startingValue };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n complete() {\n if (usingProps) return;\n setLocalProgress(100);\n checkIfFull(100);\n setIsComplete(true);\n continuous.current.active = false;\n staticStart.current.active = false;\n },\n getProgress() {\n return localProgress;\n },\n }));\n\n useEffect(() => {\n if (progress !== undefined) {\n setUsingProps(true);\n setLocalProgress(progress);\n }\n }, [progress]);\n\n useEffect(() => {\n if (isComplete && localProgress >= 100) {\n const timeoutId = setTimeout(() => {\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n setIsComplete(false);\n }, waitingTime);\n\n return () => clearTimeout(timeoutId);\n }\n }, [isComplete, localProgress, waitingTime, onLoaderFinished]);\n\n useInterval(() => {\n if (continuous.current.active && !isComplete) {\n const increment = randomInt(1, 10);\n setLocalProgress((prev) => Math.min(prev + increment, 100));\n if (localProgress + increment >= 100) {\n continuous.current.active = false;\n setIsComplete(true);\n }\n }\n }, continuous.current.active ? continuous.current.refreshRate : null);\n\n // Helpers\n const checkIfFull = (progress: number) => {\n if (progress >= 100) {\n setLoaderStyle({\n ...loaderStyle,\n width: \"100%\"\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n setLoaderStyle({\n ...loaderStyle,\n opacity: 0,\n width: \"100%\",\n transition: `all ${transitionTime}ms ease-out`,\n color: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\")\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n // Handle continuous start\n if (continuous.current.active) {\n\n continuous.current = {\n ...continuous.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n // Handle static start\n if (staticStart.current.active) {\n\n staticStart.current = {\n ...staticStart.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n checkIfFull(0);\n }, transitionTime);\n }, waitingTime);\n } else {\n setLoaderStyle((prev) => (\n {\n ...prev,\n width: `${progress}%`,\n opacity: 1,\n transition: `all ${transitionTime}ms ease-out`,\n }\n ));\n }\n };\n\n // Handle mount\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n }\n }, []);\n\n return (\n <div style={containerStyles} className={containerClassName} >\n <div style={loaderStyle} className={className} > </div>\n {shadow && <div style={{ ...baseStyles.shadow, ...shadowStyle }} />}\n </div>\n );\n }\n);\n\nexport default LoadingBar;","import { useEffect, useRef } from \"react\";\n\nexport const useInterval = (\n callback: () => void,\n delay: number | null,\n immediate?: boolean\n) => {\n const savedCallback = useRef(() => { });\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (immediate && delay !== null) {\n savedCallback.current();\n }\n }, [immediate, delay]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(savedCallback.current, delay);\n return () => clearInterval(id);\n }, [delay]);\n};","const randomValue = (min: number, max: number): number => (Math.random() * (max - min + 1) + min);\n\nexport const randomInt = (min: number, max: number): number => Math.floor(randomValue(min, max));"],"names":["isGradient","color","Array","isArray","length","join","isValidHex","test","baseStyles","top","left","width","zIndex","height","position","overflow","transition","transform","boxShadow","LoadingBar","forwardRef","_ref","ref","callback","delay","savedCallback","progress","_ref$color","_ref$background","background","_ref$shadow","shadow","_ref$height","onLoaderFinished","_ref$transitionTime","transitionTime","_ref$waitingTime","waitingTime","_ref$className","className","_ref$containerClassNa","containerClassName","_ref$style","style","_ref$containerStyle","containerStyle","_ref$shadowStyle","shadowStyle","_useState","useState","localProgress","setLocalProgress","_useState2","usingProps","setUsingProps","_useState3","isComplete","setIsComplete","_useState4","_extends","loaderStyle","setLoaderStyle","containerStyles","isMounted","useRef","continuous","active","refreshRate","staticStart","value","useImperativeHandle","continuousStart","startingValue","current","checkIfFull","complete","getProgress","useEffect","undefined","timeoutId","setTimeout","clearTimeout","increment","Math","floor","random","prev","min","immediate","id","setInterval","clearInterval","opacity","React"],"mappings":"mUAAaA,EAAa,SAACC,GACvB,SAAIC,MAAMC,QAAQF,IAAUA,EAAMG,OAAS,iCACHH,EAAMI,KAAK,WAK1CC,EAAa,SAACL,8CAAiEM,KAAKN,ICP3FO,EACS,CACPC,IAAK,EACLC,KAAM,EACNC,MAAO,OACPC,OAAQ,KACRC,OAAQ,OACRC,SAAU,QACVC,SAAU,UARZP,EAUM,CACJG,MAAO,KACPE,OAAQ,OACRG,WAAY,iBAbdR,EAeM,CACJE,KAAM,SACNG,OAAQ,OACRC,SAAU,WACVE,WAAY,gBACZC,UAAW,kCACXC,UAAW,+CCNbC,EAAaC,EACf,SAAAC,EAgBIC,OC7BJC,EACAC,EAGMC,EDWEC,EAAQL,EAARK,SAAQC,EAAAN,EACRpB,MAAAA,WAAK0B,EAAG,SAAQA,EAAAC,EAAAP,EAChBQ,WAAAA,WAAUD,EAAG,cAAaA,EAAAE,EAAAT,EAC1BU,OAAAA,WAAMD,GAAOA,EAAAE,EAAAX,EACbR,OAAAA,WAAMmB,EAAG,EAACA,EACVC,EAAgBZ,EAAhBY,iBAAgBC,EAAAb,EAChBc,eAAAA,WAAcD,EAAG,IAAGA,EAAAE,EAAAf,EACpBgB,YAAAA,WAAWD,EAAG,IAAIA,EAAAE,EAAAjB,EAClBkB,UAAAA,WAASD,EAAG,GAAEA,EAAAE,EAAAnB,EACdoB,mBAAAA,WAAkBD,EAAG,GAAEA,EAAAE,EAAArB,EACvBsB,MAAAA,WAAKD,EAAG,GAAEA,EAAAE,EAAAvB,EACVwB,eAAAA,WAAcD,EAAG,GAAEA,EAAAE,EAAAzB,EACnB0B,YAAAA,WAAWD,EA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IAGCoB,uBAAKlD,MAAOmB,EAAiBvB,UAAWE,GACpCoD,uBAAKlD,MAAOiB,EAAarB,UAAWA,QACnCR,GAAU8D,uBAAKlD,MAAKgB,KAAOnD,EAAsBuC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.com.umd.js","sources":["../src/utils/colorUtils.ts","../src/styles/styles.ts","../src/components/LoadingBar.tsx","../src/hooks/useInterval.ts","../src/utils/randomUtils.ts"],"sourcesContent":["export const isGradient = (color: string | string[]): string | false => {\n if (Array.isArray(color) && color.length > 1) {\n return `linear-gradient(to right, ${color.join(\", \")})`;\n }\n return false;\n};\n\nexport const isValidHex = (color: string): boolean => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));","const baseStyles: Record<string, React.CSSProperties> = {\n container: {\n top: 0,\n left: 0,\n width: \"100%\",\n zIndex: 9800,\n height: \"100%\",\n position: \"fixed\",\n overflow: \"hidden\",\n },\n loader: {\n width: \"0%\",\n height: \"100%\",\n transition: \"all 0.3s ease\",\n },\n shadow: {\n left: \"-10rem\",\n height: \"100%\",\n position: \"absolute\",\n transition: \"all 0.3s ease\",\n transform: \"rotate(3deg) translate(0, -4px)\",\n boxShadow: \"0 0 10px var(--color), 0 0 5px var(--color)\",\n }\n};\n\nexport default baseStyles;","import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from \"react\";\n\n// Hooks\nimport { useInterval } from \"../hooks/useInterval\";\n\n// Utils\nimport { randomInt } from \"../utils/randomUtils\";\nimport { isGradient, isValidHex } from \"../utils/colorUtils\";\n\n// Styles\nimport baseStyles from \"../styles/styles\";\n\n// Types\nimport type { LoadingBarRef, LoadingBarProps } from \"../../types\";\n\nconst LoadingBar = forwardRef<LoadingBarRef, LoadingBarProps>(\n (\n {\n progress,\n color = \"purple\",\n background = \"transparent\",\n shadow = true,\n height = 2,\n onLoaderFinished,\n transitionTime = 300,\n waitingTime = 1000,\n className = \"\",\n containerClassName = \"\",\n style = {},\n containerStyle = {},\n shadowStyle = {},\n },\n ref\n ) => {\n // States\n const [localProgress, setLocalProgress] = useState<number>(0);\n const [usingProps, setUsingProps] = useState<boolean>(false);\n const [isComplete, setIsComplete] = useState<boolean>(false);\n\n // Style states\n const [loaderStyle, setLoaderStyle] = useState<React.CSSProperties>({\n ...baseStyles.loader,\n height,\n width: `${localProgress}%`,\n transition: `all ${transitionTime}ms ease-out`,\n background: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\"),\n ...style,\n });\n\n const [containerStyles, setContainerStyles] = useState<React.CSSProperties>({\n ...baseStyles.container,\n height,\n background,\n ...containerStyle,\n })\n\n // Refs\n const isMounted = useRef<boolean>(false);\n\n const continuous = useRef<{ active: boolean; refreshRate: number }>({\n active: false,\n refreshRate: 1000,\n });\n const staticStart = useRef<{ active: boolean; value: number }>({\n active: false,\n value: 0,\n });\n\n useImperativeHandle(ref, () => ({\n continuousStart(startingValue = 10, refreshRate = 1000) {\n if (usingProps) return;\n continuous.current = { active: true, refreshRate };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n staticStart(startingValue = 30) {\n if (usingProps) return;\n staticStart.current = { active: true, value: startingValue };\n setLocalProgress(startingValue);\n checkIfFull(startingValue);\n setIsComplete(false);\n },\n complete() {\n if (usingProps) return;\n setLocalProgress(100);\n checkIfFull(100);\n setIsComplete(true);\n continuous.current.active = false;\n staticStart.current.active = false;\n },\n getProgress() {\n return localProgress;\n },\n }));\n\n useEffect(() => {\n if (progress !== undefined) {\n setUsingProps(true);\n setLocalProgress(progress);\n }\n }, [progress]);\n\n useEffect(() => {\n if (isComplete && localProgress >= 100) {\n const timeoutId = setTimeout(() => {\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n setIsComplete(false);\n }, waitingTime);\n\n return () => clearTimeout(timeoutId);\n }\n }, [isComplete, localProgress, waitingTime, onLoaderFinished]);\n\n useInterval(() => {\n if (continuous.current.active && !isComplete) {\n const increment = randomInt(1, 10);\n setLocalProgress((prev) => Math.min(prev + increment, 100));\n if (localProgress + increment >= 100) {\n continuous.current.active = false;\n setIsComplete(true);\n }\n }\n }, continuous.current.active ? continuous.current.refreshRate : null);\n\n // Helpers\n const checkIfFull = (progress: number) => {\n if (progress >= 100) {\n setLoaderStyle({\n ...loaderStyle,\n width: \"100%\"\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n setLoaderStyle({\n ...loaderStyle,\n opacity: 0,\n width: \"100%\",\n transition: `all ${transitionTime}ms ease-out`,\n color: isGradient(color) || (isValidHex(color as string) ? (color as string) : \"purple\")\n });\n\n setTimeout(() => {\n if (!isMounted) return;\n\n // Handle continuous start\n if (continuous.current.active) {\n\n continuous.current = {\n ...continuous.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n // Handle static start\n if (staticStart.current.active) {\n\n staticStart.current = {\n ...staticStart.current,\n active: false\n };\n\n setLocalProgress(0);\n checkIfFull(0);\n }\n\n if (onLoaderFinished) onLoaderFinished();\n setLocalProgress(0);\n checkIfFull(0);\n }, transitionTime);\n }, waitingTime);\n } else {\n setLoaderStyle((prev) => (\n {\n ...prev,\n width: `${progress}%`,\n opacity: 1,\n transition: `all ${transitionTime}ms ease-out`,\n }\n ));\n }\n };\n\n // Handle mount\n useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n }\n }, []);\n\n return (\n <div style={containerStyles} className={containerClassName} >\n <div style={loaderStyle} className={className} > </div>\n {shadow && <div style={{ ...baseStyles.shadow, ...shadowStyle }} />}\n </div>\n );\n }\n);\n\nexport default LoadingBar;","import { useEffect, useRef } from \"react\";\n\nexport const useInterval = (\n callback: () => void,\n delay: number | null,\n immediate?: boolean\n) => {\n const savedCallback = useRef(() => { });\n\n useEffect(() => {\n savedCallback.current = callback;\n });\n\n useEffect(() => {\n if (immediate && delay !== null) {\n savedCallback.current();\n }\n }, [immediate, delay]);\n\n useEffect(() => {\n if (delay === null) return;\n const id = setInterval(savedCallback.current, delay);\n return () => clearInterval(id);\n }, [delay]);\n};","const randomValue = (min: number, max: number): number => (Math.random() * (max - min + 1) + min);\n\nexport const randomInt = (min: number, max: number): number => Math.floor(randomValue(min, max));"],"names":["isGradient","color","Array","isArray","length","join","isValidHex","test","baseStyles","top","left","width","zIndex","height","position","overflow","transition","transform","boxShadow","forwardRef","_ref","ref","callback","delay","savedCallback","progress","_ref$color","_ref$background","background","_ref$shadow","shadow","_ref$height","onLoaderFinished","_ref$transitionTime","transitionTime","_ref$waitingTime","waitingTime","_ref$className","className","_ref$containerClassNa","containerClassName","_ref$style","style","_ref$containerStyle","containerStyle","_ref$shadowStyle","shadowStyle","_useState","useState","localProgress","setLocalProgress","_useState2","usingProps","setUsingProps","_useState3","isComplete","setIsComplete","_useState4","_extends","loaderStyle","setLoaderStyle","containerStyles","isMounted","useRef","continuous","active","refreshRate","staticStart","value","useImperativeHandle","continuousStart","startingValue","current","checkIfFull","complete","getProgress","useEffect","undefined","timeoutId","setTimeout","clearTimeout","increment","Math","floor","random","prev","min","immediate","id","setInterval","clearInterval","opacity","React"],"mappings":"ydAAaA,EAAa,SAACC,GACvB,SAAIC,MAAMC,QAAQF,IAAUA,EAAMG,OAAS,iCACHH,EAAMI,KAAK,WAK1CC,EAAa,SAACL,8CAAiEM,KAAKN,ICP3FO,EACS,CACPC,IAAK,EACLC,KAAM,EACNC,MAAO,OACPC,OAAQ,KACRC,OAAQ,OACRC,SAAU,QACVC,SAAU,UARZP,EAUM,CACJG,MAAO,KACPE,OAAQ,OACRG,WAAY,iBAbdR,EAeM,CACJE,KAAM,SACNG,OAAQ,OACRC,SAAU,WACVE,WAAY,gBACZC,UAAW,kCACXC,UAAW,sDCNAC,aACf,SAAAC,EAgBIC,OC7BJC,EACAC,EAGMC,EDWEC,EAAQL,EAARK,SAAQC,EAAAN,EACRnB,MAAAA,WAAKyB,EAAG,SAAQA,EAAAC,EAAAP,EAChBQ,WAAAA,WAAUD,EAAG,cAAaA,EAAAE,EAAAT,E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