skeleton-ghost-loader 2.3.0 → 2.6.0

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