premium-react-loaders 2.3.0 → 3.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 +45 -3
- package/dist/components/bounce/BouncingBalls.d.ts +15 -0
- package/dist/components/bounce/BouncingBalls.d.ts.map +1 -0
- package/dist/components/bounce/BouncingDots.d.ts +15 -0
- package/dist/components/bounce/BouncingDots.d.ts.map +1 -0
- package/dist/components/bounce/index.d.ts +3 -0
- package/dist/components/bounce/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/infinity/InfinityLoader.d.ts +15 -0
- package/dist/components/infinity/InfinityLoader.d.ts.map +1 -0
- package/dist/components/infinity/MobiusLoader.d.ts +15 -0
- package/dist/components/infinity/MobiusLoader.d.ts.map +1 -0
- package/dist/components/infinity/index.d.ts +3 -0
- package/dist/components/infinity/index.d.ts.map +1 -0
- package/dist/components/orbit/AtomLoader.d.ts +15 -0
- package/dist/components/orbit/AtomLoader.d.ts.map +1 -0
- package/dist/components/orbit/OrbitDots.d.ts +15 -0
- package/dist/components/orbit/OrbitDots.d.ts.map +1 -0
- package/dist/components/orbit/OrbitRings.d.ts +15 -0
- package/dist/components/orbit/OrbitRings.d.ts.map +1 -0
- package/dist/components/orbit/index.d.ts +4 -0
- package/dist/components/orbit/index.d.ts.map +1 -0
- package/dist/components/shimmer/ShimmerBox.d.ts +15 -0
- package/dist/components/shimmer/ShimmerBox.d.ts.map +1 -0
- package/dist/components/shimmer/ShimmerButton.d.ts +15 -0
- package/dist/components/shimmer/ShimmerButton.d.ts.map +1 -0
- package/dist/components/shimmer/ShimmerText.d.ts +15 -0
- package/dist/components/shimmer/ShimmerText.d.ts.map +1 -0
- package/dist/components/shimmer/index.d.ts +4 -0
- package/dist/components/shimmer/index.d.ts.map +1 -0
- package/dist/components/text/LoadingText.d.ts +16 -0
- package/dist/components/text/LoadingText.d.ts.map +1 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/index.d.ts.map +1 -0
- package/dist/hooks/useEnhancedLoader.d.ts.map +1 -1
- package/dist/index.cjs +22 -0
- package/dist/index.js +22 -0
- 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/index16.cjs +1 -1
- package/dist/index16.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 +1 -1
- package/dist/index25.js +1 -1
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +1 -1
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +1 -1
- 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/index36.cjs +90 -119
- package/dist/index36.js +91 -120
- package/dist/index37.cjs +113 -0
- package/dist/index37.js +113 -0
- package/dist/index38.cjs +169 -0
- package/dist/index38.js +169 -0
- package/dist/index39.cjs +97 -0
- package/dist/index39.js +97 -0
- package/dist/index40.cjs +90 -0
- package/dist/index40.js +90 -0
- package/dist/index41.cjs +139 -0
- package/dist/index41.js +139 -0
- package/dist/index42.cjs +82 -0
- package/dist/index42.js +82 -0
- package/dist/index43.cjs +110 -0
- package/dist/index43.js +110 -0
- package/dist/index44.cjs +135 -0
- package/dist/index44.js +135 -0
- package/dist/index45.cjs +106 -0
- package/dist/index45.js +106 -0
- package/dist/index46.cjs +158 -0
- package/dist/index46.js +158 -0
- package/dist/index47.cjs +125 -0
- package/dist/index47.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 +217 -0
- package/dist/types/bounce.d.ts +41 -0
- package/dist/types/bounce.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +4 -0
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/infinity.d.ts +35 -0
- package/dist/types/infinity.d.ts.map +1 -0
- package/dist/types/orbit.d.ts +50 -0
- package/dist/types/orbit.d.ts.map +1 -0
- package/dist/types/shimmer.d.ts +52 -0
- package/dist/types/shimmer.d.ts.map +1 -0
- package/dist/types/text.d.ts +27 -0
- package/dist/types/text.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index36.js
CHANGED
|
@@ -1,125 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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);
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index47.js";
|
|
4
|
+
import { cn } from "./index3.js";
|
|
5
|
+
const ShimmerBox = forwardRef(
|
|
6
|
+
({
|
|
7
|
+
width = 200,
|
|
8
|
+
height,
|
|
9
|
+
borderRadius = 8,
|
|
10
|
+
baseColor = "#e5e7eb",
|
|
11
|
+
highlightColor = "#f3f4f6",
|
|
12
|
+
direction = "left-to-right",
|
|
13
|
+
aspectRatio,
|
|
14
|
+
speed = "normal",
|
|
15
|
+
respectMotionPreference = true,
|
|
16
|
+
delay = 0,
|
|
17
|
+
minDuration = 0,
|
|
18
|
+
transition,
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
testId = "shimmer-box",
|
|
22
|
+
visible = true,
|
|
23
|
+
ariaLabel = "Loading...",
|
|
24
|
+
...rest
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const prefersReducedMotion = useReducedMotion();
|
|
27
|
+
const effectiveDuration = getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
28
|
+
const { shouldRender, opacity, transitionStyle } = useLoaderVisibility(
|
|
29
|
+
visible,
|
|
30
|
+
delay,
|
|
31
|
+
minDuration,
|
|
32
|
+
transition
|
|
33
|
+
);
|
|
34
|
+
if (!shouldRender) return null;
|
|
35
|
+
const getGradientDirection = () => {
|
|
36
|
+
switch (direction) {
|
|
37
|
+
case "right-to-left":
|
|
38
|
+
return "to left";
|
|
39
|
+
case "top-to-bottom":
|
|
40
|
+
return "to bottom";
|
|
41
|
+
case "bottom-to-top":
|
|
42
|
+
return "to top";
|
|
43
|
+
default:
|
|
44
|
+
return "to right";
|
|
104
45
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
46
|
+
};
|
|
47
|
+
const getAnimationName = () => {
|
|
48
|
+
switch (direction) {
|
|
49
|
+
case "right-to-left":
|
|
50
|
+
return "shimmer-rtl";
|
|
51
|
+
case "top-to-bottom":
|
|
52
|
+
return "shimmer-ttb";
|
|
53
|
+
case "bottom-to-top":
|
|
54
|
+
return "shimmer-btt";
|
|
55
|
+
default:
|
|
56
|
+
return "shimmer-ltr";
|
|
110
57
|
}
|
|
111
58
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
ref,
|
|
63
|
+
"data-testid": testId,
|
|
64
|
+
className: cn("relative overflow-hidden", className),
|
|
65
|
+
style: {
|
|
66
|
+
width: typeof width === "number" ? `${width}px` : width,
|
|
67
|
+
height: aspectRatio ? void 0 : typeof height === "number" ? `${height}px` : height || "100px",
|
|
68
|
+
aspectRatio,
|
|
69
|
+
borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
|
|
70
|
+
backgroundColor: baseColor,
|
|
71
|
+
opacity,
|
|
72
|
+
transition: transitionStyle,
|
|
73
|
+
...style
|
|
74
|
+
},
|
|
75
|
+
role: "status",
|
|
76
|
+
"aria-label": ariaLabel,
|
|
77
|
+
"aria-busy": "true",
|
|
78
|
+
...rest,
|
|
79
|
+
children: /* @__PURE__ */ jsx(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
className: "absolute inset-0",
|
|
83
|
+
style: {
|
|
84
|
+
background: `linear-gradient(${getGradientDirection()}, transparent 0%, ${highlightColor} 50%, transparent 100%)`,
|
|
85
|
+
animation: `${getAnimationName()} ${effectiveDuration} infinite`
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
ShimmerBox.displayName = "ShimmerBox";
|
|
121
94
|
export {
|
|
122
|
-
|
|
123
|
-
useLoaderVisibility,
|
|
124
|
-
useReducedMotion
|
|
95
|
+
ShimmerBox
|
|
125
96
|
};
|
package/dist/index37.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
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("./index47.cjs");
|
|
6
|
+
const classNames = require("./index3.cjs");
|
|
7
|
+
const ShimmerText = react.forwardRef(
|
|
8
|
+
({
|
|
9
|
+
width = "100%",
|
|
10
|
+
height = 16,
|
|
11
|
+
borderRadius = 4,
|
|
12
|
+
baseColor = "#e5e7eb",
|
|
13
|
+
highlightColor = "#f3f4f6",
|
|
14
|
+
direction = "left-to-right",
|
|
15
|
+
lines = 3,
|
|
16
|
+
lineGap = 12,
|
|
17
|
+
lastLineWidth = "75%",
|
|
18
|
+
speed = "normal",
|
|
19
|
+
respectMotionPreference = true,
|
|
20
|
+
delay = 0,
|
|
21
|
+
minDuration = 0,
|
|
22
|
+
transition,
|
|
23
|
+
className,
|
|
24
|
+
style,
|
|
25
|
+
testId = "shimmer-text",
|
|
26
|
+
visible = true,
|
|
27
|
+
ariaLabel = "Loading text...",
|
|
28
|
+
...rest
|
|
29
|
+
}, ref) => {
|
|
30
|
+
const prefersReducedMotion = hooks.useReducedMotion();
|
|
31
|
+
const effectiveDuration = hooks.getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
32
|
+
const { shouldRender, opacity, transitionStyle } = hooks.useLoaderVisibility(
|
|
33
|
+
visible,
|
|
34
|
+
delay,
|
|
35
|
+
minDuration,
|
|
36
|
+
transition
|
|
37
|
+
);
|
|
38
|
+
if (!shouldRender) return null;
|
|
39
|
+
const getGradientDirection = () => {
|
|
40
|
+
switch (direction) {
|
|
41
|
+
case "right-to-left":
|
|
42
|
+
return "to left";
|
|
43
|
+
case "top-to-bottom":
|
|
44
|
+
return "to bottom";
|
|
45
|
+
case "bottom-to-top":
|
|
46
|
+
return "to top";
|
|
47
|
+
default:
|
|
48
|
+
return "to right";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const getAnimationName = () => {
|
|
52
|
+
switch (direction) {
|
|
53
|
+
case "right-to-left":
|
|
54
|
+
return "shimmer-rtl";
|
|
55
|
+
case "top-to-bottom":
|
|
56
|
+
return "shimmer-ttb";
|
|
57
|
+
case "bottom-to-top":
|
|
58
|
+
return "shimmer-btt";
|
|
59
|
+
default:
|
|
60
|
+
return "shimmer-ltr";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const normalizedGap = typeof lineGap === "number" ? `${lineGap}px` : lineGap;
|
|
64
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
"div",
|
|
66
|
+
{
|
|
67
|
+
ref,
|
|
68
|
+
"data-testid": testId,
|
|
69
|
+
className: classNames.cn("flex flex-col", className),
|
|
70
|
+
style: {
|
|
71
|
+
gap: normalizedGap,
|
|
72
|
+
opacity,
|
|
73
|
+
transition: transitionStyle,
|
|
74
|
+
...style
|
|
75
|
+
},
|
|
76
|
+
role: "status",
|
|
77
|
+
"aria-label": ariaLabel,
|
|
78
|
+
"aria-busy": "true",
|
|
79
|
+
...rest,
|
|
80
|
+
children: Array.from({ length: lines }, (_, index) => {
|
|
81
|
+
const isLastLine = index === lines - 1;
|
|
82
|
+
const lineWidth = isLastLine && lines > 1 ? lastLineWidth : width;
|
|
83
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
className: "relative overflow-hidden",
|
|
87
|
+
style: {
|
|
88
|
+
width: typeof lineWidth === "number" ? `${lineWidth}px` : lineWidth,
|
|
89
|
+
height: typeof height === "number" ? `${height}px` : height,
|
|
90
|
+
borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
|
|
91
|
+
backgroundColor: baseColor
|
|
92
|
+
},
|
|
93
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: "absolute inset-0",
|
|
97
|
+
style: {
|
|
98
|
+
background: `linear-gradient(${getGradientDirection()}, transparent 0%, ${highlightColor} 50%, transparent 100%)`,
|
|
99
|
+
animation: `${getAnimationName()} ${effectiveDuration} infinite`,
|
|
100
|
+
animationDelay: `${index * 100}ms`
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
},
|
|
105
|
+
index
|
|
106
|
+
);
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
ShimmerText.displayName = "ShimmerText";
|
|
113
|
+
exports.ShimmerText = ShimmerText;
|
package/dist/index37.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index47.js";
|
|
4
|
+
import { cn } from "./index3.js";
|
|
5
|
+
const ShimmerText = forwardRef(
|
|
6
|
+
({
|
|
7
|
+
width = "100%",
|
|
8
|
+
height = 16,
|
|
9
|
+
borderRadius = 4,
|
|
10
|
+
baseColor = "#e5e7eb",
|
|
11
|
+
highlightColor = "#f3f4f6",
|
|
12
|
+
direction = "left-to-right",
|
|
13
|
+
lines = 3,
|
|
14
|
+
lineGap = 12,
|
|
15
|
+
lastLineWidth = "75%",
|
|
16
|
+
speed = "normal",
|
|
17
|
+
respectMotionPreference = true,
|
|
18
|
+
delay = 0,
|
|
19
|
+
minDuration = 0,
|
|
20
|
+
transition,
|
|
21
|
+
className,
|
|
22
|
+
style,
|
|
23
|
+
testId = "shimmer-text",
|
|
24
|
+
visible = true,
|
|
25
|
+
ariaLabel = "Loading text...",
|
|
26
|
+
...rest
|
|
27
|
+
}, ref) => {
|
|
28
|
+
const prefersReducedMotion = useReducedMotion();
|
|
29
|
+
const effectiveDuration = getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
30
|
+
const { shouldRender, opacity, transitionStyle } = useLoaderVisibility(
|
|
31
|
+
visible,
|
|
32
|
+
delay,
|
|
33
|
+
minDuration,
|
|
34
|
+
transition
|
|
35
|
+
);
|
|
36
|
+
if (!shouldRender) return null;
|
|
37
|
+
const getGradientDirection = () => {
|
|
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";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const getAnimationName = () => {
|
|
50
|
+
switch (direction) {
|
|
51
|
+
case "right-to-left":
|
|
52
|
+
return "shimmer-rtl";
|
|
53
|
+
case "top-to-bottom":
|
|
54
|
+
return "shimmer-ttb";
|
|
55
|
+
case "bottom-to-top":
|
|
56
|
+
return "shimmer-btt";
|
|
57
|
+
default:
|
|
58
|
+
return "shimmer-ltr";
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const normalizedGap = typeof lineGap === "number" ? `${lineGap}px` : lineGap;
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
ref,
|
|
66
|
+
"data-testid": testId,
|
|
67
|
+
className: cn("flex flex-col", className),
|
|
68
|
+
style: {
|
|
69
|
+
gap: normalizedGap,
|
|
70
|
+
opacity,
|
|
71
|
+
transition: transitionStyle,
|
|
72
|
+
...style
|
|
73
|
+
},
|
|
74
|
+
role: "status",
|
|
75
|
+
"aria-label": ariaLabel,
|
|
76
|
+
"aria-busy": "true",
|
|
77
|
+
...rest,
|
|
78
|
+
children: Array.from({ length: lines }, (_, index) => {
|
|
79
|
+
const isLastLine = index === lines - 1;
|
|
80
|
+
const lineWidth = isLastLine && lines > 1 ? lastLineWidth : width;
|
|
81
|
+
return /* @__PURE__ */ jsx(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
className: "relative overflow-hidden",
|
|
85
|
+
style: {
|
|
86
|
+
width: typeof lineWidth === "number" ? `${lineWidth}px` : lineWidth,
|
|
87
|
+
height: typeof height === "number" ? `${height}px` : height,
|
|
88
|
+
borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
|
|
89
|
+
backgroundColor: baseColor
|
|
90
|
+
},
|
|
91
|
+
children: /* @__PURE__ */ jsx(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
className: "absolute inset-0",
|
|
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
|
+
})
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
ShimmerText.displayName = "ShimmerText";
|
|
111
|
+
export {
|
|
112
|
+
ShimmerText
|
|
113
|
+
};
|
package/dist/index38.cjs
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
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("./index47.cjs");
|
|
6
|
+
const classNames = require("./index3.cjs");
|
|
7
|
+
const ShimmerButton = react.forwardRef(
|
|
8
|
+
({
|
|
9
|
+
width = 120,
|
|
10
|
+
height = 40,
|
|
11
|
+
borderRadius = 8,
|
|
12
|
+
baseColor = "#e5e7eb",
|
|
13
|
+
highlightColor = "#f3f4f6",
|
|
14
|
+
direction = "left-to-right",
|
|
15
|
+
variant = "solid",
|
|
16
|
+
showIcon = false,
|
|
17
|
+
iconPosition = "left",
|
|
18
|
+
speed = "normal",
|
|
19
|
+
respectMotionPreference = true,
|
|
20
|
+
delay = 0,
|
|
21
|
+
minDuration = 0,
|
|
22
|
+
transition,
|
|
23
|
+
className,
|
|
24
|
+
style,
|
|
25
|
+
testId = "shimmer-button",
|
|
26
|
+
visible = true,
|
|
27
|
+
ariaLabel = "Loading button...",
|
|
28
|
+
...rest
|
|
29
|
+
}, ref) => {
|
|
30
|
+
const prefersReducedMotion = hooks.useReducedMotion();
|
|
31
|
+
const effectiveDuration = hooks.getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
|
|
32
|
+
const { shouldRender, opacity, transitionStyle } = hooks.useLoaderVisibility(
|
|
33
|
+
visible,
|
|
34
|
+
delay,
|
|
35
|
+
minDuration,
|
|
36
|
+
transition
|
|
37
|
+
);
|
|
38
|
+
if (!shouldRender) return null;
|
|
39
|
+
const getAnimationName = () => {
|
|
40
|
+
switch (direction) {
|
|
41
|
+
case "right-to-left":
|
|
42
|
+
return "shimmer-rtl";
|
|
43
|
+
case "top-to-bottom":
|
|
44
|
+
return "shimmer-ttb";
|
|
45
|
+
case "bottom-to-top":
|
|
46
|
+
return "shimmer-btt";
|
|
47
|
+
default:
|
|
48
|
+
return "shimmer-ltr";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const getGradientDirection = () => {
|
|
52
|
+
switch (direction) {
|
|
53
|
+
case "right-to-left":
|
|
54
|
+
return "to left";
|
|
55
|
+
case "top-to-bottom":
|
|
56
|
+
return "to bottom";
|
|
57
|
+
case "bottom-to-top":
|
|
58
|
+
return "to top";
|
|
59
|
+
default:
|
|
60
|
+
return "to right";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const normalizedHeight = typeof height === "number" ? height : 40;
|
|
64
|
+
const iconSize = Math.floor(normalizedHeight * 0.5);
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
ref,
|
|
69
|
+
"data-testid": testId,
|
|
70
|
+
className: classNames.cn(
|
|
71
|
+
"relative overflow-hidden inline-flex items-center justify-center gap-2",
|
|
72
|
+
className
|
|
73
|
+
),
|
|
74
|
+
style: {
|
|
75
|
+
width: typeof width === "number" ? `${width}px` : width,
|
|
76
|
+
height: typeof height === "number" ? `${height}px` : height,
|
|
77
|
+
borderRadius: typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
|
|
78
|
+
backgroundColor: variant === "solid" ? baseColor : "transparent",
|
|
79
|
+
border: variant === "outline" ? `2px solid ${baseColor}` : "none",
|
|
80
|
+
padding: "0 16px",
|
|
81
|
+
opacity,
|
|
82
|
+
transition: transitionStyle,
|
|
83
|
+
...style
|
|
84
|
+
},
|
|
85
|
+
role: "status",
|
|
86
|
+
"aria-label": ariaLabel,
|
|
87
|
+
"aria-busy": "true",
|
|
88
|
+
...rest,
|
|
89
|
+
children: [
|
|
90
|
+
showIcon && iconPosition === "left" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
className: "relative overflow-hidden rounded-full flex-shrink-0",
|
|
94
|
+
style: {
|
|
95
|
+
width: iconSize,
|
|
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
|
+
}
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
ShimmerButton.displayName = "ShimmerButton";
|
|
169
|
+
exports.ShimmerButton = ShimmerButton;
|