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.
Files changed (134) hide show
  1. package/README.md +45 -3
  2. package/dist/components/bounce/BouncingBalls.d.ts +15 -0
  3. package/dist/components/bounce/BouncingBalls.d.ts.map +1 -0
  4. package/dist/components/bounce/BouncingDots.d.ts +15 -0
  5. package/dist/components/bounce/BouncingDots.d.ts.map +1 -0
  6. package/dist/components/bounce/index.d.ts +3 -0
  7. package/dist/components/bounce/index.d.ts.map +1 -0
  8. package/dist/components/index.d.ts +5 -0
  9. package/dist/components/index.d.ts.map +1 -1
  10. package/dist/components/infinity/InfinityLoader.d.ts +15 -0
  11. package/dist/components/infinity/InfinityLoader.d.ts.map +1 -0
  12. package/dist/components/infinity/MobiusLoader.d.ts +15 -0
  13. package/dist/components/infinity/MobiusLoader.d.ts.map +1 -0
  14. package/dist/components/infinity/index.d.ts +3 -0
  15. package/dist/components/infinity/index.d.ts.map +1 -0
  16. package/dist/components/orbit/AtomLoader.d.ts +15 -0
  17. package/dist/components/orbit/AtomLoader.d.ts.map +1 -0
  18. package/dist/components/orbit/OrbitDots.d.ts +15 -0
  19. package/dist/components/orbit/OrbitDots.d.ts.map +1 -0
  20. package/dist/components/orbit/OrbitRings.d.ts +15 -0
  21. package/dist/components/orbit/OrbitRings.d.ts.map +1 -0
  22. package/dist/components/orbit/index.d.ts +4 -0
  23. package/dist/components/orbit/index.d.ts.map +1 -0
  24. package/dist/components/shimmer/ShimmerBox.d.ts +15 -0
  25. package/dist/components/shimmer/ShimmerBox.d.ts.map +1 -0
  26. package/dist/components/shimmer/ShimmerButton.d.ts +15 -0
  27. package/dist/components/shimmer/ShimmerButton.d.ts.map +1 -0
  28. package/dist/components/shimmer/ShimmerText.d.ts +15 -0
  29. package/dist/components/shimmer/ShimmerText.d.ts.map +1 -0
  30. package/dist/components/shimmer/index.d.ts +4 -0
  31. package/dist/components/shimmer/index.d.ts.map +1 -0
  32. package/dist/components/text/LoadingText.d.ts +16 -0
  33. package/dist/components/text/LoadingText.d.ts.map +1 -0
  34. package/dist/components/text/index.d.ts +2 -0
  35. package/dist/components/text/index.d.ts.map +1 -0
  36. package/dist/hooks/useEnhancedLoader.d.ts.map +1 -1
  37. package/dist/index.cjs +22 -0
  38. package/dist/index.js +22 -0
  39. package/dist/index10.cjs +1 -1
  40. package/dist/index10.js +1 -1
  41. package/dist/index11.cjs +1 -1
  42. package/dist/index11.js +1 -1
  43. package/dist/index12.cjs +1 -1
  44. package/dist/index12.js +1 -1
  45. package/dist/index13.cjs +1 -1
  46. package/dist/index13.js +1 -1
  47. package/dist/index14.cjs +1 -1
  48. package/dist/index14.js +1 -1
  49. package/dist/index15.cjs +1 -1
  50. package/dist/index15.js +1 -1
  51. package/dist/index16.cjs +1 -1
  52. package/dist/index16.js +1 -1
  53. package/dist/index17.cjs +1 -1
  54. package/dist/index17.js +1 -1
  55. package/dist/index18.cjs +1 -1
  56. package/dist/index18.js +1 -1
  57. package/dist/index19.cjs +1 -1
  58. package/dist/index19.js +1 -1
  59. package/dist/index20.cjs +1 -1
  60. package/dist/index20.js +1 -1
  61. package/dist/index21.cjs +1 -1
  62. package/dist/index21.js +1 -1
  63. package/dist/index22.cjs +1 -1
  64. package/dist/index22.js +1 -1
  65. package/dist/index23.cjs +1 -1
  66. package/dist/index23.js +1 -1
  67. package/dist/index24.cjs +1 -1
  68. package/dist/index24.js +1 -1
  69. package/dist/index25.cjs +1 -1
  70. package/dist/index25.js +1 -1
  71. package/dist/index26.cjs +1 -1
  72. package/dist/index26.js +1 -1
  73. package/dist/index27.cjs +1 -1
  74. package/dist/index27.js +1 -1
  75. package/dist/index28.cjs +1 -1
  76. package/dist/index28.js +1 -1
  77. package/dist/index29.cjs +1 -1
  78. package/dist/index29.js +1 -1
  79. package/dist/index30.cjs +1 -1
  80. package/dist/index30.js +1 -1
  81. package/dist/index31.cjs +1 -1
  82. package/dist/index31.js +1 -1
  83. package/dist/index32.cjs +1 -1
  84. package/dist/index32.js +1 -1
  85. package/dist/index33.cjs +1 -1
  86. package/dist/index33.js +1 -1
  87. package/dist/index34.cjs +1 -1
  88. package/dist/index34.js +1 -1
  89. package/dist/index36.cjs +90 -119
  90. package/dist/index36.js +91 -120
  91. package/dist/index37.cjs +113 -0
  92. package/dist/index37.js +113 -0
  93. package/dist/index38.cjs +169 -0
  94. package/dist/index38.js +169 -0
  95. package/dist/index39.cjs +97 -0
  96. package/dist/index39.js +97 -0
  97. package/dist/index40.cjs +90 -0
  98. package/dist/index40.js +90 -0
  99. package/dist/index41.cjs +139 -0
  100. package/dist/index41.js +139 -0
  101. package/dist/index42.cjs +82 -0
  102. package/dist/index42.js +82 -0
  103. package/dist/index43.cjs +110 -0
  104. package/dist/index43.js +110 -0
  105. package/dist/index44.cjs +135 -0
  106. package/dist/index44.js +135 -0
  107. package/dist/index45.cjs +106 -0
  108. package/dist/index45.js +106 -0
  109. package/dist/index46.cjs +158 -0
  110. package/dist/index46.js +158 -0
  111. package/dist/index47.cjs +125 -0
  112. package/dist/index47.js +125 -0
  113. package/dist/index7.cjs +1 -1
  114. package/dist/index7.js +1 -1
  115. package/dist/index8.cjs +1 -1
  116. package/dist/index8.js +1 -1
  117. package/dist/index9.cjs +1 -1
  118. package/dist/index9.js +1 -1
  119. package/dist/premium-react-loaders.css +217 -0
  120. package/dist/types/bounce.d.ts +41 -0
  121. package/dist/types/bounce.d.ts.map +1 -0
  122. package/dist/types/hooks.d.ts +4 -0
  123. package/dist/types/hooks.d.ts.map +1 -1
  124. package/dist/types/index.d.ts +5 -0
  125. package/dist/types/index.d.ts.map +1 -1
  126. package/dist/types/infinity.d.ts +35 -0
  127. package/dist/types/infinity.d.ts.map +1 -0
  128. package/dist/types/orbit.d.ts +50 -0
  129. package/dist/types/orbit.d.ts.map +1 -0
  130. package/dist/types/shimmer.d.ts +52 -0
  131. package/dist/types/shimmer.d.ts.map +1 -0
  132. package/dist/types/text.d.ts +27 -0
  133. package/dist/types/text.d.ts.map +1 -0
  134. package/package.json +1 -1
package/dist/index36.js CHANGED
@@ -1,125 +1,96 @@
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);
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
- if (minDurationTimerRef.current) {
106
- clearTimeout(minDurationTimerRef.current);
107
- }
108
- if (transitionTimerRef.current) {
109
- clearTimeout(transitionTimerRef.current);
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
- }, [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
- }
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
- getEffectiveDuration,
123
- useLoaderVisibility,
124
- useReducedMotion
95
+ ShimmerBox
125
96
  };
@@ -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;
@@ -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
+ };
@@ -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;