premium-react-loaders 3.1.1 → 4.1.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 +4 -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/neon/NeonPulse.d.ts +12 -0
- package/dist/components/neon/NeonPulse.d.ts.map +1 -0
- package/dist/components/neon/NeonSpinner.d.ts +12 -0
- package/dist/components/neon/NeonSpinner.d.ts.map +1 -0
- package/dist/components/neon/NeonText.d.ts +12 -0
- package/dist/components/neon/NeonText.d.ts.map +1 -0
- package/dist/components/neon/index.d.ts +4 -0
- package/dist/components/neon/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/ParticleField.d.ts +3 -0
- package/dist/components/particle/ParticleField.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/ParticleTrail.d.ts +12 -0
- package/dist/components/particle/ParticleTrail.d.ts.map +1 -0
- package/dist/components/particle/index.d.ts +5 -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/components/status/InfoIndicator.d.ts +29 -0
- package/dist/components/status/InfoIndicator.d.ts.map +1 -0
- package/dist/components/status/WarningIndicator.d.ts +29 -0
- package/dist/components/status/WarningIndicator.d.ts.map +1 -0
- package/dist/components/status/index.d.ts +2 -0
- package/dist/components/status/index.d.ts.map +1 -1
- package/dist/index.cjs +50 -20
- package/dist/index.d.ts +1 -1
- package/dist/index.js +50 -20
- 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/index37.cjs +59 -145
- package/dist/index37.js +61 -147
- package/dist/index38.cjs +32 -53
- package/dist/index38.js +33 -54
- package/dist/index39.cjs +138 -84
- package/dist/index39.js +140 -86
- package/dist/index4.cjs +10 -0
- package/dist/index4.js +10 -0
- package/dist/index40.cjs +33 -106
- package/dist/index40.js +34 -107
- package/dist/index41.cjs +66 -50
- package/dist/index41.js +66 -50
- package/dist/index42.cjs +123 -44
- package/dist/index42.js +124 -45
- package/dist/index43.cjs +43 -85
- package/dist/index43.js +44 -86
- package/dist/index44.cjs +35 -27
- package/dist/index44.js +35 -27
- package/dist/index45.cjs +87 -58
- package/dist/index45.js +87 -58
- package/dist/index46.cjs +35 -88
- package/dist/index46.js +36 -89
- package/dist/index47.cjs +62 -58
- package/dist/index47.js +63 -59
- package/dist/index48.cjs +87 -110
- package/dist/index48.js +88 -111
- package/dist/index49.cjs +48 -109
- package/dist/index49.js +49 -110
- package/dist/index50.cjs +110 -62
- package/dist/index50.js +111 -63
- package/dist/index51.cjs +104 -49
- package/dist/index51.js +104 -49
- package/dist/index52.cjs +43 -77
- package/dist/index52.js +44 -78
- package/dist/index53.cjs +56 -56
- package/dist/index53.js +56 -56
- package/dist/index54.cjs +104 -149
- package/dist/index54.js +106 -151
- package/dist/index55.cjs +97 -38
- package/dist/index55.js +99 -40
- package/dist/index56.cjs +184 -120
- package/dist/index56.js +185 -121
- package/dist/index57.cjs +53 -0
- package/dist/index57.js +53 -0
- package/dist/index58.cjs +55 -0
- package/dist/index58.js +55 -0
- package/dist/index59.cjs +119 -0
- package/dist/index59.js +119 -0
- package/dist/index60.cjs +70 -0
- package/dist/index60.js +70 -0
- package/dist/index61.cjs +66 -0
- package/dist/index61.js +66 -0
- package/dist/index62.cjs +68 -0
- package/dist/index62.js +68 -0
- package/dist/index63.cjs +99 -0
- package/dist/index63.js +99 -0
- package/dist/index64.cjs +75 -0
- package/dist/index64.js +75 -0
- package/dist/index65.cjs +92 -0
- package/dist/index65.js +92 -0
- package/dist/index66.cjs +76 -0
- package/dist/index66.js +76 -0
- package/dist/index67.cjs +76 -0
- package/dist/index67.js +76 -0
- package/dist/index68.cjs +64 -0
- package/dist/index68.js +64 -0
- package/dist/index69.cjs +60 -0
- package/dist/index69.js +60 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index70.cjs +57 -0
- package/dist/index70.js +57 -0
- package/dist/index71.cjs +125 -0
- package/dist/index71.js +125 -0
- 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 +126 -0
- package/dist/types/gradient.d.ts +38 -0
- package/dist/types/gradient.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -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/neon.d.ts +26 -0
- package/dist/types/neon.d.ts.map +1 -0
- package/dist/types/particle.d.ts +40 -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/types/status.d.ts +30 -0
- package/dist/types/status.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/index39.js
CHANGED
|
@@ -1,113 +1,167 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index56.js";
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useRef, useEffect } from "react";
|
|
4
3
|
import { cn } from "./index3.js";
|
|
5
|
-
const
|
|
4
|
+
const LoaderTransition = forwardRef(
|
|
6
5
|
({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
speed = "normal",
|
|
17
|
-
respectMotionPreference = true,
|
|
18
|
-
delay = 0,
|
|
19
|
-
minDuration = 0,
|
|
20
|
-
transition,
|
|
6
|
+
loading,
|
|
7
|
+
loadingContent,
|
|
8
|
+
children,
|
|
9
|
+
transitionType = "fade",
|
|
10
|
+
duration = 300,
|
|
11
|
+
timing = "ease-out",
|
|
12
|
+
keepMounted = false,
|
|
13
|
+
exitDelay = 0,
|
|
14
|
+
appearOnMount = false,
|
|
21
15
|
className,
|
|
22
16
|
style,
|
|
23
|
-
testId = "
|
|
17
|
+
testId = "loader-transition",
|
|
18
|
+
ariaLabel,
|
|
24
19
|
visible = true,
|
|
25
|
-
|
|
20
|
+
delay = 0,
|
|
21
|
+
minDuration = 0,
|
|
22
|
+
transition: transitionProp,
|
|
26
23
|
...rest
|
|
27
24
|
}, ref) => {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
switch (direction) {
|
|
39
|
-
case "right-to-left":
|
|
40
|
-
return "to left";
|
|
41
|
-
case "top-to-bottom":
|
|
42
|
-
return "to bottom";
|
|
43
|
-
case "bottom-to-top":
|
|
44
|
-
return "to top";
|
|
45
|
-
default:
|
|
46
|
-
return "to right";
|
|
25
|
+
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
26
|
+
const [showLoading, setShowLoading] = useState(appearOnMount ? loading : false);
|
|
27
|
+
const [showContent, setShowContent] = useState(!appearOnMount && !loading);
|
|
28
|
+
const timeoutRef = useRef(null);
|
|
29
|
+
const entryTimeRef = useRef(null);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!visible) {
|
|
32
|
+
setShowLoading(false);
|
|
33
|
+
setShowContent(false);
|
|
34
|
+
return;
|
|
47
35
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
36
|
+
if (loading) {
|
|
37
|
+
if (timeoutRef.current) {
|
|
38
|
+
clearTimeout(timeoutRef.current);
|
|
39
|
+
}
|
|
40
|
+
if (delay > 0) {
|
|
41
|
+
timeoutRef.current = setTimeout(() => {
|
|
42
|
+
setShowLoading(true);
|
|
43
|
+
setShowContent(false);
|
|
44
|
+
entryTimeRef.current = Date.now();
|
|
45
|
+
}, delay);
|
|
46
|
+
} else {
|
|
47
|
+
setShowLoading(true);
|
|
48
|
+
setShowContent(false);
|
|
49
|
+
entryTimeRef.current = Date.now();
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
const elapsed = entryTimeRef.current ? Date.now() - entryTimeRef.current : 0;
|
|
53
|
+
const remainingMinDuration = Math.max(0, minDuration - elapsed);
|
|
54
|
+
const totalDelay = exitDelay + remainingMinDuration;
|
|
55
|
+
if (totalDelay > 0) {
|
|
56
|
+
timeoutRef.current = setTimeout(() => {
|
|
57
|
+
setIsTransitioning(true);
|
|
58
|
+
timeoutRef.current = setTimeout(() => {
|
|
59
|
+
setShowLoading(false);
|
|
60
|
+
setShowContent(true);
|
|
61
|
+
setIsTransitioning(false);
|
|
62
|
+
}, duration);
|
|
63
|
+
}, totalDelay);
|
|
64
|
+
} else {
|
|
65
|
+
setIsTransitioning(true);
|
|
66
|
+
timeoutRef.current = setTimeout(() => {
|
|
67
|
+
setShowLoading(false);
|
|
68
|
+
setShowContent(true);
|
|
69
|
+
setIsTransitioning(false);
|
|
70
|
+
}, duration);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return () => {
|
|
74
|
+
if (timeoutRef.current) {
|
|
75
|
+
clearTimeout(timeoutRef.current);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}, [loading, visible, delay, minDuration, exitDelay, duration]);
|
|
79
|
+
const getTransitionClasses = (isLoading, isTransition) => {
|
|
80
|
+
const baseClasses = "loader-transition";
|
|
81
|
+
const timingClass = `loader-transition-${timing}`;
|
|
82
|
+
if (transitionType === "none") {
|
|
83
|
+
return baseClasses;
|
|
84
|
+
}
|
|
85
|
+
if (transitionType === "fade") {
|
|
86
|
+
if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-enter-active`;
|
|
87
|
+
if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-exit-active`;
|
|
88
|
+
if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-enter-active`;
|
|
89
|
+
return `${baseClasses} ${timingClass}`;
|
|
90
|
+
}
|
|
91
|
+
if (transitionType === "slide-up") {
|
|
92
|
+
if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-enter-active`;
|
|
93
|
+
if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-exit-active`;
|
|
94
|
+
if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-enter-active`;
|
|
95
|
+
return `${baseClasses} ${timingClass}`;
|
|
59
96
|
}
|
|
97
|
+
if (transitionType === "slide-down") {
|
|
98
|
+
if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-enter-active`;
|
|
99
|
+
if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-exit-active`;
|
|
100
|
+
if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-enter-active`;
|
|
101
|
+
return `${baseClasses} ${timingClass}`;
|
|
102
|
+
}
|
|
103
|
+
if (transitionType === "slide-left") {
|
|
104
|
+
if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-enter-active`;
|
|
105
|
+
if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-exit-active`;
|
|
106
|
+
if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-enter-active`;
|
|
107
|
+
return `${baseClasses} ${timingClass}`;
|
|
108
|
+
}
|
|
109
|
+
if (transitionType === "slide-right") {
|
|
110
|
+
if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-enter-active`;
|
|
111
|
+
if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-exit-active`;
|
|
112
|
+
if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-enter-active`;
|
|
113
|
+
return `${baseClasses} ${timingClass}`;
|
|
114
|
+
}
|
|
115
|
+
if (transitionType === "scale") {
|
|
116
|
+
if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-enter-active`;
|
|
117
|
+
if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-exit-active`;
|
|
118
|
+
if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-enter-active`;
|
|
119
|
+
return `${baseClasses} ${timingClass}`;
|
|
120
|
+
}
|
|
121
|
+
return baseClasses;
|
|
60
122
|
};
|
|
61
|
-
const
|
|
62
|
-
|
|
123
|
+
const shouldShowLoading = showLoading || keepMounted && loading;
|
|
124
|
+
const shouldShowContent = showContent || keepMounted && !loading;
|
|
125
|
+
return /* @__PURE__ */ jsxs(
|
|
63
126
|
"div",
|
|
64
127
|
{
|
|
65
128
|
ref,
|
|
66
129
|
"data-testid": testId,
|
|
67
|
-
className: cn("
|
|
68
|
-
style
|
|
69
|
-
gap: normalizedGap,
|
|
70
|
-
opacity,
|
|
71
|
-
transition: transitionStyle,
|
|
72
|
-
...style
|
|
73
|
-
},
|
|
130
|
+
className: cn("relative", className),
|
|
131
|
+
style,
|
|
74
132
|
role: "status",
|
|
75
133
|
"aria-label": ariaLabel,
|
|
76
|
-
"aria-busy":
|
|
134
|
+
"aria-busy": loading,
|
|
77
135
|
...rest,
|
|
78
|
-
children:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
136
|
+
children: [
|
|
137
|
+
shouldShowLoading && /* @__PURE__ */ jsx(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
className: getTransitionClasses(true, isTransitioning),
|
|
141
|
+
style: {
|
|
142
|
+
transitionDuration: `${duration}ms`,
|
|
143
|
+
display: showLoading ? "block" : "none"
|
|
144
|
+
},
|
|
145
|
+
children: loadingContent
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
shouldShowContent && /* @__PURE__ */ jsx(
|
|
82
149
|
"div",
|
|
83
150
|
{
|
|
84
|
-
className:
|
|
151
|
+
className: getTransitionClasses(false, isTransitioning),
|
|
85
152
|
style: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
|
|
89
|
-
backgroundColor: baseColor
|
|
153
|
+
transitionDuration: `${duration}ms`,
|
|
154
|
+
display: showContent ? "block" : "none"
|
|
90
155
|
},
|
|
91
|
-
children
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
style: {
|
|
96
|
-
background: `linear-gradient(${getGradientDirection()}, transparent 0%, ${highlightColor} 50%, transparent 100%)`,
|
|
97
|
-
animation: `${getAnimationName()} ${effectiveDuration} infinite`,
|
|
98
|
-
animationDelay: `${index * 100}ms`
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
},
|
|
103
|
-
index
|
|
104
|
-
);
|
|
105
|
-
})
|
|
156
|
+
children
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
]
|
|
106
160
|
}
|
|
107
161
|
);
|
|
108
162
|
}
|
|
109
163
|
);
|
|
110
|
-
|
|
164
|
+
LoaderTransition.displayName = "LoaderTransition";
|
|
111
165
|
export {
|
|
112
|
-
|
|
166
|
+
LoaderTransition
|
|
113
167
|
};
|
package/dist/index4.cjs
CHANGED
|
@@ -81,6 +81,15 @@ function getContrastColor(backgroundColor) {
|
|
|
81
81
|
const luminance = getColorLuminance(backgroundColor);
|
|
82
82
|
return luminance < 0.5 ? "#ffffff" : "#000000";
|
|
83
83
|
}
|
|
84
|
+
function parseDurationMs(duration) {
|
|
85
|
+
if (duration.endsWith("ms")) {
|
|
86
|
+
return parseFloat(duration);
|
|
87
|
+
}
|
|
88
|
+
if (duration.endsWith("s")) {
|
|
89
|
+
return parseFloat(duration) * 1e3;
|
|
90
|
+
}
|
|
91
|
+
return parseFloat(duration);
|
|
92
|
+
}
|
|
84
93
|
exports.getAnimationDuration = getAnimationDuration;
|
|
85
94
|
exports.getColorLuminance = getColorLuminance;
|
|
86
95
|
exports.getContrastColor = getContrastColor;
|
|
@@ -88,4 +97,5 @@ exports.hexToRgb = hexToRgb;
|
|
|
88
97
|
exports.isHexColor = isHexColor;
|
|
89
98
|
exports.isRgbColor = isRgbColor;
|
|
90
99
|
exports.normalizeSize = normalizeSize;
|
|
100
|
+
exports.parseDurationMs = parseDurationMs;
|
|
91
101
|
exports.parseSizeToNumber = parseSizeToNumber;
|
package/dist/index4.js
CHANGED
|
@@ -79,6 +79,15 @@ function getContrastColor(backgroundColor) {
|
|
|
79
79
|
const luminance = getColorLuminance(backgroundColor);
|
|
80
80
|
return luminance < 0.5 ? "#ffffff" : "#000000";
|
|
81
81
|
}
|
|
82
|
+
function parseDurationMs(duration) {
|
|
83
|
+
if (duration.endsWith("ms")) {
|
|
84
|
+
return parseFloat(duration);
|
|
85
|
+
}
|
|
86
|
+
if (duration.endsWith("s")) {
|
|
87
|
+
return parseFloat(duration) * 1e3;
|
|
88
|
+
}
|
|
89
|
+
return parseFloat(duration);
|
|
90
|
+
}
|
|
82
91
|
export {
|
|
83
92
|
getAnimationDuration,
|
|
84
93
|
getColorLuminance,
|
|
@@ -87,5 +96,6 @@ export {
|
|
|
87
96
|
isHexColor,
|
|
88
97
|
isRgbColor,
|
|
89
98
|
normalizeSize,
|
|
99
|
+
parseDurationMs,
|
|
90
100
|
parseSizeToNumber
|
|
91
101
|
};
|
package/dist/index40.cjs
CHANGED
|
@@ -2,19 +2,17 @@
|
|
|
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("./index71.cjs");
|
|
6
6
|
const classNames = require("./index3.cjs");
|
|
7
|
-
const
|
|
7
|
+
const ShimmerBox = react.forwardRef(
|
|
8
8
|
({
|
|
9
|
-
width =
|
|
10
|
-
height
|
|
9
|
+
width = 200,
|
|
10
|
+
height,
|
|
11
11
|
borderRadius = 8,
|
|
12
12
|
baseColor = "#e5e7eb",
|
|
13
13
|
highlightColor = "#f3f4f6",
|
|
14
14
|
direction = "left-to-right",
|
|
15
|
-
|
|
16
|
-
showIcon = false,
|
|
17
|
-
iconPosition = "left",
|
|
15
|
+
aspectRatio,
|
|
18
16
|
speed = "normal",
|
|
19
17
|
respectMotionPreference = true,
|
|
20
18
|
delay = 0,
|
|
@@ -22,9 +20,9 @@ const ShimmerButton = react.forwardRef(
|
|
|
22
20
|
transition,
|
|
23
21
|
className,
|
|
24
22
|
style,
|
|
25
|
-
testId = "shimmer-
|
|
23
|
+
testId = "shimmer-box",
|
|
26
24
|
visible = true,
|
|
27
|
-
ariaLabel = "Loading
|
|
25
|
+
ariaLabel = "Loading...",
|
|
28
26
|
...rest
|
|
29
27
|
}, ref) => {
|
|
30
28
|
const prefersReducedMotion = hooks.useReducedMotion();
|
|
@@ -36,48 +34,42 @@ const ShimmerButton = react.forwardRef(
|
|
|
36
34
|
transition
|
|
37
35
|
);
|
|
38
36
|
if (!shouldRender) return null;
|
|
39
|
-
const
|
|
37
|
+
const getGradientDirection = () => {
|
|
40
38
|
switch (direction) {
|
|
41
39
|
case "right-to-left":
|
|
42
|
-
return "
|
|
40
|
+
return "to left";
|
|
43
41
|
case "top-to-bottom":
|
|
44
|
-
return "
|
|
42
|
+
return "to bottom";
|
|
45
43
|
case "bottom-to-top":
|
|
46
|
-
return "
|
|
44
|
+
return "to top";
|
|
47
45
|
default:
|
|
48
|
-
return "
|
|
46
|
+
return "to right";
|
|
49
47
|
}
|
|
50
48
|
};
|
|
51
|
-
const
|
|
49
|
+
const getAnimationName = () => {
|
|
52
50
|
switch (direction) {
|
|
53
51
|
case "right-to-left":
|
|
54
|
-
return "
|
|
52
|
+
return "shimmer-rtl";
|
|
55
53
|
case "top-to-bottom":
|
|
56
|
-
return "
|
|
54
|
+
return "shimmer-ttb";
|
|
57
55
|
case "bottom-to-top":
|
|
58
|
-
return "
|
|
56
|
+
return "shimmer-btt";
|
|
59
57
|
default:
|
|
60
|
-
return "
|
|
58
|
+
return "shimmer-ltr";
|
|
61
59
|
}
|
|
62
60
|
};
|
|
63
|
-
|
|
64
|
-
const iconSize = Math.floor(normalizedHeight * 0.5);
|
|
65
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
61
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
62
|
"div",
|
|
67
63
|
{
|
|
68
64
|
ref,
|
|
69
65
|
"data-testid": testId,
|
|
70
|
-
className: classNames.cn(
|
|
71
|
-
"relative overflow-hidden inline-flex items-center justify-center gap-2",
|
|
72
|
-
className
|
|
73
|
-
),
|
|
66
|
+
className: classNames.cn("relative overflow-hidden", className),
|
|
74
67
|
style: {
|
|
75
68
|
width: typeof width === "number" ? `${width}px` : width,
|
|
76
|
-
height: typeof height === "number" ? `${height}px` : height,
|
|
69
|
+
height: aspectRatio ? void 0 : typeof height === "number" ? `${height}px` : height || "100px",
|
|
70
|
+
aspectRatio,
|
|
77
71
|
borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
|
|
78
|
-
backgroundColor:
|
|
79
|
-
border: variant === "outline" ? `2px solid ${baseColor}` : "none",
|
|
80
|
-
padding: "0 16px",
|
|
72
|
+
backgroundColor: baseColor,
|
|
81
73
|
opacity,
|
|
82
74
|
transition: transitionStyle,
|
|
83
75
|
...style
|
|
@@ -86,84 +78,19 @@ const ShimmerButton = react.forwardRef(
|
|
|
86
78
|
"aria-label": ariaLabel,
|
|
87
79
|
"aria-busy": "true",
|
|
88
80
|
...rest,
|
|
89
|
-
children:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
height: iconSize,
|
|
97
|
-
backgroundColor: variant === "solid" ? highlightColor : baseColor
|
|
98
|
-
},
|
|
99
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
100
|
-
"div",
|
|
101
|
-
{
|
|
102
|
-
className: "absolute inset-0",
|
|
103
|
-
style: {
|
|
104
|
-
background: `linear-gradient(${getGradientDirection()}, transparent 0%, ${variant === "solid" ? baseColor : highlightColor} 50%, transparent 100%)`,
|
|
105
|
-
animation: `${getAnimationName()} ${effectiveDuration} infinite`
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
),
|
|
111
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
112
|
-
"div",
|
|
113
|
-
{
|
|
114
|
-
className: "relative overflow-hidden flex-1",
|
|
115
|
-
style: {
|
|
116
|
-
height: Math.floor(normalizedHeight * 0.35),
|
|
117
|
-
borderRadius: 4,
|
|
118
|
-
backgroundColor: variant === "solid" ? highlightColor : baseColor
|
|
119
|
-
},
|
|
120
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
-
"div",
|
|
122
|
-
{
|
|
123
|
-
className: "absolute inset-0",
|
|
124
|
-
style: {
|
|
125
|
-
background: `linear-gradient(${getGradientDirection()}, transparent 0%, ${variant === "solid" ? baseColor : highlightColor} 50%, transparent 100%)`,
|
|
126
|
-
animation: `${getAnimationName()} ${effectiveDuration} infinite`
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
),
|
|
132
|
-
showIcon && iconPosition === "right" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
-
"div",
|
|
134
|
-
{
|
|
135
|
-
className: "relative overflow-hidden rounded-full flex-shrink-0",
|
|
136
|
-
style: {
|
|
137
|
-
width: iconSize,
|
|
138
|
-
height: iconSize,
|
|
139
|
-
backgroundColor: variant === "solid" ? highlightColor : baseColor
|
|
140
|
-
},
|
|
141
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
142
|
-
"div",
|
|
143
|
-
{
|
|
144
|
-
className: "absolute inset-0",
|
|
145
|
-
style: {
|
|
146
|
-
background: `linear-gradient(${getGradientDirection()}, transparent 0%, ${variant === "solid" ? baseColor : highlightColor} 50%, transparent 100%)`,
|
|
147
|
-
animation: `${getAnimationName()} ${effectiveDuration} infinite`
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
),
|
|
153
|
-
variant === "solid" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
154
|
-
"div",
|
|
155
|
-
{
|
|
156
|
-
className: "absolute inset-0 pointer-events-none",
|
|
157
|
-
style: {
|
|
158
|
-
background: `linear-gradient(${getGradientDirection()}, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%)`,
|
|
159
|
-
animation: `${getAnimationName()} ${effectiveDuration} infinite`
|
|
160
|
-
}
|
|
81
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
className: "absolute inset-0",
|
|
85
|
+
style: {
|
|
86
|
+
background: `linear-gradient(${getGradientDirection()}, transparent 0%, ${highlightColor} 50%, transparent 100%)`,
|
|
87
|
+
animation: `${getAnimationName()} ${effectiveDuration} infinite`
|
|
161
88
|
}
|
|
162
|
-
|
|
163
|
-
|
|
89
|
+
}
|
|
90
|
+
)
|
|
164
91
|
}
|
|
165
92
|
);
|
|
166
93
|
}
|
|
167
94
|
);
|
|
168
|
-
|
|
169
|
-
exports.
|
|
95
|
+
ShimmerBox.displayName = "ShimmerBox";
|
|
96
|
+
exports.ShimmerBox = ShimmerBox;
|