premium-react-loaders 3.1.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/dist/components/gradient/GradientBar.d.ts +13 -0
- package/dist/components/gradient/GradientBar.d.ts.map +1 -0
- package/dist/components/gradient/GradientRing.d.ts +12 -0
- package/dist/components/gradient/GradientRing.d.ts.map +1 -0
- package/dist/components/gradient/GradientSpinner.d.ts +12 -0
- package/dist/components/gradient/GradientSpinner.d.ts.map +1 -0
- package/dist/components/gradient/index.d.ts +4 -0
- package/dist/components/gradient/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/morph/LiquidFill.d.ts +13 -0
- package/dist/components/morph/LiquidFill.d.ts.map +1 -0
- package/dist/components/morph/MorphBlob.d.ts +12 -0
- package/dist/components/morph/MorphBlob.d.ts.map +1 -0
- package/dist/components/morph/WaveCircle.d.ts +12 -0
- package/dist/components/morph/WaveCircle.d.ts.map +1 -0
- package/dist/components/morph/index.d.ts +4 -0
- package/dist/components/morph/index.d.ts.map +1 -0
- package/dist/components/particle/ParticleBurst.d.ts +12 -0
- package/dist/components/particle/ParticleBurst.d.ts.map +1 -0
- package/dist/components/particle/ParticleOrbit.d.ts +12 -0
- package/dist/components/particle/ParticleOrbit.d.ts.map +1 -0
- package/dist/components/particle/index.d.ts +3 -0
- package/dist/components/particle/index.d.ts.map +1 -0
- package/dist/components/progress/ProgressBar.d.ts.map +1 -1
- package/dist/components/progress/ProgressCircle.d.ts.map +1 -1
- package/dist/components/progress/ProgressRing.d.ts.map +1 -1
- package/dist/index.cjs +17 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -1
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +1 -1
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +1 -1
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +1 -1
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +1 -1
- package/dist/index25.cjs +17 -2
- package/dist/index25.js +18 -3
- package/dist/index26.cjs +17 -2
- package/dist/index26.js +18 -3
- package/dist/index27.cjs +17 -2
- package/dist/index27.js +18 -3
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +1 -1
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +1 -1
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +1 -1
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +1 -1
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +1 -1
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +1 -1
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +1 -1
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +1 -1
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +1 -1
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +1 -1
- package/dist/index4.cjs +10 -0
- package/dist/index4.js +10 -0
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +1 -1
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +1 -1
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +1 -1
- package/dist/index43.cjs +1 -1
- package/dist/index43.js +1 -1
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +1 -1
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +1 -1
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +1 -1
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +1 -1
- package/dist/index48.cjs +1 -1
- package/dist/index48.js +1 -1
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +1 -1
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +1 -1
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +1 -1
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +1 -1
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +1 -1
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +1 -1
- package/dist/index56.cjs +50 -120
- package/dist/index56.js +51 -121
- package/dist/index57.cjs +119 -0
- package/dist/index57.js +119 -0
- package/dist/index58.cjs +70 -0
- package/dist/index58.js +70 -0
- package/dist/index59.cjs +66 -0
- package/dist/index59.js +66 -0
- package/dist/index60.cjs +68 -0
- package/dist/index60.js +68 -0
- package/dist/index61.cjs +99 -0
- package/dist/index61.js +99 -0
- package/dist/index62.cjs +75 -0
- package/dist/index62.js +75 -0
- package/dist/index63.cjs +92 -0
- package/dist/index63.js +92 -0
- package/dist/index64.cjs +125 -0
- package/dist/index64.js +125 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +1 -1
- package/dist/premium-react-loaders.css +41 -0
- package/dist/types/gradient.d.ts +38 -0
- package/dist/types/gradient.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/morph.d.ts +28 -0
- package/dist/types/morph.d.ts.map +1 -0
- package/dist/types/particle.d.ts +22 -0
- package/dist/types/particle.d.ts.map +1 -0
- package/dist/types/progress.d.ts +6 -0
- package/dist/types/progress.d.ts.map +1 -1
- package/dist/utils/colors.d.ts +5 -0
- package/dist/utils/colors.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index61.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useEffect } from "react";
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index64.js";
|
|
4
|
+
import { normalizeSize } from "./index4.js";
|
|
5
|
+
import { cn } from "./index3.js";
|
|
6
|
+
const GradientBar = forwardRef(
|
|
7
|
+
({
|
|
8
|
+
value,
|
|
9
|
+
width = "100%",
|
|
10
|
+
height = 8,
|
|
11
|
+
color = "#3b82f6",
|
|
12
|
+
secondaryColor = "#8b5cf6",
|
|
13
|
+
onComplete,
|
|
14
|
+
speed = "normal",
|
|
15
|
+
respectMotionPreference = true,
|
|
16
|
+
delay = 0,
|
|
17
|
+
minDuration = 0,
|
|
18
|
+
transition,
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
testId = "gradient-bar",
|
|
22
|
+
visible = true,
|
|
23
|
+
ariaLabel,
|
|
24
|
+
...rest
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const prefersReducedMotion = useReducedMotion();
|
|
27
|
+
const effectiveDuration = getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
28
|
+
const { shouldRender, opacity, transitionStyle } = useLoaderVisibility(visible, delay, minDuration, transition);
|
|
29
|
+
const onCompleteRef = useRef(onComplete);
|
|
30
|
+
onCompleteRef.current = onComplete;
|
|
31
|
+
const hasCompletedRef = useRef(false);
|
|
32
|
+
const isIndeterminate = value === void 0;
|
|
33
|
+
const clampedValue = isIndeterminate ? 0 : Math.min(100, Math.max(0, value));
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (clampedValue < 100) {
|
|
36
|
+
hasCompletedRef.current = false;
|
|
37
|
+
}
|
|
38
|
+
}, [clampedValue]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!isIndeterminate && clampedValue === 100 && !hasCompletedRef.current && onCompleteRef.current) {
|
|
41
|
+
hasCompletedRef.current = true;
|
|
42
|
+
onCompleteRef.current();
|
|
43
|
+
}
|
|
44
|
+
}, [clampedValue, isIndeterminate]);
|
|
45
|
+
if (!shouldRender) return null;
|
|
46
|
+
const gradient = `linear-gradient(90deg, ${color}, ${secondaryColor}, ${color})`;
|
|
47
|
+
const progressLabel = ariaLabel || (isIndeterminate ? "Loading..." : `Loading ${clampedValue}%`);
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
ref,
|
|
52
|
+
"data-testid": testId,
|
|
53
|
+
className: cn("relative overflow-hidden rounded-full", className),
|
|
54
|
+
style: {
|
|
55
|
+
width: normalizeSize(width),
|
|
56
|
+
height,
|
|
57
|
+
backgroundColor: `${color}20`,
|
|
58
|
+
opacity,
|
|
59
|
+
transition: transitionStyle,
|
|
60
|
+
...style
|
|
61
|
+
},
|
|
62
|
+
role: "progressbar",
|
|
63
|
+
"aria-label": progressLabel,
|
|
64
|
+
"aria-valuenow": isIndeterminate ? void 0 : clampedValue,
|
|
65
|
+
"aria-valuemin": 0,
|
|
66
|
+
"aria-valuemax": 100,
|
|
67
|
+
"aria-busy": "true",
|
|
68
|
+
...rest,
|
|
69
|
+
children: isIndeterminate ? /* @__PURE__ */ jsx(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
className: "absolute h-full rounded-full",
|
|
73
|
+
style: {
|
|
74
|
+
background: gradient,
|
|
75
|
+
backgroundSize: "200% 100%",
|
|
76
|
+
animation: `gradient-flow ${effectiveDuration} linear infinite, progress-indeterminate ${effectiveDuration} ease-in-out infinite`
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
) : /* @__PURE__ */ jsx(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
className: "h-full rounded-full",
|
|
83
|
+
style: {
|
|
84
|
+
width: `${clampedValue}%`,
|
|
85
|
+
background: gradient,
|
|
86
|
+
backgroundSize: "200% 100%",
|
|
87
|
+
animation: `gradient-flow ${effectiveDuration} linear infinite`,
|
|
88
|
+
transition: "width 0.3s ease-in-out"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
GradientBar.displayName = "GradientBar";
|
|
97
|
+
export {
|
|
98
|
+
GradientBar
|
|
99
|
+
};
|
package/dist/index62.cjs
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const hooks = require("./index64.cjs");
|
|
6
|
+
const colors = require("./index4.cjs");
|
|
7
|
+
const classNames = require("./index3.cjs");
|
|
8
|
+
const ParticleBurst = react.forwardRef(
|
|
9
|
+
({
|
|
10
|
+
size = 60,
|
|
11
|
+
count = 8,
|
|
12
|
+
color = "#3b82f6",
|
|
13
|
+
particleSize = 6,
|
|
14
|
+
speed = "normal",
|
|
15
|
+
respectMotionPreference = true,
|
|
16
|
+
delay = 0,
|
|
17
|
+
minDuration = 0,
|
|
18
|
+
transition,
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
testId = "particle-burst",
|
|
22
|
+
visible = true,
|
|
23
|
+
ariaLabel = "Loading...",
|
|
24
|
+
...rest
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const prefersReducedMotion = hooks.useReducedMotion();
|
|
27
|
+
const effectiveDuration = hooks.getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
28
|
+
const { shouldRender, opacity, transitionStyle } = hooks.useLoaderVisibility(visible, delay, minDuration, transition);
|
|
29
|
+
if (!shouldRender) return null;
|
|
30
|
+
const clampedCount = Math.min(20, Math.max(4, count));
|
|
31
|
+
const radius = size / 2;
|
|
32
|
+
const durationMs = colors.parseDurationMs(effectiveDuration);
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
"data-testid": testId,
|
|
38
|
+
className: classNames.cn("relative inline-flex items-center justify-center", className),
|
|
39
|
+
style: { width: size, height: size, opacity, transition: transitionStyle, ...style },
|
|
40
|
+
role: "status",
|
|
41
|
+
"aria-label": ariaLabel,
|
|
42
|
+
"aria-busy": "true",
|
|
43
|
+
...rest,
|
|
44
|
+
children: Array.from({ length: clampedCount }, (_, i) => {
|
|
45
|
+
const angle = i / clampedCount * 2 * Math.PI;
|
|
46
|
+
const tx = Math.cos(angle) * radius;
|
|
47
|
+
const ty = Math.sin(angle) * radius;
|
|
48
|
+
const animationDelay = `${i / clampedCount * durationMs}ms`;
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: "absolute rounded-full",
|
|
53
|
+
style: {
|
|
54
|
+
width: particleSize,
|
|
55
|
+
height: particleSize,
|
|
56
|
+
backgroundColor: color,
|
|
57
|
+
top: "50%",
|
|
58
|
+
left: "50%",
|
|
59
|
+
marginTop: -particleSize / 2,
|
|
60
|
+
marginLeft: -particleSize / 2,
|
|
61
|
+
animation: `particle-burst ${effectiveDuration} ease-out infinite`,
|
|
62
|
+
animationDelay,
|
|
63
|
+
["--tx"]: `${tx}px`,
|
|
64
|
+
["--ty"]: `${ty}px`
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
i
|
|
68
|
+
);
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
ParticleBurst.displayName = "ParticleBurst";
|
|
75
|
+
exports.ParticleBurst = ParticleBurst;
|
package/dist/index62.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index64.js";
|
|
4
|
+
import { parseDurationMs } from "./index4.js";
|
|
5
|
+
import { cn } from "./index3.js";
|
|
6
|
+
const ParticleBurst = forwardRef(
|
|
7
|
+
({
|
|
8
|
+
size = 60,
|
|
9
|
+
count = 8,
|
|
10
|
+
color = "#3b82f6",
|
|
11
|
+
particleSize = 6,
|
|
12
|
+
speed = "normal",
|
|
13
|
+
respectMotionPreference = true,
|
|
14
|
+
delay = 0,
|
|
15
|
+
minDuration = 0,
|
|
16
|
+
transition,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
testId = "particle-burst",
|
|
20
|
+
visible = true,
|
|
21
|
+
ariaLabel = "Loading...",
|
|
22
|
+
...rest
|
|
23
|
+
}, ref) => {
|
|
24
|
+
const prefersReducedMotion = useReducedMotion();
|
|
25
|
+
const effectiveDuration = getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
26
|
+
const { shouldRender, opacity, transitionStyle } = useLoaderVisibility(visible, delay, minDuration, transition);
|
|
27
|
+
if (!shouldRender) return null;
|
|
28
|
+
const clampedCount = Math.min(20, Math.max(4, count));
|
|
29
|
+
const radius = size / 2;
|
|
30
|
+
const durationMs = parseDurationMs(effectiveDuration);
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
ref,
|
|
35
|
+
"data-testid": testId,
|
|
36
|
+
className: cn("relative inline-flex items-center justify-center", className),
|
|
37
|
+
style: { width: size, height: size, opacity, transition: transitionStyle, ...style },
|
|
38
|
+
role: "status",
|
|
39
|
+
"aria-label": ariaLabel,
|
|
40
|
+
"aria-busy": "true",
|
|
41
|
+
...rest,
|
|
42
|
+
children: Array.from({ length: clampedCount }, (_, i) => {
|
|
43
|
+
const angle = i / clampedCount * 2 * Math.PI;
|
|
44
|
+
const tx = Math.cos(angle) * radius;
|
|
45
|
+
const ty = Math.sin(angle) * radius;
|
|
46
|
+
const animationDelay = `${i / clampedCount * durationMs}ms`;
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
className: "absolute rounded-full",
|
|
51
|
+
style: {
|
|
52
|
+
width: particleSize,
|
|
53
|
+
height: particleSize,
|
|
54
|
+
backgroundColor: color,
|
|
55
|
+
top: "50%",
|
|
56
|
+
left: "50%",
|
|
57
|
+
marginTop: -particleSize / 2,
|
|
58
|
+
marginLeft: -particleSize / 2,
|
|
59
|
+
animation: `particle-burst ${effectiveDuration} ease-out infinite`,
|
|
60
|
+
animationDelay,
|
|
61
|
+
["--tx"]: `${tx}px`,
|
|
62
|
+
["--ty"]: `${ty}px`
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
i
|
|
66
|
+
);
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
ParticleBurst.displayName = "ParticleBurst";
|
|
73
|
+
export {
|
|
74
|
+
ParticleBurst
|
|
75
|
+
};
|
package/dist/index63.cjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const hooks = require("./index64.cjs");
|
|
6
|
+
const colors = require("./index4.cjs");
|
|
7
|
+
const classNames = require("./index3.cjs");
|
|
8
|
+
const ParticleOrbit = react.forwardRef(
|
|
9
|
+
({
|
|
10
|
+
size = 80,
|
|
11
|
+
count = 5,
|
|
12
|
+
color = "#3b82f6",
|
|
13
|
+
centerColor,
|
|
14
|
+
speed = "normal",
|
|
15
|
+
respectMotionPreference = true,
|
|
16
|
+
delay = 0,
|
|
17
|
+
minDuration = 0,
|
|
18
|
+
transition,
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
testId = "particle-orbit",
|
|
22
|
+
visible = true,
|
|
23
|
+
ariaLabel = "Loading...",
|
|
24
|
+
...rest
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const prefersReducedMotion = hooks.useReducedMotion();
|
|
27
|
+
const effectiveDuration = hooks.getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
28
|
+
const { shouldRender, opacity, transitionStyle } = hooks.useLoaderVisibility(visible, delay, minDuration, transition);
|
|
29
|
+
if (!shouldRender) return null;
|
|
30
|
+
const clampedCount = Math.min(8, Math.max(3, count));
|
|
31
|
+
const orbitRadius = size * 0.35;
|
|
32
|
+
const particleSize = size * 0.1;
|
|
33
|
+
const centerSize = size * 0.15;
|
|
34
|
+
const dotColor = centerColor || color;
|
|
35
|
+
const durationMs = colors.parseDurationMs(effectiveDuration);
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
ref,
|
|
40
|
+
"data-testid": testId,
|
|
41
|
+
className: classNames.cn("relative inline-flex items-center justify-center", className),
|
|
42
|
+
style: { width: size, height: size, opacity, transition: transitionStyle, ...style },
|
|
43
|
+
role: "status",
|
|
44
|
+
"aria-label": ariaLabel,
|
|
45
|
+
"aria-busy": "true",
|
|
46
|
+
...rest,
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
className: "absolute rounded-full z-10",
|
|
52
|
+
style: {
|
|
53
|
+
width: centerSize,
|
|
54
|
+
height: centerSize,
|
|
55
|
+
backgroundColor: dotColor,
|
|
56
|
+
top: "50%",
|
|
57
|
+
left: "50%",
|
|
58
|
+
transform: "translate(-50%, -50%)"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
Array.from({ length: clampedCount }, (_, i) => {
|
|
63
|
+
const startAngle = `${i / clampedCount * 360}deg`;
|
|
64
|
+
const staggerDelay = `-${i / clampedCount * durationMs}ms`;
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className: "absolute rounded-full",
|
|
69
|
+
style: {
|
|
70
|
+
width: particleSize,
|
|
71
|
+
height: particleSize,
|
|
72
|
+
backgroundColor: color,
|
|
73
|
+
top: "50%",
|
|
74
|
+
left: "50%",
|
|
75
|
+
marginTop: -particleSize / 2,
|
|
76
|
+
marginLeft: -particleSize / 2,
|
|
77
|
+
animation: `particle-orbit ${effectiveDuration} linear infinite`,
|
|
78
|
+
animationDelay: staggerDelay,
|
|
79
|
+
["--start-angle"]: startAngle,
|
|
80
|
+
["--orbit-radius"]: `${orbitRadius}px`
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
i
|
|
84
|
+
);
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
ParticleOrbit.displayName = "ParticleOrbit";
|
|
92
|
+
exports.ParticleOrbit = ParticleOrbit;
|
package/dist/index63.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index64.js";
|
|
4
|
+
import { parseDurationMs } from "./index4.js";
|
|
5
|
+
import { cn } from "./index3.js";
|
|
6
|
+
const ParticleOrbit = forwardRef(
|
|
7
|
+
({
|
|
8
|
+
size = 80,
|
|
9
|
+
count = 5,
|
|
10
|
+
color = "#3b82f6",
|
|
11
|
+
centerColor,
|
|
12
|
+
speed = "normal",
|
|
13
|
+
respectMotionPreference = true,
|
|
14
|
+
delay = 0,
|
|
15
|
+
minDuration = 0,
|
|
16
|
+
transition,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
testId = "particle-orbit",
|
|
20
|
+
visible = true,
|
|
21
|
+
ariaLabel = "Loading...",
|
|
22
|
+
...rest
|
|
23
|
+
}, ref) => {
|
|
24
|
+
const prefersReducedMotion = useReducedMotion();
|
|
25
|
+
const effectiveDuration = getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
26
|
+
const { shouldRender, opacity, transitionStyle } = useLoaderVisibility(visible, delay, minDuration, transition);
|
|
27
|
+
if (!shouldRender) return null;
|
|
28
|
+
const clampedCount = Math.min(8, Math.max(3, count));
|
|
29
|
+
const orbitRadius = size * 0.35;
|
|
30
|
+
const particleSize = size * 0.1;
|
|
31
|
+
const centerSize = size * 0.15;
|
|
32
|
+
const dotColor = centerColor || color;
|
|
33
|
+
const durationMs = parseDurationMs(effectiveDuration);
|
|
34
|
+
return /* @__PURE__ */ jsxs(
|
|
35
|
+
"div",
|
|
36
|
+
{
|
|
37
|
+
ref,
|
|
38
|
+
"data-testid": testId,
|
|
39
|
+
className: cn("relative inline-flex items-center justify-center", className),
|
|
40
|
+
style: { width: size, height: size, opacity, transition: transitionStyle, ...style },
|
|
41
|
+
role: "status",
|
|
42
|
+
"aria-label": ariaLabel,
|
|
43
|
+
"aria-busy": "true",
|
|
44
|
+
...rest,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: "absolute rounded-full z-10",
|
|
50
|
+
style: {
|
|
51
|
+
width: centerSize,
|
|
52
|
+
height: centerSize,
|
|
53
|
+
backgroundColor: dotColor,
|
|
54
|
+
top: "50%",
|
|
55
|
+
left: "50%",
|
|
56
|
+
transform: "translate(-50%, -50%)"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
Array.from({ length: clampedCount }, (_, i) => {
|
|
61
|
+
const startAngle = `${i / clampedCount * 360}deg`;
|
|
62
|
+
const staggerDelay = `-${i / clampedCount * durationMs}ms`;
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
className: "absolute rounded-full",
|
|
67
|
+
style: {
|
|
68
|
+
width: particleSize,
|
|
69
|
+
height: particleSize,
|
|
70
|
+
backgroundColor: color,
|
|
71
|
+
top: "50%",
|
|
72
|
+
left: "50%",
|
|
73
|
+
marginTop: -particleSize / 2,
|
|
74
|
+
marginLeft: -particleSize / 2,
|
|
75
|
+
animation: `particle-orbit ${effectiveDuration} linear infinite`,
|
|
76
|
+
animationDelay: staggerDelay,
|
|
77
|
+
["--start-angle"]: startAngle,
|
|
78
|
+
["--orbit-radius"]: `${orbitRadius}px`
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
i
|
|
82
|
+
);
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
ParticleOrbit.displayName = "ParticleOrbit";
|
|
90
|
+
export {
|
|
91
|
+
ParticleOrbit
|
|
92
|
+
};
|
package/dist/index64.cjs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
function useReducedMotion() {
|
|
5
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = react.useState(false);
|
|
6
|
+
react.useEffect(() => {
|
|
7
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
11
|
+
setPrefersReducedMotion(mediaQuery.matches);
|
|
12
|
+
const handleChange = (event) => {
|
|
13
|
+
setPrefersReducedMotion(event.matches);
|
|
14
|
+
};
|
|
15
|
+
if (mediaQuery.addEventListener) {
|
|
16
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
17
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
18
|
+
} else {
|
|
19
|
+
mediaQuery.addListener(handleChange);
|
|
20
|
+
return () => mediaQuery.removeListener(handleChange);
|
|
21
|
+
}
|
|
22
|
+
}, []);
|
|
23
|
+
return prefersReducedMotion;
|
|
24
|
+
}
|
|
25
|
+
function getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion) {
|
|
26
|
+
if (respectMotionPreference && prefersReducedMotion) {
|
|
27
|
+
return "0.01ms";
|
|
28
|
+
}
|
|
29
|
+
if (typeof speed === "number") {
|
|
30
|
+
const validSpeed = !isNaN(speed) && speed > 0 ? Math.max(50, Math.min(1e4, speed)) : 1e3;
|
|
31
|
+
return `${validSpeed}ms`;
|
|
32
|
+
}
|
|
33
|
+
const speedMap = {
|
|
34
|
+
slow: "2s",
|
|
35
|
+
normal: "1s",
|
|
36
|
+
fast: "0.5s"
|
|
37
|
+
};
|
|
38
|
+
return speedMap[speed] || speedMap.normal;
|
|
39
|
+
}
|
|
40
|
+
function useLoaderVisibility(visible = true, delay = 0, minDuration = 0, transition) {
|
|
41
|
+
const transitionDuration = transition === true ? 150 : typeof transition === "number" ? transition : 0;
|
|
42
|
+
const hasTransition = transitionDuration > 0;
|
|
43
|
+
const [shouldRender, setShouldRender] = react.useState(visible && delay === 0);
|
|
44
|
+
const [isTransitioning, setIsTransitioning] = react.useState(visible && delay === 0 && hasTransition);
|
|
45
|
+
const showTimeRef = react.useRef(visible && delay === 0 ? Date.now() : null);
|
|
46
|
+
const delayTimerRef = react.useRef(null);
|
|
47
|
+
const minDurationTimerRef = react.useRef(null);
|
|
48
|
+
const transitionTimerRef = react.useRef(null);
|
|
49
|
+
react.useEffect(() => {
|
|
50
|
+
if (delayTimerRef.current) {
|
|
51
|
+
clearTimeout(delayTimerRef.current);
|
|
52
|
+
delayTimerRef.current = null;
|
|
53
|
+
}
|
|
54
|
+
if (minDurationTimerRef.current) {
|
|
55
|
+
clearTimeout(minDurationTimerRef.current);
|
|
56
|
+
minDurationTimerRef.current = null;
|
|
57
|
+
}
|
|
58
|
+
if (transitionTimerRef.current) {
|
|
59
|
+
clearTimeout(transitionTimerRef.current);
|
|
60
|
+
transitionTimerRef.current = null;
|
|
61
|
+
}
|
|
62
|
+
if (visible) {
|
|
63
|
+
if (delay > 0) {
|
|
64
|
+
delayTimerRef.current = setTimeout(() => {
|
|
65
|
+
setShouldRender(true);
|
|
66
|
+
showTimeRef.current = Date.now();
|
|
67
|
+
if (hasTransition) {
|
|
68
|
+
setIsTransitioning(true);
|
|
69
|
+
}
|
|
70
|
+
}, delay);
|
|
71
|
+
} else {
|
|
72
|
+
setShouldRender(true);
|
|
73
|
+
showTimeRef.current = Date.now();
|
|
74
|
+
if (hasTransition) {
|
|
75
|
+
setIsTransitioning(true);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
const hideLoader = () => {
|
|
80
|
+
if (hasTransition) {
|
|
81
|
+
setIsTransitioning(false);
|
|
82
|
+
transitionTimerRef.current = setTimeout(() => {
|
|
83
|
+
setShouldRender(false);
|
|
84
|
+
showTimeRef.current = null;
|
|
85
|
+
}, transitionDuration);
|
|
86
|
+
} else {
|
|
87
|
+
setShouldRender(false);
|
|
88
|
+
showTimeRef.current = null;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (showTimeRef.current !== null && minDuration > 0) {
|
|
92
|
+
const elapsedTime = Date.now() - showTimeRef.current;
|
|
93
|
+
const remainingTime = minDuration - elapsedTime;
|
|
94
|
+
if (remainingTime > 0) {
|
|
95
|
+
minDurationTimerRef.current = setTimeout(hideLoader, remainingTime);
|
|
96
|
+
} else {
|
|
97
|
+
hideLoader();
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
hideLoader();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return () => {
|
|
104
|
+
if (delayTimerRef.current) {
|
|
105
|
+
clearTimeout(delayTimerRef.current);
|
|
106
|
+
}
|
|
107
|
+
if (minDurationTimerRef.current) {
|
|
108
|
+
clearTimeout(minDurationTimerRef.current);
|
|
109
|
+
}
|
|
110
|
+
if (transitionTimerRef.current) {
|
|
111
|
+
clearTimeout(transitionTimerRef.current);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}, [visible, delay, minDuration, hasTransition, transitionDuration]);
|
|
115
|
+
const opacity = hasTransition ? isTransitioning ? 1 : 0 : 1;
|
|
116
|
+
const transitionStyle = hasTransition ? `opacity ${transitionDuration}ms ease-in-out` : "none";
|
|
117
|
+
return {
|
|
118
|
+
shouldRender,
|
|
119
|
+
opacity,
|
|
120
|
+
transitionStyle
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
exports.getEffectiveDuration = getEffectiveDuration;
|
|
124
|
+
exports.useLoaderVisibility = useLoaderVisibility;
|
|
125
|
+
exports.useReducedMotion = useReducedMotion;
|
package/dist/index64.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from "react";
|
|
2
|
+
function useReducedMotion() {
|
|
3
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
9
|
+
setPrefersReducedMotion(mediaQuery.matches);
|
|
10
|
+
const handleChange = (event) => {
|
|
11
|
+
setPrefersReducedMotion(event.matches);
|
|
12
|
+
};
|
|
13
|
+
if (mediaQuery.addEventListener) {
|
|
14
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
15
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
16
|
+
} else {
|
|
17
|
+
mediaQuery.addListener(handleChange);
|
|
18
|
+
return () => mediaQuery.removeListener(handleChange);
|
|
19
|
+
}
|
|
20
|
+
}, []);
|
|
21
|
+
return prefersReducedMotion;
|
|
22
|
+
}
|
|
23
|
+
function getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion) {
|
|
24
|
+
if (respectMotionPreference && prefersReducedMotion) {
|
|
25
|
+
return "0.01ms";
|
|
26
|
+
}
|
|
27
|
+
if (typeof speed === "number") {
|
|
28
|
+
const validSpeed = !isNaN(speed) && speed > 0 ? Math.max(50, Math.min(1e4, speed)) : 1e3;
|
|
29
|
+
return `${validSpeed}ms`;
|
|
30
|
+
}
|
|
31
|
+
const speedMap = {
|
|
32
|
+
slow: "2s",
|
|
33
|
+
normal: "1s",
|
|
34
|
+
fast: "0.5s"
|
|
35
|
+
};
|
|
36
|
+
return speedMap[speed] || speedMap.normal;
|
|
37
|
+
}
|
|
38
|
+
function useLoaderVisibility(visible = true, delay = 0, minDuration = 0, transition) {
|
|
39
|
+
const transitionDuration = transition === true ? 150 : typeof transition === "number" ? transition : 0;
|
|
40
|
+
const hasTransition = transitionDuration > 0;
|
|
41
|
+
const [shouldRender, setShouldRender] = useState(visible && delay === 0);
|
|
42
|
+
const [isTransitioning, setIsTransitioning] = useState(visible && delay === 0 && hasTransition);
|
|
43
|
+
const showTimeRef = useRef(visible && delay === 0 ? Date.now() : null);
|
|
44
|
+
const delayTimerRef = useRef(null);
|
|
45
|
+
const minDurationTimerRef = useRef(null);
|
|
46
|
+
const transitionTimerRef = useRef(null);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (delayTimerRef.current) {
|
|
49
|
+
clearTimeout(delayTimerRef.current);
|
|
50
|
+
delayTimerRef.current = null;
|
|
51
|
+
}
|
|
52
|
+
if (minDurationTimerRef.current) {
|
|
53
|
+
clearTimeout(minDurationTimerRef.current);
|
|
54
|
+
minDurationTimerRef.current = null;
|
|
55
|
+
}
|
|
56
|
+
if (transitionTimerRef.current) {
|
|
57
|
+
clearTimeout(transitionTimerRef.current);
|
|
58
|
+
transitionTimerRef.current = null;
|
|
59
|
+
}
|
|
60
|
+
if (visible) {
|
|
61
|
+
if (delay > 0) {
|
|
62
|
+
delayTimerRef.current = setTimeout(() => {
|
|
63
|
+
setShouldRender(true);
|
|
64
|
+
showTimeRef.current = Date.now();
|
|
65
|
+
if (hasTransition) {
|
|
66
|
+
setIsTransitioning(true);
|
|
67
|
+
}
|
|
68
|
+
}, delay);
|
|
69
|
+
} else {
|
|
70
|
+
setShouldRender(true);
|
|
71
|
+
showTimeRef.current = Date.now();
|
|
72
|
+
if (hasTransition) {
|
|
73
|
+
setIsTransitioning(true);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
const hideLoader = () => {
|
|
78
|
+
if (hasTransition) {
|
|
79
|
+
setIsTransitioning(false);
|
|
80
|
+
transitionTimerRef.current = setTimeout(() => {
|
|
81
|
+
setShouldRender(false);
|
|
82
|
+
showTimeRef.current = null;
|
|
83
|
+
}, transitionDuration);
|
|
84
|
+
} else {
|
|
85
|
+
setShouldRender(false);
|
|
86
|
+
showTimeRef.current = null;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
if (showTimeRef.current !== null && minDuration > 0) {
|
|
90
|
+
const elapsedTime = Date.now() - showTimeRef.current;
|
|
91
|
+
const remainingTime = minDuration - elapsedTime;
|
|
92
|
+
if (remainingTime > 0) {
|
|
93
|
+
minDurationTimerRef.current = setTimeout(hideLoader, remainingTime);
|
|
94
|
+
} else {
|
|
95
|
+
hideLoader();
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
hideLoader();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return () => {
|
|
102
|
+
if (delayTimerRef.current) {
|
|
103
|
+
clearTimeout(delayTimerRef.current);
|
|
104
|
+
}
|
|
105
|
+
if (minDurationTimerRef.current) {
|
|
106
|
+
clearTimeout(minDurationTimerRef.current);
|
|
107
|
+
}
|
|
108
|
+
if (transitionTimerRef.current) {
|
|
109
|
+
clearTimeout(transitionTimerRef.current);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}, [visible, delay, minDuration, hasTransition, transitionDuration]);
|
|
113
|
+
const opacity = hasTransition ? isTransitioning ? 1 : 0 : 1;
|
|
114
|
+
const transitionStyle = hasTransition ? `opacity ${transitionDuration}ms ease-in-out` : "none";
|
|
115
|
+
return {
|
|
116
|
+
shouldRender,
|
|
117
|
+
opacity,
|
|
118
|
+
transitionStyle
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
getEffectiveDuration,
|
|
123
|
+
useLoaderVisibility,
|
|
124
|
+
useReducedMotion
|
|
125
|
+
};
|
package/dist/index7.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const hooks = require("./
|
|
5
|
+
const hooks = require("./index64.cjs");
|
|
6
6
|
const colors = require("./index4.cjs");
|
|
7
7
|
const classNames = require("./index3.cjs");
|
|
8
8
|
const Skeleton = react.forwardRef(
|