premium-react-loaders 2.3.1 → 3.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.
Files changed (195) hide show
  1. package/README.md +87 -3
  2. package/dist/components/3d/CubeSpinner.d.ts +21 -0
  3. package/dist/components/3d/CubeSpinner.d.ts.map +1 -0
  4. package/dist/components/3d/FlipCard.d.ts +21 -0
  5. package/dist/components/3d/FlipCard.d.ts.map +1 -0
  6. package/dist/components/3d/Helix.d.ts +23 -0
  7. package/dist/components/3d/Helix.d.ts.map +1 -0
  8. package/dist/components/3d/PerspectiveRing.d.ts +21 -0
  9. package/dist/components/3d/PerspectiveRing.d.ts.map +1 -0
  10. package/dist/components/3d/PlaneRotate.d.ts +21 -0
  11. package/dist/components/3d/PlaneRotate.d.ts.map +1 -0
  12. package/dist/components/3d/index.d.ts +6 -0
  13. package/dist/components/3d/index.d.ts.map +1 -0
  14. package/dist/components/accessibility/LiveRegion.d.ts +34 -0
  15. package/dist/components/accessibility/LiveRegion.d.ts.map +1 -0
  16. package/dist/components/accessibility/index.d.ts +2 -0
  17. package/dist/components/accessibility/index.d.ts.map +1 -0
  18. package/dist/components/bounce/BouncingBalls.d.ts +15 -0
  19. package/dist/components/bounce/BouncingBalls.d.ts.map +1 -0
  20. package/dist/components/bounce/BouncingDots.d.ts +15 -0
  21. package/dist/components/bounce/BouncingDots.d.ts.map +1 -0
  22. package/dist/components/bounce/index.d.ts +3 -0
  23. package/dist/components/bounce/index.d.ts.map +1 -0
  24. package/dist/components/index.d.ts +8 -0
  25. package/dist/components/index.d.ts.map +1 -1
  26. package/dist/components/infinity/InfinityLoader.d.ts +15 -0
  27. package/dist/components/infinity/InfinityLoader.d.ts.map +1 -0
  28. package/dist/components/infinity/MobiusLoader.d.ts +15 -0
  29. package/dist/components/infinity/MobiusLoader.d.ts.map +1 -0
  30. package/dist/components/infinity/index.d.ts +3 -0
  31. package/dist/components/infinity/index.d.ts.map +1 -0
  32. package/dist/components/orbit/AtomLoader.d.ts +15 -0
  33. package/dist/components/orbit/AtomLoader.d.ts.map +1 -0
  34. package/dist/components/orbit/OrbitDots.d.ts +15 -0
  35. package/dist/components/orbit/OrbitDots.d.ts.map +1 -0
  36. package/dist/components/orbit/OrbitRings.d.ts +15 -0
  37. package/dist/components/orbit/OrbitRings.d.ts.map +1 -0
  38. package/dist/components/orbit/index.d.ts +4 -0
  39. package/dist/components/orbit/index.d.ts.map +1 -0
  40. package/dist/components/shimmer/ShimmerBox.d.ts +15 -0
  41. package/dist/components/shimmer/ShimmerBox.d.ts.map +1 -0
  42. package/dist/components/shimmer/ShimmerButton.d.ts +15 -0
  43. package/dist/components/shimmer/ShimmerButton.d.ts.map +1 -0
  44. package/dist/components/shimmer/ShimmerText.d.ts +15 -0
  45. package/dist/components/shimmer/ShimmerText.d.ts.map +1 -0
  46. package/dist/components/shimmer/index.d.ts +4 -0
  47. package/dist/components/shimmer/index.d.ts.map +1 -0
  48. package/dist/components/skeleton/DataTableSkeleton.d.ts +25 -0
  49. package/dist/components/skeleton/DataTableSkeleton.d.ts.map +1 -0
  50. package/dist/components/skeleton/SmartSkeleton.d.ts +23 -0
  51. package/dist/components/skeleton/SmartSkeleton.d.ts.map +1 -0
  52. package/dist/components/skeleton/index.d.ts +2 -0
  53. package/dist/components/skeleton/index.d.ts.map +1 -1
  54. package/dist/components/smart/FormFieldLoader.d.ts +22 -0
  55. package/dist/components/smart/FormFieldLoader.d.ts.map +1 -0
  56. package/dist/components/smart/index.d.ts +2 -0
  57. package/dist/components/smart/index.d.ts.map +1 -0
  58. package/dist/components/text/LoadingText.d.ts +16 -0
  59. package/dist/components/text/LoadingText.d.ts.map +1 -0
  60. package/dist/components/text/index.d.ts +2 -0
  61. package/dist/components/text/index.d.ts.map +1 -0
  62. package/dist/hooks/index.d.ts +6 -0
  63. package/dist/hooks/index.d.ts.map +1 -1
  64. package/dist/hooks/useLoadingAnalytics.d.ts +101 -0
  65. package/dist/hooks/useLoadingAnalytics.d.ts.map +1 -0
  66. package/dist/hooks/useLoadingOrchestrator.d.ts +104 -0
  67. package/dist/hooks/useLoadingOrchestrator.d.ts.map +1 -0
  68. package/dist/hooks/useSmartLoader.d.ts +98 -0
  69. package/dist/hooks/useSmartLoader.d.ts.map +1 -0
  70. package/dist/index.cjs +60 -20
  71. package/dist/index.js +60 -20
  72. package/dist/index10.cjs +1 -1
  73. package/dist/index10.js +1 -1
  74. package/dist/index11.cjs +1 -1
  75. package/dist/index11.js +1 -1
  76. package/dist/index12.cjs +1 -1
  77. package/dist/index12.js +1 -1
  78. package/dist/index13.cjs +1 -1
  79. package/dist/index13.js +1 -1
  80. package/dist/index14.cjs +1 -1
  81. package/dist/index14.js +1 -1
  82. package/dist/index15.cjs +1 -1
  83. package/dist/index15.js +1 -1
  84. package/dist/index16.cjs +131 -66
  85. package/dist/index16.js +132 -67
  86. package/dist/index17.cjs +245 -30
  87. package/dist/index17.js +246 -31
  88. package/dist/index18.cjs +24 -36
  89. package/dist/index18.js +24 -36
  90. package/dist/index19.cjs +19 -21
  91. package/dist/index19.js +19 -21
  92. package/dist/index20.cjs +25 -20
  93. package/dist/index20.js +25 -20
  94. package/dist/index21.cjs +22 -32
  95. package/dist/index21.js +22 -32
  96. package/dist/index22.cjs +26 -35
  97. package/dist/index22.js +28 -37
  98. package/dist/index23.cjs +40 -76
  99. package/dist/index23.js +42 -78
  100. package/dist/index24.cjs +53 -102
  101. package/dist/index24.js +54 -103
  102. package/dist/index25.cjs +46 -80
  103. package/dist/index25.js +47 -81
  104. package/dist/index26.cjs +105 -103
  105. package/dist/index26.js +107 -105
  106. package/dist/index27.cjs +108 -27
  107. package/dist/index27.js +111 -30
  108. package/dist/index28.cjs +104 -36
  109. package/dist/index28.js +106 -38
  110. package/dist/index29.cjs +22 -30
  111. package/dist/index29.js +23 -31
  112. package/dist/index30.cjs +30 -32
  113. package/dist/index30.js +31 -33
  114. package/dist/index31.cjs +49 -52
  115. package/dist/index31.js +50 -53
  116. package/dist/index32.cjs +37 -108
  117. package/dist/index32.js +38 -109
  118. package/dist/index33.cjs +54 -72
  119. package/dist/index33.js +55 -73
  120. package/dist/index34.cjs +112 -80
  121. package/dist/index34.js +112 -80
  122. package/dist/index35.cjs +78 -145
  123. package/dist/index35.js +80 -147
  124. package/dist/index36.cjs +112 -120
  125. package/dist/index36.js +113 -121
  126. package/dist/index37.cjs +167 -0
  127. package/dist/index37.js +167 -0
  128. package/dist/index38.cjs +96 -0
  129. package/dist/index38.js +96 -0
  130. package/dist/index39.cjs +113 -0
  131. package/dist/index39.js +113 -0
  132. package/dist/index40.cjs +169 -0
  133. package/dist/index40.js +169 -0
  134. package/dist/index41.cjs +97 -0
  135. package/dist/index41.js +97 -0
  136. package/dist/index42.cjs +90 -0
  137. package/dist/index42.js +90 -0
  138. package/dist/index43.cjs +139 -0
  139. package/dist/index43.js +139 -0
  140. package/dist/index44.cjs +82 -0
  141. package/dist/index44.js +82 -0
  142. package/dist/index45.cjs +110 -0
  143. package/dist/index45.js +110 -0
  144. package/dist/index46.cjs +135 -0
  145. package/dist/index46.js +135 -0
  146. package/dist/index47.cjs +106 -0
  147. package/dist/index47.js +106 -0
  148. package/dist/index48.cjs +158 -0
  149. package/dist/index48.js +158 -0
  150. package/dist/index49.cjs +167 -0
  151. package/dist/index49.js +167 -0
  152. package/dist/index50.cjs +110 -0
  153. package/dist/index50.js +110 -0
  154. package/dist/index51.cjs +112 -0
  155. package/dist/index51.js +112 -0
  156. package/dist/index52.cjs +144 -0
  157. package/dist/index52.js +144 -0
  158. package/dist/index53.cjs +112 -0
  159. package/dist/index53.js +112 -0
  160. package/dist/index54.cjs +189 -0
  161. package/dist/index54.js +189 -0
  162. package/dist/index55.cjs +53 -0
  163. package/dist/index55.js +53 -0
  164. package/dist/index56.cjs +125 -0
  165. package/dist/index56.js +125 -0
  166. package/dist/index7.cjs +1 -1
  167. package/dist/index7.js +1 -1
  168. package/dist/index8.cjs +1 -1
  169. package/dist/index8.js +1 -1
  170. package/dist/index9.cjs +1 -1
  171. package/dist/index9.js +1 -1
  172. package/dist/premium-react-loaders.css +357 -0
  173. package/dist/types/3d.d.ts +85 -0
  174. package/dist/types/3d.d.ts.map +1 -0
  175. package/dist/types/accessibility.d.ts +35 -0
  176. package/dist/types/accessibility.d.ts.map +1 -0
  177. package/dist/types/bounce.d.ts +41 -0
  178. package/dist/types/bounce.d.ts.map +1 -0
  179. package/dist/types/index.d.ts +8 -0
  180. package/dist/types/index.d.ts.map +1 -1
  181. package/dist/types/infinity.d.ts +35 -0
  182. package/dist/types/infinity.d.ts.map +1 -0
  183. package/dist/types/orbit.d.ts +50 -0
  184. package/dist/types/orbit.d.ts.map +1 -0
  185. package/dist/types/shimmer.d.ts +52 -0
  186. package/dist/types/shimmer.d.ts.map +1 -0
  187. package/dist/types/smart.d.ts +63 -0
  188. package/dist/types/smart.d.ts.map +1 -0
  189. package/dist/types/text.d.ts +27 -0
  190. package/dist/types/text.d.ts.map +1 -0
  191. package/dist/utils/accessibility.d.ts +67 -0
  192. package/dist/utils/accessibility.d.ts.map +1 -0
  193. package/dist/utils/index.d.ts +1 -0
  194. package/dist/utils/index.d.ts.map +1 -1
  195. package/package.json +1 -1
package/dist/index36.cjs CHANGED
@@ -1,125 +1,117 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
3
4
  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);
5
+ const hooks = require("./index56.cjs");
6
+ const classNames = require("./index3.cjs");
7
+ const colors = require("./index4.cjs");
8
+ const ErrorIndicator = react.forwardRef(
9
+ ({
10
+ size = "md",
11
+ color = "#ef4444",
12
+ strokeWidth = 3,
13
+ duration = 500,
14
+ showCircle = false,
15
+ circleColor,
16
+ fillCircle = false,
17
+ shake = true,
18
+ delay = 0,
19
+ minDuration = 0,
20
+ transition = true,
21
+ className,
22
+ style,
23
+ testId = "error-indicator",
24
+ visible = true,
25
+ ariaLabel = "Error",
26
+ ...rest
27
+ }, ref) => {
28
+ const { shouldRender, opacity, transitionStyle } = hooks.useLoaderVisibility(
29
+ visible,
30
+ delay,
31
+ minDuration,
32
+ transition
33
+ );
34
+ if (!shouldRender) return null;
35
+ const effectiveCircleColor = circleColor || color;
36
+ const sizeValue = colors.normalizeSize(size);
37
+ return /* @__PURE__ */ jsxRuntime.jsx(
38
+ "div",
39
+ {
40
+ ref,
41
+ "data-testid": testId,
42
+ className: classNames.cn("inline-flex items-center justify-center", className),
43
+ style: {
44
+ ...style,
45
+ opacity,
46
+ transition: transitionStyle
47
+ },
48
+ role: "status",
49
+ "aria-label": ariaLabel,
50
+ ...rest,
51
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
52
+ "svg",
53
+ {
54
+ className: shake ? "animate-error-shake" : "animate-error-scale",
55
+ style: {
56
+ width: sizeValue,
57
+ height: sizeValue,
58
+ animationDuration: `${duration}ms`
59
+ },
60
+ viewBox: "0 0 52 52",
61
+ children: [
62
+ showCircle && /* @__PURE__ */ jsxRuntime.jsx(
63
+ "circle",
64
+ {
65
+ className: "animate-error-circle",
66
+ cx: "26",
67
+ cy: "26",
68
+ r: "23",
69
+ fill: fillCircle ? effectiveCircleColor : "none",
70
+ stroke: effectiveCircleColor,
71
+ strokeWidth,
72
+ style: {
73
+ animationDuration: `${duration}ms`
74
+ }
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsxRuntime.jsxs(
78
+ "g",
79
+ {
80
+ className: "animate-error-x",
81
+ style: {
82
+ animationDuration: `${duration}ms`,
83
+ animationDelay: showCircle ? `${duration * 0.3}ms` : "0ms"
84
+ },
85
+ children: [
86
+ /* @__PURE__ */ jsxRuntime.jsx(
87
+ "path",
88
+ {
89
+ fill: "none",
90
+ stroke: color,
91
+ strokeWidth,
92
+ strokeLinecap: "round",
93
+ d: "M16 16 36 36"
94
+ }
95
+ ),
96
+ /* @__PURE__ */ jsxRuntime.jsx(
97
+ "path",
98
+ {
99
+ fill: "none",
100
+ stroke: color,
101
+ strokeWidth,
102
+ strokeLinecap: "round",
103
+ d: "M36 16 16 36"
104
+ }
105
+ )
106
+ ]
107
+ }
108
+ )
109
+ ]
69
110
  }
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);
111
+ )
106
112
  }
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;
113
+ );
114
+ }
115
+ );
116
+ ErrorIndicator.displayName = "ErrorIndicator";
117
+ exports.ErrorIndicator = ErrorIndicator;
package/dist/index36.js CHANGED
@@ -1,125 +1,117 @@
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);
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useLoaderVisibility } from "./index56.js";
4
+ import { cn } from "./index3.js";
5
+ import { normalizeSize } from "./index4.js";
6
+ const ErrorIndicator = forwardRef(
7
+ ({
8
+ size = "md",
9
+ color = "#ef4444",
10
+ strokeWidth = 3,
11
+ duration = 500,
12
+ showCircle = false,
13
+ circleColor,
14
+ fillCircle = false,
15
+ shake = true,
16
+ delay = 0,
17
+ minDuration = 0,
18
+ transition = true,
19
+ className,
20
+ style,
21
+ testId = "error-indicator",
22
+ visible = true,
23
+ ariaLabel = "Error",
24
+ ...rest
25
+ }, ref) => {
26
+ const { shouldRender, opacity, transitionStyle } = useLoaderVisibility(
27
+ visible,
28
+ delay,
29
+ minDuration,
30
+ transition
31
+ );
32
+ if (!shouldRender) return null;
33
+ const effectiveCircleColor = circleColor || color;
34
+ const sizeValue = normalizeSize(size);
35
+ return /* @__PURE__ */ jsx(
36
+ "div",
37
+ {
38
+ ref,
39
+ "data-testid": testId,
40
+ className: cn("inline-flex items-center justify-center", className),
41
+ style: {
42
+ ...style,
43
+ opacity,
44
+ transition: transitionStyle
45
+ },
46
+ role: "status",
47
+ "aria-label": ariaLabel,
48
+ ...rest,
49
+ children: /* @__PURE__ */ jsxs(
50
+ "svg",
51
+ {
52
+ className: shake ? "animate-error-shake" : "animate-error-scale",
53
+ style: {
54
+ width: sizeValue,
55
+ height: sizeValue,
56
+ animationDuration: `${duration}ms`
57
+ },
58
+ viewBox: "0 0 52 52",
59
+ children: [
60
+ showCircle && /* @__PURE__ */ jsx(
61
+ "circle",
62
+ {
63
+ className: "animate-error-circle",
64
+ cx: "26",
65
+ cy: "26",
66
+ r: "23",
67
+ fill: fillCircle ? effectiveCircleColor : "none",
68
+ stroke: effectiveCircleColor,
69
+ strokeWidth,
70
+ style: {
71
+ animationDuration: `${duration}ms`
72
+ }
73
+ }
74
+ ),
75
+ /* @__PURE__ */ jsxs(
76
+ "g",
77
+ {
78
+ className: "animate-error-x",
79
+ style: {
80
+ animationDuration: `${duration}ms`,
81
+ animationDelay: showCircle ? `${duration * 0.3}ms` : "0ms"
82
+ },
83
+ children: [
84
+ /* @__PURE__ */ jsx(
85
+ "path",
86
+ {
87
+ fill: "none",
88
+ stroke: color,
89
+ strokeWidth,
90
+ strokeLinecap: "round",
91
+ d: "M16 16 36 36"
92
+ }
93
+ ),
94
+ /* @__PURE__ */ jsx(
95
+ "path",
96
+ {
97
+ fill: "none",
98
+ stroke: color,
99
+ strokeWidth,
100
+ strokeLinecap: "round",
101
+ d: "M36 16 16 36"
102
+ }
103
+ )
104
+ ]
105
+ }
106
+ )
107
+ ]
67
108
  }
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);
109
+ )
104
110
  }
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
- }
111
+ );
112
+ }
113
+ );
114
+ ErrorIndicator.displayName = "ErrorIndicator";
121
115
  export {
122
- getEffectiveDuration,
123
- useLoaderVisibility,
124
- useReducedMotion
116
+ ErrorIndicator
125
117
  };
@@ -0,0 +1,167 @@
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 classNames = require("./index3.cjs");
6
+ const LoaderTransition = react.forwardRef(
7
+ ({
8
+ loading,
9
+ loadingContent,
10
+ children,
11
+ transitionType = "fade",
12
+ duration = 300,
13
+ timing = "ease-out",
14
+ keepMounted = false,
15
+ exitDelay = 0,
16
+ appearOnMount = false,
17
+ className,
18
+ style,
19
+ testId = "loader-transition",
20
+ ariaLabel,
21
+ visible = true,
22
+ delay = 0,
23
+ minDuration = 0,
24
+ transition: transitionProp,
25
+ ...rest
26
+ }, ref) => {
27
+ const [isTransitioning, setIsTransitioning] = react.useState(false);
28
+ const [showLoading, setShowLoading] = react.useState(appearOnMount ? loading : false);
29
+ const [showContent, setShowContent] = react.useState(!appearOnMount && !loading);
30
+ const timeoutRef = react.useRef(null);
31
+ const entryTimeRef = react.useRef(null);
32
+ react.useEffect(() => {
33
+ if (!visible) {
34
+ setShowLoading(false);
35
+ setShowContent(false);
36
+ return;
37
+ }
38
+ if (loading) {
39
+ if (timeoutRef.current) {
40
+ clearTimeout(timeoutRef.current);
41
+ }
42
+ if (delay > 0) {
43
+ timeoutRef.current = setTimeout(() => {
44
+ setShowLoading(true);
45
+ setShowContent(false);
46
+ entryTimeRef.current = Date.now();
47
+ }, delay);
48
+ } else {
49
+ setShowLoading(true);
50
+ setShowContent(false);
51
+ entryTimeRef.current = Date.now();
52
+ }
53
+ } else {
54
+ const elapsed = entryTimeRef.current ? Date.now() - entryTimeRef.current : 0;
55
+ const remainingMinDuration = Math.max(0, minDuration - elapsed);
56
+ const totalDelay = exitDelay + remainingMinDuration;
57
+ if (totalDelay > 0) {
58
+ timeoutRef.current = setTimeout(() => {
59
+ setIsTransitioning(true);
60
+ timeoutRef.current = setTimeout(() => {
61
+ setShowLoading(false);
62
+ setShowContent(true);
63
+ setIsTransitioning(false);
64
+ }, duration);
65
+ }, totalDelay);
66
+ } else {
67
+ setIsTransitioning(true);
68
+ timeoutRef.current = setTimeout(() => {
69
+ setShowLoading(false);
70
+ setShowContent(true);
71
+ setIsTransitioning(false);
72
+ }, duration);
73
+ }
74
+ }
75
+ return () => {
76
+ if (timeoutRef.current) {
77
+ clearTimeout(timeoutRef.current);
78
+ }
79
+ };
80
+ }, [loading, visible, delay, minDuration, exitDelay, duration]);
81
+ const getTransitionClasses = (isLoading, isTransition) => {
82
+ const baseClasses = "loader-transition";
83
+ const timingClass = `loader-transition-${timing}`;
84
+ if (transitionType === "none") {
85
+ return baseClasses;
86
+ }
87
+ if (transitionType === "fade") {
88
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-enter-active`;
89
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-exit-active`;
90
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-enter-active`;
91
+ return `${baseClasses} ${timingClass}`;
92
+ }
93
+ if (transitionType === "slide-up") {
94
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-enter-active`;
95
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-exit-active`;
96
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-enter-active`;
97
+ return `${baseClasses} ${timingClass}`;
98
+ }
99
+ if (transitionType === "slide-down") {
100
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-enter-active`;
101
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-exit-active`;
102
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-enter-active`;
103
+ return `${baseClasses} ${timingClass}`;
104
+ }
105
+ if (transitionType === "slide-left") {
106
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-enter-active`;
107
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-exit-active`;
108
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-enter-active`;
109
+ return `${baseClasses} ${timingClass}`;
110
+ }
111
+ if (transitionType === "slide-right") {
112
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-enter-active`;
113
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-exit-active`;
114
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-enter-active`;
115
+ return `${baseClasses} ${timingClass}`;
116
+ }
117
+ if (transitionType === "scale") {
118
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-enter-active`;
119
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-exit-active`;
120
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-enter-active`;
121
+ return `${baseClasses} ${timingClass}`;
122
+ }
123
+ return baseClasses;
124
+ };
125
+ const shouldShowLoading = showLoading || keepMounted && loading;
126
+ const shouldShowContent = showContent || keepMounted && !loading;
127
+ return /* @__PURE__ */ jsxRuntime.jsxs(
128
+ "div",
129
+ {
130
+ ref,
131
+ "data-testid": testId,
132
+ className: classNames.cn("relative", className),
133
+ style,
134
+ role: "status",
135
+ "aria-label": ariaLabel,
136
+ "aria-busy": loading,
137
+ ...rest,
138
+ children: [
139
+ shouldShowLoading && /* @__PURE__ */ jsxRuntime.jsx(
140
+ "div",
141
+ {
142
+ className: getTransitionClasses(true, isTransitioning),
143
+ style: {
144
+ transitionDuration: `${duration}ms`,
145
+ display: showLoading ? "block" : "none"
146
+ },
147
+ children: loadingContent
148
+ }
149
+ ),
150
+ shouldShowContent && /* @__PURE__ */ jsxRuntime.jsx(
151
+ "div",
152
+ {
153
+ className: getTransitionClasses(false, isTransitioning),
154
+ style: {
155
+ transitionDuration: `${duration}ms`,
156
+ display: showContent ? "block" : "none"
157
+ },
158
+ children
159
+ }
160
+ )
161
+ ]
162
+ }
163
+ );
164
+ }
165
+ );
166
+ LoaderTransition.displayName = "LoaderTransition";
167
+ exports.LoaderTransition = LoaderTransition;