react-skeletonify 1.0.2 → 1.1.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 CHANGED
@@ -1,21 +1,41 @@
1
- [![npm version](https://img.shields.io/npm/v/react-skeletonify.svg)](https://www.npmjs.com/package/react-skeletonify)
2
- [![npm downloads](https://img.shields.io/npm/dm/react-skeletonify.svg)](https://www.npmjs.com/package/react-skeletonify)
3
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
4
-
5
- # React Skeletonify
6
-
7
- React Skeletonify is a lightweight React skeleton loader component. Create beautiful loading placeholders for text, images, buttons, or cards with smooth animations.
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/Sinan0333/react-smart-skeleton/main/assets/logo.png" alt="React Skeletonify Logo" width="120" height="110" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/react-skeletonify">
7
+ <img src="https://img.shields.io/npm/v/react-skeletonify.svg" alt="npm version" />
8
+ </a>
9
+ <a href="https://www.npmjs.com/package/react-skeletonify">
10
+ <img src="https://img.shields.io/npm/dm/react-skeletonify.svg" alt="npm downloads" />
11
+ </a>
12
+ <a href="https://github.com/prettier/prettier">
13
+ <img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square" alt="code style: prettier" />
14
+ </a>
15
+ </p>
16
+
17
+ <h1 align="center">⚡ React Skeletonify</h1>
18
+
19
+ A **lightweight and flexible skeleton loader** for React, built to make loading states feel smooth and natural.
20
+ Unlike traditional static skeletons, **React Skeletonify** adapts to your components dynamically — letting you configure animations, styles, and exclusions globally or per-component.
8
21
 
9
22
  ## 🎮 Live Demo
10
23
 
11
24
  👉 [Try it here](https://playcode.io/2556254)
12
25
 
26
+ ## 📚 Documentation
27
+
28
+ For complete guides and examples check out the full documentation site:
29
+ 👉 [React Skeletonify Documentation](https://react-skeletonify.sinan-dev.in)
30
+
13
31
  ## ✨ Features
14
32
 
15
- - Lightweight and dependency-free
16
- - Easy to wrap around any component
17
- - Smooth animations
18
- - Customizable styles
33
+ - 🎨 **Global & local configuration** with `SkeletonProvider` and `SkeletonWrapper`
34
+ - **Smooth animations** with multiple presets
35
+ - 🛠️ **Highly customizable** styles, backgrounds, borders, and speed
36
+ - 🧩 Works with **any React component**
37
+ - 🧃 Exclude tags or groups (text, form, media, etc.) from skeleton rendering
38
+ - 🪶 Lightweight, no external dependencies
19
39
 
20
40
  ## 🚀 Installation
21
41
 
@@ -25,32 +45,41 @@ npm install react-skeletonify
25
45
  yarn add react-skeletonify
26
46
  ```
27
47
 
28
- ```bash
29
- import "react-skeletonify/dist/index.css";
48
+ Import styles once:
30
49
 
50
+ ```tsx
51
+ import "react-skeletonify/dist/index.css";
31
52
  ```
32
53
 
33
- ## Example
54
+ ## 🔥 Quick Example
34
55
 
35
- ```jsx
56
+ ```tsx
36
57
  import React from "react";
37
- import { SkeletonWrapper } from "react-skeletonify";
58
+ import { SkeletonProvider, SkeletonWrapper } from "react-skeletonify";
38
59
  import "react-skeletonify/dist/index.css";
39
60
 
40
61
  function App() {
41
62
  return (
42
- <SkeletonWrapper loading={true}>
43
- <div style={{ height: "100px", width: "500px", padding: "10px" }}>
44
- <div
45
- style={{
46
- height: "50px",
47
- width: "50px",
48
- borderRadius: "100%",
49
- }}></div>
50
- <h6>React Skeletonify</h6>
51
- <p>Example React component for creating loading skeleton</p>
52
- </div>
53
- </SkeletonWrapper>
63
+ <SkeletonProvider
64
+ config={{
65
+ animation: "animation-1",
66
+ borderRadius: "8px",
67
+ animationSpeed: 3,
68
+ }}>
69
+ <SkeletonWrapper loading={true}>
70
+ <div style={{ height: "120px", width: "400px", padding: "10px" }}>
71
+ <div
72
+ style={{
73
+ height: "50px",
74
+ width: "50px",
75
+ borderRadius: "100%",
76
+ marginBottom: "10px",
77
+ }}></div>
78
+ <h6>React Skeletonify</h6>
79
+ <p>This is an example with global provider config 🚀</p>
80
+ </div>
81
+ </SkeletonWrapper>
82
+ </SkeletonProvider>
54
83
  );
55
84
  }
56
85
 
@@ -59,23 +88,81 @@ export default App;
59
88
 
60
89
  ## ⚙️ API
61
90
 
62
- ### SkeletonWrapper
91
+ ### 🔹 `SkeletonProvider`
92
+
93
+ Provides **global configuration** for skeletons. Wrap your app (or part of it) in this provider.
94
+
95
+ | Prop | Type | Default | Description |
96
+ | -------- | ------------------------- | ------- | ---------------------- |
97
+ | children | `ReactNode` | `null` | Child components |
98
+ | config | `Partial<SkeletonConfig>` | `{}` | Global skeleton config |
99
+ | style | `CSSProperties` | `{}` | Inline style overrides |
100
+
101
+ ---
102
+
103
+ ### 🔹 `SkeletonWrapper`
104
+
105
+ Wraps **specific content** and applies skeletons when `loading` is true.
106
+ It can **inherit** from `SkeletonProvider` or override per instance.
107
+
108
+ | Prop | Type | Default | Description |
109
+ | -------------- | ------------------------- | ------- | ---------------------- |
110
+ | loading | `boolean` | `false` | Show skeleton if true |
111
+ | children | `ReactNode` | `null` | Content to render |
112
+ | overrideConfig | `Partial<SkeletonConfig>` | `{}` | Override global config |
113
+ | style | `CSSProperties` | `{}` | Inline style overrides |
114
+
115
+ ---
116
+
117
+ ## 🎨 Configuration Options (`SkeletonConfig`)
118
+
119
+ | Key | Type | Default | Description |
120
+ | --------------- | -------------------------------- | --------------- | -------------------- |
121
+ | animationSpeed | `number` | `3` | Speed of animation |
122
+ | background | `string` | `#aeaeae` | Background color |
123
+ | border | `string` | `"none"` | Border style |
124
+ | borderRadius | `string \| number` | `"0"` | Border radius |
125
+ | textTagsMargin | `string` | `"0"` | Margin for text tags |
126
+ | className | `string` | `""` | Custom class |
127
+ | style | `CSSProperties` | `{}` | Inline styles |
128
+ | animation | `"animation-1" \| "animation-2"` | `"animation-1"` | Animation type |
129
+ | exceptTags | `string[]` | `[]` | Excluded HTML tags |
130
+ | exceptTagGroups | `HtmlTagGroup[]` | `[]` | Excluded tag groups |
131
+
132
+ **Available Tag Groups:**
133
+ `TEXT_TAGS`, `STRUCTURE_TAGS`, `METADATA_TAGS`, `LIST_TAGS`, `TABLE_TAGS`, `FORM_TAGS`, `MEDIA_TAGS`, `INTERACTIVE_TAGS`, `MISC_TAGS`
134
+
135
+ ---
136
+
137
+ ## 📦 Example with `exceptTags`
138
+
139
+ ```tsx
140
+ <SkeletonWrapper
141
+ loading={true}
142
+ overrideConfig={{
143
+ exceptTags: ["img", "button"],
144
+ borderRadius: "6px",
145
+ }}>
146
+ <div>
147
+ <img src="/profile.jpg" alt="Profile" />
148
+ <h2>Hello World</h2>
149
+ <button>Click me</button>
150
+ </div>
151
+ </SkeletonWrapper>
152
+ ```
63
153
 
64
- | Prop | Type | Default | Description |
65
- | :------: | :-------: | :-----: | :---------------------------------------: |
66
- | loading | boolean | false | Whether to show skeletons or real content |
67
- | children | ReactNode | null | Content you want wrapped with skeletons |
154
+ 👉 In this case, the `img` and `button` will not be skeletonized.
68
155
 
69
- ## Versioning
156
+ ## 📌 Versioning
70
157
 
71
158
  We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [versions](https://www.npmjs.com/package/react-skeletonify?activeTab=versions).
72
159
 
73
160
  ## 🤝 Contributing
74
161
 
75
- Contributions, issues, and feature requests are welcome!
76
- Feel free to open a PR or issue.
162
+ Contributions, issues, and feature requests are welcome! 🎉
163
+ Feel free to open a PR or an issue.
77
164
 
78
- ## Authors
165
+ ## 👨‍💻 Author
79
166
 
80
167
  - **Sinan** - [GitHub](https://github.com/Sinan0333) · [Portfolio](http://sinan-dev.in)
81
168
 
package/dist/index.css CHANGED
@@ -1,27 +1,39 @@
1
1
  /* src/styles/skeleton.css */
2
- .Rss-skeleton {
3
- animation: Rss-skeleton-loading 1s linear infinite alternate;
4
- background-color: hsl(200, 20%, 90%);
2
+ .react-skeletonify {
5
3
  color: transparent !important;
6
- border: none !important;
7
4
  outline: none !important;
8
5
  pointer-events: none !important;
9
- border-radius: 8px !important;
10
6
  }
11
- .Rss-skeleton img {
7
+ .react-skeletonify img {
12
8
  opacity: 0;
13
9
  }
14
- .Rss-skeleton a {
10
+ .react-skeletonify a {
15
11
  text-decoration: none !important;
16
12
  color: transparent !important;
17
13
  }
18
- .Rss-skeleton-text {
14
+ .react-skeletonify-text {
19
15
  margin-top: 5px !important;
20
16
  }
21
- .Rss-skeleton::placeholder {
17
+ .react-skeletonify::placeholder {
22
18
  color: transparent !important;
23
19
  }
24
- @keyframes Rss-skeleton-loading {
20
+ @keyframes react-skeletonify-animation-1 {
21
+ 0% {
22
+ opacity: 1;
23
+ }
24
+ 50% {
25
+ opacity: 0.4;
26
+ }
27
+ 100% {
28
+ opacity: 1;
29
+ }
30
+ }
31
+ @keyframes react-skeletonify-animation-2 {
32
+ 100% {
33
+ background-position: -100% 0;
34
+ }
35
+ }
36
+ @keyframes react-skeletonify-animation-3 {
25
37
  0% {
26
38
  background-color: hsl(200, 20%, 80%);
27
39
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styles/skeleton.css"],"sourcesContent":[".Rss-skeleton {\n animation: Rss-skeleton-loading 1s linear infinite alternate;\n background-color: hsl(200, 20%, 90%);\n color: transparent !important;\n border: none !important;\n outline: none !important;\n pointer-events: none !important;\n border-radius: 8px !important;\n}\n\n.Rss-skeleton img {\n opacity: 0;\n}\n\n.Rss-skeleton a {\n text-decoration: none !important;\n color: transparent !important;\n}\n\n.Rss-skeleton-text {\n margin-top: 5px !important;\n}\n\n.Rss-skeleton::placeholder {\n color: transparent !important;\n}\n\n@keyframes Rss-skeleton-loading {\n 0% {\n background-color: hsl(200, 20%, 80%);\n }\n 100% {\n background-color: hsl(200, 20%, 95%);\n }\n}\n"],"mappings":";AAAA,CAAC;AACC,aAAW,qBAAqB,GAAG,OAAO,SAAS;AACnD,oBAAkB,IAAI,GAAG,EAAE,GAAG,EAAE;AAChC,SAAO;AACP,UAAQ;AACR,WAAS;AACT,kBAAgB;AAChB,iBAAe;AACjB;AAEA,CAVC,aAUa;AACZ,WAAS;AACX;AAEA,CAdC,aAca;AACZ,mBAAiB;AACjB,SAAO;AACT;AAEA,CAAC;AACC,cAAY;AACd;AAEA,CAvBC,YAuBY;AACX,SAAO;AACT;AAEA,WA1Ba;AA2BX;AACE,sBAAkB,IAAI,GAAG,EAAE,GAAG,EAAE;AAClC;AACA;AACE,sBAAkB,IAAI,GAAG,EAAE,GAAG,EAAE;AAClC;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/styles/skeleton.css"],"sourcesContent":[".react-skeletonify {\n color: transparent !important;\n outline: none !important;\n pointer-events: none !important;\n}\n.react-skeletonify img {\n opacity: 0;\n}\n.react-skeletonify a {\n text-decoration: none !important;\n color: transparent !important;\n}\n.react-skeletonify-text {\n margin-top: 5px !important;\n}\n.react-skeletonify::placeholder {\n color: transparent !important;\n}\n\n/* Animation 1 */\n/* animation: react-skeletonify-animation-1 3s ease-in-out infinite;\nanimation-delay: 0.5s; */\n@keyframes react-skeletonify-animation-1 {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0.4;\n }\n 100% {\n opacity: 1;\n }\n}\n\n/* Animation 2 */\n/* animation: react-skeletonify-animation-2 2s infinite;*/\n@keyframes react-skeletonify-animation-2 {\n 100% {\n background-position: -100% 0;\n }\n}\n\n/* Animation 3 */\n/* animation: react-skeletonify-animation-3 1s linear infinite alternate; */\n@keyframes react-skeletonify-animation-3 {\n 0% {\n background-color: hsl(200, 20%, 80%);\n }\n 100% {\n background-color: hsl(200, 20%, 95%);\n }\n}\n"],"mappings":";AAAA,CAAC;AACC,SAAO;AACP,WAAS;AACT,kBAAgB;AAClB;AACA,CALC,kBAKkB;AACjB,WAAS;AACX;AACA,CARC,kBAQkB;AACjB,mBAAiB;AACjB,SAAO;AACT;AACA,CAAC;AACC,cAAY;AACd;AACA,CAfC,iBAeiB;AAChB,SAAO;AACT;AAKA,WAAW;AACT;AACE,aAAS;AACX;AACA;AACE,aAAS;AACX;AACA;AACE,aAAS;AACX;AACF;AAIA,WAAW;AACT;AACE,yBAAqB,MAAM;AAC7B;AACF;AAIA,WAAW;AACT;AACE,sBAAkB,IAAI,GAAG,EAAE,GAAG,EAAE;AAClC;AACA;AACE,sBAAkB,IAAI,GAAG,EAAE,GAAG,EAAE;AAClC;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,9 +1,34 @@
1
- import React from 'react';
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ declare const HTML_TAG_GROUPS: readonly ["TEXT_TAGS", "STRUCTURE_TAGS", "METADATA_TAGS", "LIST_TAGS", "TABLE_TAGS", "FORM_TAGS", "MEDIA_TAGS", "INTERACTIVE_TAGS", "MISC_TAGS"];
4
+ type HtmlTagGroup = (typeof HTML_TAG_GROUPS)[number];
5
+ type SkeletonConfig = {
6
+ animationSpeed: number;
7
+ background: string;
8
+ border: string;
9
+ borderRadius: string;
10
+ textTagsMargin: string;
11
+ className?: string;
12
+ style?: CSSProperties;
13
+ animation: "animation-1" | "animation-2";
14
+ exceptTags: string[];
15
+ exceptTagGroups: HtmlTagGroup[];
16
+ };
2
17
 
3
18
  interface SkeletonWrapperProps {
4
19
  loading: boolean;
5
20
  children: React.ReactNode;
21
+ overrideConfig?: Partial<SkeletonConfig>;
22
+ style?: CSSProperties;
6
23
  }
7
24
  declare const SkeletonWrapper: React.FC<SkeletonWrapperProps>;
8
25
 
9
- export { SkeletonWrapper };
26
+ interface SkeletonProviderProps {
27
+ children: React.ReactNode;
28
+ config?: Partial<SkeletonConfig>;
29
+ style?: CSSProperties;
30
+ }
31
+ declare const SkeletonProvider: React.FC<SkeletonProviderProps>;
32
+ declare const useSkeleton: () => SkeletonConfig;
33
+
34
+ export { type SkeletonConfig, SkeletonProvider, SkeletonWrapper, useSkeleton };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,34 @@
1
- import React from 'react';
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ declare const HTML_TAG_GROUPS: readonly ["TEXT_TAGS", "STRUCTURE_TAGS", "METADATA_TAGS", "LIST_TAGS", "TABLE_TAGS", "FORM_TAGS", "MEDIA_TAGS", "INTERACTIVE_TAGS", "MISC_TAGS"];
4
+ type HtmlTagGroup = (typeof HTML_TAG_GROUPS)[number];
5
+ type SkeletonConfig = {
6
+ animationSpeed: number;
7
+ background: string;
8
+ border: string;
9
+ borderRadius: string;
10
+ textTagsMargin: string;
11
+ className?: string;
12
+ style?: CSSProperties;
13
+ animation: "animation-1" | "animation-2";
14
+ exceptTags: string[];
15
+ exceptTagGroups: HtmlTagGroup[];
16
+ };
2
17
 
3
18
  interface SkeletonWrapperProps {
4
19
  loading: boolean;
5
20
  children: React.ReactNode;
21
+ overrideConfig?: Partial<SkeletonConfig>;
22
+ style?: CSSProperties;
6
23
  }
7
24
  declare const SkeletonWrapper: React.FC<SkeletonWrapperProps>;
8
25
 
9
- export { SkeletonWrapper };
26
+ interface SkeletonProviderProps {
27
+ children: React.ReactNode;
28
+ config?: Partial<SkeletonConfig>;
29
+ style?: CSSProperties;
30
+ }
31
+ declare const SkeletonProvider: React.FC<SkeletonProviderProps>;
32
+ declare const useSkeleton: () => SkeletonConfig;
33
+
34
+ export { type SkeletonConfig, SkeletonProvider, SkeletonWrapper, useSkeleton };
package/dist/index.js CHANGED
@@ -30,10 +30,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.tsx
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- SkeletonWrapper: () => SkeletonWrapper_default
33
+ SkeletonProvider: () => SkeletonProvider,
34
+ SkeletonWrapper: () => SkeletonWrapper_default,
35
+ useSkeleton: () => useSkeleton
34
36
  });
35
37
  module.exports = __toCommonJS(index_exports);
36
38
 
39
+ // src/components/SkeletonWrapper.tsx
40
+ var import_react6 = require("react");
41
+
37
42
  // src/components/SkeletonElement.tsx
38
43
  var import_react4 = __toESM(require("react"));
39
44
 
@@ -42,18 +47,69 @@ var import_react3 = __toESM(require("react"));
42
47
 
43
48
  // src/utils/create-node-wrapper.ts
44
49
  var import_react = require("react");
45
- function createNodeWrapper(node) {
46
- var _a;
50
+ function createNodeWrapper(node, className, style) {
51
+ var _a, _b;
47
52
  if (!node) return null;
48
53
  return (0, import_react.createElement)(
49
54
  "div",
50
55
  {
51
- className: (((_a = node == null ? void 0 : node.props) == null ? void 0 : _a.className) || "") + " Rss-skeleton"
56
+ className: className + (((_a = node == null ? void 0 : node.props) == null ? void 0 : _a.className) || ""),
57
+ style: {
58
+ ...style,
59
+ ...(_b = node == null ? void 0 : node.props) == null ? void 0 : _b.style
60
+ }
52
61
  },
53
62
  node
54
63
  );
55
64
  }
56
65
 
66
+ // src/utils/create-leaf-node.ts
67
+ var import_react2 = __toESM(require("react"));
68
+ function createLeafNode(node, className, style) {
69
+ return import_react2.default.cloneElement(node, {
70
+ ...node.props,
71
+ className: className + (node.props.className || ""),
72
+ style: {
73
+ ...style,
74
+ ...node.props.style
75
+ }
76
+ });
77
+ }
78
+
79
+ // src/utils/create-style.ts
80
+ var getAnimation = (animation, animationSpeed, background) => {
81
+ switch (animation) {
82
+ case "animation-1":
83
+ return {
84
+ animation: `react-skeletonify-animation-1 ${animationSpeed}s ease-in-out infinite `,
85
+ background,
86
+ animationDelay: "0.5s"
87
+ };
88
+ case "animation-2":
89
+ return {
90
+ animation: `react-skeletonify-animation-2 ${animationSpeed}s infinite`,
91
+ background: `linear-gradient(120deg, ${background} 30%, #f0f0f0 38%, #f0f0f0 40%, ${background} 48%)`,
92
+ backgroundSize: "200% 100%",
93
+ backgroundPosition: "100% 0"
94
+ };
95
+ case "animation-3":
96
+ return {
97
+ animation: `react-skeletonify-animation-3 ${animationSpeed}s linear infinite alternate`,
98
+ backgroundColor: background
99
+ };
100
+ }
101
+ };
102
+ var create_style_default = (config) => {
103
+ const { animationSpeed, background, border, borderRadius, animation, style } = config;
104
+ const skeletonAnimation = {
105
+ ...getAnimation(animation, animationSpeed, background),
106
+ border,
107
+ borderRadius,
108
+ ...style
109
+ };
110
+ return skeletonAnimation;
111
+ };
112
+
57
113
  // src/constants/tags.ts
58
114
  var TEXT_TAGS = [
59
115
  "p",
@@ -64,36 +120,161 @@ var TEXT_TAGS = [
64
120
  "h4",
65
121
  "h5",
66
122
  "h6",
67
- "li"
123
+ "b",
124
+ "strong",
125
+ "i",
126
+ "em",
127
+ "u",
128
+ "mark",
129
+ "small",
130
+ "sup",
131
+ "sub",
132
+ "abbr",
133
+ "cite",
134
+ "q",
135
+ "blockquote",
136
+ "code",
137
+ "pre",
138
+ "samp",
139
+ "kbd",
140
+ "var",
141
+ "time",
142
+ "br",
143
+ "wbr"
144
+ ];
145
+ var STRUCTURE_TAGS = [
146
+ "html",
147
+ "head",
148
+ "body",
149
+ "main",
150
+ "header",
151
+ "footer",
152
+ "nav",
153
+ "section",
154
+ "article",
155
+ "aside"
156
+ ];
157
+ var METADATA_TAGS = ["base", "link", "meta", "style", "title"];
158
+ var LIST_TAGS = ["ul", "ol", "li", "dl", "dt", "dd"];
159
+ var TABLE_TAGS = [
160
+ "table",
161
+ "caption",
162
+ "thead",
163
+ "tbody",
164
+ "tfoot",
165
+ "tr",
166
+ "th",
167
+ "td",
168
+ "col",
169
+ "colgroup"
170
+ ];
171
+ var FORM_TAGS = [
172
+ "form",
173
+ "input",
174
+ "textarea",
175
+ "button",
176
+ "label",
177
+ "select",
178
+ "option",
179
+ "optgroup",
180
+ "fieldset",
181
+ "legend",
182
+ "datalist",
183
+ "output",
184
+ "meter",
185
+ "progress"
186
+ ];
187
+ var MEDIA_TAGS = [
188
+ "img",
189
+ "audio",
190
+ "video",
191
+ "source",
192
+ "track",
193
+ "picture",
194
+ "iframe",
195
+ "embed",
196
+ "object",
197
+ "map",
198
+ "area",
199
+ "canvas"
200
+ ];
201
+ var INTERACTIVE_TAGS = [
202
+ "details",
203
+ "summary",
204
+ "dialog",
205
+ "script",
206
+ "noscript",
207
+ "template"
68
208
  ];
209
+ var MISC_TAGS = ["ins", "del", "s", "bdi", "bdo", "ruby", "rt", "rp"];
69
210
 
70
- // src/utils/create-leaf-node.ts
71
- var import_react2 = __toESM(require("react"));
72
- function createLeafNode(node, className = "") {
73
- return import_react2.default.cloneElement(node, {
74
- ...node.props,
75
- className: (node.props.className || "") + " Rss-skeleton " + className
211
+ // src/utils/check-tag-in-group.ts
212
+ function checkTagInGroup(tag, groups) {
213
+ return groups.some((group) => {
214
+ switch (group) {
215
+ case "TEXT_TAGS":
216
+ return TEXT_TAGS.includes(tag);
217
+ case "STRUCTURE_TAGS":
218
+ return STRUCTURE_TAGS.includes(tag);
219
+ case "METADATA_TAGS":
220
+ return METADATA_TAGS.includes(tag);
221
+ case "LIST_TAGS":
222
+ return LIST_TAGS.includes(tag);
223
+ case "TABLE_TAGS":
224
+ return TABLE_TAGS.includes(tag);
225
+ case "FORM_TAGS":
226
+ return FORM_TAGS.includes(tag);
227
+ case "MEDIA_TAGS":
228
+ return MEDIA_TAGS.includes(tag);
229
+ case "INTERACTIVE_TAGS":
230
+ return INTERACTIVE_TAGS.includes(tag);
231
+ case "MISC_TAGS":
232
+ return MISC_TAGS.includes(tag);
233
+ }
76
234
  });
77
235
  }
78
236
 
237
+ // src/utils/is-text-element.ts
238
+ var is_text_element_default = (elementType) => {
239
+ return TEXT_TAGS.includes(elementType) || LIST_TAGS.includes(elementType);
240
+ };
241
+
79
242
  // src/hooks/useAddSkelton.ts
80
- function useAddSkelton() {
243
+ function useAddSkelton(config) {
244
+ const { className, exceptTags, exceptTagGroups, textTagsMargin } = config;
245
+ const CLASS_NAME = `react-skeletonify ${className} `;
246
+ const style = create_style_default(config);
81
247
  const addSkeleton = (node) => {
82
- if (!import_react3.default.isValidElement(node)) return createNodeWrapper(node);
248
+ if (!import_react3.default.isValidElement(node))
249
+ return createNodeWrapper(node, CLASS_NAME, style);
83
250
  const element = node;
84
251
  const { children } = element.props;
85
252
  const elementType = element.type;
253
+ if (typeof elementType === "string") {
254
+ if (exceptTags.includes(elementType)) {
255
+ return element;
256
+ }
257
+ const isRestrictedGroupTag = checkTagInGroup(
258
+ elementType,
259
+ exceptTagGroups
260
+ );
261
+ if (isRestrictedGroupTag) return element;
262
+ }
86
263
  const hasChildren = import_react3.default.Children.count(children) > 0;
87
264
  const isValidChildren = typeof children !== "string";
88
265
  if (typeof elementType === "function") {
89
266
  const rendered = elementType(element.props);
90
267
  return addSkeleton(rendered);
91
268
  }
92
- if (TEXT_TAGS.includes(elementType)) {
93
- return createLeafNode(node, "Rss-skeleton-text");
269
+ const isTextTag = is_text_element_default(elementType);
270
+ if (isTextTag) {
271
+ return createLeafNode(element, CLASS_NAME, {
272
+ ...style,
273
+ margin: textTagsMargin
274
+ });
94
275
  }
95
276
  if (elementType === "img") {
96
- return createNodeWrapper(element);
277
+ return createNodeWrapper(element, CLASS_NAME, style);
97
278
  }
98
279
  if (hasChildren && isValidChildren) {
99
280
  const childWithSkeletons = import_react3.default.Children.map(children, addSkeleton);
@@ -102,36 +283,84 @@ function useAddSkelton() {
102
283
  children: childWithSkeletons
103
284
  });
104
285
  }
105
- return createLeafNode(element);
286
+ return createLeafNode(element, CLASS_NAME, style);
106
287
  };
107
288
  return addSkeleton;
108
289
  }
109
290
  var useAddSkelton_default = useAddSkelton;
110
291
 
111
292
  // src/components/SkeletonElement.tsx
112
- var import_jsx_runtime = require("react/jsx-runtime");
113
- var SkeletonElement = ({
114
- children
115
- }) => {
116
- const addSkeleton = useAddSkelton_default();
117
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "skeleton-container", children: import_react4.default.Children.map(children, (child) => addSkeleton(child)) });
293
+ var SkeletonElement = (props) => {
294
+ const { children, config } = props;
295
+ const addSkeleton = useAddSkelton_default(config);
296
+ return import_react4.default.Children.map(children, (child) => addSkeleton(child));
118
297
  };
119
298
  var SkeletonElement_default = SkeletonElement;
120
299
 
300
+ // src/context/SkeletonContext.tsx
301
+ var import_react5 = require("react");
302
+
303
+ // src/context/skeleton-config.ts
304
+ var defaultBackground = {
305
+ "animation-1": "#aeaeae",
306
+ "animation-2": "#e5e5e5",
307
+ "animation-3": "hsl(210, 20%, 90%)"
308
+ };
309
+ var defaultValues = {
310
+ animationSpeed: 3,
311
+ background: "#aeaeae",
312
+ border: "none",
313
+ borderRadius: "0",
314
+ textTagsMargin: "0",
315
+ className: "",
316
+ style: {},
317
+ animation: "animation-1",
318
+ exceptTags: [],
319
+ exceptTagGroups: []
320
+ };
321
+
322
+ // src/context/SkeletonContext.tsx
323
+ var import_jsx_runtime = require("react/jsx-runtime");
324
+ var SkeletonContext = (0, import_react5.createContext)(defaultValues);
325
+ var SkeletonProvider = (props) => {
326
+ const { children, config, style } = props;
327
+ const { animation = defaultValues.animation, background } = config || {};
328
+ const value = (0, import_react5.useMemo)(
329
+ () => ({
330
+ ...defaultValues,
331
+ ...config,
332
+ background: background ? background : defaultBackground[animation],
333
+ style: { ...defaultValues.style, ...config == null ? void 0 : config.style, ...style }
334
+ }),
335
+ [animation, background, config, style]
336
+ );
337
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SkeletonContext.Provider, { value, children });
338
+ };
339
+ var useSkeleton = () => (0, import_react5.useContext)(SkeletonContext);
340
+
121
341
  // src/components/SkeletonWrapper.tsx
122
342
  var import_jsx_runtime2 = require("react/jsx-runtime");
123
- var SkeletonWrapper = ({
124
- loading,
125
- children
126
- }) => {
343
+ var SkeletonWrapper = (props) => {
344
+ const { loading, children, overrideConfig, style } = props;
345
+ const mainConfig = useSkeleton();
346
+ const config = (0, import_react6.useMemo)(
347
+ () => ({
348
+ ...mainConfig,
349
+ ...overrideConfig,
350
+ style: { ...mainConfig.style, ...overrideConfig == null ? void 0 : overrideConfig.style, ...style }
351
+ }),
352
+ [overrideConfig, mainConfig]
353
+ );
127
354
  if (loading) {
128
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SkeletonElement_default, { children });
355
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SkeletonElement_default, { config, children });
129
356
  }
130
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children });
357
+ return children;
131
358
  };
132
359
  var SkeletonWrapper_default = SkeletonWrapper;
133
360
  // Annotate the CommonJS export names for ESM import in node:
134
361
  0 && (module.exports = {
135
- SkeletonWrapper
362
+ SkeletonProvider,
363
+ SkeletonWrapper,
364
+ useSkeleton
136
365
  });
137
366
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx","../src/components/SkeletonElement.tsx","../src/hooks/useAddSkelton.ts","../src/utils/create-node-wrapper.ts","../src/constants/tags.ts","../src/utils/create-leaf-node.ts","../src/components/SkeletonWrapper.tsx"],"sourcesContent":["import \"./styles/skeleton.css\";\n\nexport { default as SkeletonWrapper } from \"./components/SkeletonWrapper\";\n","import React from \"react\";\nimport useAddSkelton from \"../hooks/useAddSkelton\";\n\nconst SkeletonElement: React.FC<{ children: React.ReactNode }> = ({\n children,\n}) => {\n const addSkeleton = useAddSkelton();\n return (\n <div className=\"skeleton-container\">\n {React.Children.map(children, (child) => addSkeleton(child))}\n </div>\n );\n};\n\nexport default SkeletonElement;\n","import React from \"react\";\nimport createNodeWrapper from \"../utils/create-node-wrapper\";\nimport { TEXT_TAGS } from \"../constants/tags\";\nimport createLeafNode from \"../utils/create-leaf-node\";\n\nfunction useAddSkelton() {\n const addSkeleton = (node: React.ReactNode): React.ReactNode => {\n if (!React.isValidElement(node)) return createNodeWrapper(node as any);\n\n const element = node as React.ReactElement<any>;\n const { children } = element.props;\n const elementType = element.type;\n\n const hasChildren = React.Children.count(children) > 0;\n const isValidChildren = typeof children !== \"string\";\n\n if (typeof elementType === \"function\") {\n const rendered = (elementType as any)(element.props);\n return addSkeleton(rendered);\n }\n\n if (TEXT_TAGS.includes(elementType)) {\n return createLeafNode(node, \"Rss-skeleton-text\");\n }\n\n if (elementType === \"img\") {\n return createNodeWrapper(element);\n }\n\n if (hasChildren && isValidChildren) {\n const childWithSkeletons = React.Children.map(children, addSkeleton);\n\n return React.cloneElement(element, {\n ...element.props,\n children: childWithSkeletons,\n } as typeof element.props);\n }\n\n return createLeafNode(element);\n };\n\n return addSkeleton;\n}\n\nexport default useAddSkelton;\n","import React, { createElement } from \"react\";\n\nexport default function createNodeWrapper(node: React.ReactElement<any>) {\n if (!node) return null;\n\n return createElement(\n \"div\",\n {\n className: (node?.props?.className || \"\") + \" Rss-skeleton\",\n },\n node\n );\n}\n","export const TEXT_TAGS = [\n \"p\",\n \"span\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"li\",\n];\n","import React from \"react\";\n\nexport default function createLeafNode(\n node: React.ReactElement<any>,\n className: string = \"\"\n): React.ReactElement {\n return React.cloneElement(node, {\n ...node.props,\n className: (node.props.className || \"\") + \" Rss-skeleton \" + className,\n } as typeof node.props);\n}\n","import React from \"react\";\nimport SkeletonElement from \"./SkeletonElement\";\n\ninterface SkeletonWrapperProps {\n loading: boolean;\n children: React.ReactNode;\n}\n\nconst SkeletonWrapper: React.FC<SkeletonWrapperProps> = ({\n loading,\n children,\n}) => {\n if (loading) {\n return <SkeletonElement>{children}</SkeletonElement>;\n }\n return <>{children}</>;\n};\n\nexport default SkeletonWrapper;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAkB;;;ACAlB,IAAAC,gBAAkB;;;ACAlB,mBAAqC;AAEtB,SAAR,kBAAmC,MAA+B;AAFzE;AAGE,MAAI,CAAC,KAAM,QAAO;AAElB,aAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,cAAY,kCAAM,UAAN,mBAAa,cAAa,MAAM;AAAA,IAC9C;AAAA,IACA;AAAA,EACF;AACF;;;ACZO,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACVA,IAAAC,gBAAkB;AAEH,SAAR,eACL,MACA,YAAoB,IACA;AAC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AA,EACvD;AAAA,EACA;AACF,MAAM;AACJ,MAAI,SAAS;AACX,WAAO,6CAAC,2BAAiB,UAAS;AAAA,EACpC;AACA,SAAO,6EAAG,UAAS;AACrB;AAEA,IAAO,0BAAQ;","names":["import_react","import_react","import_react","React","React","React","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../src/index.tsx","../src/components/SkeletonWrapper.tsx","../src/components/SkeletonElement.tsx","../src/hooks/useAddSkelton.ts","../src/utils/create-node-wrapper.ts","../src/utils/create-leaf-node.ts","../src/utils/create-style.ts","../src/constants/tags.ts","../src/utils/check-tag-in-group.ts","../src/utils/is-text-element.ts","../src/context/SkeletonContext.tsx","../src/context/skeleton-config.ts"],"sourcesContent":["import \"./styles/skeleton.css\";\n\nexport { default as SkeletonWrapper } from \"./components/SkeletonWrapper\";\nexport { SkeletonProvider, useSkeleton } from \"./context/SkeletonContext\";\nexport type { SkeletonConfig } from \"./context/skeleton-config\";\n","import React, { CSSProperties, useMemo } from \"react\";\nimport SkeletonElement from \"./SkeletonElement\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\nimport { useSkeleton } from \"../context/SkeletonContext\";\n\ninterface SkeletonWrapperProps {\n loading: boolean;\n children: React.ReactNode;\n overrideConfig?: Partial<SkeletonConfig>;\n style?: CSSProperties;\n}\n\nconst SkeletonWrapper: React.FC<SkeletonWrapperProps> = (props) => {\n const { loading, children, overrideConfig, style } = props;\n const mainConfig = useSkeleton();\n\n const config: SkeletonConfig = useMemo(\n () => ({\n ...mainConfig,\n ...overrideConfig,\n style: { ...mainConfig.style, ...overrideConfig?.style, ...style },\n }),\n [overrideConfig, mainConfig]\n );\n\n if (loading) {\n return <SkeletonElement config={config}>{children}</SkeletonElement>;\n }\n return children;\n};\n\nexport default SkeletonWrapper;\n","import React from \"react\";\nimport useAddSkelton from \"../hooks/useAddSkelton\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\n\ninterface SkeletonElementProps {\n children: React.ReactNode;\n config: SkeletonConfig;\n}\n\nconst SkeletonElement: React.FC<SkeletonElementProps> = (props) => {\n const { children, config } = props;\n const addSkeleton = useAddSkelton(config);\n\n return React.Children.map(children, (child) => addSkeleton(child));\n};\n\nexport default SkeletonElement;\n","import React from \"react\";\nimport createNodeWrapper from \"../utils/create-node-wrapper\";\nimport createLeafNode from \"../utils/create-leaf-node\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\nimport createStyle from \"../utils/create-style\";\nimport checkTagInGroup from \"../utils/check-tag-in-group\";\nimport isTextElement from \"../utils/is-text-element\";\n\nfunction useAddSkelton(config: SkeletonConfig) {\n const { className, exceptTags, exceptTagGroups, textTagsMargin } = config;\n const CLASS_NAME = `react-skeletonify ${className} `;\n const style = createStyle(config);\n\n const addSkeleton = (node: React.ReactNode): React.ReactNode => {\n if (!React.isValidElement(node))\n return createNodeWrapper(node as any, CLASS_NAME, style);\n\n const element = node as React.ReactElement<any>;\n const { children } = element.props;\n const elementType = element.type;\n\n if (typeof elementType === \"string\") {\n if (exceptTags.includes(elementType)) {\n return element;\n }\n const isRestrictedGroupTag = checkTagInGroup(\n elementType,\n exceptTagGroups\n );\n\n if (isRestrictedGroupTag) return element;\n }\n\n const hasChildren = React.Children.count(children) > 0;\n const isValidChildren = typeof children !== \"string\";\n\n if (typeof elementType === \"function\") {\n const rendered = (elementType as any)(element.props);\n return addSkeleton(rendered);\n }\n\n const isTextTag = isTextElement(elementType);\n\n if (isTextTag) {\n return createLeafNode(element, CLASS_NAME, {\n ...style,\n margin: textTagsMargin,\n });\n }\n\n if (elementType === \"img\") {\n return createNodeWrapper(element, CLASS_NAME, style);\n }\n\n if (hasChildren && isValidChildren) {\n const childWithSkeletons = React.Children.map(children, addSkeleton);\n\n return React.cloneElement(element, {\n ...element.props,\n children: childWithSkeletons,\n } as typeof element.props);\n }\n\n return createLeafNode(element, CLASS_NAME, style);\n };\n\n return addSkeleton;\n}\n\nexport default useAddSkelton;\n","import React, { createElement, CSSProperties } from \"react\";\n\nexport default function createNodeWrapper(\n node: React.ReactElement<any>,\n className: string,\n style: CSSProperties\n) {\n if (!node) return null;\n\n return createElement(\n \"div\",\n {\n className: className + (node?.props?.className || \"\"),\n style: {\n ...style,\n ...node?.props?.style,\n },\n },\n node\n );\n}\n","import React, { CSSProperties } from \"react\";\n\nexport default function createLeafNode(\n node: React.ReactElement<any>,\n className: string,\n style: CSSProperties\n): React.ReactElement {\n return React.cloneElement(node, {\n ...node.props,\n className: className + (node.props.className || \"\"),\n style: {\n ...style,\n ...node.props.style,\n },\n } as typeof node.props);\n}\n","import { CSSProperties } from \"react\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\n\nconst getAnimation = (\n animation: string,\n animationSpeed: number,\n background: string\n) => {\n switch (animation) {\n case \"animation-1\":\n return {\n animation: `react-skeletonify-animation-1 ${animationSpeed}s ease-in-out infinite `,\n background: background,\n animationDelay: \"0.5s\",\n };\n case \"animation-2\":\n return {\n animation: `react-skeletonify-animation-2 ${animationSpeed}s infinite`,\n background: `linear-gradient(120deg, ${background} 30%, #f0f0f0 38%, #f0f0f0 40%, ${background} 48%)`,\n backgroundSize: \"200% 100%\",\n backgroundPosition: \"100% 0\",\n };\n case \"animation-3\":\n return {\n animation: `react-skeletonify-animation-3 ${animationSpeed}s linear infinite alternate`,\n backgroundColor: background,\n };\n }\n};\n\nexport default (config: SkeletonConfig) => {\n const { animationSpeed, background, border, borderRadius, animation, style } =\n config;\n\n const skeletonAnimation: CSSProperties = {\n ...getAnimation(animation, animationSpeed, background),\n border,\n borderRadius,\n ...style,\n };\n\n return skeletonAnimation;\n};\n","// --- Text & Content ---\nexport const TEXT_TAGS = [\n \"p\",\n \"span\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"b\",\n \"strong\",\n \"i\",\n \"em\",\n \"u\",\n \"mark\",\n \"small\",\n \"sup\",\n \"sub\",\n \"abbr\",\n \"cite\",\n \"q\",\n \"blockquote\",\n \"code\",\n \"pre\",\n \"samp\",\n \"kbd\",\n \"var\",\n \"time\",\n \"br\",\n \"wbr\",\n];\n\n// --- Sectioning / Structure ---\nexport const STRUCTURE_TAGS = [\n \"html\",\n \"head\",\n \"body\",\n \"main\",\n \"header\",\n \"footer\",\n \"nav\",\n \"section\",\n \"article\",\n \"aside\",\n];\n\n// --- Metadata ---\nexport const METADATA_TAGS = [\"base\", \"link\", \"meta\", \"style\", \"title\"];\n\n// --- Lists ---\nexport const LIST_TAGS = [\"ul\", \"ol\", \"li\", \"dl\", \"dt\", \"dd\"];\n\n// --- Tables ---\nexport const TABLE_TAGS = [\n \"table\",\n \"caption\",\n \"thead\",\n \"tbody\",\n \"tfoot\",\n \"tr\",\n \"th\",\n \"td\",\n \"col\",\n \"colgroup\",\n];\n\n// --- Forms & Inputs ---\nexport const FORM_TAGS = [\n \"form\",\n \"input\",\n \"textarea\",\n \"button\",\n \"label\",\n \"select\",\n \"option\",\n \"optgroup\",\n \"fieldset\",\n \"legend\",\n \"datalist\",\n \"output\",\n \"meter\",\n \"progress\",\n];\n\n// --- Media ---\nexport const MEDIA_TAGS = [\n \"img\",\n \"audio\",\n \"video\",\n \"source\",\n \"track\",\n \"picture\",\n \"iframe\",\n \"embed\",\n \"object\",\n \"map\",\n \"area\",\n \"canvas\",\n];\n\n// --- Interactive ---\nexport const INTERACTIVE_TAGS = [\n \"details\",\n \"summary\",\n \"dialog\",\n \"script\",\n \"noscript\",\n \"template\",\n];\n\n// --- Other / Inline semantics ---\nexport const MISC_TAGS = [\"ins\", \"del\", \"s\", \"bdi\", \"bdo\", \"ruby\", \"rt\", \"rp\"];\n","import {\n FORM_TAGS,\n INTERACTIVE_TAGS,\n LIST_TAGS,\n MEDIA_TAGS,\n METADATA_TAGS,\n MISC_TAGS,\n STRUCTURE_TAGS,\n TABLE_TAGS,\n TEXT_TAGS,\n} from \"../constants/tags\";\nimport { HtmlTagGroup } from \"../context/skeleton-config\";\n\nexport default function checkTagInGroup(\n tag: string,\n groups: HtmlTagGroup[]\n): boolean {\n return groups.some((group) => {\n switch (group) {\n case \"TEXT_TAGS\":\n return TEXT_TAGS.includes(tag);\n case \"STRUCTURE_TAGS\":\n return STRUCTURE_TAGS.includes(tag);\n case \"METADATA_TAGS\":\n return METADATA_TAGS.includes(tag);\n case \"LIST_TAGS\":\n return LIST_TAGS.includes(tag);\n case \"TABLE_TAGS\":\n return TABLE_TAGS.includes(tag);\n case \"FORM_TAGS\":\n return FORM_TAGS.includes(tag);\n case \"MEDIA_TAGS\":\n return MEDIA_TAGS.includes(tag);\n case \"INTERACTIVE_TAGS\":\n return INTERACTIVE_TAGS.includes(tag);\n case \"MISC_TAGS\":\n return MISC_TAGS.includes(tag);\n }\n });\n}\n","import { LIST_TAGS, TEXT_TAGS } from \"../constants/tags\";\n\nexport default (elementType: string) => {\n return TEXT_TAGS.includes(elementType) || LIST_TAGS.includes(elementType);\n};\n","import React, {\n createContext,\n CSSProperties,\n useContext,\n useMemo,\n} from \"react\";\nimport {\n SkeletonConfig,\n defaultBackground,\n defaultValues,\n} from \"./skeleton-config\";\n\nconst SkeletonContext = createContext<SkeletonConfig>(defaultValues);\ninterface SkeletonProviderProps {\n children: React.ReactNode;\n config?: Partial<SkeletonConfig>;\n style?: CSSProperties;\n}\n\nexport const SkeletonProvider: React.FC<SkeletonProviderProps> = (props) => {\n const { children, config, style } = props;\n const { animation = defaultValues.animation, background } = config || {};\n\n const value: SkeletonConfig = useMemo(\n () => ({\n ...defaultValues,\n ...config,\n background: background ? background : defaultBackground[animation],\n style: { ...defaultValues.style, ...config?.style, ...style },\n }),\n [animation, background, config, style]\n );\n\n return (\n <SkeletonContext.Provider value={value}>\n {children}\n </SkeletonContext.Provider>\n );\n};\n\nexport const useSkeleton = () => useContext(SkeletonContext);\n","import { CSSProperties } from \"react\";\n\nexport const HTML_TAG_GROUPS = [\n \"TEXT_TAGS\",\n \"STRUCTURE_TAGS\",\n \"METADATA_TAGS\",\n \"LIST_TAGS\",\n \"TABLE_TAGS\",\n \"FORM_TAGS\",\n \"MEDIA_TAGS\",\n \"INTERACTIVE_TAGS\",\n \"MISC_TAGS\",\n] as const;\n\nexport type HtmlTagGroup = (typeof HTML_TAG_GROUPS)[number];\n\nexport const defaultBackground = {\n \"animation-1\": \"#aeaeae\",\n \"animation-2\": \"#e5e5e5\",\n \"animation-3\": \"hsl(210, 20%, 90%)\",\n};\n\nexport type SkeletonConfig = {\n animationSpeed: number;\n background: string;\n border: string;\n borderRadius: string;\n textTagsMargin: string;\n className?: string;\n style?: CSSProperties;\n animation: \"animation-1\" | \"animation-2\";\n exceptTags: string[];\n exceptTagGroups: HtmlTagGroup[];\n};\n\nexport const defaultValues: SkeletonConfig = {\n animationSpeed: 3,\n background: \"#aeaeae\",\n border: \"none\",\n borderRadius: \"0\",\n textTagsMargin: \"0\",\n className: \"\",\n style: {},\n animation: \"animation-1\",\n exceptTags: [],\n exceptTagGroups: [],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8C;;;ACA9C,IAAAC,gBAAkB;;;ACAlB,IAAAC,gBAAkB;;;ACAlB,mBAAoD;AAErC,SAAR,kBACL,MACA,WACA,OACA;AANF;AAOE,MAAI,CAAC,KAAM,QAAO;AAElB,aAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,WAAW,eAAa,kCAAM,UAAN,mBAAa,cAAa;AAAA,MAClD,OAAO;AAAA,QACL,GAAG;AAAA,QACH,IAAG,kCAAM,UAAN,mBAAa;AAAA,MAClB;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;;;ACpBA,IAAAC,gBAAqC;AAEtB,SAAR,eACL,MACA,WACA,OACoB;AACpB,SAAO,cAAAC,QAAM,aAAa,MAAM;AAAA,IAC9B,GAAG,KAAK;AAAA,IACR,WAAW,aAAa,KAAK,MAAM,aAAa;AAAA,IAChD,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG,KAAK,MAAM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AkD,CAAC,UAAU;AACjE,QAAM,EAAE,SAAS,UAAU,gBAAgB,MAAM,IAAI;AACrD,QAAM,aAAa,YAAY;AAE/B,QAAM,aAAyB;AAAA,IAC7B,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG;AAAA,MACH,OAAO,EAAE,GAAG,WAAW,OAAO,GAAG,iDAAgB,OAAO,GAAG,MAAM;AAAA,IACnE;AAAA,IACA,CAAC,gBAAgB,UAAU;AAAA,EAC7B;AAEA,MAAI,SAAS;AACX,WAAO,6CAAC,2BAAgB,QAAiB,UAAS;AAAA,EACpD;AACA,SAAO;AACT;AAEA,IAAO,0BAAQ;","names":["import_react","import_react","import_react","import_react","React","React","React","import_react","import_jsx_runtime"]}
package/dist/index.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ // src/components/SkeletonWrapper.tsx
2
+ import { useMemo as useMemo2 } from "react";
3
+
1
4
  // src/components/SkeletonElement.tsx
2
5
  import React4 from "react";
3
6
 
@@ -6,18 +9,69 @@ import React3 from "react";
6
9
 
7
10
  // src/utils/create-node-wrapper.ts
8
11
  import { createElement } from "react";
9
- function createNodeWrapper(node) {
10
- var _a;
12
+ function createNodeWrapper(node, className, style) {
13
+ var _a, _b;
11
14
  if (!node) return null;
12
15
  return createElement(
13
16
  "div",
14
17
  {
15
- className: (((_a = node == null ? void 0 : node.props) == null ? void 0 : _a.className) || "") + " Rss-skeleton"
18
+ className: className + (((_a = node == null ? void 0 : node.props) == null ? void 0 : _a.className) || ""),
19
+ style: {
20
+ ...style,
21
+ ...(_b = node == null ? void 0 : node.props) == null ? void 0 : _b.style
22
+ }
16
23
  },
17
24
  node
18
25
  );
19
26
  }
20
27
 
28
+ // src/utils/create-leaf-node.ts
29
+ import React2 from "react";
30
+ function createLeafNode(node, className, style) {
31
+ return React2.cloneElement(node, {
32
+ ...node.props,
33
+ className: className + (node.props.className || ""),
34
+ style: {
35
+ ...style,
36
+ ...node.props.style
37
+ }
38
+ });
39
+ }
40
+
41
+ // src/utils/create-style.ts
42
+ var getAnimation = (animation, animationSpeed, background) => {
43
+ switch (animation) {
44
+ case "animation-1":
45
+ return {
46
+ animation: `react-skeletonify-animation-1 ${animationSpeed}s ease-in-out infinite `,
47
+ background,
48
+ animationDelay: "0.5s"
49
+ };
50
+ case "animation-2":
51
+ return {
52
+ animation: `react-skeletonify-animation-2 ${animationSpeed}s infinite`,
53
+ background: `linear-gradient(120deg, ${background} 30%, #f0f0f0 38%, #f0f0f0 40%, ${background} 48%)`,
54
+ backgroundSize: "200% 100%",
55
+ backgroundPosition: "100% 0"
56
+ };
57
+ case "animation-3":
58
+ return {
59
+ animation: `react-skeletonify-animation-3 ${animationSpeed}s linear infinite alternate`,
60
+ backgroundColor: background
61
+ };
62
+ }
63
+ };
64
+ var create_style_default = (config) => {
65
+ const { animationSpeed, background, border, borderRadius, animation, style } = config;
66
+ const skeletonAnimation = {
67
+ ...getAnimation(animation, animationSpeed, background),
68
+ border,
69
+ borderRadius,
70
+ ...style
71
+ };
72
+ return skeletonAnimation;
73
+ };
74
+
21
75
  // src/constants/tags.ts
22
76
  var TEXT_TAGS = [
23
77
  "p",
@@ -28,36 +82,161 @@ var TEXT_TAGS = [
28
82
  "h4",
29
83
  "h5",
30
84
  "h6",
31
- "li"
85
+ "b",
86
+ "strong",
87
+ "i",
88
+ "em",
89
+ "u",
90
+ "mark",
91
+ "small",
92
+ "sup",
93
+ "sub",
94
+ "abbr",
95
+ "cite",
96
+ "q",
97
+ "blockquote",
98
+ "code",
99
+ "pre",
100
+ "samp",
101
+ "kbd",
102
+ "var",
103
+ "time",
104
+ "br",
105
+ "wbr"
106
+ ];
107
+ var STRUCTURE_TAGS = [
108
+ "html",
109
+ "head",
110
+ "body",
111
+ "main",
112
+ "header",
113
+ "footer",
114
+ "nav",
115
+ "section",
116
+ "article",
117
+ "aside"
118
+ ];
119
+ var METADATA_TAGS = ["base", "link", "meta", "style", "title"];
120
+ var LIST_TAGS = ["ul", "ol", "li", "dl", "dt", "dd"];
121
+ var TABLE_TAGS = [
122
+ "table",
123
+ "caption",
124
+ "thead",
125
+ "tbody",
126
+ "tfoot",
127
+ "tr",
128
+ "th",
129
+ "td",
130
+ "col",
131
+ "colgroup"
132
+ ];
133
+ var FORM_TAGS = [
134
+ "form",
135
+ "input",
136
+ "textarea",
137
+ "button",
138
+ "label",
139
+ "select",
140
+ "option",
141
+ "optgroup",
142
+ "fieldset",
143
+ "legend",
144
+ "datalist",
145
+ "output",
146
+ "meter",
147
+ "progress"
148
+ ];
149
+ var MEDIA_TAGS = [
150
+ "img",
151
+ "audio",
152
+ "video",
153
+ "source",
154
+ "track",
155
+ "picture",
156
+ "iframe",
157
+ "embed",
158
+ "object",
159
+ "map",
160
+ "area",
161
+ "canvas"
162
+ ];
163
+ var INTERACTIVE_TAGS = [
164
+ "details",
165
+ "summary",
166
+ "dialog",
167
+ "script",
168
+ "noscript",
169
+ "template"
32
170
  ];
171
+ var MISC_TAGS = ["ins", "del", "s", "bdi", "bdo", "ruby", "rt", "rp"];
33
172
 
34
- // src/utils/create-leaf-node.ts
35
- import React2 from "react";
36
- function createLeafNode(node, className = "") {
37
- return React2.cloneElement(node, {
38
- ...node.props,
39
- className: (node.props.className || "") + " Rss-skeleton " + className
173
+ // src/utils/check-tag-in-group.ts
174
+ function checkTagInGroup(tag, groups) {
175
+ return groups.some((group) => {
176
+ switch (group) {
177
+ case "TEXT_TAGS":
178
+ return TEXT_TAGS.includes(tag);
179
+ case "STRUCTURE_TAGS":
180
+ return STRUCTURE_TAGS.includes(tag);
181
+ case "METADATA_TAGS":
182
+ return METADATA_TAGS.includes(tag);
183
+ case "LIST_TAGS":
184
+ return LIST_TAGS.includes(tag);
185
+ case "TABLE_TAGS":
186
+ return TABLE_TAGS.includes(tag);
187
+ case "FORM_TAGS":
188
+ return FORM_TAGS.includes(tag);
189
+ case "MEDIA_TAGS":
190
+ return MEDIA_TAGS.includes(tag);
191
+ case "INTERACTIVE_TAGS":
192
+ return INTERACTIVE_TAGS.includes(tag);
193
+ case "MISC_TAGS":
194
+ return MISC_TAGS.includes(tag);
195
+ }
40
196
  });
41
197
  }
42
198
 
199
+ // src/utils/is-text-element.ts
200
+ var is_text_element_default = (elementType) => {
201
+ return TEXT_TAGS.includes(elementType) || LIST_TAGS.includes(elementType);
202
+ };
203
+
43
204
  // src/hooks/useAddSkelton.ts
44
- function useAddSkelton() {
205
+ function useAddSkelton(config) {
206
+ const { className, exceptTags, exceptTagGroups, textTagsMargin } = config;
207
+ const CLASS_NAME = `react-skeletonify ${className} `;
208
+ const style = create_style_default(config);
45
209
  const addSkeleton = (node) => {
46
- if (!React3.isValidElement(node)) return createNodeWrapper(node);
210
+ if (!React3.isValidElement(node))
211
+ return createNodeWrapper(node, CLASS_NAME, style);
47
212
  const element = node;
48
213
  const { children } = element.props;
49
214
  const elementType = element.type;
215
+ if (typeof elementType === "string") {
216
+ if (exceptTags.includes(elementType)) {
217
+ return element;
218
+ }
219
+ const isRestrictedGroupTag = checkTagInGroup(
220
+ elementType,
221
+ exceptTagGroups
222
+ );
223
+ if (isRestrictedGroupTag) return element;
224
+ }
50
225
  const hasChildren = React3.Children.count(children) > 0;
51
226
  const isValidChildren = typeof children !== "string";
52
227
  if (typeof elementType === "function") {
53
228
  const rendered = elementType(element.props);
54
229
  return addSkeleton(rendered);
55
230
  }
56
- if (TEXT_TAGS.includes(elementType)) {
57
- return createLeafNode(node, "Rss-skeleton-text");
231
+ const isTextTag = is_text_element_default(elementType);
232
+ if (isTextTag) {
233
+ return createLeafNode(element, CLASS_NAME, {
234
+ ...style,
235
+ margin: textTagsMargin
236
+ });
58
237
  }
59
238
  if (elementType === "img") {
60
- return createNodeWrapper(element);
239
+ return createNodeWrapper(element, CLASS_NAME, style);
61
240
  }
62
241
  if (hasChildren && isValidChildren) {
63
242
  const childWithSkeletons = React3.Children.map(children, addSkeleton);
@@ -66,35 +245,87 @@ function useAddSkelton() {
66
245
  children: childWithSkeletons
67
246
  });
68
247
  }
69
- return createLeafNode(element);
248
+ return createLeafNode(element, CLASS_NAME, style);
70
249
  };
71
250
  return addSkeleton;
72
251
  }
73
252
  var useAddSkelton_default = useAddSkelton;
74
253
 
75
254
  // src/components/SkeletonElement.tsx
76
- import { jsx } from "react/jsx-runtime";
77
- var SkeletonElement = ({
78
- children
79
- }) => {
80
- const addSkeleton = useAddSkelton_default();
81
- return /* @__PURE__ */ jsx("div", { className: "skeleton-container", children: React4.Children.map(children, (child) => addSkeleton(child)) });
255
+ var SkeletonElement = (props) => {
256
+ const { children, config } = props;
257
+ const addSkeleton = useAddSkelton_default(config);
258
+ return React4.Children.map(children, (child) => addSkeleton(child));
82
259
  };
83
260
  var SkeletonElement_default = SkeletonElement;
84
261
 
262
+ // src/context/SkeletonContext.tsx
263
+ import {
264
+ createContext,
265
+ useContext,
266
+ useMemo
267
+ } from "react";
268
+
269
+ // src/context/skeleton-config.ts
270
+ var defaultBackground = {
271
+ "animation-1": "#aeaeae",
272
+ "animation-2": "#e5e5e5",
273
+ "animation-3": "hsl(210, 20%, 90%)"
274
+ };
275
+ var defaultValues = {
276
+ animationSpeed: 3,
277
+ background: "#aeaeae",
278
+ border: "none",
279
+ borderRadius: "0",
280
+ textTagsMargin: "0",
281
+ className: "",
282
+ style: {},
283
+ animation: "animation-1",
284
+ exceptTags: [],
285
+ exceptTagGroups: []
286
+ };
287
+
288
+ // src/context/SkeletonContext.tsx
289
+ import { jsx } from "react/jsx-runtime";
290
+ var SkeletonContext = createContext(defaultValues);
291
+ var SkeletonProvider = (props) => {
292
+ const { children, config, style } = props;
293
+ const { animation = defaultValues.animation, background } = config || {};
294
+ const value = useMemo(
295
+ () => ({
296
+ ...defaultValues,
297
+ ...config,
298
+ background: background ? background : defaultBackground[animation],
299
+ style: { ...defaultValues.style, ...config == null ? void 0 : config.style, ...style }
300
+ }),
301
+ [animation, background, config, style]
302
+ );
303
+ return /* @__PURE__ */ jsx(SkeletonContext.Provider, { value, children });
304
+ };
305
+ var useSkeleton = () => useContext(SkeletonContext);
306
+
85
307
  // src/components/SkeletonWrapper.tsx
86
- import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
87
- var SkeletonWrapper = ({
88
- loading,
89
- children
90
- }) => {
308
+ import { jsx as jsx2 } from "react/jsx-runtime";
309
+ var SkeletonWrapper = (props) => {
310
+ const { loading, children, overrideConfig, style } = props;
311
+ const mainConfig = useSkeleton();
312
+ const config = useMemo2(
313
+ () => ({
314
+ ...mainConfig,
315
+ ...overrideConfig,
316
+ style: { ...mainConfig.style, ...overrideConfig == null ? void 0 : overrideConfig.style, ...style }
317
+ }),
318
+ [overrideConfig, mainConfig]
319
+ );
91
320
  if (loading) {
92
- return /* @__PURE__ */ jsx2(SkeletonElement_default, { children });
321
+ return /* @__PURE__ */ jsx2(SkeletonElement_default, { config, children });
93
322
  }
94
- return /* @__PURE__ */ jsx2(Fragment, { children });
323
+ return children;
95
324
  };
96
325
  var SkeletonWrapper_default = SkeletonWrapper;
97
326
  export {
98
- SkeletonWrapper_default as SkeletonWrapper
327
+ SkeletonProvider,
328
+ SkeletonWrapper_default as SkeletonWrapper,
329
+ useSkeleton
99
330
  };
100
331
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/SkeletonElement.tsx","../src/hooks/useAddSkelton.ts","../src/utils/create-node-wrapper.ts","../src/constants/tags.ts","../src/utils/create-leaf-node.ts","../src/components/SkeletonWrapper.tsx"],"sourcesContent":["import React from \"react\";\nimport useAddSkelton from \"../hooks/useAddSkelton\";\n\nconst SkeletonElement: React.FC<{ children: React.ReactNode }> = ({\n children,\n}) => {\n const addSkeleton = useAddSkelton();\n return (\n <div className=\"skeleton-container\">\n {React.Children.map(children, (child) => addSkeleton(child))}\n </div>\n );\n};\n\nexport default SkeletonElement;\n","import React from \"react\";\nimport createNodeWrapper from \"../utils/create-node-wrapper\";\nimport { TEXT_TAGS } from \"../constants/tags\";\nimport createLeafNode from \"../utils/create-leaf-node\";\n\nfunction useAddSkelton() {\n const addSkeleton = (node: React.ReactNode): React.ReactNode => {\n if (!React.isValidElement(node)) return createNodeWrapper(node as any);\n\n const element = node as React.ReactElement<any>;\n const { children } = element.props;\n const elementType = element.type;\n\n const hasChildren = React.Children.count(children) > 0;\n const isValidChildren = typeof children !== \"string\";\n\n if (typeof elementType === \"function\") {\n const rendered = (elementType as any)(element.props);\n return addSkeleton(rendered);\n }\n\n if (TEXT_TAGS.includes(elementType)) {\n return createLeafNode(node, \"Rss-skeleton-text\");\n }\n\n if (elementType === \"img\") {\n return createNodeWrapper(element);\n }\n\n if (hasChildren && isValidChildren) {\n const childWithSkeletons = React.Children.map(children, addSkeleton);\n\n return React.cloneElement(element, {\n ...element.props,\n children: childWithSkeletons,\n } as typeof element.props);\n }\n\n return createLeafNode(element);\n };\n\n return addSkeleton;\n}\n\nexport default useAddSkelton;\n","import React, { createElement } from \"react\";\n\nexport default function createNodeWrapper(node: React.ReactElement<any>) {\n if (!node) return null;\n\n return createElement(\n \"div\",\n {\n className: (node?.props?.className || \"\") + \" Rss-skeleton\",\n },\n node\n );\n}\n","export const TEXT_TAGS = [\n \"p\",\n \"span\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"li\",\n];\n","import React from \"react\";\n\nexport default function createLeafNode(\n node: React.ReactElement<any>,\n className: string = \"\"\n): React.ReactElement {\n return React.cloneElement(node, {\n ...node.props,\n className: (node.props.className || \"\") + \" Rss-skeleton \" + className,\n } as typeof node.props);\n}\n","import React from \"react\";\nimport SkeletonElement from \"./SkeletonElement\";\n\ninterface SkeletonWrapperProps {\n loading: boolean;\n children: React.ReactNode;\n}\n\nconst SkeletonWrapper: React.FC<SkeletonWrapperProps> = ({\n loading,\n children,\n}) => {\n if (loading) {\n return <SkeletonElement>{children}</SkeletonElement>;\n }\n return <>{children}</>;\n};\n\nexport default SkeletonWrapper;\n"],"mappings":";AAAA,OAAOA,YAAW;;;ACAlB,OAAOC,YAAW;;;ACAlB,SAAgB,qBAAqB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,WAAO,eAAe,OAAO;AAAA,EAC/B;AAEA,SAAO;AACT;AAEA,IAAO,wBAAQ;;;ADpCX;AALJ,IAAM,kBAA2D,CAAC;AAAA,EAChE;AACF,MAAM;AACJ,QAAM,cAAc,sBAAc;AAClC,SACE,oBAAC,SAAI,WAAU,sBACZ,UAAAC,OAAM,SAAS,IAAI,UAAU,CAAC,UAAU,YAAY,KAAK,CAAC,GAC7D;AAEJ;AAEA,IAAO,0BAAQ;;;AKDJ,SAEF,UAFE,OAAAC,YAAA;AALX,IAAM,kBAAkD,CAAC;AAAA,EACvD;AAAA,EACA;AACF,MAAM;AACJ,MAAI,SAAS;AACX,WAAO,gBAAAA,KAAC,2BAAiB,UAAS;AAAA,EACpC;AACA,SAAO,gBAAAA,KAAA,YAAG,UAAS;AACrB;AAEA,IAAO,0BAAQ;","names":["React","React","React","React","React","jsx"]}
1
+ {"version":3,"sources":["../src/components/SkeletonWrapper.tsx","../src/components/SkeletonElement.tsx","../src/hooks/useAddSkelton.ts","../src/utils/create-node-wrapper.ts","../src/utils/create-leaf-node.ts","../src/utils/create-style.ts","../src/constants/tags.ts","../src/utils/check-tag-in-group.ts","../src/utils/is-text-element.ts","../src/context/SkeletonContext.tsx","../src/context/skeleton-config.ts"],"sourcesContent":["import React, { CSSProperties, useMemo } from \"react\";\nimport SkeletonElement from \"./SkeletonElement\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\nimport { useSkeleton } from \"../context/SkeletonContext\";\n\ninterface SkeletonWrapperProps {\n loading: boolean;\n children: React.ReactNode;\n overrideConfig?: Partial<SkeletonConfig>;\n style?: CSSProperties;\n}\n\nconst SkeletonWrapper: React.FC<SkeletonWrapperProps> = (props) => {\n const { loading, children, overrideConfig, style } = props;\n const mainConfig = useSkeleton();\n\n const config: SkeletonConfig = useMemo(\n () => ({\n ...mainConfig,\n ...overrideConfig,\n style: { ...mainConfig.style, ...overrideConfig?.style, ...style },\n }),\n [overrideConfig, mainConfig]\n );\n\n if (loading) {\n return <SkeletonElement config={config}>{children}</SkeletonElement>;\n }\n return children;\n};\n\nexport default SkeletonWrapper;\n","import React from \"react\";\nimport useAddSkelton from \"../hooks/useAddSkelton\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\n\ninterface SkeletonElementProps {\n children: React.ReactNode;\n config: SkeletonConfig;\n}\n\nconst SkeletonElement: React.FC<SkeletonElementProps> = (props) => {\n const { children, config } = props;\n const addSkeleton = useAddSkelton(config);\n\n return React.Children.map(children, (child) => addSkeleton(child));\n};\n\nexport default SkeletonElement;\n","import React from \"react\";\nimport createNodeWrapper from \"../utils/create-node-wrapper\";\nimport createLeafNode from \"../utils/create-leaf-node\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\nimport createStyle from \"../utils/create-style\";\nimport checkTagInGroup from \"../utils/check-tag-in-group\";\nimport isTextElement from \"../utils/is-text-element\";\n\nfunction useAddSkelton(config: SkeletonConfig) {\n const { className, exceptTags, exceptTagGroups, textTagsMargin } = config;\n const CLASS_NAME = `react-skeletonify ${className} `;\n const style = createStyle(config);\n\n const addSkeleton = (node: React.ReactNode): React.ReactNode => {\n if (!React.isValidElement(node))\n return createNodeWrapper(node as any, CLASS_NAME, style);\n\n const element = node as React.ReactElement<any>;\n const { children } = element.props;\n const elementType = element.type;\n\n if (typeof elementType === \"string\") {\n if (exceptTags.includes(elementType)) {\n return element;\n }\n const isRestrictedGroupTag = checkTagInGroup(\n elementType,\n exceptTagGroups\n );\n\n if (isRestrictedGroupTag) return element;\n }\n\n const hasChildren = React.Children.count(children) > 0;\n const isValidChildren = typeof children !== \"string\";\n\n if (typeof elementType === \"function\") {\n const rendered = (elementType as any)(element.props);\n return addSkeleton(rendered);\n }\n\n const isTextTag = isTextElement(elementType);\n\n if (isTextTag) {\n return createLeafNode(element, CLASS_NAME, {\n ...style,\n margin: textTagsMargin,\n });\n }\n\n if (elementType === \"img\") {\n return createNodeWrapper(element, CLASS_NAME, style);\n }\n\n if (hasChildren && isValidChildren) {\n const childWithSkeletons = React.Children.map(children, addSkeleton);\n\n return React.cloneElement(element, {\n ...element.props,\n children: childWithSkeletons,\n } as typeof element.props);\n }\n\n return createLeafNode(element, CLASS_NAME, style);\n };\n\n return addSkeleton;\n}\n\nexport default useAddSkelton;\n","import React, { createElement, CSSProperties } from \"react\";\n\nexport default function createNodeWrapper(\n node: React.ReactElement<any>,\n className: string,\n style: CSSProperties\n) {\n if (!node) return null;\n\n return createElement(\n \"div\",\n {\n className: className + (node?.props?.className || \"\"),\n style: {\n ...style,\n ...node?.props?.style,\n },\n },\n node\n );\n}\n","import React, { CSSProperties } from \"react\";\n\nexport default function createLeafNode(\n node: React.ReactElement<any>,\n className: string,\n style: CSSProperties\n): React.ReactElement {\n return React.cloneElement(node, {\n ...node.props,\n className: className + (node.props.className || \"\"),\n style: {\n ...style,\n ...node.props.style,\n },\n } as typeof node.props);\n}\n","import { CSSProperties } from \"react\";\nimport { SkeletonConfig } from \"../context/skeleton-config\";\n\nconst getAnimation = (\n animation: string,\n animationSpeed: number,\n background: string\n) => {\n switch (animation) {\n case \"animation-1\":\n return {\n animation: `react-skeletonify-animation-1 ${animationSpeed}s ease-in-out infinite `,\n background: background,\n animationDelay: \"0.5s\",\n };\n case \"animation-2\":\n return {\n animation: `react-skeletonify-animation-2 ${animationSpeed}s infinite`,\n background: `linear-gradient(120deg, ${background} 30%, #f0f0f0 38%, #f0f0f0 40%, ${background} 48%)`,\n backgroundSize: \"200% 100%\",\n backgroundPosition: \"100% 0\",\n };\n case \"animation-3\":\n return {\n animation: `react-skeletonify-animation-3 ${animationSpeed}s linear infinite alternate`,\n backgroundColor: background,\n };\n }\n};\n\nexport default (config: SkeletonConfig) => {\n const { animationSpeed, background, border, borderRadius, animation, style } =\n config;\n\n const skeletonAnimation: CSSProperties = {\n ...getAnimation(animation, animationSpeed, background),\n border,\n borderRadius,\n ...style,\n };\n\n return skeletonAnimation;\n};\n","// --- Text & Content ---\nexport const TEXT_TAGS = [\n \"p\",\n \"span\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"b\",\n \"strong\",\n \"i\",\n \"em\",\n \"u\",\n \"mark\",\n \"small\",\n \"sup\",\n \"sub\",\n \"abbr\",\n \"cite\",\n \"q\",\n \"blockquote\",\n \"code\",\n \"pre\",\n \"samp\",\n \"kbd\",\n \"var\",\n \"time\",\n \"br\",\n \"wbr\",\n];\n\n// --- Sectioning / Structure ---\nexport const STRUCTURE_TAGS = [\n \"html\",\n \"head\",\n \"body\",\n \"main\",\n \"header\",\n \"footer\",\n \"nav\",\n \"section\",\n \"article\",\n \"aside\",\n];\n\n// --- Metadata ---\nexport const METADATA_TAGS = [\"base\", \"link\", \"meta\", \"style\", \"title\"];\n\n// --- Lists ---\nexport const LIST_TAGS = [\"ul\", \"ol\", \"li\", \"dl\", \"dt\", \"dd\"];\n\n// --- Tables ---\nexport const TABLE_TAGS = [\n \"table\",\n \"caption\",\n \"thead\",\n \"tbody\",\n \"tfoot\",\n \"tr\",\n \"th\",\n \"td\",\n \"col\",\n \"colgroup\",\n];\n\n// --- Forms & Inputs ---\nexport const FORM_TAGS = [\n \"form\",\n \"input\",\n \"textarea\",\n \"button\",\n \"label\",\n \"select\",\n \"option\",\n \"optgroup\",\n \"fieldset\",\n \"legend\",\n \"datalist\",\n \"output\",\n \"meter\",\n \"progress\",\n];\n\n// --- Media ---\nexport const MEDIA_TAGS = [\n \"img\",\n \"audio\",\n \"video\",\n \"source\",\n \"track\",\n \"picture\",\n \"iframe\",\n \"embed\",\n \"object\",\n \"map\",\n \"area\",\n \"canvas\",\n];\n\n// --- Interactive ---\nexport const INTERACTIVE_TAGS = [\n \"details\",\n \"summary\",\n \"dialog\",\n \"script\",\n \"noscript\",\n \"template\",\n];\n\n// --- Other / Inline semantics ---\nexport const MISC_TAGS = [\"ins\", \"del\", \"s\", \"bdi\", \"bdo\", \"ruby\", \"rt\", \"rp\"];\n","import {\n FORM_TAGS,\n INTERACTIVE_TAGS,\n LIST_TAGS,\n MEDIA_TAGS,\n METADATA_TAGS,\n MISC_TAGS,\n STRUCTURE_TAGS,\n TABLE_TAGS,\n TEXT_TAGS,\n} from \"../constants/tags\";\nimport { HtmlTagGroup } from \"../context/skeleton-config\";\n\nexport default function checkTagInGroup(\n tag: string,\n groups: HtmlTagGroup[]\n): boolean {\n return groups.some((group) => {\n switch (group) {\n case \"TEXT_TAGS\":\n return TEXT_TAGS.includes(tag);\n case \"STRUCTURE_TAGS\":\n return STRUCTURE_TAGS.includes(tag);\n case \"METADATA_TAGS\":\n return METADATA_TAGS.includes(tag);\n case \"LIST_TAGS\":\n return LIST_TAGS.includes(tag);\n case \"TABLE_TAGS\":\n return TABLE_TAGS.includes(tag);\n case \"FORM_TAGS\":\n return FORM_TAGS.includes(tag);\n case \"MEDIA_TAGS\":\n return MEDIA_TAGS.includes(tag);\n case \"INTERACTIVE_TAGS\":\n return INTERACTIVE_TAGS.includes(tag);\n case \"MISC_TAGS\":\n return MISC_TAGS.includes(tag);\n }\n });\n}\n","import { LIST_TAGS, TEXT_TAGS } from \"../constants/tags\";\n\nexport default (elementType: string) => {\n return TEXT_TAGS.includes(elementType) || LIST_TAGS.includes(elementType);\n};\n","import React, {\n createContext,\n CSSProperties,\n useContext,\n useMemo,\n} from \"react\";\nimport {\n SkeletonConfig,\n defaultBackground,\n defaultValues,\n} from \"./skeleton-config\";\n\nconst SkeletonContext = createContext<SkeletonConfig>(defaultValues);\ninterface SkeletonProviderProps {\n children: React.ReactNode;\n config?: Partial<SkeletonConfig>;\n style?: CSSProperties;\n}\n\nexport const SkeletonProvider: React.FC<SkeletonProviderProps> = (props) => {\n const { children, config, style } = props;\n const { animation = defaultValues.animation, background } = config || {};\n\n const value: SkeletonConfig = useMemo(\n () => ({\n ...defaultValues,\n ...config,\n background: background ? background : defaultBackground[animation],\n style: { ...defaultValues.style, ...config?.style, ...style },\n }),\n [animation, background, config, style]\n );\n\n return (\n <SkeletonContext.Provider value={value}>\n {children}\n </SkeletonContext.Provider>\n );\n};\n\nexport const useSkeleton = () => useContext(SkeletonContext);\n","import { CSSProperties } from \"react\";\n\nexport const HTML_TAG_GROUPS = [\n \"TEXT_TAGS\",\n \"STRUCTURE_TAGS\",\n \"METADATA_TAGS\",\n \"LIST_TAGS\",\n \"TABLE_TAGS\",\n \"FORM_TAGS\",\n \"MEDIA_TAGS\",\n \"INTERACTIVE_TAGS\",\n \"MISC_TAGS\",\n] as const;\n\nexport type HtmlTagGroup = (typeof HTML_TAG_GROUPS)[number];\n\nexport const defaultBackground = {\n \"animation-1\": \"#aeaeae\",\n \"animation-2\": \"#e5e5e5\",\n \"animation-3\": \"hsl(210, 20%, 90%)\",\n};\n\nexport type SkeletonConfig = {\n animationSpeed: number;\n background: string;\n border: string;\n borderRadius: string;\n textTagsMargin: string;\n className?: string;\n style?: CSSProperties;\n animation: \"animation-1\" | \"animation-2\";\n exceptTags: string[];\n exceptTagGroups: HtmlTagGroup[];\n};\n\nexport const defaultValues: SkeletonConfig = {\n animationSpeed: 3,\n background: \"#aeaeae\",\n border: \"none\",\n borderRadius: \"0\",\n textTagsMargin: \"0\",\n className: \"\",\n style: {},\n animation: \"animation-1\",\n exceptTags: [],\n exceptTagGroups: [],\n};\n"],"mappings":";AAAA,SAA+B,WAAAA,gBAAe;;;ACA9C,OAAOC,YAAW;;;ACAlB,OAAOC,YAAW;;;ACAlB,SAAgB,qBAAoC;AAErC,SAAR,kBACL,MACA,WACA,OACA;AANF;AAOE,MAAI,CAAC,KAAM,QAAO;AAElB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,WAAW,eAAa,kCAAM,UAAN,mBAAa,cAAa;AAAA,MAClD,OAAO;AAAA,QACL,GAAG;AAAA,QACH,IAAG,kCAAM,UAAN,mBAAa;AAAA,MAClB;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;;;ACpBA,OAAOC,YAA8B;AAEtB,SAAR,eACL,MACA,WACA,OACoB;AACpB,SAAOA,OAAM,aAAa,MAAM;AAAA,I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,gBAAgB,UAAhB,EAAyB,OACvB,UACH;AAEJ;AAEO,IAAM,cAAc,MAAM,WAAW,eAAe;;;ATdhD,gBAAAC,YAAA;AAdX,IAAM,kBAAkD,CAAC,UAAU;AACjE,QAAM,EAAE,SAAS,UAAU,gBAAgB,MAAM,IAAI;AACrD,QAAM,aAAa,YAAY;AAE/B,QAAM,SAAyBC;AAAA,IAC7B,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG;AAAA,MACH,OAAO,EAAE,GAAG,WAAW,OAAO,GAAG,iDAAgB,OAAO,GAAG,MAAM;AAAA,IACnE;AAAA,IACA,CAAC,gBAAgB,UAAU;AAAA,EAC7B;AAEA,MAAI,SAAS;AACX,WAAO,gBAAAD,KAAC,2BAAgB,QAAiB,UAAS;AAAA,EACpD;AACA,SAAO;AACT;AAEA,IAAO,0BAAQ;","names":["useMemo","React","React","React","React","React","jsx","useMemo"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-skeletonify",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "type": "git",
31
31
  "url": "https://github.com/Sinan0333/react-skeletonify"
32
32
  },
33
- "homepage": "https://github.com/Sinan0333/react-skeletonify#readme",
33
+ "homepage": "https://react-skeletonify.sinan-dev.in",
34
34
  "bugs": {
35
35
  "url": "https://github.com/Sinan0333/react-skeletonify/issues"
36
36
  },