premium-react-loaders 2.3.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -3
- package/dist/components/3d/CubeSpinner.d.ts +21 -0
- package/dist/components/3d/CubeSpinner.d.ts.map +1 -0
- package/dist/components/3d/FlipCard.d.ts +21 -0
- package/dist/components/3d/FlipCard.d.ts.map +1 -0
- package/dist/components/3d/Helix.d.ts +23 -0
- package/dist/components/3d/Helix.d.ts.map +1 -0
- package/dist/components/3d/PerspectiveRing.d.ts +21 -0
- package/dist/components/3d/PerspectiveRing.d.ts.map +1 -0
- package/dist/components/3d/PlaneRotate.d.ts +21 -0
- package/dist/components/3d/PlaneRotate.d.ts.map +1 -0
- package/dist/components/3d/index.d.ts +6 -0
- package/dist/components/3d/index.d.ts.map +1 -0
- package/dist/components/accessibility/LiveRegion.d.ts +34 -0
- package/dist/components/accessibility/LiveRegion.d.ts.map +1 -0
- package/dist/components/accessibility/index.d.ts +2 -0
- package/dist/components/accessibility/index.d.ts.map +1 -0
- package/dist/components/bounce/BouncingBalls.d.ts +15 -0
- package/dist/components/bounce/BouncingBalls.d.ts.map +1 -0
- package/dist/components/bounce/BouncingDots.d.ts +15 -0
- package/dist/components/bounce/BouncingDots.d.ts.map +1 -0
- package/dist/components/bounce/index.d.ts +3 -0
- package/dist/components/bounce/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/infinity/InfinityLoader.d.ts +15 -0
- package/dist/components/infinity/InfinityLoader.d.ts.map +1 -0
- package/dist/components/infinity/MobiusLoader.d.ts +15 -0
- package/dist/components/infinity/MobiusLoader.d.ts.map +1 -0
- package/dist/components/infinity/index.d.ts +3 -0
- package/dist/components/infinity/index.d.ts.map +1 -0
- package/dist/components/orbit/AtomLoader.d.ts +15 -0
- package/dist/components/orbit/AtomLoader.d.ts.map +1 -0
- package/dist/components/orbit/OrbitDots.d.ts +15 -0
- package/dist/components/orbit/OrbitDots.d.ts.map +1 -0
- package/dist/components/orbit/OrbitRings.d.ts +15 -0
- package/dist/components/orbit/OrbitRings.d.ts.map +1 -0
- package/dist/components/orbit/index.d.ts +4 -0
- package/dist/components/orbit/index.d.ts.map +1 -0
- package/dist/components/shimmer/ShimmerBox.d.ts +15 -0
- package/dist/components/shimmer/ShimmerBox.d.ts.map +1 -0
- package/dist/components/shimmer/ShimmerButton.d.ts +15 -0
- package/dist/components/shimmer/ShimmerButton.d.ts.map +1 -0
- package/dist/components/shimmer/ShimmerText.d.ts +15 -0
- package/dist/components/shimmer/ShimmerText.d.ts.map +1 -0
- package/dist/components/shimmer/index.d.ts +4 -0
- package/dist/components/shimmer/index.d.ts.map +1 -0
- package/dist/components/skeleton/DataTableSkeleton.d.ts +25 -0
- package/dist/components/skeleton/DataTableSkeleton.d.ts.map +1 -0
- package/dist/components/skeleton/SmartSkeleton.d.ts +23 -0
- package/dist/components/skeleton/SmartSkeleton.d.ts.map +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.d.ts.map +1 -1
- package/dist/components/smart/FormFieldLoader.d.ts +22 -0
- package/dist/components/smart/FormFieldLoader.d.ts.map +1 -0
- package/dist/components/smart/index.d.ts +2 -0
- package/dist/components/smart/index.d.ts.map +1 -0
- package/dist/components/text/LoadingText.d.ts +16 -0
- package/dist/components/text/LoadingText.d.ts.map +1 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useLoadingAnalytics.d.ts +101 -0
- package/dist/hooks/useLoadingAnalytics.d.ts.map +1 -0
- package/dist/hooks/useLoadingOrchestrator.d.ts +104 -0
- package/dist/hooks/useLoadingOrchestrator.d.ts.map +1 -0
- package/dist/hooks/useSmartLoader.d.ts +98 -0
- package/dist/hooks/useSmartLoader.d.ts.map +1 -0
- package/dist/index.cjs +60 -20
- package/dist/index.js +60 -20
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +1 -1
- package/dist/index16.cjs +131 -66
- package/dist/index16.js +132 -67
- package/dist/index17.cjs +245 -30
- package/dist/index17.js +246 -31
- package/dist/index18.cjs +24 -36
- package/dist/index18.js +24 -36
- package/dist/index19.cjs +19 -21
- package/dist/index19.js +19 -21
- package/dist/index20.cjs +25 -20
- package/dist/index20.js +25 -20
- package/dist/index21.cjs +22 -32
- package/dist/index21.js +22 -32
- package/dist/index22.cjs +26 -35
- package/dist/index22.js +28 -37
- package/dist/index23.cjs +40 -76
- package/dist/index23.js +42 -78
- package/dist/index24.cjs +53 -102
- package/dist/index24.js +54 -103
- package/dist/index25.cjs +46 -80
- package/dist/index25.js +47 -81
- package/dist/index26.cjs +105 -103
- package/dist/index26.js +107 -105
- package/dist/index27.cjs +108 -27
- package/dist/index27.js +111 -30
- package/dist/index28.cjs +104 -36
- package/dist/index28.js +106 -38
- package/dist/index29.cjs +22 -30
- package/dist/index29.js +23 -31
- package/dist/index30.cjs +30 -32
- package/dist/index30.js +31 -33
- package/dist/index31.cjs +49 -52
- package/dist/index31.js +50 -53
- package/dist/index32.cjs +37 -108
- package/dist/index32.js +38 -109
- package/dist/index33.cjs +54 -72
- package/dist/index33.js +55 -73
- package/dist/index34.cjs +112 -80
- package/dist/index34.js +112 -80
- package/dist/index35.cjs +78 -145
- package/dist/index35.js +80 -147
- package/dist/index36.cjs +112 -120
- package/dist/index36.js +113 -121
- package/dist/index37.cjs +167 -0
- package/dist/index37.js +167 -0
- package/dist/index38.cjs +96 -0
- package/dist/index38.js +96 -0
- package/dist/index39.cjs +113 -0
- package/dist/index39.js +113 -0
- package/dist/index40.cjs +169 -0
- package/dist/index40.js +169 -0
- package/dist/index41.cjs +97 -0
- package/dist/index41.js +97 -0
- package/dist/index42.cjs +90 -0
- package/dist/index42.js +90 -0
- package/dist/index43.cjs +139 -0
- package/dist/index43.js +139 -0
- package/dist/index44.cjs +82 -0
- package/dist/index44.js +82 -0
- package/dist/index45.cjs +110 -0
- package/dist/index45.js +110 -0
- package/dist/index46.cjs +135 -0
- package/dist/index46.js +135 -0
- package/dist/index47.cjs +106 -0
- package/dist/index47.js +106 -0
- package/dist/index48.cjs +158 -0
- package/dist/index48.js +158 -0
- package/dist/index49.cjs +167 -0
- package/dist/index49.js +167 -0
- package/dist/index50.cjs +110 -0
- package/dist/index50.js +110 -0
- package/dist/index51.cjs +112 -0
- package/dist/index51.js +112 -0
- package/dist/index52.cjs +144 -0
- package/dist/index52.js +144 -0
- package/dist/index53.cjs +112 -0
- package/dist/index53.js +112 -0
- package/dist/index54.cjs +189 -0
- package/dist/index54.js +189 -0
- package/dist/index55.cjs +53 -0
- package/dist/index55.js +53 -0
- package/dist/index56.cjs +125 -0
- package/dist/index56.js +125 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +1 -1
- package/dist/premium-react-loaders.css +357 -0
- package/dist/types/3d.d.ts +85 -0
- package/dist/types/3d.d.ts.map +1 -0
- package/dist/types/accessibility.d.ts +35 -0
- package/dist/types/accessibility.d.ts.map +1 -0
- package/dist/types/bounce.d.ts +41 -0
- package/dist/types/bounce.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/infinity.d.ts +35 -0
- package/dist/types/infinity.d.ts.map +1 -0
- package/dist/types/orbit.d.ts +50 -0
- package/dist/types/orbit.d.ts.map +1 -0
- package/dist/types/shimmer.d.ts +52 -0
- package/dist/types/shimmer.d.ts.map +1 -0
- package/dist/types/smart.d.ts +63 -0
- package/dist/types/smart.d.ts.map +1 -0
- package/dist/types/text.d.ts +27 -0
- package/dist/types/text.d.ts.map +1 -0
- package/dist/utils/accessibility.d.ts +67 -0
- package/dist/utils/accessibility.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index12.cjs
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const Skeleton = require("./index7.cjs");
|
|
6
|
-
const hooks = require("./
|
|
6
|
+
const hooks = require("./index56.cjs");
|
|
7
7
|
const colors = require("./index4.cjs");
|
|
8
8
|
const classNames = require("./index3.cjs");
|
|
9
9
|
const SkeletonList = react.forwardRef(
|
package/dist/index12.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Skeleton } from "./index7.js";
|
|
4
|
-
import { useLoaderVisibility } from "./
|
|
4
|
+
import { useLoaderVisibility } from "./index56.js";
|
|
5
5
|
import { normalizeSize } from "./index4.js";
|
|
6
6
|
import { cn } from "./index3.js";
|
|
7
7
|
const SkeletonList = forwardRef(
|
package/dist/index13.cjs
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const Skeleton = require("./index7.cjs");
|
|
6
|
-
const hooks = require("./
|
|
6
|
+
const hooks = require("./index56.cjs");
|
|
7
7
|
const classNames = require("./index3.cjs");
|
|
8
8
|
const SkeletonTable = react.forwardRef(
|
|
9
9
|
({
|
package/dist/index13.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Skeleton } from "./index7.js";
|
|
4
|
-
import { useLoaderVisibility } from "./
|
|
4
|
+
import { useLoaderVisibility } from "./index56.js";
|
|
5
5
|
import { cn } from "./index3.js";
|
|
6
6
|
const SkeletonTable = forwardRef(
|
|
7
7
|
({
|
package/dist/index14.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const react = require("react");
|
|
|
5
5
|
const Skeleton = require("./index7.cjs");
|
|
6
6
|
const SkeletonText = require("./index8.cjs");
|
|
7
7
|
const SkeletonAvatar = require("./index9.cjs");
|
|
8
|
-
const hooks = require("./
|
|
8
|
+
const hooks = require("./index56.cjs");
|
|
9
9
|
const classNames = require("./index3.cjs");
|
|
10
10
|
const SkeletonPage = react.forwardRef(
|
|
11
11
|
({
|
package/dist/index14.js
CHANGED
|
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
|
|
|
3
3
|
import { Skeleton } from "./index7.js";
|
|
4
4
|
import { SkeletonText } from "./index8.js";
|
|
5
5
|
import { SkeletonAvatar } from "./index9.js";
|
|
6
|
-
import { useLoaderVisibility } from "./
|
|
6
|
+
import { useLoaderVisibility } from "./index56.js";
|
|
7
7
|
import { cn } from "./index3.js";
|
|
8
8
|
const SkeletonPage = forwardRef(
|
|
9
9
|
({
|
package/dist/index15.cjs
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const Skeleton = require("./index7.cjs");
|
|
6
|
-
const hooks = require("./
|
|
6
|
+
const hooks = require("./index56.cjs");
|
|
7
7
|
const colors = require("./index4.cjs");
|
|
8
8
|
const classNames = require("./index3.cjs");
|
|
9
9
|
const SkeletonForm = react.forwardRef(
|
package/dist/index15.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Skeleton } from "./index7.js";
|
|
4
|
-
import { useLoaderVisibility } from "./
|
|
4
|
+
import { useLoaderVisibility } from "./index56.js";
|
|
5
5
|
import { normalizeSize } from "./index4.js";
|
|
6
6
|
import { cn } from "./index3.js";
|
|
7
7
|
const SkeletonForm = forwardRef(
|
package/dist/index16.cjs
CHANGED
|
@@ -2,80 +2,145 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
5
|
+
const SkeletonCard = require("./index11.cjs");
|
|
6
|
+
const SkeletonTable = require("./index13.cjs");
|
|
7
|
+
const SkeletonList = require("./index12.cjs");
|
|
8
|
+
const SkeletonText = require("./index8.cjs");
|
|
9
|
+
const SkeletonImage = require("./index10.cjs");
|
|
10
|
+
const SkeletonForm = require("./index15.cjs");
|
|
11
|
+
const SmartSkeleton = react.forwardRef(
|
|
9
12
|
({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
contentType = "text",
|
|
14
|
+
referenceElement,
|
|
15
|
+
itemCount = 3,
|
|
16
|
+
detectionStrategy = "mixed",
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
animate = true,
|
|
20
|
+
baseColor,
|
|
21
|
+
highlightColor,
|
|
19
22
|
className,
|
|
20
23
|
style,
|
|
21
|
-
testId = "
|
|
24
|
+
testId = "smart-skeleton",
|
|
22
25
|
visible = true,
|
|
23
|
-
ariaLabel = "Loading...",
|
|
24
26
|
...rest
|
|
25
27
|
}, ref) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const [detectedType, setDetectedType] = react.useState(contentType);
|
|
29
|
+
react.useEffect(() => {
|
|
30
|
+
if (contentType !== "auto" || !referenceElement) return;
|
|
31
|
+
const detectContentType = () => {
|
|
32
|
+
if (detectionStrategy === "dom" || detectionStrategy === "mixed") {
|
|
33
|
+
const tagName = referenceElement.tagName.toLowerCase();
|
|
34
|
+
if (tagName === "table" || referenceElement.querySelector("table")) {
|
|
35
|
+
return "table";
|
|
36
|
+
}
|
|
37
|
+
if (tagName === "form" || referenceElement.querySelector("form")) {
|
|
38
|
+
return "form";
|
|
39
|
+
}
|
|
40
|
+
if (tagName === "ul" || tagName === "ol" || referenceElement.querySelector("ul, ol")) {
|
|
41
|
+
return "list";
|
|
42
|
+
}
|
|
43
|
+
if (tagName === "img" || referenceElement.querySelector("img")) {
|
|
44
|
+
return "image";
|
|
45
|
+
}
|
|
46
|
+
const hasImage = !!referenceElement.querySelector("img");
|
|
47
|
+
const hasText = referenceElement.textContent && referenceElement.textContent.length > 50;
|
|
48
|
+
if (hasImage && hasText) {
|
|
49
|
+
return "card";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (detectionStrategy === "dimensions" || detectionStrategy === "mixed") {
|
|
53
|
+
const { width: width2, height: height2 } = referenceElement.getBoundingClientRect();
|
|
54
|
+
const aspectRatio = width2 / height2;
|
|
55
|
+
if (aspectRatio > 2 && height2 < 100) {
|
|
56
|
+
return "text";
|
|
57
|
+
}
|
|
58
|
+
if (aspectRatio >= 0.7 && aspectRatio <= 1.5 && width2 > 200) {
|
|
59
|
+
return "card";
|
|
60
|
+
}
|
|
61
|
+
if (aspectRatio > 3) {
|
|
62
|
+
return "table";
|
|
63
|
+
}
|
|
64
|
+
if (aspectRatio < 0.5) {
|
|
65
|
+
return "list";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return "text";
|
|
69
|
+
};
|
|
70
|
+
const type = detectContentType();
|
|
71
|
+
setDetectedType(type);
|
|
72
|
+
}, [contentType, referenceElement, detectionStrategy]);
|
|
73
|
+
const activeType = contentType === "auto" ? detectedType : contentType;
|
|
74
|
+
const commonProps = {
|
|
75
|
+
ref,
|
|
76
|
+
className,
|
|
77
|
+
style,
|
|
78
|
+
testId,
|
|
29
79
|
visible,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
animate,
|
|
81
|
+
baseColor,
|
|
82
|
+
highlightColor,
|
|
83
|
+
...rest
|
|
84
|
+
};
|
|
85
|
+
switch (activeType) {
|
|
86
|
+
case "card":
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
SkeletonCard.SkeletonCard,
|
|
89
|
+
{
|
|
90
|
+
...commonProps,
|
|
91
|
+
width,
|
|
92
|
+
hasAvatar: true,
|
|
93
|
+
lines: 3
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
case "table":
|
|
97
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
SkeletonTable.SkeletonTable,
|
|
99
|
+
{
|
|
100
|
+
...commonProps,
|
|
101
|
+
rows: itemCount,
|
|
102
|
+
columns: 4,
|
|
103
|
+
showHeader: true
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
case "list":
|
|
107
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
108
|
+
SkeletonList.SkeletonList,
|
|
109
|
+
{
|
|
110
|
+
...commonProps,
|
|
111
|
+
items: itemCount,
|
|
112
|
+
itemHeight: 60
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
case "form":
|
|
116
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
117
|
+
SkeletonForm.SkeletonForm,
|
|
118
|
+
{
|
|
119
|
+
...commonProps,
|
|
120
|
+
fields: itemCount || 4,
|
|
121
|
+
showLabels: true
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
case "image":
|
|
125
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
126
|
+
SkeletonImage.SkeletonImage,
|
|
127
|
+
{
|
|
128
|
+
...commonProps,
|
|
129
|
+
width: width || "100%",
|
|
130
|
+
height: height || 200
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
case "text":
|
|
134
|
+
default:
|
|
135
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
SkeletonText.SkeletonText,
|
|
52
137
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
width: colors.normalizeSize(size),
|
|
56
|
-
height: colors.normalizeSize(size),
|
|
57
|
-
animationDuration: effectiveDuration,
|
|
58
|
-
animationDirection: reverse ? "reverse" : "normal"
|
|
59
|
-
},
|
|
60
|
-
viewBox: "0 0 50 50",
|
|
61
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
62
|
-
"circle",
|
|
63
|
-
{
|
|
64
|
-
cx: "25",
|
|
65
|
-
cy: "25",
|
|
66
|
-
r: 25 - thickness * 2,
|
|
67
|
-
fill: "none",
|
|
68
|
-
stroke: color,
|
|
69
|
-
strokeWidth: thickness,
|
|
70
|
-
strokeDasharray: "80, 200",
|
|
71
|
-
strokeLinecap: "round"
|
|
72
|
-
}
|
|
73
|
-
)
|
|
138
|
+
...commonProps,
|
|
139
|
+
lines: itemCount
|
|
74
140
|
}
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
);
|
|
141
|
+
);
|
|
142
|
+
}
|
|
78
143
|
}
|
|
79
144
|
);
|
|
80
|
-
|
|
81
|
-
exports.
|
|
145
|
+
SmartSkeleton.displayName = "SmartSkeleton";
|
|
146
|
+
exports.SmartSkeleton = SmartSkeleton;
|
package/dist/index16.js
CHANGED
|
@@ -1,81 +1,146 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { forwardRef, useState, useEffect } from "react";
|
|
3
|
+
import { SkeletonCard } from "./index11.js";
|
|
4
|
+
import { SkeletonTable } from "./index13.js";
|
|
5
|
+
import { SkeletonList } from "./index12.js";
|
|
6
|
+
import { SkeletonText } from "./index8.js";
|
|
7
|
+
import { SkeletonImage } from "./index10.js";
|
|
8
|
+
import { SkeletonForm } from "./index15.js";
|
|
9
|
+
const SmartSkeleton = forwardRef(
|
|
7
10
|
({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
contentType = "text",
|
|
12
|
+
referenceElement,
|
|
13
|
+
itemCount = 3,
|
|
14
|
+
detectionStrategy = "mixed",
|
|
15
|
+
width,
|
|
16
|
+
height,
|
|
17
|
+
animate = true,
|
|
18
|
+
baseColor,
|
|
19
|
+
highlightColor,
|
|
17
20
|
className,
|
|
18
21
|
style,
|
|
19
|
-
testId = "
|
|
22
|
+
testId = "smart-skeleton",
|
|
20
23
|
visible = true,
|
|
21
|
-
ariaLabel = "Loading...",
|
|
22
24
|
...rest
|
|
23
25
|
}, ref) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const [detectedType, setDetectedType] = useState(contentType);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (contentType !== "auto" || !referenceElement) return;
|
|
29
|
+
const detectContentType = () => {
|
|
30
|
+
if (detectionStrategy === "dom" || detectionStrategy === "mixed") {
|
|
31
|
+
const tagName = referenceElement.tagName.toLowerCase();
|
|
32
|
+
if (tagName === "table" || referenceElement.querySelector("table")) {
|
|
33
|
+
return "table";
|
|
34
|
+
}
|
|
35
|
+
if (tagName === "form" || referenceElement.querySelector("form")) {
|
|
36
|
+
return "form";
|
|
37
|
+
}
|
|
38
|
+
if (tagName === "ul" || tagName === "ol" || referenceElement.querySelector("ul, ol")) {
|
|
39
|
+
return "list";
|
|
40
|
+
}
|
|
41
|
+
if (tagName === "img" || referenceElement.querySelector("img")) {
|
|
42
|
+
return "image";
|
|
43
|
+
}
|
|
44
|
+
const hasImage = !!referenceElement.querySelector("img");
|
|
45
|
+
const hasText = referenceElement.textContent && referenceElement.textContent.length > 50;
|
|
46
|
+
if (hasImage && hasText) {
|
|
47
|
+
return "card";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (detectionStrategy === "dimensions" || detectionStrategy === "mixed") {
|
|
51
|
+
const { width: width2, height: height2 } = referenceElement.getBoundingClientRect();
|
|
52
|
+
const aspectRatio = width2 / height2;
|
|
53
|
+
if (aspectRatio > 2 && height2 < 100) {
|
|
54
|
+
return "text";
|
|
55
|
+
}
|
|
56
|
+
if (aspectRatio >= 0.7 && aspectRatio <= 1.5 && width2 > 200) {
|
|
57
|
+
return "card";
|
|
58
|
+
}
|
|
59
|
+
if (aspectRatio > 3) {
|
|
60
|
+
return "table";
|
|
61
|
+
}
|
|
62
|
+
if (aspectRatio < 0.5) {
|
|
63
|
+
return "list";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return "text";
|
|
67
|
+
};
|
|
68
|
+
const type = detectContentType();
|
|
69
|
+
setDetectedType(type);
|
|
70
|
+
}, [contentType, referenceElement, detectionStrategy]);
|
|
71
|
+
const activeType = contentType === "auto" ? detectedType : contentType;
|
|
72
|
+
const commonProps = {
|
|
73
|
+
ref,
|
|
74
|
+
className,
|
|
75
|
+
style,
|
|
76
|
+
testId,
|
|
27
77
|
visible,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
78
|
+
animate,
|
|
79
|
+
baseColor,
|
|
80
|
+
highlightColor,
|
|
81
|
+
...rest
|
|
82
|
+
};
|
|
83
|
+
switch (activeType) {
|
|
84
|
+
case "card":
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
SkeletonCard,
|
|
87
|
+
{
|
|
88
|
+
...commonProps,
|
|
89
|
+
width,
|
|
90
|
+
hasAvatar: true,
|
|
91
|
+
lines: 3
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
case "table":
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
SkeletonTable,
|
|
97
|
+
{
|
|
98
|
+
...commonProps,
|
|
99
|
+
rows: itemCount,
|
|
100
|
+
columns: 4,
|
|
101
|
+
showHeader: true
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
case "list":
|
|
105
|
+
return /* @__PURE__ */ jsx(
|
|
106
|
+
SkeletonList,
|
|
107
|
+
{
|
|
108
|
+
...commonProps,
|
|
109
|
+
items: itemCount,
|
|
110
|
+
itemHeight: 60
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
case "form":
|
|
114
|
+
return /* @__PURE__ */ jsx(
|
|
115
|
+
SkeletonForm,
|
|
116
|
+
{
|
|
117
|
+
...commonProps,
|
|
118
|
+
fields: itemCount || 4,
|
|
119
|
+
showLabels: true
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
case "image":
|
|
123
|
+
return /* @__PURE__ */ jsx(
|
|
124
|
+
SkeletonImage,
|
|
125
|
+
{
|
|
126
|
+
...commonProps,
|
|
127
|
+
width: width || "100%",
|
|
128
|
+
height: height || 200
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
case "text":
|
|
132
|
+
default:
|
|
133
|
+
return /* @__PURE__ */ jsx(
|
|
134
|
+
SkeletonText,
|
|
50
135
|
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
width: normalizeSize(size),
|
|
54
|
-
height: normalizeSize(size),
|
|
55
|
-
animationDuration: effectiveDuration,
|
|
56
|
-
animationDirection: reverse ? "reverse" : "normal"
|
|
57
|
-
},
|
|
58
|
-
viewBox: "0 0 50 50",
|
|
59
|
-
children: /* @__PURE__ */ jsx(
|
|
60
|
-
"circle",
|
|
61
|
-
{
|
|
62
|
-
cx: "25",
|
|
63
|
-
cy: "25",
|
|
64
|
-
r: 25 - thickness * 2,
|
|
65
|
-
fill: "none",
|
|
66
|
-
stroke: color,
|
|
67
|
-
strokeWidth: thickness,
|
|
68
|
-
strokeDasharray: "80, 200",
|
|
69
|
-
strokeLinecap: "round"
|
|
70
|
-
}
|
|
71
|
-
)
|
|
136
|
+
...commonProps,
|
|
137
|
+
lines: itemCount
|
|
72
138
|
}
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
);
|
|
139
|
+
);
|
|
140
|
+
}
|
|
76
141
|
}
|
|
77
142
|
);
|
|
78
|
-
|
|
143
|
+
SmartSkeleton.displayName = "SmartSkeleton";
|
|
79
144
|
export {
|
|
80
|
-
|
|
145
|
+
SmartSkeleton
|
|
81
146
|
};
|