react-page-loading-bar 1.0.6 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- package/build/components/LoadingBar.d.ts +4 -4
- package/build/hooks/useInterval.d.ts +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -3
- package/build/index.js.map +1 -1
- package/build/index.modern.js +2 -0
- package/build/index.modern.js.map +1 -0
- package/build/index.module.js +2 -0
- package/build/index.module.js.map +1 -0
- package/build/index.umd.js +2 -0
- package/build/index.umd.js.map +1 -0
- package/build/styles/styles.d.ts +3 -2
- package/build/utils/colorUtils.d.ts +2 -2
- package/build/utils/randomUtils.d.ts +1 -1
- package/package.json +2 -2
- package/build/components/LoadingBar.js +0 -162
- package/build/components/LoadingBar.js.map +0 -1
- package/build/hooks/useInterval.js +0 -19
- package/build/hooks/useInterval.js.map +0 -1
- package/build/styles/styles.js +0 -26
- package/build/styles/styles.js.map +0 -1
- package/build/utils/colorUtils.js +0 -8
- package/build/utils/colorUtils.js.map +0 -1
- package/build/utils/randomUtils.js +0 -3
- package/build/utils/randomUtils.js.map +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import type { LoadingBarRef, LoadingBarProps } from "../../types";
|
3
|
-
declare const LoadingBar: React.ForwardRefExoticComponent<LoadingBarProps & React.RefAttributes<LoadingBarRef>>;
|
4
|
-
export default LoadingBar;
|
1
|
+
import React from "react";
|
2
|
+
import type { LoadingBarRef, LoadingBarProps } from "../../types";
|
3
|
+
declare const LoadingBar: React.ForwardRefExoticComponent<LoadingBarProps & React.RefAttributes<LoadingBarRef>>;
|
4
|
+
export default LoadingBar;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const useInterval: (callback: () => void, delay: number | null, immediate?: boolean) => void;
|
1
|
+
export declare const useInterval: (callback: () => void, delay: number | null, immediate?: boolean | undefined) => void;
|
package/build/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import LoadingBar from "./components/LoadingBar";
|
2
|
-
export default LoadingBar;
|
1
|
+
import LoadingBar from "./components/LoadingBar";
|
2
|
+
export default LoadingBar;
|
package/build/index.js
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
//# sourceMappingURL=index.js.map
|
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.js.map
|
package/build/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,eAAe,UAAU,CAAC"}
|
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,GAAOA,EAAAE,EAAAX,EACbR,OAAAA,WAAMmB,EAAG,EAACA,EACVC,EAAgBZ,EAAhBY,iBAAgBC,EAAAb,EA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uB,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"}
|
@@ -0,0 +1,2 @@
|
|
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.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,EDWEC,EAAQL,EAARK,SAAQC,EAAAN,EACRpB,MAAAA,WAAK0B,EAAG,SAAQA,EAAAC,EAAAP,EAChBQ,WAAAA,WAAUD,EAAG,cAAaA,EAAA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AoBA,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"}
|
@@ -0,0 +1,2 @@
|
|
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.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.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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O,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"}
|
@@ -0,0 +1,2 @@
|
|
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.umd.js.map
|
@@ -0,0 +1 @@
|
|
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,CACP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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,GACHhD,MAAO,UAGXoE,WAAW,WACFjB,IAELF,EAAcF,KACPC,GACHgC,QAAS,EACThF,MAAO,OACPK,kBAAmBkB,gBACnBjC,MAAOD,EAAWC,KAAWK,EAAWL,GAAoBA,EAAmB,aAGnF8E,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,GACH1E,MAAUc,MACVkE,QAAS,EACT3E,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/build/styles/styles.d.ts
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/// <reference types="react" />
|
2
|
+
declare const baseStyles: Record<string, React.CSSProperties>;
|
3
|
+
export default baseStyles;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const isGradient: (color: string | string[]) => string | false;
|
2
|
-
export declare const isValidHex: (color: string) => boolean;
|
1
|
+
export declare const isGradient: (color: string | string[]) => string | false;
|
2
|
+
export declare const isValidHex: (color: string) => boolean;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const randomInt: (min: number, max: number) => number;
|
1
|
+
export declare const randomInt: (min: number, max: number) => number;
|
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.8",
|
4
4
|
"description": "A react top loading bar component for page loads",
|
5
5
|
"author": {
|
6
6
|
"name": "SyntaxisCS",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
},
|
9
9
|
"type": "module",
|
10
10
|
"source": "src/index.ts",
|
11
|
-
"main": "./build/index.
|
11
|
+
"main": "./build/index.js",
|
12
12
|
"module": "./build/index.module.js",
|
13
13
|
"exports": {
|
14
14
|
"require": "./dist/index.cjs",
|
@@ -1,162 +0,0 @@
|
|
1
|
-
import React, { useEffect, useState, forwardRef, useRef, useImperativeHandle } from "react";
|
2
|
-
// Hooks
|
3
|
-
import { useInterval } from "../hooks/useInterval";
|
4
|
-
// Utils
|
5
|
-
import { randomInt } from "../utils/randomUtils";
|
6
|
-
import { isGradient, isValidHex } from "../utils/colorUtils";
|
7
|
-
// Styles
|
8
|
-
import baseStyles from "../styles/styles";
|
9
|
-
const LoadingBar = forwardRef(({ progress, color = "purple", background = "transparent", shadow = true, height = 2, onLoaderFinished, transitionTime = 300, waitingTime = 1000, className = "", containerClassName = "", style = {}, containerStyle = {}, shadowStyle = {}, }, ref) => {
|
10
|
-
// States
|
11
|
-
const [localProgress, setLocalProgress] = useState(0);
|
12
|
-
const [usingProps, setUsingProps] = useState(false);
|
13
|
-
const [isComplete, setIsComplete] = useState(false);
|
14
|
-
// Style states
|
15
|
-
const [loaderStyle, setLoaderStyle] = useState({
|
16
|
-
...baseStyles.loader,
|
17
|
-
height,
|
18
|
-
width: `${localProgress}%`,
|
19
|
-
transition: `all ${transitionTime}ms ease-out`,
|
20
|
-
background: isGradient(color) || (isValidHex(color) ? color : "purple"),
|
21
|
-
...style,
|
22
|
-
});
|
23
|
-
const [containerStyles, setContainerStyles] = useState({
|
24
|
-
...baseStyles.container,
|
25
|
-
height,
|
26
|
-
background,
|
27
|
-
...containerStyle,
|
28
|
-
});
|
29
|
-
// Refs
|
30
|
-
const isMounted = useRef(false);
|
31
|
-
const continuous = useRef({
|
32
|
-
active: false,
|
33
|
-
refreshRate: 1000,
|
34
|
-
});
|
35
|
-
const staticStart = useRef({
|
36
|
-
active: false,
|
37
|
-
value: 0,
|
38
|
-
});
|
39
|
-
useImperativeHandle(ref, () => ({
|
40
|
-
continuousStart(startingValue = 10, refreshRate = 1000) {
|
41
|
-
if (usingProps)
|
42
|
-
return;
|
43
|
-
continuous.current = { active: true, refreshRate };
|
44
|
-
setLocalProgress(startingValue);
|
45
|
-
checkIfFull(startingValue);
|
46
|
-
setIsComplete(false);
|
47
|
-
},
|
48
|
-
staticStart(startingValue = 30) {
|
49
|
-
if (usingProps)
|
50
|
-
return;
|
51
|
-
staticStart.current = { active: true, value: startingValue };
|
52
|
-
setLocalProgress(startingValue);
|
53
|
-
checkIfFull(startingValue);
|
54
|
-
setIsComplete(false);
|
55
|
-
},
|
56
|
-
complete() {
|
57
|
-
if (usingProps)
|
58
|
-
return;
|
59
|
-
setLocalProgress(100);
|
60
|
-
checkIfFull(100);
|
61
|
-
setIsComplete(true);
|
62
|
-
continuous.current.active = false;
|
63
|
-
staticStart.current.active = false;
|
64
|
-
},
|
65
|
-
getProgress() {
|
66
|
-
return localProgress;
|
67
|
-
},
|
68
|
-
}));
|
69
|
-
useEffect(() => {
|
70
|
-
if (progress !== undefined) {
|
71
|
-
setUsingProps(true);
|
72
|
-
setLocalProgress(progress);
|
73
|
-
}
|
74
|
-
}, [progress]);
|
75
|
-
useEffect(() => {
|
76
|
-
if (isComplete && localProgress >= 100) {
|
77
|
-
const timeoutId = setTimeout(() => {
|
78
|
-
if (onLoaderFinished)
|
79
|
-
onLoaderFinished();
|
80
|
-
setLocalProgress(0);
|
81
|
-
setIsComplete(false);
|
82
|
-
}, waitingTime);
|
83
|
-
return () => clearTimeout(timeoutId);
|
84
|
-
}
|
85
|
-
}, [isComplete, localProgress, waitingTime, onLoaderFinished]);
|
86
|
-
useInterval(() => {
|
87
|
-
if (continuous.current.active && !isComplete) {
|
88
|
-
const increment = randomInt(1, 10);
|
89
|
-
setLocalProgress((prev) => Math.min(prev + increment, 100));
|
90
|
-
if (localProgress + increment >= 100) {
|
91
|
-
continuous.current.active = false;
|
92
|
-
setIsComplete(true);
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}, continuous.current.active ? continuous.current.refreshRate : null);
|
96
|
-
// Helpers
|
97
|
-
const checkIfFull = (progress) => {
|
98
|
-
if (progress >= 100) {
|
99
|
-
setLoaderStyle({
|
100
|
-
...loaderStyle,
|
101
|
-
width: "100%"
|
102
|
-
});
|
103
|
-
setTimeout(() => {
|
104
|
-
if (!isMounted)
|
105
|
-
return;
|
106
|
-
setLoaderStyle({
|
107
|
-
...loaderStyle,
|
108
|
-
opacity: 0,
|
109
|
-
width: "100%",
|
110
|
-
transition: `all ${transitionTime}ms ease-out`,
|
111
|
-
color: isGradient(color) || (isValidHex(color) ? color : "purple")
|
112
|
-
});
|
113
|
-
setTimeout(() => {
|
114
|
-
if (!isMounted)
|
115
|
-
return;
|
116
|
-
// Handle continuous start
|
117
|
-
if (continuous.current.active) {
|
118
|
-
continuous.current = {
|
119
|
-
...continuous.current,
|
120
|
-
active: false
|
121
|
-
};
|
122
|
-
setLocalProgress(0);
|
123
|
-
checkIfFull(0);
|
124
|
-
}
|
125
|
-
// Handle static start
|
126
|
-
if (staticStart.current.active) {
|
127
|
-
staticStart.current = {
|
128
|
-
...staticStart.current,
|
129
|
-
active: false
|
130
|
-
};
|
131
|
-
setLocalProgress(0);
|
132
|
-
checkIfFull(0);
|
133
|
-
}
|
134
|
-
if (onLoaderFinished)
|
135
|
-
onLoaderFinished();
|
136
|
-
setLocalProgress(0);
|
137
|
-
checkIfFull(0);
|
138
|
-
}, transitionTime);
|
139
|
-
}, waitingTime);
|
140
|
-
}
|
141
|
-
else {
|
142
|
-
setLoaderStyle((prev) => ({
|
143
|
-
...prev,
|
144
|
-
width: `${progress}%`,
|
145
|
-
opacity: 1,
|
146
|
-
transition: `all ${transitionTime}ms ease-out`,
|
147
|
-
}));
|
148
|
-
}
|
149
|
-
};
|
150
|
-
// Handle mount
|
151
|
-
useEffect(() => {
|
152
|
-
isMounted.current = true;
|
153
|
-
return () => {
|
154
|
-
isMounted.current = false;
|
155
|
-
};
|
156
|
-
}, []);
|
157
|
-
return (React.createElement("div", { style: containerStyles, className: containerClassName },
|
158
|
-
React.createElement("div", { style: loaderStyle, className: className }, " "),
|
159
|
-
shadow && React.createElement("div", { style: { ...baseStyles.shadow, ...shadowStyle } })));
|
160
|
-
});
|
161
|
-
export default LoadingBar;
|
162
|
-
//# sourceMappingURL=LoadingBar.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"LoadingBar.js","sourceRoot":"","sources":["../../src/components/LoadingBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE5F,QAAQ;AACR,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,QAAQ;AACR,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,SAAS;AACT,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAK1C,MAAM,UAAU,GAAG,UAAU,CACzB,CACI,EACI,QAAQ,EACR,KAAK,GAAG,QAAQ,EAChB,UAAU,GAAG,aAAa,EAC1B,MAAM,GAAG,IAAI,EACb,MAAM,GAAG,CAAC,EACV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AAQ,GAAG;gBACrB,OAAO,EAAE,CAAC;gBACV,UAAU,EAAE,OAAO,cAAc,aAAa;aACjD,CACJ,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC;IAEF,eAAe;IACf,SAAS,CAAC,GAAG,EAAE;QACX,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;QACzB,OAAO,GAAG,EAAE;YACR,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;QAC9B,CAAC,CAAA;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACH,6BAAK,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,kBAAkB;QACtD,6BAAK,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,QAAU;QACtD,MAAM,IAAI,6BAAK,KAAK,EAAE,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,WAAW,EAAE,GAAI,CACjE,CACT,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { useEffect, useRef } from "react";
|
2
|
-
export const useInterval = (callback, delay, immediate) => {
|
3
|
-
const savedCallback = useRef(() => { });
|
4
|
-
useEffect(() => {
|
5
|
-
savedCallback.current = callback;
|
6
|
-
});
|
7
|
-
useEffect(() => {
|
8
|
-
if (immediate && delay !== null) {
|
9
|
-
savedCallback.current();
|
10
|
-
}
|
11
|
-
}, [immediate, delay]);
|
12
|
-
useEffect(() => {
|
13
|
-
if (delay === null)
|
14
|
-
return;
|
15
|
-
const id = setInterval(savedCallback.current, delay);
|
16
|
-
return () => clearInterval(id);
|
17
|
-
}, [delay]);
|
18
|
-
};
|
19
|
-
//# sourceMappingURL=useInterval.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useInterval.js","sourceRoot":"","sources":["../../src/hooks/useInterval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,QAAoB,EACpB,KAAoB,EACpB,SAAmB,EACrB,EAAE;IACA,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACX,aAAa,CAAC,OAAO,GAAG,QAAQ,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC9B,aAAa,CAAC,OAAO,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAC3B,MAAM,EAAE,GAAG,WAAW,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC"}
|
package/build/styles/styles.js
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
const baseStyles = {
|
2
|
-
container: {
|
3
|
-
top: 0,
|
4
|
-
left: 0,
|
5
|
-
width: "100%",
|
6
|
-
zIndex: 9800,
|
7
|
-
height: "100%",
|
8
|
-
position: "fixed",
|
9
|
-
overflow: "hidden",
|
10
|
-
},
|
11
|
-
loader: {
|
12
|
-
width: "0%",
|
13
|
-
height: "100%",
|
14
|
-
transition: "all 0.3s ease",
|
15
|
-
},
|
16
|
-
shadow: {
|
17
|
-
left: "-10rem",
|
18
|
-
height: "100%",
|
19
|
-
position: "absolute",
|
20
|
-
transition: "all 0.3s ease",
|
21
|
-
transform: "rotate(3deg) translate(0, -4px)",
|
22
|
-
boxShadow: "0 0 10px var(--color), 0 0 5px var(--color)",
|
23
|
-
}
|
24
|
-
};
|
25
|
-
export default baseStyles;
|
26
|
-
//# sourceMappingURL=styles.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/styles/styles.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAwC;IACpD,SAAS,EAAE;QACP,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,QAAQ;KACrB;IACD,MAAM,EAAE;QACJ,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,eAAe;KAC9B;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,UAAU;QACpB,UAAU,EAAE,eAAe;QAC3B,SAAS,EAAE,iCAAiC;QAC5C,SAAS,EAAE,6CAA6C;KAC3D;CACJ,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
export const isGradient = (color) => {
|
2
|
-
if (Array.isArray(color) && color.length > 1) {
|
3
|
-
return `linear-gradient(to right, ${color.join(", ")})`;
|
4
|
-
}
|
5
|
-
return false;
|
6
|
-
};
|
7
|
-
export const isValidHex = (color) => (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color));
|
8
|
-
//# sourceMappingURL=colorUtils.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"colorUtils.js","sourceRoot":"","sources":["../../src/utils/colorUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAwB,EAAkB,EAAE;IACnE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO,6BAA6B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,CAAC,oCAAoC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"randomUtils.js","sourceRoot":"","sources":["../../src/utils/randomUtils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,GAAW,EAAU,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AAElG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,GAAW,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC"}
|