skeleton-ghost-loader 1.0.0 → 2.0.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/README.md CHANGED
@@ -1,29 +1,26 @@
1
- # skeletonloader
1
+ # React Smart Skeleton 🦴
2
2
 
3
- A **Tailwind CSS–based, structure-preserving skeleton loader for React**.
3
+ A **smart skeleton loader** for React that automatically matches:
4
+ - inline styles
5
+ - class styles (including Tailwind)
6
+ - browser default styles
4
7
 
5
- `skeletonloader` automatically converts your existing JSX into skeleton placeholders **while keeping the exact layout and styling**, by reusing the same `className` (Tailwind utilities).
6
-
7
- ✅ No DOM measurement
8
- ✅ No layout shift
9
- ✅ SSR / Next.js safe
10
- ✅ Zero config
11
- ✅ Tailwind-native
8
+ No wrappers. No layout shift. Just add one prop.
12
9
 
13
10
  ---
14
11
 
15
12
  ## ✨ Features
16
13
 
17
- - 🧱 **Preserves structure** DOM tree stays the same
18
- - 🎨 **Uses Tailwind classes** – width, height, radius come from `className`
19
- - 🌗 **Dark mode support** – works with `dark:` utilities
20
- - **Disable animation** optional pulse control
21
- - **Skip skeleton** – exclude specific components
22
- - **Lightweight** no extra dependencies
14
+ Works with Vite, CRA, Next.js
15
+ Supports Tailwind CSS
16
+ Uses real computed browser styles
17
+ Text & box skeleton differentiation
18
+ Zero config
19
+ Tree traversal (deep children supported)
23
20
 
24
21
  ---
25
22
 
26
23
  ## 📦 Installation
27
24
 
28
25
  ```bash
29
- npm install skeletonloader
26
+ npm i skeleton-ghost-loader
@@ -0,0 +1,675 @@
1
+ import F from "react";
2
+ var Q = { exports: {} }, I = {};
3
+ /**
4
+ * @license React
5
+ * react-jsx-runtime.production.min.js
6
+ *
7
+ * Copyright (c) Facebook, Inc. and its affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ var we;
13
+ function dr() {
14
+ if (we) return I;
15
+ we = 1;
16
+ var h = F, E = Symbol.for("react.element"), d = Symbol.for("react.fragment"), f = Object.prototype.hasOwnProperty, a = h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, _ = { key: !0, ref: !0, __self: !0, __source: !0 };
17
+ function S(m, v, P) {
18
+ var y, T = {}, w = null, Y = null;
19
+ P !== void 0 && (w = "" + P), v.key !== void 0 && (w = "" + v.key), v.ref !== void 0 && (Y = v.ref);
20
+ for (y in v) f.call(v, y) && !_.hasOwnProperty(y) && (T[y] = v[y]);
21
+ if (m && m.defaultProps) for (y in v = m.defaultProps, v) T[y] === void 0 && (T[y] = v[y]);
22
+ return { $$typeof: E, type: m, key: w, ref: Y, props: T, _owner: a.current };
23
+ }
24
+ return I.Fragment = d, I.jsx = S, I.jsxs = S, I;
25
+ }
26
+ var W = {};
27
+ /**
28
+ * @license React
29
+ * react-jsx-runtime.development.js
30
+ *
31
+ * Copyright (c) Facebook, Inc. and its affiliates.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ */
36
+ var Oe;
37
+ function vr() {
38
+ return Oe || (Oe = 1, process.env.NODE_ENV !== "production" && function() {
39
+ var h = F, E = Symbol.for("react.element"), d = Symbol.for("react.portal"), f = Symbol.for("react.fragment"), a = Symbol.for("react.strict_mode"), _ = Symbol.for("react.profiler"), S = Symbol.for("react.provider"), m = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), Y = Symbol.for("react.offscreen"), ee = Symbol.iterator, Pe = "@@iterator";
40
+ function xe(e) {
41
+ if (e === null || typeof e != "object")
42
+ return null;
43
+ var r = ee && e[ee] || e[Pe];
44
+ return typeof r == "function" ? r : null;
45
+ }
46
+ var x = h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
+ function p(e) {
48
+ {
49
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
50
+ t[n - 1] = arguments[n];
51
+ je("error", e, t);
52
+ }
53
+ }
54
+ function je(e, r, t) {
55
+ {
56
+ var n = x.ReactDebugCurrentFrame, u = n.getStackAddendum();
57
+ u !== "" && (r += "%s", t = t.concat([u]));
58
+ var s = t.map(function(o) {
59
+ return String(o);
60
+ });
61
+ s.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, s);
62
+ }
63
+ }
64
+ var De = !1, Fe = !1, Ae = !1, $e = !1, Ie = !1, re;
65
+ re = Symbol.for("react.module.reference");
66
+ function We(e) {
67
+ return !!(typeof e == "string" || typeof e == "function" || e === f || e === _ || Ie || e === a || e === P || e === y || $e || e === Y || De || Fe || Ae || typeof e == "object" && e !== null && (e.$$typeof === w || e.$$typeof === T || e.$$typeof === S || e.$$typeof === m || e.$$typeof === v || // This needs to include all possible module reference object
68
+ // types supported by any Flight configuration anywhere since
69
+ // we don't know which Flight build this will end up being used
70
+ // with.
71
+ e.$$typeof === re || e.getModuleId !== void 0));
72
+ }
73
+ function Ye(e, r, t) {
74
+ var n = e.displayName;
75
+ if (n)
76
+ return n;
77
+ var u = r.displayName || r.name || "";
78
+ return u !== "" ? t + "(" + u + ")" : t;
79
+ }
80
+ function te(e) {
81
+ return e.displayName || "Context";
82
+ }
83
+ function C(e) {
84
+ if (e == null)
85
+ return null;
86
+ if (typeof e.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
87
+ return e.displayName || e.name || null;
88
+ if (typeof e == "string")
89
+ return e;
90
+ switch (e) {
91
+ case f:
92
+ return "Fragment";
93
+ case d:
94
+ return "Portal";
95
+ case _:
96
+ return "Profiler";
97
+ case a:
98
+ return "StrictMode";
99
+ case P:
100
+ return "Suspense";
101
+ case y:
102
+ return "SuspenseList";
103
+ }
104
+ if (typeof e == "object")
105
+ switch (e.$$typeof) {
106
+ case m:
107
+ var r = e;
108
+ return te(r) + ".Consumer";
109
+ case S:
110
+ var t = e;
111
+ return te(t._context) + ".Provider";
112
+ case v:
113
+ return Ye(e, e.render, "ForwardRef");
114
+ case T:
115
+ var n = e.displayName || null;
116
+ return n !== null ? n : C(e.type) || "Memo";
117
+ case w: {
118
+ var u = e, s = u._payload, o = u._init;
119
+ try {
120
+ return C(o(s));
121
+ } catch {
122
+ return null;
123
+ }
124
+ }
125
+ }
126
+ return null;
127
+ }
128
+ var O = Object.assign, A = 0, ne, ae, ie, oe, ue, se, le;
129
+ function ce() {
130
+ }
131
+ ce.__reactDisabledLog = !0;
132
+ function Ve() {
133
+ {
134
+ if (A === 0) {
135
+ ne = console.log, ae = console.info, ie = console.warn, oe = console.error, ue = console.group, se = console.groupCollapsed, le = console.groupEnd;
136
+ var e = {
137
+ configurable: !0,
138
+ enumerable: !0,
139
+ value: ce,
140
+ writable: !0
141
+ };
142
+ Object.defineProperties(console, {
143
+ info: e,
144
+ log: e,
145
+ warn: e,
146
+ error: e,
147
+ group: e,
148
+ groupCollapsed: e,
149
+ groupEnd: e
150
+ });
151
+ }
152
+ A++;
153
+ }
154
+ }
155
+ function Le() {
156
+ {
157
+ if (A--, A === 0) {
158
+ var e = {
159
+ configurable: !0,
160
+ enumerable: !0,
161
+ writable: !0
162
+ };
163
+ Object.defineProperties(console, {
164
+ log: O({}, e, {
165
+ value: ne
166
+ }),
167
+ info: O({}, e, {
168
+ value: ae
169
+ }),
170
+ warn: O({}, e, {
171
+ value: ie
172
+ }),
173
+ error: O({}, e, {
174
+ value: oe
175
+ }),
176
+ group: O({}, e, {
177
+ value: ue
178
+ }),
179
+ groupCollapsed: O({}, e, {
180
+ value: se
181
+ }),
182
+ groupEnd: O({}, e, {
183
+ value: le
184
+ })
185
+ });
186
+ }
187
+ A < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
188
+ }
189
+ }
190
+ var U = x.ReactCurrentDispatcher, B;
191
+ function V(e, r, t) {
192
+ {
193
+ if (B === void 0)
194
+ try {
195
+ throw Error();
196
+ } catch (u) {
197
+ var n = u.stack.trim().match(/\n( *(at )?)/);
198
+ B = n && n[1] || "";
199
+ }
200
+ return `
201
+ ` + B + e;
202
+ }
203
+ }
204
+ var z = !1, L;
205
+ {
206
+ var Me = typeof WeakMap == "function" ? WeakMap : Map;
207
+ L = new Me();
208
+ }
209
+ function fe(e, r) {
210
+ if (!e || z)
211
+ return "";
212
+ {
213
+ var t = L.get(e);
214
+ if (t !== void 0)
215
+ return t;
216
+ }
217
+ var n;
218
+ z = !0;
219
+ var u = Error.prepareStackTrace;
220
+ Error.prepareStackTrace = void 0;
221
+ var s;
222
+ s = U.current, U.current = null, Ve();
223
+ try {
224
+ if (r) {
225
+ var o = function() {
226
+ throw Error();
227
+ };
228
+ if (Object.defineProperty(o.prototype, "props", {
229
+ set: function() {
230
+ throw Error();
231
+ }
232
+ }), typeof Reflect == "object" && Reflect.construct) {
233
+ try {
234
+ Reflect.construct(o, []);
235
+ } catch (b) {
236
+ n = b;
237
+ }
238
+ Reflect.construct(e, [], o);
239
+ } else {
240
+ try {
241
+ o.call();
242
+ } catch (b) {
243
+ n = b;
244
+ }
245
+ e.call(o.prototype);
246
+ }
247
+ } else {
248
+ try {
249
+ throw Error();
250
+ } catch (b) {
251
+ n = b;
252
+ }
253
+ e();
254
+ }
255
+ } catch (b) {
256
+ if (b && n && typeof b.stack == "string") {
257
+ for (var i = b.stack.split(`
258
+ `), g = n.stack.split(`
259
+ `), l = i.length - 1, c = g.length - 1; l >= 1 && c >= 0 && i[l] !== g[c]; )
260
+ c--;
261
+ for (; l >= 1 && c >= 0; l--, c--)
262
+ if (i[l] !== g[c]) {
263
+ if (l !== 1 || c !== 1)
264
+ do
265
+ if (l--, c--, c < 0 || i[l] !== g[c]) {
266
+ var R = `
267
+ ` + i[l].replace(" at new ", " at ");
268
+ return e.displayName && R.includes("<anonymous>") && (R = R.replace("<anonymous>", e.displayName)), typeof e == "function" && L.set(e, R), R;
269
+ }
270
+ while (l >= 1 && c >= 0);
271
+ break;
272
+ }
273
+ }
274
+ } finally {
275
+ z = !1, U.current = s, Le(), Error.prepareStackTrace = u;
276
+ }
277
+ var D = e ? e.displayName || e.name : "", k = D ? V(D) : "";
278
+ return typeof e == "function" && L.set(e, k), k;
279
+ }
280
+ function Ne(e, r, t) {
281
+ return fe(e, !1);
282
+ }
283
+ function Ue(e) {
284
+ var r = e.prototype;
285
+ return !!(r && r.isReactComponent);
286
+ }
287
+ function M(e, r, t) {
288
+ if (e == null)
289
+ return "";
290
+ if (typeof e == "function")
291
+ return fe(e, Ue(e));
292
+ if (typeof e == "string")
293
+ return V(e);
294
+ switch (e) {
295
+ case P:
296
+ return V("Suspense");
297
+ case y:
298
+ return V("SuspenseList");
299
+ }
300
+ if (typeof e == "object")
301
+ switch (e.$$typeof) {
302
+ case v:
303
+ return Ne(e.render);
304
+ case T:
305
+ return M(e.type, r, t);
306
+ case w: {
307
+ var n = e, u = n._payload, s = n._init;
308
+ try {
309
+ return M(s(u), r, t);
310
+ } catch {
311
+ }
312
+ }
313
+ }
314
+ return "";
315
+ }
316
+ var $ = Object.prototype.hasOwnProperty, de = {}, ve = x.ReactDebugCurrentFrame;
317
+ function N(e) {
318
+ if (e) {
319
+ var r = e._owner, t = M(e.type, e._source, r ? r.type : null);
320
+ ve.setExtraStackFrame(t);
321
+ } else
322
+ ve.setExtraStackFrame(null);
323
+ }
324
+ function Be(e, r, t, n, u) {
325
+ {
326
+ var s = Function.call.bind($);
327
+ for (var o in e)
328
+ if (s(e, o)) {
329
+ var i = void 0;
330
+ try {
331
+ if (typeof e[o] != "function") {
332
+ var g = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
333
+ throw g.name = "Invariant Violation", g;
334
+ }
335
+ i = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
336
+ } catch (l) {
337
+ i = l;
338
+ }
339
+ i && !(i instanceof Error) && (N(u), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof i), N(null)), i instanceof Error && !(i.message in de) && (de[i.message] = !0, N(u), p("Failed %s type: %s", t, i.message), N(null));
340
+ }
341
+ }
342
+ }
343
+ var ze = Array.isArray;
344
+ function q(e) {
345
+ return ze(e);
346
+ }
347
+ function qe(e) {
348
+ {
349
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
350
+ return t;
351
+ }
352
+ }
353
+ function Je(e) {
354
+ try {
355
+ return pe(e), !1;
356
+ } catch {
357
+ return !0;
358
+ }
359
+ }
360
+ function pe(e) {
361
+ return "" + e;
362
+ }
363
+ function ge(e) {
364
+ if (Je(e))
365
+ return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", qe(e)), pe(e);
366
+ }
367
+ var he = x.ReactCurrentOwner, Ke = {
368
+ key: !0,
369
+ ref: !0,
370
+ __self: !0,
371
+ __source: !0
372
+ }, me, be;
373
+ function Ge(e) {
374
+ if ($.call(e, "ref")) {
375
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
376
+ if (r && r.isReactWarning)
377
+ return !1;
378
+ }
379
+ return e.ref !== void 0;
380
+ }
381
+ function Xe(e) {
382
+ if ($.call(e, "key")) {
383
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
384
+ if (r && r.isReactWarning)
385
+ return !1;
386
+ }
387
+ return e.key !== void 0;
388
+ }
389
+ function He(e, r) {
390
+ typeof e.ref == "string" && he.current;
391
+ }
392
+ function Ze(e, r) {
393
+ {
394
+ var t = function() {
395
+ me || (me = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
396
+ };
397
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
398
+ get: t,
399
+ configurable: !0
400
+ });
401
+ }
402
+ }
403
+ function Qe(e, r) {
404
+ {
405
+ var t = function() {
406
+ be || (be = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
407
+ };
408
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
409
+ get: t,
410
+ configurable: !0
411
+ });
412
+ }
413
+ }
414
+ var er = function(e, r, t, n, u, s, o) {
415
+ var i = {
416
+ // This tag allows us to uniquely identify this as a React Element
417
+ $$typeof: E,
418
+ // Built-in properties that belong on the element
419
+ type: e,
420
+ key: r,
421
+ ref: t,
422
+ props: o,
423
+ // Record the component responsible for creating this element.
424
+ _owner: s
425
+ };
426
+ return i._store = {}, Object.defineProperty(i._store, "validated", {
427
+ configurable: !1,
428
+ enumerable: !1,
429
+ writable: !0,
430
+ value: !1
431
+ }), Object.defineProperty(i, "_self", {
432
+ configurable: !1,
433
+ enumerable: !1,
434
+ writable: !1,
435
+ value: n
436
+ }), Object.defineProperty(i, "_source", {
437
+ configurable: !1,
438
+ enumerable: !1,
439
+ writable: !1,
440
+ value: u
441
+ }), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
442
+ };
443
+ function rr(e, r, t, n, u) {
444
+ {
445
+ var s, o = {}, i = null, g = null;
446
+ t !== void 0 && (ge(t), i = "" + t), Xe(r) && (ge(r.key), i = "" + r.key), Ge(r) && (g = r.ref, He(r, u));
447
+ for (s in r)
448
+ $.call(r, s) && !Ke.hasOwnProperty(s) && (o[s] = r[s]);
449
+ if (e && e.defaultProps) {
450
+ var l = e.defaultProps;
451
+ for (s in l)
452
+ o[s] === void 0 && (o[s] = l[s]);
453
+ }
454
+ if (i || g) {
455
+ var c = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
456
+ i && Ze(o, c), g && Qe(o, c);
457
+ }
458
+ return er(e, i, g, u, n, he.current, o);
459
+ }
460
+ }
461
+ var J = x.ReactCurrentOwner, ye = x.ReactDebugCurrentFrame;
462
+ function j(e) {
463
+ if (e) {
464
+ var r = e._owner, t = M(e.type, e._source, r ? r.type : null);
465
+ ye.setExtraStackFrame(t);
466
+ } else
467
+ ye.setExtraStackFrame(null);
468
+ }
469
+ var K;
470
+ K = !1;
471
+ function G(e) {
472
+ return typeof e == "object" && e !== null && e.$$typeof === E;
473
+ }
474
+ function Ee() {
475
+ {
476
+ if (J.current) {
477
+ var e = C(J.current.type);
478
+ if (e)
479
+ return `
480
+
481
+ Check the render method of \`` + e + "`.";
482
+ }
483
+ return "";
484
+ }
485
+ }
486
+ function tr(e) {
487
+ return "";
488
+ }
489
+ var Re = {};
490
+ function nr(e) {
491
+ {
492
+ var r = Ee();
493
+ if (!r) {
494
+ var t = typeof e == "string" ? e : e.displayName || e.name;
495
+ t && (r = `
496
+
497
+ Check the top-level render call using <` + t + ">.");
498
+ }
499
+ return r;
500
+ }
501
+ }
502
+ function _e(e, r) {
503
+ {
504
+ if (!e._store || e._store.validated || e.key != null)
505
+ return;
506
+ e._store.validated = !0;
507
+ var t = nr(r);
508
+ if (Re[t])
509
+ return;
510
+ Re[t] = !0;
511
+ var n = "";
512
+ e && e._owner && e._owner !== J.current && (n = " It was passed a child from " + C(e._owner.type) + "."), j(e), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), j(null);
513
+ }
514
+ }
515
+ function Te(e, r) {
516
+ {
517
+ if (typeof e != "object")
518
+ return;
519
+ if (q(e))
520
+ for (var t = 0; t < e.length; t++) {
521
+ var n = e[t];
522
+ G(n) && _e(n, r);
523
+ }
524
+ else if (G(e))
525
+ e._store && (e._store.validated = !0);
526
+ else if (e) {
527
+ var u = xe(e);
528
+ if (typeof u == "function" && u !== e.entries)
529
+ for (var s = u.call(e), o; !(o = s.next()).done; )
530
+ G(o.value) && _e(o.value, r);
531
+ }
532
+ }
533
+ }
534
+ function ar(e) {
535
+ {
536
+ var r = e.type;
537
+ if (r == null || typeof r == "string")
538
+ return;
539
+ var t;
540
+ if (typeof r == "function")
541
+ t = r.propTypes;
542
+ else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
543
+ // Inner props are checked in the reconciler.
544
+ r.$$typeof === T))
545
+ t = r.propTypes;
546
+ else
547
+ return;
548
+ if (t) {
549
+ var n = C(r);
550
+ Be(t, e.props, "prop", n, e);
551
+ } else if (r.PropTypes !== void 0 && !K) {
552
+ K = !0;
553
+ var u = C(r);
554
+ p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", u || "Unknown");
555
+ }
556
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
557
+ }
558
+ }
559
+ function ir(e) {
560
+ {
561
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
562
+ var n = r[t];
563
+ if (n !== "children" && n !== "key") {
564
+ j(e), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), j(null);
565
+ break;
566
+ }
567
+ }
568
+ e.ref !== null && (j(e), p("Invalid attribute `ref` supplied to `React.Fragment`."), j(null));
569
+ }
570
+ }
571
+ var Ce = {};
572
+ function Se(e, r, t, n, u, s) {
573
+ {
574
+ var o = We(e);
575
+ if (!o) {
576
+ var i = "";
577
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (i += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
578
+ var g = tr();
579
+ g ? i += g : i += Ee();
580
+ var l;
581
+ e === null ? l = "null" : q(e) ? l = "array" : e !== void 0 && e.$$typeof === E ? (l = "<" + (C(e.type) || "Unknown") + " />", i = " Did you accidentally export a JSX literal instead of a component?") : l = typeof e, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", l, i);
582
+ }
583
+ var c = rr(e, r, t, u, s);
584
+ if (c == null)
585
+ return c;
586
+ if (o) {
587
+ var R = r.children;
588
+ if (R !== void 0)
589
+ if (n)
590
+ if (q(R)) {
591
+ for (var D = 0; D < R.length; D++)
592
+ Te(R[D], e);
593
+ Object.freeze && Object.freeze(R);
594
+ } else
595
+ p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
596
+ else
597
+ Te(R, e);
598
+ }
599
+ if ($.call(r, "key")) {
600
+ var k = C(e), b = Object.keys(r).filter(function(fr) {
601
+ return fr !== "key";
602
+ }), X = b.length > 0 ? "{key: someKey, " + b.join(": ..., ") + ": ...}" : "{key: someKey}";
603
+ if (!Ce[k + X]) {
604
+ var cr = b.length > 0 ? "{" + b.join(": ..., ") + ": ...}" : "{}";
605
+ p(`A props object containing a "key" prop is being spread into JSX:
606
+ let props = %s;
607
+ <%s {...props} />
608
+ React keys must be passed directly to JSX without using spread:
609
+ let props = %s;
610
+ <%s key={someKey} {...props} />`, X, k, cr, k), Ce[k + X] = !0;
611
+ }
612
+ }
613
+ return e === f ? ir(c) : ar(c), c;
614
+ }
615
+ }
616
+ function or(e, r, t) {
617
+ return Se(e, r, t, !0);
618
+ }
619
+ function ur(e, r, t) {
620
+ return Se(e, r, t, !1);
621
+ }
622
+ var sr = ur, lr = or;
623
+ W.Fragment = f, W.jsx = sr, W.jsxs = lr;
624
+ }()), W;
625
+ }
626
+ process.env.NODE_ENV === "production" ? Q.exports = dr() : Q.exports = vr();
627
+ var H = Q.exports;
628
+ const ke = {
629
+ text: "#ccc",
630
+ box: "#e0e0e0"
631
+ }, Z = /* @__PURE__ */ new Map();
632
+ function pr(h) {
633
+ if (typeof document > "u") return {};
634
+ const E = typeof h.type == "string" ? h.type : "div", d = `${E}-${h.props.id || ""}-${h.props.className || ""}`;
635
+ if (Z.has(d)) return Z.get(d);
636
+ const f = document.createElement(E);
637
+ h.props.className && (f.className = h.props.className), h.props.id && (f.id = h.props.id), document.body.appendChild(f);
638
+ const a = window.getComputedStyle(f), _ = {
639
+ height: a.height,
640
+ width: a.width,
641
+ fontSize: a.fontSize,
642
+ margin: a.margin,
643
+ padding: a.padding,
644
+ borderRadius: a.borderRadius
645
+ };
646
+ return document.body.removeChild(f), Z.set(d, _), _;
647
+ }
648
+ function hr({ children: h }) {
649
+ function E(d) {
650
+ if (!F.isValidElement(d)) return d;
651
+ const f = { ...d.props }, a = { ...f.style };
652
+ if (f.skeletonrequired === !0) {
653
+ const _ = typeof d.type == "string" ? d.type : "div", S = ["p", "span", "h1", "h2", "h3", "h4", "h5", "h6"].includes(_), m = pr(d);
654
+ a.height || (a.height = m.height || "1em"), a.width || (a.width = m.width || "100%"), a.fontSize || (a.fontSize = m.fontSize), a.margin || (a.margin = m.margin || "0"), a.padding || (a.padding = m.padding || "0"), a.borderRadius || (a.borderRadius = m.borderRadius || "4px"), a.backgroundColor = S ? ke.text : ke.box, a.color = "transparent", a.backgroundImage = `linear-gradient(90deg, ${a.backgroundColor}, #f5f5f5, ${a.backgroundColor})`, a.backgroundSize = "200% 100%", a.animation = "skeleton-shimmer 1.4s infinite", delete f.skeletonrequired, f.style = a;
655
+ }
656
+ return typeof d.type == "function" ? E(d.type(f)) : F.cloneElement(
657
+ d,
658
+ f,
659
+ F.Children.map(d.props.children, E)
660
+ );
661
+ }
662
+ return /* @__PURE__ */ H.jsxs(H.Fragment, { children: [
663
+ /* @__PURE__ */ H.jsx("style", { children: `
664
+ @keyframes skeleton-shimmer {
665
+ 0% { background-position: -200% 0; }
666
+ 100% { background-position: 200% 0; }
667
+ }
668
+ ` }),
669
+ F.Children.map(h, E)
670
+ ] });
671
+ }
672
+ export {
673
+ hr as SkeletonBlock,
674
+ hr as default
675
+ };
@@ -0,0 +1,35 @@
1
+ (function(C,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],R):(C=typeof globalThis<"u"?globalThis:C||self,R(C.ReactSmartSkeleton={},C.React))})(this,function(C,R){"use strict";var B={exports:{}},$={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var re;function je(){if(re)return $;re=1;var h=R,E=Symbol.for("react.element"),d=Symbol.for("react.fragment"),c=Object.prototype.hasOwnProperty,a=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,T={key:!0,ref:!0,__self:!0,__source:!0};function O(m,v,j){var y,S={},k=null,M=null;j!==void 0&&(k=""+j),v.key!==void 0&&(k=""+v.key),v.ref!==void 0&&(M=v.ref);for(y in v)c.call(v,y)&&!T.hasOwnProperty(y)&&(S[y]=v[y]);if(m&&m.defaultProps)for(y in v=m.defaultProps,v)S[y]===void 0&&(S[y]=v[y]);return{$$typeof:E,type:m,key:k,ref:M,props:S,_owner:a.current}}return $.Fragment=d,$.jsx=O,$.jsxs=O,$}var I={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var te;function De(){return te||(te=1,process.env.NODE_ENV!=="production"&&function(){var h=R,E=Symbol.for("react.element"),d=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),m=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),M=Symbol.for("react.offscreen"),ie=Symbol.iterator,Ae="@@iterator";function $e(e){if(e===null||typeof e!="object")return null;var r=ie&&e[ie]||e[Ae];return typeof r=="function"?r:null}var D=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Ie("error",e,t)}}function Ie(e,r,t){{var n=D.ReactDebugCurrentFrame,u=n.getStackAddendum();u!==""&&(r+="%s",t=t.concat([u]));var s=t.map(function(o){return String(o)});s.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,s)}}var We=!1,Ye=!1,Me=!1,Ve=!1,Le=!1,oe;oe=Symbol.for("react.module.reference");function Ne(e){return!!(typeof e=="string"||typeof e=="function"||e===c||e===T||Le||e===a||e===j||e===y||Ve||e===M||We||Ye||Me||typeof e=="object"&&e!==null&&(e.$$typeof===k||e.$$typeof===S||e.$$typeof===O||e.$$typeof===m||e.$$typeof===v||e.$$typeof===oe||e.getModuleId!==void 0))}function Ue(e,r,t){var n=e.displayName;if(n)return n;var u=r.displayName||r.name||"";return u!==""?t+"("+u+")":t}function ue(e){return e.displayName||"Context"}function w(e){if(e==null)return null;if(typeof e.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case c:return"Fragment";case d:return"Portal";case T:return"Profiler";case a:return"StrictMode";case j:return"Suspense";case y:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case m:var r=e;return ue(r)+".Consumer";case O:var t=e;return ue(t._context)+".Provider";case v:return Ue(e,e.render,"ForwardRef");case S:var n=e.displayName||null;return n!==null?n:w(e.type)||"Memo";case k:{var u=e,s=u._payload,o=u._init;try{return w(o(s))}catch{return null}}}return null}var P=Object.assign,W=0,se,le,fe,ce,de,ve,pe;function ge(){}ge.__reactDisabledLog=!0;function Be(){{if(W===0){se=console.log,le=console.info,fe=console.warn,ce=console.error,de=console.group,ve=console.groupCollapsed,pe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ge,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}W++}}function qe(){{if(W--,W===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},e,{value:se}),info:P({},e,{value:le}),warn:P({},e,{value:fe}),error:P({},e,{value:ce}),group:P({},e,{value:de}),groupCollapsed:P({},e,{value:ve}),groupEnd:P({},e,{value:pe})})}W<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var J=D.ReactCurrentDispatcher,K;function V(e,r,t){{if(K===void 0)try{throw Error()}catch(u){var n=u.stack.trim().match(/\n( *(at )?)/);K=n&&n[1]||""}return`
18
+ `+K+e}}var G=!1,L;{var ze=typeof WeakMap=="function"?WeakMap:Map;L=new ze}function he(e,r){if(!e||G)return"";{var t=L.get(e);if(t!==void 0)return t}var n;G=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var s;s=J.current,J.current=null,Be();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(b){n=b}Reflect.construct(e,[],o)}else{try{o.call()}catch(b){n=b}e.call(o.prototype)}}else{try{throw Error()}catch(b){n=b}e()}}catch(b){if(b&&n&&typeof b.stack=="string"){for(var i=b.stack.split(`
19
+ `),g=n.stack.split(`
20
+ `),l=i.length-1,f=g.length-1;l>=1&&f>=0&&i[l]!==g[f];)f--;for(;l>=1&&f>=0;l--,f--)if(i[l]!==g[f]){if(l!==1||f!==1)do if(l--,f--,f<0||i[l]!==g[f]){var _=`
21
+ `+i[l].replace(" at new "," at ");return e.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",e.displayName)),typeof e=="function"&&L.set(e,_),_}while(l>=1&&f>=0);break}}}finally{G=!1,J.current=s,qe(),Error.prepareStackTrace=u}var A=e?e.displayName||e.name:"",x=A?V(A):"";return typeof e=="function"&&L.set(e,x),x}function Je(e,r,t){return he(e,!1)}function Ke(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function N(e,r,t){if(e==null)return"";if(typeof e=="function")return he(e,Ke(e));if(typeof e=="string")return V(e);switch(e){case j:return V("Suspense");case y:return V("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return Je(e.render);case S:return N(e.type,r,t);case k:{var n=e,u=n._payload,s=n._init;try{return N(s(u),r,t)}catch{}}}return""}var Y=Object.prototype.hasOwnProperty,me={},be=D.ReactDebugCurrentFrame;function U(e){if(e){var r=e._owner,t=N(e.type,e._source,r?r.type:null);be.setExtraStackFrame(t)}else be.setExtraStackFrame(null)}function Ge(e,r,t,n,u){{var s=Function.call.bind(Y);for(var o in e)if(s(e,o)){var i=void 0;try{if(typeof e[o]!="function"){var g=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw g.name="Invariant Violation",g}i=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(l){i=l}i&&!(i instanceof Error)&&(U(u),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof i),U(null)),i instanceof Error&&!(i.message in me)&&(me[i.message]=!0,U(u),p("Failed %s type: %s",t,i.message),U(null))}}}var Xe=Array.isArray;function X(e){return Xe(e)}function He(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Ze(e){try{return ye(e),!1}catch{return!0}}function ye(e){return""+e}function Ee(e){if(Ze(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",He(e)),ye(e)}var _e=D.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},Re,Te;function er(e){if(Y.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function rr(e){if(Y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function tr(e,r){typeof e.ref=="string"&&_e.current}function nr(e,r){{var t=function(){Re||(Re=!0,p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function ar(e,r){{var t=function(){Te||(Te=!0,p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ir=function(e,r,t,n,u,s,o){var i={$$typeof:E,type:e,key:r,ref:t,props:o,_owner:s};return i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function or(e,r,t,n,u){{var s,o={},i=null,g=null;t!==void 0&&(Ee(t),i=""+t),rr(r)&&(Ee(r.key),i=""+r.key),er(r)&&(g=r.ref,tr(r,u));for(s in r)Y.call(r,s)&&!Qe.hasOwnProperty(s)&&(o[s]=r[s]);if(e&&e.defaultProps){var l=e.defaultProps;for(s in l)o[s]===void 0&&(o[s]=l[s])}if(i||g){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;i&&nr(o,f),g&&ar(o,f)}return ir(e,i,g,u,n,_e.current,o)}}var H=D.ReactCurrentOwner,Se=D.ReactDebugCurrentFrame;function F(e){if(e){var r=e._owner,t=N(e.type,e._source,r?r.type:null);Se.setExtraStackFrame(t)}else Se.setExtraStackFrame(null)}var Z;Z=!1;function Q(e){return typeof e=="object"&&e!==null&&e.$$typeof===E}function Ce(){{if(H.current){var e=w(H.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function ur(e){return""}var we={};function sr(e){{var r=Ce();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
24
+
25
+ Check the top-level render call using <`+t+">.")}return r}}function Oe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=sr(r);if(we[t])return;we[t]=!0;var n="";e&&e._owner&&e._owner!==H.current&&(n=" It was passed a child from "+w(e._owner.type)+"."),F(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),F(null)}}function ke(e,r){{if(typeof e!="object")return;if(X(e))for(var t=0;t<e.length;t++){var n=e[t];Q(n)&&Oe(n,r)}else if(Q(e))e._store&&(e._store.validated=!0);else if(e){var u=$e(e);if(typeof u=="function"&&u!==e.entries)for(var s=u.call(e),o;!(o=s.next()).done;)Q(o.value)&&Oe(o.value,r)}}}function lr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===v||r.$$typeof===S))t=r.propTypes;else return;if(t){var n=w(r);Ge(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!Z){Z=!0;var u=w(r);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function fr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){F(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),F(null);break}}e.ref!==null&&(F(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),F(null))}}var Pe={};function xe(e,r,t,n,u,s){{var o=Ne(e);if(!o){var i="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(i+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var g=ur();g?i+=g:i+=Ce();var l;e===null?l="null":X(e)?l="array":e!==void 0&&e.$$typeof===E?(l="<"+(w(e.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):l=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",l,i)}var f=or(e,r,t,u,s);if(f==null)return f;if(o){var _=r.children;if(_!==void 0)if(n)if(X(_)){for(var A=0;A<_.length;A++)ke(_[A],e);Object.freeze&&Object.freeze(_)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ke(_,e)}if(Y.call(r,"key")){var x=w(e),b=Object.keys(r).filter(function(hr){return hr!=="key"}),ee=b.length>0?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}";if(!Pe[x+ee]){var gr=b.length>0?"{"+b.join(": ..., ")+": ...}":"{}";p(`A props object containing a "key" prop is being spread into JSX:
26
+ let props = %s;
27
+ <%s {...props} />
28
+ React keys must be passed directly to JSX without using spread:
29
+ let props = %s;
30
+ <%s key={someKey} {...props} />`,ee,x,gr,x),Pe[x+ee]=!0}}return e===c?fr(f):lr(f),f}}function cr(e,r,t){return xe(e,r,t,!0)}function dr(e,r,t){return xe(e,r,t,!1)}var vr=dr,pr=cr;I.Fragment=c,I.jsx=vr,I.jsxs=pr}()),I}process.env.NODE_ENV==="production"?B.exports=je():B.exports=De();var q=B.exports;const ne={text:"#ccc",box:"#e0e0e0"},z=new Map;function Fe(h){if(typeof document>"u")return{};const E=typeof h.type=="string"?h.type:"div",d=`${E}-${h.props.id||""}-${h.props.className||""}`;if(z.has(d))return z.get(d);const c=document.createElement(E);h.props.className&&(c.className=h.props.className),h.props.id&&(c.id=h.props.id),document.body.appendChild(c);const a=window.getComputedStyle(c),T={height:a.height,width:a.width,fontSize:a.fontSize,margin:a.margin,padding:a.padding,borderRadius:a.borderRadius};return document.body.removeChild(c),z.set(d,T),T}function ae({children:h}){function E(d){if(!R.isValidElement(d))return d;const c={...d.props},a={...c.style};if(c.skeletonrequired===!0){const T=typeof d.type=="string"?d.type:"div",O=["p","span","h1","h2","h3","h4","h5","h6"].includes(T),m=Fe(d);a.height||(a.height=m.height||"1em"),a.width||(a.width=m.width||"100%"),a.fontSize||(a.fontSize=m.fontSize),a.margin||(a.margin=m.margin||"0"),a.padding||(a.padding=m.padding||"0"),a.borderRadius||(a.borderRadius=m.borderRadius||"4px"),a.backgroundColor=O?ne.text:ne.box,a.color="transparent",a.backgroundImage=`linear-gradient(90deg, ${a.backgroundColor}, #f5f5f5, ${a.backgroundColor})`,a.backgroundSize="200% 100%",a.animation="skeleton-shimmer 1.4s infinite",delete c.skeletonrequired,c.style=a}return typeof d.type=="function"?E(d.type(c)):R.cloneElement(d,c,R.Children.map(d.props.children,E))}return q.jsxs(q.Fragment,{children:[q.jsx("style",{children:`
31
+ @keyframes skeleton-shimmer {
32
+ 0% { background-position: -200% 0; }
33
+ 100% { background-position: 200% 0; }
34
+ }
35
+ `}),R.Children.map(h,E)]})}C.SkeletonBlock=ae,C.default=ae,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,22 +1,33 @@
1
1
  {
2
2
  "name": "skeleton-ghost-loader",
3
- "version": "1.0.0",
4
- "description": "Tailwind-based structure preserving skeleton loader for React",
5
- "main": "index.js",
3
+ "version": "2.0.5",
4
+ "description": "Smart skeleton loader that auto-detects styles (inline, class, Tailwind, browser defaults)",
5
+ "author": "Shubh Patil",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "dist/skeleton-loader.umd.js",
9
+ "module": "dist/skeleton-loader.es.js",
10
+ "types": "types/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/skeleton-loader.es.js",
14
+ "require": "./dist/skeleton-loader.umd.js",
15
+ "types": "./types/index.d.ts"
16
+ }
17
+ },
6
18
  "files": [
7
- "index.js",
8
- "src"
19
+ "dist",
20
+ "types"
9
21
  ],
10
- "keywords": [
11
- "react",
12
- "skeleton",
13
- "tailwind",
14
- "loader",
15
- "ui"
16
- ],
17
- "license": "ISC",
22
+ "scripts": {
23
+ "build": "vite build"
24
+ },
18
25
  "peerDependencies": {
19
- "react": ">=16.8",
20
- "react-dom": ">=16.8"
26
+ "react": "^18.0.0",
27
+ "react-dom": "^18.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "vite": "^5.0.0",
31
+ "@vitejs/plugin-react": "^4.0.0"
21
32
  }
22
33
  }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+
3
+ export interface SkeletonBlockProps {
4
+ children: React.ReactNode;
5
+ }
6
+
7
+ declare const SkeletonBlock: React.FC<SkeletonBlockProps>;
8
+ export default SkeletonBlock;
9
+ export { SkeletonBlock };
package/index.js DELETED
@@ -1 +0,0 @@
1
- export { default } from "./src";
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- import { replaceWithSkeleton } from "../utils/replaceWithSkeleton";
3
- import Skip from "./Skip";
4
-
5
- const Skeleton = ({ loading, children, pulse = true }) => {
6
- if (!loading) return children;
7
-
8
- return (
9
- <>
10
- {replaceWithSkeleton(children, { pulse })}
11
- </>
12
- );
13
- };
14
-
15
-
16
- Skeleton.Skip = Skip;
17
-
18
- export default Skeleton;
@@ -1,17 +0,0 @@
1
- import React from "react";
2
-
3
- const SkeletonItem = ({ className = "", pulse }) => {
4
- return (
5
- <div
6
- aria-hidden="true"
7
- className={`
8
- ${className}
9
- bg-gray-200 dark:bg-gray-700
10
- rounded
11
- ${pulse ? "animate-pulse" : ""}
12
- `}
13
- />
14
- );
15
- };
16
-
17
- export default SkeletonItem;
@@ -1,7 +0,0 @@
1
- const Skip = ({ children }) => {
2
- return children;
3
- };
4
-
5
- Skip.displayName = "SkeletonSkip";
6
-
7
- export default Skip;
package/src/index.js DELETED
@@ -1,3 +0,0 @@
1
- import Skeleton from "./components/Skeleton";
2
-
3
- export default Skeleton;
@@ -1,44 +0,0 @@
1
- import React from "react";
2
- import SkeletonItem from "../components/SkeletonItem";
3
-
4
- export function replaceWithSkeleton(node, options) {
5
- const { pulse } = options;
6
-
7
- // Text node
8
- if (typeof node === "string" || typeof node === "number") {
9
- return (
10
- <div
11
- className={`h-4 w-full rounded bg-gray-200 dark:bg-gray-700 ${
12
- pulse ? "animate-pulse" : ""
13
- }`}
14
- />
15
- );
16
- }
17
-
18
- if (!React.isValidElement(node)) return node;
19
-
20
- // Skip skeleton
21
- if (node.type?.displayName === "SkeletonSkip") {
22
- return node.props.children;
23
- }
24
-
25
- const { className = "", children } = node.props;
26
-
27
- // Leaf node
28
- if (!children) {
29
- return (
30
- <SkeletonItem
31
- className={className}
32
- pulse={pulse}
33
- />
34
- );
35
- }
36
-
37
- // Container node
38
- return React.cloneElement(node, {
39
- className,
40
- children: React.Children.map(children, (child) =>
41
- replaceWithSkeleton(child, options)
42
- ),
43
- });
44
- }