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.
Files changed (81) hide show
  1. package/README.md +83 -0
  2. package/dist/components/index.d.ts +1 -0
  3. package/dist/components/index.d.ts.map +1 -1
  4. package/dist/components/transition/LoaderTransition.d.ts +32 -0
  5. package/dist/components/transition/LoaderTransition.d.ts.map +1 -0
  6. package/dist/components/transition/index.d.ts +2 -0
  7. package/dist/components/transition/index.d.ts.map +1 -0
  8. package/dist/hooks/index.d.ts +3 -1
  9. package/dist/hooks/index.d.ts.map +1 -1
  10. package/dist/hooks/useEnhancedLoader.d.ts +62 -0
  11. package/dist/hooks/useEnhancedLoader.d.ts.map +1 -0
  12. package/dist/index.cjs +2 -0
  13. package/dist/index.js +2 -0
  14. package/dist/index10.cjs +1 -1
  15. package/dist/index10.js +1 -1
  16. package/dist/index11.cjs +1 -1
  17. package/dist/index11.js +1 -1
  18. package/dist/index12.cjs +1 -1
  19. package/dist/index12.js +1 -1
  20. package/dist/index13.cjs +1 -1
  21. package/dist/index13.js +1 -1
  22. package/dist/index14.cjs +1 -1
  23. package/dist/index14.js +1 -1
  24. package/dist/index15.cjs +1 -1
  25. package/dist/index15.js +1 -1
  26. package/dist/index16.cjs +1 -1
  27. package/dist/index16.js +1 -1
  28. package/dist/index17.cjs +1 -1
  29. package/dist/index17.js +1 -1
  30. package/dist/index18.cjs +1 -1
  31. package/dist/index18.js +1 -1
  32. package/dist/index19.cjs +1 -1
  33. package/dist/index19.js +1 -1
  34. package/dist/index20.cjs +1 -1
  35. package/dist/index20.js +1 -1
  36. package/dist/index21.cjs +1 -1
  37. package/dist/index21.js +1 -1
  38. package/dist/index22.cjs +1 -1
  39. package/dist/index22.js +1 -1
  40. package/dist/index23.cjs +1 -1
  41. package/dist/index23.js +1 -1
  42. package/dist/index24.cjs +1 -1
  43. package/dist/index24.js +1 -1
  44. package/dist/index25.cjs +1 -1
  45. package/dist/index25.js +1 -1
  46. package/dist/index26.cjs +1 -1
  47. package/dist/index26.js +1 -1
  48. package/dist/index27.cjs +1 -1
  49. package/dist/index27.js +1 -1
  50. package/dist/index28.cjs +1 -1
  51. package/dist/index28.js +1 -1
  52. package/dist/index29.cjs +1 -1
  53. package/dist/index29.js +1 -1
  54. package/dist/index30.cjs +1 -1
  55. package/dist/index30.js +1 -1
  56. package/dist/index31.cjs +1 -1
  57. package/dist/index31.js +1 -1
  58. package/dist/index32.cjs +1 -1
  59. package/dist/index32.js +1 -1
  60. package/dist/index33.cjs +1 -1
  61. package/dist/index33.js +1 -1
  62. package/dist/index34.cjs +1 -1
  63. package/dist/index34.js +1 -1
  64. package/dist/index35.cjs +153 -111
  65. package/dist/index35.js +154 -112
  66. package/dist/index36.cjs +125 -0
  67. package/dist/index36.js +125 -0
  68. package/dist/index7.cjs +1 -1
  69. package/dist/index7.js +1 -1
  70. package/dist/index8.cjs +1 -1
  71. package/dist/index8.js +1 -1
  72. package/dist/index9.cjs +1 -1
  73. package/dist/index9.js +1 -1
  74. package/dist/premium-react-loaders.css +75 -0
  75. package/dist/types/hooks.d.ts +95 -0
  76. package/dist/types/hooks.d.ts.map +1 -0
  77. package/dist/types/index.d.ts +2 -0
  78. package/dist/types/index.d.ts.map +1 -1
  79. package/dist/types/transition.d.ts +34 -0
  80. package/dist/types/transition.d.ts.map +1 -0
  81. package/package.json +1 -1
package/dist/index35.js CHANGED
@@ -1,125 +1,167 @@
1
- import { useState, useRef, useEffect } from "react";
2
- function useReducedMotion() {
3
- const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
4
- useEffect(() => {
5
- if (typeof window === "undefined" || !window.matchMedia) {
6
- return;
7
- }
8
- const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
9
- setPrefersReducedMotion(mediaQuery.matches);
10
- const handleChange = (event) => {
11
- setPrefersReducedMotion(event.matches);
12
- };
13
- if (mediaQuery.addEventListener) {
14
- mediaQuery.addEventListener("change", handleChange);
15
- return () => mediaQuery.removeEventListener("change", handleChange);
16
- } else {
17
- mediaQuery.addListener(handleChange);
18
- return () => mediaQuery.removeListener(handleChange);
19
- }
20
- }, []);
21
- return prefersReducedMotion;
22
- }
23
- function getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion) {
24
- if (respectMotionPreference && prefersReducedMotion) {
25
- return "0.01ms";
26
- }
27
- if (typeof speed === "number") {
28
- const validSpeed = !isNaN(speed) && speed > 0 ? Math.max(50, Math.min(1e4, speed)) : 1e3;
29
- return `${validSpeed}ms`;
30
- }
31
- const speedMap = {
32
- slow: "2s",
33
- normal: "1s",
34
- fast: "0.5s"
35
- };
36
- return speedMap[speed] || speedMap.normal;
37
- }
38
- function useLoaderVisibility(visible = true, delay = 0, minDuration = 0, transition) {
39
- const transitionDuration = transition === true ? 150 : typeof transition === "number" ? transition : 0;
40
- const hasTransition = transitionDuration > 0;
41
- const [shouldRender, setShouldRender] = useState(visible && delay === 0);
42
- const [isTransitioning, setIsTransitioning] = useState(visible && delay === 0 && hasTransition);
43
- const showTimeRef = useRef(visible && delay === 0 ? Date.now() : null);
44
- const delayTimerRef = useRef(null);
45
- const minDurationTimerRef = useRef(null);
46
- const transitionTimerRef = useRef(null);
47
- useEffect(() => {
48
- if (delayTimerRef.current) {
49
- clearTimeout(delayTimerRef.current);
50
- delayTimerRef.current = null;
51
- }
52
- if (minDurationTimerRef.current) {
53
- clearTimeout(minDurationTimerRef.current);
54
- minDurationTimerRef.current = null;
55
- }
56
- if (transitionTimerRef.current) {
57
- clearTimeout(transitionTimerRef.current);
58
- transitionTimerRef.current = null;
59
- }
60
- if (visible) {
61
- if (delay > 0) {
62
- delayTimerRef.current = setTimeout(() => {
63
- setShouldRender(true);
64
- showTimeRef.current = Date.now();
65
- if (hasTransition) {
66
- setIsTransitioning(true);
67
- }
68
- }, delay);
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useRef, useEffect } from "react";
3
+ import { cn } from "./index3.js";
4
+ const LoaderTransition = forwardRef(
5
+ ({
6
+ loading,
7
+ loadingContent,
8
+ children,
9
+ transitionType = "fade",
10
+ duration = 300,
11
+ timing = "ease-out",
12
+ keepMounted = false,
13
+ exitDelay = 0,
14
+ appearOnMount = false,
15
+ className,
16
+ style,
17
+ testId = "loader-transition",
18
+ ariaLabel,
19
+ visible = true,
20
+ delay = 0,
21
+ minDuration = 0,
22
+ transition: transitionProp,
23
+ ...rest
24
+ }, ref) => {
25
+ const [isTransitioning, setIsTransitioning] = useState(false);
26
+ const [showLoading, setShowLoading] = useState(appearOnMount ? loading : false);
27
+ const [showContent, setShowContent] = useState(!appearOnMount && !loading);
28
+ const timeoutRef = useRef(null);
29
+ const entryTimeRef = useRef(null);
30
+ useEffect(() => {
31
+ if (!visible) {
32
+ setShowLoading(false);
33
+ setShowContent(false);
34
+ return;
35
+ }
36
+ if (loading) {
37
+ if (timeoutRef.current) {
38
+ clearTimeout(timeoutRef.current);
39
+ }
40
+ if (delay > 0) {
41
+ timeoutRef.current = setTimeout(() => {
42
+ setShowLoading(true);
43
+ setShowContent(false);
44
+ entryTimeRef.current = Date.now();
45
+ }, delay);
46
+ } else {
47
+ setShowLoading(true);
48
+ setShowContent(false);
49
+ entryTimeRef.current = Date.now();
50
+ }
69
51
  } else {
70
- setShouldRender(true);
71
- showTimeRef.current = Date.now();
72
- if (hasTransition) {
52
+ const elapsed = entryTimeRef.current ? Date.now() - entryTimeRef.current : 0;
53
+ const remainingMinDuration = Math.max(0, minDuration - elapsed);
54
+ const totalDelay = exitDelay + remainingMinDuration;
55
+ if (totalDelay > 0) {
56
+ timeoutRef.current = setTimeout(() => {
57
+ setIsTransitioning(true);
58
+ timeoutRef.current = setTimeout(() => {
59
+ setShowLoading(false);
60
+ setShowContent(true);
61
+ setIsTransitioning(false);
62
+ }, duration);
63
+ }, totalDelay);
64
+ } else {
73
65
  setIsTransitioning(true);
66
+ timeoutRef.current = setTimeout(() => {
67
+ setShowLoading(false);
68
+ setShowContent(true);
69
+ setIsTransitioning(false);
70
+ }, duration);
74
71
  }
75
72
  }
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;
73
+ return () => {
74
+ if (timeoutRef.current) {
75
+ clearTimeout(timeoutRef.current);
87
76
  }
88
77
  };
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();
78
+ }, [loading, visible, delay, minDuration, exitDelay, duration]);
79
+ const getTransitionClasses = (isLoading, isTransition) => {
80
+ const baseClasses = "loader-transition";
81
+ const timingClass = `loader-transition-${timing}`;
82
+ if (transitionType === "none") {
83
+ return baseClasses;
84
+ }
85
+ if (transitionType === "fade") {
86
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-enter-active`;
87
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-exit-active`;
88
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-fade-enter-active`;
89
+ return `${baseClasses} ${timingClass}`;
99
90
  }
100
- }
101
- return () => {
102
- if (delayTimerRef.current) {
103
- clearTimeout(delayTimerRef.current);
91
+ if (transitionType === "slide-up") {
92
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-enter-active`;
93
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-exit-active`;
94
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-up-enter-active`;
95
+ return `${baseClasses} ${timingClass}`;
104
96
  }
105
- if (minDurationTimerRef.current) {
106
- clearTimeout(minDurationTimerRef.current);
97
+ if (transitionType === "slide-down") {
98
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-enter-active`;
99
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-exit-active`;
100
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-down-enter-active`;
101
+ return `${baseClasses} ${timingClass}`;
107
102
  }
108
- if (transitionTimerRef.current) {
109
- clearTimeout(transitionTimerRef.current);
103
+ if (transitionType === "slide-left") {
104
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-enter-active`;
105
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-exit-active`;
106
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-left-enter-active`;
107
+ return `${baseClasses} ${timingClass}`;
110
108
  }
109
+ if (transitionType === "slide-right") {
110
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-enter-active`;
111
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-exit-active`;
112
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-slide-right-enter-active`;
113
+ return `${baseClasses} ${timingClass}`;
114
+ }
115
+ if (transitionType === "scale") {
116
+ if (isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-enter-active`;
117
+ if (!isLoading && isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-exit-active`;
118
+ if (!isLoading && !isTransition) return `${baseClasses} ${timingClass} loader-transition-scale-enter-active`;
119
+ return `${baseClasses} ${timingClass}`;
120
+ }
121
+ return baseClasses;
111
122
  };
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
- }
123
+ const shouldShowLoading = showLoading || keepMounted && loading;
124
+ const shouldShowContent = showContent || keepMounted && !loading;
125
+ return /* @__PURE__ */ jsxs(
126
+ "div",
127
+ {
128
+ ref,
129
+ "data-testid": testId,
130
+ className: cn("relative", className),
131
+ style,
132
+ role: "status",
133
+ "aria-label": ariaLabel,
134
+ "aria-busy": loading,
135
+ ...rest,
136
+ children: [
137
+ shouldShowLoading && /* @__PURE__ */ jsx(
138
+ "div",
139
+ {
140
+ className: getTransitionClasses(true, isTransitioning),
141
+ style: {
142
+ transitionDuration: `${duration}ms`,
143
+ display: showLoading ? "block" : "none"
144
+ },
145
+ children: loadingContent
146
+ }
147
+ ),
148
+ shouldShowContent && /* @__PURE__ */ jsx(
149
+ "div",
150
+ {
151
+ className: getTransitionClasses(false, isTransitioning),
152
+ style: {
153
+ transitionDuration: `${duration}ms`,
154
+ display: showContent ? "block" : "none"
155
+ },
156
+ children
157
+ }
158
+ )
159
+ ]
160
+ }
161
+ );
162
+ }
163
+ );
164
+ LoaderTransition.displayName = "LoaderTransition";
121
165
  export {
122
- getEffectiveDuration,
123
- useLoaderVisibility,
124
- useReducedMotion
166
+ LoaderTransition
125
167
  };
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ 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);
69
+ }
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);
106
+ }
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;
@@ -0,0 +1,125 @@
1
+ import { useState, useRef, useEffect } from "react";
2
+ function useReducedMotion() {
3
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
4
+ useEffect(() => {
5
+ if (typeof window === "undefined" || !window.matchMedia) {
6
+ return;
7
+ }
8
+ const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
9
+ setPrefersReducedMotion(mediaQuery.matches);
10
+ const handleChange = (event) => {
11
+ setPrefersReducedMotion(event.matches);
12
+ };
13
+ if (mediaQuery.addEventListener) {
14
+ mediaQuery.addEventListener("change", handleChange);
15
+ return () => mediaQuery.removeEventListener("change", handleChange);
16
+ } else {
17
+ mediaQuery.addListener(handleChange);
18
+ return () => mediaQuery.removeListener(handleChange);
19
+ }
20
+ }, []);
21
+ return prefersReducedMotion;
22
+ }
23
+ function getEffectiveDuration(speed, respectMotionPreference, prefersReducedMotion) {
24
+ if (respectMotionPreference && prefersReducedMotion) {
25
+ return "0.01ms";
26
+ }
27
+ if (typeof speed === "number") {
28
+ const validSpeed = !isNaN(speed) && speed > 0 ? Math.max(50, Math.min(1e4, speed)) : 1e3;
29
+ return `${validSpeed}ms`;
30
+ }
31
+ const speedMap = {
32
+ slow: "2s",
33
+ normal: "1s",
34
+ fast: "0.5s"
35
+ };
36
+ return speedMap[speed] || speedMap.normal;
37
+ }
38
+ function useLoaderVisibility(visible = true, delay = 0, minDuration = 0, transition) {
39
+ const transitionDuration = transition === true ? 150 : typeof transition === "number" ? transition : 0;
40
+ const hasTransition = transitionDuration > 0;
41
+ const [shouldRender, setShouldRender] = useState(visible && delay === 0);
42
+ const [isTransitioning, setIsTransitioning] = useState(visible && delay === 0 && hasTransition);
43
+ const showTimeRef = useRef(visible && delay === 0 ? Date.now() : null);
44
+ const delayTimerRef = useRef(null);
45
+ const minDurationTimerRef = useRef(null);
46
+ const transitionTimerRef = useRef(null);
47
+ useEffect(() => {
48
+ if (delayTimerRef.current) {
49
+ clearTimeout(delayTimerRef.current);
50
+ delayTimerRef.current = null;
51
+ }
52
+ if (minDurationTimerRef.current) {
53
+ clearTimeout(minDurationTimerRef.current);
54
+ minDurationTimerRef.current = null;
55
+ }
56
+ if (transitionTimerRef.current) {
57
+ clearTimeout(transitionTimerRef.current);
58
+ transitionTimerRef.current = null;
59
+ }
60
+ if (visible) {
61
+ if (delay > 0) {
62
+ delayTimerRef.current = setTimeout(() => {
63
+ setShouldRender(true);
64
+ showTimeRef.current = Date.now();
65
+ if (hasTransition) {
66
+ setIsTransitioning(true);
67
+ }
68
+ }, delay);
69
+ } else {
70
+ setShouldRender(true);
71
+ showTimeRef.current = Date.now();
72
+ if (hasTransition) {
73
+ setIsTransitioning(true);
74
+ }
75
+ }
76
+ } else {
77
+ const hideLoader = () => {
78
+ if (hasTransition) {
79
+ setIsTransitioning(false);
80
+ transitionTimerRef.current = setTimeout(() => {
81
+ setShouldRender(false);
82
+ showTimeRef.current = null;
83
+ }, transitionDuration);
84
+ } else {
85
+ setShouldRender(false);
86
+ showTimeRef.current = null;
87
+ }
88
+ };
89
+ if (showTimeRef.current !== null && minDuration > 0) {
90
+ const elapsedTime = Date.now() - showTimeRef.current;
91
+ const remainingTime = minDuration - elapsedTime;
92
+ if (remainingTime > 0) {
93
+ minDurationTimerRef.current = setTimeout(hideLoader, remainingTime);
94
+ } else {
95
+ hideLoader();
96
+ }
97
+ } else {
98
+ hideLoader();
99
+ }
100
+ }
101
+ return () => {
102
+ if (delayTimerRef.current) {
103
+ clearTimeout(delayTimerRef.current);
104
+ }
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
+ }
121
+ export {
122
+ getEffectiveDuration,
123
+ useLoaderVisibility,
124
+ useReducedMotion
125
+ };
package/dist/index7.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("./index35.cjs");
5
+ const hooks = require("./index36.cjs");
6
6
  const colors = require("./index4.cjs");
7
7
  const classNames = require("./index3.cjs");
8
8
  const Skeleton = react.forwardRef(
package/dist/index7.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- import { useLoaderVisibility } from "./index35.js";
3
+ import { useLoaderVisibility } from "./index36.js";
4
4
  import { normalizeSize } from "./index4.js";
5
5
  import { cn } from "./index3.js";
6
6
  const Skeleton = forwardRef(
package/dist/index8.cjs CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const react = require("react");
5
5
  const Skeleton = require("./index7.cjs");
6
- const hooks = require("./index35.cjs");
6
+ const hooks = require("./index36.cjs");
7
7
  const colors = require("./index4.cjs");
8
8
  const classNames = require("./index3.cjs");
9
9
  const SkeletonText = react.forwardRef(
package/dist/index8.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { Skeleton } from "./index7.js";
4
- import { useLoaderVisibility } from "./index35.js";
4
+ import { useLoaderVisibility } from "./index36.js";
5
5
  import { normalizeSize } from "./index4.js";
6
6
  import { cn } from "./index3.js";
7
7
  const SkeletonText = forwardRef(
package/dist/index9.cjs CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const react = require("react");
5
5
  const Skeleton = require("./index7.cjs");
6
- const hooks = require("./index35.cjs");
6
+ const hooks = require("./index36.cjs");
7
7
  const colors = require("./index4.cjs");
8
8
  const SkeletonAvatar = react.forwardRef(
9
9
  ({
package/dist/index9.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { Skeleton } from "./index7.js";
4
- import { useLoaderVisibility } from "./index35.js";
4
+ import { useLoaderVisibility } from "./index36.js";
5
5
  import { normalizeSize } from "./index4.js";
6
6
  const SkeletonAvatar = forwardRef(
7
7
  ({
@@ -481,6 +481,81 @@
481
481
  .animate-error-x {
482
482
  animation: error-x var(--animation-duration-normal, 500ms) ease-out forwards;
483
483
  }
484
+ /* Transition animations for LoaderTransition */
485
+ .loader-transition {
486
+ transition-property: opacity, transform;
487
+ }
488
+ /* Timing functions */
489
+ .loader-transition-ease {
490
+ transition-timing-function: ease;
491
+ }
492
+ .loader-transition-ease-in {
493
+ transition-timing-function: ease-in;
494
+ }
495
+ .loader-transition-ease-out {
496
+ transition-timing-function: ease-out;
497
+ }
498
+ .loader-transition-ease-in-out {
499
+ transition-timing-function: ease-in-out;
500
+ }
501
+ .loader-transition-linear {
502
+ transition-timing-function: linear;
503
+ }
504
+ .loader-transition-spring {
505
+ transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
506
+ }
507
+ /* Fade transitions */
508
+ .loader-transition-fade-enter-active {
509
+ opacity: 1;
510
+ }
511
+ .loader-transition-fade-exit-active {
512
+ opacity: 0;
513
+ }
514
+ /* Slide up transitions */
515
+ .loader-transition-slide-up-enter-active {
516
+ opacity: 1;
517
+ transform: translateY(0);
518
+ }
519
+ .loader-transition-slide-up-exit-active {
520
+ opacity: 0;
521
+ transform: translateY(-20px);
522
+ }
523
+ /* Slide down transitions */
524
+ .loader-transition-slide-down-enter-active {
525
+ opacity: 1;
526
+ transform: translateY(0);
527
+ }
528
+ .loader-transition-slide-down-exit-active {
529
+ opacity: 0;
530
+ transform: translateY(20px);
531
+ }
532
+ /* Slide left transitions */
533
+ .loader-transition-slide-left-enter-active {
534
+ opacity: 1;
535
+ transform: translateX(0);
536
+ }
537
+ .loader-transition-slide-left-exit-active {
538
+ opacity: 0;
539
+ transform: translateX(-20px);
540
+ }
541
+ /* Slide right transitions */
542
+ .loader-transition-slide-right-enter-active {
543
+ opacity: 1;
544
+ transform: translateX(0);
545
+ }
546
+ .loader-transition-slide-right-exit-active {
547
+ opacity: 0;
548
+ transform: translateX(20px);
549
+ }
550
+ /* Scale transitions */
551
+ .loader-transition-scale-enter-active {
552
+ opacity: 1;
553
+ transform: scale(1);
554
+ }
555
+ .loader-transition-scale-exit-active {
556
+ opacity: 0;
557
+ transform: scale(0.95);
558
+ }
484
559
  /* Speed variants */
485
560
  .animate-slow {
486
561
  animation-duration: var(--animation-duration-slow, 2s);