premium-react-loaders 3.0.0 → 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 (153) hide show
  1. package/README.md +45 -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/index.d.ts +3 -0
  19. package/dist/components/index.d.ts.map +1 -1
  20. package/dist/components/skeleton/DataTableSkeleton.d.ts +25 -0
  21. package/dist/components/skeleton/DataTableSkeleton.d.ts.map +1 -0
  22. package/dist/components/skeleton/SmartSkeleton.d.ts +23 -0
  23. package/dist/components/skeleton/SmartSkeleton.d.ts.map +1 -0
  24. package/dist/components/skeleton/index.d.ts +2 -0
  25. package/dist/components/skeleton/index.d.ts.map +1 -1
  26. package/dist/components/smart/FormFieldLoader.d.ts +22 -0
  27. package/dist/components/smart/FormFieldLoader.d.ts.map +1 -0
  28. package/dist/components/smart/index.d.ts +2 -0
  29. package/dist/components/smart/index.d.ts.map +1 -0
  30. package/dist/hooks/index.d.ts +6 -0
  31. package/dist/hooks/index.d.ts.map +1 -1
  32. package/dist/hooks/useLoadingAnalytics.d.ts +101 -0
  33. package/dist/hooks/useLoadingAnalytics.d.ts.map +1 -0
  34. package/dist/hooks/useLoadingOrchestrator.d.ts +104 -0
  35. package/dist/hooks/useLoadingOrchestrator.d.ts.map +1 -0
  36. package/dist/hooks/useSmartLoader.d.ts +98 -0
  37. package/dist/hooks/useSmartLoader.d.ts.map +1 -0
  38. package/dist/index.cjs +49 -31
  39. package/dist/index.js +49 -31
  40. package/dist/index10.cjs +1 -1
  41. package/dist/index10.js +1 -1
  42. package/dist/index11.cjs +1 -1
  43. package/dist/index11.js +1 -1
  44. package/dist/index12.cjs +1 -1
  45. package/dist/index12.js +1 -1
  46. package/dist/index13.cjs +1 -1
  47. package/dist/index13.js +1 -1
  48. package/dist/index14.cjs +1 -1
  49. package/dist/index14.js +1 -1
  50. package/dist/index15.cjs +1 -1
  51. package/dist/index15.js +1 -1
  52. package/dist/index16.cjs +131 -66
  53. package/dist/index16.js +132 -67
  54. package/dist/index17.cjs +245 -30
  55. package/dist/index17.js +246 -31
  56. package/dist/index18.cjs +24 -36
  57. package/dist/index18.js +24 -36
  58. package/dist/index19.cjs +19 -21
  59. package/dist/index19.js +19 -21
  60. package/dist/index20.cjs +25 -20
  61. package/dist/index20.js +25 -20
  62. package/dist/index21.cjs +22 -32
  63. package/dist/index21.js +22 -32
  64. package/dist/index22.cjs +26 -35
  65. package/dist/index22.js +28 -37
  66. package/dist/index23.cjs +40 -76
  67. package/dist/index23.js +42 -78
  68. package/dist/index24.cjs +53 -102
  69. package/dist/index24.js +54 -103
  70. package/dist/index25.cjs +46 -80
  71. package/dist/index25.js +47 -81
  72. package/dist/index26.cjs +105 -103
  73. package/dist/index26.js +107 -105
  74. package/dist/index27.cjs +108 -27
  75. package/dist/index27.js +111 -30
  76. package/dist/index28.cjs +104 -36
  77. package/dist/index28.js +106 -38
  78. package/dist/index29.cjs +22 -30
  79. package/dist/index29.js +23 -31
  80. package/dist/index30.cjs +30 -32
  81. package/dist/index30.js +31 -33
  82. package/dist/index31.cjs +49 -52
  83. package/dist/index31.js +50 -53
  84. package/dist/index32.cjs +37 -108
  85. package/dist/index32.js +38 -109
  86. package/dist/index33.cjs +54 -72
  87. package/dist/index33.js +55 -73
  88. package/dist/index34.cjs +112 -80
  89. package/dist/index34.js +112 -80
  90. package/dist/index35.cjs +78 -145
  91. package/dist/index35.js +80 -147
  92. package/dist/index36.cjs +78 -57
  93. package/dist/index36.js +79 -58
  94. package/dist/index37.cjs +138 -84
  95. package/dist/index37.js +140 -86
  96. package/dist/index38.cjs +33 -106
  97. package/dist/index38.js +34 -107
  98. package/dist/index39.cjs +66 -50
  99. package/dist/index39.js +66 -50
  100. package/dist/index40.cjs +123 -44
  101. package/dist/index40.js +124 -45
  102. package/dist/index41.cjs +43 -85
  103. package/dist/index41.js +44 -86
  104. package/dist/index42.cjs +35 -27
  105. package/dist/index42.js +35 -27
  106. package/dist/index43.cjs +87 -58
  107. package/dist/index43.js +87 -58
  108. package/dist/index44.cjs +35 -88
  109. package/dist/index44.js +36 -89
  110. package/dist/index45.cjs +62 -58
  111. package/dist/index45.js +63 -59
  112. package/dist/index46.cjs +87 -110
  113. package/dist/index46.js +88 -111
  114. package/dist/index47.cjs +101 -120
  115. package/dist/index47.js +102 -121
  116. package/dist/index48.cjs +158 -0
  117. package/dist/index48.js +158 -0
  118. package/dist/index49.cjs +167 -0
  119. package/dist/index49.js +167 -0
  120. package/dist/index50.cjs +110 -0
  121. package/dist/index50.js +110 -0
  122. package/dist/index51.cjs +112 -0
  123. package/dist/index51.js +112 -0
  124. package/dist/index52.cjs +144 -0
  125. package/dist/index52.js +144 -0
  126. package/dist/index53.cjs +112 -0
  127. package/dist/index53.js +112 -0
  128. package/dist/index54.cjs +189 -0
  129. package/dist/index54.js +189 -0
  130. package/dist/index55.cjs +53 -0
  131. package/dist/index55.js +53 -0
  132. package/dist/index56.cjs +125 -0
  133. package/dist/index56.js +125 -0
  134. package/dist/index7.cjs +1 -1
  135. package/dist/index7.js +1 -1
  136. package/dist/index8.cjs +1 -1
  137. package/dist/index8.js +1 -1
  138. package/dist/index9.cjs +1 -1
  139. package/dist/index9.js +1 -1
  140. package/dist/premium-react-loaders.css +140 -0
  141. package/dist/types/3d.d.ts +85 -0
  142. package/dist/types/3d.d.ts.map +1 -0
  143. package/dist/types/accessibility.d.ts +35 -0
  144. package/dist/types/accessibility.d.ts.map +1 -0
  145. package/dist/types/index.d.ts +3 -0
  146. package/dist/types/index.d.ts.map +1 -1
  147. package/dist/types/smart.d.ts +63 -0
  148. package/dist/types/smart.d.ts.map +1 -0
  149. package/dist/utils/accessibility.d.ts +67 -0
  150. package/dist/utils/accessibility.d.ts.map +1 -0
  151. package/dist/utils/index.d.ts +1 -0
  152. package/dist/utils/index.d.ts.map +1 -1
  153. package/package.json +1 -1
package/dist/index47.cjs CHANGED
@@ -1,125 +1,106 @@
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 colors = require("./index4.cjs");
7
+ const classNames = require("./index3.cjs");
8
+ const MobiusLoader = react.forwardRef(
9
+ ({
10
+ size = "md",
11
+ color = "#3b82f6",
12
+ secondaryColor,
13
+ thickness = 2,
14
+ segments = 6,
15
+ twist = true,
16
+ ribbonWidth = 8,
17
+ speed = "normal",
18
+ reverse = false,
19
+ respectMotionPreference = true,
20
+ delay = 0,
21
+ minDuration = 0,
22
+ transition,
23
+ className,
24
+ style,
25
+ testId = "mobius-loader",
26
+ visible = true,
27
+ ariaLabel = "Loading...",
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 normalizedSize = colors.normalizeSize(size);
40
+ const sizeNum = parseInt(normalizedSize, 10);
41
+ const durationNum = parseInt(effectiveDuration, 10);
42
+ const centerX = sizeNum / 2;
43
+ const centerY = sizeNum / 2;
44
+ const radiusX = (sizeNum - ribbonWidth) / 2;
45
+ const radiusY = (sizeNum - ribbonWidth) / 3;
46
+ return /* @__PURE__ */ jsxRuntime.jsx(
47
+ "div",
48
+ {
49
+ ref,
50
+ "data-testid": testId,
51
+ className: classNames.cn("inline-flex items-center justify-center", className),
52
+ style: {
53
+ width: normalizedSize,
54
+ height: normalizedSize,
55
+ opacity,
56
+ transition: transitionStyle,
57
+ ...style
58
+ },
59
+ role: "status",
60
+ "aria-label": ariaLabel,
61
+ "aria-busy": "true",
62
+ ...rest,
63
+ children: /* @__PURE__ */ jsxRuntime.jsx(
64
+ "div",
65
+ {
66
+ className: "relative w-full h-full",
67
+ style: {
68
+ animation: `mobius-rotate ${durationNum}ms linear infinite`,
69
+ animationDirection: reverse ? "reverse" : "normal"
70
+ },
71
+ children: Array.from({ length: segments }, (_, index) => {
72
+ const angle = 360 / segments * index;
73
+ const radians = angle * Math.PI / 180;
74
+ const x = centerX + radiusX * Math.cos(radians);
75
+ const y = centerY + radiusY * Math.sin(radians);
76
+ const twistAngle = twist ? angle + 90 : 90;
77
+ const segmentOpacity = 0.3 + 0.7 * (index / segments);
78
+ const segmentColor = secondaryColor && index % 2 === 0 ? secondaryColor : color;
79
+ return /* @__PURE__ */ jsxRuntime.jsx(
80
+ "div",
81
+ {
82
+ className: "absolute",
83
+ style: {
84
+ width: ribbonWidth,
85
+ height: thickness,
86
+ backgroundColor: segmentColor,
87
+ borderRadius: thickness / 2,
88
+ left: x - ribbonWidth / 2,
89
+ top: y - thickness / 2,
90
+ transform: `rotate(${twistAngle}deg)`,
91
+ opacity: segmentOpacity,
92
+ animation: `mobius-segment ${durationNum}ms ease-in-out infinite`,
93
+ animationDelay: `${index / segments * durationNum}ms`
94
+ }
95
+ },
96
+ index
97
+ );
98
+ })
69
99
  }
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);
100
+ )
106
101
  }
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;
102
+ );
103
+ }
104
+ );
105
+ MobiusLoader.displayName = "MobiusLoader";
106
+ exports.MobiusLoader = MobiusLoader;
package/dist/index47.js CHANGED
@@ -1,125 +1,106 @@
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 } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index56.js";
4
+ import { normalizeSize } from "./index4.js";
5
+ import { cn } from "./index3.js";
6
+ const MobiusLoader = forwardRef(
7
+ ({
8
+ size = "md",
9
+ color = "#3b82f6",
10
+ secondaryColor,
11
+ thickness = 2,
12
+ segments = 6,
13
+ twist = true,
14
+ ribbonWidth = 8,
15
+ speed = "normal",
16
+ reverse = false,
17
+ respectMotionPreference = true,
18
+ delay = 0,
19
+ minDuration = 0,
20
+ transition,
21
+ className,
22
+ style,
23
+ testId = "mobius-loader",
24
+ visible = true,
25
+ ariaLabel = "Loading...",
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 normalizedSize = normalizeSize(size);
38
+ const sizeNum = parseInt(normalizedSize, 10);
39
+ const durationNum = parseInt(effectiveDuration, 10);
40
+ const centerX = sizeNum / 2;
41
+ const centerY = sizeNum / 2;
42
+ const radiusX = (sizeNum - ribbonWidth) / 2;
43
+ const radiusY = (sizeNum - ribbonWidth) / 3;
44
+ return /* @__PURE__ */ jsx(
45
+ "div",
46
+ {
47
+ ref,
48
+ "data-testid": testId,
49
+ className: cn("inline-flex items-center justify-center", className),
50
+ style: {
51
+ width: normalizedSize,
52
+ height: normalizedSize,
53
+ opacity,
54
+ transition: transitionStyle,
55
+ ...style
56
+ },
57
+ role: "status",
58
+ "aria-label": ariaLabel,
59
+ "aria-busy": "true",
60
+ ...rest,
61
+ children: /* @__PURE__ */ jsx(
62
+ "div",
63
+ {
64
+ className: "relative w-full h-full",
65
+ style: {
66
+ animation: `mobius-rotate ${durationNum}ms linear infinite`,
67
+ animationDirection: reverse ? "reverse" : "normal"
68
+ },
69
+ children: Array.from({ length: segments }, (_, index) => {
70
+ const angle = 360 / segments * index;
71
+ const radians = angle * Math.PI / 180;
72
+ const x = centerX + radiusX * Math.cos(radians);
73
+ const y = centerY + radiusY * Math.sin(radians);
74
+ const twistAngle = twist ? angle + 90 : 90;
75
+ const segmentOpacity = 0.3 + 0.7 * (index / segments);
76
+ const segmentColor = secondaryColor && index % 2 === 0 ? secondaryColor : color;
77
+ return /* @__PURE__ */ jsx(
78
+ "div",
79
+ {
80
+ className: "absolute",
81
+ style: {
82
+ width: ribbonWidth,
83
+ height: thickness,
84
+ backgroundColor: segmentColor,
85
+ borderRadius: thickness / 2,
86
+ left: x - ribbonWidth / 2,
87
+ top: y - thickness / 2,
88
+ transform: `rotate(${twistAngle}deg)`,
89
+ opacity: segmentOpacity,
90
+ animation: `mobius-segment ${durationNum}ms ease-in-out infinite`,
91
+ animationDelay: `${index / segments * durationNum}ms`
92
+ }
93
+ },
94
+ index
95
+ );
96
+ })
67
97
  }
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);
98
+ )
104
99
  }
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
- }
100
+ );
101
+ }
102
+ );
103
+ MobiusLoader.displayName = "MobiusLoader";
121
104
  export {
122
- getEffectiveDuration,
123
- useLoaderVisibility,
124
- useReducedMotion
105
+ MobiusLoader
125
106
  };
@@ -0,0 +1,158 @@
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("./index56.cjs");
6
+ const classNames = require("./index3.cjs");
7
+ const LoadingText = react.forwardRef(
8
+ ({
9
+ text = "Loading",
10
+ animation = "dots",
11
+ fontSize = 16,
12
+ fontWeight = 500,
13
+ color = "#374151",
14
+ dotCount = 3,
15
+ showEllipsis = true,
16
+ textClassName,
17
+ speed = "normal",
18
+ respectMotionPreference = true,
19
+ delay = 0,
20
+ minDuration = 0,
21
+ transition,
22
+ className,
23
+ style,
24
+ testId = "loading-text",
25
+ visible = true,
26
+ ariaLabel,
27
+ ...rest
28
+ }, ref) => {
29
+ const prefersReducedMotion = hooks.useReducedMotion();
30
+ const effectiveDuration = hooks.getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion);
31
+ const { shouldRender, opacity, transitionStyle } = hooks.useLoaderVisibility(
32
+ visible,
33
+ delay,
34
+ minDuration,
35
+ transition
36
+ );
37
+ if (!shouldRender) return null;
38
+ const durationNum = parseInt(effectiveDuration, 10);
39
+ const normalizedFontSize = typeof fontSize === "number" ? `${fontSize}px` : fontSize;
40
+ const renderDots = () => {
41
+ if (!showEllipsis) return null;
42
+ switch (animation) {
43
+ case "dots":
44
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex", children: Array.from({ length: dotCount }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx(
45
+ "span",
46
+ {
47
+ style: {
48
+ animation: `loading-text-dot ${durationNum}ms ease-in-out infinite`,
49
+ animationDelay: `${index * (durationNum / dotCount / 2)}ms`
50
+ },
51
+ children: "."
52
+ },
53
+ index
54
+ )) });
55
+ case "fade":
56
+ return /* @__PURE__ */ jsxRuntime.jsx(
57
+ "span",
58
+ {
59
+ style: {
60
+ animation: `loading-text-fade ${durationNum}ms ease-in-out infinite`
61
+ },
62
+ children: "..."
63
+ }
64
+ );
65
+ case "bounce":
66
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex", children: Array.from({ length: dotCount }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx(
67
+ "span",
68
+ {
69
+ className: "inline-block",
70
+ style: {
71
+ animation: `loading-text-bounce ${durationNum}ms ease-in-out infinite`,
72
+ animationDelay: `${index * (durationNum / dotCount / 2)}ms`
73
+ },
74
+ children: "."
75
+ },
76
+ index
77
+ )) });
78
+ case "wave":
79
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex", children: Array.from({ length: dotCount }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx(
80
+ "span",
81
+ {
82
+ className: "inline-block",
83
+ style: {
84
+ animation: `loading-text-wave ${durationNum}ms ease-in-out infinite`,
85
+ animationDelay: `${index * (durationNum / dotCount / 1.5)}ms`
86
+ },
87
+ children: "."
88
+ },
89
+ index
90
+ )) });
91
+ default:
92
+ return "...";
93
+ }
94
+ };
95
+ const renderText = () => {
96
+ if (animation === "wave" || animation === "bounce") {
97
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: text.split("").map((char, index) => /* @__PURE__ */ jsxRuntime.jsx(
98
+ "span",
99
+ {
100
+ className: "inline-block",
101
+ style: {
102
+ animation: `loading-text-${animation} ${durationNum}ms ease-in-out infinite`,
103
+ animationDelay: `${index * 50}ms`
104
+ },
105
+ children: char === " " ? " " : char
106
+ },
107
+ index
108
+ )) });
109
+ }
110
+ if (animation === "fade") {
111
+ return /* @__PURE__ */ jsxRuntime.jsx(
112
+ "span",
113
+ {
114
+ style: {
115
+ animation: `loading-text-fade ${durationNum}ms ease-in-out infinite`
116
+ },
117
+ children: text
118
+ }
119
+ );
120
+ }
121
+ return text;
122
+ };
123
+ return /* @__PURE__ */ jsxRuntime.jsx(
124
+ "div",
125
+ {
126
+ ref,
127
+ "data-testid": testId,
128
+ className: classNames.cn("inline-flex items-center", className),
129
+ style: {
130
+ opacity,
131
+ transition: transitionStyle,
132
+ ...style
133
+ },
134
+ role: "status",
135
+ "aria-label": ariaLabel || `${text}...`,
136
+ "aria-busy": "true",
137
+ ...rest,
138
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
139
+ "span",
140
+ {
141
+ className: classNames.cn("inline-flex items-baseline", textClassName),
142
+ style: {
143
+ fontSize: normalizedFontSize,
144
+ fontWeight,
145
+ color
146
+ },
147
+ children: [
148
+ renderText(),
149
+ renderDots()
150
+ ]
151
+ }
152
+ )
153
+ }
154
+ );
155
+ }
156
+ );
157
+ LoadingText.displayName = "LoadingText";
158
+ exports.LoadingText = LoadingText;