react-loadly 1.0.0 → 1.0.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 +142 -34
- package/dist/{index.js → index.cjs.js} +660 -367
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +84 -30
- package/dist/index.esm.js +644 -352
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/dist/types/@types/interfaces/IBaseLoaderProps.d.ts +10 -0
- package/dist/types/@types/interfaces/IBaseLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/IElementLoaderProps.d.ts +11 -0
- package/dist/types/@types/interfaces/IElementLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts +2 -1
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/ILogoLoaderProps.d.ts +1 -1
- package/dist/types/@types/interfaces/ILogoLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/ITextLoaderProps.d.ts +1 -2
- package/dist/types/@types/interfaces/ITextLoaderProps.d.ts.map +1 -1
- package/dist/types/__tests__/ElementLoader.example.d.ts +4 -0
- package/dist/types/__tests__/ElementLoader.example.d.ts.map +1 -0
- package/dist/types/components/atoms/Circle.d.ts +2 -1
- package/dist/types/components/atoms/Circle.d.ts.map +1 -1
- package/dist/types/components/atoms/Dot.d.ts +1 -1
- package/dist/types/components/atoms/Dot.d.ts.map +1 -1
- package/dist/types/components/atoms/Line.d.ts +1 -1
- package/dist/types/components/atoms/Line.d.ts.map +1 -1
- package/dist/types/components/atoms/Rectangle.d.ts +1 -0
- package/dist/types/components/atoms/Rectangle.d.ts.map +1 -1
- package/dist/types/components/molecules/DotCluster.d.ts +1 -0
- package/dist/types/components/molecules/DotCluster.d.ts.map +1 -1
- package/dist/types/components/molecules/LineGroup.d.ts +1 -0
- package/dist/types/components/molecules/LineGroup.d.ts.map +1 -1
- package/dist/types/components/molecules/ShapeGroup.d.ts +1 -0
- package/dist/types/components/molecules/ShapeGroup.d.ts.map +1 -1
- package/dist/types/components/organisms/BarsLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/BlobLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/BounceLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/DotsLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/ElementLoader.d.ts +27 -0
- package/dist/types/components/organisms/ElementLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/FallbackLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/FlowLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/GridLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/LiquidLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/LogoSpinLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/PulseLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/RingLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/RotateLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/SpinLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/TypingLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/WaveLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/index.d.ts +6 -5
- package/dist/types/components/organisms/index.d.ts.map +1 -1
- package/dist/types/hooks/useLoaderState.d.ts.map +1 -1
- package/package.json +11 -21
- package/dist/index.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var react = require('react');
|
|
3
|
+
var React = require('react');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Merges default props with user props, handling undefined values gracefully
|
|
@@ -173,7 +172,7 @@ const Dot = ({ size = 8, color = "var(--react-loadly-color)", opacity = 1, class
|
|
|
173
172
|
boxShadow: glowIntensity > 0 ? `0 0 ${glowIntensity * 10}px ${color}` : undefined,
|
|
174
173
|
...style,
|
|
175
174
|
};
|
|
176
|
-
return
|
|
175
|
+
return React.createElement("div", { className: `react-loadly-dot ${className}`.trim(), style: dotStyle, "data-testid": dataTestId, ...props });
|
|
177
176
|
};
|
|
178
177
|
|
|
179
178
|
const Line = ({ width = 30, height = 4, color = "var(--react-loadly-color)", opacity = 1, borderRadius = 2, className = "", style = {}, animation, animationDuration, animationDelay, orientation = "horizontal", "data-testid": dataTestId, ...props }) => {
|
|
@@ -191,7 +190,7 @@ const Line = ({ width = 30, height = 4, color = "var(--react-loadly-color)", opa
|
|
|
191
190
|
display: "inline-block",
|
|
192
191
|
...style,
|
|
193
192
|
};
|
|
194
|
-
return (
|
|
193
|
+
return (React.createElement("div", { className: `react-loadly-line react-loadly-line-${orientation} ${className}`.trim(), style: lineStyle, "data-testid": dataTestId, ...props }));
|
|
195
194
|
};
|
|
196
195
|
|
|
197
196
|
const Rectangle = ({ width = 20, height = 20, color = "var(--react-loadly-color)", borderColor, borderWidth = 0, borderRadius = 0, opacity = 1, className = "", style = {}, animation, animationDuration, animationDelay, "data-testid": dataTestId, ...props }) => {
|
|
@@ -211,7 +210,7 @@ const Rectangle = ({ width = 20, height = 20, color = "var(--react-loadly-color)
|
|
|
211
210
|
display: "inline-block",
|
|
212
211
|
...style,
|
|
213
212
|
};
|
|
214
|
-
return
|
|
213
|
+
return React.createElement("div", { className: `react-loadly-rectangle ${className}`.trim(), style: rectangleStyle, "data-testid": dataTestId, ...props });
|
|
215
214
|
};
|
|
216
215
|
|
|
217
216
|
const Circle = ({ size = 20, color = "var(--react-loadly-color)", borderColor, borderWidth = 0, opacity = 1, className = "", style = {}, animation, animationDuration, animationDelay, "data-testid": dataTestId, ...props }) => {
|
|
@@ -229,7 +228,7 @@ const Circle = ({ size = 20, color = "var(--react-loadly-color)", borderColor, b
|
|
|
229
228
|
display: "inline-block",
|
|
230
229
|
...style,
|
|
231
230
|
};
|
|
232
|
-
return
|
|
231
|
+
return React.createElement("div", { className: `react-loadly-circle ${className}`.trim(), style: circleStyle, "data-testid": dataTestId, ...props });
|
|
233
232
|
};
|
|
234
233
|
|
|
235
234
|
const DotCluster = ({ count = 3, dotSize = 8, color = "var(--react-loadly-color)", secondaryColor, spacing = 8, speed = 1, arrangement = "linear", className = "", style = {}, animationType = "wave", "data-testid": dataTestId, ...props }) => {
|
|
@@ -282,7 +281,7 @@ const DotCluster = ({ count = 3, dotSize = 8, color = "var(--react-loadly-color)
|
|
|
282
281
|
...getArrangementStyle(),
|
|
283
282
|
...style,
|
|
284
283
|
};
|
|
285
|
-
return (
|
|
284
|
+
return (React.createElement("div", { className: `react-loadly-dot-cluster react-loadly-dot-cluster-${arrangement} ${className}`.trim(), style: containerStyle, "data-testid": dataTestId, ...props }, Array.from({ length: count }, (_, index) => (React.createElement(Dot, { key: index, size: dotSize, color: secondaryColor && index % 2 === 1 ? secondaryColor : color, animation: `react-loadly-${animationType}`, animationDuration: animationDuration, animationDelay: getDotAnimationDelay(index), style: getDotPosition(index), "data-testid": dataTestId ? `${dataTestId}-dot-${index}` : undefined })))));
|
|
286
285
|
};
|
|
287
286
|
|
|
288
287
|
const LineGroup = ({ count = 5, lineWidth = 4, lineHeight = 35, color = "var(--react-loadly-color)", secondaryColor, spacing = 6, speed = 1, arrangement = "parallel", orientation = "vertical", className = "", style = {}, animationType = "wave", "data-testid": dataTestId, ...props }) => {
|
|
@@ -341,7 +340,7 @@ const LineGroup = ({ count = 5, lineWidth = 4, lineHeight = 35, color = "var(--r
|
|
|
341
340
|
...getArrangementStyle(),
|
|
342
341
|
...style,
|
|
343
342
|
};
|
|
344
|
-
return (
|
|
343
|
+
return (React.createElement("div", { className: `react-loadly-line-group react-loadly-line-group-${arrangement} ${className}`.trim(), style: containerStyle, "data-testid": dataTestId, ...props }, Array.from({ length: count }, (_, index) => (React.createElement(Line, { key: index, width: orientation === "horizontal" ? lineWidth : lineHeight, height: orientation === "horizontal" ? lineHeight : lineWidth, color: secondaryColor && index % 2 === 1 ? secondaryColor : color, orientation: orientation, animation: `react-loadly-${animationType}`, animationDuration: animationDuration, animationDelay: getLineAnimationDelay(index), style: getLinePosition(index), "data-testid": dataTestId ? `${dataTestId}-line-${index}` : undefined })))));
|
|
345
344
|
};
|
|
346
345
|
|
|
347
346
|
const ShapeGroup = ({ count = 4, shapeSize = 16, color = "var(--react-loadly-color)", secondaryColor, spacing = 8, speed = 1, arrangement = "linear", shapeTypes = ["circle", "rectangle"], className = "", style = {}, animationType = "pulse", borderWidth = 0, "data-testid": dataTestId, ...props }) => {
|
|
@@ -423,13 +422,75 @@ const ShapeGroup = ({ count = 4, shapeSize = 16, color = "var(--react-loadly-col
|
|
|
423
422
|
"data-testid": dataTestId ? `${dataTestId}-shape-${index}` : undefined,
|
|
424
423
|
};
|
|
425
424
|
if (shapeType === "circle") {
|
|
426
|
-
return
|
|
425
|
+
return React.createElement(Circle, { ...commonProps, size: shapeSize });
|
|
427
426
|
}
|
|
428
427
|
else {
|
|
429
|
-
return
|
|
428
|
+
return React.createElement(Rectangle, { ...commonProps, width: shapeSize, height: shapeSize });
|
|
430
429
|
}
|
|
431
430
|
};
|
|
432
|
-
return (
|
|
431
|
+
return (React.createElement("div", { className: `react-loadly-shape-group react-loadly-shape-group-${arrangement} ${className}`.trim(), style: containerStyle, "data-testid": dataTestId, ...props }, Array.from({ length: count }, (_, index) => renderShape(index))));
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
const defaultProps$e = {
|
|
435
|
+
size: 20,
|
|
436
|
+
color: "var(--react-loadly-color)",
|
|
437
|
+
speed: 1,
|
|
438
|
+
loading: true,
|
|
439
|
+
count: 5,
|
|
440
|
+
"aria-label": "Loading...",
|
|
441
|
+
};
|
|
442
|
+
const BarsLoader = (userProps) => {
|
|
443
|
+
const props = mergeProps(defaultProps$e, userProps);
|
|
444
|
+
const { size, color, speed, loading, className = "", style = {}, count = 5, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
445
|
+
const id = React.useMemo(() => generateId("bars-loader"), []);
|
|
446
|
+
const sizeValue = getSizeValue(size);
|
|
447
|
+
const animationSettings = getOptimizedAnimationSettings(speed);
|
|
448
|
+
if (!loading)
|
|
449
|
+
return null;
|
|
450
|
+
const containerStyle = {
|
|
451
|
+
display: "inline-flex",
|
|
452
|
+
flexDirection: "column",
|
|
453
|
+
alignItems: "center",
|
|
454
|
+
...style,
|
|
455
|
+
...(fullscreen && {
|
|
456
|
+
position: "fixed",
|
|
457
|
+
top: 0,
|
|
458
|
+
left: 0,
|
|
459
|
+
width: screenWidth || "100vw",
|
|
460
|
+
height: screenHeight || "100vh",
|
|
461
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
462
|
+
zIndex: 9999,
|
|
463
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
464
|
+
}),
|
|
465
|
+
};
|
|
466
|
+
const barsContainerStyle = {
|
|
467
|
+
display: "flex",
|
|
468
|
+
justifyContent: "center",
|
|
469
|
+
alignItems: "center",
|
|
470
|
+
gap: "4px",
|
|
471
|
+
};
|
|
472
|
+
const barStyle = {
|
|
473
|
+
width: "4px",
|
|
474
|
+
height: sizeValue,
|
|
475
|
+
backgroundColor: color,
|
|
476
|
+
borderRadius: "2px",
|
|
477
|
+
animation: `react-loadly-bars ${animationSettings.duration} ease-in-out infinite`,
|
|
478
|
+
animationPlayState: animationSettings.playState,
|
|
479
|
+
};
|
|
480
|
+
// Create bars with different animation delays
|
|
481
|
+
const bars = Array.from({ length: count }).map((_, index) => {
|
|
482
|
+
const delay = `${index * 0.1}s`;
|
|
483
|
+
const heightFactor = 0.5 + (index % 3) * 0.25; // Vary heights for visual interest
|
|
484
|
+
return (React.createElement("div", { key: index, style: {
|
|
485
|
+
...barStyle,
|
|
486
|
+
animationDelay: delay,
|
|
487
|
+
height: `${parseFloat(sizeValue) * heightFactor}px`,
|
|
488
|
+
}, "data-testid": dataTestId ? `${dataTestId}-bar-${index}` : undefined }));
|
|
489
|
+
});
|
|
490
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-bars ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
491
|
+
React.createElement("div", { style: barsContainerStyle }, bars),
|
|
492
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
493
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
433
494
|
};
|
|
434
495
|
|
|
435
496
|
const defaultProps$d = {
|
|
@@ -444,7 +505,7 @@ const defaultProps$d = {
|
|
|
444
505
|
const BlobLoader = (userProps) => {
|
|
445
506
|
const props = mergeProps(defaultProps$d, userProps);
|
|
446
507
|
const { size, color, secondaryColor, speed, loading, fluidity, amplitude, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
447
|
-
const id =
|
|
508
|
+
const id = React.useMemo(() => generateId("blob-loader"), []);
|
|
448
509
|
const sizeValue = getSizeValue(size);
|
|
449
510
|
const animationDuration = getAnimationDuration(2500, speed);
|
|
450
511
|
if (!loading)
|
|
@@ -475,7 +536,8 @@ const BlobLoader = (userProps) => {
|
|
|
475
536
|
animation: `blob-inner ${animationDuration} ease-in-out infinite reverse`,
|
|
476
537
|
opacity: 0.7,
|
|
477
538
|
};
|
|
478
|
-
return (
|
|
539
|
+
return (React.createElement(React.Fragment, null,
|
|
540
|
+
React.createElement("style", null, `
|
|
479
541
|
@keyframes blob-morph {
|
|
480
542
|
0%, 100% {
|
|
481
543
|
border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
|
|
@@ -509,21 +571,244 @@ const BlobLoader = (userProps) => {
|
|
|
509
571
|
transform: scale(${0.9 + (fluidity ?? 1) * 0.05}) rotate(-240deg);
|
|
510
572
|
}
|
|
511
573
|
}
|
|
512
|
-
`
|
|
574
|
+
`),
|
|
575
|
+
React.createElement("div", { className: `react-loadly react-loadly-blob ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
576
|
+
React.createElement("div", { style: blobStyle, "data-testid": dataTestId ? `${dataTestId}-blob` : undefined },
|
|
577
|
+
React.createElement("div", { style: innerBlobStyle })),
|
|
578
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
579
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel))));
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const defaultProps$c = {
|
|
583
|
+
size: 15,
|
|
584
|
+
color: "var(--react-loadly-color)",
|
|
585
|
+
speed: 1,
|
|
586
|
+
loading: true,
|
|
587
|
+
count: 3,
|
|
588
|
+
"aria-label": "Loading...",
|
|
589
|
+
};
|
|
590
|
+
const BounceLoader = (userProps) => {
|
|
591
|
+
const props = mergeProps(defaultProps$c, userProps);
|
|
592
|
+
const { size, color, speed, loading, className = "", style = {}, count = 3, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
593
|
+
const id = React.useMemo(() => generateId("bounce-loader"), []);
|
|
594
|
+
const sizeValue = getSizeValue(size);
|
|
595
|
+
const animationSettings = getOptimizedAnimationSettings(speed);
|
|
596
|
+
if (!loading)
|
|
597
|
+
return null;
|
|
598
|
+
const containerStyle = {
|
|
599
|
+
display: "inline-flex",
|
|
600
|
+
flexDirection: "column",
|
|
601
|
+
alignItems: "center",
|
|
602
|
+
...style,
|
|
603
|
+
...(fullscreen && {
|
|
604
|
+
position: "fixed",
|
|
605
|
+
top: 0,
|
|
606
|
+
left: 0,
|
|
607
|
+
width: screenWidth || "100vw",
|
|
608
|
+
height: screenHeight || "100vh",
|
|
609
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
610
|
+
zIndex: 9999,
|
|
611
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
612
|
+
}),
|
|
613
|
+
};
|
|
614
|
+
const bounceContainerStyle = {
|
|
615
|
+
display: "flex",
|
|
616
|
+
justifyContent: "center",
|
|
617
|
+
alignItems: "center",
|
|
618
|
+
gap: "8px",
|
|
619
|
+
};
|
|
620
|
+
const bounceBallStyle = {
|
|
621
|
+
width: sizeValue,
|
|
622
|
+
height: sizeValue,
|
|
623
|
+
borderRadius: "50%",
|
|
624
|
+
backgroundColor: color,
|
|
625
|
+
animation: `react-loadly-bounce ${animationSettings.duration} ease-in-out infinite`,
|
|
626
|
+
animationPlayState: animationSettings.playState,
|
|
627
|
+
};
|
|
628
|
+
// Create bounce animation delays for each ball
|
|
629
|
+
const balls = Array.from({ length: count }).map((_, index) => {
|
|
630
|
+
const delay = `${index * 0.1}s`;
|
|
631
|
+
return (React.createElement("div", { key: index, style: {
|
|
632
|
+
...bounceBallStyle,
|
|
633
|
+
animationDelay: delay,
|
|
634
|
+
}, "data-testid": dataTestId ? `${dataTestId}-ball-${index}` : undefined }));
|
|
635
|
+
});
|
|
636
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-bounce ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
637
|
+
React.createElement("div", { style: bounceContainerStyle }, balls),
|
|
638
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
639
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
513
640
|
};
|
|
514
641
|
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
642
|
+
const defaultProps$b = {
|
|
643
|
+
size: 12,
|
|
644
|
+
color: "var(--react-loadly-color)",
|
|
645
|
+
speed: 1,
|
|
646
|
+
loading: true,
|
|
647
|
+
count: 3,
|
|
648
|
+
"aria-label": "Loading...",
|
|
649
|
+
};
|
|
650
|
+
const DotsLoader = (userProps) => {
|
|
651
|
+
const props = mergeProps(defaultProps$b, userProps);
|
|
652
|
+
const { size, color, speed, loading, className = "", style = {}, count = 3, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
653
|
+
const id = React.useMemo(() => generateId("dots-loader"), []);
|
|
654
|
+
const sizeValue = getSizeValue(size);
|
|
655
|
+
const animationSettings = getOptimizedAnimationSettings(speed);
|
|
656
|
+
if (!loading)
|
|
657
|
+
return null;
|
|
658
|
+
const containerStyle = {
|
|
659
|
+
display: "inline-flex",
|
|
660
|
+
flexDirection: "column",
|
|
661
|
+
alignItems: "center",
|
|
662
|
+
...style,
|
|
663
|
+
...(fullscreen && {
|
|
664
|
+
position: "fixed",
|
|
665
|
+
top: 0,
|
|
666
|
+
left: 0,
|
|
667
|
+
width: screenWidth || "100vw",
|
|
668
|
+
height: screenHeight || "100vh",
|
|
669
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
670
|
+
zIndex: 9999,
|
|
671
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
672
|
+
}),
|
|
673
|
+
};
|
|
674
|
+
const dotsContainerStyle = {
|
|
675
|
+
display: "flex",
|
|
676
|
+
justifyContent: "center",
|
|
677
|
+
alignItems: "center",
|
|
678
|
+
gap: "6px",
|
|
679
|
+
};
|
|
680
|
+
const dotStyle = {
|
|
681
|
+
width: sizeValue,
|
|
682
|
+
height: sizeValue,
|
|
683
|
+
borderRadius: "50%",
|
|
684
|
+
backgroundColor: color,
|
|
685
|
+
animation: `react-loadly-dots ${animationSettings.duration} ease-in-out infinite`,
|
|
686
|
+
animationPlayState: animationSettings.playState,
|
|
687
|
+
};
|
|
688
|
+
// Create dots with different animation delays
|
|
689
|
+
const dots = Array.from({ length: count }).map((_, index) => {
|
|
690
|
+
const delay = `${index * 0.2}s`;
|
|
691
|
+
return (React.createElement("div", { key: index, style: {
|
|
692
|
+
...dotStyle,
|
|
693
|
+
animationDelay: delay,
|
|
694
|
+
}, "data-testid": dataTestId ? `${dataTestId}-dot-${index}` : undefined }));
|
|
695
|
+
});
|
|
696
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-dots ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
697
|
+
React.createElement("div", { style: dotsContainerStyle }, dots),
|
|
698
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
699
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
const defaultProps$a = {
|
|
703
|
+
size: 60,
|
|
704
|
+
speed: 1,
|
|
705
|
+
loading: true,
|
|
706
|
+
animationType: "spin",
|
|
707
|
+
glowIntensity: 0.3,
|
|
708
|
+
"aria-label": "Loading...",
|
|
709
|
+
};
|
|
710
|
+
const ElementLoader = (userProps) => {
|
|
711
|
+
const props = mergeProps(defaultProps$a, userProps);
|
|
712
|
+
const { size, width, height, speed = 1, loading, animationType, glowIntensity, className = "", style = {}, color = "var(--react-loadly-color)", "aria-label": ariaLabel, loadingText, showText, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, children, ...restProps } = props;
|
|
713
|
+
if (!loading)
|
|
714
|
+
return null;
|
|
715
|
+
const containerStyle = {
|
|
716
|
+
display: "inline-flex",
|
|
717
|
+
flexDirection: "column",
|
|
718
|
+
alignItems: "center",
|
|
719
|
+
...style,
|
|
720
|
+
...(fullscreen && {
|
|
721
|
+
position: "fixed",
|
|
722
|
+
top: 0,
|
|
723
|
+
left: 0,
|
|
724
|
+
width: screenWidth || "100vw",
|
|
725
|
+
height: screenHeight || "100vh",
|
|
726
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
727
|
+
zIndex: 9999,
|
|
728
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
729
|
+
}),
|
|
730
|
+
};
|
|
731
|
+
// Enhanced animation variants for ElementLoader
|
|
732
|
+
const getAnimation = () => {
|
|
733
|
+
switch (animationType) {
|
|
734
|
+
case "pulse":
|
|
735
|
+
return `react-loadly-pulse ${getAnimationDuration(2000, speed)} infinite`;
|
|
736
|
+
case "glow":
|
|
737
|
+
return `react-loadly-glow ${getAnimationDuration(2000, speed)} infinite`;
|
|
738
|
+
case "bounce":
|
|
739
|
+
return `react-loadly-bounce ${getAnimationDuration(2000, speed)} infinite`;
|
|
740
|
+
case "flip":
|
|
741
|
+
return `react-loadly-flip ${getAnimationDuration(2000, speed)} infinite`;
|
|
742
|
+
case "spin":
|
|
743
|
+
default:
|
|
744
|
+
return `react-loadly-spin ${getAnimationDuration(2000, speed)} infinite`;
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
// Calculate dimensions, prioritizing width/height props over size
|
|
748
|
+
const elementWidth = width || size;
|
|
749
|
+
const elementHeight = height || size;
|
|
750
|
+
const elementStyle = {
|
|
751
|
+
width: typeof elementWidth === "number" ? `${elementWidth}px` : elementWidth,
|
|
752
|
+
height: typeof elementHeight === "number" ? `${elementHeight}px` : elementHeight,
|
|
753
|
+
animation: getAnimation(),
|
|
754
|
+
filter: (glowIntensity ?? 0) > 0 ? `drop-shadow(0 0 ${(glowIntensity ?? 0) * 20}px ${color})` : undefined,
|
|
755
|
+
transformStyle: "preserve-3d",
|
|
756
|
+
willChange: "transform",
|
|
757
|
+
display: "flex",
|
|
758
|
+
alignItems: "center",
|
|
759
|
+
justifyContent: "center",
|
|
760
|
+
};
|
|
761
|
+
// Add additional animated elements for enhanced visual effect
|
|
762
|
+
const innerElementStyle = {
|
|
763
|
+
position: "absolute",
|
|
764
|
+
top: "50%",
|
|
765
|
+
left: "50%",
|
|
766
|
+
width: "60%",
|
|
767
|
+
height: "60%",
|
|
768
|
+
borderRadius: "50%",
|
|
769
|
+
backgroundColor: color,
|
|
770
|
+
opacity: 0.3,
|
|
771
|
+
transform: "translate(-50%, -50%)",
|
|
772
|
+
animation: `react-loadly-pulse ${getAnimationDuration(1500, speed * 1.5)} infinite`,
|
|
773
|
+
zIndex: -1,
|
|
774
|
+
};
|
|
775
|
+
const outerElementStyle = {
|
|
776
|
+
position: "absolute",
|
|
777
|
+
top: "50%",
|
|
778
|
+
left: "50%",
|
|
779
|
+
width: "120%",
|
|
780
|
+
height: "120%",
|
|
781
|
+
borderRadius: "50%",
|
|
782
|
+
border: `2px solid ${color}`,
|
|
783
|
+
opacity: 0.2,
|
|
784
|
+
transform: "translate(-50%, -50%)",
|
|
785
|
+
animation: `react-loadly-spin ${getAnimationDuration(3000, speed * 0.8)} infinite reverse`,
|
|
786
|
+
zIndex: -2,
|
|
787
|
+
};
|
|
788
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-element-loader ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
789
|
+
React.createElement("div", { style: { position: "relative", display: "flex", alignItems: "center", justifyContent: "center" } },
|
|
790
|
+
React.createElement("div", { style: outerElementStyle }),
|
|
791
|
+
React.createElement("div", { style: innerElementStyle }),
|
|
792
|
+
React.createElement("div", { style: elementStyle, className: "react-loadly-element", "data-testid": dataTestId ? `${dataTestId}-element` : undefined }, children)),
|
|
793
|
+
showText && (React.createElement("div", { className: "react-loadly-text", "aria-live": "polite" }, loadingText || ariaLabel)),
|
|
794
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
const ErrorIcon = ({ className = "" }) => (React.createElement("svg", { className: className, fill: "currentColor", viewBox: "0 0 20 20", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
798
|
+
React.createElement("path", { clipRule: "evenodd", fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z" })));
|
|
799
|
+
const NetworkIcon = ({ className = "" }) => (React.createElement("svg", { className: className, fill: "currentColor", viewBox: "0 0 20 20", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
800
|
+
React.createElement("path", { fillRule: "evenodd", d: "M9.243 3.03a1 1 0 01.727 1.213L9.53 6h2.94l.56-2.243a1 1 0 111.94.486L14.53 6H16a1 1 0 110 2h-1.97l-1 4H15a1 1 0 110 2h-2.47l-.56 2.242a1 1 0 11-1.94-.485L10.47 14H7.53l-.56 2.242a1 1 0 11-1.94-.485L5.47 14H4a1 1 0 110-2h1.97l1-4H5a1 1 0 110-2h2.47l.56-2.243a1 1 0 011.213-.727zM9.03 8l-1 4h2.94l1-4H9.03z", clipRule: "evenodd" })));
|
|
801
|
+
const TimeoutIcon = ({ className = "" }) => (React.createElement("svg", { className: className, fill: "currentColor", viewBox: "0 0 20 20", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true" },
|
|
802
|
+
React.createElement("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z", clipRule: "evenodd" })));
|
|
803
|
+
const FallbackLoader = ({ error = "Something went wrong", onRetry, showRetry = true, children, type = "error", className = "", style = {}, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps }) => {
|
|
519
804
|
const getIcon = () => {
|
|
520
805
|
switch (type) {
|
|
521
806
|
case "network":
|
|
522
|
-
return
|
|
807
|
+
return React.createElement(NetworkIcon, { className: "react-loadly-error-icon" });
|
|
523
808
|
case "timeout":
|
|
524
|
-
return
|
|
809
|
+
return React.createElement(TimeoutIcon, { className: "react-loadly-error-icon" });
|
|
525
810
|
default:
|
|
526
|
-
return
|
|
811
|
+
return React.createElement(ErrorIcon, { className: "react-loadly-error-icon" });
|
|
527
812
|
}
|
|
528
813
|
};
|
|
529
814
|
const getMessage = () => {
|
|
@@ -536,13 +821,32 @@ const FallbackLoader = ({ error = "Something went wrong", onRetry, showRetry = t
|
|
|
536
821
|
return error || "Something went wrong. Please try again.";
|
|
537
822
|
}
|
|
538
823
|
};
|
|
824
|
+
const containerStyle = {
|
|
825
|
+
...style,
|
|
826
|
+
...(fullscreen && {
|
|
827
|
+
position: "fixed",
|
|
828
|
+
top: 0,
|
|
829
|
+
left: 0,
|
|
830
|
+
width: screenWidth || "100vw",
|
|
831
|
+
height: screenHeight || "100vh",
|
|
832
|
+
backgroundColor: screenBackground || "var(--react-loadly-error-background)",
|
|
833
|
+
zIndex: 9999,
|
|
834
|
+
display: "flex",
|
|
835
|
+
flexDirection: "column",
|
|
836
|
+
alignItems: "center",
|
|
837
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
838
|
+
}),
|
|
839
|
+
};
|
|
539
840
|
if (children) {
|
|
540
|
-
return
|
|
841
|
+
return React.createElement("div", { className: `react-loadly-fallback ${className}`.trim(), style: containerStyle, ...restProps }, children);
|
|
541
842
|
}
|
|
542
|
-
return (
|
|
843
|
+
return (React.createElement("div", { className: `react-loadly-error ${className}`.trim(), style: containerStyle, role: "alert", "aria-live": "polite", ...restProps },
|
|
844
|
+
getIcon(),
|
|
845
|
+
React.createElement("p", { className: "react-loadly-error-message" }, getMessage()),
|
|
846
|
+
showRetry && onRetry && (React.createElement("button", { className: "react-loadly-retry-button", onClick: onRetry, type: "button", "aria-label": "Retry loading" }, "Try Again"))));
|
|
543
847
|
};
|
|
544
848
|
|
|
545
|
-
const defaultProps$
|
|
849
|
+
const defaultProps$9 = {
|
|
546
850
|
size: 60,
|
|
547
851
|
color: "var(--react-loadly-color)",
|
|
548
852
|
speed: 1,
|
|
@@ -552,9 +856,9 @@ const defaultProps$c = {
|
|
|
552
856
|
"aria-label": "Loading...",
|
|
553
857
|
};
|
|
554
858
|
const FlowLoader = (userProps) => {
|
|
555
|
-
const props = mergeProps(defaultProps$
|
|
556
|
-
const { size, color, secondaryColor, speed, loading, amplitude, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
557
|
-
const id =
|
|
859
|
+
const props = mergeProps(defaultProps$9, userProps);
|
|
860
|
+
const { size, color, secondaryColor, speed, loading, amplitude, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
861
|
+
const id = React.useMemo(() => generateId("flow-loader"), []);
|
|
558
862
|
const sizeValue = getSizeValue(size);
|
|
559
863
|
const numericSize = parseInt(sizeValue);
|
|
560
864
|
const containerHeight = Math.max(numericSize * 0.4, 10); // Minimum height of 10px
|
|
@@ -566,6 +870,16 @@ const FlowLoader = (userProps) => {
|
|
|
566
870
|
flexDirection: "column",
|
|
567
871
|
alignItems: "center",
|
|
568
872
|
...style,
|
|
873
|
+
...(fullscreen && {
|
|
874
|
+
position: "fixed",
|
|
875
|
+
top: 0,
|
|
876
|
+
left: 0,
|
|
877
|
+
width: screenWidth || "100vw",
|
|
878
|
+
height: screenHeight || "100vh",
|
|
879
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
880
|
+
zIndex: 9999,
|
|
881
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
882
|
+
}),
|
|
569
883
|
};
|
|
570
884
|
const flowContainerStyle = {
|
|
571
885
|
width: sizeValue,
|
|
@@ -583,7 +897,7 @@ const FlowLoader = (userProps) => {
|
|
|
583
897
|
// Scale particle size based on container size
|
|
584
898
|
const minParticleSize = Math.max(numericSize / 10, 4); // Minimum 4px
|
|
585
899
|
const particleSize = minParticleSize + (index % 3) * (minParticleSize / 2);
|
|
586
|
-
return (
|
|
900
|
+
return (React.createElement("div", { key: index, style: {
|
|
587
901
|
position: "absolute",
|
|
588
902
|
width: `${particleSize}px`,
|
|
589
903
|
height: `${particleSize}px`,
|
|
@@ -594,9 +908,10 @@ const FlowLoader = (userProps) => {
|
|
|
594
908
|
opacity: 0.8 - index * 0.1,
|
|
595
909
|
left: "0px", // Start at the beginning of the container
|
|
596
910
|
top: `${(containerHeight - particleSize) / 2 + (index % 3) * (containerHeight / (particleCount + 1))}px`, // Distribute vertically
|
|
597
|
-
}, "data-testid": dataTestId ? `${dataTestId}-particle-${index}` : undefined }
|
|
911
|
+
}, "data-testid": dataTestId ? `${dataTestId}-particle-${index}` : undefined }));
|
|
598
912
|
};
|
|
599
|
-
return (
|
|
913
|
+
return (React.createElement(React.Fragment, null,
|
|
914
|
+
React.createElement("style", null, `
|
|
600
915
|
@keyframes flow-particle-${id} {
|
|
601
916
|
0% {
|
|
602
917
|
transform: translateX(0) translateY(0) scale(0);
|
|
@@ -619,10 +934,14 @@ const FlowLoader = (userProps) => {
|
|
|
619
934
|
opacity: 0;
|
|
620
935
|
}
|
|
621
936
|
}
|
|
622
|
-
`
|
|
937
|
+
`),
|
|
938
|
+
React.createElement("div", { className: `react-loadly react-loadly-flow ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
939
|
+
React.createElement("div", { style: flowContainerStyle, "data-testid": dataTestId ? `${dataTestId}-container` : undefined }, Array.from({ length: particleCount }, (_, index) => createParticle(index))),
|
|
940
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
941
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel))));
|
|
623
942
|
};
|
|
624
943
|
|
|
625
|
-
const defaultProps$
|
|
944
|
+
const defaultProps$8 = {
|
|
626
945
|
size: 40,
|
|
627
946
|
color: "var(--react-loadly-color)",
|
|
628
947
|
speed: 1,
|
|
@@ -631,10 +950,10 @@ const defaultProps$b = {
|
|
|
631
950
|
"aria-label": "Loading...",
|
|
632
951
|
};
|
|
633
952
|
const GridLoader = (userProps) => {
|
|
634
|
-
const props = mergeProps(defaultProps$
|
|
635
|
-
const { size, color, secondaryColor, speed, loading, count, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
636
|
-
const id =
|
|
637
|
-
const shapeSize =
|
|
953
|
+
const props = mergeProps(defaultProps$8, userProps);
|
|
954
|
+
const { size, color, secondaryColor, speed = 1, loading, count, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
955
|
+
const id = React.useMemo(() => generateId("grid-loader"), []);
|
|
956
|
+
const shapeSize = React.useMemo(() => {
|
|
638
957
|
const sizeNum = typeof size === "number" ? size : parseInt(getSizeValue(size));
|
|
639
958
|
const gridSize = Math.ceil(Math.sqrt(count || 4));
|
|
640
959
|
return Math.max(sizeNum / (gridSize * 1.5), 8);
|
|
@@ -646,22 +965,35 @@ const GridLoader = (userProps) => {
|
|
|
646
965
|
flexDirection: "column",
|
|
647
966
|
alignItems: "center",
|
|
648
967
|
...style,
|
|
968
|
+
...(fullscreen && {
|
|
969
|
+
position: "fixed",
|
|
970
|
+
top: 0,
|
|
971
|
+
left: 0,
|
|
972
|
+
width: screenWidth || "100vw",
|
|
973
|
+
height: screenHeight || "100vh",
|
|
974
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
975
|
+
zIndex: 9999,
|
|
976
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
977
|
+
}),
|
|
649
978
|
};
|
|
650
|
-
return (
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
979
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-grid ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
980
|
+
React.createElement("div", { className: "react-loadly-grid-container", style: {
|
|
981
|
+
display: "grid",
|
|
982
|
+
gridTemplateColumns: `repeat(${Math.ceil(Math.sqrt(count || 4))}, 1fr)`,
|
|
983
|
+
gap: `${shapeSize / 3}px`,
|
|
984
|
+
}, "data-testid": dataTestId ? `${dataTestId}-grid` : undefined }, Array.from({ length: count || 4 }).map((_, index) => (React.createElement("div", { key: index, className: "react-loadly-grid-item", style: {
|
|
985
|
+
width: `${shapeSize}px`,
|
|
986
|
+
height: `${shapeSize}px`,
|
|
987
|
+
backgroundColor: index % 2 === 0 ? color : secondaryColor || color,
|
|
988
|
+
borderRadius: "20%",
|
|
989
|
+
animation: `react-loadly-scale ${1.2 / (speed || 1)}s ease-in-out infinite`,
|
|
990
|
+
animationDelay: `${(index * 0.1) / (speed || 1)}s`,
|
|
991
|
+
} })))),
|
|
992
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
993
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
662
994
|
};
|
|
663
995
|
|
|
664
|
-
const defaultProps$
|
|
996
|
+
const defaultProps$7 = {
|
|
665
997
|
size: 60,
|
|
666
998
|
color: "var(--react-loadly-color)",
|
|
667
999
|
speed: 1,
|
|
@@ -671,9 +1003,9 @@ const defaultProps$a = {
|
|
|
671
1003
|
"aria-label": "Loading...",
|
|
672
1004
|
};
|
|
673
1005
|
const LiquidLoader = (userProps) => {
|
|
674
|
-
const props = mergeProps(defaultProps$
|
|
675
|
-
const { size, color, secondaryColor, speed, loading, amplitude, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
676
|
-
const id =
|
|
1006
|
+
const props = mergeProps(defaultProps$7, userProps);
|
|
1007
|
+
const { size, color, secondaryColor, speed, loading, amplitude, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
1008
|
+
const id = React.useMemo(() => generateId("liquid-loader"), []);
|
|
677
1009
|
const sizeValue = getSizeValue(size);
|
|
678
1010
|
const animationDuration = getAnimationDuration(2000, speed);
|
|
679
1011
|
if (!loading)
|
|
@@ -683,6 +1015,16 @@ const LiquidLoader = (userProps) => {
|
|
|
683
1015
|
flexDirection: "column",
|
|
684
1016
|
alignItems: "center",
|
|
685
1017
|
...style,
|
|
1018
|
+
...(fullscreen && {
|
|
1019
|
+
position: "fixed",
|
|
1020
|
+
top: 0,
|
|
1021
|
+
left: 0,
|
|
1022
|
+
width: screenWidth || "100vw",
|
|
1023
|
+
height: screenHeight || "100vh",
|
|
1024
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1025
|
+
zIndex: 9999,
|
|
1026
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1027
|
+
}),
|
|
686
1028
|
};
|
|
687
1029
|
const liquidStyle = {
|
|
688
1030
|
width: sizeValue,
|
|
@@ -713,7 +1055,8 @@ const LiquidLoader = (userProps) => {
|
|
|
713
1055
|
animationDelay: `${ -0.5 / (speed ?? 1)}s`,
|
|
714
1056
|
opacity: 0.8,
|
|
715
1057
|
};
|
|
716
|
-
return (
|
|
1058
|
+
return (React.createElement(React.Fragment, null,
|
|
1059
|
+
React.createElement("style", null, `
|
|
717
1060
|
@keyframes react-loadly-liquid-wave {
|
|
718
1061
|
0%, 100% {
|
|
719
1062
|
transform: translate(-25%, 50%) rotate(0deg);
|
|
@@ -722,20 +1065,27 @@ const LiquidLoader = (userProps) => {
|
|
|
722
1065
|
transform: translate(-25%, ${translateY}%) rotate(180deg);
|
|
723
1066
|
}
|
|
724
1067
|
}
|
|
725
|
-
`
|
|
1068
|
+
`),
|
|
1069
|
+
React.createElement("div", { className: `react-loadly react-loadly-liquid ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1070
|
+
React.createElement("div", { style: liquidStyle, "data-testid": dataTestId ? `${dataTestId}-container` : undefined },
|
|
1071
|
+
React.createElement("div", { style: waveStyle }),
|
|
1072
|
+
React.createElement("div", { style: wave2Style })),
|
|
1073
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
1074
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel))));
|
|
726
1075
|
};
|
|
727
1076
|
|
|
728
|
-
const defaultProps$
|
|
1077
|
+
const defaultProps$6 = {
|
|
729
1078
|
size: 60,
|
|
730
1079
|
speed: 1,
|
|
731
1080
|
loading: true,
|
|
732
1081
|
animationType: "spin",
|
|
733
1082
|
glowIntensity: 0.3,
|
|
734
1083
|
"aria-label": "Loading...",
|
|
1084
|
+
alt: "Loading",
|
|
735
1085
|
};
|
|
736
1086
|
const LogoSpinLoader = (userProps) => {
|
|
737
|
-
const props = mergeProps(defaultProps$
|
|
738
|
-
const { src, alt
|
|
1087
|
+
const props = mergeProps(defaultProps$6, userProps);
|
|
1088
|
+
const { src, alt, size, speed, loading, animationType, glowIntensity, className = "", style = {}, color = "var(--react-loadly-color)", "aria-label": ariaLabel, loadingText, showText, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
739
1089
|
if (!loading)
|
|
740
1090
|
return null;
|
|
741
1091
|
const containerStyle = {
|
|
@@ -743,6 +1093,16 @@ const LogoSpinLoader = (userProps) => {
|
|
|
743
1093
|
flexDirection: "column",
|
|
744
1094
|
alignItems: "center",
|
|
745
1095
|
...style,
|
|
1096
|
+
...(fullscreen && {
|
|
1097
|
+
position: "fixed",
|
|
1098
|
+
top: 0,
|
|
1099
|
+
left: 0,
|
|
1100
|
+
width: screenWidth || "100vw",
|
|
1101
|
+
height: screenHeight || "100vh",
|
|
1102
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1103
|
+
zIndex: 9999,
|
|
1104
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1105
|
+
}),
|
|
746
1106
|
};
|
|
747
1107
|
const logoStyle = {
|
|
748
1108
|
width: typeof size === "number" ? `${size}px` : size,
|
|
@@ -750,19 +1110,13 @@ const LogoSpinLoader = (userProps) => {
|
|
|
750
1110
|
animation: `react-loadly-${animationType} ${getAnimationDuration(2000, speed)} infinite`,
|
|
751
1111
|
filter: (glowIntensity ?? 0) > 0 ? `drop-shadow(0 0 ${(glowIntensity ?? 0) * 20}px ${color})` : undefined,
|
|
752
1112
|
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
borderRadius: "50%",
|
|
758
|
-
backgroundColor: color,
|
|
759
|
-
opacity: 0.8,
|
|
760
|
-
}, "data-testid": dataTestId ? `${dataTestId}-default` : undefined }), jsxRuntime.jsx("span", { className: "react-loadly-sr-only", children: ariaLabel })] }));
|
|
761
|
-
}
|
|
762
|
-
return (jsxRuntime.jsxs("div", { className: `react-loadly react-loadly-logo ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps, children: [jsxRuntime.jsx("img", { src: src, alt: alt, style: logoStyle, "data-testid": dataTestId ? `${dataTestId}-image` : undefined }), jsxRuntime.jsx("span", { className: "react-loadly-sr-only", children: ariaLabel })] }));
|
|
1113
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-logo-spin ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1114
|
+
React.createElement("img", { src: src, alt: alt, style: logoStyle, className: "react-loadly-logo", "data-testid": dataTestId ? `${dataTestId}-logo` : undefined }),
|
|
1115
|
+
showText && (React.createElement("div", { className: "react-loadly-text", "aria-live": "polite" }, loadingText || ariaLabel)),
|
|
1116
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
763
1117
|
};
|
|
764
1118
|
|
|
765
|
-
const defaultProps$
|
|
1119
|
+
const defaultProps$5 = {
|
|
766
1120
|
size: 40,
|
|
767
1121
|
color: "var(--react-loadly-color)",
|
|
768
1122
|
speed: 1,
|
|
@@ -771,10 +1125,10 @@ const defaultProps$8 = {
|
|
|
771
1125
|
"aria-label": "Loading...",
|
|
772
1126
|
};
|
|
773
1127
|
const PulseLoader = (userProps) => {
|
|
774
|
-
const props = mergeProps(defaultProps$
|
|
775
|
-
const { size, color, secondaryColor, speed, loading, count, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
776
|
-
const id =
|
|
777
|
-
const dotSize =
|
|
1128
|
+
const props = mergeProps(defaultProps$5, userProps);
|
|
1129
|
+
const { size, color, secondaryColor, speed, loading, count, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
1130
|
+
const id = React.useMemo(() => generateId("pulse-loader"), []);
|
|
1131
|
+
const dotSize = React.useMemo(() => {
|
|
778
1132
|
const sizeNum = typeof size === "number" ? size : parseInt(getSizeValue(size));
|
|
779
1133
|
return Math.max(sizeNum / 5, 6); // Ensure minimum dot size
|
|
780
1134
|
}, [size]);
|
|
@@ -785,25 +1139,39 @@ const PulseLoader = (userProps) => {
|
|
|
785
1139
|
flexDirection: "column",
|
|
786
1140
|
alignItems: "center",
|
|
787
1141
|
...style,
|
|
1142
|
+
...(fullscreen && {
|
|
1143
|
+
position: "fixed",
|
|
1144
|
+
top: 0,
|
|
1145
|
+
left: 0,
|
|
1146
|
+
width: screenWidth || "100vw",
|
|
1147
|
+
height: screenHeight || "100vh",
|
|
1148
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1149
|
+
zIndex: 9999,
|
|
1150
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1151
|
+
}),
|
|
788
1152
|
};
|
|
789
|
-
return (
|
|
1153
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-pulse ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1154
|
+
React.createElement(DotCluster, { count: count, dotSize: dotSize, color: color, secondaryColor: secondaryColor, speed: speed, arrangement: "linear", animationType: "pulse", spacing: dotSize / 2, "data-testid": dataTestId ? `${dataTestId}-dots` : undefined }),
|
|
1155
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
1156
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
790
1157
|
};
|
|
791
1158
|
|
|
792
|
-
const defaultProps$
|
|
793
|
-
size:
|
|
1159
|
+
const defaultProps$4 = {
|
|
1160
|
+
size: 60,
|
|
794
1161
|
color: "var(--react-loadly-color)",
|
|
795
1162
|
speed: 1,
|
|
796
1163
|
loading: true,
|
|
797
1164
|
borderWidth: 4,
|
|
798
1165
|
"aria-label": "Loading...",
|
|
799
1166
|
};
|
|
800
|
-
const
|
|
801
|
-
const props = mergeProps(defaultProps$
|
|
802
|
-
const { size, color, speed, loading, className = "", style = {}, borderWidth, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
1167
|
+
const RingLoader = (userProps) => {
|
|
1168
|
+
const props = mergeProps(defaultProps$4, userProps);
|
|
1169
|
+
const { size, color, speed, loading, className = "", style = {}, borderWidth, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
803
1170
|
// Use useRef instead of useMemo for better compatibility
|
|
804
|
-
const idRef =
|
|
1171
|
+
const idRef = React.useRef(generateId("ring-loader"));
|
|
805
1172
|
const sizeValue = getSizeValue(size);
|
|
806
1173
|
const animationSettings = getOptimizedAnimationSettings(speed);
|
|
1174
|
+
// Don't render anything if not loading
|
|
807
1175
|
if (!loading)
|
|
808
1176
|
return null;
|
|
809
1177
|
const containerStyle = {
|
|
@@ -811,168 +1179,49 @@ const SpinLoader = (userProps) => {
|
|
|
811
1179
|
flexDirection: "column",
|
|
812
1180
|
alignItems: "center",
|
|
813
1181
|
...style,
|
|
1182
|
+
...(fullscreen && {
|
|
1183
|
+
position: "fixed",
|
|
1184
|
+
top: 0,
|
|
1185
|
+
left: 0,
|
|
1186
|
+
width: screenWidth || "100vw",
|
|
1187
|
+
height: screenHeight || "100vh",
|
|
1188
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1189
|
+
zIndex: 9999,
|
|
1190
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1191
|
+
}),
|
|
814
1192
|
};
|
|
815
|
-
const
|
|
1193
|
+
const ringStyle = {
|
|
1194
|
+
position: "relative",
|
|
1195
|
+
width: sizeValue,
|
|
1196
|
+
height: sizeValue,
|
|
1197
|
+
};
|
|
1198
|
+
const ringSegmentStyle = {
|
|
1199
|
+
boxSizing: "border-box",
|
|
1200
|
+
display: "block",
|
|
1201
|
+
position: "absolute",
|
|
816
1202
|
width: sizeValue,
|
|
817
1203
|
height: sizeValue,
|
|
818
1204
|
border: `${borderWidth}px solid transparent`,
|
|
819
1205
|
borderTop: `${borderWidth}px solid ${color}`,
|
|
1206
|
+
borderBottom: `${borderWidth}px solid ${color}`,
|
|
820
1207
|
borderRadius: "50%",
|
|
821
|
-
animation: `react-loadly-
|
|
822
|
-
animationPlayState: animationSettings.playState,
|
|
823
|
-
};
|
|
824
|
-
return (jsxRuntime.jsxs("div", { className: `react-loadly react-loadly-spin ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps, children: [jsxRuntime.jsx("div", { style: spinnerStyle, "data-testid": dataTestId ? `${dataTestId}-spinner` : undefined }), showText && (jsxRuntime.jsx("div", { className: "react-loadly-text", id: `${idRef.current}-text`, "aria-live": "polite", children: loadingText })), jsxRuntime.jsx("span", { className: "react-loadly-sr-only", children: ariaLabel })] }));
|
|
825
|
-
};
|
|
826
|
-
|
|
827
|
-
const defaultProps$6 = {
|
|
828
|
-
text: "Loading...",
|
|
829
|
-
speed: 1,
|
|
830
|
-
loading: true,
|
|
831
|
-
charDelay: 100,
|
|
832
|
-
"aria-label": "Loading...",
|
|
833
|
-
};
|
|
834
|
-
const TypingLoader = (userProps) => {
|
|
835
|
-
const props = mergeProps(defaultProps$6, userProps);
|
|
836
|
-
const { text, speed, loading, charDelay, className = "", style = {}, color = "var(--react-loadly-text-color)", fontFamily, fontWeight = 500, "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
837
|
-
const [displayText, setDisplayText] = react.useState("");
|
|
838
|
-
const [isTyping, setIsTyping] = react.useState(false);
|
|
839
|
-
const timeoutRef = react.useRef(null);
|
|
840
|
-
react.useEffect(() => {
|
|
841
|
-
// Clear any existing timeout
|
|
842
|
-
if (timeoutRef.current) {
|
|
843
|
-
clearTimeout(timeoutRef.current);
|
|
844
|
-
timeoutRef.current = null;
|
|
845
|
-
}
|
|
846
|
-
if (!loading || !text) {
|
|
847
|
-
setDisplayText("");
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
850
|
-
setIsTyping(true);
|
|
851
|
-
setDisplayText("");
|
|
852
|
-
let currentIndex = 0;
|
|
853
|
-
const typeChar = () => {
|
|
854
|
-
if (currentIndex < text.length) {
|
|
855
|
-
setDisplayText(text.slice(0, currentIndex + 1));
|
|
856
|
-
currentIndex++;
|
|
857
|
-
timeoutRef.current = setTimeout(typeChar, (charDelay ?? 100) / (speed ?? 1));
|
|
858
|
-
}
|
|
859
|
-
else {
|
|
860
|
-
setIsTyping(false);
|
|
861
|
-
// Reset and start over
|
|
862
|
-
timeoutRef.current = setTimeout(() => {
|
|
863
|
-
currentIndex = 0;
|
|
864
|
-
setDisplayText("");
|
|
865
|
-
if (loading)
|
|
866
|
-
typeChar();
|
|
867
|
-
}, 1000 / (speed ?? 1));
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
typeChar();
|
|
871
|
-
return () => {
|
|
872
|
-
setIsTyping(false);
|
|
873
|
-
if (timeoutRef.current) {
|
|
874
|
-
clearTimeout(timeoutRef.current);
|
|
875
|
-
timeoutRef.current = null;
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
}, [text, loading, charDelay, speed]);
|
|
879
|
-
if (!loading)
|
|
880
|
-
return null;
|
|
881
|
-
const containerStyle = {
|
|
882
|
-
display: "inline-flex",
|
|
883
|
-
alignItems: "center",
|
|
884
|
-
fontFamily: fontFamily || "var(--react-loadly-font-family)",
|
|
885
|
-
fontSize: "var(--react-loadly-font-size)",
|
|
886
|
-
fontWeight,
|
|
887
|
-
color,
|
|
888
|
-
...style,
|
|
889
|
-
};
|
|
890
|
-
const cursorStyle = {
|
|
891
|
-
marginLeft: "2px",
|
|
892
|
-
animation: isTyping ? "none" : "react-loadly-fade 1s infinite",
|
|
893
|
-
opacity: isTyping ? 1 : 0.5,
|
|
894
|
-
};
|
|
895
|
-
return (jsxRuntime.jsxs("div", { className: `react-loadly react-loadly-typing ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps, children: [jsxRuntime.jsx("span", { children: displayText }), jsxRuntime.jsx("span", { style: cursorStyle, children: "|" }), jsxRuntime.jsx("span", { className: "react-loadly-sr-only", children: ariaLabel })] }));
|
|
896
|
-
};
|
|
897
|
-
|
|
898
|
-
const defaultProps$5 = {
|
|
899
|
-
size: 40,
|
|
900
|
-
color: "var(--react-loadly-color)",
|
|
901
|
-
speed: 1,
|
|
902
|
-
loading: true,
|
|
903
|
-
count: 5,
|
|
904
|
-
"aria-label": "Loading...",
|
|
905
|
-
};
|
|
906
|
-
const WaveLoader = (userProps) => {
|
|
907
|
-
const props = mergeProps(defaultProps$5, userProps);
|
|
908
|
-
const { size, color, secondaryColor, speed, loading, count, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
909
|
-
const id = react.useMemo(() => generateId("wave-loader"), []);
|
|
910
|
-
const lineSpecs = react.useMemo(() => {
|
|
911
|
-
const sizeNum = typeof size === "number" ? size : parseInt(getSizeValue(size));
|
|
912
|
-
return {
|
|
913
|
-
width: Math.max(sizeNum / 10, 3), // Line thickness
|
|
914
|
-
height: sizeNum, // Line height
|
|
915
|
-
spacing: Math.max(sizeNum / 8, 4), // Spacing between lines
|
|
916
|
-
};
|
|
917
|
-
}, [size]);
|
|
918
|
-
if (!loading)
|
|
919
|
-
return null;
|
|
920
|
-
const containerStyle = {
|
|
921
|
-
display: "inline-flex",
|
|
922
|
-
flexDirection: "column",
|
|
923
|
-
alignItems: "center",
|
|
924
|
-
...style,
|
|
925
|
-
};
|
|
926
|
-
return (jsxRuntime.jsxs("div", { className: `react-loadly react-loadly-wave ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps, children: [jsxRuntime.jsx(LineGroup, { count: count, lineWidth: lineSpecs.width, lineHeight: lineSpecs.height, color: color, secondaryColor: secondaryColor, speed: speed, arrangement: "staggered", orientation: "vertical", animationType: "wave", spacing: lineSpecs.spacing, "data-testid": dataTestId ? `${dataTestId}-lines` : undefined }), showText && (jsxRuntime.jsx("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite", children: loadingText })), jsxRuntime.jsx("span", { className: "react-loadly-sr-only", children: ariaLabel })] }));
|
|
927
|
-
};
|
|
928
|
-
|
|
929
|
-
const defaultProps$4 = {
|
|
930
|
-
size: 20,
|
|
931
|
-
color: "var(--react-loadly-color)",
|
|
932
|
-
speed: 1,
|
|
933
|
-
loading: true,
|
|
934
|
-
count: 5,
|
|
935
|
-
"aria-label": "Loading...",
|
|
936
|
-
};
|
|
937
|
-
const BarsLoader = (userProps) => {
|
|
938
|
-
const props = mergeProps(defaultProps$4, userProps);
|
|
939
|
-
const { size, color, speed, loading, className = "", style = {}, count = 5, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, ...restProps } = props;
|
|
940
|
-
const id = react.useMemo(() => generateId("bars-loader"), []);
|
|
941
|
-
const sizeValue = getSizeValue(size);
|
|
942
|
-
const animationSettings = getOptimizedAnimationSettings(speed);
|
|
943
|
-
if (!loading)
|
|
944
|
-
return null;
|
|
945
|
-
const containerStyle = {
|
|
946
|
-
display: "inline-flex",
|
|
947
|
-
flexDirection: "column",
|
|
948
|
-
alignItems: "center",
|
|
949
|
-
...style,
|
|
950
|
-
};
|
|
951
|
-
const barsContainerStyle = {
|
|
952
|
-
display: "flex",
|
|
953
|
-
justifyContent: "center",
|
|
954
|
-
alignItems: "center",
|
|
955
|
-
gap: "4px",
|
|
956
|
-
};
|
|
957
|
-
const barStyle = {
|
|
958
|
-
width: "4px",
|
|
959
|
-
height: sizeValue,
|
|
960
|
-
backgroundColor: color,
|
|
961
|
-
borderRadius: "2px",
|
|
962
|
-
animation: `react-loadly-bars ${animationSettings.duration} ease-in-out infinite`,
|
|
1208
|
+
animation: `react-loadly-ring ${animationSettings.duration} cubic-bezier(0.5, 0, 0.5, 1) infinite`,
|
|
963
1209
|
animationPlayState: animationSettings.playState,
|
|
964
1210
|
};
|
|
965
|
-
// Create
|
|
966
|
-
const
|
|
967
|
-
const
|
|
968
|
-
const
|
|
969
|
-
return (
|
|
970
|
-
...
|
|
1211
|
+
// Create the 4 ring segments with their specific styles
|
|
1212
|
+
const segments = Array.from({ length: 4 }).map((_, index) => {
|
|
1213
|
+
const rotation = `${index * 90}deg`;
|
|
1214
|
+
const delay = `${index * -0.15}s`;
|
|
1215
|
+
return (React.createElement("div", { key: index, style: {
|
|
1216
|
+
...ringSegmentStyle,
|
|
1217
|
+
transform: `rotate(${rotation})`,
|
|
971
1218
|
animationDelay: delay,
|
|
972
|
-
|
|
973
|
-
}, "data-testid": dataTestId ? `${dataTestId}-bar-${index}` : undefined }, index));
|
|
1219
|
+
}, "data-testid": dataTestId ? `${dataTestId}-segment-${index}` : undefined }));
|
|
974
1220
|
});
|
|
975
|
-
return (
|
|
1221
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-ring ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1222
|
+
React.createElement("div", { style: ringStyle }, segments),
|
|
1223
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${idRef.current}-text`, "aria-live": "polite" }, loadingText)),
|
|
1224
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
976
1225
|
};
|
|
977
1226
|
|
|
978
1227
|
const defaultProps$3 = {
|
|
@@ -980,13 +1229,13 @@ const defaultProps$3 = {
|
|
|
980
1229
|
color: "var(--react-loadly-color)",
|
|
981
1230
|
speed: 1,
|
|
982
1231
|
loading: true,
|
|
983
|
-
count:
|
|
1232
|
+
count: 2,
|
|
984
1233
|
"aria-label": "Loading...",
|
|
985
1234
|
};
|
|
986
|
-
const
|
|
1235
|
+
const RotateLoader = (userProps) => {
|
|
987
1236
|
const props = mergeProps(defaultProps$3, userProps);
|
|
988
|
-
const { size, color, speed, loading, className = "", style = {}, count =
|
|
989
|
-
const id =
|
|
1237
|
+
const { size, color, speed, loading, className = "", style = {}, count = 2, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
1238
|
+
const id = React.useMemo(() => generateId("rotate-loader"), []);
|
|
990
1239
|
const sizeValue = getSizeValue(size);
|
|
991
1240
|
const animationSettings = getOptimizedAnimationSettings(speed);
|
|
992
1241
|
if (!loading)
|
|
@@ -996,44 +1245,67 @@ const BounceLoader = (userProps) => {
|
|
|
996
1245
|
flexDirection: "column",
|
|
997
1246
|
alignItems: "center",
|
|
998
1247
|
...style,
|
|
1248
|
+
...(fullscreen && {
|
|
1249
|
+
position: "fixed",
|
|
1250
|
+
top: 0,
|
|
1251
|
+
left: 0,
|
|
1252
|
+
width: screenWidth || "100vw",
|
|
1253
|
+
height: screenHeight || "100vh",
|
|
1254
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1255
|
+
zIndex: 9999,
|
|
1256
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1257
|
+
}),
|
|
999
1258
|
};
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
gap: "8px",
|
|
1259
|
+
const rotateContainerStyle = {
|
|
1260
|
+
position: "relative",
|
|
1261
|
+
width: sizeValue,
|
|
1262
|
+
height: sizeValue,
|
|
1005
1263
|
};
|
|
1006
|
-
const
|
|
1264
|
+
const rotateElementStyle = {
|
|
1265
|
+
position: "absolute",
|
|
1007
1266
|
width: sizeValue,
|
|
1008
1267
|
height: sizeValue,
|
|
1268
|
+
border: "2px solid transparent",
|
|
1269
|
+
borderTopColor: color,
|
|
1270
|
+
borderBottomColor: color,
|
|
1009
1271
|
borderRadius: "50%",
|
|
1010
|
-
|
|
1011
|
-
animation: `react-loadly-bounce ${animationSettings.duration} ease-in-out infinite`,
|
|
1272
|
+
animation: `react-loadly-ring ${animationSettings.duration} cubic-bezier(0.5, 0, 0.5, 1) infinite`,
|
|
1012
1273
|
animationPlayState: animationSettings.playState,
|
|
1274
|
+
transform: "rotate(0deg)",
|
|
1013
1275
|
};
|
|
1014
|
-
// Create
|
|
1015
|
-
const
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1018
|
-
|
|
1276
|
+
// Create rotating elements
|
|
1277
|
+
const elements = Array.from({ length: count }).map((_, index) => {
|
|
1278
|
+
const sizeFactor = 1 - index * 0.2;
|
|
1279
|
+
const borderWidth = 2 + index;
|
|
1280
|
+
const delay = `${index * -0.15}s`;
|
|
1281
|
+
return (React.createElement("div", { key: index, style: {
|
|
1282
|
+
...rotateElementStyle,
|
|
1283
|
+
width: `${parseFloat(sizeValue) * sizeFactor}px`,
|
|
1284
|
+
height: `${parseFloat(sizeValue) * sizeFactor}px`,
|
|
1285
|
+
borderWidth: `${borderWidth}px`,
|
|
1286
|
+
animationDuration: `${parseFloat(animationSettings.duration) * (1 + index * 0.5)}ms`,
|
|
1019
1287
|
animationDelay: delay,
|
|
1020
|
-
}, "data-testid": dataTestId ? `${dataTestId}-
|
|
1288
|
+
}, "data-testid": dataTestId ? `${dataTestId}-element-${index}` : undefined }));
|
|
1021
1289
|
});
|
|
1022
|
-
return (
|
|
1290
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-ring ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1291
|
+
React.createElement("div", { style: rotateContainerStyle }, elements),
|
|
1292
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
1293
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
1023
1294
|
};
|
|
1024
1295
|
|
|
1025
1296
|
const defaultProps$2 = {
|
|
1026
|
-
size:
|
|
1297
|
+
size: 40,
|
|
1027
1298
|
color: "var(--react-loadly-color)",
|
|
1028
1299
|
speed: 1,
|
|
1029
1300
|
loading: true,
|
|
1030
|
-
|
|
1301
|
+
borderWidth: 4,
|
|
1031
1302
|
"aria-label": "Loading...",
|
|
1032
1303
|
};
|
|
1033
|
-
const
|
|
1304
|
+
const SpinLoader = (userProps) => {
|
|
1034
1305
|
const props = mergeProps(defaultProps$2, userProps);
|
|
1035
|
-
const { size, color, speed, loading, className = "", style = {},
|
|
1036
|
-
|
|
1306
|
+
const { size, color, speed, loading, className = "", style = {}, borderWidth, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
1307
|
+
// Use useRef instead of useMemo for better compatibility
|
|
1308
|
+
const idRef = React.useRef(generateId("spin-loader"));
|
|
1037
1309
|
const sizeValue = getSizeValue(size);
|
|
1038
1310
|
const animationSettings = getOptimizedAnimationSettings(speed);
|
|
1039
1311
|
if (!loading)
|
|
@@ -1043,48 +1315,81 @@ const DotsLoader = (userProps) => {
|
|
|
1043
1315
|
flexDirection: "column",
|
|
1044
1316
|
alignItems: "center",
|
|
1045
1317
|
...style,
|
|
1318
|
+
...(fullscreen && {
|
|
1319
|
+
position: "fixed",
|
|
1320
|
+
top: 0,
|
|
1321
|
+
left: 0,
|
|
1322
|
+
width: screenWidth || "100vw",
|
|
1323
|
+
height: screenHeight || "100vh",
|
|
1324
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1325
|
+
zIndex: 9999,
|
|
1326
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1327
|
+
}),
|
|
1046
1328
|
};
|
|
1047
|
-
const
|
|
1048
|
-
display: "flex",
|
|
1049
|
-
justifyContent: "center",
|
|
1050
|
-
alignItems: "center",
|
|
1051
|
-
gap: "6px",
|
|
1052
|
-
};
|
|
1053
|
-
const dotStyle = {
|
|
1329
|
+
const spinnerStyle = {
|
|
1054
1330
|
width: sizeValue,
|
|
1055
1331
|
height: sizeValue,
|
|
1332
|
+
border: `${borderWidth}px solid transparent`,
|
|
1333
|
+
borderTop: `${borderWidth}px solid ${color}`,
|
|
1056
1334
|
borderRadius: "50%",
|
|
1057
|
-
|
|
1058
|
-
animation: `react-loadly-dots ${animationSettings.duration} ease-in-out infinite`,
|
|
1335
|
+
animation: `react-loadly-spin ${animationSettings.duration} linear infinite`,
|
|
1059
1336
|
animationPlayState: animationSettings.playState,
|
|
1060
1337
|
};
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
...dotStyle,
|
|
1066
|
-
animationDelay: delay,
|
|
1067
|
-
}, "data-testid": dataTestId ? `${dataTestId}-dot-${index}` : undefined }, index));
|
|
1068
|
-
});
|
|
1069
|
-
return (jsxRuntime.jsxs("div", { className: `react-loadly react-loadly-dots ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps, children: [jsxRuntime.jsx("div", { style: dotsContainerStyle, children: dots }), showText && (jsxRuntime.jsx("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite", children: loadingText })), jsxRuntime.jsx("span", { className: "react-loadly-sr-only", children: ariaLabel })] }));
|
|
1338
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-spin ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1339
|
+
React.createElement("div", { style: spinnerStyle, "data-testid": dataTestId ? `${dataTestId}-spinner` : undefined }),
|
|
1340
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${idRef.current}-text`, "aria-live": "polite" }, loadingText)),
|
|
1341
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
1070
1342
|
};
|
|
1071
1343
|
|
|
1072
1344
|
const defaultProps$1 = {
|
|
1073
|
-
size: 60,
|
|
1074
|
-
color: "var(--react-loadly-color)",
|
|
1075
1345
|
speed: 1,
|
|
1076
1346
|
loading: true,
|
|
1077
|
-
|
|
1347
|
+
charDelay: 100,
|
|
1078
1348
|
"aria-label": "Loading...",
|
|
1349
|
+
loop: true,
|
|
1079
1350
|
};
|
|
1080
|
-
const
|
|
1351
|
+
const TypingLoader = (userProps) => {
|
|
1081
1352
|
const props = mergeProps(defaultProps$1, userProps);
|
|
1082
|
-
const {
|
|
1083
|
-
|
|
1084
|
-
const
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1353
|
+
const { loadingText, speed = 1, loading, charDelay = 100, loop, className = "", style = {}, color = "var(--react-loadly-text-color)", fontFamily, fontWeight = 500, "aria-label": ariaLabel, "data-testid": dataTestId, showText, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
1354
|
+
const [displayText, setDisplayText] = React.useState("");
|
|
1355
|
+
const [isTyping, setIsTyping] = React.useState(false);
|
|
1356
|
+
const timeoutRef = React.useRef(null);
|
|
1357
|
+
React.useEffect(() => {
|
|
1358
|
+
// Clear any existing timeout
|
|
1359
|
+
if (timeoutRef.current) {
|
|
1360
|
+
clearTimeout(timeoutRef.current);
|
|
1361
|
+
timeoutRef.current = null;
|
|
1362
|
+
}
|
|
1363
|
+
if (!loading || !loadingText) {
|
|
1364
|
+
setDisplayText("");
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
setIsTyping(true);
|
|
1368
|
+
setDisplayText("");
|
|
1369
|
+
const typeText = (index = 0) => {
|
|
1370
|
+
if (index < loadingText.length) {
|
|
1371
|
+
setDisplayText(loadingText.substring(0, index + 1));
|
|
1372
|
+
timeoutRef.current = setTimeout(() => typeText(index + 1), charDelay / speed);
|
|
1373
|
+
}
|
|
1374
|
+
else if (loop) {
|
|
1375
|
+
// Reset and start over if looping
|
|
1376
|
+
timeoutRef.current = setTimeout(() => {
|
|
1377
|
+
setDisplayText("");
|
|
1378
|
+
typeText(0);
|
|
1379
|
+
}, charDelay * 2);
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
setIsTyping(false);
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
typeText(0);
|
|
1386
|
+
// Cleanup timeouts on unmount or when dependencies change
|
|
1387
|
+
return () => {
|
|
1388
|
+
if (timeoutRef.current) {
|
|
1389
|
+
clearTimeout(timeoutRef.current);
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
}, [loading, loadingText, charDelay, speed, loop]);
|
|
1088
1393
|
if (!loading)
|
|
1089
1394
|
return null;
|
|
1090
1395
|
const containerStyle = {
|
|
@@ -1092,52 +1397,57 @@ const RingLoader = (userProps) => {
|
|
|
1092
1397
|
flexDirection: "column",
|
|
1093
1398
|
alignItems: "center",
|
|
1094
1399
|
...style,
|
|
1400
|
+
...(fullscreen && {
|
|
1401
|
+
position: "fixed",
|
|
1402
|
+
top: 0,
|
|
1403
|
+
left: 0,
|
|
1404
|
+
width: screenWidth || "100vw",
|
|
1405
|
+
height: screenHeight || "100vh",
|
|
1406
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1407
|
+
zIndex: 9999,
|
|
1408
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1409
|
+
}),
|
|
1095
1410
|
};
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
boxSizing: "border-box",
|
|
1103
|
-
display: "block",
|
|
1104
|
-
position: "absolute",
|
|
1105
|
-
width: sizeValue,
|
|
1106
|
-
height: sizeValue,
|
|
1107
|
-
border: `${borderWidth}px solid transparent`,
|
|
1108
|
-
borderTop: `${borderWidth}px solid ${color}`,
|
|
1109
|
-
borderBottom: `${borderWidth}px solid ${color}`,
|
|
1110
|
-
borderRadius: "50%",
|
|
1111
|
-
animation: `react-loadly-ring ${animationSettings.duration} cubic-bezier(0.5, 0, 0.5, 1) infinite`,
|
|
1112
|
-
animationPlayState: animationSettings.playState,
|
|
1411
|
+
const textStyle = {
|
|
1412
|
+
color,
|
|
1413
|
+
fontFamily,
|
|
1414
|
+
fontWeight,
|
|
1415
|
+
fontSize: "1.2em",
|
|
1416
|
+
whiteSpace: "pre",
|
|
1113
1417
|
};
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1418
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-typing ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1419
|
+
React.createElement("div", { style: textStyle, "data-testid": dataTestId ? `${dataTestId}-text` : undefined },
|
|
1420
|
+
displayText,
|
|
1421
|
+
React.createElement("span", { className: "react-loadly-typing-cursor", style: {
|
|
1422
|
+
display: isTyping ? "inline-block" : "none",
|
|
1423
|
+
animation: `react-loadly-blink ${1 / speed}s step-end infinite`,
|
|
1424
|
+
marginLeft: "2px",
|
|
1425
|
+
verticalAlign: "baseline",
|
|
1426
|
+
} }, "|")),
|
|
1427
|
+
showText && (React.createElement("div", { className: "react-loadly-text", "aria-live": "polite" }, loadingText)),
|
|
1428
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
1125
1429
|
};
|
|
1126
1430
|
|
|
1127
1431
|
const defaultProps = {
|
|
1128
|
-
size:
|
|
1432
|
+
size: 40,
|
|
1129
1433
|
color: "var(--react-loadly-color)",
|
|
1130
1434
|
speed: 1,
|
|
1131
1435
|
loading: true,
|
|
1132
|
-
count:
|
|
1436
|
+
count: 5,
|
|
1133
1437
|
"aria-label": "Loading...",
|
|
1134
1438
|
};
|
|
1135
|
-
const
|
|
1439
|
+
const WaveLoader = (userProps) => {
|
|
1136
1440
|
const props = mergeProps(defaultProps, userProps);
|
|
1137
|
-
const { size, color, speed, loading, className = "", style = {},
|
|
1138
|
-
const id =
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1441
|
+
const { size, color, secondaryColor, speed, loading, count, className = "", style = {}, showText, loadingText = "Loading...", "aria-label": ariaLabel, "data-testid": dataTestId, fullscreen, screenWidth, screenHeight, loaderCenter, screenBackground, ...restProps } = props;
|
|
1442
|
+
const id = React.useMemo(() => generateId("wave-loader"), []);
|
|
1443
|
+
const lineSpecs = React.useMemo(() => {
|
|
1444
|
+
const sizeNum = typeof size === "number" ? size : parseInt(getSizeValue(size));
|
|
1445
|
+
return {
|
|
1446
|
+
width: Math.max(sizeNum / 10, 3), // Line thickness
|
|
1447
|
+
height: sizeNum, // Line height
|
|
1448
|
+
spacing: Math.max(sizeNum / 8, 4), // Spacing between lines
|
|
1449
|
+
};
|
|
1450
|
+
}, [size]);
|
|
1141
1451
|
if (!loading)
|
|
1142
1452
|
return null;
|
|
1143
1453
|
const containerStyle = {
|
|
@@ -1145,39 +1455,21 @@ const RotateLoader = (userProps) => {
|
|
|
1145
1455
|
flexDirection: "column",
|
|
1146
1456
|
alignItems: "center",
|
|
1147
1457
|
...style,
|
|
1458
|
+
...(fullscreen && {
|
|
1459
|
+
position: "fixed",
|
|
1460
|
+
top: 0,
|
|
1461
|
+
left: 0,
|
|
1462
|
+
width: screenWidth || "100vw",
|
|
1463
|
+
height: screenHeight || "100vh",
|
|
1464
|
+
backgroundColor: screenBackground || "var(--react-loadly-background)",
|
|
1465
|
+
zIndex: 9999,
|
|
1466
|
+
justifyContent: loaderCenter ? "center" : style.justifyContent,
|
|
1467
|
+
}),
|
|
1148
1468
|
};
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
};
|
|
1154
|
-
const rotateElementStyle = {
|
|
1155
|
-
position: "absolute",
|
|
1156
|
-
width: sizeValue,
|
|
1157
|
-
height: sizeValue,
|
|
1158
|
-
border: "2px solid transparent",
|
|
1159
|
-
borderTopColor: color,
|
|
1160
|
-
borderBottomColor: color,
|
|
1161
|
-
borderRadius: "50%",
|
|
1162
|
-
animation: `react-loadly-ring ${animationSettings.duration} cubic-bezier(0.5, 0, 0.5, 1) infinite`,
|
|
1163
|
-
animationPlayState: animationSettings.playState,
|
|
1164
|
-
transform: "rotate(0deg)",
|
|
1165
|
-
};
|
|
1166
|
-
// Create rotating elements
|
|
1167
|
-
const elements = Array.from({ length: count }).map((_, index) => {
|
|
1168
|
-
const sizeFactor = 1 - index * 0.2;
|
|
1169
|
-
const borderWidth = 2 + index;
|
|
1170
|
-
const delay = `${index * -0.15}s`;
|
|
1171
|
-
return (jsxRuntime.jsx("div", { style: {
|
|
1172
|
-
...rotateElementStyle,
|
|
1173
|
-
width: `${parseFloat(sizeValue) * sizeFactor}px`,
|
|
1174
|
-
height: `${parseFloat(sizeValue) * sizeFactor}px`,
|
|
1175
|
-
borderWidth: `${borderWidth}px`,
|
|
1176
|
-
animationDuration: `${parseFloat(animationSettings.duration) * (1 + index * 0.5)}ms`,
|
|
1177
|
-
animationDelay: delay,
|
|
1178
|
-
}, "data-testid": dataTestId ? `${dataTestId}-element-${index}` : undefined }, index));
|
|
1179
|
-
});
|
|
1180
|
-
return (jsxRuntime.jsxs("div", { className: `react-loadly react-loadly-ring ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps, children: [jsxRuntime.jsx("div", { style: rotateContainerStyle, children: elements }), showText && (jsxRuntime.jsx("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite", children: loadingText })), jsxRuntime.jsx("span", { className: "react-loadly-sr-only", children: ariaLabel })] }));
|
|
1469
|
+
return (React.createElement("div", { className: `react-loadly react-loadly-wave ${className}`.trim(), style: containerStyle, role: "status", "aria-label": ariaLabel, "aria-live": "polite", "aria-busy": loading, "data-testid": dataTestId, ...restProps },
|
|
1470
|
+
React.createElement(LineGroup, { count: count, lineWidth: lineSpecs.width, lineHeight: lineSpecs.height, color: color, secondaryColor: secondaryColor, speed: speed, arrangement: "staggered", orientation: "vertical", animationType: "wave", spacing: lineSpecs.spacing, "data-testid": dataTestId ? `${dataTestId}-lines` : undefined }),
|
|
1471
|
+
showText && (React.createElement("div", { className: "react-loadly-text", id: `${id}-text`, "aria-live": "polite" }, loadingText)),
|
|
1472
|
+
React.createElement("span", { className: "react-loadly-sr-only" }, ariaLabel)));
|
|
1181
1473
|
};
|
|
1182
1474
|
|
|
1183
1475
|
/**
|
|
@@ -1188,17 +1480,17 @@ const RotateLoader = (userProps) => {
|
|
|
1188
1480
|
* @returns Object containing state and methods to control the loader
|
|
1189
1481
|
*/
|
|
1190
1482
|
const useLoaderState = (options = {}) => {
|
|
1191
|
-
const { initialLoading = false, timeout, maxRetries = 3, onLoadingChange, onError, onProgress
|
|
1192
|
-
const [state, setState] =
|
|
1483
|
+
const { initialLoading = false, timeout, maxRetries = 3, onLoadingChange, onError, onProgress } = options;
|
|
1484
|
+
const [state, setState] = React.useState({
|
|
1193
1485
|
isLoading: initialLoading,
|
|
1194
1486
|
progress: 0,
|
|
1195
1487
|
error: null,
|
|
1196
1488
|
retryCount: 0,
|
|
1197
1489
|
});
|
|
1198
|
-
const timeoutRef =
|
|
1199
|
-
const retryTimeoutRef =
|
|
1490
|
+
const timeoutRef = React.useRef(null);
|
|
1491
|
+
const retryTimeoutRef = React.useRef(null);
|
|
1200
1492
|
// Clear timeouts on unmount
|
|
1201
|
-
|
|
1493
|
+
React.useEffect(() => {
|
|
1202
1494
|
return () => {
|
|
1203
1495
|
if (timeoutRef.current) {
|
|
1204
1496
|
clearTimeout(timeoutRef.current);
|
|
@@ -1209,7 +1501,7 @@ const useLoaderState = (options = {}) => {
|
|
|
1209
1501
|
};
|
|
1210
1502
|
}, []);
|
|
1211
1503
|
// Handle timeout
|
|
1212
|
-
|
|
1504
|
+
React.useEffect(() => {
|
|
1213
1505
|
if (state.isLoading && timeout) {
|
|
1214
1506
|
timeoutRef.current = setTimeout(() => {
|
|
1215
1507
|
setState((prev) => ({
|
|
@@ -1230,16 +1522,16 @@ const useLoaderState = (options = {}) => {
|
|
|
1230
1522
|
};
|
|
1231
1523
|
}, [state.isLoading, timeout, onError]);
|
|
1232
1524
|
// Call onLoadingChange when loading state changes
|
|
1233
|
-
|
|
1525
|
+
React.useEffect(() => {
|
|
1234
1526
|
onLoadingChange?.(state.isLoading);
|
|
1235
1527
|
}, [state.isLoading, onLoadingChange]);
|
|
1236
1528
|
// Call onProgress when progress changes
|
|
1237
|
-
|
|
1529
|
+
React.useEffect(() => {
|
|
1238
1530
|
if (state.progress !== undefined) {
|
|
1239
1531
|
onProgress?.(state.progress);
|
|
1240
1532
|
}
|
|
1241
1533
|
}, [state.progress, onProgress]);
|
|
1242
|
-
const setLoading =
|
|
1534
|
+
const setLoading = React.useCallback((loading) => {
|
|
1243
1535
|
setState((prev) => ({
|
|
1244
1536
|
...prev,
|
|
1245
1537
|
isLoading: loading,
|
|
@@ -1247,7 +1539,7 @@ const useLoaderState = (options = {}) => {
|
|
|
1247
1539
|
progress: loading ? 0 : prev.progress, // Reset progress when starting
|
|
1248
1540
|
}));
|
|
1249
1541
|
}, []);
|
|
1250
|
-
const setProgress =
|
|
1542
|
+
const setProgress = React.useCallback((progress) => {
|
|
1251
1543
|
const clampedProgress = Math.min(Math.max(progress, 0), 100);
|
|
1252
1544
|
setState((prev) => ({
|
|
1253
1545
|
...prev,
|
|
@@ -1256,7 +1548,7 @@ const useLoaderState = (options = {}) => {
|
|
|
1256
1548
|
isLoading: clampedProgress >= 100 ? false : prev.isLoading,
|
|
1257
1549
|
}));
|
|
1258
1550
|
}, []);
|
|
1259
|
-
const setError =
|
|
1551
|
+
const setError = React.useCallback((error) => {
|
|
1260
1552
|
setState((prev) => ({
|
|
1261
1553
|
...prev,
|
|
1262
1554
|
error,
|
|
@@ -1266,7 +1558,7 @@ const useLoaderState = (options = {}) => {
|
|
|
1266
1558
|
onError?.(error);
|
|
1267
1559
|
}
|
|
1268
1560
|
}, [onError]);
|
|
1269
|
-
const retry =
|
|
1561
|
+
const retry = React.useCallback(() => {
|
|
1270
1562
|
setState((prev) => {
|
|
1271
1563
|
const newRetryCount = (prev.retryCount || 0) + 1;
|
|
1272
1564
|
if (newRetryCount > maxRetries) {
|
|
@@ -1291,7 +1583,7 @@ const useLoaderState = (options = {}) => {
|
|
|
1291
1583
|
setState((prev) => ({ ...prev, isLoading: true }));
|
|
1292
1584
|
}, backoffDelay);
|
|
1293
1585
|
}, [state.retryCount, maxRetries, onError]);
|
|
1294
|
-
const reset =
|
|
1586
|
+
const reset = React.useCallback(() => {
|
|
1295
1587
|
setState({
|
|
1296
1588
|
isLoading: false,
|
|
1297
1589
|
progress: 0,
|
|
@@ -1342,8 +1634,8 @@ const useMultipleLoaderStates = (keys, options = {}) => {
|
|
|
1342
1634
|
*/
|
|
1343
1635
|
const useAsyncLoader = (asyncFn, dependencies = [], options = {}) => {
|
|
1344
1636
|
const loaderState = useLoaderState(options);
|
|
1345
|
-
const [data, setData] =
|
|
1346
|
-
const execute =
|
|
1637
|
+
const [data, setData] = React.useState(null);
|
|
1638
|
+
const execute = React.useCallback(async () => {
|
|
1347
1639
|
try {
|
|
1348
1640
|
loaderState.setLoading(true);
|
|
1349
1641
|
loaderState.setError(null);
|
|
@@ -1359,7 +1651,7 @@ const useAsyncLoader = (asyncFn, dependencies = [], options = {}) => {
|
|
|
1359
1651
|
}
|
|
1360
1652
|
}, [asyncFn, loaderState]);
|
|
1361
1653
|
// Auto-execute on dependency changes
|
|
1362
|
-
|
|
1654
|
+
React.useEffect(() => {
|
|
1363
1655
|
execute();
|
|
1364
1656
|
}, dependencies);
|
|
1365
1657
|
return {
|
|
@@ -1376,6 +1668,7 @@ exports.Circle = Circle;
|
|
|
1376
1668
|
exports.Dot = Dot;
|
|
1377
1669
|
exports.DotCluster = DotCluster;
|
|
1378
1670
|
exports.DotsLoader = DotsLoader;
|
|
1671
|
+
exports.ElementLoader = ElementLoader;
|
|
1379
1672
|
exports.FallbackLoader = FallbackLoader;
|
|
1380
1673
|
exports.FlowLoader = FlowLoader;
|
|
1381
1674
|
exports.GridLoader = GridLoader;
|
|
@@ -1406,4 +1699,4 @@ exports.sanitizeCSSValue = sanitizeCSSValue;
|
|
|
1406
1699
|
exports.useAsyncLoader = useAsyncLoader;
|
|
1407
1700
|
exports.useLoaderState = useLoaderState;
|
|
1408
1701
|
exports.useMultipleLoaderStates = useMultipleLoaderStates;
|
|
1409
|
-
//# sourceMappingURL=index.js.map
|
|
1702
|
+
//# sourceMappingURL=index.cjs.js.map
|