skeleton-ghost-loader 2.6.3 → 2.6.5
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/dist/skeleton-loader.es.js +26 -29
- package/dist/skeleton-loader.umd.js +27 -47
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React from "react";
|
|
3
3
|
const skeletonBgColors = {
|
|
4
4
|
text: "#ccc",
|
|
5
5
|
box: "#e0e0e0"
|
|
@@ -27,7 +27,7 @@ function getComputedStyleFromNode(node) {
|
|
|
27
27
|
fontSize: cs.fontSize || void 0,
|
|
28
28
|
margin: cs.margin || "0",
|
|
29
29
|
padding: cs.padding || "0",
|
|
30
|
-
borderRadius: cs.borderRadius || "
|
|
30
|
+
borderRadius: cs.borderRadius || "0px"
|
|
31
31
|
};
|
|
32
32
|
document.body.removeChild(el);
|
|
33
33
|
styleCache[key] = computed;
|
|
@@ -36,34 +36,31 @@ function getComputedStyleFromNode(node) {
|
|
|
36
36
|
const SkeletonBlock = ({ children }) => {
|
|
37
37
|
function traverse(node) {
|
|
38
38
|
if (!React.isValidElement(node)) return node;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
newProps.style = style;
|
|
62
|
-
}
|
|
63
|
-
const childrenNodes = React.Children.map(node.props.children, traverse);
|
|
64
|
-
return React.cloneElement(node, newProps, childrenNodes);
|
|
39
|
+
let newProps = { ...node.props };
|
|
40
|
+
let style = { ...newProps.style };
|
|
41
|
+
if (newProps.skeletonrequired === "y" && typeof node.type === "string") {
|
|
42
|
+
const type = node.type;
|
|
43
|
+
const defaults = getComputedStyleFromNode(node);
|
|
44
|
+
style.height = style.height || newProps.height || defaults.height || "20px";
|
|
45
|
+
style.width = style.width || newProps.width || defaults.width || "100%";
|
|
46
|
+
style.fontSize = style.fontSize || newProps.fontSize || defaults.fontSize || "16px";
|
|
47
|
+
style.margin = style.margin || newProps.margin || defaults.margin || "0";
|
|
48
|
+
style.padding = style.padding || newProps.padding || defaults.padding || "0";
|
|
49
|
+
style.borderRadius = style.borderRadius || defaults.borderRadius || "4px";
|
|
50
|
+
const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(type);
|
|
51
|
+
style.backgroundColor = isText ? skeletonBgColors.text : skeletonBgColors.box;
|
|
52
|
+
style.color = "transparent";
|
|
53
|
+
style.position = "relative";
|
|
54
|
+
style.overflow = "hidden";
|
|
55
|
+
const shimmerBase = isText ? skeletonBgColors.text : skeletonBgColors.box;
|
|
56
|
+
style.backgroundImage = `linear-gradient(90deg, ${shimmerBase} 0%, #f5f5f5 50%, ${shimmerBase} 100%)`;
|
|
57
|
+
style.backgroundSize = "200% 100%";
|
|
58
|
+
style.animation = "shimmer 1.5s infinite";
|
|
59
|
+
delete newProps.skeletonrequired;
|
|
60
|
+
newProps.style = style;
|
|
65
61
|
}
|
|
66
|
-
|
|
62
|
+
const childrenNodes = React.Children.map(node.props.children, traverse);
|
|
63
|
+
return React.cloneElement(node, newProps, childrenNodes);
|
|
67
64
|
}
|
|
68
65
|
const result = React.Children.map(children, traverse);
|
|
69
66
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -2,23 +2,6 @@
|
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.SkeletonGhostLoader = {}, global.jsxRuntime, global.React));
|
|
3
3
|
})(this, function(exports2, jsxRuntime, React) {
|
|
4
4
|
"use strict";
|
|
5
|
-
function _interopNamespaceDefault(e) {
|
|
6
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
-
if (e) {
|
|
8
|
-
for (const k in e) {
|
|
9
|
-
if (k !== "default") {
|
|
10
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: () => e[k]
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
22
5
|
const skeletonBgColors = {
|
|
23
6
|
text: "#ccc",
|
|
24
7
|
box: "#e0e0e0"
|
|
@@ -46,7 +29,7 @@
|
|
|
46
29
|
fontSize: cs.fontSize || void 0,
|
|
47
30
|
margin: cs.margin || "0",
|
|
48
31
|
padding: cs.padding || "0",
|
|
49
|
-
borderRadius: cs.borderRadius || "
|
|
32
|
+
borderRadius: cs.borderRadius || "0px"
|
|
50
33
|
};
|
|
51
34
|
document.body.removeChild(el);
|
|
52
35
|
styleCache[key] = computed;
|
|
@@ -54,37 +37,34 @@
|
|
|
54
37
|
}
|
|
55
38
|
const SkeletonBlock = ({ children }) => {
|
|
56
39
|
function traverse(node) {
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
newProps.style = style;
|
|
81
|
-
}
|
|
82
|
-
const childrenNodes = React__namespace.Children.map(node.props.children, traverse);
|
|
83
|
-
return React__namespace.cloneElement(node, newProps, childrenNodes);
|
|
40
|
+
if (!React.isValidElement(node)) return node;
|
|
41
|
+
let newProps = { ...node.props };
|
|
42
|
+
let style = { ...newProps.style };
|
|
43
|
+
if (newProps.skeletonrequired === "y" && typeof node.type === "string") {
|
|
44
|
+
const type = node.type;
|
|
45
|
+
const defaults = getComputedStyleFromNode(node);
|
|
46
|
+
style.height = style.height || newProps.height || defaults.height || "20px";
|
|
47
|
+
style.width = style.width || newProps.width || defaults.width || "100%";
|
|
48
|
+
style.fontSize = style.fontSize || newProps.fontSize || defaults.fontSize || "16px";
|
|
49
|
+
style.margin = style.margin || newProps.margin || defaults.margin || "0";
|
|
50
|
+
style.padding = style.padding || newProps.padding || defaults.padding || "0";
|
|
51
|
+
style.borderRadius = style.borderRadius || defaults.borderRadius || "4px";
|
|
52
|
+
const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(type);
|
|
53
|
+
style.backgroundColor = isText ? skeletonBgColors.text : skeletonBgColors.box;
|
|
54
|
+
style.color = "transparent";
|
|
55
|
+
style.position = "relative";
|
|
56
|
+
style.overflow = "hidden";
|
|
57
|
+
const shimmerBase = isText ? skeletonBgColors.text : skeletonBgColors.box;
|
|
58
|
+
style.backgroundImage = `linear-gradient(90deg, ${shimmerBase} 0%, #f5f5f5 50%, ${shimmerBase} 100%)`;
|
|
59
|
+
style.backgroundSize = "200% 100%";
|
|
60
|
+
style.animation = "shimmer 1.5s infinite";
|
|
61
|
+
delete newProps.skeletonrequired;
|
|
62
|
+
newProps.style = style;
|
|
84
63
|
}
|
|
85
|
-
|
|
64
|
+
const childrenNodes = React.Children.map(node.props.children, traverse);
|
|
65
|
+
return React.cloneElement(node, newProps, childrenNodes);
|
|
86
66
|
}
|
|
87
|
-
const result =
|
|
67
|
+
const result = React.Children.map(children, traverse);
|
|
88
68
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
89
69
|
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
90
70
|
@keyframes shimmer {
|