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.
- package/README.md +45 -3
- package/dist/components/3d/CubeSpinner.d.ts +21 -0
- package/dist/components/3d/CubeSpinner.d.ts.map +1 -0
- package/dist/components/3d/FlipCard.d.ts +21 -0
- package/dist/components/3d/FlipCard.d.ts.map +1 -0
- package/dist/components/3d/Helix.d.ts +23 -0
- package/dist/components/3d/Helix.d.ts.map +1 -0
- package/dist/components/3d/PerspectiveRing.d.ts +21 -0
- package/dist/components/3d/PerspectiveRing.d.ts.map +1 -0
- package/dist/components/3d/PlaneRotate.d.ts +21 -0
- package/dist/components/3d/PlaneRotate.d.ts.map +1 -0
- package/dist/components/3d/index.d.ts +6 -0
- package/dist/components/3d/index.d.ts.map +1 -0
- package/dist/components/accessibility/LiveRegion.d.ts +34 -0
- package/dist/components/accessibility/LiveRegion.d.ts.map +1 -0
- package/dist/components/accessibility/index.d.ts +2 -0
- package/dist/components/accessibility/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/skeleton/DataTableSkeleton.d.ts +25 -0
- package/dist/components/skeleton/DataTableSkeleton.d.ts.map +1 -0
- package/dist/components/skeleton/SmartSkeleton.d.ts +23 -0
- package/dist/components/skeleton/SmartSkeleton.d.ts.map +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.d.ts.map +1 -1
- package/dist/components/smart/FormFieldLoader.d.ts +22 -0
- package/dist/components/smart/FormFieldLoader.d.ts.map +1 -0
- package/dist/components/smart/index.d.ts +2 -0
- package/dist/components/smart/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useLoadingAnalytics.d.ts +101 -0
- package/dist/hooks/useLoadingAnalytics.d.ts.map +1 -0
- package/dist/hooks/useLoadingOrchestrator.d.ts +104 -0
- package/dist/hooks/useLoadingOrchestrator.d.ts.map +1 -0
- package/dist/hooks/useSmartLoader.d.ts +98 -0
- package/dist/hooks/useSmartLoader.d.ts.map +1 -0
- package/dist/index.cjs +49 -31
- package/dist/index.js +49 -31
- 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 +131 -66
- package/dist/index16.js +132 -67
- package/dist/index17.cjs +245 -30
- package/dist/index17.js +246 -31
- package/dist/index18.cjs +24 -36
- package/dist/index18.js +24 -36
- package/dist/index19.cjs +19 -21
- package/dist/index19.js +19 -21
- package/dist/index20.cjs +25 -20
- package/dist/index20.js +25 -20
- package/dist/index21.cjs +22 -32
- package/dist/index21.js +22 -32
- package/dist/index22.cjs +26 -35
- package/dist/index22.js +28 -37
- package/dist/index23.cjs +40 -76
- package/dist/index23.js +42 -78
- package/dist/index24.cjs +53 -102
- package/dist/index24.js +54 -103
- package/dist/index25.cjs +46 -80
- package/dist/index25.js +47 -81
- package/dist/index26.cjs +105 -103
- package/dist/index26.js +107 -105
- package/dist/index27.cjs +108 -27
- package/dist/index27.js +111 -30
- package/dist/index28.cjs +104 -36
- package/dist/index28.js +106 -38
- package/dist/index29.cjs +22 -30
- package/dist/index29.js +23 -31
- package/dist/index30.cjs +30 -32
- package/dist/index30.js +31 -33
- package/dist/index31.cjs +49 -52
- package/dist/index31.js +50 -53
- package/dist/index32.cjs +37 -108
- package/dist/index32.js +38 -109
- package/dist/index33.cjs +54 -72
- package/dist/index33.js +55 -73
- package/dist/index34.cjs +112 -80
- package/dist/index34.js +112 -80
- package/dist/index35.cjs +78 -145
- package/dist/index35.js +80 -147
- package/dist/index36.cjs +78 -57
- package/dist/index36.js +79 -58
- package/dist/index37.cjs +138 -84
- package/dist/index37.js +140 -86
- package/dist/index38.cjs +33 -106
- package/dist/index38.js +34 -107
- package/dist/index39.cjs +66 -50
- package/dist/index39.js +66 -50
- package/dist/index40.cjs +123 -44
- package/dist/index40.js +124 -45
- package/dist/index41.cjs +43 -85
- package/dist/index41.js +44 -86
- package/dist/index42.cjs +35 -27
- package/dist/index42.js +35 -27
- package/dist/index43.cjs +87 -58
- package/dist/index43.js +87 -58
- package/dist/index44.cjs +35 -88
- package/dist/index44.js +36 -89
- package/dist/index45.cjs +62 -58
- package/dist/index45.js +63 -59
- package/dist/index46.cjs +87 -110
- package/dist/index46.js +88 -111
- package/dist/index47.cjs +101 -120
- package/dist/index47.js +102 -121
- package/dist/index48.cjs +158 -0
- package/dist/index48.js +158 -0
- package/dist/index49.cjs +167 -0
- package/dist/index49.js +167 -0
- package/dist/index50.cjs +110 -0
- package/dist/index50.js +110 -0
- package/dist/index51.cjs +112 -0
- package/dist/index51.js +112 -0
- package/dist/index52.cjs +144 -0
- package/dist/index52.js +144 -0
- package/dist/index53.cjs +112 -0
- package/dist/index53.js +112 -0
- package/dist/index54.cjs +189 -0
- package/dist/index54.js +189 -0
- package/dist/index55.cjs +53 -0
- package/dist/index55.js +53 -0
- package/dist/index56.cjs +125 -0
- package/dist/index56.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 +140 -0
- package/dist/types/3d.d.ts +85 -0
- package/dist/types/3d.d.ts.map +1 -0
- package/dist/types/accessibility.d.ts +35 -0
- package/dist/types/accessibility.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/smart.d.ts +63 -0
- package/dist/types/smart.d.ts.map +1 -0
- package/dist/utils/accessibility.d.ts +67 -0
- package/dist/utils/accessibility.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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 {
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
123
|
-
useLoaderVisibility,
|
|
124
|
-
useReducedMotion
|
|
105
|
+
MobiusLoader
|
|
125
106
|
};
|
package/dist/index48.cjs
ADDED
|
@@ -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;
|