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.
@@ -1,5 +1,5 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import * as React from "react";
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 || "4px"
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
- if (typeof node.type === "string") {
40
- const newProps = { ...node.props };
41
- let style = { ...newProps.style };
42
- if (newProps.skeletonrequired === "y") {
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 type = node.type;
51
- const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(type);
52
- style.backgroundColor = isText ? skeletonBgColors.text : skeletonBgColors.box;
53
- style.color = "transparent";
54
- style.position = "relative";
55
- style.overflow = "hidden";
56
- const shimmerBase = isText ? skeletonBgColors.text : skeletonBgColors.box;
57
- style.backgroundImage = `linear-gradient(90deg, ${shimmerBase} 0%, #f5f5f5 50%, ${shimmerBase} 100%)`;
58
- style.backgroundSize = "200% 100%";
59
- style.animation = "shimmer 1.5s infinite";
60
- delete newProps.skeletonrequired;
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
- return node;
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 || "4px"
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 (!React__namespace.isValidElement(node)) return node;
58
- if (typeof node.type === "string") {
59
- const newProps = { ...node.props };
60
- let style = { ...newProps.style };
61
- if (newProps.skeletonrequired === "y") {
62
- const defaults = getComputedStyleFromNode(node);
63
- style.height = style.height || newProps.height || defaults.height || "20px";
64
- style.width = style.width || newProps.width || defaults.width || "100%";
65
- style.fontSize = style.fontSize || newProps.fontSize || defaults.fontSize || "16px";
66
- style.margin = style.margin || newProps.margin || defaults.margin || "0";
67
- style.padding = style.padding || newProps.padding || defaults.padding || "0";
68
- style.borderRadius = style.borderRadius || defaults.borderRadius || "4px";
69
- const type = node.type;
70
- const isText = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(type);
71
- style.backgroundColor = isText ? skeletonBgColors.text : skeletonBgColors.box;
72
- style.color = "transparent";
73
- style.position = "relative";
74
- style.overflow = "hidden";
75
- const shimmerBase = isText ? skeletonBgColors.text : skeletonBgColors.box;
76
- style.backgroundImage = `linear-gradient(90deg, ${shimmerBase} 0%, #f5f5f5 50%, ${shimmerBase} 100%)`;
77
- style.backgroundSize = "200% 100%";
78
- style.animation = "shimmer 1.5s infinite";
79
- delete newProps.skeletonrequired;
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
- return node;
64
+ const childrenNodes = React.Children.map(node.props.children, traverse);
65
+ return React.cloneElement(node, newProps, childrenNodes);
86
66
  }
87
- const result = React__namespace.Children.map(children, traverse);
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skeleton-ghost-loader",
3
- "version": "2.6.3",
3
+ "version": "2.6.5",
4
4
  "description": "Smart skeleton loader that auto-detects styles (inline, class, Tailwind, browser defaults)",
5
5
  "author": "Shubh Patil",
6
6
  "license": "MIT",