premium-react-loaders 2.2.0 → 2.3.1
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 +86 -3
- 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 +99 -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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading state status
|
|
3
|
+
*/
|
|
4
|
+
export type LoadingStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
5
|
+
/**
|
|
6
|
+
* Retry strategy configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface RetryConfig {
|
|
9
|
+
/** Maximum number of retry attempts */
|
|
10
|
+
maxRetries?: number;
|
|
11
|
+
/** Initial delay in milliseconds before first retry */
|
|
12
|
+
initialDelay?: number;
|
|
13
|
+
/** Maximum delay in milliseconds between retries */
|
|
14
|
+
maxDelay?: number;
|
|
15
|
+
/** Exponential backoff multiplier (default: 2) */
|
|
16
|
+
backoffMultiplier?: number;
|
|
17
|
+
/** Function to determine if error should trigger a retry */
|
|
18
|
+
shouldRetry?: (error: Error, attemptNumber: number) => boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Enhanced useLoader hook options
|
|
22
|
+
*/
|
|
23
|
+
export interface UseLoaderOptions {
|
|
24
|
+
/** Delay in milliseconds before showing loader */
|
|
25
|
+
delay?: number;
|
|
26
|
+
/** Minimum duration in milliseconds to show loader once visible */
|
|
27
|
+
minDuration?: number;
|
|
28
|
+
/** Auto-hide loader after specified milliseconds */
|
|
29
|
+
autoHide?: number;
|
|
30
|
+
/** Enable fade transition */
|
|
31
|
+
transition?: boolean | number;
|
|
32
|
+
/** Retry configuration */
|
|
33
|
+
retry?: RetryConfig;
|
|
34
|
+
/** Debounce delay in milliseconds for startLoading calls */
|
|
35
|
+
debounce?: number;
|
|
36
|
+
/** Throttle delay in milliseconds for startLoading calls */
|
|
37
|
+
throttle?: number;
|
|
38
|
+
/** Callback when loading starts */
|
|
39
|
+
onLoadingStart?: () => void;
|
|
40
|
+
/** Callback when loading completes successfully */
|
|
41
|
+
onSuccess?: () => void;
|
|
42
|
+
/** Callback when loading fails */
|
|
43
|
+
onError?: (error: Error) => void;
|
|
44
|
+
/** Success display duration in milliseconds before resetting */
|
|
45
|
+
successDuration?: number;
|
|
46
|
+
/** Error display duration in milliseconds before resetting */
|
|
47
|
+
errorDuration?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Loading state history entry
|
|
51
|
+
*/
|
|
52
|
+
export interface LoadingHistoryEntry {
|
|
53
|
+
/** Timestamp when loading started */
|
|
54
|
+
startTime: number;
|
|
55
|
+
/** Timestamp when loading ended */
|
|
56
|
+
endTime?: number;
|
|
57
|
+
/** Duration in milliseconds (if ended) */
|
|
58
|
+
duration?: number;
|
|
59
|
+
/** Final status of this loading session */
|
|
60
|
+
status: LoadingStatus;
|
|
61
|
+
/** Error if status is 'error' */
|
|
62
|
+
error?: Error;
|
|
63
|
+
/** Number of retry attempts made */
|
|
64
|
+
retryCount?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Enhanced useLoader hook return value
|
|
68
|
+
*/
|
|
69
|
+
export interface UseLoaderReturn {
|
|
70
|
+
/** Current loading state */
|
|
71
|
+
loading: boolean;
|
|
72
|
+
/** Whether loader should be visible (respects delay and minDuration) */
|
|
73
|
+
isVisible: boolean;
|
|
74
|
+
/** Current status (idle, loading, success, error) */
|
|
75
|
+
status: LoadingStatus;
|
|
76
|
+
/** Current error if any */
|
|
77
|
+
error: Error | null;
|
|
78
|
+
/** Number of current retry attempt (0 if not retrying) */
|
|
79
|
+
retryAttempt: number;
|
|
80
|
+
/** Loading history */
|
|
81
|
+
history: LoadingHistoryEntry[];
|
|
82
|
+
/** Start loading */
|
|
83
|
+
startLoading: () => void;
|
|
84
|
+
/** Stop loading with success */
|
|
85
|
+
stopLoading: () => void;
|
|
86
|
+
/** Toggle loading state */
|
|
87
|
+
toggleLoading: () => void;
|
|
88
|
+
/** Set loading state directly */
|
|
89
|
+
setLoading: (loading: boolean) => void;
|
|
90
|
+
/** Stop loading with error */
|
|
91
|
+
setError: (error: Error) => void;
|
|
92
|
+
/** Manually retry the last failed operation */
|
|
93
|
+
retry: () => void;
|
|
94
|
+
/** Reset to idle state */
|
|
95
|
+
reset: () => void;
|
|
96
|
+
/** Clear history */
|
|
97
|
+
clearHistory: () => void;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,kDAAkD;IAClD,iBAAiB,CAAC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C9B,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,wEAAwE;IACxE,SAAS,EAAE,OAAO,CAAC;IAEnB,qDAAqD;IACrD,MAAM,EAAE,aAAa,CAAC;IAEtB,2BAA2B;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IAErB,sBAAsB;IACtB,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAE/B,oBAAoB;IACpB,YAAY,EAAE,MAAM,IAAI,CAAC;IAEzB,gCAAgC;IAChC,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB,2BAA2B;IAC3B,aAAa,EAAE,MAAM,IAAI,CAAC;IAE1B,iCAAiC;IACjC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAEvC,8BAA8B;IAC9B,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC,+CAA+C;IAC/C,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB,oBAAoB;IACpB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAGzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAGzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseLoaderProps } from './common';
|
|
3
|
+
/**
|
|
4
|
+
* Transition animation type
|
|
5
|
+
*/
|
|
6
|
+
export type TransitionType = 'fade' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'scale' | 'none';
|
|
7
|
+
/**
|
|
8
|
+
* Transition timing function
|
|
9
|
+
*/
|
|
10
|
+
export type TransitionTiming = 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' | 'spring';
|
|
11
|
+
/**
|
|
12
|
+
* LoaderTransition component props
|
|
13
|
+
*/
|
|
14
|
+
export interface LoaderTransitionProps extends Omit<BaseLoaderProps, 'size' | 'color' | 'secondaryColor' | 'speed' | 'reverse'> {
|
|
15
|
+
/** Whether currently in loading state */
|
|
16
|
+
loading: boolean;
|
|
17
|
+
/** Loading content to show (skeleton, spinner, etc.) */
|
|
18
|
+
loadingContent: ReactNode;
|
|
19
|
+
/** Actual content to show when loaded */
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/** Type of transition animation */
|
|
22
|
+
transitionType?: TransitionType;
|
|
23
|
+
/** Duration of transition in milliseconds */
|
|
24
|
+
duration?: number;
|
|
25
|
+
/** Timing function for the transition */
|
|
26
|
+
timing?: TransitionTiming;
|
|
27
|
+
/** Whether to keep the loading content mounted (improves performance for repeated loads) */
|
|
28
|
+
keepMounted?: boolean;
|
|
29
|
+
/** Delay before starting the transition out (prevents flash on quick loads) */
|
|
30
|
+
exitDelay?: number;
|
|
31
|
+
/** Whether to show loading content on first render */
|
|
32
|
+
appearOnMount?: boolean;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../src/types/transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AAElH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErG;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,CAAC;IAC7H,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IAEjB,wDAAwD;IACxD,cAAc,EAAE,SAAS,CAAC;IAE1B,yCAAyC;IACzC,QAAQ,EAAE,SAAS,CAAC;IAEpB,mCAAmC;IACnC,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yCAAyC;IACzC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B,4FAA4F;IAC5F,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,sDAAsD;IACtD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|