premium-react-loaders 2.2.0 → 2.3.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 +83 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/transition/LoaderTransition.d.ts +32 -0
- package/dist/components/transition/LoaderTransition.d.ts.map +1 -0
- package/dist/components/transition/index.d.ts +2 -0
- package/dist/components/transition/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useEnhancedLoader.d.ts +62 -0
- package/dist/hooks/useEnhancedLoader.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.js +2 -0
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +1 -1
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +1 -1
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +1 -1
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +1 -1
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +1 -1
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +1 -1
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +1 -1
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +1 -1
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +1 -1
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +1 -1
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +1 -1
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +1 -1
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +1 -1
- package/dist/index35.cjs +153 -111
- package/dist/index35.js +154 -112
- package/dist/index36.cjs +125 -0
- package/dist/index36.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 +75 -0
- package/dist/types/hooks.d.ts +95 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/transition.d.ts +34 -0
- package/dist/types/transition.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index29.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const hooks = require("./
|
|
5
|
+
const hooks = require("./index36.cjs");
|
|
6
6
|
const colors = require("./index4.cjs");
|
|
7
7
|
const classNames = require("./index3.cjs");
|
|
8
8
|
const PulseBars = react.forwardRef(
|
package/dist/index29.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index36.js";
|
|
4
4
|
import { normalizeSize, parseSizeToNumber } from "./index4.js";
|
|
5
5
|
import { cn } from "./index3.js";
|
|
6
6
|
const PulseBars = forwardRef(
|
package/dist/index30.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const hooks = require("./
|
|
5
|
+
const hooks = require("./index36.cjs");
|
|
6
6
|
const colors = require("./index4.cjs");
|
|
7
7
|
const classNames = require("./index3.cjs");
|
|
8
8
|
const TypingIndicator = react.forwardRef(
|
package/dist/index30.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index36.js";
|
|
4
4
|
import { normalizeSize } from "./index4.js";
|
|
5
5
|
import { cn } from "./index3.js";
|
|
6
6
|
const TypingIndicator = forwardRef(
|
package/dist/index31.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const hooks = require("./
|
|
5
|
+
const hooks = require("./index36.cjs");
|
|
6
6
|
const classNames = require("./index3.cjs");
|
|
7
7
|
const LoaderOverlay = react.forwardRef(
|
|
8
8
|
({
|
package/dist/index31.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { useLoaderVisibility } from "./
|
|
3
|
+
import { useLoaderVisibility } from "./index36.js";
|
|
4
4
|
import { cn } from "./index3.js";
|
|
5
5
|
const LoaderOverlay = forwardRef(
|
|
6
6
|
({
|
package/dist/index32.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const hooks = require("./
|
|
5
|
+
const hooks = require("./index36.cjs");
|
|
6
6
|
const classNames = require("./index3.cjs");
|
|
7
7
|
const colors = require("./index4.cjs");
|
|
8
8
|
const ButtonSpinner = react.forwardRef(
|
package/dist/index32.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./
|
|
3
|
+
import { useReducedMotion, useLoaderVisibility, getEffectiveDuration } from "./index36.js";
|
|
4
4
|
import { cn } from "./index3.js";
|
|
5
5
|
import { normalizeSize } from "./index4.js";
|
|
6
6
|
const ButtonSpinner = forwardRef(
|
package/dist/index33.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const hooks = require("./
|
|
5
|
+
const hooks = require("./index36.cjs");
|
|
6
6
|
const classNames = require("./index3.cjs");
|
|
7
7
|
const colors = require("./index4.cjs");
|
|
8
8
|
const SuccessCheckmark = react.forwardRef(
|
package/dist/index33.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { useLoaderVisibility } from "./
|
|
3
|
+
import { useLoaderVisibility } from "./index36.js";
|
|
4
4
|
import { cn } from "./index3.js";
|
|
5
5
|
import { normalizeSize } from "./index4.js";
|
|
6
6
|
const SuccessCheckmark = forwardRef(
|
package/dist/index34.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const hooks = require("./
|
|
5
|
+
const hooks = require("./index36.cjs");
|
|
6
6
|
const classNames = require("./index3.cjs");
|
|
7
7
|
const colors = require("./index4.cjs");
|
|
8
8
|
const ErrorIndicator = react.forwardRef(
|
package/dist/index34.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
-
import { useLoaderVisibility } from "./
|
|
3
|
+
import { useLoaderVisibility } from "./index36.js";
|
|
4
4
|
import { cn } from "./index3.js";
|
|
5
5
|
import { normalizeSize } from "./index4.js";
|
|
6
6
|
const ErrorIndicator = forwardRef(
|
package/dist/index35.cjs
CHANGED
|
@@ -1,125 +1,167 @@
|
|
|
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
|
-
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);
|
|
69
|
-
}
|
|
70
|
-
}, delay);
|
|
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
|
+
}
|
|
71
53
|
} else {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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 {
|
|
75
67
|
setIsTransitioning(true);
|
|
68
|
+
timeoutRef.current = setTimeout(() => {
|
|
69
|
+
setShowLoading(false);
|
|
70
|
+
setShowContent(true);
|
|
71
|
+
setIsTransitioning(false);
|
|
72
|
+
}, duration);
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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;
|
|
75
|
+
return () => {
|
|
76
|
+
if (timeoutRef.current) {
|
|
77
|
+
clearTimeout(timeoutRef.current);
|
|
89
78
|
}
|
|
90
79
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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}`;
|
|
101
92
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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}`;
|
|
106
98
|
}
|
|
107
|
-
if (
|
|
108
|
-
|
|
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}`;
|
|
109
104
|
}
|
|
110
|
-
if (
|
|
111
|
-
|
|
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}`;
|
|
112
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;
|
|
113
124
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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;
|